RFR: JDK-8152115 (proxy) Examine performance of dynamic proxy creation

Peter Levart peter.levart at gmail.com
Fri Apr 8 10:41:01 UTC 2016


With Mandy we have prepared the following patch to restore performance 
of java.lanf.reflect.Proxy class caching that has regressed with 
introduction of additional checks that have to be performed due to modules:


Jigsaw changed caching of proxy classes  from ClassLoader+interfaces to 
Module+interfaces to accommodate possible future extension of the API 
that might take given Module as a parameter. Additional validation of 
constraints and derivation of dynamic module to host proxy class was 
performed on the fast path, degrading performance. This change restores 
the caching back to ClassLoader+interfaces, but also introduces new 
caching mechanism that allows simple derivation of other coexisting 
caching schemes that can support possible additions to the Proxy API. 
The new mechanism also simplifies caching by avoiding the need to 
reference ClassLoader and interfaces through WeakReference objects. 
Instead it uses a single ConcurrentHashMap per ClassLoader instance 
referenced directly from ClassLoader object. The caching API - 
ClassLoaderValue - is general enough to be used for other purposes where 
caching per ClassLoader is desired. Currently it is encapsulated as a 
java.lang.reflect package-private API, but could simply be promoted to a 
public API in an internal concealed package if desired.

Performance of Proxy class caching is back to pre-jigsaw state and even 



I haven't yet removed the superfluous checking and providing access from 
dynamic module to the modules/packages of transitive closure of 
interfaces implemented by proxy class. I think this should be done in a 
separate issue so that this change doesn't change the semantics of 

Regards, Peter

More information about the core-libs-dev mailing list