7175133: jinfo failed to get system properties after 6924259
authorminqi
Fri, 22 Jun 2012 15:35:30 -0700
changeset 13094 110c9357d14b
parent 13093 ad8f15a5cd05
child 13095 e963ab7b3a6f
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
hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Wed Jun 20 14:29:23 2012 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Fri Jun 22 15:35:30 2012 -0700
@@ -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 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) {