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



Important (please note from article above)

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


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.

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.