Last active
August 29, 2015 14:23
-
-
Save vlsi/aeeb4a61d9c2b67ad213 to your computer and use it in GitHub Desktop.
JRE 7 compatibility test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.Duration; | |
import java.util.Optional; | |
public class Jre7Test { | |
public static class MyClass { | |
public Optional<Duration> optional(java.time.Duration duration) { | |
return Optional.of(duration); | |
} | |
public void say(String greeting) { | |
System.out.println(greeting); | |
} | |
} | |
public static void main(String[] args) throws Throwable { | |
MyClass.class.getMethods(); | |
new MyClass().say("Works like a charm!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash-3.2$ /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/javac -source 1.7 -target 1.7 Jre7Test.java | |
warning: [options] bootstrap class path not set in conjunction with -source 1.7 | |
1 warning | |
bash-3.2$ /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java Jre7Test | |
Exception in thread "main" java.lang.NoClassDefFoundError: java/time/Duration | |
at java.lang.Class.getDeclaredMethods0(Native Method) | |
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531) | |
at java.lang.Class.privateGetPublicMethods(Class.java:2651) | |
at java.lang.Class.getMethods(Class.java:1467) | |
at Jre7Test.main(Jre7Test.java:16) | |
Caused by: java.lang.ClassNotFoundException: java.time.Duration | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) | |
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) | |
... 5 more | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the full 12.1.1 from https://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html
I've split it paragraph by paragraph.
No additional checks.
No additional checks.
No additional checks.
So, the process of loading the main class is exactly the same in 12.1.1 and 12.2.
Please stop saying "contains more checks". Just point me into at least to a single "additional check".
I could easily miss it out due to English being my foreign language.