diff graal/com.oracle.jvmci.options/src/com/oracle/jvmci/options/OptionValue.java @ 21562:47bebae7454f

Merge.
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 May 2015 21:58:33 +0200
parents graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java@cecb4e39521c graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java@d563baeca9df
children
line wrap: on
line diff
--- a/graal/com.oracle.jvmci.options/src/com/oracle/jvmci/options/OptionValue.java	Thu May 28 17:13:22 2015 +0200
+++ b/graal/com.oracle.jvmci.options/src/com/oracle/jvmci/options/OptionValue.java	Thu May 28 21:58:33 2015 +0200
@@ -30,7 +30,6 @@
  * An option value.
  */
 public class OptionValue<T> {
-
     /**
      * Temporarily changes the value for an option. The {@linkplain OptionValue#getValue() value} of
      * {@code option} is set to {@code value} until {@link OverrideScope#close()} is called on the
@@ -138,7 +137,7 @@
         overrideScopeTL.set(overrideScope);
     }
 
-    private T initialValue;
+    private T defaultValue;
 
     /**
      * The raw option value.
@@ -164,29 +163,30 @@
 
     @SuppressWarnings("unchecked")
     public OptionValue(T value) {
-        this.initialValue = value;
-        this.value = (T) UNINITIALIZED;
+        this.defaultValue = value;
+        this.value = (T) DEFAULT;
         addToHistogram(this);
     }
 
+    private static final Object DEFAULT = "DEFAULT";
     private static final Object UNINITIALIZED = "UNINITIALIZED";
 
     /**
      * Creates an uninitialized option value for a subclass that initializes itself
-     * {@link #initialValue() lazily}.
+     * {@link #defaultValue() lazily}.
      */
     @SuppressWarnings("unchecked")
     protected OptionValue() {
-        this.initialValue = (T) UNINITIALIZED;
-        this.value = (T) UNINITIALIZED;
+        this.defaultValue = (T) UNINITIALIZED;
+        this.value = (T) DEFAULT;
         addToHistogram(this);
     }
 
     /**
-     * Lazy initialization of value.
+     * Lazy initialization of default value.
      */
-    protected T initialValue() {
-        throw new InternalError("Uninitialized option value must override initialValue()");
+    protected T defaultValue() {
+        throw new InternalError("Option without a default value value must override defaultValue()");
     }
 
     /**
@@ -223,27 +223,19 @@
      * {@link #setValue(Object)} or registering {@link OverrideScope}s. Therefore, it is also not
      * affected by options set on the command line.
      */
-    public T getInitialValue() {
-        if (initialValue == UNINITIALIZED) {
-            initialValue = initialValue();
+    public T getDefaultValue() {
+        if (defaultValue == UNINITIALIZED) {
+            defaultValue = defaultValue();
         }
-        return initialValue;
+        return defaultValue;
     }
 
     /**
      * Returns true if the option has the same value that was set in the source code.
      */
-    public boolean hasInitialValue() {
-        if (!(this instanceof StableOptionValue)) {
-            OverrideScope overrideScope = getOverrideScope();
-            if (overrideScope != null) {
-                T override = overrideScope.getOverride(this);
-                if (override != null) {
-                    return false;
-                }
-            }
-        }
-        return value == UNINITIALIZED || Objects.equals(value, getInitialValue());
+    public boolean hasDefaultValue() {
+        getValue(); // ensure initialized
+        return value == DEFAULT || Objects.equals(value, getDefaultValue());
     }
 
     /**
@@ -262,10 +254,10 @@
                 }
             }
         }
-        if (value != UNINITIALIZED) {
+        if (value != DEFAULT) {
             return value;
         } else {
-            return getInitialValue();
+            return getDefaultValue();
         }
     }
 
@@ -285,10 +277,10 @@
                 overrideScope.getOverrides(this, (Collection<Object>) values);
             }
         }
-        if (value != UNINITIALIZED) {
+        if (value != DEFAULT) {
             values.add(value);
         } else {
-            values.add(getInitialValue());
+            values.add(getDefaultValue());
         }
         return values;
     }