Menu
Hidden classes could be coming to Java

Hidden classes could be coming to Java

A JDK Enhancement Proposal says introducing hidden classes in Java could make other JVM languages more efficient

Credit: Dreamstime

A proposal before the OpenJDK development team would add hidden classes to Java, a capability intended to improve the efficiency of language implementations built on the JVM.

Hidden classes are classes that cannot be used directly by the bytecode of other classes, according to the JDK Enhancement Proposal. Rather, hidden classes are intended to be used by frameworks that generate classes at runtime and use them indirectly via reflection.

A hidden class can be defined as a member of an access control nest and may be weakly referenced by its class loader. There is no timetable yet for when hidden classes might appear in Java.

In explaining the motivation behind the plan, the proposal states that many language implementations built on the JVM leverage dynamic class generation for efficiency and flexibility.

Java’s javac compiler, for example, does not translate a lambda expression into a dedicated class file at compile time but emits bytecode to dynamically generate and instantiate a class. Similarly, non-Java JVM languages often implement higher-order features by using dynamic proxies to generate classes dynamically.

The implementers of these languages usually want a dynamically generated class to be part of an existing statically generated class and to have properties desirable of dynamically generated classes such as non-discoverability and access control. However, the standard APIs that define a class weren’t designed with these purposes in mind.

If the standard APIs could define hidden, non-discoverable classes with a limited lifecycle, then frameworks inside and outside of the JDK that generate classes dynamically could define hidden classes instead, improving JVM language efficiency.

Goals of the hidden classes proposal include:

  • Enabling frameworks to define classes as non-discoverable implementation details of the framework, so they cannot be linked against by other classes, or discovered via reflection
  • Deprecation of the non-standard API, misc.Unsafe::defineAnonymousClass, with the goal of removing it in a future release
  • Not changing the Java language at all
  • Support extending an access-control nest with non-discoverable classes
  • Supporting aggressive unloading of non-discoverable classes, giving frameworks the flexibility to define as needed

Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags java

Events

Featured

Slideshows

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners

This year’s Reseller News 30 Under 30 Tech Awards were held as an integral part of the first entirely virtual Emerging Leaders​ forum, an annual event dedicated to identifying, educating and showcasing the New Zealand technology market’s rising stars. The 30 Under 30 Tech Awards 2020 recognised the outstanding achievements and business excellence of 30 talented individuals​, across both young leaders and those just starting out. In this slideshow, Reseller News honours this year's winners and captures their thoughts about how their ideas of leadership have changed over time.​

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners
Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security

Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security

This exclusive Reseller News Exchange event in Auckland explored the challenges facing the partner community on the cloud security frontier, as well as market trends, customer priorities and how the channel can capitalise on the opportunities available. In association with Arrow, Bitdefender, Exclusive Networks, Fortinet and Palo Alto Networks. Photos by Gino Demeer.

Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security
Reseller News welcomes industry figures at 2020 Hall of Fame lunch

Reseller News welcomes industry figures at 2020 Hall of Fame lunch

Reseller News welcomed 2019 inductees - Leanne Buer, Ross Jenkins and Terry Dunn - to the fourth running of the Reseller News Hall of Fame lunch, held at the French Cafe in Auckland. The inductees discussed the changing face of the IT channel ecosystem in New Zealand and what it means to be a Reseller News Hall of Fame inductee. Photos by Gino Demeer.

Reseller News welcomes industry figures at 2020 Hall of Fame lunch
Show Comments