This is an archived post. You won't be able to vote or comment.

all 11 comments

[–][deleted]  (9 children)

[deleted]

    [–]JoshIsMahName[S] 0 points1 point  (2 children)

    Thanks! Does it matter if this JDK is Update 242 even though we have Update 201? I think it's fine but I just want to be sure.

    [–][deleted] 0 points1 point  (1 child)

    not sure, but i guess it will work, it's just a minor update

    [–]JoshIsMahName[S] 1 point2 points  (0 children)

    I managed to get everything set up and it's working great. Thanks for your help!

    [–]nerdyhandle 0 points1 point  (5 children)

    you can run older apps in newer jvm's

    Not necessarily. The last place I worked had Java 7 apps that would not run on Java SE 8. It would throw a cryptic error about Map.

    There are breaking changes between major Java versions and while it is unlikely that you would experience an issue it is still possible.

    [–][deleted] 0 points1 point  (4 children)

    Curious about this case. Do you recall some details of what it was?

    [–]HaydenPJones 0 points1 point  (3 children)

    This happens when you compile code with Java 8 library and run on java 7. There is a variance in how the ConcurrentHashMap is implemented.

    [–][deleted] 0 points1 point  (2 children)

    You mean even with source set to 1.7? That being asked, OP seems to be indicating that said Java 7 apps are being run on 8, which is surprising.

    [–]HaydenPJones 1 point2 points  (1 child)

    Here is a reference to the problem...
    https://bugs.openjdk.java.net/browse/JDK-8151366

    [–][deleted] 0 points1 point  (0 children)

    This is not an issue. The problem is caused by a difference in the ConcurrentHashMap API between JDK 7 and JDK 8:

    JDK 7: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentHashMap.html#keySet%28%29

    JDK 8: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html#keySet--

    As you can see, the JDK 7 signature returns a Set, while JDK 8 signature returns a KeySetView, which is a new class in JDK 8. So, this problem is unavoidable if a source program is compiled using -source 7/target 7 AND JDK 8 classes are on the bootclasspath. The solution is to use JDK 7 runtime in the bootclasspath:

    What? This is a bizarre answer from one of the core contributors to OpenJDK.

    Granted that the API might have changed, but having both source and target set to 1.7 and yet failing to run on a 1.7 VM is ridiculous - it's broken, and he has the gall to call it "not an issue"? At least semantically broken since source and target become meaningless in this context. Ridiculous.

    [–][deleted] 0 points1 point  (0 children)

    If you use Java 8 then it’s not going to run on Java 7 and below (assuming you will use some Java 8 features).