JDK-6380132 : REGRESSION: UnsupportedClassVersionError should include the class name
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-02-02
  • Updated: 2015-02-23
  • Resolved: 2006-02-15
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
6 b72Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
When I get an UnsupportedClassVersionError, the message says "Bad version in .class file." This helps to clarify the nature of the problem, I suppose, but it doesn't offer any information beyond the name of the class. It would be much more helpful if the message printed out the name of the class so I know what needs to be recompiled.

JUSTIFICATION :
In general, error messages should include information that is specific to the actual incident. In the case of an array index out of bounds, for example, the message reports the bad index. With UnsupportedClassVersionError, I want to know if I just need to recompile a specific file or if I need to recompile the entire project, which takes longer. This is a small change, but it would be very helpful when I see this error.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
UnsupportedClassVersionError should report the name of the class that had the bad version number, like this:

java.lang.UnsuportedClassVersionError: CustomWidget.class has a bad
version number.

(I don't really need the version number, that it wouldn't hurt to include that as well, for people who do need it.)

java.lang.UnsuportedClassVersionError: CustomWidget.class has a bad version number of 63.

ACTUAL -
Error message just says this:

java.lang.UnsuportedClassVersionError: Bad version number in .class file


---------- BEGIN SOURCE ----------
This can happen with any source. Compile a source file under Mustang and execute it under Tiger to see this error.
---------- END SOURCE ----------

Release Regression From : 1.4.2_10
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

Comments
EVALUATION If the major.minor version numbers are unsupported by the VM, it can't assume that the class file format is the same as it is now, and so it cannot read the class name from the classfile format. That said, in most situations, the class file parser knows what class it is looking for (for example, when a name is provided to ClassLoader.defineClass()). So, if a name is provided, we can add that name to the exception message. The message will be updated to read: <class> : Unsupported major.minor version XX.XX or if the name is not available: Unsupported major.minor version XX.XX
03-02-2006