annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java @ 24225:a2dbb6fcc923

Added tag jvmci-0.33 for changeset 3aed4cb813f4
author Doug Simon <doug.simon@oracle.com>
date Fri, 18 Aug 2017 22:47:33 +0200
parents 813c28963a9e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23988
diff changeset
2 * Copyright (c) 2011, 2017, 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 */
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22664
diff changeset
23 package jdk.vm.ci.hotspot;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
23749
d6bd0b9cd0b6 remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents: 23393
diff changeset
25 import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers;
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22664
diff changeset
26 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
22569
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22432
diff changeset
27
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22432
diff changeset
28 import java.lang.annotation.Annotation;
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22432
diff changeset
29 import java.lang.reflect.Field;
8949
da5140eedfa1 made format of toString() consistent across HotSpot subclasses of JavaField and JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 8415
diff changeset
30
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22664
diff changeset
31 import jdk.vm.ci.meta.JavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22664
diff changeset
32 import jdk.vm.ci.meta.ResolvedJavaType;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 * Represents a field in a HotSpot type.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 */
23393
1d4ce2d19e52 clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
37 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
39 private final HotSpotResolvedObjectTypeImpl holder;
14047
fde464340755 don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14012
diff changeset
40 private JavaType type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 private final int offset;
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23988
diff changeset
42 private final short index;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43
13823
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
44 /**
14012
1f34717ccafa remove CompilerToVM.getInstanceFields
twisti
parents: 13823
diff changeset
45 * This value contains all flags as stored in the VM including internal ones.
1f34717ccafa remove CompilerToVM.getInstanceFields
twisti
parents: 13823
diff changeset
46 */
1f34717ccafa remove CompilerToVM.getInstanceFields
twisti
parents: 13823
diff changeset
47 private final int modifiers;
13823
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
48
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23988
diff changeset
49 HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, JavaType type, long offset, int modifiers, int index) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 this.holder = holder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 this.type = type;
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23988
diff changeset
52 this.index = (short) index;
23996
11f0412408cd 8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents: 23989
diff changeset
53 this.offset = (int) offset;
11f0412408cd 8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents: 23989
diff changeset
54 this.modifiers = modifiers;
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23988
diff changeset
55 assert this.index == index;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 assert offset != -1;
13263
81055aacb98d removed CompilerToVM.getJavaField
twisti
parents: 12628
diff changeset
57 assert offset == (int) offset : "offset larger than int";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 @Override
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
61 public boolean equals(Object obj) {
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
62 if (this == obj) {
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
63 return true;
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
64 }
14525
5e55de0379d9 fixed bug in HotSpotResolvedJavaField.equals
Doug Simon <doug.simon@oracle.com>
parents: 14158
diff changeset
65 if (obj instanceof HotSpotResolvedJavaField) {
18264
e28aa8468d5e converted HotSpotResolvedJavaField to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18262
diff changeset
66 HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj;
19042
0d7302ddcc90 Bugfix: static and instance field with same offset are not equal
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19005
diff changeset
67 if (that.offset != this.offset || that.isStatic() != this.isStatic()) {
19005
a64863622854 Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
68 return false;
a64863622854 Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
69 } else if (this.holder.equals(that.holder)) {
a64863622854 Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
70 return true;
a64863622854 Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
71 }
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
72 }
14525
5e55de0379d9 fixed bug in HotSpotResolvedJavaField.equals
Doug Simon <doug.simon@oracle.com>
parents: 14158
diff changeset
73 return false;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
74 }
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
75
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
76 @Override
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
77 public int hashCode() {
24121
813c28963a9e 8178048: [JVMCI] improve HotSpotResolvedJavaFieldImpl.hashCode()
Christian Haeubl <christian.haeubl@oracle.com>
parents: 23997
diff changeset
78 return holder.hashCode() ^ offset;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
79 }
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
80
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14138
diff changeset
81 @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: 6525
diff changeset
82 public int getModifiers() {
23749
d6bd0b9cd0b6 remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents: 23393
diff changeset
83 return modifiers & jvmFieldModifiers();
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 @Override
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
87 public boolean isInternal() {
22581
3884a98ebcde consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents: 22569
diff changeset
88 return (modifiers & config().jvmAccFieldInternal) != 0;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
89 }
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
90
10065
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
91 /**
12628
c36bdee8ca29 added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents: 12559
diff changeset
92 * Determines if a given object contains this field.
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
93 *
13823
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
94 * @return true iff this is a non-static field and its declaring class is assignable from
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
95 * {@code object}'s class
12628
c36bdee8ca29 added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents: 12559
diff changeset
96 */
c36bdee8ca29 added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents: 12559
diff changeset
97 public boolean isInObject(Object object) {
15311
820c6d353358 added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents: 15259
diff changeset
98 if (isStatic()) {
13823
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
99 return false;
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
100 }
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
101 return getDeclaringClass().isAssignableFrom(HotSpotResolvedObjectTypeImpl.fromObjectClass(object.getClass()));
12628
c36bdee8ca29 added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents: 12559
diff changeset
102 }
c36bdee8ca29 added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents: 12559
diff changeset
103
5629
26a060cc58ca Initial implementation of closed world analysis by iteratively expanding the universe starting at method entry points.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5554
diff changeset
104 @Override
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
105 public HotSpotResolvedObjectTypeImpl getDeclaringClass() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 return holder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 @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: 6525
diff changeset
110 public String getName() {
23996
11f0412408cd 8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents: 23989
diff changeset
111 return holder.createFieldInfo(index).getName();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 @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: 6525
diff changeset
115 public JavaType getType() {
20878
673e0b242d4d fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents: 20821
diff changeset
116 // Pull field into local variable to prevent a race causing
673e0b242d4d fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents: 20821
diff changeset
117 // a ClassCastException below
673e0b242d4d fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents: 20821
diff changeset
118 JavaType currentType = type;
673e0b242d4d fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents: 20821
diff changeset
119 if (currentType instanceof HotSpotUnresolvedJavaType) {
14047
fde464340755 don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14012
diff changeset
120 // Don't allow unresolved types to hang around forever
20878
673e0b242d4d fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents: 20821
diff changeset
121 HotSpotUnresolvedJavaType unresolvedType = (HotSpotUnresolvedJavaType) currentType;
673e0b242d4d fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents: 20821
diff changeset
122 ResolvedJavaType resolved = unresolvedType.reresolve(holder);
14047
fde464340755 don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14012
diff changeset
123 if (resolved != null) {
fde464340755 don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14012
diff changeset
124 type = resolved;
fde464340755 don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14012
diff changeset
125 }
fde464340755 don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14012
diff changeset
126 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 return type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 public int offset() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 return offset;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 public String toString() {
16481
e7fc65330742 moved format(String format, JavaField field) from MetaUtil to be a default method in JavaField
Doug Simon <doug.simon@oracle.com>
parents: 16383
diff changeset
136 return format("HotSpotField<%H.%n %t:") + offset + ">";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 @Override
9984
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
140 public boolean isSynthetic() {
23997
9a740aa0d87b use raw method name symbol for isConstructor and isClassInitializer
Doug Simon <doug.simon@oracle.com>
parents: 23996
diff changeset
141 return (config().jvmAccSynthetic & modifiers) != 0;
9984
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
142 }
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
143
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
144 /**
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
145 * Checks if this field has the {@link Stable} annotation.
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
146 *
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
147 * @return true if field has {@link Stable} annotation, false otherwise
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
148 */
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
149 public boolean isStable() {
23391
dd9f3badc978 Remove implicit stable field handling (JDK-8156552).
Roland Schatz <roland.schatz@oracle.com>
parents: 23388
diff changeset
150 return (config().jvmAccFieldStable & modifiers) != 0;
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
151 }
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
152
9984
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
153 @Override
22432
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
154 public Annotation[] getAnnotations() {
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
155 Field javaField = toJava();
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
156 if (javaField != null) {
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
157 return javaField.getAnnotations();
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
158 }
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
159 return new Annotation[0];
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
160 }
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
161
e4f0d819fe22 Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22054
diff changeset
162 @Override
23376
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
163 public Annotation[] getDeclaredAnnotations() {
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
164 Field javaField = toJava();
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
165 if (javaField != null) {
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
166 return javaField.getDeclaredAnnotations();
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
167 }
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
168 return new Annotation[0];
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
169 }
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
170
ae27c683c128 Make ResolvedJava* types extend AnnotatedElement.
Roland Schatz <roland.schatz@oracle.com>
parents: 23306
diff changeset
171 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 Field javaField = toJava();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 if (javaField != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 return javaField.getAnnotation(annotationClass);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 private Field toJava() {
13823
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
181 if (isInternal()) {
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
182 return null;
6dd8b95a7fbb fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents: 13818
diff changeset
183 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 try {
23996
11f0412408cd 8173912: [JVMCI] fix memory overhead of JVMCI
Doug Simon <doug.simon@oracle.com>
parents: 23989
diff changeset
185 return holder.mirror().getDeclaredField(getName());
19917
6575b4e3f629 Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19855
diff changeset
186 } catch (NoSuchFieldException | NoClassDefFoundError e) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }