< prev index next >
src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -20,24 +20,31 @@
* 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.*;
-import static jdk.vm.ci.hotspot.HotSpotResolvedJavaFieldImpl.Options.*;
+import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
+import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
-import java.lang.annotation.*;
-import java.lang.reflect.*;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
-import jdk.vm.ci.common.*;
-import jdk.vm.ci.meta.*;
-import jdk.vm.ci.options.*;
+import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.meta.JavaType;
+import jdk.vm.ci.meta.LocationIdentity;
+import jdk.vm.ci.meta.MetaAccessProvider;
+import jdk.vm.ci.meta.ModifiersProvider;
+import jdk.vm.ci.meta.ResolvedJavaField;
+import jdk.vm.ci.meta.ResolvedJavaType;
+import jdk.vm.ci.options.Option;
+import jdk.vm.ci.options.OptionType;
+import jdk.vm.ci.options.OptionValue;
/**
* Represents a field in a HotSpot type.
*/
-public class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified {
+class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified {
static class Options {
//@formatter:off
@Option(help = "Mark well-known stable fields as such.", type = OptionType.Debug)
public static final OptionValue<Boolean> ImplicitStableValues = new OptionValue<>(true);
@@ -89,11 +96,11 @@
public String toString() {
return inner.getName();
}
}
- public HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) {
+ HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) {
this.holder = holder;
this.name = name;
this.type = type;
assert offset != -1;
assert offset == (int) offset : "offset larger than int";
@@ -128,11 +135,11 @@
return modifiers & ModifiersProvider.jvmFieldModifiers();
}
@Override
public boolean isInternal() {
- return (modifiers & runtime().getConfig().jvmAccFieldInternal) != 0;
+ return (modifiers & config().jvmAccFieldInternal) != 0;
}
/**
* Determines if a given object contains this field.
*
@@ -181,24 +188,24 @@
return format("HotSpotField<%H.%n %t:") + offset + ">";
}
@Override
public boolean isSynthetic() {
- return (runtime().getConfig().syntheticFlag & modifiers) != 0;
+ return (config().syntheticFlag & modifiers) != 0;
}
/**
* Checks if this field has the {@link Stable} annotation.
*
* @return true if field has {@link Stable} annotation, false otherwise
*/
public boolean isStable() {
- if ((runtime().getConfig().jvmAccFieldStable & modifiers) != 0) {
+ if ((config().jvmAccFieldStable & modifiers) != 0) {
return true;
}
assert getAnnotation(Stable.class) == null;
- if (ImplicitStableValues.getValue() && isImplicitStableField()) {
+ if (Options.ImplicitStableValues.getValue() && isImplicitStableField()) {
return true;
}
return false;
}
@@ -241,23 +248,29 @@
JavaType fieldType = getType();
return fieldType instanceof ResolvedJavaType && ((ResolvedJavaType) fieldType).isArray();
}
private boolean isImplicitStableField() {
- if (isSynthetic()) {
- if (isSyntheticImplicitStableField()) {
+ if (isSyntheticEnumSwitchMap()) {
return true;
}
- } else if (isWellKnownImplicitStableField()) {
+ if (isWellKnownImplicitStableField()) {
return true;
}
return false;
}
- private boolean isSyntheticImplicitStableField() {
- assert this.isSynthetic();
- if (isStatic() && isArray()) {
+ 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
@@ -279,10 +292,11 @@
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) {
< prev index next >