Bug 188648 - ECJ compiler fails to find boot classes on Harmony
Summary: ECJ compiler fails to find boot classes on Harmony
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.3 RC2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 192576 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-23 10:20 EDT by Gregory Shimansky CLA
Modified: 2007-06-14 08:54 EDT (History)
3 users (show)

See Also:
kent_johnson: review+
maxime_daniel: review+


Attachments
Proposed fix (3.89 KB, patch)
2007-05-23 12:06 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (4.13 KB, patch)
2007-05-23 12:14 EDT, Olivier Thomann CLA
no flags Details | Diff
Better patch (4.13 KB, patch)
2007-05-23 14:57 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gregory Shimansky CLA 2007-05-23 10:20:54 EDT
When running ECJ standalone compiler on Harmony JVMs (both DRLVM and IBM VME binary) from command line as

java -jar ecj.jar <java source file>

I get an error that java.lang.Object (and other core java classes) cannot be resolved. This happens because Harmony structure of boot class JARs different from Sun. On Sun all boot class JARs are located in java.home/lib directory and so ECJ finds them successfully.

On Harmony boot class JARs are located in java.home/lib/boot (and subdirectories) and java.home/bin/default. This layout comes from Harmony modularity. But ECJ fails to find boot class JARs because they are located in java.home/lib subdirectories, and heuristics that works for Sun fails with Harmony.

Harmony JVMs provide a property which contains all the JAR files with absolute path names called "org.apache.harmony.boot.class.path". The easiest way to allow ECJ to find boot classes on Harmony would be to make it use this property.

BTW on Sun and BEA JVMs it is possible to use sun.boot.library.path instead of searching for JAR files in java.home/lib directory :)
Comment 1 Olivier Thomann CLA 2007-05-23 11:33:46 EDT
It seems that the property "sun.boot.class.path" is defined for all VMs I tried (Harmony, IBM, Sun, BEA).
The property "org.apache.harmony.boot.class.path" doesn't seem to include a jar that contains java.lang.Object.
I have a patch ready that is using the property "sun.boot.class.path" for all VMs and it looks like the bootclasspath is properly retrieved now for Harmony as well.
Did I miss something as you suggested to use only the property "org.apache.harmony.boot.class.path" ?
Comment 2 Olivier Thomann CLA 2007-05-23 12:06:31 EDT
Created attachment 68374 [details]
Proposed fix

I tested it with Harmony(0.5M1), IBM(1.4/1.5/1.6), BEA(27.1) and Sun VM (1.4/1.5/1.6/1.7). It seems to work as expected now.
Comment 3 Olivier Thomann CLA 2007-05-23 12:06:58 EDT
Kent, please review.
Comment 4 Olivier Thomann CLA 2007-05-23 12:07:29 EDT
Maxime, please review.
Comment 5 Olivier Thomann CLA 2007-05-23 12:14:17 EDT
Created attachment 68378 [details]
Proposed fix

New patch to also check for the property "org.apache.harmony.boot.class.path" in case of run on IBM VME (from the Harmony mailing list).
Comment 6 Maxime Daniel CLA 2007-05-23 14:48:04 EDT
Olivier,
I'd suggest that you cascade the tests as:
		String bootclasspathProperty = System.getProperty("sun.boot.class.path"); //$NON-NLS-1$
		if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
			// IBM J9 VMs
			bootclasspathProperty = System.getProperty("vm.boot.class.path"); //$NON-NLS-1$
		  if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
			  // Harmony using IBM VME
			  bootclasspathProperty = System.getProperty("org.apache.harmony.boot.class.path"); //$NON-NLS-1$
		}		
}

This would save a couple of tests most times (since we expect to get it right on the sun.boot.class.path call in most cases).

Patch still good without this change anyway.
Comment 7 Olivier Thomann CLA 2007-05-23 14:55:29 EDT
Good suggestion.
Released for 3.3RC2
Comment 8 Olivier Thomann CLA 2007-05-23 14:57:07 EDT
Created attachment 68417 [details]
Better patch

Patch based on Maxime's suggestion.
Comment 9 Gregory Shimansky CLA 2007-05-24 11:16:19 EDT
I verified that the bug is fixed on the nightly build I20070524-0800. Harmony runs ECJ just fine now.
Comment 10 Olivier Thomann CLA 2007-06-14 08:54:25 EDT
*** Bug 192576 has been marked as a duplicate of this bug. ***