changeset 27204:d32159f98906

added compile-time only JDK9_STUBS library to support compilation with JDK8 javac and Eclipse
author Doug Simon <doug.simon@oracle.com>
date Tue, 19 Jan 2016 16:43:13 +0100
parents aeacc0114172
children 52d4adddb417
files .mx.jvmci/mx_jvmci.py .mx.jvmci/suite.py src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
diffstat 3 files changed, 46 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/.mx.jvmci/mx_jvmci.py	Tue Jan 19 13:13:41 2016 +0100
+++ b/.mx.jvmci/mx_jvmci.py	Tue Jan 19 16:43:13 2016 +0100
@@ -880,3 +880,38 @@
 
     for jdkDist in jdkDeployedDists:
         jdkDist.post_parse_cmd_line()
+
+def _update_JDK9_STUBS_library():
+    """
+    Sets the "path" and "sha1" attributes of the "JDK9_STUBS" library.
+    """
+    jdk9InternalLib = _suite.suiteDict['libraries']['JDK9_STUBS']
+    jarInputDir = join(_suite.get_output_root(), 'jdk9-stubs')
+    jarPath = join(_suite.get_output_root(), 'jdk9-stubs.jar')
+
+    stubs = [
+        ('jdk.internal.misc', 'VM', """package jdk.internal.misc;
+public class VM {
+    public static String getSavedProperty(String key) {
+        throw new InternalError("should not reach here");
+    }
+}
+""")
+    ]
+
+    if not exists(jarPath):
+        sourceFiles = []
+        for (package, className, source) in stubs:
+            sourceFile = join(jarInputDir, package.replace('.', os.sep), className + '.java')
+            mx.ensure_dir_exists(os.path.dirname(sourceFile))
+            with open(sourceFile, 'w') as fp:
+                fp.write(source)
+            sourceFiles.append(sourceFile)
+        jdk = mx.get_jdk(tag='default')
+        mx.run([jdk.javac, '-d', jarInputDir] + sourceFiles)
+        mx.run([jdk.jar, 'cf', jarPath, '.'], cwd=jarInputDir)
+
+    jdk9InternalLib['path'] = jarPath
+    jdk9InternalLib['sha1'] = mx.sha1OfFile(jarPath)
+
+_update_JDK9_STUBS_library()
--- a/.mx.jvmci/suite.py	Tue Jan 19 13:13:41 2016 +0100
+++ b/.mx.jvmci/suite.py	Tue Jan 19 16:43:13 2016 +0100
@@ -24,7 +24,7 @@
 
   "defaultLicense" : "GPLv2-CPE",
 
-  # This puts mx/ as a sibiling of the JDK build configuration directories
+  # This puts mx/ as a sibling of the JDK build configuration directories
   # (e.g., macosx-x86_64-normal-server-release).
   "outputRoot" : "../build/mx/hotspot",
 
@@ -32,8 +32,6 @@
 
   "libraries" : {
 
-    # ------------- Libraries -------------
-
     "HCFDIS" : {
       "urls" : ["https://lafo.ssw.uni-linz.ac.at/pub/hcfdis-3.jar"],
       "sha1" : "a71247c6ddb90aad4abf7c77e501acc60674ef57",
@@ -53,6 +51,13 @@
       "sha1" : "122b87ca88e41a415cf8b523fd3d03b4325134a3",
       "urls" : ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/batik-all-1.7.jar"],
     },
+
+    # Stubs for classes introduced in JDK9 that allow compilation with a JDK8 javac and Eclipse.
+    # The "path" and "sha1" attributes are added when mx_jvmci is loaded
+    # (see mx_jvmci._update_JDK9_STUBS_library()).
+    "JDK9_STUBS" : {
+        "license" : "GPLv2-CPE",
+     },
   },
 
   "projects" : {
@@ -163,6 +168,7 @@
         "jdk.vm.ci.inittimer",
         "jdk.vm.ci.runtime",
         "jdk.vm.ci.services",
+        "JDK9_STUBS",
       ],
       "checkstyle" : "jdk.vm.ci.services",
       "javaCompliance" : "1.8",
@@ -298,6 +304,7 @@
         "jdk.vm.ci.hotspot.amd64",
         "jdk.vm.ci.hotspot.sparc",
       ],
+      "exclude" : ["JDK9_STUBS"]
     },
   },
 }
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Tue Jan 19 13:13:41 2016 +0100
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Tue Jan 19 16:43:13 2016 +0100
@@ -37,6 +37,7 @@
 import java.util.Objects;
 import java.util.TreeMap;
 
+import jdk.internal.misc.VM;
 import jdk.vm.ci.code.Architecture;
 import jdk.vm.ci.code.CompilationRequestResult;
 import jdk.vm.ci.code.CompiledCode;
@@ -51,7 +52,6 @@
 import jdk.vm.ci.runtime.JVMCIBackend;
 import jdk.vm.ci.runtime.JVMCICompiler;
 import jdk.vm.ci.services.Services;
-import jdk.internal.misc.VM;
 
 //JaCoCo Exclude