Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/jdi/MethodImpl.java @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 37be97a58393 |
children |
rev | line source |
---|---|
0 | 1 /* |
2471
37be97a58393
7010849: 5/5 Extraneous javac source/target options when building sa-jdi
andrew
parents:
1552
diff
changeset
|
2 * Copyright (c) 2002, 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.jdi; | |
26 | |
27 import com.sun.jdi.*; | |
28 import sun.jvm.hotspot.oops.Symbol; | |
29 import sun.jvm.hotspot.oops.LocalVariableTableElement; | |
30 import java.util.List; | |
31 import java.util.Iterator; | |
32 import java.util.ArrayList; | |
33 import java.util.Comparator; | |
34 import java.lang.ref.SoftReference; | |
35 import java.util.Collections; | |
36 | |
37 public abstract class MethodImpl extends TypeComponentImpl implements Method { | |
38 private JNITypeParser signatureParser; | |
39 protected sun.jvm.hotspot.oops.Method saMethod; | |
40 | |
41 abstract int argSlotCount() throws AbsentInformationException; | |
42 abstract List allLineLocations(SDE.Stratum stratum, | |
43 String sourceName) | |
44 throws AbsentInformationException; | |
45 abstract List locationsOfLine(SDE.Stratum stratum, | |
46 String sourceName, | |
47 int lineNumber) | |
48 throws AbsentInformationException; | |
49 | |
50 static MethodImpl createMethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, | |
51 sun.jvm.hotspot.oops.Method saMethod) { | |
52 // Someday might have to add concrete and non-concrete subclasses. | |
53 if (saMethod.isNative() || saMethod.isAbstract()) { | |
54 return new NonConcreteMethodImpl(vm, declaringType, saMethod); | |
55 } else { | |
56 return new ConcreteMethodImpl(vm, declaringType, saMethod); | |
57 } | |
58 } | |
59 | |
60 MethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, | |
61 sun.jvm.hotspot.oops.Method saMethod ) { | |
62 super(vm, declaringType); | |
63 this.saMethod = saMethod; | |
64 getParser(); | |
65 } | |
66 | |
67 private JNITypeParser getParser() { | |
68 if (signatureParser == null) { | |
69 Symbol sig1 = saMethod.getSignature(); | |
70 signature = sig1.asString(); | |
71 signatureParser = new JNITypeParser(signature); | |
72 } | |
73 return signatureParser; | |
74 } | |
75 | |
76 // Object ref() { | |
77 sun.jvm.hotspot.oops.Method ref() { | |
78 return saMethod; | |
79 } | |
80 | |
81 public String genericSignature() { | |
82 Symbol genSig = saMethod.getGenericSignature(); | |
83 return (genSig != null)? genSig.asString() : null; | |
84 } | |
85 | |
86 public String returnTypeName() { | |
87 return getParser().typeName(); | |
88 } | |
89 | |
90 public Type returnType() throws ClassNotLoadedException { | |
91 return findType(getParser().signature()); | |
92 } | |
93 | |
94 private Type findType(String signature) throws ClassNotLoadedException { | |
95 ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType(); | |
96 return enclosing.findType(signature); | |
97 } | |
98 | |
99 public List argumentTypeNames() { | |
100 return getParser().argumentTypeNames(); | |
101 } | |
102 | |
103 List argumentSignatures() { | |
104 return getParser().argumentSignatures(); | |
105 } | |
106 | |
107 Type argumentType(int index) throws ClassNotLoadedException { | |
108 ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType(); | |
109 String signature = (String)argumentSignatures().get(index); | |
110 return enclosing.findType(signature); | |
111 } | |
112 | |
113 public List argumentTypes() throws ClassNotLoadedException { | |
114 int size = argumentSignatures().size(); | |
115 ArrayList types = new ArrayList(size); | |
116 for (int i = 0; i < size; i++) { | |
117 Type type = argumentType(i); | |
118 types.add(type); | |
119 } | |
120 return types; | |
121 } | |
122 | |
123 public boolean isAbstract() { | |
124 return saMethod.isAbstract(); | |
125 } | |
126 | |
127 public boolean isBridge() { | |
128 return saMethod.isBridge(); | |
129 } | |
130 | |
131 public boolean isSynchronized() { | |
132 return saMethod.isSynchronized(); | |
133 } | |
134 | |
135 public boolean isNative() { | |
136 return saMethod.isNative(); | |
137 } | |
138 | |
139 public boolean isVarArgs() { | |
140 return saMethod.isVarArgs(); | |
141 } | |
142 | |
143 public boolean isConstructor() { | |
144 return saMethod.isConstructor(); | |
145 } | |
146 | |
147 public boolean isStaticInitializer() { | |
148 return saMethod.isStaticInitializer(); | |
149 } | |
150 | |
151 public boolean isObsolete() { | |
152 return saMethod.isObsolete(); | |
153 } | |
154 | |
155 public final List allLineLocations() | |
156 throws AbsentInformationException { | |
157 return allLineLocations(vm.getDefaultStratum(), null); | |
158 } | |
159 | |
160 public List allLineLocations(String stratumID, | |
161 String sourceName) | |
162 throws AbsentInformationException { | |
163 return allLineLocations(declaringType.stratum(stratumID), | |
164 sourceName); | |
165 } | |
166 | |
167 public final List locationsOfLine(int lineNumber) | |
168 throws AbsentInformationException { | |
169 return locationsOfLine(vm.getDefaultStratum(), | |
170 null, lineNumber); | |
171 } | |
172 | |
173 public List locationsOfLine(String stratumID, | |
174 String sourceName, | |
175 int lineNumber) | |
176 throws AbsentInformationException { | |
177 return locationsOfLine(declaringType.stratum(stratumID), | |
178 sourceName, lineNumber); | |
179 } | |
180 | |
181 LineInfo codeIndexToLineInfo(SDE.Stratum stratum, | |
182 long codeIndex) { | |
183 if (stratum.isJava()) { | |
184 return new BaseLineInfo(-1, declaringType); | |
185 } else { | |
186 return new StratumLineInfo(stratum.id(), -1, | |
187 null, null); | |
188 } | |
189 } | |
190 | |
191 public boolean equals(Object obj) { | |
192 if ((obj != null) && (obj instanceof MethodImpl)) { | |
193 MethodImpl other = (MethodImpl)obj; | |
194 return (declaringType().equals(other.declaringType())) && | |
195 (ref().equals(other.ref())) && | |
196 super.equals(obj); | |
197 } else { | |
198 return false; | |
199 } | |
200 } | |
201 | |
202 // From interface Comparable | |
2471
37be97a58393
7010849: 5/5 Extraneous javac source/target options when building sa-jdi
andrew
parents:
1552
diff
changeset
|
203 public int compareTo(Method method) { |
0 | 204 ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType(); |
205 int rc = declaringType.compareTo(method.declaringType()); | |
206 if (rc == 0) { | |
207 rc = declaringType.indexOf(this) - | |
208 declaringType.indexOf(method); | |
209 } | |
210 return rc; | |
211 } | |
212 | |
213 // from interface Mirror | |
214 public String toString() { | |
215 StringBuffer sb = new StringBuffer(); | |
216 sb.append(declaringType().name()); | |
217 sb.append("."); | |
218 sb.append(name()); | |
219 sb.append("("); | |
220 boolean first = true; | |
221 for (Iterator it = argumentTypeNames().iterator(); it.hasNext();) { | |
222 if (!first) { | |
223 sb.append(", "); | |
224 } | |
225 sb.append((String)it.next()); | |
226 first = false; | |
227 } | |
228 sb.append(")"); | |
229 return sb.toString(); | |
230 } | |
231 | |
232 public String name() { | |
233 Symbol myName = saMethod.getName(); | |
234 return myName.asString(); | |
235 } | |
236 | |
237 public int modifiers() { | |
238 return saMethod.getAccessFlagsObj().getStandardFlags(); | |
239 } | |
240 | |
241 public boolean isPackagePrivate() { | |
242 return saMethod.isPackagePrivate(); | |
243 } | |
244 | |
245 public boolean isPrivate() { | |
246 return saMethod.isPrivate(); | |
247 } | |
248 | |
249 public boolean isProtected() { | |
250 return saMethod.isProtected(); | |
251 } | |
252 | |
253 public boolean isPublic() { | |
254 return saMethod.isPublic(); | |
255 } | |
256 | |
257 public boolean isStatic() { | |
258 return saMethod.isStatic(); | |
259 } | |
260 | |
261 public boolean isSynthetic() { | |
262 return saMethod.isSynthetic(); | |
263 } | |
264 | |
265 public boolean isFinal() { | |
266 return saMethod.isFinal(); | |
267 } | |
268 | |
269 public int hashCode() { | |
270 return saMethod.hashCode(); | |
271 } | |
272 } |