Community
Participate
Working Groups
An end of line comment must end with a line terminator according to the Java Language spec (second editon). If this comment is at the very end of a file without a newline then this is not valid. SDK 1.2 - 1.3 did not report this but 1.4.1 is more strict and throws a compiler error: CommentTest.java:19: unclosed comment // no line terminator ^ 1 error Our compiler should do the same. We had files which did compile inside Eclipse but were rejected when compiling outside Eclipse with SDK 1.4.1.
This would mean that we actually tokenize comments during regular parsing, but we don't. This could slow down the parser.
In fact the bug is that the scanner is not reporting an error when a line comment is not closed with a line break (i.e. EOF is reached before a line break is found).
Do we want to report this error only in JCK 1.4 mode?
In case there is a line break after the line comment, is it supposed to be part of the line comment. If I have: // test\n Is the source of this comment "// test\n" or "// test"?
>Do we want to report this error only in JCK 1.4 mode? I guess not only in JCK1.4 mode except you want to leave the bug in there for compatibility reasons (see Java Language spec 2nd ed.). >Is the source of this comment "// test\n" or "// test"? At least in the Java Language specification it is part of the comment
It is trivial to modify the scanner to report an error when the line delimiter is not found behind the line comment. We need to change it too to include the line delimiters in its positions.
Changed milestone. Fixing this problem has a bad side-effect on the formatter. So we need to be sure that the new formatter is ready prior to releasing any code.
Fixed and released in 2.1 stream. Regression tests added.
Verified.