Java 15

Java 15 – Hidden Classes

Java 15 has introduced hidden classes which cannot be used directly by other classes bytecode. These hidden classes are intended to be used by frameworks which genereate classes at runtime and use them using reflection.

A hidden class is defined as a member of Nest Based Access Control Context and it can be unloaded inrespective of other classes.

This proposal, JEP 371, aims at improvement of all languages on JVM by providing a standard API to define hidden classes which are not discoverable and have limited lifecycle. JDK frameworks or external frameworks can generate classses dynamically which can generate hidden classes.

JVM languages relies heavily on dynamic class generation for flexibility and efficiency.

Goals

Following is the list of targetted goals of this enhancement.

  1. Frameworks should be able to define classes as non-discoverable implementation details of the framework, These classes cannot neither be linked to other classes nor discoverable using reflection.
  2. Extend Access Control Nest with non-discoverable classes.
  3. Aggressive unloading of hidden classes which will help frameworks to define as many as hidden classes as required without degrading the performance.
  4. Depreate the non-standard API, misc.Unsafe::defineAnonymousClass, to be removed in future release.

About the Author: Elavarasan PK

Technical Specialist, Intersoft Data Labs