Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java @ 6070:0251d217257f
7162726: Wrong filter predicate of visible locals in SA JSJavaFrame
Reviewed-by: sla, dcubed
Contributed-by: Krystal Mok <rednaxelafx@gmail.com>
author | sla |
---|---|
date | Tue, 08 May 2012 20:28:35 +0200 |
parents | 63997f575155 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
2411
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
1552
diff
changeset
|
2 * Copyright (c) 2004, 2011, 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.utilities.soql; | |
26 | |
27 import java.lang.ref.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.oops.*; | |
30 import sun.jvm.hotspot.runtime.*; | |
31 import sun.jvm.hotspot.utilities.*; | |
32 | |
33 public class JSJavaFactoryImpl implements JSJavaFactory { | |
34 public JSJavaObject newJSJavaObject(Oop oop) { | |
35 if (oop == null) return null; | |
36 SoftReference sref = (SoftReference) om.get(oop); | |
37 JSJavaObject res = (sref != null)? (JSJavaObject) sref.get() : null; | |
38 if (res == null) { | |
39 if (oop instanceof TypeArray) { | |
40 res = new JSJavaTypeArray((TypeArray)oop, this); | |
41 } else if (oop instanceof ObjArray) { | |
42 res = new JSJavaObjArray((ObjArray)oop, this); | |
43 } else if (oop instanceof Instance) { | |
44 res = newJavaInstance((Instance) oop); | |
45 } else if (oop instanceof Method) { | |
46 res = new JSJavaMethod((Method) oop, this); | |
47 } | |
48 } | |
49 if (res != null) { | |
50 om.put(oop, new SoftReference(res)); | |
51 } | |
52 return res; | |
53 } | |
54 | |
55 public JSJavaKlass newJSJavaKlass(Klass klass) { | |
56 JSJavaKlass res = null; | |
57 if (klass instanceof InstanceKlass) { | |
58 res = new JSJavaInstanceKlass((InstanceKlass) klass, this); | |
59 } else if (klass instanceof ObjArrayKlass) { | |
60 res = new JSJavaObjArrayKlass((ObjArrayKlass) klass, this); | |
61 } else if (klass instanceof TypeArrayKlass) { | |
62 res = new JSJavaTypeArrayKlass((TypeArrayKlass) klass, this); | |
63 } | |
64 if (res != null) { | |
65 om.put(klass, new SoftReference(res)); | |
66 } | |
67 return res; | |
68 } | |
69 | |
70 public JSJavaField newJSJavaField(Field field) { | |
71 if (field == null) return null; | |
72 return new JSJavaField(field, this); | |
73 } | |
74 | |
75 public JSJavaThread newJSJavaThread(JavaThread jthread) { | |
76 if (jthread == null) return null; | |
77 return new JSJavaThread(jthread, this); | |
78 } | |
79 | |
80 public JSJavaFrame newJSJavaFrame(JavaVFrame jvf) { | |
81 if (jvf == null) return null; | |
82 return new JSJavaFrame(jvf, this); | |
83 } | |
84 | |
85 public JSList newJSList(List list) { | |
86 if (list == null) return null; | |
87 return new JSList(list, this); | |
88 } | |
89 | |
90 public JSMap newJSMap(Map map) { | |
91 if (map == null) return null; | |
92 return new JSMap(map, this); | |
93 } | |
94 | |
95 public Object newJSJavaWrapper(Object item) { | |
96 if (item == null) return null; | |
97 if (item instanceof Oop) { | |
98 return newJSJavaObject((Oop) item); | |
99 } else if (item instanceof Field) { | |
100 return newJSJavaField((Field) item); | |
101 } else if (item instanceof JavaThread) { | |
102 return newJSJavaThread((JavaThread) item); | |
103 } else if (item instanceof JavaVFrame) { | |
104 return newJSJavaFrame((JavaVFrame) item); | |
105 } else if (item instanceof List) { | |
106 return newJSList((List) item); | |
107 } else if (item instanceof Map) { | |
108 return newJSMap((Map) item); | |
109 } else { | |
110 // not-a-special-type, just return the input item | |
111 return item; | |
112 } | |
113 } | |
114 | |
115 public JSJavaHeap newJSJavaHeap() { | |
116 return new JSJavaHeap(this); | |
117 } | |
118 | |
119 public JSJavaVM newJSJavaVM() { | |
120 return new JSJavaVM(this); | |
121 } | |
122 | |
123 // -- Internals only below this point | |
124 private Symbol javaLangString() { | |
125 if (javaLangString == null) { | |
126 javaLangString = getSymbol("java/lang/String"); | |
127 } | |
128 return javaLangString; | |
129 } | |
130 | |
131 private Symbol javaLangThread() { | |
132 if (javaLangThread == null) { | |
133 javaLangThread = getSymbol("java/lang/Thread"); | |
134 } | |
135 return javaLangThread; | |
136 } | |
137 | |
138 private Symbol javaLangClass() { | |
139 if (javaLangClass == null) { | |
140 javaLangClass = getSymbol("java/lang/Class"); | |
141 } | |
142 return javaLangClass; | |
143 } | |
144 | |
145 private Symbol getSymbol(String str) { | |
146 return VM.getVM().getSymbolTable().probe(str); | |
147 } | |
148 | |
149 private JSJavaObject newJavaInstance(Instance instance) { | |
150 // look for well-known classes | |
151 Symbol className = instance.getKlass().getName(); | |
152 if (Assert.ASSERTS_ENABLED) { | |
153 Assert.that(className != null, "Null class name"); | |
154 } | |
155 JSJavaObject res = null; | |
156 if (className.equals(javaLangString())) { | |
157 res = new JSJavaString(instance, this); | |
158 } else if (className.equals(javaLangThread())) { | |
159 res = new JSJavaThread(instance, this); | |
160 } else if (className.equals(javaLangClass())) { | |
2411
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
1552
diff
changeset
|
161 Klass reflectedType = java_lang_Class.asKlass(instance); |
0 | 162 if (reflectedType != null) { |
163 JSJavaKlass jk = newJSJavaKlass(reflectedType); | |
164 // we don't support mirrors of VM internal Klasses | |
165 if (jk == null) return null; | |
166 res = new JSJavaClass(instance, jk, this); | |
167 } else { | |
168 // for primitive Classes, the reflected type is null | |
169 return null; | |
170 } | |
171 } else { | |
172 // not a well-known class. But the base class may be | |
173 // one of the known classes. | |
174 Klass kls = instance.getKlass().getSuper(); | |
175 while (kls != null) { | |
176 className = kls.getName(); | |
177 // java.lang.Class and java.lang.String are final classes | |
178 if (className.equals(javaLangThread())) { | |
179 res = new JSJavaThread(instance, this); | |
180 break; | |
181 } | |
182 kls = kls.getSuper(); | |
183 } | |
184 } | |
185 if (res == null) { | |
186 res = new JSJavaInstance(instance, this); | |
187 } | |
188 return res; | |
189 } | |
190 | |
191 // Map<Oop, SoftReference<JSJavaObject>> | |
192 private Map om = new HashMap(); | |
193 private Symbol javaLangString; | |
194 private Symbol javaLangThread; | |
195 private Symbol javaLangClass; | |
196 } |