--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options/src/org/graalvm/compiler/options/ModifiableOptionValues.java 2017-08-03 22:42:53.129535510 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options/src/org/graalvm/compiler/options/ModifiableOptionValues.java 2017-08-03 22:42:53.030531072 -0700 @@ -48,7 +48,16 @@ } /** + * Value that can be used in {@link #update(UnmodifiableEconomicMap)} and + * {@link #update(OptionKey, Object)} to remove an explicitly set value for a key such that + * {@link OptionKey#hasBeenSet(OptionValues)} will return {@code false} for the key. + */ + public static final Object UNSET_KEY = new Object(); + + /** * Updates this object with the given key/value pair. + * + * @see #UNSET_KEY */ public void update(OptionKey key, Object value) { UnmodifiableEconomicMap, Object> expect; @@ -56,14 +65,20 @@ do { expect = v.get(); newMap = EconomicMap.create(Equivalence.IDENTITY, expect); - key.update(newMap, value); - // Need to do the null encoding here as `key.update()` doesn't do it - newMap.put(key, encodeNull(value)); + if (value == UNSET_KEY) { + newMap.removeKey(key); + } else { + key.update(newMap, value); + // Need to do the null encoding here as `key.update()` doesn't do it + newMap.put(key, encodeNull(value)); + } } while (!v.compareAndSet(expect, newMap)); } /** * Updates this object with the key/value pairs in {@code values}. + * + * @see #UNSET_KEY */ public void update(UnmodifiableEconomicMap, Object> values) { if (values.isEmpty()) { @@ -78,9 +93,13 @@ while (cursor.advance()) { OptionKey key = cursor.getKey(); Object value = cursor.getValue(); - key.update(newMap, value); - // Need to do the null encoding here as `key.update()` doesn't do it - newMap.put(key, encodeNull(value)); + if (value == UNSET_KEY) { + newMap.removeKey(key); + } else { + key.update(newMap, value); + // Need to do the null encoding here as `key.update()` doesn't do it + newMap.put(key, encodeNull(value)); + } } } while (!v.compareAndSet(expect, newMap)); }