JDK-8046666 : (reflect) Reduce allocations in Class.MethodArray.matchesNameAndDescriptor()
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2014-06-12
  • Updated: 2022-05-18
  • Resolved: 2022-05-18
Related Reports
Relates :  
Description
Peter Levart noted:

"I don't know if this is warranted, since this is on slow path (the resulting methods are cached) and the number of overloaded methods is typically not large, but the following MethodArray method:

2803         private boolean matchesNameAndDescriptor(Method m1, Method m2) {

could use a JavaLangAccess bridge to access the Method's parameter types without cloning the array each time.  Especially since it's called many times inside nested loop (see removeLessSpecifics()) where the number of invocations grows quadratically with the MethodArray's length. Method.getParameterTypes() is only invoked for pairs of overloaded methods, so this might not be a real issue."
Comments
The code in question was removed by JDK-8062389, closing as Not an Issue.
18-05-2022

We need access to non-public fields on Method, that implies LangReflectAccess, but that ins't used in Class today.
12-06-2014