JDK-8229871 : Improve performance of Method.copy() and leafCopy()
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2019-08-19
  • Updated: 2023-11-03
  • Resolved: 2023-11-03
Related Reports
Duplicate :  
Description
Method.copy() and leafCopy() creates a copy of a Method object with sharing MethodAccessor object.  Since the methodAccessor field is a volatile variable, copying this field needs memory fence to ensure the field is visible to all threads on the weak memory platforms such as POWER and ARM.

When the methodAccessor of the root object is null (i.e., not initialized yet), we do not need to copy the null value because this field of the copied object has been initialized to null in the constructor.  We can reduce overhead of the memory fence only when the root's methodAccessor is non-null.
Comments
JDK-8274299 removed the volatile modifiers on the accessors; this issue is no longer applicable.
03-11-2023