Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaMethod.java @ 4006:436b4a3231bf
7098194: integrate macosx-port changes
Summary: Integrate bsd-port/hotspot and macosx-port/hotspot changes as of 2011.09.29.
Reviewed-by: kvn, dholmes, never, phh
Contributed-by: Christos Zoulas <christos@zoulas.com>, Greg Lewis <glewis@eyesbeyond.com>, Kurt Miller <kurt@intricatesoftware.com>, Alexander Strange <astrange@apple.com>, Mike Swingler <swingler@apple.com>, Roger Hoover <rhoover@apple.com>, Victor Hernandez <vhernandez@apple.com>, Pratik Solanki <psolanki@apple.com>
author | dcubed |
---|---|
date | Thu, 13 Oct 2011 09:35:42 -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) 2004, 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.utilities.soql; | |
26 | |
27 import java.util.*; | |
28 import sun.jvm.hotspot.oops.*; | |
29 import sun.jvm.hotspot.runtime.*; | |
30 | |
31 /** | |
32 * Wraps a methodOop from the debuggee VM. | |
33 */ | |
34 public class JSJavaMethod extends JSJavaObject { | |
35 private static final int FIELD_NAME = 0; | |
36 private static final int FIELD_SIGNATURE = 1; | |
37 private static final int FIELD_HOLDER = 2; | |
38 private static final int FIELD_IS_PRIVATE = 3; | |
39 private static final int FIELD_IS_PUBLIC = 4; | |
40 private static final int FIELD_IS_PROTECTED = 5; | |
41 private static final int FIELD_IS_PACKAGE_PRIVATE = 6; | |
42 private static final int FIELD_IS_STATIC = 7; | |
43 private static final int FIELD_IS_FINAL = 8; | |
44 private static final int FIELD_IS_SYNCHRONIZED = 9; | |
45 private static final int FIELD_IS_NATIVE = 10; | |
46 private static final int FIELD_IS_ABSTRACT = 11; | |
47 private static final int FIELD_IS_STRICT = 12; | |
48 private static final int FIELD_IS_SYNTHETIC = 13; | |
49 private static final int FIELD_IS_OBSOLETE = 14; | |
50 private static final int FIELD_UNDEFINED = -1; | |
51 | |
52 public JSJavaMethod(Method m, JSJavaFactory fac) { | |
53 super(m, fac); | |
54 } | |
55 | |
56 public final Method getMethod() { | |
57 return (Method) getOop(); | |
58 } | |
59 | |
60 public Object get(String name) { | |
61 int fieldID = getFieldID(name); | |
62 Method method = getMethod(); | |
63 switch (fieldID) { | |
64 case FIELD_NAME: | |
65 return method.getName().asString(); | |
66 case FIELD_SIGNATURE: | |
67 return method.getSignature().asString(); | |
68 case FIELD_HOLDER: | |
69 return getMethodHolder(); | |
70 case FIELD_IS_PRIVATE: | |
71 return Boolean.valueOf(method.isPrivate()); | |
72 case FIELD_IS_PUBLIC: | |
73 return Boolean.valueOf(method.isPublic()); | |
74 case FIELD_IS_PROTECTED: | |
75 return Boolean.valueOf(method.isProtected()); | |
76 case FIELD_IS_PACKAGE_PRIVATE: | |
77 return Boolean.valueOf(method.isPackagePrivate()); | |
78 case FIELD_IS_STATIC: | |
79 return Boolean.valueOf(method.isStatic()); | |
80 case FIELD_IS_FINAL: | |
81 return Boolean.valueOf(method.isFinal()); | |
82 case FIELD_IS_SYNCHRONIZED: | |
83 return Boolean.valueOf(method.isSynchronized()); | |
84 case FIELD_IS_NATIVE: | |
85 return Boolean.valueOf(method.isNative()); | |
86 case FIELD_IS_ABSTRACT: | |
87 return Boolean.valueOf(method.isAbstract()); | |
88 case FIELD_IS_STRICT: | |
89 return Boolean.valueOf(method.isStrict()); | |
90 case FIELD_IS_SYNTHETIC: | |
91 return Boolean.valueOf(method.isSynthetic()); | |
92 case FIELD_IS_OBSOLETE: | |
93 return Boolean.valueOf(method.isObsolete()); | |
94 case FIELD_UNDEFINED: | |
95 default: | |
96 return super.get(name); | |
97 } | |
98 } | |
99 | |
100 public Object[] getIds() { | |
101 Object[] fieldNames = fields.keySet().toArray(); | |
102 Object[] superFields = super.getIds(); | |
103 Object[] res = new Object[fieldNames.length + superFields.length]; | |
104 System.arraycopy(fieldNames, 0, res, 0, fieldNames.length); | |
105 System.arraycopy(superFields, 0, res, fieldNames.length, superFields.length); | |
106 return res; | |
107 } | |
108 | |
109 public boolean has(String name) { | |
110 if (getFieldID(name) != FIELD_UNDEFINED) { | |
111 return true; | |
112 } else { | |
113 return super.has(name); | |
114 } | |
115 } | |
116 | |
117 public void put(String name, Object value) { | |
118 if (getFieldID(name) != FIELD_UNDEFINED) { | |
119 return; | |
120 } else { | |
121 super.put(name, value); | |
122 } | |
123 } | |
124 | |
125 public String toString() { | |
126 StringBuffer buf = new StringBuffer(); | |
127 buf.append("Method "); | |
128 buf.append(getMethod().externalNameAndSignature()); | |
129 return buf.toString(); | |
130 } | |
131 | |
132 //-- Internals only below this point | |
133 private JSJavaObject getMethodHolder() { | |
134 Klass k = getMethod().getMethodHolder(); | |
135 return factory.newJSJavaKlass(k).getJSJavaClass(); | |
136 } | |
137 | |
138 private static Map fields = new HashMap(); | |
139 private static void addField(String name, int fieldId) { | |
140 fields.put(name, new Integer(fieldId)); | |
141 } | |
142 | |
143 private static int getFieldID(String name) { | |
144 Integer res = (Integer) fields.get(name); | |
145 return (res != null)? res.intValue() : FIELD_UNDEFINED; | |
146 } | |
147 | |
148 static { | |
149 addField("name", FIELD_NAME); | |
150 addField("signature", FIELD_SIGNATURE); | |
151 addField("holder", FIELD_HOLDER); | |
152 addField("isPrivate", FIELD_IS_PRIVATE); | |
153 addField("isPublic", FIELD_IS_PUBLIC); | |
154 addField("isProtected", FIELD_IS_PROTECTED); | |
155 addField("isPackagePrivate", FIELD_IS_PACKAGE_PRIVATE); | |
156 addField("isStatic", FIELD_IS_STATIC); | |
157 addField("isFinal", FIELD_IS_FINAL); | |
158 addField("isSynchronized", FIELD_IS_SYNCHRONIZED); | |
159 addField("isNative", FIELD_IS_NATIVE); | |
160 addField("isAbstract", FIELD_IS_ABSTRACT); | |
161 addField("isStrict", FIELD_IS_STRICT); | |
162 addField("isSynthetic", FIELD_IS_SYNTHETIC); | |
163 addField("isObsolete", FIELD_IS_OBSOLETE); | |
164 } | |
165 } |