JDK-6507179 : javadoc -source 1.3 does not work with jdk6
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2006-12-21
  • Updated: 2011-03-01
  • Resolved: 2007-04-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u2 b02Fixed 7Fixed OpenJDK6Fixed
Description
FULL PRODUCT VERSION :
betelgeuse@pena ~/test/java $ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
betelgeuse@pena ~/test/java $ uname -a
Linux pena 2.6.19-gentoo-r2 #6 SMP Sat Dec 16 23:59:19 EET 2006 i686 Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz GenuineIntel GNU/Linux

A DESCRIPTION OF THE PROBLEM :
javadoc -source 1.3 does not work any more with 1.6. This behaviour is inconsistent with the help message when running javadoc without -source 1.3 and -source 1.3 used to work correctly in 1.5.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run javadoc -source 1.3 on a code containing assert in a place where a keyword is expected.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
  From 1.5:
betelgeuse@pena ~/test/java $ java -version
java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Server VM (build 1.5.0_10-b03, mixed mode)
betelgeuse@pena ~/test/java $ javadoc -source 1.3 Hello.java
Loading source file Hello.java...
Hello.java:3: warning: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier
(try -source 1.4 or higher to use 'assert' as a keyword)
        private void assert(){;}
                     ^
Constructing Javadoc information...
Standard Doclet version 1.5.0_10
Building tree for all the packages and classes...
Generating Hello.html...
Generating package-frame.html...
Generating package-summary.html...
Generating package-tree.html...
Generating constant-values.html...
Building index for all the packages and classes...
Generating overview-tree.html...
Generating index-all.html...
Generating deprecated-list.html...
Building index for all classes...
Generating allclasses-frame.html...
Generating allclasses-noframe.html...
Generating index.html...
Generating help-doc.html...
Generating stylesheet.css...
1 warning

ACTUAL -
betelgeuse@pena ~/test/java $ javadoc -source 1.3 Hello.java
Loading source file Hello.java...
Hello.java:3: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier
(use -source 1.3 or lower to use 'assert' as an identifier)
        private void assert(){;}
                     ^
1 error
betelgeuse

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
betelgeuse@pena ~/test/java $ cat Hello.java
public class Hello
{
        private void assert(){;}
        public static void main(String[] args)
        {
                System.out.println("Hello World!");
        }
}

---------- END SOURCE ----------

Comments
EVALUATION The Source object is being initialized before the "-source" option has been parsed. The javadoc tool initializes its Messager (a javac Log) early on: even before the command line is fully parsed, since it uses the Messager in several ways during parsing. Before JDK 6 this was safe, as the Log didn't access the Source object. But since JDK 6 it does access it, to determine if mandatory warnings are in effect. Thus the Source object is being initialized earlier now, leading to the problem.
14-03-2007