changeset 5742:6b44a535f706

RT-34236: FXMLLoader throws " java.lang.InternalError: CallerSensitive annotation expected at frame 1 " Summary: JDK8 should not embed the launcher anymore Reviewed-by: kcr ddehaven
author mhowe
date Mon, 18 Nov 2013 14:58:17 -0800
parents 2650ad7e53bf
children 267dbc0bb8a4
files modules/fxpackager/src/main/java/com/sun/javafx/tools/ant/FXJar.java modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/CreateJarParams.java modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/Main.java modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java
diffstat 4 files changed, 41 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/modules/fxpackager/src/main/java/com/sun/javafx/tools/ant/FXJar.java	Mon Nov 18 16:24:16 2013 -0500
+++ b/modules/fxpackager/src/main/java/com/sun/javafx/tools/ant/FXJar.java	Mon Nov 18 14:58:17 2013 -0800
@@ -115,8 +115,6 @@
         checkAttributesAndElements();
 
         createJarParams.setCss2bin(css2bin);
-        //always embed JavaFX launcher
-        createJarParams.setEmbedLauncher(true);
 
         if (app != null) {
            createJarParams.setApplicationClass(app.get().mainClass);
--- a/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/CreateJarParams.java	Mon Nov 18 16:24:16 2013 -0500
+++ b/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/CreateJarParams.java	Mon Nov 18 14:58:17 2013 -0800
@@ -78,6 +78,12 @@
         this.css2bin = css2bin;
     }
 
+    /**
+     * In JKD8/FX8 launcher is never embedded,
+     * app must use main to call Application launcher()
+     * @deprecated
+     * @param embedLauncher
+     */
     public void setEmbedLauncher(boolean embedLauncher) {
         this.embedLauncher = embedLauncher;
     }
@@ -109,7 +115,7 @@
         return "CreateJarParams{" + "applicationClass=" + applicationClass
                 + " preloader=" + preloader + " classpath=" + classpath
                 + " manifestAttrs=" + manifestAttrs
-                + " embedLauncher=" + embedLauncher + " css2bin=" + css2bin
+                + " embedLauncher=deprecated" + " css2bin=" + css2bin
                 + " outfile=" + outfile + " sdkHome=" + fxVersion + '}'
                 + "            CommonParams{" + "outdir=" + outdir
                 + " verbose=" + verbose + " resources=" + resources + '}';
--- a/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/Main.java	Mon Nov 18 16:24:16 2013 -0500
+++ b/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/Main.java	Mon Nov 18 14:58:17 2013 -0800
@@ -193,7 +193,7 @@
                         } else if (arg.equalsIgnoreCase("-manifestAttrs")) {
                             createJarParams.setManifestAttrs(createAttrMap(nextArg(args, i++)));
                         } else if (arg.equalsIgnoreCase("-noembedlauncher")) {
-                            createJarParams.setEmbedLauncher(false);
+                            System.out.println("-noembedlauncher is deprecated");
                         } else if (arg.equalsIgnoreCase("-nocss2bin")) {
                             createJarParams.setCss2bin(false);
                         } else if (arg.equalsIgnoreCase("-runtimeVersion")) {
--- a/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java	Mon Nov 18 16:24:16 2013 -0500
+++ b/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/PackagerLib.java	Mon Nov 18 14:58:17 2013 -0800
@@ -105,16 +105,9 @@
     private File bssTmpDir;
     private boolean isSignedJNLP;
 
+
     private enum Filter {ALL, CLASSES_ONLY, RESOURCES};
 
-    private static String[] launcherFiles = {
-        "com/javafx/main/Main.class",
-        "com/javafx/main/Main$1.class",
-        "com/javafx/main/Main$2.class",
-        "com/javafx/main/NoJavaFXFallback.class"
-    };
-    private static String prefix_in_antjar = "/resources/classes/";
-
     private ClassLoader classLoader;
 
     private ClassLoader getClassLoader() throws PackagerException {
@@ -251,60 +244,46 @@
                 attr.put(new Attributes.Name(e.getKey()), e.getValue());
             }
         }
-        if (createJarParams.embedLauncher) {
-            //Reset Classpath (make sense if we are updating jar)
-            attr.remove(Attributes.Name.CLASS_PATH);
 
-            attr.put(Attributes.Name.MAIN_CLASS, "com/javafx/main/Main");
-            attr.put(new Attributes.Name(MANIFEST_JAVAFX_MAIN), createJarParams.applicationClass);
-            attr.put(new Attributes.Name("JavaFX-Version"), createJarParams.fxVersion);
+        attr.put(Attributes.Name.MAIN_CLASS, createJarParams.applicationClass);
+        if (createJarParams.classpath != null) {
+            // Allow comma or semicolon as delimeter (turn them into spaces)
+            String cp = createJarParams.classpath;
+            cp = cp.replace(';', ' ').replace(',', ' ');
+            attr.put(new Attributes.Name("Class-Path"), cp);
+        }
 
-            if (createJarParams.preloader != null) {
-                attr.put(new Attributes.Name("JavaFX-Preloader-Class"), createJarParams.preloader);
+        attr.put(new Attributes.Name("JavaFX-Version"), createJarParams.fxVersion);
+
+        if (createJarParams.preloader != null) {
+            attr.put(new Attributes.Name("JavaFX-Preloader-Class"), createJarParams.preloader);
+        }
+
+
+        if (createJarParams.arguments != null) {
+            int idx = 1;
+            for (String arg: createJarParams.arguments) {
+                attr.put(new Attributes.Name("JavaFX-Argument-"+idx),
+                        encodeAsBase64(arg.getBytes()));
+                idx++;
             }
-
-            if (createJarParams.classpath != null) {
-                // Allow comma or semicolon as delimeter (turn them into spaces)
-                String cp = createJarParams.classpath;
-                cp = cp.replace(';', ' ').replace(',', ' ');
-                attr.put(new Attributes.Name("JavaFX-Class-Path"), cp);
-            }
-            //Default fallback class uses "private" interface to
-            // get additional error paramters. Do not add it to manifest
-            // explicitly to avoid treating it as custom
-            if (createJarParams.fallbackClass != null &&
-                    !createJarParams.defaultFallbackApp.equals(
-                    createJarParams.fallbackClass)) {
-                attr.put(new Attributes.Name("JavaFX-Fallback-Class"),
-                        createJarParams.fallbackClass);
-            }
-
-            if (createJarParams.arguments != null) {
-                int idx = 1;
-                for (String arg: createJarParams.arguments) {
-                    attr.put(new Attributes.Name("JavaFX-Argument-"+idx),
-                            encodeAsBase64(arg.getBytes()));
+        }
+        if (createJarParams.params != null) {
+            int idx = 1;
+            for (Param p : createJarParams.params) {
+                if (p.name != null) { //otherwise it is something weird and we skip it
+                    attr.put(new Attributes.Name("JavaFX-Parameter-Name-" + idx),
+                            encodeAsBase64(p.name.getBytes()));
+                    if (p.value != null) { //legal, means not value specified
+                        attr.put(new Attributes.Name("JavaFX-Parameter-Value-" + idx),
+                                encodeAsBase64(p.value.getBytes()));
+                    }
                     idx++;
                 }
             }
-            if (createJarParams.params != null) {
-                int idx = 1;
-                for (Param p : createJarParams.params) {
-                    if (p.name != null) { //otherwise it is something weird and we skip it
-                        attr.put(new Attributes.Name("JavaFX-Parameter-Name-" + idx),
-                                encodeAsBase64(p.name.getBytes()));
-                        if (p.value != null) { //legal, means not value specified
-                            attr.put(new Attributes.Name("JavaFX-Parameter-Value-" + idx),
-                                    encodeAsBase64(p.value.getBytes()));
-                        }
-                        idx++;
-                    }
-                }
-            }
-        } else {
-            attr.put(Attributes.Name.MAIN_CLASS, createJarParams.applicationClass);
         }
 
+
         if (createJarParams.css2bin) {
             try {
                 bssTmpDir = File.createTempFile("bssfiles", "");
@@ -1404,9 +1383,6 @@
                             pr.getBaseDir().getAbsolutePath().length() + 1);
                 }
             }
-            if (createJarParams.embedLauncher) {
-                addEmbeddedLauncher(jar);
-            }
         } finally {
             jar.close();
             alreadyAddedEntries.clear();
@@ -1429,30 +1405,6 @@
         }
     }
 
-    private void addEmbeddedLauncher(JarOutputStream jar) throws IOException {
-        for (String cls : launcherFiles) {
-            String nm = prefix_in_antjar + cls;
-            InputStream in = PackagerLib.class.getResourceAsStream(nm);
-            if (in == null) {
-                System.err.println(
-                        "Internal error. Missing embedded resource [" + cls + "]");
-            }
-            jar.putNextEntry(new JarEntry(cls));
-
-            byte b[] = new byte[65000];
-            int i;
-            try {
-                while ((i = in.read(b)) > 0) {
-                    jar.write(b, 0, i);
-                }
-            } finally {
-                in.close();
-            }
-
-            jar.closeEntry();
-        }
-    }
-
     //add everything but manifest from given jar file
     private void copyFromOtherJar(JarOutputStream jar, File inputFile) throws IOException {
         JarFile inJar = new JarFile(inputFile);