8163272: jhsdb jinfo cannot show system properties
Reviewed-by: dholmes, dsamersoff
This commit is contained in:
parent
8857b866e7
commit
4d61582818
@ -26,6 +26,7 @@ package sun.jvm.hotspot.utilities;
|
|||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.*;
|
||||||
import sun.jvm.hotspot.debugger.*;
|
import sun.jvm.hotspot.debugger.*;
|
||||||
import sun.jvm.hotspot.oops.*;
|
import sun.jvm.hotspot.oops.*;
|
||||||
import sun.jvm.hotspot.runtime.*;
|
import sun.jvm.hotspot.runtime.*;
|
||||||
@ -204,15 +205,29 @@ public class ObjectReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object getHashtable(Instance oop, boolean isProperties) {
|
private void setPropertiesEntry(java.util.Properties p, Oop oop) {
|
||||||
|
InstanceKlass ik = (InstanceKlass)oop.getKlass();
|
||||||
|
OopField keyField = (OopField)ik.findField("key", "Ljava/lang/Object;");
|
||||||
|
OopField valueField = (OopField)ik.findField("val", "Ljava/lang/Object;");
|
||||||
|
|
||||||
|
try {
|
||||||
|
p.setProperty((String)readObject(keyField.getValue(oop)),
|
||||||
|
(String)readObject(valueField.getValue(oop)));
|
||||||
|
} catch (ClassNotFoundException ce) {
|
||||||
|
if (DEBUG) {
|
||||||
|
debugPrintStackTrace(ce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Object getHashtable(Instance oop) {
|
||||||
InstanceKlass k = (InstanceKlass)oop.getKlass();
|
InstanceKlass k = (InstanceKlass)oop.getKlass();
|
||||||
OopField tableField = (OopField)k.findField("table", "[Ljava/util/Hashtable$Entry;");
|
OopField tableField = (OopField)k.findField("table", "[Ljava/util/Hashtable$Entry;");
|
||||||
if (tableField == null) {
|
if (tableField == null) {
|
||||||
debugPrintln("Could not find field of [Ljava/util/Hashtable$Entry;");
|
debugPrintln("Could not find field of [Ljava/util/Hashtable$Entry;");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
java.util.Hashtable table = (isProperties) ? new java.util.Properties()
|
java.util.Hashtable table = new java.util.Hashtable();
|
||||||
: new java.util.Hashtable();
|
|
||||||
ObjArray kvs = (ObjArray)tableField.getValue(oop);
|
ObjArray kvs = (ObjArray)tableField.getValue(oop);
|
||||||
long size = kvs.getLength();
|
long size = kvs.getLength();
|
||||||
debugPrintln("Hashtable$Entry Size = " + size);
|
debugPrintln("Hashtable$Entry Size = " + size);
|
||||||
@ -225,6 +240,39 @@ public class ObjectReader {
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Properties getProperties(Instance oop) {
|
||||||
|
InstanceKlass k = (InstanceKlass)oop.getKlass();
|
||||||
|
OopField mapField = (OopField)k.findField("map", "Ljava/util/concurrent/ConcurrentHashMap;");
|
||||||
|
if (mapField == null) {
|
||||||
|
debugPrintln("Could not find field of Ljava/util/concurrent/ConcurrentHashMap");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance mapObj = (Instance)mapField.getValue(oop);
|
||||||
|
if (mapObj == null) {
|
||||||
|
debugPrintln("Could not get map field from java.util.Properties");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
InstanceKlass mk = (InstanceKlass)mapObj.getKlass();
|
||||||
|
OopField tableField = (OopField)mk.findField("table", "[Ljava/util/concurrent/ConcurrentHashMap$Node;");
|
||||||
|
if (tableField == null) {
|
||||||
|
debugPrintln("Could not find field of [Ljava/util/concurrent/ConcurrentHashMap$Node");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
java.util.Properties props = new java.util.Properties();
|
||||||
|
ObjArray kvs = (ObjArray)tableField.getValue(mapObj);
|
||||||
|
long size = kvs.getLength();
|
||||||
|
debugPrintln("ConcurrentHashMap$Node Size = " + size);
|
||||||
|
LongStream.range(0, size)
|
||||||
|
.mapToObj(kvs::getObjAt)
|
||||||
|
.filter(o -> o != null)
|
||||||
|
.forEach(o -> setPropertiesEntry(props, o));
|
||||||
|
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
public Object readInstance(Instance oop) throws ClassNotFoundException {
|
public Object readInstance(Instance oop) throws ClassNotFoundException {
|
||||||
Object result = getFromObjTable(oop);
|
Object result = getFromObjTable(oop);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -240,11 +288,11 @@ public class ObjectReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (kls.getName().equals(javaUtilHashtable())) {
|
if (kls.getName().equals(javaUtilHashtable())) {
|
||||||
return getHashtable(oop, false);
|
return getHashtable(oop);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kls.getName().equals(javaUtilProperties())) {
|
if (kls.getName().equals(javaUtilProperties())) {
|
||||||
return getHashtable(oop, true);
|
return getProperties(oop);
|
||||||
}
|
}
|
||||||
|
|
||||||
Class clz = readClass(kls);
|
Class clz = readClass(kls);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user