From 6b7ae0f792823658c678749cad302fc5fbc48277 Mon Sep 17 00:00:00 2001 From: minqi Date: Fri, 22 Jun 2012 15:35:30 -0700 Subject: [PATCH] 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 --- .../sun/jvm/hotspot/oops/OopUtilities.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java index edd8a8064..a42d8be68 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -141,18 +141,19 @@ public class OopUtilities implements /* imports */ JVMTIThreadState { public static String stringOopToString(Oop stringOop) { if (offsetField == null) { InstanceKlass k = (InstanceKlass) stringOop.getKlass(); - offsetField = (IntField) k.findField("offset", "I"); - countField = (IntField) k.findField("count", "I"); + offsetField = (IntField) k.findField("offset", "I"); // optional + countField = (IntField) k.findField("count", "I"); // optional valueField = (OopField) k.findField("value", "[C"); if (Assert.ASSERTS_ENABLED) { - Assert.that(offsetField != null && - countField != null && - valueField != null, "must find all java.lang.String fields"); + Assert.that(valueField != null, "Field \'value\' of java.lang.String not found"); } } - return charArrayToString((TypeArray) valueField.getValue(stringOop), - offsetField.getValue(stringOop), - countField.getValue(stringOop)); + if (offsetField != null && countField != null) { + return charArrayToString((TypeArray) valueField.getValue(stringOop), + offsetField.getValue(stringOop), + countField.getValue(stringOop)); + } + return charArrayToString((TypeArray) valueField.getValue(stringOop)); } public static String stringOopToEscapedString(Oop stringOop) { -- GitLab