-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
I'm creating a class, called Outer, and an inner class inside it, called Inner.
I'm then using the inner class as a generic parameter of an anonymous class in another class in the same package.
The result is that in the generic parameter the inner class is written unqualified and not imported, resulting in a compile error.
Here is an example code
JCodeModel cm = new JCodeModel();
JDefinedClass outerClass = cm._class("test.Outer");
JDefinedClass innerClass = outerClass._class("Inner");
JDefinedClass testClass = cm._class("test.Test");
JAnonymousClass anonymousClass = cm.anonymousClass(cm.ref(List.class).narrow(innerClass));
testClass.field(0, cm.ref(List.class).narrow(innerClass), "field", JExpr._new(anonymousClass));And this is the result
package test;
import java.util.List;
public class Test {
List<Outer.Inner> field = new List<Inner>() {
}
;
}The declaration List<Outer.Inner> field is correct, but the instantiation new List<Inner> is not.