Bug 288991 - Run simple java on eclipse, UnsupportedClassVersionError
Summary: Run simple java on eclipse, UnsupportedClassVersionError
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: eclipse   
(Show other bugs)
Version: rawhide
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Andrew Overholt
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
: 310571 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-09-13 10:18 UTC by sangu
Modified: 2007-11-30 22:12 UTC (History)
5 users (show)

Fixed In Version: 3.3.0-22.fc8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-10-03 18:53:56 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description sangu 2007-09-13 10:18:03 UTC
Description of problem:
HelloWold.java

class HelloWorld {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("Hello world!");
		
	}

}

== console on eclipse ==
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld :
Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:638)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:143)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:281)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:216)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:209)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:324)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:269)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:337)


Version-Release number of selected component (if applicable):
3.3.0-19.fc8

How reproducible:
always

Steps to Reproduce:
1. $yum install eclipse
2. launch eclipse
3. Create HelloWorld Project in eclipse tutorial
4. Run 

Actual results:


Expected results:


Additional info:

$javac ~/workspace/HelloWorld/src/HelloWorld.java
$java ~/workspace/HelloWorld/src/HelloWorld
Hello world!

$ rpm -qa | grep ^eclipse
eclipse-cvs-client-3.3.0-19.fc8
eclipse-mylyn-bugzilla-2.0.0-4.fc8
eclipse-jdt-3.3.0-19.fc8
eclipse-ecj-3.3.0-19.fc8
eclipse-changelog-2.5.1-2.fc8
eclipse-mylyn-trac-2.0.0-4.fc8
eclipse-subclipse-1.2.2-6.fc8
eclipse-rpm-editor-0.1.0-7.fc8
eclipse-platform-3.3.0-19.fc8
eclipse-mylyn-java-2.0.0-4.fc8
eclipse-mylyn-2.0.0-4.fc8
eclipse-rcp-3.3.0-19.fc8
eclipse-mylyn-ide-2.0.0-4.fc8

$ rpm -q java-1.7.0-icedtea
java-1.7.0-icedtea-1.7.0.0-0.15.b19.snapshot.fc8

Comment 1 sangu 2007-09-13 11:31:33 UTC
After Compiler compliance level is set to 1.4.,  run works well.

Initial Compiler compliance level value is 6. <-- this is bug?

Click Restore Defaults,  Compiler compliance level changes to 1.4.

Comment 2 Andrew Overholt 2007-09-13 17:35:15 UTC
I don't understand.  Is ecj generating something that IcedTea can't run?  Tom,
do you have any idea what's up here?

Comment 3 Thomas Fitzsimmons 2007-09-13 19:41:02 UTC
51 is the 1.7 major version so the code is being built by IcedTea.  sangu, what
JDK is Eclipse configured to run programs with?

Comment 4 sangu 2007-09-13 23:37:34 UTC
$rm -rf ~/.eclipse ~/workspace/
1. Launch eclipse
( Compiler compliance level 6)
2. Make helloworld project in tutorials
(Create Hello World application)
3. Run
UnsupportedClassVersionError 

1. Window menu  -> Preferences - Java - Compiler -> Compiler compliance level
6.0 -> 1.4
2. Run 
Works well.

-----------------
* Compiler compliance level 6 (Initial value)
- Run -> UnsupportedClassVersionError 

*  Compiler compliance level 1.4  (Click Restore Defaults)
- Run -> Works well.

Comment 5 Sylvain Pasche 2007-09-15 13:02:30 UTC
Looks like there are some troubles with IcedTea: it can't run .class files it
generates:

javac -target 1.7 Hello.java
java Hello

Exception in thread "main" java.lang.UnsupportedClassVersionError: Hello :
Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)

Comment 6 Andrew Overholt 2007-09-15 13:26:42 UTC
Updating component.

Comment 7 Thomas Fitzsimmons 2007-09-17 17:27:01 UTC
From openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp:

#define JAVA_MAX_SUPPORTED_VERSION        50

OpenJDK represents the Java 1.7 development cycle.  It's unknown whether a class
file format version bump will be required once Java 1.7 is finalized.  In the
mean time, people shouldn't be building with -target 1.7 (except maybe javac
developers), and I expect JAVA_MAX_SUPPORTED_VERSION 50 is a reminder of this.

The correct fix here is to make Eclipse build with -target 1.6 rather than 1.7.

Comment 8 Andrew Overholt 2007-09-18 17:47:47 UTC
This is going to be difficult.

Comment 9 Andrew Overholt 2007-09-26 19:41:42 UTC
It turns out it's not difficult at all :)  I'm uncomfortable making this change
at such a low level, but I guess someone running on OpenJDK can generate
1.7-level bytecode if they so choose by changing their project properties.

I've included a patch and a build should show up in rawhide tomorrow (2007-09-27).

Comment 10 Andrew Overholt 2007-09-28 12:32:14 UTC
Can someone please verify that this is fixed in 3.3.0-22.fc8?

Comment 11 Andrew Overholt 2007-09-28 12:33:51 UTC
*** Bug 310571 has been marked as a duplicate of this bug. ***

Comment 12 Thomas Fitzsimmons 2007-10-03 17:24:53 UTC
Confirmed fixed in 3.3.0-22.fc8.

Comment 13 Andrew Overholt 2007-10-03 18:53:56 UTC
Thanks, closing.


Note You need to log in before you can comment on or make changes to this bug.