JDK-6527368 : Class.getDeclaringClass() resolves unnecessary constant pool entries
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2007-02-22
  • Updated: 2015-02-23
  • Resolved: 2015-02-23
Related Reports
Relates :  
The HotSpot native implementation of
Class.getDeclaringClass() cross-checks the relationship between
the nested class and the enclosing class using the "inner_classes"
attributes in respective class files of the two classes. The
current implementation can resolve inner_classes entries which
are class constants other than the two relevant classes. This wastes
time and memory and can also trigger incorrect ClassCircularityErrors
in some cases when getDeclaringClass() is called directly or indirectly
in a class loader's loadClass() implementation.

The HotSpot implementation of the getDeclaringClass()
native method in jvm.cpp actually attempts to avoid
resolving irrelevant constant pool entries by calling
klass_name_at_matches() before calling klass_at().
However, it then calls Reflection:check_for_inner_classes()
which does not attempt to avoid constant pool class
entries with irrelevant class names.

We're not going to change this, the code has worked this way for years without issues. Changing it seems like an unnecessary risk. Closing as WNF