提交 6b7ae0f7 编写于 作者: M minqi

7175133: jinfo failed to get system properties after 6924259

Summary: String offset and count fields as fix of 6924259 were removed, and become optional. SA still use offset and count fields to read String contents and failed. Fix if they exist, use them other then use value field only to read, this keeps consistent with the changes in 6924259.
Reviewed-by: dholmes, mikael
Contributed-by: yumin.qi@oracle.com
上级 cac79fe8
/* /*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -141,18 +141,19 @@ public class OopUtilities implements /* imports */ JVMTIThreadState { ...@@ -141,18 +141,19 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
public static String stringOopToString(Oop stringOop) { public static String stringOopToString(Oop stringOop) {
if (offsetField == null) { if (offsetField == null) {
InstanceKlass k = (InstanceKlass) stringOop.getKlass(); InstanceKlass k = (InstanceKlass) stringOop.getKlass();
offsetField = (IntField) k.findField("offset", "I"); offsetField = (IntField) k.findField("offset", "I"); // optional
countField = (IntField) k.findField("count", "I"); countField = (IntField) k.findField("count", "I"); // optional
valueField = (OopField) k.findField("value", "[C"); valueField = (OopField) k.findField("value", "[C");
if (Assert.ASSERTS_ENABLED) { if (Assert.ASSERTS_ENABLED) {
Assert.that(offsetField != null && Assert.that(valueField != null, "Field \'value\' of java.lang.String not found");
countField != null &&
valueField != null, "must find all java.lang.String fields");
} }
} }
return charArrayToString((TypeArray) valueField.getValue(stringOop), if (offsetField != null && countField != null) {
offsetField.getValue(stringOop), return charArrayToString((TypeArray) valueField.getValue(stringOop),
countField.getValue(stringOop)); offsetField.getValue(stringOop),
countField.getValue(stringOop));
}
return charArrayToString((TypeArray) valueField.getValue(stringOop));
} }
public static String stringOopToEscapedString(Oop stringOop) { public static String stringOopToEscapedString(Oop stringOop) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册