| Summary: | Missing annotations in binary dependencies cause "cannot be resolved" error | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Ed Costello <edward.costello> | ||||
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | amj87.iitr, edward.costello, hello | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | All | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
|
Description
Ed Costello
(In reply to comment #0) > Build Identifier: 20090619-0625 > My understanding is that annotations are supposed to be dropped from the class > file if the annotation class isn't present. So this should be a warning at > most. Do you have a ready reference backing this observation ? > Reproducible: Always I can believe we have/had a problem here (as we have had similar issues related to overload method resolution requiring somewhat "deeper" processing than what would seemingly appear needed) I presume the exact same setup compiles fine with javac ? I am having some trouble reproducing this. Could you please attach a (small) test case ? Thanks. Alternatively could you test with 3.6 or 3.5.2 (the former is a year later than the version you have (2010 Jun as opposed to 2009 Jun). Several bugs have been resolved in this area: most notably https://bugs.eclipse.org/bugs/show_bug.cgi?id=293443 https://bugs.eclipse.org/bugs/show_bug.cgi?id=283687 https://bugs.eclipse.org/bugs/show_bug.cgi?id=278745 https://bugs.eclipse.org/bugs/show_bug.cgi?id=283403 https://bugs.eclipse.org/bugs/show_bug.cgi?id=280410 https://bugs.eclipse.org/bugs/show_bug.cgi?id=275471 (In reply to comment #1) > Alternatively could you test with 3.6 or 3.5.2 (the former is > a year later than the version you have (2010 Jun as opposed to > 2009 Jun). I would request that you test with 3.6, I didn't verify that all of the bugs I had cited as having been fixed since 3.5 went into 3.5.2, but they surely did in 3.6 stream. Alternately, if you can provide a small test case I can verify. Thanks. Created attachment 178110 [details] Standalone Reproduction of Issues I've reproduced this in isolation and it is a more complex scenario than I origionally thought. I'm also not entirely sure it's a bug but there is an inconsistency between the javac compiler & the eclipse compiler. There are 3 scenarios tested here, all are different variants of a missing class retention annotation. All scenarios are based on different annotation definitions and usages within the ExampleLibrary project, while any errors occur in the other projects which use classes from this "library" ----------------------------------------------------------------- Scenario 1: Class Retention annotation with no elements annotating a Class (UseTheAnnotatedClassWithoutEnum) A library class (ClassUsingAnnotationWithoutEnum) is annotated with a Class Retention annotation which has no fields (ClassRetentionAnnotationWithoutEnum). This class is then used in another project (UseTheAnnotatedClassWithoutEnum) which has the library class on the class-path but not the annotation. Eclipse Behavior: Compiles fine, no errors or warnings Javac Behaviour: Compiles fine, no errors or warnings ----------------------------------------------------------------- Scenario 2: Class Retention annotation with enum element annotating a Class (UseTheAnnotatedClassWithEnum) A library class (ClassUsingAnnotationWithEnum) is annotated with a Class Retention annotation which has a field that is an enumerated type (ClassRetentionAnnotationWithEnum). This class is then used in another project (UseTheAnnotatedClassWithEnum) which has the library class on the class-path but not the annotation or the enumeration referenced by the enumeration. Eclipse Behavior: Viewing the java source for the using class (ClassUsingAnnotatedClassWithEnum) displays the error "The type com.example.annotation.definition.AnEnumeration cannot be resolved. It is indirectly referenced from required .class files" but this does not show up on the problems view, appear as an overlay or apparently prevent compilation. This error does interfere with auto-complete, refactoring and other such operations. Javac Behaviour: Compiler issues a warning and then crashes with an error (not a syntax error) com/example/annotated/clz/ClassUsingAnnotationWithEnum.class(com/example/annotated/clz:ClassUsingAnnotationWithEnum.class): warning: Cannot find annotation method 'value()' in type 'com.example.annotation.definition.ClassRetentionAnnotationWithEnum': class file for com.example.annotation.definition.ClassRetentionAnnotationWithEnum not found An exception has occurred in the compiler (1.6.0_20). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you. com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.example.annotation.definition.AnEnumeration not found ----------------------------------------------------------------- Scenario 3: Class Retention annotation with enum element annotating a Package (UseTheAnnotatedPackage) A library class (ClassInAnnotatedPackage) exists in a package (com.example.annotated.pkg) which is annotated with a Class Retention annotation which has an enum type field (ClassRetentionAnnotationWithEnum). This class is then used in another project (UseTheAnnotatedPackage) which has the library class on the class-path but not the annotation or enumeration used by the annotation. Eclipse Behavior: Viewing the java source for the using class (ClassUsingClassInAnnotatedPackage) displays the error "The type com.example.annotation.definition.AnEnumeration cannot be resolved. It is indirectly referenced from required .class files" but this does not show up on the problems view, appear as an overlay or apparently prevent compilation. This error does interfere with auto-complete, refactoring and other such operations. Javac Behaviour: Compiles fine, no errors or warnings ----------------------------------------------------------------- The javac behaviour for scenario 2 appears to be: http://bugs.sun.com/view_bug.do?bug_id=6550655 though that is using runtime retention annotations rather than class retention. ----------------------------------------------------------------- The attached RuntimeRetentionCompilerBehaviourExample.tar.bz2 contains 4 projects which can be imported into an eclipse workspace. ExampleLibrary - contains the annotation definitions and classes & packages annotated with these annotations. This also contains ExampleLibrary.jardesc which creates a jar containing the compiled classes but excludes the annotations. The other 3 projects illustrate the 3 scenarios above. These depend on the compiled jar rather than the ExampleLibrary project to ensure only the classes are available. In addition there is an ant build.xml file which demonstrates the behaviour of javac for these cases. This can be tested by running the demonstrate target. > Do you have a ready reference backing this observation ? I've been unable to find this specified anywhere, however it is the observed behavior of both sun javac, java runtime and the eclipse compiler. As noted above the original issue description is wrong, the annotations are being silently dropped, it's the enumeration referenced by the annotation which is causing the issues. > I would request that you test with 3.6, I didn't verify that all of the bugs I had cited as having been fixed since 3.5 went into 3.5.2, but they surely did in 3.6 stream. This occurs in both 3.5 and 3.6. And the attached test case will replicate in both. However as stated it's a more complex case than originally reported. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |