Skip to content

-XX:[+|-]ShareAnonymousClasses

This option enables and disables the storage of VM anonymous classes, those created by Unsafe.defineAnonymousClass, in the shared classes cache.

Start of content that applies to Java 15+ In OpenJDK 15 and later versions, this option also enables and disables the storage of hidden classes in the shared classes cache.

The option is enabled by default, which means that anonymous classes (and hidden classes, in OpenJDK 15 and later) are stored in the shared classes cache and are therefore available for ahead-of-time (AOT) compilation, potentially improving startup performance.

Syntax

    -XX:[+|-]ShareAnonymousClasses
Setting Effect Default
-XX:+ShareAnonymousClasses Enable yes
-XX:-ShareAnonymousClasses Disable

See also