Community
Participate
Working Groups
BETA_JAVA8: ---------- Per discussions in the EG list, the spec is being amended to require a target_type=CLASS_EXTENDS type annotation for the following case: This is apart from the target_type=NEW type annotation which we already emit. Note that the reference compiler already emits the CLASS_EXTENDS type annotation, but not the NEW target type annotation, a bug has been raised against javac for this purpose. // --- @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE_USE) @interface X {} class C { void m() { new @X Foo() {}; } } // -- From the EG discussion: ... The wording for target_type=CLASS_EXTENDS (0x10) refers to a "type in extends clause of class or interface declaration" so it's not clear that the @X annotation should be stored this way. To clarify, the wording for target_type=CLASS_EXTENDS should say: "type in extends clause of class or interface declaration (including the direct superclass of an anonymous class declaration), ..." ...
Andy, please take a look, TIA.
We should remember to check to do the right thing for the case below where an interface is implemented by the anonymous class. interface I { void f(); } public class X { void foo() { I i = new I () { public void f() { } }; } }
Created attachment 236025 [details] Fix and tests Two tests: one for the class case, one for the interface case. The fix here is to ensure we don't lose the annotated type reference object, by attaching it to the generated type declaration for the anonymous usage. If attached correctly the type annotation generator will just do the right thing (which is why there are only 3 lines of change to make it work here).
Fix is good, released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=5ecdad70bb6e2e1bbd5c5ec539acc885a5698c4e. Thanks a lot Andy.
Patch looks good. Released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=5ecdad70bb6e2e1bbd5c5ec539acc885a5698c4e. Thanks Andy.
Third attempt at resolving...