Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotUnresolvedJavaType.java @ 21696:ca140f8c35be
Empty pointer stamps are also non-null.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 14:08:29 +0200 |
parents | 48c1ebd24120 |
children |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
23 package com.oracle.jvmci.hotspot; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
25 import com.oracle.jvmci.meta.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 /** |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5554
diff
changeset
|
28 * Implementation of {@link JavaType} for unresolved HotSpot classes. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 */ |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
30 public class HotSpotUnresolvedJavaType extends HotSpotJavaType { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
32 private final HotSpotJVMCIRuntimeProvider runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
34 public HotSpotUnresolvedJavaType(String name, HotSpotJVMCIRuntimeProvider runtime) { |
7026
f31d374e8195
fixed bug in creation of the name for a HotSpotTypeUnresolved
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
35 super(name); |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
15730
diff
changeset
|
36 assert name.charAt(0) == '[' || name.charAt(name.length() - 1) == ';' : name; |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
37 this.runtime = runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
13305
diff
changeset
|
40 /** |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
13305
diff
changeset
|
41 * Creates an unresolved type for a valid {@link JavaType#getName() type name}. |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
13305
diff
changeset
|
42 */ |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
43 public static HotSpotUnresolvedJavaType create(HotSpotJVMCIRuntimeProvider runtime, String name) { |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
44 return new HotSpotUnresolvedJavaType(name, runtime); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6325
diff
changeset
|
48 public JavaType getComponentType() { |
15730
920b7bb058a6
Simplify HotSpotUnresolvedJavaType, harmonize toString for HotSpotUnresolvedJavaType and HotSpotResolvedObjectType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14093
diff
changeset
|
49 assert getName().charAt(0) == '[' : "no array class" + getName(); |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
50 return new HotSpotUnresolvedJavaType(getName().substring(1), runtime); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6325
diff
changeset
|
54 public JavaType getArrayClass() { |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
55 return new HotSpotUnresolvedJavaType('[' + getName(), runtime); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6325
diff
changeset
|
59 public Kind getKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
60 return Kind.Object; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 public int hashCode() { |
15730
920b7bb058a6
Simplify HotSpotUnresolvedJavaType, harmonize toString for HotSpotUnresolvedJavaType and HotSpotResolvedObjectType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14093
diff
changeset
|
65 return getName().hashCode(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 @Override |
14093 | 69 public boolean equals(Object obj) { |
70 if (this == obj) { | |
71 return true; | |
72 } | |
73 if (obj == null || !(obj instanceof HotSpotUnresolvedJavaType)) { | |
74 return false; | |
75 } | |
76 HotSpotUnresolvedJavaType that = (HotSpotUnresolvedJavaType) obj; | |
15730
920b7bb058a6
Simplify HotSpotUnresolvedJavaType, harmonize toString for HotSpotUnresolvedJavaType and HotSpotResolvedObjectType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14093
diff
changeset
|
77 return this.getName().equals(that.getName()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 public String toString() { |
15730
920b7bb058a6
Simplify HotSpotUnresolvedJavaType, harmonize toString for HotSpotUnresolvedJavaType and HotSpotResolvedObjectType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14093
diff
changeset
|
82 return "HotSpotType<" + getName() + ", unresolved>"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
86 public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { |
18542
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
87 return (ResolvedJavaType) runtime.lookupType(getName(), (HotSpotResolvedObjectType) accessingClass, true); |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4199
diff
changeset
|
88 } |
19917
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
89 |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
90 /** |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
91 * Try to find a loaded version of this class. |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
92 * |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
93 * @param accessingClass |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
94 * @return the resolved class or null. |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
95 */ |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
96 ResolvedJavaType reresolve(HotSpotResolvedObjectType accessingClass) { |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
97 JavaType type = runtime.lookupType(getName(), accessingClass, false); |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
98 if (type instanceof ResolvedJavaType) { |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
99 return (ResolvedJavaType) type; |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
100 } |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
101 return null; |
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18542
diff
changeset
|
102 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |