--- old/modules/jdk.packager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java 2017-12-13 19:01:47.000000000 -0800 +++ new/modules/jdk.packager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java 2017-12-13 19:01:46.000000000 -0800 @@ -34,6 +34,7 @@ import com.sun.javafx.tools.packager.bundlers.BundleParams; import com.sun.javafx.tools.packager.bundlers.Bundler.BundleType; import com.sun.javafx.tools.resource.PackagerResource; +import com.sun.javafx.css.parser.Css2Bin; import java.io.BufferedReader; import java.io.File; @@ -46,10 +47,6 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.Writer; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.security.InvalidKeyException; @@ -98,20 +95,6 @@ private enum Filter {ALL, CLASSES_ONLY, RESOURCES} - private ClassLoader classLoader; - - private ClassLoader getClassLoader() throws PackagerException { - if (classLoader == null) { - try { - URL[] urls = {new URL(getJfxrtPath())}; - classLoader = URLClassLoader.newInstance(urls); - } catch (MalformedURLException ex) { - throw new PackagerException(ex, "ERR_CantFindRuntime"); - } - } - return classLoader; - } - // if set of input resources consist of SINGLE element and // this element is jar file then we expect this to be request to // "update" jar file @@ -517,14 +500,6 @@ final File javac = new File(new File(jHome), "bin/javac" + exe); - String jfxHome = System.getenv("JAVAFX_HOME"); - if (jfxHome == null) { - jfxHome = System.getProperty("javafx.home"); - } - if (jfxHome == null) { - throw new PackagerException("ERR_MissingJavaFxHome"); - } - final String srcDirName = "src"; final String compiledDirName = "compiled"; final String distDirName = "dist"; @@ -542,23 +517,31 @@ try (FileWriter sources = new FileWriter(tmpFile)) { scanAndCopy(new PackagerResource(new File(srcDirName), "."), sources, compiledDir); } - String classpath = jfxHome + "/../lib/jfxrt.jar"; - if (makeAllParams.classpath != null) { - classpath += File.pathSeparator + makeAllParams.classpath; - } + if (makeAllParams.verbose) { Log.info("Executing javac:"); Log.infof("%s %s %s %s %s %s%n", javac.getAbsolutePath(), "-d", compiledDirName, - "-cp", classpath, + "-cp", makeAllParams.classpath != null ? + makeAllParams.classpath : "", "@" + tmpFile.getAbsolutePath()); } - int ret = execute( - javac.getAbsolutePath(), - "-d", compiledDirName, - "-cp", classpath, - "@" + tmpFile.getAbsolutePath()); + + int ret = -1; + if (makeAllParams.classpath != null) { + ret = execute( + javac.getAbsolutePath(), + "-d", compiledDirName, + "-cp", makeAllParams.classpath, + "@" + tmpFile.getAbsolutePath()); + } else { + ret = execute( + javac.getAbsolutePath(), + "-d", compiledDirName, + "@" + tmpFile.getAbsolutePath()); + } + if (ret != 0) { throw new PackagerException("ERR_JavacFailed", Integer.toString(ret)); } @@ -833,34 +816,6 @@ } } - // Returns path to jfxrt.jar relatively to jar containing PackagerLib.class - private String getJfxrtPath() throws PackagerException { - String theClassFile = "PackagerLib.class"; - Class theClass = PackagerLib.class; - String classUrl = theClass.getResource(theClassFile).toString(); - - if (!classUrl.startsWith("jar:file:") || !classUrl.contains("!")){ - throw new PackagerException("ERR_CantFindRuntime"); - } - - // Strip everything after and including the "!" - classUrl = classUrl.substring(0, classUrl.lastIndexOf("!")); - // Strip everything after the last "/" or "\" to get rid of the jar filename - int lastIndexOfSlash = Math.max(classUrl.lastIndexOf("/"), classUrl.lastIndexOf("\\")); - - return classUrl.substring(0, lastIndexOfSlash) - + "/../lib/jfxrt.jar!/"; - } - - private Class loadClassFromRuntime(String className) throws PackagerException { - try { - ClassLoader cl = getClassLoader(); - return cl.loadClass(className); - } catch (ClassNotFoundException ex) { - throw new PackagerException(ex, "ERR_CantFindRuntime"); - } - } - private void createBinaryCss(String cssFile, String binCssFile) throws PackagerException { String ofname = (binCssFile != null) ? binCssFile @@ -873,21 +828,9 @@ parentFile.mkdirs(); } - // Using reflection because CSS parser is part of runtime - // and we want to avoid dependency on jfxrt during build - Class clazz; try { - clazz = Class.forName("com.sun.javafx.css.parser.Css2Bin"); - } catch (ClassNotFoundException e) { - // class was not found with default class loader, trying to - // locate it by loading from jfxrt.jar - clazz = loadClassFromRuntime("com.sun.javafx.css.parser.Css2Bin"); - } - - try { - Method m = clazz.getMethod("convertToBinary", String.class, String.class); - m.invoke(null, cssFile, ofname); - } catch (Exception ex) { + Css2Bin.convertToBinary(cssFile, ofname); + } catch (IOException ex) { Throwable causeEx = ex.getCause(); String cause = (causeEx != null) ? causeEx.getMessage() : bundle.getString("ERR_UnknownReason");