Community
Participate
Working Groups
After doing a full rebuild (Project -> Clean) on a project containing an annotation and a class where the annotation is used, the annotation is not available at runtime. Doing a change to the class where it is used and saving the class to force a recompile makes the annotation visible again. Tested with I20041207 and I20041214.
Created attachment 16589 [details] Two classes which demonstrate the problem. Here are an annotation class and a main class which uses the annotation and checks for its existence at runtime.
Kent, can you please investigate ? (it looks like a full build produces a different class file then an incremental build)
Issue is likely in Olivier's hands where the classfile is misgenerated, and thus misbehaving when compiled agasint, as opposed to when compiled against sources directly (fullbuild case).
I will investigate.
The problem comes from the fact that in full build, the method setFoo is generated before the tagBits for Ann are set. Therefore it is too late to find out that the retention is RUNTIME.
When Main is compiled against the binary type Ann, then it works fine, because the tagBits for a binary type are set when the classfile reader initializes the structure of Ann. If the two types are defined in the same CU, then it also works because all types are resolved before the code generation is done. So to fix it the source type binding should set it tagBits during its construction. Kent, do you think this is doable?
Created attachment 16609 [details] Apply on org.eclipse.jdt.core.tests.compiler in HEAD Adds two tests that checks it works with binary types (test101), but it does not work with source types in two different files (test100).
Should hook annotations resolution into #completeTypeBindings stage. Should invoke: ASTNode.resolveAnnotations(...) using a blockscope (see current senders) Should only be done once hierarchies got connected. Note that this will resolve entire annotations during #completeTypeBindings stage, including initialization expressions carried by attributes, which is not the purpose of this stage. Problem is that if not resolving these, then we cannot compute the proper annotation tagBits. We could only resolve the ones we care about at this stage, and defer the full resolution until the AST is resolved (as currently).
Regression tests are: AnnotationTest#test102-103. Implemented an alternate solution allowing to lazily resolve the forward annotation reference. Clients are now using #getAnnotationTagBits() instead of directly reading field: tagBits (for TypeBinding). This uses same approach as field constant lazy computation.
Fixed
Verified in 200412160010