JDK-8130089 : 5.4.3.5: Avoid unnecessary resolution steps for CONSTANT_MethodType
  • Type: Enhancement
  • Component: specification
  • Sub-Component: vm
  • Affected Version: 7
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2015-06-29
  • Updated: 2024-10-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Relates :  
Relates :  
Description
Resolution of a CONSTANT_MethodType occurs by resolving each mentioned class.  This, in turn, requires loading each class and testing that it is accessible to the caller.

Compared to the process for resolving a field or method reference (5.4.3.2, 5.4.3.3), this carries additional overhead and can prompt unwanted errors.  Method descriptors need not name accessible classes -- in fact, they need not name classes that exist at all (as long as the verification rules are still satisfied).

It might be better to avoid checking the classes named by a MethodType for accessibility; further, if the MethodType API can be enhanced to avoid requiring Class objects (JDK-8130087), it would be possible to construct a MethodType with the referenced descriptor directly, rather than resolving the named classes first.
Comments
This MethodType class accessibility check has prevented java.lang.reflect.Proxy implementation to use MethodType constants to represent method descriptors. Interfaces can declare methods with package-private return or parameter types and still have such methods overridden in implementing classes. That said, now this check is part of VM implementations and in the reference implementation of MethodTypeDesc::resolveConstantDesc, changing this behavior may result in an incompatibility.
18-10-2024