< prev index next >
src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java
Print this page
*** 20,30 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.vm.ci.hotspot;
- import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
--- 20,29 ----
*** 189,206 ****
* Checks if this field has the {@link Stable} annotation.
*
* @return true if field has {@link Stable} annotation, false otherwise
*/
public boolean isStable() {
! if ((config().jvmAccFieldStable & modifiers) != 0) {
! return true;
! }
! assert getAnnotation(Stable.class) == null;
! if (Option.ImplicitStableValues.getBoolean() && isImplicitStableField()) {
! return true;
! }
! return false;
}
@Override
public Annotation[] getAnnotations() {
Field javaField = toJava();
--- 188,198 ----
* Checks if this field has the {@link Stable} annotation.
*
* @return true if field has {@link Stable} annotation, false otherwise
*/
public boolean isStable() {
! return (config().jvmAccFieldStable & modifiers) != 0;
}
@Override
public Annotation[] getAnnotations() {
Field javaField = toJava();
*** 243,312 ****
} catch (NoSuchFieldException | NoClassDefFoundError e) {
return null;
}
}
- private boolean isArray() {
- JavaType fieldType = getType();
- return fieldType instanceof ResolvedJavaType && ((ResolvedJavaType) fieldType).isArray();
- }
-
- private boolean isImplicitStableField() {
- if (isSyntheticEnumSwitchMap()) {
- return true;
- }
- if (isWellKnownImplicitStableField()) {
- return true;
- }
- return false;
- }
-
- public boolean isDefaultStable() {
- assert this.isStable();
- if (isSyntheticEnumSwitchMap()) {
- return true;
- }
- return false;
- }
-
- private boolean isSyntheticEnumSwitchMap() {
- if (isSynthetic() && isStatic() && isArray()) {
- if (isFinal() && name.equals("$VALUES") || name.equals("ENUM$VALUES")) {
- // generated int[] field for EnumClass::values()
- return true;
- } else if (name.startsWith("$SwitchMap$") || name.startsWith("$SWITCH_TABLE$")) {
- // javac and ecj generate a static field in an inner class for a switch on an enum
- // named $SwitchMap$p$k$g$EnumClass and $SWITCH_TABLE$p$k$g$EnumClass, respectively
- return true;
- }
- }
- return false;
- }
-
- private boolean isWellKnownImplicitStableField() {
- return WellKnownImplicitStableField.test(this);
- }
-
- static class WellKnownImplicitStableField {
- /**
- * @return {@code true} if the field is a well-known stable field.
- */
- public static boolean test(HotSpotResolvedJavaField field) {
- return field.equals(STRING_VALUE_FIELD);
- }
-
- private static final ResolvedJavaField STRING_VALUE_FIELD;
-
- static {
- try {
- MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess();
- STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value"));
- } catch (SecurityException | NoSuchFieldException e) {
- throw new JVMCIError(e);
- }
- }
- }
-
public LocationIdentity getLocationIdentity() {
return locationIdentity;
}
}
--- 235,243 ----
< prev index next >