comparison agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java @ 6169:cfa2c82f4c04

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
author minqi
date Fri, 22 Jun 2012 15:35:30 -0700
parents f6f3bb0ee072
children f9d003ea9023
comparison
equal deleted inserted replaced
6168:7de1d3b57419 6169:cfa2c82f4c04
1 /* 1 /*
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
139 } 139 }
140 140
141 public static String stringOopToString(Oop stringOop) { 141 public static String stringOopToString(Oop stringOop) {
142 if (offsetField == null) { 142 if (offsetField == null) {
143 InstanceKlass k = (InstanceKlass) stringOop.getKlass(); 143 InstanceKlass k = (InstanceKlass) stringOop.getKlass();
144 offsetField = (IntField) k.findField("offset", "I"); 144 offsetField = (IntField) k.findField("offset", "I"); // optional
145 countField = (IntField) k.findField("count", "I"); 145 countField = (IntField) k.findField("count", "I"); // optional
146 valueField = (OopField) k.findField("value", "[C"); 146 valueField = (OopField) k.findField("value", "[C");
147 if (Assert.ASSERTS_ENABLED) { 147 if (Assert.ASSERTS_ENABLED) {
148 Assert.that(offsetField != null && 148 Assert.that(valueField != null, "Field \'value\' of java.lang.String not found");
149 countField != null && 149 }
150 valueField != null, "must find all java.lang.String fields"); 150 }
151 } 151 if (offsetField != null && countField != null) {
152 } 152 return charArrayToString((TypeArray) valueField.getValue(stringOop),
153 return charArrayToString((TypeArray) valueField.getValue(stringOop), 153 offsetField.getValue(stringOop),
154 offsetField.getValue(stringOop), 154 countField.getValue(stringOop));
155 countField.getValue(stringOop)); 155 }
156 return charArrayToString((TypeArray) valueField.getValue(stringOop));
156 } 157 }
157 158
158 public static String stringOopToEscapedString(Oop stringOop) { 159 public static String stringOopToEscapedString(Oop stringOop) {
159 return escapeString(stringOopToString(stringOop)); 160 return escapeString(stringOopToString(stringOop));
160 } 161 }