JDK-6567414 : javac compiler reports no source file or line on enum constant declaration error
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-06-08
  • Updated: 2012-01-13
  • Resolved: 2012-01-13
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 7
7 b81Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
No line number is indicated when a compile error occurs in an enum constant. See the test case below, where the enum constructor declares a checked exception, and see that the compiler output does not say which line (or even which source file) this error occurs in. Obviously that makes it hard to track down the error. :)

Note that I think this may well be caused by the issue noted in bug 6472751.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the example code below.
javac Test.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I'd expect an error with a line number, as was given in JDK 5.0's compiler:

Test.java:3: unreported exception java.lang.Exception; must be caught or declared to be thrown
  FOO;
  ^
1 error
ACTUAL -
error: unreported exception java.lang.Exception; must be caught or declared to be thrown
1 error

ERROR MESSAGES/STACK TRACES THAT OCCUR :
error: unreported exception java.lang.Exception; must be caught or declared to be thrown
1 error

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public enum Test {
  FOO;
  Test() throws Exception {}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use JDK 5.0 to find the compile error, if possible, and then fix the compile error of course.

Comments
EVALUATION Introduced by 4994049.
13-01-2010