Bug 23096 - Compiler does not report end of line comment error
Summary: Compiler does not report end of line comment error
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: readme
Depends on:
Blocks: 24744 24833
  Show dependency tree
 
Reported: 2002-09-03 04:04 EDT by Dani Megert CLA
Modified: 2002-11-15 17:54 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2002-09-03 04:04:39 EDT
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.
Comment 1 Olivier Thomann CLA 2002-09-23 10:28:07 EDT
This would mean that we actually tokenize comments during regular parsing, but 
we don't. This could slow down the parser.
Comment 2 Olivier Thomann CLA 2002-09-23 13:57:51 EDT
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).
Comment 3 Olivier Thomann CLA 2002-09-23 14:01:49 EDT
Do we want to report this error only in JCK 1.4 mode?
Comment 4 Olivier Thomann CLA 2002-09-23 15:11:55 EDT
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"?
Comment 5 Dani Megert CLA 2002-09-24 03:23:13 EDT
>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

Comment 6 Olivier Thomann CLA 2002-09-26 11:40:33 EDT
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.
Comment 7 Olivier Thomann CLA 2002-10-10 09:18:00 EDT
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.
Comment 8 Olivier Thomann CLA 2002-10-22 14:50:56 EDT
Fixed and released in 2.1 stream.
Regression tests added.
Comment 9 David Audel CLA 2002-11-13 06:10:48 EST
Verified.