| Summary: | [1.8][compiler] Type annotations on class declaration go vanishing | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Component: | Core | Assignee: | Andrew Clement <aclement> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | stephan.herrmann | ||||
| Version: | 4.4 | Flags: | srikanth_sankaran:
review+
|
||||
| Target Milestone: | BETA J8 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 409235 | ||||||
| Attachments: |
|
||||||
Regression test available via: org.eclipse.jdt.core.tests.compiler.regression.JSR308SpecSnippetTests.test030() Created attachment 234666 [details]
fix and tests
Fixes the issue and adds a couple more test variants. The change is in ClassFile where runtime annotations are generated I added a parameter to indicate if type use annotations should be included (like in the 'special case' here where they should be). The code does not verify that TYPE_USE is specified and not TYPE_PARAMETER because that check will have been done sooner - so if we reach the code generation point we know it is valid and simply checking whether it is a type annotation is sufficient.
may want to apply after the patch on bug 415399 to reduce chance of merge conflicts. This contribution complies with http://www.eclipse.org/legal/CoO.php Fix looks good. Fix and tests released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=e002812d8385bfcab83bbcee92fbb80489aadeb5 (In reply to comment #5) > Fix looks good. Fix and tests released here: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?h=BETA_JAVA8&id=e002812d8385bfcab83bbcee92fbb80489aadeb5 Starting with this commit I see regressions in NegativeTypeAnnotationTest#test392119b ff. Is it just me seeing this (perhaps because I'm still on b92)? Should these tests simply be adjusted? (In reply to comment #6) > (In reply to comment #5) > > Fix looks good. Fix and tests released here: > > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > > ?h=BETA_JAVA8&id=e002812d8385bfcab83bbcee92fbb80489aadeb5 > > Starting with this commit I see regressions in > NegativeTypeAnnotationTest#test392119b ff. > > Is it just me seeing this (perhaps because I'm still on b92)? > Should these tests simply be adjusted? Fixed via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=f5abb716de8ce6d7aaee3cf06a3285e91953dad7. The behavior was correct, the tests hadn't been updated to account for new behavior. Andy, please make sure RunAllJava8Tests is green before posting patches. Sorry, I had got into the lazy habit of running the JSR308 snippet tests and my type annotation tests, won't happen again. |
BETA_JAVA8: When the following program is compiled: // -- import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; @Target({TYPE_USE}) @interface TypeAnnotation { } @Target({TYPE}) @interface Annotation { } @Annotation @TypeAnnotation class X { } // -- @TypeAnnotation does not seem to make it to the class file. JSR308, section 2.3 expressly allows such usage. Excerpt: "A type annotation (one meta-annotated with @Target(ElementType.TYPE USE)) is permitted to be written anywhere @Target(ElementType.TYPE) or @Target(ElementType.TYPE PARAMETER) would permit—that is, on a class, interface, or enum declaration, or on a type parameter declaration. Strictly speaking, these are declaration sites, not uses of a type. However, it is convenient to write a type annotation at a type declaration, as shorthand for applying it at all uses. For example, @Interned class MyClass { ... } could indicate that all uses of MyClass are interned, even though for other classes some instances may be interned and other instances not interned."