< prev index next >

./build.gradle

Print this page
rev 10703 : 8189111: Cannot build JavaFX modules with boot JDK that does not already include them
Reviewed-by:

@@ -1061,10 +1061,23 @@
     inStream.close();
 }
 if (!project.hasProperty("jdkRuntimeVersion")) throw new Exception("Unable to determine the version of Java in JDK_HOME at $JDK_HOME");
 
 
+// Determine whether the javafx.* modules are present in the JDK. To do this,
+// we will execute "java --list-modules" and search for javafx.base
+ext.HAS_JAVAFX_MODULES = false;
+def inStream2 = new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.ProcessBuilder(JAVA, "--list-modules").start().getInputStream()));
+try {
+    String v;
+    while ((v = inStream2.readLine()) != null) {
+        v = v.trim();
+        if (v.startsWith("javafx.base")) ext.HAS_JAVAFX_MODULES = true;
+    }
+} finally {
+    inStream2.close();
+}
 
 // Verify that CONF is something useful
 if (CONF != "Release" && CONF != "Debug" && CONF != "DebugNative") {
     logger.warn("Unknown configuration CONF='$CONF'. Treating as 'Release'")
 }

@@ -1117,10 +1130,11 @@
 logger.quiet("jdk.runtime.version: ${jdkRuntimeVersion}")
 logger.quiet("jdk version: ${jdkVersion}")
 logger.quiet("jdk build number: ${jdkBuildNumber}")
 logger.quiet("minimum jdk version: ${jfxBuildJdkVersionMin}")
 logger.quiet("minimum jdk build number: ${jfxBuildJdkBuildnumMin}")
+logger.quiet("HAS_JAVAFX_MODULES: $HAS_JAVAFX_MODULES")
 logger.quiet("STUB_RUNTIME: $STUB_RUNTIME")
 logger.quiet("CONF: $CONF")
 logger.quiet("NUM_COMPILE_THREADS: $NUM_COMPILE_THREADS")
 logger.quiet("COMPILE_TARGETS: $COMPILE_TARGETS")
 logger.quiet("COMPILE_FLAGS_FILES: $COMPILE_FLAGS_FILES")

@@ -1260,21 +1274,28 @@
 }
 
 void addJSL(Project project, String name, String pkg, List<String> addExports, Closure compile) {
     def lowerName = name.toLowerCase()
 
+    def modulePath = "${project.sourceSets.main.output.classesDir}"
+    modulePath += File.pathSeparator + "${rootProject.projectDir}/modules/javafx.base/build/classes/main"
     def compileCompilers = project.task("compile${name}Compilers",
             type: JavaCompile,
             dependsOn: project.compileJava) {
         description = "Compile the $name JSL Compilers"
 
-        classpath = project.files(project.sourceSets.main.output.classesDir) +
+        classpath =
                project.files(project.sourceSets.jslc.output.classesDir) +
                project.configurations.antlr
         source = [project.file("src/main/jsl-$lowerName")]
         destinationDir = project.file("$project.buildDir/classes/jsl-compilers/$lowerName")
 
+        options.compilerArgs.addAll([
+            "-implicit:none",
+            "--module-path", modulePath,
+            "--add-modules=javafx.graphics"
+            ])
         if (addExports != null) {
             options.compilerArgs.addAll(addExports)
         }
     }
 

@@ -1514,10 +1535,38 @@
 
     compileTestJava {
     }
 }
 
+// Qualified exports needed by javafx.* modules (excluding javafx.swing)
+def qualExportsCore = [
+    "--add-exports=java.base/jdk.internal.misc=javafx.graphics",
+    "--add-exports=java.base/jdk.internal.ref=javafx.media",
+    "--add-exports=java.base/sun.net.www=javafx.web",
+    "--add-exports=java.base/sun.nio.ch=javafx.media",
+    "--add-exports=java.base/sun.reflect.misc=javafx.base",
+    "--add-exports=java.base/sun.reflect.misc=javafx.fxml",
+    "--add-exports=java.base/sun.reflect.misc=javafx.web",
+    "--add-exports=java.base/sun.util.logging=javafx.base",
+    "--add-exports=java.base/sun.util.logging=javafx.controls",
+    "--add-exports=java.base/sun.util.logging=javafx.fxml",
+    "--add-exports=java.base/sun.util.logging=javafx.graphics",
+    "--add-exports=java.desktop/sun.font.lookup=javafx.graphics",
+    "--add-exports=java.desktop/sun.print=javafx.graphics",
+]
+
+// Qualified exports needed by javafx.swing
+def qualExportsSwing = [
+        "--add-exports=java.base/sun.util.logging=javafx.swing",
+        "--add-exports=java.desktop/java.awt.dnd.peer=javafx.swing",
+        "--add-exports=java.desktop/sun.awt=javafx.swing",
+        "--add-exports=java.desktop/sun.awt.dnd=javafx.swing",
+        "--add-exports=java.desktop/sun.awt.image=javafx.swing",
+        "--add-exports=java.desktop/sun.java2d=javafx.swing",
+        "--add-exports=java.desktop/sun.swing=javafx.swing",
+]
+
 // These strings define the module-source-path to be used in compilation.
 // They need to contain the full paths to the sources and the * will be
 // used to infer the module name that is used.
 project.ext.defaultModuleSourcePath =
     cygpath(rootProject.projectDir.path + '/modules/*/src/main/java') +

@@ -1593,10 +1642,12 @@
     // We DO NOT want to include src/main/version-info
 
     sourceSets.main.java.srcDirs += "$buildDir/gensrc/java"
 
     compileJava.dependsOn processVersionInfo
+
+    compileJava.options.compilerArgs.addAll(qualExportsCore)
 }
 
 // The graphics module is needed for any graphical JavaFX application. It requires
 // the base module and includes the scene graph, layout, css, prism, windowing, etc.
 // This is a fairly complicated module. There are many different types of native components

@@ -1705,10 +1756,11 @@
         options.compilerArgs.addAll([
             '-h', "$buildDir/gensrc/headers/",  // Note: this creates the native headers
             '-implicit:none',
             '--module-source-path', defaultModuleSourcePath
             ] )
+        options.compilerArgs.addAll(qualExportsCore)
     }
     classes.dependsOn(compileFullJava)
 
     project.sourceSets.shims.java.srcDirs += project.sourceSets.shaders.output
     project.sourceSets.shims.java.srcDirs += "$buildDir/gensrc/jsl-prism"

@@ -1843,10 +1895,12 @@
     // The native library must be copied over during SDK creation time in the "sdk" task. In
     // addition to these steps, the clean task is created. Note that I didn't bother to create
     // a new task for each of the decora files, preferring instead just to create a rule?? Also
     // need "clean" tasks for each compile task.
 
+    def modulePath = "${project.sourceSets.main.output.classesDir}"
+    modulePath += File.pathSeparator + "${rootProject.projectDir}/modules/javafx.base/build/classes/main"
     addJSL(project, "Decora", "com/sun/scenario/effect/impl/hw/d3d/hlsl", decoraAddExports) { sourceDir, destinationDir ->
         [[fileName: "ColorAdjust", generator: "CompileJSL", outputs: "-all"],
          [fileName: "Brightpass", generator: "CompileJSL", outputs: "-all"],
          [fileName: "SepiaTone", generator: "CompileJSL", outputs: "-all"],
          [fileName: "PerspectiveTransform", generator: "CompileJSL", outputs: "-all"],

@@ -1863,12 +1917,13 @@
                 classpath = configurations.compile + configurations.antlr
                 classpath += files(project.sourceSets.jslc.output.classesDir)
 
                 classpath += files("${project.projectDir}/src/jslc/resources")
 
-                classpath += files("$buildDir/classes/main")
                 classpath += files("$buildDir/classes/jsl-compilers/decora")
+                jvmArgs += "--module-path=$modulePath"
+                jvmArgs += "--add-modules=javafx.graphics"
                 jvmArgs += decoraAddExports
                 args += ["-i", sourceDir, "-o", destinationDir, "-t", "-pkg", "com/sun/scenario/effect", "$settings.outputs", "$settings.fileName"]
             }
         }
     }

@@ -2009,10 +2064,12 @@
                 include "**/antlr-complete-3.5.2.jar"
                 includeEmptyDirs = false
             }
         }
     }
+
+    compileJava.options.compilerArgs.addAll(qualExportsCore)
 }
 
 project(":controls") {
     project.ext.buildModule = true
     project.ext.includeSources = true

@@ -2039,20 +2096,29 @@
         def cssDir = file("$buildDir/classes/main/javafx")
         jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit",
             "-DCSS_META_DATA_TEST_DIR=$cssDir"
     }
 
+    List<String> css2BinAddExports = [
+            '--add-exports=java.base/sun.util.logging=javafx.graphics',
+            ]
+    def modulePath = "${project.sourceSets.main.output.classesDir}"
+    modulePath += File.pathSeparator + "${rootProject.projectDir}/modules/javafx.graphics/build/classes/main"
+    modulePath += File.pathSeparator + "${rootProject.projectDir}/modules/javafx.base/build/classes/main"
     processResources << {
         def cssFiles = fileTree(dir: "$moduleDir/com/sun/javafx/scene/control/skin")
         cssFiles.include "**/*.css"
         cssFiles.each { css ->
             logger.info("converting CSS to BSS ${css}");
 
             javaexec {
                 executable = JAVA
                 workingDir = project.projectDir
                 jvmArgs += patchModuleArgs
+                jvmArgs += "--module-path=$modulePath"
+                jvmArgs += "--add-modules=javafx.graphics"
+                jvmArgs += css2BinAddExports
                 main = "com.sun.javafx.css.parser.Css2Bin"
                 args css
             }
         }
     }

@@ -2060,10 +2126,12 @@
     processShimsResources.dependsOn(project.task("copyShimBss", type: Copy) {
         from project.moduleDir
         into project.moduleShimsDir
         include "**/*.bss"
     })
+
+    compileJava.options.compilerArgs.addAll(qualExportsCore)
 }
 
 project(":swing") {
     /* should not be built, but needed in JMX
     tasks.all {

@@ -2090,10 +2158,13 @@
     }
 
     test {
         enabled = IS_FULL_TEST && IS_AWT_TEST
     }
+
+    compileJava.options.compilerArgs.addAll(qualExportsCore)
+    compileJava.options.compilerArgs.addAll(qualExportsSwing)
 }
 
 project(":swt") {
     tasks.all {
         if (!COMPILE_SWT) it.enabled = false

@@ -2180,10 +2251,12 @@
         // we have to use the stub toolkit for now.
         jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit"
         // FIXME: change this to also allow JDK 9 boot jdk
         classpath += files("$JDK_HOME/jre/lib/ext/nashorn.jar")
     }
+
+    compileJava.options.compilerArgs.addAll(qualExportsCore)
 }
 
 project(":jmx") {
     project.ext.buildModule = false
     project.ext.moduleRuntime = false

@@ -3106,10 +3179,12 @@
         dependsOn compileJava
         if (IS_COMPILE_MEDIA) {
             dependsOn buildNativeTargets
         }
     }
+
+    compileJava.options.compilerArgs.addAll(qualExportsCore)
 }
 
 project(":web") {
     configurations {
         webkit

@@ -3324,10 +3399,12 @@
     }
 
     if (IS_COMPILE_WEBKIT) {
         assemble.dependsOn compileJavaDOMBinding, drtJar
     }
+
+    compileJava.options.compilerArgs.addAll(qualExportsCore)
 }
 
 // This project is for system tests that need to run with a full SDK.
 // Most of them display a stage or do other things that preclude running
 // them in a shared JVM or as part of the "smoke test" run (which must
< prev index next >