7175133: jinfo failed to get system properties after 6924259

Fri, 22 Jun 2012 15:35:30 -0700

author
minqi
date
Fri, 22 Jun 2012 15:35:30 -0700
changeset 3872
cfa2c82f4c04
parent 3871
7de1d3b57419
child 3873
d8a240abb23a

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

agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java file | annotate | diff | comparison | revisions
     1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Wed Jun 20 14:29:23 2012 -0700
     1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Fri Jun 22 15:35:30 2012 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -141,18 +141,19 @@
    1.11    public static String stringOopToString(Oop stringOop) {
    1.12      if (offsetField == null) {
    1.13        InstanceKlass k = (InstanceKlass) stringOop.getKlass();
    1.14 -      offsetField = (IntField) k.findField("offset", "I");
    1.15 -      countField  = (IntField) k.findField("count",  "I");
    1.16 +      offsetField = (IntField) k.findField("offset", "I");   // optional
    1.17 +      countField  = (IntField) k.findField("count",  "I");   // optional
    1.18        valueField  = (OopField) k.findField("value",  "[C");
    1.19        if (Assert.ASSERTS_ENABLED) {
    1.20 -        Assert.that(offsetField != null &&
    1.21 -                    countField != null &&
    1.22 -                    valueField != null, "must find all java.lang.String fields");
    1.23 +         Assert.that(valueField != null, "Field \'value\' of java.lang.String not found");
    1.24        }
    1.25      }
    1.26 -    return charArrayToString((TypeArray) valueField.getValue(stringOop),
    1.27 -                             offsetField.getValue(stringOop),
    1.28 -                             countField.getValue(stringOop));
    1.29 +    if (offsetField != null && countField != null) {
    1.30 +      return charArrayToString((TypeArray) valueField.getValue(stringOop),
    1.31 +                               offsetField.getValue(stringOop),
    1.32 +                               countField.getValue(stringOop));
    1.33 +    }
    1.34 +    return  charArrayToString((TypeArray) valueField.getValue(stringOop));
    1.35    }
    1.36  
    1.37    public static String stringOopToEscapedString(Oop stringOop) {

mercurial