Why do you need -Xshare:off and -XX:-UseTypeSpeculation for Java 11 Follow

-Xshare:off

https://docs.oracle.com/en/java/javase/11/vm/class-data-sharing.html

Important (please note from article above)


If the flag is not set it caused JVM crashes in the past seen by other customers.


-XX:-UseTypeSpeculation

Ever since JVM optimization was introduced in Java there was a bug originally discovered in Java 8, fixed in Java 9 and a new form of that bug was introduced in Java 11.
https://bugs.openjdk.java.net/browse/JDK-8037595
https://bugs.openjdk.java.net/browse/JDK-8038636
https://bugs.openjdk.java.net/browse/JDK-8040237

Essentially this bug in the JVM optimization feature can cause the JVM to crash.
The -XX:-UseTypeSpeculation argument disables the optimization.

It's important to note that this is a very minor optimization, and disabling it should not have any noticeable impact on performance. The optimization allows method B to make assumptions on the types of some arguments passed to it by method A, only in case the JVM decides to inline B in A and if A passes to B polymorphic arguments. When all of the above happens, the optimization allows B to assume types instead of performing a cast-check or an instance-of.

Same here, we have seen JVM crashes by other customers when using Java 11.

Comments

0 comments