Mercurial > hg > truffle
comparison graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedPrimitiveType.java @ 21526:1da7aef31a08
created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 19 May 2015 23:16:07 +0200 |
parents | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java@082417ac43e4 |
children |
comparison
equal
deleted
inserted
replaced
21489:b3f1d8b23037 | 21526:1da7aef31a08 |
---|---|
1 /* | |
2 * Copyright (c) 2011, 2014, 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 package com.oracle.graal.hotspot.jvmci; | |
24 | |
25 import static java.util.Objects.*; | |
26 | |
27 import java.lang.annotation.*; | |
28 import java.lang.reflect.*; | |
29 import java.net.*; | |
30 | |
31 import com.oracle.graal.api.meta.*; | |
32 import com.oracle.graal.api.meta.Assumptions.AssumptionResult; | |
33 import com.oracle.graal.compiler.common.*; | |
34 | |
35 /** | |
36 * Implementation of {@link JavaType} for primitive HotSpot types. | |
37 */ | |
38 public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements HotSpotProxified { | |
39 | |
40 private final Kind kind; | |
41 | |
42 /** | |
43 * Creates the Graal mirror for a primitive {@link Kind}. | |
44 * | |
45 * <p> | |
46 * <b>NOTE</b>: Creating an instance of this class does not install the mirror for the | |
47 * {@link Class} type. Use {@link #fromClass(Class)} instead. | |
48 * </p> | |
49 * | |
50 * @param kind the Kind to create the mirror for | |
51 */ | |
52 public HotSpotResolvedPrimitiveType(Kind kind) { | |
53 super(String.valueOf(Character.toUpperCase(kind.getTypeChar()))); | |
54 this.kind = kind; | |
55 assert mirror().isPrimitive() : mirror() + " not a primitive type"; | |
56 } | |
57 | |
58 @Override | |
59 public int getModifiers() { | |
60 return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC; | |
61 } | |
62 | |
63 @Override | |
64 public HotSpotResolvedObjectTypeImpl getArrayClass() { | |
65 if (kind == Kind.Void) { | |
66 return null; | |
67 } | |
68 Class<?> javaArrayMirror = Array.newInstance(mirror(), 0).getClass(); | |
69 return HotSpotResolvedObjectTypeImpl.fromObjectClass(javaArrayMirror); | |
70 } | |
71 | |
72 public ResolvedJavaType getElementalType() { | |
73 return this; | |
74 } | |
75 | |
76 @Override | |
77 public ResolvedJavaType getComponentType() { | |
78 return null; | |
79 } | |
80 | |
81 @Override | |
82 public ResolvedJavaType asExactType() { | |
83 return this; | |
84 } | |
85 | |
86 @Override | |
87 public ResolvedJavaType getSuperclass() { | |
88 return null; | |
89 } | |
90 | |
91 @Override | |
92 public ResolvedJavaType[] getInterfaces() { | |
93 return new ResolvedJavaType[0]; | |
94 } | |
95 | |
96 @Override | |
97 public ResolvedJavaType getSingleImplementor() { | |
98 throw new GraalInternalError("Cannot call getImplementor() on a non-interface type: " + this); | |
99 } | |
100 | |
101 @Override | |
102 public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { | |
103 return null; | |
104 } | |
105 | |
106 @Override | |
107 public JavaConstant getObjectHub() { | |
108 throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getObjectHub"); | |
109 } | |
110 | |
111 @Override | |
112 public JavaConstant getJavaClass() { | |
113 throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getJavaClass"); | |
114 } | |
115 | |
116 @Override | |
117 public AssumptionResult<Boolean> hasFinalizableSubclass() { | |
118 return new AssumptionResult<>(false); | |
119 } | |
120 | |
121 @Override | |
122 public boolean hasFinalizer() { | |
123 return false; | |
124 } | |
125 | |
126 @Override | |
127 public boolean isArray() { | |
128 return false; | |
129 } | |
130 | |
131 @Override | |
132 public boolean isPrimitive() { | |
133 return true; | |
134 } | |
135 | |
136 @Override | |
137 public boolean isInitialized() { | |
138 return true; | |
139 } | |
140 | |
141 public boolean isLinked() { | |
142 return true; | |
143 } | |
144 | |
145 @Override | |
146 public boolean isInstance(JavaConstant obj) { | |
147 return false; | |
148 } | |
149 | |
150 @Override | |
151 public boolean isInstanceClass() { | |
152 return false; | |
153 } | |
154 | |
155 @Override | |
156 public boolean isInterface() { | |
157 return false; | |
158 } | |
159 | |
160 @Override | |
161 public boolean isAssignableFrom(ResolvedJavaType other) { | |
162 assert other != null; | |
163 return other.equals(this); | |
164 } | |
165 | |
166 @Override | |
167 public Kind getKind() { | |
168 return kind; | |
169 } | |
170 | |
171 @Override | |
172 public boolean isJavaLangObject() { | |
173 return false; | |
174 } | |
175 | |
176 @Override | |
177 public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { | |
178 return null; | |
179 } | |
180 | |
181 @Override | |
182 public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType, boolean includeAbstract) { | |
183 return null; | |
184 } | |
185 | |
186 @Override | |
187 public String toString() { | |
188 return "HotSpotResolvedPrimitiveType<" + kind + ">"; | |
189 } | |
190 | |
191 @Override | |
192 public AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype() { | |
193 return new AssumptionResult<>(this); | |
194 } | |
195 | |
196 @Override | |
197 public AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method) { | |
198 return null; | |
199 } | |
200 | |
201 @Override | |
202 public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { | |
203 return new ResolvedJavaField[0]; | |
204 } | |
205 | |
206 @Override | |
207 public ResolvedJavaField[] getStaticFields() { | |
208 return new ResolvedJavaField[0]; | |
209 } | |
210 | |
211 @Override | |
212 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { | |
213 return null; | |
214 } | |
215 | |
216 @Override | |
217 public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { | |
218 requireNonNull(accessingClass); | |
219 return this; | |
220 } | |
221 | |
222 @Override | |
223 public void initialize() { | |
224 } | |
225 | |
226 @Override | |
227 public ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind expectedType) { | |
228 return null; | |
229 } | |
230 | |
231 @Override | |
232 public String getSourceFileName() { | |
233 throw GraalInternalError.shouldNotReachHere(); | |
234 } | |
235 | |
236 @Override | |
237 public Class<?> mirror() { | |
238 return kind.toJavaClass(); | |
239 } | |
240 | |
241 @Override | |
242 public URL getClassFilePath() { | |
243 return null; | |
244 } | |
245 | |
246 @Override | |
247 public boolean isLocal() { | |
248 return false; | |
249 } | |
250 | |
251 @Override | |
252 public boolean isMember() { | |
253 return false; | |
254 } | |
255 | |
256 @Override | |
257 public ResolvedJavaType getEnclosingType() { | |
258 return null; | |
259 } | |
260 | |
261 @Override | |
262 public ResolvedJavaMethod[] getDeclaredConstructors() { | |
263 return new ResolvedJavaMethod[0]; | |
264 } | |
265 | |
266 @Override | |
267 public ResolvedJavaMethod[] getDeclaredMethods() { | |
268 return new ResolvedJavaMethod[0]; | |
269 } | |
270 | |
271 @Override | |
272 public ResolvedJavaMethod getClassInitializer() { | |
273 return null; | |
274 } | |
275 | |
276 @Override | |
277 public boolean isTrustedInterfaceType() { | |
278 return false; | |
279 } | |
280 } |