7145358: SA throws ClassCastException for partially loaded ConstantPool
Summary: In printValueOn() in ConstantPool.java check if the poolHolder is a valid Klass and only then print it.
Reviewed-by: sla, sspitsyn
Contributed-by: Krystal Mok <sajia@taobao.com>
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Sun Feb 19 13:11:39 2012 +0100
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Mon Feb 20 21:27:56 2012 -0800
@@ -648,7 +648,12 @@
}
public void printValueOn(PrintStream tty) {
- tty.print("ConstantPool for " + getPoolHolder().getName().asString());
+ Oop holder = poolHolder.getValue(this);
+ if (holder instanceof Klass) {
+ tty.print("ConstantPool for " + ((Klass)holder).getName().asString());
+ } else {
+ tty.print("ConstantPool for partially loaded class");
+ }
}
public long getObjectSize() {