A proposition before the OpenJDK development group would add hidden classes to Java, a capacity expected to improve the productivity of language implementations built on the Java Virtual Machine (JVM).
Hidden classes will be classes that can’t be utilized legitimately by the bytecode of different classes, as indicated by the Java Development Kit (JDK)Enhancement Proposal. Or maybe, hidden classes are planned to be utilized by frameworks that create classes at runtime and use them indirectly through reflection. A hidden class can be characterized as an individual from an assess control home and might be pitifully referenced by its group loader. There is no timetable yet for when hidden classes may show up in Java.
In clarifying the inspiration driving the plan, the proposition states that numerous language implementations based on the JVM leverage dynamic class age for efficiency and flexibility. Java’s java compiler, for instance, doesn’t make an interpretation of a lambda articulation into a devoted class file at compile time however emanates byte code to progressively create and start up a class. Additionally, non-Java JVM languages regularly execute higher-order features by utilizing dynamic proxies to produce classes dynamically.
The implementers of these languages normally need a powerfully created class to be a part of a current statically produced class and to have properties alluring of dynamically created classes, for example, non-discoverability and access control. Nonetheless, the standard APIs that characterize a class were not planned with these purposes in mind.
On the off chance that the standard APIs could define hidden, non-discoverable classes with a constrained lifecycle, then frameworks inside and outside of the JDK that produces classes dynamically could characterize hidden classes rather, improving JVM language proficiency.
Objectives of the hidden classes proposition include:
- Empowering frameworks to characterize classes as non-discoverable implementation details of the framework, so they can’t be connected against by different classes or found by means of reflection.
- Deprecation of the non-standard API, Unsafe:defineAnonymousClass, with the objective of evacuating it in a future release.
- Not changing the Java language by any means.
- Backing expanding an access control nest with non-discoverable classes.
- Supporting forceful emptying of non-discoverable classes, giving frameworks the flexibility to characterize as needed.