--- a/jdk/src/share/classes/sun/misc/URLClassPath.java Mon Jan 21 23:17:58 2013 -0500
+++ b/jdk/src/share/classes/sun/misc/URLClassPath.java Mon Jan 21 23:20:42 2013 -0500
@@ -35,6 +35,7 @@
import java.util.jar.Manifest;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
+import java.util.jar.UnsupportedProfileException;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@@ -64,6 +65,12 @@
final static String JAVA_VERSION;
private static final boolean DEBUG;
+ /**
+ * Used by launcher to indicate that checking of the JAR file "Profile"
+ * attribute has been suppressed.
+ */
+ private static boolean profileCheckSuppressedByLauncher;
+
static {
JAVA_VERSION = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.version"));
@@ -581,6 +588,15 @@
}
}
+ /**
+ * Used by the launcher to suppress further checking of the JAR file Profile
+ * attribute (necessary when the launcher is aborting as the abort involves
+ * a resource lookup that may involve opening additional JAR files)
+ */
+ public static void suppressProfileCheckForLauncher() {
+ profileCheckSuppressedByLauncher = true;
+ }
+
/*
* Inner class used to represent a Loader of resources from a JAR URL.
*/
@@ -788,6 +804,28 @@
return false;
}
+ /**
+ * If the Profile attribute is present then this method checks that the runtime
+ * supports that profile.
+ *
+ * ## Add a fast path like Class-Path to avoid reading the manifest when the attribute
+ * is not present.
+ */
+ void checkProfileAttribute() throws IOException {
+ Manifest man = jar.getManifest();
+ if (man != null) {
+ Attributes attr = man.getMainAttributes();
+ if (attr != null) {
+ String value = attr.getValue(Name.PROFILE);
+ if (value != null && !Version.supportsProfile(value)) {
+ String prefix = Version.profileName().length() > 0 ?
+ "This runtime implements " + Version.profileName() + ", " : "";
+ throw new UnsupportedProfileException(prefix + csu + " requires " + value);
+ }
+ }
+ }
+ }
+
/*
* Returns the URL for a resource with the specified name
*/
@@ -957,6 +995,12 @@
ensureOpen();
parseExtensionsDependencies();
+
+ // check Profile attribute if present
+ if (!profileCheckSuppressedByLauncher) {
+ checkProfileAttribute();
+ }
+
if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) { // Only get manifest when necessary
Manifest man = jar.getManifest();
if (man != null) {