-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b03
-
generic
-
generic
-
Verified
The javac parser stores the end position for annotations, which cannot be heuristically determined because parentheses can be optional in an annotation expression. However, it always stores the end position of the annotation's identifier, rather than the closing parenthesis when parentheses are present:
@SuppressWarning("foo")
------------------^ current endPos stored in endPositions
-------------------------^ correct endPos
The problem is that com.sun.tools.javac.parser.Parser.annotation() stores the identifier's end position before parsing any fields, then stores that value regardless of whether there were any parentheses. The suggested fix checks whether the next token is a left-parenthesis, and if so uses the last token's end position, otherwise the stored value. Although there isn't a test case, this fix was verified with Jackpot.
@SuppressWarning("foo")
------------------^ current endPos stored in endPositions
-------------------------^ correct endPos
The problem is that com.sun.tools.javac.parser.Parser.annotation() stores the identifier's end position before parsing any fields, then stores that value regardless of whether there were any parentheses. The suggested fix checks whether the next token is a left-parenthesis, and if so uses the last token's end position, otherwise the stored value. Although there isn't a test case, this fix was verified with Jackpot.
- relates to
-
JDK-6402077 Start position is wrong for package private constructors
-
- Closed
-