Sun JDK 6 javac vs OpenJDK 6 javac

Mark Mahieu mark at twistedbanana.demon.co.uk
Sun Nov 29 00:52:09 PST 2009


Repost from the right email address this time (I hope!)...

I wrote:

>  should I expect to see
>  the same result from javac in Sun JDK 6 compared to OpenJDK 6


Tim Bell kindly bounced with:
> 
> Well - probably 'yes'.  What did you do... what was the unexpected
> result?  What was the expected result?  Do you have a small test
> program to demonstrate the issue?  What was surprising or unexpected
> about it? 


I stumbled across the following, which compiles without errors using Sun JDK 6 (various builds from b10 through b16), but is rejected by OpenJDK 6's javac (at least build b10 through to now) and OpenJDK 7 (clone of jdk7/tl/langtools):

class SunJDKvsOpenJDK {

    public static void main(String[] args) {
        foo(bar("a", "b"));
    }

    static void foo(String s) {}

    static <R, A1 extends R, A2 extends R> R bar(A1 a1, A2 a2) {
        return null;
    }
}


Output from a recent OpenJDK 6 build:

SunJDKvsOpenJDK.java:4: foo(java.lang.String) in SunJDKvsOpenJDK cannot be applied to (java.lang.Object)
                foo(bar("a", "b"));
                ^
1 error


However, the main reason I'm asking out loud on this list is because I've been naively grabbing Sun JDK 6 and OpenJDK 6 builds of a similar vintage pretty much at random, to use as a base-line for regression testing some experiments I'm making in OpenJDK 7's javac, and given the above, I'm now wondering if I should try to stick to one or the other.


Mark




More information about the compiler-dev mailing list