[jsword-devel] Cross-compilation

DM Smith dmsmith at crosswire.org
Fri Mar 8 07:38:44 MST 2013


When compiling for source="1.5" I've been seeing a message that bootclasspath has not been set.

In researching this found out some interesting things.

For a while now you could compile for a prior version of Java. So, for many years we used Java 5 or 6 to compile for Java 1.4 and Java 6 or 7 to compile for Java 5.

I've not seen any problems with this. But it can create runtime exceptions or changes in behavior.

Here is an example of the problem:
Let's say we're targeting Java 6 but using Java 7 to compile and Java 7 has an overloaded method not present in 6.

Java 6:
interface foo {
	boolean isValid(int x);
}

Java 7:
interface foo {
	boolean isValid(int x);
	boolean isValid(long x);
}

The Java 7 compiler resolving a call to isValid(x) only has one choice in Java 6, but two in Java 7. If the compiler picks the one that is new, then the code won't run using a Java 6 jre.

The solution
* use at the same level as the lowest allowed runtime
 or
* supply the rt.jar (classes.jar on the mac) matching the lowest allowed runtime as the argument for the bootclasspath.

We need to do this both in the ant and maven builds. Currently, we require Java 5.

In Him,
	DM




More information about the jsword-devel mailing list