JDK-6823296 : (reflect) getDeclaredMethod, getMethod, getDeclaredField, getField cause many classes to be loaded
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 7
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2009-03-27
  • Updated: 2024-04-12
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 :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
The current implementation of getting a single method (i.e. Class.getDeclaredMethod and getMethod) has the same class loading effect as Class.getDeclaredMethods and Class.getMethods to obtain all methods.  It will resolve all types declared in the method signatures.

Similiarly for Class.getDeclaredField and getField, getting a single field will cause loading of the class of all types for all fields like Class.getDeclaredFields and getFields.

This causes additional classes that are not used to be loaded. e.g. 
java.awt.PopupMenu and other classes loaded due to java.awt.Component.class.getDeclaredMethod() call.

Comments
When this gets fixed, double check that duplicate bug JDK-6888126 is also fixed.
15-03-2017

I've removed the modularization label from this issue as this issue is no longer important for our modularity effort (mostly because the modules are more coarse grain that was originally investigated back when this issue was created).
08-02-2014