Created
June 11, 2019 11:25
-
-
Save martijndwars/5e9c2cc72820f00699d1e3388072ef4f to your computer and use it in GitHub Desktop.
Compile on Java 8, run on Java 11
This file contains hidden or 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
martijn@dhcp-10-175-42-124:/p/t/javatest$ cat Main.java | |
import sun.misc.Unsafe; | |
import java.lang.reflect.Field; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
Unsafe unsafe = getUnsafe(); | |
System.out.println("Page size = " + unsafe.pageSize()); | |
} | |
public static Unsafe getUnsafe() throws Exception { | |
Field f = Unsafe.class.getDeclaredField("theUnsafe"); | |
f.setAccessible(true); | |
Unsafe unsafe = (Unsafe) f.get(null); | |
return unsafe; | |
} | |
} | |
martijn@dhcp-10-175-42-124:/p/t/javatest$ javac Main.java && java Main | |
Page size = 4096 | |
martijn@dhcp-10-175-42-124:/p/t/javatest$ java11 | |
martijn@dhcp-10-175-42-124:/p/t/javatest$ echo $JAVA11_HOME | |
/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home | |
martijn@dhcp-10-175-42-124:/p/t/javatest$ java Main | |
Page size = 4096 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment