changeset 23344:5538acafd12f

support for jdk.internal.misc.VM (jdk9) as well as sun.misc.VM (< jdk9)
author Doug Simon <doug.simon@oracle.com>
date Wed, 20 Jan 2016 22:30:50 +0100
parents b2223a89bd22
children 3e4b96f3e4d3
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java	Wed Jan 20 10:54:25 2016 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java	Wed Jan 20 22:30:50 2016 +0100
@@ -40,7 +40,6 @@
 import jdk.vm.ci.runtime.JVMCICompilerFactory;
 import jdk.vm.ci.runtime.JVMCIRuntime;
 import jdk.vm.ci.services.Services;
-import sun.misc.VM;
 
 import com.oracle.graal.options.GraalJarsOptionDescriptorsProvider;
 import com.oracle.graal.options.Option;
@@ -105,7 +104,7 @@
     }
 
     /**
-     * Parses the options in the file denoted by the {@linkplain VM#getSavedProperty(String) saved}
+     * Parses the options in the file denoted by the {@code VM.getSavedProperty(String) saved}
      * system property named {@value HotSpotGraalCompilerFactory#GRAAL_OPTIONS_FILE_PROPERTY_NAME}
      * if the file exists followed by the options encoded in saved system properties whose names
      * start with {@code "graal.option."}. Key/value pairs are parsed from the file denoted by
@@ -140,7 +139,7 @@
                 }
             }
 
-            Properties savedProps = getSavedProperties();
+            Properties savedProps = getSavedProperties(jdk8OrEarlier);
 
             Map<String, String> optionSettings = new HashMap<>();
             for (Map.Entry<Object, Object> e : savedProps.entrySet()) {
@@ -159,9 +158,11 @@
         }
     }
 
-    private static Properties getSavedProperties() {
+    private static Properties getSavedProperties(boolean jdk8OrEarlier) {
         try {
-            Field savedPropsField = VM.class.getDeclaredField("savedProps");
+            String vmClassName = jdk8OrEarlier ? "sun.misc.VM" : "jdk.internal.misc.VM";
+            Class<?> vmClass = Class.forName(vmClassName);
+            Field savedPropsField = vmClass.getDeclaredField("savedProps");
             savedPropsField.setAccessible(true);
             return (Properties) savedPropsField.get(null);
         } catch (Exception e) {