Bug 144 - Anonymous classes sometimes need extra annotations
Anonymous classes sometimes need extra annotations
Product: loci
Classification: Unclassified
Component: Loci plugin
PC All
: P2 enhancement
: ---
Assigned To: amanjpro
Depends on:
  Show dependency treegraph
Reported: 2011-03-18 20:59 UTC by amanjpro
Modified: 2011-03-18 21:19 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description amanjpro 2011-03-18 20:59:14 UTC

Sometimes, when you have an anonymous class, and it has an implicit annotation
other than @Owner, you might need to add the right
annotation explicitly to prevent Loci from producing false reports.
for example:

abstract class A{

@Shared class B{
   Object method(){
      return null;

   void m1(){
       A a = new @Shared A(){ //We need to put this annotation, even though it
                              // should be obvious in Loci’s eyes, that this
                              // class should be @Shared as it is located
                              // in an @Shared class to prevent Loci from
                              // producing an error in the line
                              // (Object b = new method();)
            public m(){
               Object b = method();


abstract class A{
    A(A b, @Shared Object k){}
    public abstract A m();
    public static A getA(){
       return null;

public class ClassTest{
    void m(A b){
       @Shared A dd = b.getA();
       dd = new @Shared A(dd, b.getA()){ 
                    //Even though, Loci should automatically detect
                    // the implicit annotation here, it fails.
                    // Unfortunately, that is because, Loci expects the
                    // called constructor to be inside the anonymous class
                    // and fails to fetch the correct constructor element
(which is
                    // practically inherited from the abstract class A)
            public A m(){return null;}
Comment 1 amanjpro 2011-03-18 20:59:43 UTC
We are aware about this problem, and working on it. Until the fix arrived,
unfortunately you have to provide the extra annotation.