jdk/src/share/classes/sun/launcher/LauncherHelper.java
changeset 1329 ce13b59a8401
parent 1323 e14a3b3536cd
child 1343 ecc86134ee4c
--- a/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Fri Oct 03 09:36:05 2008 -0700
+++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Wed Oct 01 09:04:42 2008 -0700
@@ -151,7 +151,7 @@
                 throw new IOException("no main mainifest attributes, in " +
                         jarname);
             }
-            return mainAttrs.getValue(MAIN_CLASS);
+            return mainAttrs.getValue(MAIN_CLASS).trim();
         } finally {
             if (jarFile != null) {
                 jarFile.close();
@@ -207,10 +207,9 @@
             throw new RuntimeException("Main method not found in " + classname);
         }
         /*
-         * Usually the getMethod (above) will choose the correct method, based
-         * on its modifiers and parameter types, the only check required is the
-         * getReturnType check as getMethod does not check for this, all the
-         * other modifier tests are redundant, and are simply here for safety.
+         * getMethod (above) will choose the correct method, based
+         * on its name and parameter type, however, we still have to
+         * ensure that the method is static and returns a void.
          */
         int mod = method.getModifiers();
         if (!Modifier.isStatic(mod)) {
@@ -219,12 +218,6 @@
             throw new RuntimeException("Main method is not static in class " +
                     classname);
         }
-        if (!Modifier.isPublic(mod)) {
-            ostream.println(getLocalizedMessage("java.launcher.cls.error2",
-                    "public", classname));
-            throw new RuntimeException("Main method is not public in class " +
-                    classname);
-        }
         Class<?> rType = method.getReturnType();
         if (!rType.isPrimitive() || !rType.getName().equals("void")) {
             ostream.println(getLocalizedMessage("java.launcher.cls.error3",