Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/oops/java_lang_Class.java @ 2411:63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
Reviewed-by: kvn, dcubed
author | never |
---|---|
date | Wed, 30 Mar 2011 07:47:19 -0700 |
parents | |
children | e6b1331a51d2 |
comparison
equal
deleted
inserted
replaced
2410:fe1dbd98e18f | 2411:63997f575155 |
---|---|
1 /* | |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 package sun.jvm.hotspot.oops; | |
26 | |
27 import java.util.*; | |
28 | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.memory.*; | |
31 import sun.jvm.hotspot.runtime.*; | |
32 import sun.jvm.hotspot.types.Type; | |
33 import sun.jvm.hotspot.types.TypeDataBase; | |
34 import sun.jvm.hotspot.utilities.*; | |
35 import sun.jvm.hotspot.jdi.JVMTIThreadState; | |
36 | |
37 /** A utility class encapsulating useful oop operations */ | |
38 | |
39 // initialize fields for java.lang.Class | |
40 public class java_lang_Class { | |
41 | |
42 // java.lang.Class fields | |
43 static OopField klassField; | |
44 static IntField oopSizeField; | |
45 | |
46 static { | |
47 VM.registerVMInitializedObserver(new Observer() { | |
48 public void update(Observable o, Object data) { | |
49 initialize(VM.getVM().getTypeDataBase()); | |
50 } | |
51 }); | |
52 } | |
53 | |
54 private static synchronized void initialize(TypeDataBase db) { | |
55 // klass and oop_size are HotSpot magic fields and hence we can't | |
56 // find them from InstanceKlass for java.lang.Class. | |
57 Type jlc = db.lookupType("java_lang_Class"); | |
58 int klassOffset = (int) jlc.getCIntegerField("klass_offset").getValue(); | |
59 if (VM.getVM().isCompressedOopsEnabled()) { | |
60 klassField = new NarrowOopField(new NamedFieldIdentifier("klass"), klassOffset, true); | |
61 } else { | |
62 klassField = new OopField(new NamedFieldIdentifier("klass"), klassOffset, true); | |
63 } | |
64 int oopSizeOffset = (int) jlc.getCIntegerField("oop_size_offset").getValue(); | |
65 oopSizeField = new IntField(new NamedFieldIdentifier("oop_size"), oopSizeOffset, true); | |
66 } | |
67 | |
68 /** get klassOop field at offset hc_klass_offset from a java.lang.Class object */ | |
69 public static Klass asKlass(Oop aClass) { | |
70 return (Klass) java_lang_Class.klassField.getValue(aClass); | |
71 } | |
72 | |
73 /** get oop_size field at offset oop_size_offset from a java.lang.Class object */ | |
74 public static long getOopSize(Oop aClass) { | |
75 return java_lang_Class.oopSizeField.getValue(aClass); | |
76 } | |
77 } |