Skip to content

-XX:[+|-]ShareOrphans

This option enables or disables sharing of orphan classes from class loaders that do not implement the OpenJ9's public shared classes cache APIs.

Syntax

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

Explanation

In the previous versions, OpenJ9 stored only bootstrap classes and hidden classes in the shared classes cache by default, that is the -Xshareclasses option is not specified by default. When the -Xshareclasses option was specified, only those class loaders that implemented the OpenJ9's public shared classes cache APIs (and its child class loaders) could store classes to the shared classes cache. For classes from custom class loaders that did not implement the shared classes cache APIs, the VM does not have their module or class path information. Such classes were not stored to the cache.

You can enable class sharing from all class loaders, irrespective of whether the class loader implements the cache API, with the -XX:+ShareOrphans option. This option automatically enables the -Xshareclasses option. When the class sharing from all class loaders is enabled, following is the sharing behavior:

  • For classes from class loaders that implement the shared class cache API, they are shared as normal ROM classes, which is same as enabling -Xshareclasses.

  • For classes from class loaders that do not implement the shared class cache API, the VM won't have their class or module path information. They are shared as orphan ROM classes with other VMs after extra comparisons.

Storing additional classes in the cache makes more classes available for Ahead-of-Time (AOT) compilation and therefore might improve startup performance.

You can disable sharing class as orphans from class loader that does not implement the shared class cache API with the -XX:-ShareOrphans option. This option is the default mode.

Restrictions:

  • Sharing classes as orphans requires more comparison on the classes by the VM. The comparison itself has a negative performance impact. However, the benefits of more AOT generated for the cached class might offset the negative impact.
  • More cached classes usually result in more AOT-compiled methods. The relative advantage of orphan sharing decreases when the CPUs are less. With more CPUs, the compilation threads can compile those additional methods in parallel with the application threads, while with fewer CPUs, extra compilation activity hinders application threads.
  • The class comparison might not detect the removal of method access modifiers. For example, a change of a method from public to package-private.
  • java.lang.StackTraceElement.getClassLoaderName() might return null for classes that are stored in the shared cache.

See also