-
Bug
-
Resolution: Fixed
-
P5
-
1.3.0, 1.4.1
-
hopper
-
x86, sparc
-
solaris_8, windows_nt, windows_2000
-
Verified
Name: tb29552 Date: 02/27/2000
java version "1.2.2"
Classic VM (build JDK-1.2.2-001, native threads, symcjit)
Create a file containing only 2 bytes: "//" and compile that file with javac.
Notice that no diagostic is reported. This is contrary to the specification of
java's lexical structure, which says that "//" a newline is required to be
paired with a newline:
There is the description...
// text A single-line comment: all the text from the ASCII characters // to the
end of the line is ignored (as in C++).
And the grammar...
EndOfLineComment:
/ / CharactersInLineopt LineTerminator
It would appear that the End Of File is also acting as a line terminator,
as defined in JLS section 3.4 "Line Terminators":
http://java.sun.com/docs/books/jls/html/3.doc.html#231571
(Incidently, the compiler does properly report a diagnostic if the file
contains only "/*".)
Compare this:
% ls -l Comment1.java
-rw-r--r-- 1 user group 2 Feb 27 11:00 Comment1.java
(the file is two bytes long...)
cat Comment1.java
//% javac -J-showversion Comment1.java
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-U)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, interpreted mode)
%
To this:
% ls -l Comment2.java
-rw-r--r-- 1 user group 2 Feb 27 11:02 Comment2.java
(again, the file is two bytes long...)
% cat Comment2.java
/*%javac -J-showversion Comment2.java
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-U)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, interpreted mode)
Comment2.java:1: unclosed comment
/*
^
Comment2.java:1: 'class' or 'interface' expected
/*
^
2 errors
%
(Review ID: 101427)
======================================================================
- duplicates
-
JDK-4702562 Java compiler can not compile a file ended with comment
- Closed
-
JDK-4706348 REGRESSION: 1.4.1-beta compiler doesn't handle single line comments correctly
- Closed