[icedtea-web] RFC: Patch to check the manifest file for main class

Deepak Bhole dbhole at redhat.com
Mon Feb 27 14:42:22 PST 2012


Hi,

This commit introduced a check for main in HEAD:
http://icedtea.classpath.org/hg/icedtea-web/rev/bd59947fa857

However it causes an error if the main method is listed in the manifest
rather than JNLP (e.g.: http://pardemo02.ilog.fr/mapviewer/mapviewer.jnlp)

Attached patch adds a check in the manifest file for main.

ChangeLog:
2012-02-27  Deepak Bhole <dbhole at redhat.com>

	* netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
	(checkForMain): Also check manifest file of main jar.

OK for 1.2 and HEAD?

Thanks,
Deepak
-------------- next part --------------
diff -r 4d7bddf0d4de netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Mon Feb 27 21:58:41 2012 +0100
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Mon Feb 27 17:40:45 2012 -0500
@@ -593,6 +593,22 @@
             mainClass = ad.getMainClass();
         } else
             return;
+
+        // The main class may be specified in the manifest
+        if (mainClass == null) {
+            JARDesc mainJarDesc = file.getResources().getMainJAR();
+            File f = CacheUtil.getCacheFile(mainJarDesc.getLocation(), null);
+            if( f != null) {
+                try {
+                    JarFile mainJar = new JarFile(f);
+                    mainClass = mainJar.getManifest().
+                            getMainAttributes().getValue("Main-Class");
+                } catch (IOException ioe) {
+                    return;
+                }
+            }
+        }
+
         String desiredJarEntryName = mainClass + ".class";
 
         for (int i = 0; i < jars.size(); i++) {


More information about the distro-pkg-dev mailing list