[nestmates] setAccessible(true) restriction on hidden classes

Mandy Chung mandy.chung at oracle.com
Tue Sep 10 23:27:03 UTC 2019


One restriction we proposed for hidden class is that it does not allow 
setAccessible(true) on members of hidden classes.  This ensures that 
private internals of a language runtime are not accessible from outside 
the implementation.

The compatibility concern seems to be higher than what we anticipated.  
Libraries reflecting on lambda proxy classes and calls 
setAccessible(true) on their members unconditionally are impacted by 
this.  Our testing shows that cassandra uses MemoryMeter library that 
does this.

setAccessible can suppress language access check only if the declaring 
class is in the same module as the caller or the package of the 
declaring class is not open to the caller's module.  To mitigate the 
incompatibility concern, I propose to relax the restriction on hidden 
classes and follow the existing setAccessible rules.  If a hidden class 
is injected in a package that is open to the caller for deep reflection, 
setAccessible(true) will succeed.

Comments?

Mandy
[1] 
https://download.java.net/java/early_access/jdk14/docs/api/java.base/java/lang/reflect/AccessibleObject.html#setAccessible(boolean)



More information about the valhalla-dev mailing list