# HG changeset patch # User Gilles Duboscq # Date 1444222508 -7200 # Node ID 47f047ae2b4b2667335f4e3ef7ab06d66673a670 # Parent 41b97852175d08b9332d06bf525ddec49edfb2fb Make default values stable in enum switch maps Added isDefaultStable to HotSpotResolvedJavaField Fixed reference to Stable annotation diff -r 41b97852175d -r 47f047ae2b4b jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantReflectionProvider.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantReflectionProvider.java Wed Oct 07 13:32:56 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantReflectionProvider.java Wed Oct 07 14:55:08 2015 +0200 @@ -338,7 +338,7 @@ if (!hotspotField.isStable()) { return readNonStableFieldValue(field, receiver); } else { - return readStableFieldValue(field, receiver, false); + return readStableFieldValue(field, receiver, hotspotField.isDefaultStable()); } } diff -r 41b97852175d -r 47f047ae2b4b jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaField.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaField.java Wed Oct 07 13:32:56 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaField.java Wed Oct 07 14:55:08 2015 +0200 @@ -45,4 +45,12 @@ * @return true if field has {@link Stable} annotation, false otherwise */ boolean isStable(); + + /** + * If this field is stable, checks if default values (0, null, etc.) should be considered stable + * as well. + * + * @return true if default values should be considered stable, false otherwise + */ + boolean isDefaultStable(); } diff -r 41b97852175d -r 47f047ae2b4b jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java Wed Oct 07 13:32:56 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java Wed Oct 07 14:55:08 2015 +0200 @@ -250,19 +250,25 @@ } private boolean isImplicitStableField() { - if (isSynthetic()) { - if (isSyntheticImplicitStableField()) { - return true; - } - } else if (isWellKnownImplicitStableField()) { + if (isSyntheticEnumSwitchMap()) { + return true; + } + 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; @@ -288,6 +294,7 @@ } private static final ResolvedJavaField STRING_VALUE_FIELD; + static { try { MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess(); diff -r 41b97852175d -r 47f047ae2b4b jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/Stable.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/Stable.java Wed Oct 07 13:32:56 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/Stable.java Wed Oct 07 14:55:08 2015 +0200 @@ -29,8 +29,8 @@ import java.lang.annotation.Target; /** - * This annotation functions as an alias for the sun.invoke.Stable annotation within JVMCI code. It - * is specially recognized during class file parsing in the same way as that annotation. + * This annotation functions as an alias for the java.lang.invoke.Stable annotation within JVMCI + * code. It is specially recognized during class file parsing in the same way as that annotation. */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME)