This chapter is about 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.
- 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.
- Extend Access Control Nest with non-discoverable classes.
- Aggressive unloading of hidden classes which will help frameworks to define as many as hidden classes as required without degrading the performance.
- Depreate the non-standard API, misc.Unsafe::defineAnonymousClass, to be removed in future release.
In this topic we learned about Java 15 – Hidden Classes. To know more, Click Here.
Pingback: Java 15 - Record for Sealed Interfaces - Adglob Infosystem Pvt Ltd