JDK-8213054 : Allow classes to be marked private within nests
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2018-10-26
  • Updated: 2021-06-24
  • Resolved: 2021-06-24
Related Reports
Relates :  
Description
The nestmates feature allows declarations with private access to be shared between multiple classes. This raises the possibility that it would be semantically meaningful to apply ACC_PRIVATE to classes (including interfaces, I guess?). And there are reasonable use cases���classes that currently have package access could be more tightly controlled.

JEP 181 did not pursue this feature, because it was not an essential part of the story. Instead, this bug is to track it as a potential future enhancement.

The JEP 181 spec had this to say about specifying private class access:

"A future enhancement may allow classes to be declared private, accessible only to nestmates. If that occurs, the steps to determine the nest host will have to change slightly, because there would be a circular dependency: nest host determination depends on class resolution, class resolution depends on class access control, and class access control depends on nest host resolution."

Comments
When the language team decides they'd like to do this then please reopen this issue.
24-06-2021

This is a much harder gap to bridge, for little gain. In addition to the problem already listed, performing a nest-based access control check for class access may well require that the nest host is resolved/loaded much earlier than currently required.
28-10-2018

While I agree with Dan's assessment about priority, I'll just add: the main motivation for nestmates was aligning the language and VM notions of access control. The language supports private classes, which are compiled to package-private; this is more of the same gap that nestmates was intended to close.
27-10-2018

This is not a high priority, and I don't expect it to be pursued in the near future. But maybe in the medium term.
26-10-2018