Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/TypeArrayKlass.java @ 3962:cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
Reviewed-by: kvn
author | never |
---|---|
date | Thu, 29 Sep 2011 09:53:56 -0700 |
parents | c18cbe5936b8 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.oops; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.runtime.*; | |
31 import sun.jvm.hotspot.types.*; | |
32 import sun.jvm.hotspot.utilities.*; | |
33 | |
34 // TypeArrayKlass is a proxy for typeArrayKlass in the JVM | |
35 | |
36 public class TypeArrayKlass extends ArrayKlass { | |
37 static { | |
38 VM.registerVMInitializedObserver(new Observer() { | |
39 public void update(Observable o, Object data) { | |
40 initialize(VM.getVM().getTypeDataBase()); | |
41 } | |
42 }); | |
43 } | |
44 | |
45 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | |
46 Type t = db.lookupType("typeArrayKlass"); | |
47 maxLength = new CIntField(t.getCIntegerField("_max_length"), Oop.getHeaderSize()); | |
48 } | |
49 | |
50 TypeArrayKlass(OopHandle handle, ObjectHeap heap) { | |
51 super(handle, heap); | |
52 } | |
53 | |
54 private static CIntField maxLength; | |
55 | |
56 public long getMaxLength() { return maxLength.getValue(this); } | |
57 | |
58 public static final int T_BOOLEAN = 4; | |
59 public static final int T_CHAR = 5; | |
60 public static final int T_FLOAT = 6; | |
61 public static final int T_DOUBLE = 7; | |
62 public static final int T_BYTE = 8; | |
63 public static final int T_SHORT = 9; | |
64 public static final int T_INT = 10; | |
65 public static final int T_LONG = 11; | |
66 | |
67 public String getTypeName() { | |
68 switch ((int) getElementType()) { | |
69 case T_BOOLEAN: return "[Z"; | |
70 case T_CHAR: return "[C"; | |
71 case T_FLOAT: return "[F"; | |
72 case T_DOUBLE: return "[D"; | |
73 case T_BYTE: return "[B"; | |
74 case T_SHORT: return "[S"; | |
75 case T_INT: return "[I"; | |
76 case T_LONG: return "[J"; | |
77 } | |
78 return "Unknown TypeArray"; | |
79 } | |
80 | |
81 public String getElementTypeName() { | |
82 switch ((int) getElementType()) { | |
83 case T_BOOLEAN: return "boolean"; | |
84 case T_CHAR: return "char"; | |
85 case T_FLOAT: return "float"; | |
86 case T_DOUBLE: return "double"; | |
87 case T_BYTE: return "byte"; | |
88 case T_SHORT: return "short"; | |
89 case T_INT: return "int"; | |
90 case T_LONG: return "long"; | |
91 } | |
92 throw new RuntimeException("should not reach here"); | |
93 } | |
94 | |
95 public void printValueOn(PrintStream tty) { | |
96 tty.print("TypeArrayKlass for " + getTypeName()); | |
97 } | |
98 | |
99 public void iterateFields(OopVisitor visitor, boolean doVMFields) { | |
100 super.iterateFields(visitor, doVMFields); | |
101 if (doVMFields) { | |
102 visitor.doCInt(maxLength, true); | |
103 } | |
104 } | |
105 | |
106 public Klass arrayKlassImpl(boolean orNull, int n) { | |
107 int dimension = (int) getDimension(); | |
108 if (Assert.ASSERTS_ENABLED) { | |
109 Assert.that(dimension <= n, "check order of chain"); | |
110 } | |
111 if (dimension == n) | |
112 return this; | |
113 ObjArrayKlass ak = (ObjArrayKlass) getHigherDimension(); | |
114 if (ak == null) { | |
115 if (orNull) return null; | |
116 // FIXME: would need to change in reflective system to actually | |
117 // allocate klass | |
118 throw new RuntimeException("Can not allocate array klasses in debugging system"); | |
119 } | |
120 if (orNull) { | |
121 return ak.arrayKlassOrNull(n); | |
122 } | |
123 return ak.arrayKlass(n); | |
124 } | |
125 | |
126 public Klass arrayKlassImpl(boolean orNull) { | |
127 return arrayKlassImpl(orNull, (int) (getDimension() + 1)); | |
128 } | |
129 } |