If you decompile the java.lang.Class class in java from the rt.jar library you will notice there is a native method declaration:
native ConstantPool getConstantPool();
I played a while ago with class decompilation using Sun's .class file specification and I was able to obtain the constant pool record from each .class file. But that was actually decompiling classes.
It's just that I was surprised to see this signature in the Class class. So what I did is I wrote a small piece of code in the Main() method:
ConstantPool cp = new ConstantPool();
cp.getMethodAtIfLoaded(0);
If you decompile the sun.reflect.ConstantPool class you will notice it has a lot of method related to classes, method, parameters, fields declared, etc.
When I execute the app, I get this HotSpot exception:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d7e01d3, pid=2816, tid=5464
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_15-b04 mixed mode)
# Problematic frame:
# V [jvm.dll+0xa01d3]
#
# An error report file with more information is saved as hs_err_pid2816.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Why can't I get the ConstantPool of any class? Considering the fact that getConstantPool() is a native/non-public method I assume Sun does not want me to call it directly.