JDK-8016445 : UnsupportedClassVersionError should be more informative
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • Submitted: 2013-06-12
  • Updated: 2013-06-18
  • Resolved: 2013-06-18
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
any

EXTRA RELEVANT SYSTEM CONFIGURATION :
Current version of JRE, Beta version of JDK

A DESCRIPTION OF THE PROBLEM :
Developers using the newest version of Java are penalized by users who think there is a problem in the developer's code.   The code returned is rather obscure and appears to be a problem with the code at first glance.

The problem is that the user automatically assumes that the code is flawed.  I see this error coming up repeatedly because I develop on Java 1.7 and I release nightly.  When users run my application, they are greeted with an exception so they send me a bug report.   Because  my application isn't even running, I get spammed with text instead of my own logging system.

This is a horrible way to say  " Java is out of date " .

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java -jar path_to/LatestJava.jar

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
  " Java attempted to launch this app with API Level 47, but Level 51 is needed to run this application. A Java update is required. " 

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread  " main "  java.lang.UnsupportedClassVersionError: CASUAL/CASUALApp : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: CASUAL.CASUALApp. Program will exit.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Compile this on a new version of Java and run it on an older version.


public static void main(String[] args) {}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
There is no way to work around this issue.   Code will not launch at this point.

Suggestion:
Parse the exception for  " Unsupported major.minor version "  and just output the text if run from command line.
Comments
I've changed the synopsis to make it clear what this issue is about.
12-06-2013