[jsword-devel] Cross-compilation

DM Smith dmsmith at crosswire.org
Fri Mar 8 08:40:13 MST 2013


I've been bit with this many times. I'm fixing a problem w/in BibleDesktop regarding inheritance via interfaces that only surfaced because I recompiled using Java 5. Turns out it is not a runtime issue, because Java 6 improvements "do the right thing".

This is addressed with Java 7. You can tell javac that it has to use a particular runtime (by providing rt.jar) to pick the method that the jar has.

In Eclipse, you can create launchers and pick the execution environment. Not sure how to get it to do day-to-day compilation to use the proper compile environment other than to use that version of Java.

It becomes especially tricky when JSword development is Java 5, STEP is Java 6 and your local JDK is Java 7.

I'm still exploring to see what I can do to make it better.

All this is making me want to upgrade JSword development to Java 6 soon after the release. I had to go through hoops to get Java 5 on OSX Mountain Lion.

-- DM

On Mar 8, 2013, at 10:06 AM, Chris Burrell <chris at burrell.me.uk> wrote:

> Hi DM
> 
> One of the issues with cross-compiling, is that it does the cross-compiling in terms of the language structures. It however bases everything on the assumption that the JRE provides the various classes, methods, etc.
> 
> I've hit that several times on STEP, where I've targeted a java 7 method by without realising.
> 
> Chris
> 
> 
> On 8 March 2013 14:38, DM Smith <dmsmith at crosswire.org> wrote:
> 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
> 
> 
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
> 
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20130308/5e206a0c/attachment-0001.html>


More information about the jsword-devel mailing list