3 Replies Latest reply: Jun 1, 2010 8:40 AM by Vlastimil Eliáš RSS

CtClass getNestedClasses() returns the same class when applied to an anonymous class

Dam Dam Newbie

Hello everyone,

 

I think I have found a bug using CtClass.getNestedClasses(). When I apply this method to a CtClass which is an anonymous class, like "com.bla.MyClass$1", it returns the array with the same class as its first element : "com.bla.MyClass$1".

 

Is this a bug, or am I missing something ? I think it shouldn't return nothing.

 

 

ClassPool pool = ClassPool.getDefault();
try{
    CtClass c = pool.get("com.bla.MyClass$1");
    System.out.println(c.getName());
    CtClass[]arr= c.getNestedClasses();
    for(int i = 0; i < arr.length;i++){
        System.out.println(arr[i].getName());
    }
}
catch(NotFoundException nfe){
    nfe.printStackTrace();
}

 

The result :

 

com.bla.MyClass$1

com.bla.MyClass$1

 

 

Thanks for the replies,

Dam.