# HG changeset patch # User Doug Simon # Date 1378999965 -7200 # Node ID 54dff87002e0f5cc1bc36c8a2a13b771412bf391 # Parent a27678c479487dc6833b86c4640b153e946c382b check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called diff -r a27678c47948 -r 54dff87002e0 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Sep 12 16:23:28 2013 +0200 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Sep 12 17:32:45 2013 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.graal.debug; -import static com.oracle.graal.debug.Debug.Initializer.*; +import static com.oracle.graal.debug.Debug.Initialization.*; import java.io.*; import java.util.*; @@ -32,27 +32,38 @@ /** * Scope based debugging facility. This facility is {@link #isEnabled()} if assertions are enabled - * for the {@link Debug} class or the {@value Initializer#INITIALIZER_PROPERTY_NAME} system property - * is {@code "true"} when {@link Debug} is initialized. + * for the {@link Debug} class or the {@value Initialization#INITIALIZER_PROPERTY_NAME} system + * property is {@code "true"} when {@link Debug} is initialized. */ public class Debug { /** - * Class declaring the name of the system property to be used enabling the debugging facilities. + * Class to assist with initialization of {@link Debug}. */ - public static class Initializer { + public static class Initialization { public static final String INITIALIZER_PROPERTY_NAME = "graal.debug.enable"; + + private static boolean initialized; + + /** + * Determines if {@link Debug} has been initialized. + */ + public static boolean isDebugInitialized() { + return initialized; + } + } @SuppressWarnings("all") - private static boolean assertionsEnabled() { - boolean enabled = false; - assert enabled = true; - return enabled; + private static boolean initialize() { + boolean assertionsEnabled = false; + assert assertionsEnabled = true; + Initialization.initialized = true; + return assertionsEnabled || Boolean.getBoolean(INITIALIZER_PROPERTY_NAME); } - private static final boolean ENABLED = assertionsEnabled() || Boolean.getBoolean(INITIALIZER_PROPERTY_NAME); + private static final boolean ENABLED = initialize(); public static boolean isEnabled() { return ENABLED; diff -r a27678c47948 -r 54dff87002e0 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Sep 12 16:23:28 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Thu Sep 12 17:32:45 2013 +0200 @@ -183,7 +183,8 @@ */ public static void finalizeOptions(boolean ciTime) { if (areDebugScopePatternsEnabled() || ciTime) { - System.setProperty(Debug.Initializer.INITIALIZER_PROPERTY_NAME, "true"); + assert !Debug.Initialization.isDebugInitialized(); + System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true"); } } diff -r a27678c47948 -r 54dff87002e0 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Thu Sep 12 16:23:28 2013 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java Thu Sep 12 17:32:45 2013 +0200 @@ -35,7 +35,7 @@ public static void initialize(PrintStream log) { if (!Debug.isEnabled()) { - log.println("WARNING: Scope debugging needs to be enabled with -esa or -D" + Debug.Initializer.INITIALIZER_PROPERTY_NAME + "=true"); + log.println("WARNING: Scope debugging needs to be enabled with -esa or -D" + Debug.Initialization.INITIALIZER_PROPERTY_NAME + "=true"); return; } List dumpHandlers = new ArrayList<>();