Community
Participate
Working Groups
Using RC2, the positions for the local variable are wrong. They include the javadoc positions. They should start on the final keyword. public class Y { public static void foo(Object object) { /** * javadoc comment. */ if (object instanceof ClassLoader) { final String s = null; } } }
The problem comes from the fact that we consider javadoc inside method bodies. This has a side-effect on the local variable declaration because this is changing the modifierSourceStart. So any local that has a modifier (likely final) can potentially have bad positions if a javadoc comment is within the same method.
Created attachment 23090 [details] Proposed fix The only side-effect of this fix is that local classes within a method don't include the preceeding javadoc if any. They are considered as a statement (indeed they are a type declaration statement). Method declarations inside these local classes keep their javadoc if any. I don't break any existing JDT/Core DOM/AST tests with this patch. It would need to be reviewed.
Created attachment 23091 [details] Corresponding regression test
Another side effect of the current bug is that the local declaration has no modidier in the DOM/AST tree.
Fix is not good enough. Needs more investigation.
This is a regression compare to 3.0.2. The positions looks good in 3.0.2.
Too risky for 3.1. Will be considered post 3.1.
Tagged as 3.1.1 since this is a regression compare to 3.0.2
Created attachment 25611 [details] Simpler patch to fix this issue This fix has the advantage to be minimalistic and seems to have no side effect (ie. javadoc comments for local class and their body declarations are kept).
Created attachment 25612 [details] New test cases added to ASTConverterJavadocTest These new test cases complete previous regression test, especially to verify that javadoc comments are kept inside method.
Created attachment 25613 [details] Bundle all test cases in one patch Note that previous patch was not complete... I forgot to put last changes for testBug100041c.
All JDT/Core and JDT/UI tests pass with this fix. Patches released in R3_1_maintenance branch.
Backported in HEAD stream.
Verified in 3.2M1 (I20050808-2000)
Verified for 3.1.1 using build M20050923-1430.
Verified.