Bug 303096 - compiled class (eclipse) runs with error (compiled with JDK it runs without)
Summary: compiled class (eclipse) runs with error (compiled with JDK it runs without)
Status: VERIFIED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-17 13:08 EST by Stefan2110 CLA
Modified: 2010-03-08 13:37 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan2110 CLA 2010-02-17 13:08:23 EST
Build Identifier: I20100129-1300 (win64)

When I compile a small test class with eclipse and then run it with JVM 1.6.0_18 64Bit there will be an incorrect result. Running it with JVM 1.6.0_18 32Bit to get the proper result.

But When the class is compiled directly with the jdk 1.6.0_18 x64 you get the same (right) result on x64/x32 JVM.

Hava a look at
http://forums.sun.com/thread.jspa?threadID=5427954 
there i explained it too!

Here is the class
public class problem64Bit
{
 
	/**
	 * @param args
	 *            Arguments
	 */
	public static void main(final String[] args)
	{
		booleanInvert(Integer.MAX_VALUE);
		booleanInvert(Integer.MAX_VALUE - 1);
	}
 
	private static void booleanInvert(final int max)
	{
		boolean test1 = false;
		boolean test2 = false;
 
		for (int i = 0; i < max; i++)
		{
			test1 = !test1;
		}
 
		for (int i = 0; i < max; i++)
		{
			test2 ^= true;
		}
 
		if (test1 != test2)
		{
			System.out.println("ERROR: Boolean invert\n\ttest1=" + test1
					+ "\n\ttest2=" + test2);
		} else
		{
			System.out.println("Everything as it should be!");
		}
	}
}

Both loops should result in the same boolean state - but when the loop iterates over INTEGER.MAX_VALUE then the compiled class (compiled with eclipse 3.6 x64 or 3.5 x64) will result in a different state.

Here is the output from the JVM 1.6.0_18 x64
ERROR: Boolean invert
	test1=true
	test2=false
Everything as it should be!

Reproducible: Always
Comment 2 Olivier Thomann CLA 2010-02-17 13:16:25 EST
I'll investigate.
Comment 3 Olivier Thomann CLA 2010-02-17 14:12:13 EST
If I run the class file compiled by Eclipse using:
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)

I do get the expected output.

Could you please try to run your test case on the VM you have and disable the JIT ?

I'll try to retrieve the VM that you are using, but so far it looks like a VM issue.
Comment 4 Olivier Thomann CLA 2010-02-17 14:43:07 EST
This looks like a VM issue:

...>\Test\jdk\jdk6_18\bin\java X
ERROR: Boolean invert
        test1=true
        test2=false
Everything as it should be!

...>\Test\jdk\jdk6_18\bin\java -Djava.compiler=none X
Everything as it should be!
Everything as it should be!

So no JIT over the same .class file works.
Differences in the javap can be explained by the way the for loop is generated.
Nothing noticable on that side.

Closing as NOT_ECLIPSE.
Comment 5 Olivier Thomann CLA 2010-02-17 14:43:38 EST
Note that 1.6.0_13 64Bit VM works fine.
Comment 6 Frederic Fusier CLA 2010-03-08 13:37:46 EST
Verified