From 3b10a3f9b81229e3fec028fe173b3e7de69f65b6 Mon Sep 17 00:00:00 2001
From: Bradford Wetmore
Date: Mon, 21 May 2012 15:42:15 -0700
Subject: [PATCH 01/56] 7167656: Multiple Seeders are being created
Reviewed-by: smarks, mduigou, ahgross
---
.../sun/security/provider/SecureRandom.java | 35 ++++++++++++-------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/jdk/src/share/classes/sun/security/provider/SecureRandom.java b/jdk/src/share/classes/sun/security/provider/SecureRandom.java
index e79e9d7f49a..fa88334e1c3 100644
--- a/jdk/src/share/classes/sun/security/provider/SecureRandom.java
+++ b/jdk/src/share/classes/sun/security/provider/SecureRandom.java
@@ -56,12 +56,6 @@ implements java.io.Serializable {
private static final long serialVersionUID = 3581829991155417889L;
- /**
- * This static object will be seeded by SeedGenerator, and used
- * to seed future instances of SecureRandom
- */
- private static SecureRandom seeder;
-
private static final int DIGEST_SIZE = 20;
private transient MessageDigest digest;
private byte[] state;
@@ -172,6 +166,28 @@ implements java.io.Serializable {
state[0]++;
}
+ /**
+ * This static object will be seeded by SeedGenerator, and used
+ * to seed future instances of SHA1PRNG SecureRandoms.
+ *
+ * Bloch, Effective Java Second Edition: Item 71
+ */
+ private static class SeederHolder {
+
+ private static final SecureRandom seeder;
+
+ static {
+ /*
+ * Call to SeedGenerator.generateSeed() to add additional
+ * seed material (likely from the Native implementation).
+ */
+ seeder = new SecureRandom(SeedGenerator.getSystemEntropy());
+ byte [] b = new byte[DIGEST_SIZE];
+ SeedGenerator.generateSeed(b);
+ seeder.engineSetSeed(b);
+ }
+ }
+
/**
* Generates a user-specified number of random bytes.
*
@@ -183,13 +199,8 @@ implements java.io.Serializable {
byte[] output = remainder;
if (state == null) {
- if (seeder == null) {
- seeder = new SecureRandom(SeedGenerator.getSystemEntropy());
- seeder.engineSetSeed(engineGenerateSeed(DIGEST_SIZE));
- }
-
byte[] seed = new byte[DIGEST_SIZE];
- seeder.engineNextBytes(seed);
+ SeederHolder.seeder.engineNextBytes(seed);
state = digest.digest(seed);
}
From 52f39f95df16df5d3f5c9c6df42cacb2778f3a45 Mon Sep 17 00:00:00 2001
From: Sean Mullan
Date: Fri, 8 Jun 2012 11:02:47 -0400
Subject: [PATCH 02/56] 7163198: Tightened package accessibility 7169887:
Tightened package accessibility
Reviewed-by: vinnie, hawtin
---
jdk/src/share/lib/security/java.security | 4 ++--
jdk/src/share/lib/security/java.security-macosx | 4 ++--
jdk/src/share/lib/security/java.security-solaris | 4 ++--
jdk/src/share/lib/security/java.security-windows | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/jdk/src/share/lib/security/java.security b/jdk/src/share/lib/security/java.security
index e8ca7bd7eea..3bb8597654c 100644
--- a/jdk/src/share/lib/security/java.security
+++ b/jdk/src/share/lib/security/java.security
@@ -145,7 +145,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# List of comma-separated packages that start with or equal this string
@@ -157,7 +157,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
-package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# Determines whether this properties file can be appended to
diff --git a/jdk/src/share/lib/security/java.security-macosx b/jdk/src/share/lib/security/java.security-macosx
index 1c04236e5d6..689172f40d6 100644
--- a/jdk/src/share/lib/security/java.security-macosx
+++ b/jdk/src/share/lib/security/java.security-macosx
@@ -146,7 +146,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# List of comma-separated packages that start with or equal this string
@@ -158,7 +158,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
-package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# Determines whether this properties file can be appended to
diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris
index 87a6f1ea5b4..1c5062c4c8b 100644
--- a/jdk/src/share/lib/security/java.security-solaris
+++ b/jdk/src/share/lib/security/java.security-solaris
@@ -147,7 +147,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# List of comma-separated packages that start with or equal this string
@@ -159,7 +159,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
-package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# Determines whether this properties file can be appended to
diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows
index e7c36d8c470..c98c0c95865 100644
--- a/jdk/src/share/lib/security/java.security-windows
+++ b/jdk/src/share/lib/security/java.security-windows
@@ -146,7 +146,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# List of comma-separated packages that start with or equal this string
@@ -158,7 +158,7 @@ package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.
# by default, none of the class loaders supplied with the JDK call
# checkPackageDefinition.
#
-package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
+package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.
#
# Determines whether this properties file can be appended to
From a15896d20e9470d22e8cb97c1e51d94d7b9d760c Mon Sep 17 00:00:00 2001
From: Weijun Wang
Date: Fri, 15 Jun 2012 09:51:09 +0800
Subject: [PATCH 03/56] 6631398: FilePermission improved path checking
Reviewed-by: mullan, skoivu, jdn
---
jdk/src/share/classes/java/io/FilePermission.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jdk/src/share/classes/java/io/FilePermission.java b/jdk/src/share/classes/java/io/FilePermission.java
index a5781f3fb00..2555a77644d 100644
--- a/jdk/src/share/classes/java/io/FilePermission.java
+++ b/jdk/src/share/classes/java/io/FilePermission.java
@@ -418,7 +418,7 @@ public final class FilePermission extends Permission implements Serializable {
*/
public int hashCode() {
- return this.cpath.hashCode();
+ return 0;
}
/**
From d87e57ac8aaa1902baeadb3a73aa757a3505fda1 Mon Sep 17 00:00:00 2001
From: Sean Mullan
Date: Mon, 18 Jun 2012 10:00:55 -0400
Subject: [PATCH 04/56] 7172522: Improve DomainCombiner checking
Reviewed-by: vinnie, ahgross
---
jdk/src/share/classes/java/security/AccessController.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/jdk/src/share/classes/java/security/AccessController.java b/jdk/src/share/classes/java/security/AccessController.java
index 97383f54a46..8a8eadea62d 100644
--- a/jdk/src/share/classes/java/security/AccessController.java
+++ b/jdk/src/share/classes/java/security/AccessController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -293,7 +293,7 @@ public final class AccessController {
DomainCombiner dc = null;
AccessControlContext acc = getStackAccessControlContext();
if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
- return AccessController.doPrivileged(action);
+ return AccessController.doPrivileged(action, acc);
}
return AccessController.doPrivileged(action, preserveCombiner(dc));
}
@@ -389,7 +389,7 @@ public final class AccessController {
DomainCombiner dc = null;
AccessControlContext acc = getStackAccessControlContext();
if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
- return AccessController.doPrivileged(action);
+ return AccessController.doPrivileged(action, acc);
}
return AccessController.doPrivileged(action, preserveCombiner(dc));
}
From 63cf10e50057789d99c83d231c14cb3005c663ad Mon Sep 17 00:00:00 2001
From: Stuart Marks
Date: Thu, 21 Jun 2012 00:20:49 -0700
Subject: [PATCH 05/56] 7093490: adjust package access in rmiregistry
Reviewed-by: ahgross, coffeys, dmocek
---
jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
index 34579c204de..e086f79c1bf 100644
--- a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
+++ b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
@@ -405,7 +405,8 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
*/
perms.add(new SocketPermission("*", "connect,accept"));
- perms.add(new RuntimePermission("accessClassInPackage.sun.*"));
+ perms.add(new RuntimePermission("accessClassInPackage.sun.jvmstat.*"));
+ perms.add(new RuntimePermission("accessClassInPackage.sun.jvm.hotspot.*"));
perms.add(new FilePermission("<>", "read"));
From 9a307c8287e7cc0594d41bf877ef6263a0ec1b4c Mon Sep 17 00:00:00 2001
From: Dmitry Samersoff
Date: Fri, 22 Jun 2012 16:22:22 +0400
Subject: [PATCH 06/56] 7158796: Tighten properties checking in EnvHelp
Move getProperty call out of computeBooleanFromString
Reviewed-by: skoivu, sla
---
.../remote/internal/ServerNotifForwarder.java | 6 +-
.../com/sun/jmx/remote/util/EnvHelp.java | 76 +++++--------------
.../management/remote/rmi/RMIConnector.java | 6 +-
.../remote/rmi/RMIConnectorServer.java | 5 +-
4 files changed, 26 insertions(+), 67 deletions(-)
diff --git a/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java b/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
index ba071411608..58ccfb45280 100644
--- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
+++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
@@ -68,9 +68,9 @@ public class ServerNotifForwarder {
this.notifBuffer = notifBuffer;
this.connectionId = connectionId;
connectionTimeout = EnvHelp.getServerConnectionTimeout(env);
- checkNotificationEmission = EnvHelp.computeBooleanFromString(
- env,
- "jmx.remote.x.check.notification.emission",false);
+
+ String stringBoolean = (String) env.get("jmx.remote.x.check.notification.emission");
+ checkNotificationEmission = EnvHelp.computeBooleanFromString( stringBoolean );
notificationAccessController =
EnvHelp.getNotificationAccessController(env);
}
diff --git a/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java b/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java
index e61d9d09d60..b8bf9d37a0f 100644
--- a/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java
+++ b/jdk/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java
@@ -665,97 +665,57 @@ public class EnvHelp {
* Computes a boolean value from a string value retrieved from a
* property in the given map.
*
- * @param env the environment map.
- * @param prop the name of the property in the environment map whose
- * returned string value must be converted into a boolean value.
- * @param systemProperty if true, consult a system property of the
- * same name if there is no entry in the environment map.
+ * @param stringBoolean the string value that must be converted
+ * into a boolean value.
*
* @return
*
- *
{@code false} if {@code env.get(prop)} is {@code null}
+ *
{@code false} if {@code stringBoolean} is {@code null}
*
{@code false} if
- * {@code ((String)env.get(prop)).equalsIgnoreCase("false")}
+ * {@code stringBoolean.equalsIgnoreCase("false")}
* is {@code true}
*
{@code true} if
- * {@code ((String)env.get(prop)).equalsIgnoreCase("true")}
+ * {@code stringBoolean.equalsIgnoreCase("true")}
* is {@code true}
*
*
- * @throws IllegalArgumentException if {@code env} is {@code null} or
- * {@code env.get(prop)} is not {@code null} and
+ * @throws IllegalArgumentException if
* {@code ((String)env.get(prop)).equalsIgnoreCase("false")} and
* {@code ((String)env.get(prop)).equalsIgnoreCase("true")} are
* {@code false}.
- * @throws ClassCastException if {@code env.get(prop)} cannot be cast
- * to {@code String}.
*/
- public static boolean computeBooleanFromString(
- Map env, String prop, boolean systemProperty) {
-
- if (env == null)
- throw new IllegalArgumentException("env map cannot be null");
-
+ public static boolean computeBooleanFromString(String stringBoolean) {
// returns a default value of 'false' if no property is found...
- return computeBooleanFromString(env,prop,systemProperty,false);
+ return computeBooleanFromString(stringBoolean,false);
}
/**
* Computes a boolean value from a string value retrieved from a
* property in the given map.
*
- * @param env the environment map.
- * @param prop the name of the property in the environment map whose
- * returned string value must be converted into a boolean value.
- * @param systemProperty if true, consult a system property of the
- * same name if there is no entry in the environment map.
+ * @param stringBoolean the string value that must be converted
+ * into a boolean value.
* @param defaultValue a default value to return in case no property
* was defined.
*
* @return
*
- *
{@code defaultValue} if {@code env.get(prop)} is {@code null}
- * and {@code systemProperty} is {@code false}
- *
{@code defaultValue} if {@code env.get(prop)} is {@code null}
- * and {@code systemProperty} is {@code true} and
- * {@code System.getProperty(prop)} is {@code null}
- *
{@code false} if {@code env.get(prop)} is {@code null}
- * and {@code systemProperty} is {@code true} and
- * {@code System.getProperty(prop).equalsIgnoreCase("false")}
- * is {@code true}
- *
{@code true} if {@code env.get(prop)} is {@code null}
- * and {@code systemProperty} is {@code true} and
- * {@code System.getProperty(prop).equalsIgnoreCase("true")}
- * is {@code true}
+ *
{@code defaultValue} if {@code stringBoolean}
+ * is {@code null}
*
{@code false} if
- * {@code ((String)env.get(prop)).equalsIgnoreCase("false")}
+ * {@code stringBoolean.equalsIgnoreCase("false")}
* is {@code true}
*
{@code true} if
- * {@code ((String)env.get(prop)).equalsIgnoreCase("true")}
+ * {@code stringBoolean.equalsIgnoreCase("true")}
* is {@code true}
*
*
- * @throws IllegalArgumentException if {@code env} is {@code null} or
- * {@code env.get(prop)} is not {@code null} and
+ * @throws IllegalArgumentException if
* {@code ((String)env.get(prop)).equalsIgnoreCase("false")} and
* {@code ((String)env.get(prop)).equalsIgnoreCase("true")} are
* {@code false}.
- * @throws ClassCastException if {@code env.get(prop)} cannot be cast
- * to {@code String}.
*/
- public static boolean computeBooleanFromString(
- Map env, String prop,
- boolean systemProperty, boolean defaultValue) {
-
- if (env == null)
- throw new IllegalArgumentException("env map cannot be null");
-
- String stringBoolean = (String) env.get(prop);
- if (stringBoolean == null && systemProperty) {
- stringBoolean =
- AccessController.doPrivileged(new GetPropertyAction(prop));
- }
-
+ public static boolean computeBooleanFromString( String stringBoolean, boolean defaultValue) {
if (stringBoolean == null)
return defaultValue;
else if (stringBoolean.equalsIgnoreCase("true"))
@@ -763,8 +723,8 @@ public class EnvHelp {
else if (stringBoolean.equalsIgnoreCase("false"))
return false;
else
- throw new IllegalArgumentException(prop +
- " must be \"true\" or \"false\" instead of \"" +
+ throw new IllegalArgumentException(
+ "Property value must be \"true\" or \"false\" instead of \"" +
stringBoolean + "\"");
}
diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
index f5359f9b12c..f6d17d6cc08 100644
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
@@ -277,9 +277,9 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
// Check for secure RMIServer stub if the corresponding
// client-side environment property is set to "true".
//
- boolean checkStub = EnvHelp.computeBooleanFromString(
- usemap,
- "jmx.remote.x.check.stub",false);
+ String stringBoolean = (String) usemap.get("jmx.remote.x.check.stub");
+ boolean checkStub = EnvHelp.computeBooleanFromString(stringBoolean);
+
if (checkStub) checkStub(stub, rmiServerImplStubClass);
// Connect IIOP Stub if needed.
diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
index 909b9cb0d47..da92f49f70b 100644
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
@@ -412,9 +412,8 @@ public class RMIConnectorServer extends JMXConnectorServer {
if (tracing)
logger.trace("start", "Using external directory: " + jndiUrl);
- final boolean rebind = EnvHelp.computeBooleanFromString(
- attributes,
- JNDI_REBIND_ATTRIBUTE,false);
+ String stringBoolean = (String) attributes.get(JNDI_REBIND_ATTRIBUTE);
+ final boolean rebind = EnvHelp.computeBooleanFromString( stringBoolean );
if (tracing)
logger.trace("start", JNDI_REBIND_ATTRIBUTE + "=" + rebind);
From 5e84600efcf5392e04e12a6b56aa4104c241022d Mon Sep 17 00:00:00 2001
From: Dmitry Samersoff
Date: Fri, 22 Jun 2012 18:19:48 +0400
Subject: [PATCH 07/56] 7169888: Narrowing resource definitions in JMX RMI
connector
CPU bug, we can't put offending calls outside doPrivileged, but narrow granted permissions.
Reviewed-by: ahgross, fparain
---
.../remote/rmi/RMIConnectionImpl.java | 89 ++++++++++---------
1 file changed, 48 insertions(+), 41 deletions(-)
diff --git a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
index f322af0f2bc..9449210e897 100644
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
@@ -25,6 +25,30 @@
package javax.management.remote.rmi;
+import java.io.IOException;
+import java.rmi.MarshalledObject;
+import java.rmi.UnmarshalException;
+import java.rmi.server.Unreferenced;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.*;
+import javax.management.remote.JMXServerErrorException;
+import javax.management.remote.NotificationResult;
+import javax.management.remote.TargetedNotification;
+import javax.security.auth.Subject;
+
import static com.sun.jmx.mbeanserver.Util.cast;
import com.sun.jmx.remote.internal.ServerCommunicatorAdmin;
import com.sun.jmx.remote.internal.ServerNotifForwarder;
@@ -35,44 +59,6 @@ import com.sun.jmx.remote.util.ClassLogger;
import com.sun.jmx.remote.util.EnvHelp;
import com.sun.jmx.remote.util.OrderClassLoaders;
-import java.io.IOException;
-import java.rmi.MarshalledObject;
-import java.rmi.UnmarshalException;
-import java.rmi.server.Unreferenced;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import javax.management.remote.JMXServerErrorException;
-import javax.management.remote.NotificationResult;
-import javax.management.remote.TargetedNotification;
-import javax.security.auth.Subject;
-
/**
*
Implementation of the {@link RMIConnection} interface. User
* code will not usually reference this class.
@@ -143,6 +129,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
this.mbeanServer = rmiServer.getMBeanServer();
final ClassLoader dcl = defaultClassLoader;
+
this.classLoaderWithRepository =
AccessController.doPrivileged(
new PrivilegedAction() {
@@ -151,13 +138,29 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
mbeanServer.getClassLoaderRepository(),
dcl);
}
- });
+ },
+
+ withPermissions( new MBeanPermission("*", "getClassLoaderRepository"),
+ new RuntimePermission("createClassLoader"))
+ );
+
serverCommunicatorAdmin = new
RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));
this.env = env;
}
+ private static AccessControlContext withPermissions(Permission ... perms){
+ Permissions col = new Permissions();
+
+ for (Permission thePerm : perms ) {
+ col.add(thePerm);
+ }
+
+ final ProtectionDomain pd = new ProtectionDomain(null, col);
+ return new AccessControlContext( new ProtectionDomain[] { pd });
+ }
+
private synchronized ServerNotifForwarder getServerNotifFwd() {
// Lazily created when first use. Mainly when
// addNotificationListener is first called.
@@ -1330,7 +1333,9 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
public ClassLoader run() throws InstanceNotFoundException {
return mbeanServer.getClassLoader(name);
}
- });
+ },
+ withPermissions(new MBeanPermission("*", "getClassLoader"))
+ );
} catch (PrivilegedActionException pe) {
throw (InstanceNotFoundException) extractException(pe);
}
@@ -1345,7 +1350,9 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced {
public Object run() throws InstanceNotFoundException {
return mbeanServer.getClassLoaderFor(name);
}
- });
+ },
+ withPermissions(new MBeanPermission("*", "getClassLoaderFor"))
+ );
} catch (PrivilegedActionException pe) {
throw (InstanceNotFoundException) extractException(pe);
}
From 1c29d4299bf222478eb9fb59540a8f631c5aaa7d Mon Sep 17 00:00:00 2001
From: Xue-Lei Andrew Fan
Date: Sat, 28 Jul 2012 19:42:50 -0700
Subject: [PATCH 08/56] 7186286: TLS implementation to better adhere to RFC
Also reviewed by Alexander Fomin , Andrew Gross, Sean Coffey
Reviewed-by: valeriep, wetmore
---
.../sun/security/ssl/HandshakeInStream.java | 13 ++++-
.../classes/sun/security/ssl/Handshaker.java | 4 +-
.../security/ssl/RSAClientKeyExchange.java | 56 ++++++++++++-------
3 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java b/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java
index f6ca477efe2..81c84643f14 100644
--- a/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java
+++ b/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -190,6 +190,7 @@ public class HandshakeInStream extends InputStream {
byte[] getBytes8() throws IOException {
int len = getInt8();
+ verifyLength(len);
byte b[] = new byte[len];
read(b, 0, len);
@@ -198,6 +199,7 @@ public class HandshakeInStream extends InputStream {
public byte[] getBytes16() throws IOException {
int len = getInt16();
+ verifyLength(len);
byte b[] = new byte[len];
read(b, 0, len);
@@ -206,10 +208,19 @@ public class HandshakeInStream extends InputStream {
byte[] getBytes24() throws IOException {
int len = getInt24();
+ verifyLength(len);
byte b[] = new byte[len];
read(b, 0, len);
return b;
}
+ // Is a length greater than available bytes in the record?
+ private void verifyLength(int len) throws SSLException {
+ if (len > available()) {
+ throw new SSLException(
+ "Not enough data to fill declared vector size");
+ }
+ }
+
}
diff --git a/jdk/src/share/classes/sun/security/ssl/Handshaker.java b/jdk/src/share/classes/sun/security/ssl/Handshaker.java
index 4fb7fec7d61..38dd491f99f 100644
--- a/jdk/src/share/classes/sun/security/ssl/Handshaker.java
+++ b/jdk/src/share/classes/sun/security/ssl/Handshaker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1063,7 +1063,6 @@ abstract class Handshaker {
if (debug != null && Debug.isOn("handshake")) {
System.out.println("RSA master secret generation error:");
e.printStackTrace(System.out);
- System.out.println("Generating new random premaster secret");
}
if (requestedVersion != null) {
@@ -1130,7 +1129,6 @@ abstract class Handshaker {
System.out.println("RSA PreMasterSecret version error: expected"
+ protocolVersion + " or " + requestedVersion + ", decrypted: "
+ premasterVersion);
- System.out.println("Generating new random premaster secret");
}
preMasterSecret =
RSAClientKeyExchange.generateDummySecret(requestedVersion);
diff --git a/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java b/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java
index 1c0d6921091..36fda8c39cb 100644
--- a/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java
+++ b/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@ import javax.crypto.spec.*;
import javax.net.ssl.*;
import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
+import sun.security.util.KeyLength;
/**
* This is the client key exchange message (CLIENT --> SERVER) used with
@@ -192,26 +193,38 @@ final class RSAClientKeyExchange extends HandshakeMessage {
"unable to get the plaintext of the premaster secret");
}
- // We are not always able to get the encoded key of the
- // premaster secret. Pass the cheking to master secret
+ int keySize = KeyLength.getKeySize(secretKey);
+ if (keySize > 0 && keySize != 384) { // 384 = 48 * 8
+ if (debug != null && Debug.isOn("handshake")) {
+ System.out.println(
+ "incorrect length of premaster secret: " +
+ (keySize/8));
+ }
+
+ return generateDummySecret(clientHelloVersion);
+ }
+
+ // The key size is exactly 48 bytes or not accessible.
+ //
+ // Conservatively, pass the checking to master secret
// calculation.
return secretKey;
} else if (encoded.length == 48) {
// check the version
if (clientHelloVersion.major == encoded[0] &&
clientHelloVersion.minor == encoded[1]) {
+
return secretKey;
- } else if (clientHelloVersion.v <= ProtocolVersion.TLS10.v) {
+ } else if (clientHelloVersion.v <= ProtocolVersion.TLS10.v &&
+ currentVersion.major == encoded[0] &&
+ currentVersion.minor == encoded[1]) {
/*
- * we never checked the client_version in server side
- * for TLS v1.0 and SSL v3.0. For compatibility, we
- * maintain this behavior.
+ * For compatibility, we maintain the behavior that the
+ * version in pre_master_secret can be the negotiated
+ * version for TLS v1.0 and SSL v3.0.
*/
- if (currentVersion.major == encoded[0] &&
- currentVersion.minor == encoded[1]) {
- this.protocolVersion = currentVersion;
- return secretKey;
- }
+ this.protocolVersion = currentVersion;
+ return secretKey;
}
if (debug != null && Debug.isOn("handshake")) {
@@ -220,22 +233,23 @@ final class RSAClientKeyExchange extends HandshakeMessage {
", while PreMasterSecret.client_version is " +
ProtocolVersion.valueOf(encoded[0], encoded[1]));
}
+
+ return generateDummySecret(clientHelloVersion);
} else {
if (debug != null && Debug.isOn("handshake")) {
System.out.println(
"incorrect length of premaster secret: " +
encoded.length);
}
+
+ return generateDummySecret(clientHelloVersion);
}
}
- if (debug != null && Debug.isOn("handshake")) {
- if (failoverException != null) {
- System.out.println("Error decrypting premaster secret:");
- failoverException.printStackTrace(System.out);
- }
-
- System.out.println("Generating random secret");
+ if (debug != null && Debug.isOn("handshake") &&
+ failoverException != null) {
+ System.out.println("Error decrypting premaster secret:");
+ failoverException.printStackTrace(System.out);
}
return generateDummySecret(clientHelloVersion);
@@ -243,6 +257,10 @@ final class RSAClientKeyExchange extends HandshakeMessage {
// generate a premaster secret with the specified version number
static SecretKey generateDummySecret(ProtocolVersion version) {
+ if (debug != null && Debug.isOn("handshake")) {
+ System.out.println("Generating a random fake premaster secret");
+ }
+
try {
String s = ((version.v >= ProtocolVersion.TLS12.v) ?
"SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
From e5fbf0148998595f148f340e8f663afa5a99eefa Mon Sep 17 00:00:00 2001
From: Sean Mullan
Date: Wed, 15 Aug 2012 15:31:30 -0400
Subject: [PATCH 09/56] 7189490: More improvements to DomainCombiner checking
Reviewed-by: ahgross, jdn, vinnie
---
.../java/security/AccessController.java | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/jdk/src/share/classes/java/security/AccessController.java b/jdk/src/share/classes/java/security/AccessController.java
index 8a8eadea62d..4e790ffc8da 100644
--- a/jdk/src/share/classes/java/security/AccessController.java
+++ b/jdk/src/share/classes/java/security/AccessController.java
@@ -290,11 +290,11 @@ public final class AccessController {
*/
public static T doPrivilegedWithCombiner(PrivilegedAction action) {
- DomainCombiner dc = null;
AccessControlContext acc = getStackAccessControlContext();
- if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
- return AccessController.doPrivileged(action, acc);
+ if (acc == null) {
+ return AccessController.doPrivileged(action);
}
+ DomainCombiner dc = acc.getAssignedCombiner();
return AccessController.doPrivileged(action, preserveCombiner(dc));
}
@@ -386,11 +386,11 @@ public final class AccessController {
public static T doPrivilegedWithCombiner
(PrivilegedExceptionAction action) throws PrivilegedActionException {
- DomainCombiner dc = null;
AccessControlContext acc = getStackAccessControlContext();
- if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
- return AccessController.doPrivileged(action, acc);
+ if (acc == null) {
+ return AccessController.doPrivileged(action);
}
+ DomainCombiner dc = acc.getAssignedCombiner();
return AccessController.doPrivileged(action, preserveCombiner(dc));
}
@@ -417,7 +417,12 @@ public final class AccessController {
// perform 'combine' on the caller of doPrivileged,
// even if the caller is from the bootclasspath
ProtectionDomain[] pds = new ProtectionDomain[] {callerPd};
- return new AccessControlContext(combiner.combine(pds, null), combiner);
+ if (combiner == null) {
+ return new AccessControlContext(pds);
+ } else {
+ return new AccessControlContext(combiner.combine(pds, null),
+ combiner);
+ }
}
From 9f27d2af4c0366b2ae376c510b28a80c17ac90ee Mon Sep 17 00:00:00 2001
From: Chris Hegarty
Date: Thu, 16 Aug 2012 15:02:34 +0100
Subject: [PATCH 10/56] 7189103: Executors needs to maintain state
Reviewed-by: dholmes, hawtin
---
.../java/util/concurrent/Executors.java | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/jdk/src/share/classes/java/util/concurrent/Executors.java b/jdk/src/share/classes/java/util/concurrent/Executors.java
index 4ff71418422..78708f8d773 100644
--- a/jdk/src/share/classes/java/util/concurrent/Executors.java
+++ b/jdk/src/share/classes/java/util/concurrent/Executors.java
@@ -530,18 +530,17 @@ public class Executors {
return AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public T run() throws Exception {
- ClassLoader savedcl = null;
Thread t = Thread.currentThread();
- try {
- ClassLoader cl = t.getContextClassLoader();
- if (ccl != cl) {
- t.setContextClassLoader(ccl);
- savedcl = cl;
- }
+ ClassLoader cl = t.getContextClassLoader();
+ if (ccl == cl) {
return task.call();
- } finally {
- if (savedcl != null)
- t.setContextClassLoader(savedcl);
+ } else {
+ t.setContextClassLoader(ccl);
+ try {
+ return task.call();
+ } finally {
+ t.setContextClassLoader(cl);
+ }
}
}
}, acc);
From 6b158b4089e2baccdbc8c2c90b28b6440c2fa76a Mon Sep 17 00:00:00 2001
From: Harold Seigel
Date: Wed, 10 Oct 2012 17:04:33 -0400
Subject: [PATCH 11/56] 7199068: NPG: SharedSkipVerify is meaningless
Remove the SharedSkipVerify flag
Reviewed-by: kamg, sspitsyn, coleenp
---
hotspot/src/share/vm/classfile/javaClasses.cpp | 3 +--
hotspot/src/share/vm/memory/universe.cpp | 4 ----
hotspot/src/share/vm/oops/klass.cpp | 7 +++----
hotspot/src/share/vm/runtime/globals.hpp | 4 ----
hotspot/src/share/vm/runtime/handles.cpp | 2 +-
hotspot/src/share/vm/runtime/handles.hpp | 8 ++++----
6 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp
index 7e8c39cdd3b..d74a6174a99 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp
@@ -413,8 +413,7 @@ char* java_lang_String::as_utf8_string(oop java_string, int start, int len) {
}
bool java_lang_String::equals(oop java_string, jchar* chars, int len) {
- assert(SharedSkipVerify ||
- java_string->klass() == SystemDictionary::String_klass(),
+ assert(java_string->klass() == SystemDictionary::String_klass(),
"must be java_string");
typeArrayOop value = java_lang_String::value(java_string);
int offset = java_lang_String::offset(java_string);
diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp
index f8e733bb49b..8fe747939af 100644
--- a/hotspot/src/share/vm/memory/universe.cpp
+++ b/hotspot/src/share/vm/memory/universe.cpp
@@ -1243,10 +1243,6 @@ void Universe::print_heap_after_gc(outputStream* st, bool ignore_extended) {
}
void Universe::verify(bool silent, VerifyOption option) {
- if (SharedSkipVerify) {
- return;
- }
-
// The use of _verify_in_progress is a temporary work around for
// 6320749. Don't bother with a creating a class to set and clear
// it since it is only used in this method and the control flow is
diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp
index 94546f0d71a..06a99aff6b0 100644
--- a/hotspot/src/share/vm/oops/klass.cpp
+++ b/hotspot/src/share/vm/oops/klass.cpp
@@ -356,12 +356,11 @@ void Klass::set_next_sibling(Klass* s) {
}
void Klass::append_to_sibling_list() {
- debug_only(if (!SharedSkipVerify) verify();)
+ debug_only(verify();)
// add ourselves to superklass' subklass list
InstanceKlass* super = superklass();
if (super == NULL) return; // special case: class Object
- assert(SharedSkipVerify ||
- (!super->is_interface() // interfaces cannot be supers
+ assert((!super->is_interface() // interfaces cannot be supers
&& (super->superklass() == NULL || !is_interface())),
"an interface can only be a subklass of Object");
Klass* prev_first_subklass = super->subklass_oop();
@@ -371,7 +370,7 @@ void Klass::append_to_sibling_list() {
}
// make ourselves the superklass' first subklass
super->set_subklass(this);
- debug_only(if (!SharedSkipVerify) verify();)
+ debug_only(verify();)
}
void Klass::remove_from_sibling_list() {
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index 0bef41fadab..cdefd82e4f5 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -3542,10 +3542,6 @@ class CommandLineFlags {
product(uintx, SharedDummyBlockSize, 0, \
"Size of dummy block used to shift heap addresses (in bytes)") \
\
- diagnostic(bool, SharedSkipVerify, false, \
- "Skip assert() and verify() which page-in unwanted shared " \
- "objects. ") \
- \
diagnostic(bool, EnableInvokeDynamic, true, \
"support JSR 292 (method handles, invokedynamic, " \
"anonymous classes") \
diff --git a/hotspot/src/share/vm/runtime/handles.cpp b/hotspot/src/share/vm/runtime/handles.cpp
index 0ba6c984ef8..cb53088ee69 100644
--- a/hotspot/src/share/vm/runtime/handles.cpp
+++ b/hotspot/src/share/vm/runtime/handles.cpp
@@ -48,7 +48,7 @@
oop* HandleArea::allocate_handle(oop obj) {
assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark");
assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark");
- assert(SharedSkipVerify || obj->is_oop(), "sanity check");
+ assert(obj->is_oop(), "sanity check");
return real_allocate_handle(obj);
}
diff --git a/hotspot/src/share/vm/runtime/handles.hpp b/hotspot/src/share/vm/runtime/handles.hpp
index 4a2e9ff8252..cab3dc581f9 100644
--- a/hotspot/src/share/vm/runtime/handles.hpp
+++ b/hotspot/src/share/vm/runtime/handles.hpp
@@ -110,11 +110,11 @@ class Handle VALUE_OBJ_CLASS_SPEC {
/* Constructors */ \
type##Handle () : Handle() {} \
type##Handle (type##Oop obj) : Handle((oop)obj) { \
- assert(SharedSkipVerify || is_null() || ((oop)obj)->is_a(), \
+ assert(is_null() || ((oop)obj)->is_a(), \
"illegal type"); \
} \
type##Handle (Thread* thread, type##Oop obj) : Handle(thread, (oop)obj) { \
- assert(SharedSkipVerify || is_null() || ((oop)obj)->is_a(), "illegal type"); \
+ assert(is_null() || ((oop)obj)->is_a(), "illegal type"); \
} \
\
/* Operators for ease of use */ \
@@ -201,11 +201,11 @@ class instanceKlassHandle : public KlassHandle {
/* Constructors */
instanceKlassHandle () : KlassHandle() {}
instanceKlassHandle (const Klass* k) : KlassHandle(k) {
- assert(SharedSkipVerify || k == NULL || k->oop_is_instance(),
+ assert(k == NULL || k->oop_is_instance(),
"illegal type");
}
instanceKlassHandle (Thread* thread, const Klass* k) : KlassHandle(thread, k) {
- assert(SharedSkipVerify || k == NULL || k->oop_is_instance(),
+ assert(k == NULL || k->oop_is_instance(),
"illegal type");
}
/* Access to klass part */
From 04a9a141937e4781ba1ebd793d69e94296097b81 Mon Sep 17 00:00:00 2001
From: Keith McGuigan
Date: Thu, 11 Oct 2012 14:27:54 -0400
Subject: [PATCH 12/56] 7054345: Support version 52.0 class file in HotSpot
Accept classfiles with major version 52
Reviewed-by: coleenp, acorn
---
hotspot/src/share/vm/classfile/classFileParser.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp
index 5d260d56492..c9a2c44d002 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp
@@ -67,7 +67,7 @@
#define JAVA_CLASSFILE_MAGIC 0xCAFEBABE
#define JAVA_MIN_SUPPORTED_VERSION 45
-#define JAVA_MAX_SUPPORTED_VERSION 51
+#define JAVA_MAX_SUPPORTED_VERSION 52
#define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
// Used for two backward compatibility reasons:
From b296b69382c85f74286499dc941fb18b5c53fb03 Mon Sep 17 00:00:00 2001
From: Kevin Walls
Date: Mon, 15 Oct 2012 16:48:48 +0100
Subject: [PATCH 13/56] 7195151: Multiplatform tescase for 6929067
Reviewed-by: kamg, kvn
---
hotspot/test/runtime/6929067/Test6929067.sh | 89 ++++++++++++++++++---
1 file changed, 78 insertions(+), 11 deletions(-)
diff --git a/hotspot/test/runtime/6929067/Test6929067.sh b/hotspot/test/runtime/6929067/Test6929067.sh
index c08aa6b8f09..e4b649df82b 100644
--- a/hotspot/test/runtime/6929067/Test6929067.sh
+++ b/hotspot/test/runtime/6929067/Test6929067.sh
@@ -4,6 +4,7 @@
## @test Test6929067.sh
## @bug 6929067
## @summary Stack guard pages should be removed when thread is detached
+## @compile T.java
## @run shell Test6929067.sh
##
@@ -33,31 +34,97 @@ case "$OS" in
;;
esac
-# Choose arch: i386 or amd64 (test is Linux-specific)
+${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1
+
+# Bitness:
# Cannot simply look at TESTVMOPTS as -d64 is not
# passed if there is only a 64-bit JVM available.
-${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>1 | grep "64-Bit" >/dev/null
+grep "64-Bit" vm_version.out > ${NULL}
if [ "$?" = "0" ]
then
- ARCH=amd64
+ COMP_FLAG="-m64"
else
- ARCH=i386
+ COMP_FLAG="-m32"
fi
-LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/client:/usr/openwin/lib:/usr/dt/lib:/usr/lib:$LD_LIBRARY_PATH
+
+# Architecture:
+# Translate uname output to JVM directory name, but permit testing
+# 32-bit x86 on an x64 platform.
+ARCH=`uname -m`
+case "$ARCH" in
+ x86_64)
+ if [ "$COMP_FLAG" = "-m32" ]; then
+ ARCH=i386
+ else
+ ARCH=amd64
+ fi
+ ;;
+ ppc64)
+ if [ "$COMP_FLAG" = "-m32" ]; then
+ ARCH=ppc
+ else
+ ARCH=ppc64
+ fi
+ ;;
+ sparc64)
+ if [ "$COMP_FLAG" = "-m32" ]; then
+ ARCH=sparc
+ else
+ ARCH=sparc64
+ fi
+ ;;
+ arm*)
+ # 32-bit ARM machine: compiler may not recognise -m32
+ COMP_FLAG=""
+ ARCH=arm
+ ;;
+ aarch64)
+ # 64-bit arm machine, could be testing 32 or 64-bit:
+ if [ "$COMP_FLAG" = "-m32" ]; then
+ ARCH=arm
+ else
+ ARCH=aarch64
+ fi
+ ;;
+ i586)
+ ARCH=i386
+ ;;
+ i686)
+ ARCH=i386
+ ;;
+ # Assuming other ARCH values need no translation
+esac
+
+
+# VM type: need to know server or client
+VMTYPE=client
+grep Server vm_version.out > ${NULL}
+if [ "$?" = "0" ]
+then
+ VMTYPE=server
+fi
+
+
+LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
-THIS_DIR=`pwd`
-
-cp ${TESTSRC}${FS}invoke.c ${THIS_DIR}
-cp ${TESTSRC}${FS}T.java ${THIS_DIR}
+cp ${TESTSRC}${FS}invoke.c .
+# Copy the result of our @compile action:
+cp ${TESTCLASSES}${FS}T.class .
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -fullversion
-${TESTJAVA}${FS}bin${FS}javac T.java
+echo "Architecture: ${ARCH}"
+echo "Compilation flag: ${COMP_FLAG}"
+echo "VM type: ${VMTYPE}"
+
+gcc -DLINUX ${COMP_FLAG} -o invoke \
+ -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \
+ -L${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE} \
+ -ljvm -lpthread invoke.c
-gcc -o invoke -I${TESTJAVA}/include -I${TESTJAVA}/include/linux invoke.c ${TESTJAVA}/jre/lib/${ARCH}/client/libjvm.so
./invoke
exit $?
From 228b4f6d7f0b8e27a5eddb7e31f0abe16e33c395 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rickard=20B=C3=A4ckman?=
Date: Tue, 28 Aug 2012 15:15:29 +0200
Subject: [PATCH 14/56] 7093328: JVMTI: jvmtiPrimitiveFieldCallback always
report 0's for static primitives
Reviewed-by: dholmes, dcubed
---
hotspot/src/share/vm/prims/jvmtiTagMap.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
index 22871642434..c3e744bd32e 100644
--- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
@@ -1135,7 +1135,7 @@ static jint invoke_primitive_field_callback_for_static_fields
// get offset and field value
int offset = field->field_offset();
- address addr = (address)klass + offset;
+ address addr = (address)klass->java_mirror() + offset;
jvalue value;
copy_to_jvalue(&value, addr, value_type);
From 84603e4d94b7a0504aa1284a341c24a8ab9284f2 Mon Sep 17 00:00:00 2001
From: Chris Hegarty
Date: Wed, 29 Aug 2012 14:05:37 +0100
Subject: [PATCH 15/56] 7189567: java net obselete protocol
Reviewed-by: alanb, ahgross
---
jdk/make/sun/net/FILES_java.gmk | 2 -
.../net/www/protocol/gopher/GopherClient.java | 357 ------------------
.../sun/net/www/protocol/gopher/Handler.java | 100 -----
jdk/test/java/net/URL/Test.java | 4 -
4 files changed, 463 deletions(-)
delete mode 100644 jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java
delete mode 100644 jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java
diff --git a/jdk/make/sun/net/FILES_java.gmk b/jdk/make/sun/net/FILES_java.gmk
index 6c140abc68b..9c5feb4457e 100644
--- a/jdk/make/sun/net/FILES_java.gmk
+++ b/jdk/make/sun/net/FILES_java.gmk
@@ -128,8 +128,6 @@ FILES_java = \
sun/net/www/content/audio/x_wav.java \
sun/net/www/protocol/ftp/Handler.java \
sun/net/www/protocol/ftp/FtpURLConnection.java \
- sun/net/www/protocol/gopher/GopherClient.java \
- sun/net/www/protocol/gopher/Handler.java \
sun/net/www/protocol/mailto/Handler.java \
sun/net/www/protocol/mailto/MailToURLConnection.java \
sun/net/idn/Punycode.java \
diff --git a/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java b/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java
deleted file mode 100644
index 03470634a37..00000000000
--- a/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.net.www.protocol.gopher;
-
-import java.io.*;
-import java.util.*;
-import java.net.*;
-import sun.net.www.*;
-import sun.net.NetworkClient;
-import java.net.URL;
-import java.net.URLStreamHandler;
-
-import sun.security.action.GetBooleanAction;
-
-/** Class to maintain the state of a gopher fetch and handle the protocol */
-public class GopherClient extends NetworkClient implements Runnable {
-
- /* The following three data members are left in for binary
- * backwards-compatibility. Unfortunately, HotJava sets them directly
- * when it wants to change the settings. The new design has us not
- * cache these, so this is unnecessary, but eliminating the data members
- * would break HJB 1.1 under JDK 1.2.
- *
- * These data members are not used, and their values are meaningless.
- * REMIND: Take them out for JDK 2.0!
- */
-
- /**
- * @deprecated
- */
- @Deprecated
- public static boolean useGopherProxy;
-
- /**
- * @deprecated
- */
- @Deprecated
- public static String gopherProxyHost;
-
- /**
- * @deprecated
- */
- @Deprecated
- public static int gopherProxyPort;
-
-
- static {
- useGopherProxy = java.security.AccessController.doPrivileged(
- new sun.security.action.GetBooleanAction("gopherProxySet"))
- .booleanValue();
-
- gopherProxyHost = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("gopherProxyHost"));
-
- gopherProxyPort = java.security.AccessController.doPrivileged(
- new sun.security.action.GetIntegerAction("gopherProxyPort", 80))
- .intValue();
- }
-
- PipedOutputStream os;
- URL u;
- int gtype;
- String gkey;
- sun.net.www.URLConnection connection;
-
- GopherClient(sun.net.www.URLConnection connection) {
- this.connection = connection;
- }
-
- /**
- * @return true if gopher connections should go through a proxy, according
- * to system properties.
- */
- public static boolean getUseGopherProxy() {
- return java.security.AccessController.doPrivileged(
- new GetBooleanAction("gopherProxySet")).booleanValue();
- }
-
- /**
- * @return the proxy host to use, or null if nothing is set.
- */
- public static String getGopherProxyHost() {
- String host = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("gopherProxyHost"));
- if ("".equals(host)) {
- host = null;
- }
- return host;
- }
-
- /**
- * @return the proxy port to use. Will default reasonably.
- */
- public static int getGopherProxyPort() {
- return java.security.AccessController.doPrivileged(
- new sun.security.action.GetIntegerAction("gopherProxyPort", 80))
- .intValue();
- }
-
- /** Given a url, setup to fetch the gopher document it refers to */
- InputStream openStream(URL u) throws IOException {
- this.u = u;
- this.os = os;
- int i = 0;
- String s = u.getFile();
- int limit = s.length();
- int c = '1';
- while (i < limit && (c = s.charAt(i)) == '/')
- i++;
- gtype = c == '/' ? '1' : c;
- if (i < limit)
- i++;
- gkey = s.substring(i);
-
- openServer(u.getHost(), u.getPort() <= 0 ? 70 : u.getPort());
-
- MessageHeader msgh = new MessageHeader();
-
- switch (gtype) {
- case '0':
- case '7':
- msgh.add("content-type", "text/plain");
- break;
- case '1':
- msgh.add("content-type", "text/html");
- break;
- case 'g':
- case 'I':
- msgh.add("content-type", "image/gif");
- break;
- default:
- msgh.add("content-type", "content/unknown");
- break;
- }
- if (gtype != '7') {
- serverOutput.print(decodePercent(gkey) + "\r\n");
- serverOutput.flush();
- } else if ((i = gkey.indexOf('?')) >= 0) {
- serverOutput.print(decodePercent(gkey.substring(0, i) + "\t" +
- gkey.substring(i + 1) + "\r\n"));
- serverOutput.flush();
- msgh.add("content-type", "text/html");
- } else {
- msgh.add("content-type", "text/html");
- }
- connection.setProperties(msgh);
- if (msgh.findValue("content-type") == "text/html") {
- os = new PipedOutputStream();
- PipedInputStream ret = new PipedInputStream();
- ret.connect(os);
- new Thread(this).start();
- return ret;
- }
- return new GopherInputStream(this, serverInput);
- }
-
- /** Translate all the instances of %NN into the character they represent */
- private String decodePercent(String s) {
- if (s == null || s.indexOf('%') < 0)
- return s;
- int limit = s.length();
- char d[] = new char[limit];
- int dp = 0;
- for (int sp = 0; sp < limit; sp++) {
- int c = s.charAt(sp);
- if (c == '%' && sp + 2 < limit) {
- int s1 = s.charAt(sp + 1);
- int s2 = s.charAt(sp + 2);
- if ('0' <= s1 && s1 <= '9')
- s1 = s1 - '0';
- else if ('a' <= s1 && s1 <= 'f')
- s1 = s1 - 'a' + 10;
- else if ('A' <= s1 && s1 <= 'F')
- s1 = s1 - 'A' + 10;
- else
- s1 = -1;
- if ('0' <= s2 && s2 <= '9')
- s2 = s2 - '0';
- else if ('a' <= s2 && s2 <= 'f')
- s2 = s2 - 'a' + 10;
- else if ('A' <= s2 && s2 <= 'F')
- s2 = s2 - 'A' + 10;
- else
- s2 = -1;
- if (s1 >= 0 && s2 >= 0) {
- c = (s1 << 4) | s2;
- sp += 2;
- }
- }
- d[dp++] = (char) c;
- }
- return new String(d, 0, dp);
- }
-
- /** Turn special characters into the %NN form */
- private String encodePercent(String s) {
- if (s == null)
- return s;
- int limit = s.length();
- char d[] = null;
- int dp = 0;
- for (int sp = 0; sp < limit; sp++) {
- int c = s.charAt(sp);
- if (c <= ' ' || c == '"' || c == '%') {
- if (d == null)
- d = s.toCharArray();
- if (dp + 3 >= d.length) {
- char nd[] = new char[dp + 10];
- System.arraycopy(d, 0, nd, 0, dp);
- d = nd;
- }
- d[dp] = '%';
- int dig = (c >> 4) & 0xF;
- d[dp + 1] = (char) (dig < 10 ? '0' + dig : 'A' - 10 + dig);
- dig = c & 0xF;
- d[dp + 2] = (char) (dig < 10 ? '0' + dig : 'A' - 10 + dig);
- dp += 3;
- } else {
- if (d != null) {
- if (dp >= d.length) {
- char nd[] = new char[dp + 10];
- System.arraycopy(d, 0, nd, 0, dp);
- d = nd;
- }
- d[dp] = (char) c;
- }
- dp++;
- }
- }
- return d == null ? s : new String(d, 0, dp);
- }
-
- /** This method is run as a seperate thread when an incoming gopher
- document requires translation to html */
- public void run() {
- int qpos = -1;
- try {
- if (gtype == '7' && (qpos = gkey.indexOf('?')) < 0) {
- PrintStream ps = new PrintStream(os, false, encoding);
- ps.print("Searchable Gopher Index\n
Searchable Gopher Index
\n\n");
- } else if (gtype != '1' && gtype != '7') {
- byte buf[] = new byte[2048];
- try {
- int n;
- while ((n = serverInput.read(buf)) >= 0)
- os.write(buf, 0, n);
- } catch(Exception e) {
- }
- } else {
- PrintStream ps = new PrintStream(os, false, encoding);
- String title = null;
- if (gtype == '7')
- title = "Results of searching for \"" + gkey.substring(qpos + 1)
- + "\" on " + u.getHost();
- else
- title = "Gopher directory " + gkey + " from " + u.getHost();
- ps.print("");
- ps.print(title);
- ps.print("\n\n
");
- ps.print(title);
- ps.print("
\n");
- BufferedReader ds = new BufferedReader(new InputStreamReader(serverInput));
- String s;
- while ((s = ds.readLine()) != null) {
- int len = s.length();
- while (len > 0 && s.charAt(len - 1) <= ' ')
- len--;
- if (len <= 0)
- continue;
- int key = s.charAt(0);
- int t1 = s.indexOf('\t');
- int t2 = t1 > 0 ? s.indexOf('\t', t1 + 1) : -1;
- int t3 = t2 > 0 ? s.indexOf('\t', t2 + 1) : -1;
- if (t3 < 0) {
- // ps.print(" "+s+"\n");
- continue;
- }
- String port = t3 + 1 < len ? ":" + s.substring(t3 + 1, len) : "";
- String host = t2 + 1 < t3 ? s.substring(t2 + 1, t3) : u.getHost();
- ps.print("
\n");
- ps.close();
- }
-
- } catch (UnsupportedEncodingException e) {
- throw new InternalError(encoding+ " encoding not found", e);
- } catch (IOException e) {
- } finally {
- try {
- closeServer();
- os.close();
- } catch (IOException e2) {
- }
- }
- }
-}
-
-/** An input stream that does nothing more than hold on to the NetworkClient
- that created it. This is used when only the input stream is needed, and
- the network client needs to be closed when the input stream is closed. */
-class GopherInputStream extends FilterInputStream {
- NetworkClient parent;
-
- GopherInputStream(NetworkClient o, InputStream fd) {
- super(fd);
- parent = o;
- }
-
- public void close() {
- try {
- parent.closeServer();
- super.close();
- } catch (IOException e) {
- }
- }
-}
diff --git a/jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java b/jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java
deleted file mode 100644
index 800985960a3..00000000000
--- a/jdk/src/share/classes/sun/net/www/protocol/gopher/Handler.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.net.www.protocol.gopher;
-
-import java.io.*;
-import java.util.*;
-import sun.net.NetworkClient;
-import java.net.URL;
-import java.net.URLStreamHandler;
-import java.net.Proxy;
-import java.net.InetSocketAddress;
-import java.net.SocketPermission;
-import java.security.Permission;
-import sun.net.www.protocol.http.HttpURLConnection;
-
-/**
- * A class to handle the gopher protocol.
- */
-
-public class Handler extends java.net.URLStreamHandler {
-
- protected int getDefaultPort() {
- return 70;
- }
-
- public java.net.URLConnection openConnection(URL u)
- throws IOException {
- return openConnection(u, null);
- }
-
- public java.net.URLConnection openConnection(URL u, Proxy p)
- throws IOException {
-
-
- /* if set for proxy usage then go through the http code to get */
- /* the url connection. */
- if (p == null && GopherClient.getUseGopherProxy()) {
- String host = GopherClient.getGopherProxyHost();
- if (host != null) {
- InetSocketAddress saddr = InetSocketAddress.createUnresolved(host, GopherClient.getGopherProxyPort());
-
- p = new Proxy(Proxy.Type.HTTP, saddr);
- }
- }
- if (p != null) {
- return new HttpURLConnection(u, p);
- }
-
- return new GopherURLConnection(u);
- }
-}
-
-class GopherURLConnection extends sun.net.www.URLConnection {
-
- Permission permission;
-
- GopherURLConnection(URL u) {
- super(u);
- }
-
- public void connect() throws IOException {
- }
-
- public InputStream getInputStream() throws IOException {
- return new GopherClient(this).openStream(url);
- }
-
- public Permission getPermission() {
- if (permission == null) {
- int port = url.getPort();
- port = port < 0 ? 70 : port;
- String host = url.getHost() + ":" + url.getPort();
- permission = new SocketPermission(host, "connect");
- }
- return permission;
- }
-}
diff --git a/jdk/test/java/net/URL/Test.java b/jdk/test/java/net/URL/Test.java
index 58c88182723..5a0909efe26 100644
--- a/jdk/test/java/net/URL/Test.java
+++ b/jdk/test/java/net/URL/Test.java
@@ -322,10 +322,6 @@ public class Test {
test("ftp://ftp.is.co.za/rfc/rfc1808.txt")
.s("ftp").h("ftp.is.co.za").p("/rfc/rfc1808.txt").z();
- test("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles")
- .s("gopher").h("spinaltap.micro.umn.edu")
- .p("/00/Weather/California/Los%20Angeles").z();
-
test("http://www.math.uio.no/faq/compression-faq/part1.html")
.s("http").h("www.math.uio.no").p("/faq/compression-faq/part1.html").z();
From c6f43f359973f7ee8826c4ed250f38668e94e5dc Mon Sep 17 00:00:00 2001
From: Alan Bateman
Date: Sat, 8 Sep 2012 20:31:42 +0100
Subject: [PATCH 16/56] 7169884: LogManager checks do not work correctly for
sub-types
Reviewed-by: mchung, ahgross
---
.../java/util/logging/FileHandler.java | 12 +++++-----
.../classes/java/util/logging/Handler.java | 16 ++++++-------
.../classes/java/util/logging/LogManager.java | 23 ++++++++++---------
.../classes/java/util/logging/Logger.java | 16 ++++++-------
.../java/util/logging/MemoryHandler.java | 2 +-
.../java/util/logging/StreamHandler.java | 2 +-
6 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java
index fb3b67c4d92..b9a5d73c341 100644
--- a/jdk/src/share/classes/java/util/logging/FileHandler.java
+++ b/jdk/src/share/classes/java/util/logging/FileHandler.java
@@ -220,7 +220,7 @@ public class FileHandler extends StreamHandler {
* @exception NullPointerException if pattern property is an empty String.
*/
public FileHandler() throws IOException, SecurityException {
- checkAccess();
+ checkPermission();
configure();
openFiles();
}
@@ -246,7 +246,7 @@ public class FileHandler extends StreamHandler {
if (pattern.length() < 1 ) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = 0;
@@ -278,7 +278,7 @@ public class FileHandler extends StreamHandler {
if (pattern.length() < 1 ) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = 0;
@@ -315,7 +315,7 @@ public class FileHandler extends StreamHandler {
if (limit < 0 || count < 1 || pattern.length() < 1) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = limit;
@@ -354,7 +354,7 @@ public class FileHandler extends StreamHandler {
if (limit < 0 || count < 1 || pattern.length() < 1) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = limit;
@@ -367,7 +367,7 @@ public class FileHandler extends StreamHandler {
// configured instance variables.
private void openFiles() throws IOException {
LogManager manager = LogManager.getLogManager();
- manager.checkAccess();
+ manager.checkPermission();
if (count < 1) {
throw new IllegalArgumentException("file count = " + count);
}
diff --git a/jdk/src/share/classes/java/util/logging/Handler.java b/jdk/src/share/classes/java/util/logging/Handler.java
index 1317b572d92..fd04c2cb496 100644
--- a/jdk/src/share/classes/java/util/logging/Handler.java
+++ b/jdk/src/share/classes/java/util/logging/Handler.java
@@ -111,7 +111,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public void setFormatter(Formatter newFormatter) throws SecurityException {
- checkAccess();
+ checkPermission();
// Check for a null pointer:
newFormatter.getClass();
formatter = newFormatter;
@@ -140,7 +140,7 @@ public abstract class Handler {
*/
public void setEncoding(String encoding)
throws SecurityException, java.io.UnsupportedEncodingException {
- checkAccess();
+ checkPermission();
if (encoding != null) {
try {
if(!java.nio.charset.Charset.isSupported(encoding)) {
@@ -175,7 +175,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public void setFilter(Filter newFilter) throws SecurityException {
- checkAccess();
+ checkPermission();
filter = newFilter;
}
@@ -199,7 +199,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public void setErrorManager(ErrorManager em) {
- checkAccess();
+ checkPermission();
if (em == null) {
throw new NullPointerException();
}
@@ -213,7 +213,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public ErrorManager getErrorManager() {
- checkAccess();
+ checkPermission();
return errorManager;
}
@@ -253,7 +253,7 @@ public abstract class Handler {
if (newLevel == null) {
throw new NullPointerException();
}
- checkAccess();
+ checkPermission();
logLevel = newLevel;
}
@@ -296,9 +296,9 @@ public abstract class Handler {
// If "sealed" is true, we check that the caller has
// appropriate security privileges to update Handler
// state and if not throw a SecurityException.
- void checkAccess() throws SecurityException {
+ void checkPermission() throws SecurityException {
if (sealed) {
- manager.checkAccess();
+ manager.checkPermission();
}
}
}
diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java
index 24f61b46f74..bfdf83f93da 100644
--- a/jdk/src/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java
@@ -314,7 +314,7 @@ public class LogManager {
*/
public void addPropertyChangeListener(PropertyChangeListener l) throws SecurityException {
PropertyChangeListener listener = Objects.requireNonNull(l);
- checkAccess();
+ checkPermission();
synchronized (listenerMap) {
// increment the registration count if already registered
Integer value = listenerMap.get(listener);
@@ -338,7 +338,7 @@ public class LogManager {
* the caller does not have LoggingPermission("control").
*/
public void removePropertyChangeListener(PropertyChangeListener l) throws SecurityException {
- checkAccess();
+ checkPermission();
if (l != null) {
PropertyChangeListener listener = l;
synchronized (listenerMap) {
@@ -793,7 +793,7 @@ public class LogManager {
* @exception IOException if there are IO problems reading the configuration.
*/
public void readConfiguration() throws IOException, SecurityException {
- checkAccess();
+ checkPermission();
// if a configuration class is specified, load it and use it.
String cname = System.getProperty("java.util.logging.config.class");
@@ -851,7 +851,7 @@ public class LogManager {
*/
public void reset() throws SecurityException {
- checkAccess();
+ checkPermission();
synchronized (this) {
props = new Properties();
// Since we are doing a reset we no longer want to initialize
@@ -936,7 +936,7 @@ public class LogManager {
* @exception IOException if there are problems reading from the stream.
*/
public void readConfiguration(InputStream ins) throws IOException, SecurityException {
- checkAccess();
+ checkPermission();
reset();
// Load the properties
@@ -1113,8 +1113,13 @@ public class LogManager {
loadLoggerHandlers(rootLogger, null, "handlers");
}
+ private final Permission controlPermission = new LoggingPermission("control", null);
- private Permission ourPermission = new LoggingPermission("control", null);
+ void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(controlPermission);
+ }
/**
* Check that the current context is trusted to modify the logging
@@ -1127,11 +1132,7 @@ public class LogManager {
* the caller does not have LoggingPermission("control").
*/
public void checkAccess() throws SecurityException {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null) {
- return;
- }
- sm.checkPermission(ourPermission);
+ checkPermission();
}
// Nested class to represent a node in our tree of named loggers.
diff --git a/jdk/src/share/classes/java/util/logging/Logger.java b/jdk/src/share/classes/java/util/logging/Logger.java
index aebf63ed5e8..f1d6f729b91 100644
--- a/jdk/src/share/classes/java/util/logging/Logger.java
+++ b/jdk/src/share/classes/java/util/logging/Logger.java
@@ -276,13 +276,13 @@ public class Logger {
this.manager = manager;
}
- private void checkAccess() throws SecurityException {
+ private void checkPermission() throws SecurityException {
if (!anonymous) {
if (manager == null) {
// Complete initialization of the global Logger.
manager = LogManager.getLogManager();
}
- manager.checkAccess();
+ manager.checkPermission();
}
}
@@ -482,7 +482,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setFilter(Filter newFilter) throws SecurityException {
- checkAccess();
+ checkPermission();
filter = newFilter;
}
@@ -1168,7 +1168,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setLevel(Level newLevel) throws SecurityException {
- checkAccess();
+ checkPermission();
synchronized (treeLock) {
levelObject = newLevel;
updateEffectiveLevel();
@@ -1223,7 +1223,7 @@ public class Logger {
public void addHandler(Handler handler) throws SecurityException {
// Check for null handler
handler.getClass();
- checkAccess();
+ checkPermission();
handlers.add(handler);
}
@@ -1237,7 +1237,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void removeHandler(Handler handler) throws SecurityException {
- checkAccess();
+ checkPermission();
if (handler == null) {
return;
}
@@ -1265,7 +1265,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setUseParentHandlers(boolean useParentHandlers) {
- checkAccess();
+ checkPermission();
this.useParentHandlers = useParentHandlers;
}
@@ -1420,7 +1420,7 @@ public class Logger {
if (parent == null) {
throw new NullPointerException();
}
- manager.checkAccess();
+ manager.checkPermission();
doSetParent(parent);
}
diff --git a/jdk/src/share/classes/java/util/logging/MemoryHandler.java b/jdk/src/share/classes/java/util/logging/MemoryHandler.java
index 2c297301d92..06c0930ed5c 100644
--- a/jdk/src/share/classes/java/util/logging/MemoryHandler.java
+++ b/jdk/src/share/classes/java/util/logging/MemoryHandler.java
@@ -238,7 +238,7 @@ public class MemoryHandler extends Handler {
throw new NullPointerException();
}
LogManager manager = LogManager.getLogManager();
- checkAccess();
+ checkPermission();
pushLevel = newLevel;
}
diff --git a/jdk/src/share/classes/java/util/logging/StreamHandler.java b/jdk/src/share/classes/java/util/logging/StreamHandler.java
index 9ed9e57b768..f6407ec2bfd 100644
--- a/jdk/src/share/classes/java/util/logging/StreamHandler.java
+++ b/jdk/src/share/classes/java/util/logging/StreamHandler.java
@@ -249,7 +249,7 @@ public class StreamHandler extends Handler {
}
private synchronized void flushAndClose() throws SecurityException {
- checkAccess();
+ checkPermission();
if (writer != null) {
try {
if (!doneHeader) {
From 7004635879b74a308e9f47af207cc4972d974ccd Mon Sep 17 00:00:00 2001
From: Stuart Marks
Date: Mon, 10 Sep 2012 16:05:53 -0700
Subject: [PATCH 17/56] 7195919: (sl) ServiceLoader can throw CCE without
needing to create instance
Reviewed-by: ahgross, alanb, dmeetry
---
.../share/classes/java/util/ServiceLoader.java | 15 +++++++++++----
jdk/src/share/classes/sun/misc/Service.java | 12 ++++++++++--
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/jdk/src/share/classes/java/util/ServiceLoader.java b/jdk/src/share/classes/java/util/ServiceLoader.java
index 62aa9dd2453..37176c677a9 100644
--- a/jdk/src/share/classes/java/util/ServiceLoader.java
+++ b/jdk/src/share/classes/java/util/ServiceLoader.java
@@ -358,14 +358,21 @@ public final class ServiceLoader
}
String cn = nextName;
nextName = null;
+ Class> c = null;
try {
- S p = service.cast(Class.forName(cn, true, loader)
- .newInstance());
- providers.put(cn, p);
- return p;
+ c = Class.forName(cn, false, loader);
} catch (ClassNotFoundException x) {
fail(service,
"Provider " + cn + " not found");
+ }
+ if (!service.isAssignableFrom(c)) {
+ fail(service,
+ "Provider " + cn + " not a subtype");
+ }
+ try {
+ S p = service.cast(c.newInstance());
+ providers.put(cn, p);
+ return p;
} catch (Throwable x) {
fail(service,
"Provider " + cn + " could not be instantiated: " + x,
diff --git a/jdk/src/share/classes/sun/misc/Service.java b/jdk/src/share/classes/sun/misc/Service.java
index 37d39b43019..d74abbd1cb3 100644
--- a/jdk/src/share/classes/sun/misc/Service.java
+++ b/jdk/src/share/classes/sun/misc/Service.java
@@ -284,12 +284,20 @@ public final class Service {
}
String cn = nextName;
nextName = null;
+ Class> c = null;
try {
- return service.cast(Class.forName(cn, true, loader).newInstance());
+ c = Class.forName(cn, false, loader);
} catch (ClassNotFoundException x) {
fail(service,
"Provider " + cn + " not found");
- } catch (Exception x) {
+ }
+ if (!service.isAssignableFrom(c)) {
+ fail(service,
+ "Provider " + cn + " not a subtype");
+ }
+ try {
+ return service.cast(c.newInstance());
+ } catch (Throwable x) {
fail(service,
"Provider " + cn + " could not be instantiated: " + x,
x);
From e539ff810a49ab7948c7a7194b371849b5afedad Mon Sep 17 00:00:00 2001
From: Sergey Malenkov
Date: Tue, 11 Sep 2012 12:57:09 +0400
Subject: [PATCH 18/56] 7195549: Better bean object persistence
Reviewed-by: art, ahgross
---
.../sun/beans/decoder/PropertyElementHandler.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java b/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java
index f20829385d4..8f4c40cac93 100644
--- a/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java
+++ b/jdk/src/share/classes/com/sun/beans/decoder/PropertyElementHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,8 @@ import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import sun.reflect.misc.MethodUtil;
+
/**
* This class is intended to handle <property> element.
* This element simplifies access to the properties.
@@ -168,11 +170,11 @@ final class PropertyElementHandler extends AccessorElementHandler {
private static Object getPropertyValue(Object bean, String name, Integer index) throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException {
Class> type = bean.getClass();
if (index == null) {
- return findGetter(type, name).invoke(bean);
+ return MethodUtil.invoke(findGetter(type, name), bean, new Object[] {});
} else if (type.isArray() && (name == null)) {
return Array.get(bean, index);
} else {
- return findGetter(type, name, int.class).invoke(bean, index);
+ return MethodUtil.invoke(findGetter(type, name, int.class), bean, new Object[] {index});
}
}
@@ -197,11 +199,11 @@ final class PropertyElementHandler extends AccessorElementHandler {
: null;
if (index == null) {
- findSetter(type, name, param).invoke(bean, value);
+ MethodUtil.invoke(findSetter(type, name, param), bean, new Object[] {value});
} else if (type.isArray() && (name == null)) {
Array.set(bean, index, value);
} else {
- findSetter(type, name, int.class, param).invoke(bean, index, value);
+ MethodUtil.invoke(findSetter(type, name, int.class, param), bean, new Object[] {index, value});
}
}
From 41e85e364f92496350236119d170ae7544ca7518 Mon Sep 17 00:00:00 2001
From: Pavel Porvatov
Date: Tue, 11 Sep 2012 15:59:24 +0400
Subject: [PATCH 19/56] 7195194: Better data validation for Swing
Reviewed-by: art, ahgross
---
jdk/src/share/classes/javax/swing/text/DefaultFormatter.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java
index 5e003b55bca..b67966ab70a 100644
--- a/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java
+++ b/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java
@@ -24,6 +24,8 @@
*/
package javax.swing.text;
+import sun.reflect.misc.ConstructorUtil;
+
import java.io.Serializable;
import java.lang.reflect.*;
import java.text.ParseException;
@@ -245,7 +247,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter
Constructor cons;
try {
- cons = vc.getConstructor(new Class[] { String.class });
+ cons = ConstructorUtil.getConstructor(vc, new Class[]{String.class});
} catch (NoSuchMethodException nsme) {
cons = null;
From 1a3e1b43e0f5a1b16abc8a127dd20680dfa6624c Mon Sep 17 00:00:00 2001
From: Sergey Malenkov
Date: Wed, 19 Sep 2012 21:42:21 +0400
Subject: [PATCH 20/56] 7195917: XMLDecoder parsing at close-time should be
improved
Reviewed-by: art, ahgross
---
.../sun/beans/decoder/DocumentHandler.java | 55 ++++++++++++-------
.../share/classes/java/beans/XMLDecoder.java | 16 +++++-
2 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java b/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java
index f454006ab7e..4bbb8f4a201 100644
--- a/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java
+++ b/jdk/src/share/classes/com/sun/beans/decoder/DocumentHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,9 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
@@ -46,6 +49,8 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+import sun.misc.SharedSecrets;
+
/**
* The main class to parse JavaBeans XML archive.
*
@@ -56,11 +61,10 @@ import org.xml.sax.helpers.DefaultHandler;
* @see ElementHandler
*/
public final class DocumentHandler extends DefaultHandler {
- private final Map> handlers = new HashMap>();
-
- private final Map environment = new HashMap();
-
- private final List
Linux:
XRender header files are required for building the
@@ -1456,7 +1555,9 @@
Devel
make
The GNU version of the 'make' utility built for CYGWIN.
- NOTE: See the GNU make section
+ NOTE: the Cygwin make can not be used to build the
+ OpenJDK. You only need it to build your own version of make
+ (see the GNU make section)
m4.exe
@@ -1521,6 +1622,21 @@
So it's important that the Visual Studio paths in PATH preceed
the CYGWIN path /usr/bin.
+ Minimalist GNU for Windows (MinGW/MSYS)
+
+ Alternatively, the set of unix command tools for the OpenJDK build on
+ Windows can be supplied by
+ MinGW/MSYS.
+
+ In addition to the tools which will be installed by default, you have
+ to manually install the msys-zip and msys-unzip packages.
+ This can be easily done with the MinGW command line installer:
+
+ mingw-get.exe install msys-zip
+ mingw-get.exe install msys-unzip
+
+
- The top-level directory of the libraries and include files for the platform's
- graphical programming environment. The default location is platform specific.
- For example, on Linux it defaults to /usr/X11R6/.
-
+ The top-level directory of the libraries and include files for the platform's
+ graphical programming environment. The default location is platform specific.
+ For example, on Linux it defaults to /usr/X11R6/.
+
Windows specific:
@@ -1792,9 +1908,9 @@
The location of the
Microsoft Windows SDK where some tools will be
- located.
- The default is whatever WINDOWSSDKDIR is set to
- (or WindowsSdkDir) or the path
+ located.
+ The default is whatever WINDOWSSDKDIR is set to
+ (or WindowsSdkDir) or the path
c:\Program Files\Microsoft SDKs\Windows\v7.0a
@@ -1823,17 +1939,17 @@
is that ALT_COMPILER_PATH is set
to point to the cross-compiler and that any cross-compilation specific flags
are passed using EXTRA_CFLAGS.
- The ALT_OPENWIN_HOME variable should
- also be set to point to the graphical header files (e.g. X11) provided with
- the cross-compiler.
+ The ALT_OPENWIN_HOME variable should
+ also be set to point to the graphical header files (e.g. X11) provided with
+ the cross-compiler.
When cross-compiling we skip execution of any demos etc that may be built, and
also skip binary-file verification.
- Used to pass cross-compilation options to the cross-compiler.
+ Used to pass cross-compilation options to the cross-compiler.
These are added to the CFLAGS and CXXFLAGS variables.
-
Used primarily for cross-compilation builds (and always set in that case)
@@ -1868,23 +1984,23 @@
BUILD_HEADLESS_ONLY
Used when the build environment has no graphical capabilities at all. This
- excludes building anything that requires graphical libraries to be available.
+ excludes building anything that requires graphical libraries to be available.
JAVASE_EMBEDDED
- Used to indicate this is a build of the Oracle Java SE Embedded product.
- This will enable the directives included in the SE-Embedded specific build
- files.
+ Used to indicate this is a build of the Oracle Java SE Embedded product.
+ This will enable the directives included in the SE-Embedded specific build
+ files.
- If set to false, disables the use of mmap by the zip utility. Otherwise,
- mmap will be used.
+ If set to false, disables the use of mmap by the zip utility. Otherwise,
+ mmap will be used.
COMPRESS_JARS
- If set to true, causes certain jar files that would otherwise be built without
- compression, to use compression.
+ If set to true, causes certain jar files that would otherwise be built without
+ compression, to use compression.
diff --git a/make/scripts/fixpath.pl b/make/scripts/fixpath.pl
new file mode 100644
index 00000000000..36ec981cdf5
--- /dev/null
+++ b/make/scripts/fixpath.pl
@@ -0,0 +1,169 @@
+#!/bin/perl
+
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# Crunch down the input(s) to Windows short (mangled) form.
+# Any elements not actually found in the filesystem will be dropped.
+#
+# This script needs three modes:
+# 1) DOS mode with drive letter followed by : and ; path separator
+# 2) Cygwin mode with /cygdrive// and : path separator
+# 3) MinGW/MSYS mode with // and : path separator
+
+use strict;
+use warnings;
+use Getopt::Std;
+
+sub Usage() {
+ print ("Usage:\n $0 -d | -c | -m \\n");
+ print (" -d DOS style (drive letter, :, and ; path separator)\n");
+ print (" -c Cywgin style (/cygdrive/drive/ and : path separator)\n");
+ print (" -m MinGW style (/drive/ and : path separator)\n");
+ exit 1;
+}
+# Process command line options:
+my %opts;
+getopts('dcm', \%opts) || Usage();
+
+if (scalar(@ARGV) != 1) {Usage()};
+
+# Translate drive letters such as C:/
+# if MSDOS, Win32::GetShortPathName() does the work (see below).
+# if Cygwin, use the /cygdrive/c/ form.
+# if MinGW, use the /c/ form.
+my $path0;
+my $sep2;
+if (defined ($opts{'d'})) {
+ #MSDOS
+ $path0 = '';
+ $sep2 = ';';
+} elsif (defined ($opts{'c'})) {
+ #Cygwin
+ $path0 = '/cygdrive';
+ $sep2 = ':';
+} elsif (defined ($opts{'m'})) {
+ #MinGW/MSYS
+ $path0 = '';
+ $sep2 = ':';
+} else {
+ Usage();
+}
+
+my $input = $ARGV[0];
+my $sep1;
+
+# Is the input ';' separated, or ':' separated, or a simple string?
+if (($input =~ tr/;/;/) > 0) {
+ # One or more ';' implies Windows style path.
+ $sep1 = ';';
+} elsif (($input =~ tr/:/:/) > 1) {
+ # Two or more ':' implies Cygwin or MinGW/MSYS style path.
+ $sep1 = ':';
+} else {
+ # Otherwise, this is not a path - take up to the end of string in
+ # one piece.
+ $sep1 = '/$/';
+}
+
+# Split the input on $sep1 PATH separator and process the pieces.
+my @pieces;
+for (split($sep1, $input)) {
+ my $try = $_;
+
+ if (($try =~ /^\/cygdrive\/(.)\/(.*)$/) || ($try =~ /^\/(.)\/(.*)$/)) {
+ # Special case #1: This is a Cygwin /cygrive/ 1)) {
+ $result = join ($sep2, @pieces);
+} else {
+ $result = $pieces[0];
+}
+
+if (defined ($result)) {
+
+ # Change all '\' to '/'
+ $result =~ s/\\/\//g;
+
+ # Remove duplicate '/'
+ $result =~ s/\/\//\//g;
+
+ # Map to lower case
+ $result =~ tr/A-Z/a-z/;
+
+ print ("$result\n");
+}
diff --git a/make/scripts/vsvars.sh b/make/scripts/vsvars.sh
index 369a04a9ec3..928777cb54f 100644
--- a/make/scripts/vsvars.sh
+++ b/make/scripts/vsvars.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,22 +27,6 @@
# variables normally set by the vcvars32.bat or vcvars64.bat file or
# SetEnv.cmd for older SDKs.
-# Use cygpath?
-isCygwin="`uname -s | grep CYGWIN`"
-if [ "${isCygwin}" != "" ] ; then
- cygpath="/usr/bin/cygpath"
- cygpath_short="${cygpath} -m -s"
- cygpath_windows="${cygpath} -w -s"
- cygpath_path="${cygpath} -p"
- pathsep=':'
-else
- cygpath="dosname"
- cygpath_short="${cygpath} -s"
- cygpath_windows="${cygpath} -s"
- cygpath_path="echo"
- pathsep=';'
-fi
-
########################################################################
# Error functions
msg() # message
@@ -60,8 +44,8 @@ warning() # message
}
envpath() # path
{
- if [ "${cygpath_short}" != "" -a -d "$1" ] ; then
- ${cygpath_short} "$1"
+ if [ "${fixpath}" != "" -a -d "$1" ] ; then
+ ${fixpath} "$1"
else
echo "$1"
fi
@@ -72,14 +56,65 @@ envpath() # path
# Defaults settings
debug="false"
verbose="false"
-shellStyle="sh"
-parentCsh="` ps -p ${PPID} 2> /dev/null | grep csh `"
-if [ "${parentCsh}" != "" ] ; then
- shellStyle="csh"
-fi
set -e
+CYGWIN="nodosfilewarning ntsec"
+export CYGWIN
+
+# pathsepIn is always ; because the input strings are coming from
+# vcvarsxx.bat. This is true under all of MKS, Cygwin, MINGW/msys
+pathsepIn=';'
+
+OS="`uname -s`"
+case "${OS}" in
+ CYGWIN*)
+ pathflag='-c'
+ devnull=/dev/null
+ pathsepOut=':'
+ ;;
+
+ MINGW*)
+ pathflag='-m'
+ devnull=/dev/null
+ pathsepOut=':'
+ ;;
+
+ *)
+ # MKS?
+ # Continue using dosname -s
+ pathflag='-s'
+ fixpath="dosname ${pathflag}"
+ fixpath_windows="${fixpath}"
+ fixpath_path="echo"
+ devnull=NUL
+ pathsepOut=';'
+ ;;
+esac
+
+case "${OS}" in
+ CYGWIN*|MINGW*)
+ t=`dirname ${0}`
+ wd=`cd ${t} 2> ${devnull} && pwd`
+ fixpath_script="${wd}/fixpath.pl"
+ if [ ! -f "${fixpath_script}" ] ; then
+ error "Does not exist: ${fixpath_script}"
+ fi
+ fixpath="perl ${fixpath_script} ${pathflag}"
+ fixpath_windows="perl ${fixpath_script} -d"
+ fixpath_path="${fixpath_windows}"
+ ;;
+esac
+
+shellStyle="sh"
+## As far as I can tell from hg history, this has not worked
+## for a long time because PPID is unset. When run under Cygwin
+## the script quits due to the 1 return from grep.
+##parentCsh="` ps -p ${PPID} 2> ${devnull} | grep csh `"
+##if [ "${parentCsh}" != "" ] ; then
+## shellStyle="csh"
+##fi
+
# Check environment first
if [ "${PROGRAMFILES}" != "" ] ; then
progfiles=`envpath "${PROGRAMFILES}"`
@@ -96,15 +131,19 @@ fi
# Arch data model
if [ "${PROCESSOR_IDENTIFIER}" != "" ] ; then
arch=`echo "${PROCESSOR_IDENTIFIER}" | cut -d' ' -f1`
-elif [ "${MACHTYPE}" != "" ] ; then
- if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then
- # Assume this is X64, not IA64
- arch="x64"
- else
- arch="x86"
- fi
else
- arch="`uname -m`"
+ if [ "${MACHTYPE}" != "" ] ; then
+ if [ "`echo ${MACHTYPE} | grep 64`" != "" ] ; then
+ # Assume this is X64, not IA64
+ arch="x64"
+ else
+ arch="x86"
+ fi
+ else
+ arch="`uname -m`"
+ fi
+ PROCESSOR_IDENTIFIER="${arch}"
+ export PROCESSOR_IDENTIFIER
fi
if [ "${arch}" = "X86" -o \
"${arch}" = "386" -o "${arch}" = "i386" -o \
@@ -121,11 +160,11 @@ if [ "${arch}" = "X64" -o \
"${arch}" = "intel64" -o "${arch}" = "Intel64" -o \
"${arch}" = "64" ] ; then
arch="x64"
- binarch64="/amd64"
+ binarch64="\\amd64"
fi
if [ "${arch}" = "IA64" ] ; then
arch="ia64"
- binarch64="/ia64"
+ binarch64="\\ia64"
fi
if [ "${arch}" != "x86" -a "${arch}" != "x64" -a "${arch}" != "ia64" ] ; then
error "No PROCESSOR_IDENTIFIER or MACHTYPE environment variables and uname -m is not helping"
@@ -324,25 +363,26 @@ checkPaths() # var path sep
}
# Remove all duplicate entries
-removeDeadDups() # string sep
+removeDeadDups() # string sepIn sepOut
{
set -e
- sep="$2"
+ sepIn="$2"
+ sepOut="$3"
pathlist="${tmp}/pathlist"
printf "%s\n" "$1" | \
sed -e 's@\\@/@g' | \
sed -e 's@//@/@g' | \
- ${awk} -F"${sep}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \
+ ${awk} -F"${sepIn}" '{for(i=1;i<=NF;i++){printf "%s\n",$i;}}' \
> ${pathlist}
upaths="${tmp}/upaths"
cat ${pathlist} | while read orig; do
p="${orig}"
- if [ "${cygpath_short}" != "" ] ; then
+ if [ "${fixpath}" != "" ] ; then
if [ "${p}" != "" ] ; then
if [ -d "${p}" ] ; then
- short=`${cygpath_short} "${p}"`
+ short=`${fixpath} "${p}"`
if [ "${short}" != "" -a -d "${short}" ] ; then
- p=`${cygpath} "${short}"`
+ p="${short}"
fi
echo "${p}" >> ${upaths}
fi
@@ -356,11 +396,11 @@ removeDeadDups() # string sep
if [ "${newpaths}" = "" ] ; then
newpaths="${i}"
else
- newpaths="${newpaths}${sep}${i}"
+ newpaths="${newpaths}${sepOut}${i}"
fi
done
printf "%s\n" "${newpaths}" | \
- ${awk} -F"${sep}" \
+ ${awk} -F"${sepOut}" \
'{a[$1];printf "%s",$1;for(i=2;i<=NF;i++){if(!($i in a)){a[$i];printf "%s%s",FS,$i;}};printf "\n";}'
}
@@ -388,7 +428,7 @@ set VCINSTALLDIR=
set VSINSTALLDIR=
set WindowsSdkDir=
REM Run the vcvars bat file, send all output to stderr
-call `${cygpath_windows} ${bdir}`\\${command} > `${cygpath_windows} "${stdout}"`
+call `${fixpath_windows} ${bdir}`\\${command} > `${fixpath_windows} "${stdout}"`
REM Echo out env var settings
echo VS_VS71COMNTOOLS="%VS71COMNTOOLS%"
echo export VS_VS71COMNTOOLS
@@ -427,9 +467,18 @@ EOF
# Create env file
createEnv() # batfile envfile
{
- rm -f ${1}.stdout
- cmd.exe /Q /C `${cygpath_short} $1` | \
- sed -e 's@\\@/@g' | \
+ rm -f ${1}.stdout ${1}.temp1 ${1}.temp2
+ batfile=`${fixpath} ${1}`
+ cmd.exe -Q -C < "$batfile" 1> ${1}.temp1 2> ${1}.temp2
+ cat ${1}.temp1 | \
+ sed -e 's@^Microsoft.*@@' \
+ -e 's@^.*Copyright.*@@' \
+ -e 's@^.*>REM.*@@' \
+ -e 's@^.*>set.*@@' \
+ -e 's@^.*>echo.*@@' \
+ -e 's@^.*>call.*@@' \
+ -e 's@^.*>$@@' \
+ -e 's@\\@/@g' | \
sed -e 's@//@/@g' > $2
if [ -f "${1}.stdout" ] ; then
cat ${1}.stdout 1>&2
@@ -465,7 +514,7 @@ printEnv() # name pname vsname val
#############################################################################
# Get Visual Studio settings
-if [ "${cygpath}" != "" ] ; then
+if [ "${fixpath}" != "" ] ; then
# Create bat file to run
batfile="${tmp}/vs-to-env.bat"
@@ -485,11 +534,11 @@ if [ "${cygpath}" != "" ] ; then
. ${envfile}
# Derive unix style path, save old, and define new (remove dups)
- VS_UPATH=`${cygpath_path} "${VS_WPATH}"`
+ VS_UPATH=`${fixpath_path} "${VS_WPATH}"`
export VS_UPATH
VS_OPATH=`printf "%s" "${PATH}" | sed -e 's@\\\\@/@g'`
export VS_OPATH
- VS_PATH=`removeDeadDups "${VS_UPATH}${pathsep}${VS_OPATH}" "${pathsep}"`
+ VS_PATH=`removeDeadDups "${VS_UPATH}${pathsepIn}${VS_OPATH}" "${pathsepIn}" "${pathsepOut}"`
export VS_PATH
fi
@@ -536,11 +585,13 @@ if [ "${verbose}" = "true" ] ; then
checkPaths "Windows PATH" "${VS_WPATH}" ";"
checkPaths LIB "${VS_LIB}" ";"
checkPaths INCLUDE "${VS_INCLUDE}" ";"
- checkPaths PATH "${VS_PATH}" "${pathsep}"
+ checkPaths PATH "${VS_PATH}" "${pathsepIn}"
fi
# Remove all temp files
-rm -f -r ${tmp}
+if [ "${debug}" != "true" ] ; then
+ rm -f -r ${tmp}
+fi
exit 0
From 919df15706b94e44d261ee1ee6f09f5de33cd71a Mon Sep 17 00:00:00 2001
From: "J. Duke"
Date: Wed, 5 Jul 2017 18:26:11 +0200
Subject: [PATCH 55/56] Added tag jdk8-b61 for changeset cdaa6122185f
---
.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/.hgtags b/.hgtags
index fde585f8bbb..bf173376ee4 100644
--- a/.hgtags
+++ b/.hgtags
@@ -182,3 +182,4 @@ ffe6bce5a521be40146af2ac03c509b7bac30595 jdk8-b56
479d3302a26d7607ba271d66973e59ebf58825b6 jdk8-b58
3bd874584fc01aae92fbc8827e2bd04d8b6ace04 jdk8-b59
5e3adc681779037a2d33b7be6f75680619085492 jdk8-b60
+cdaa6122185f9bf512dcd6600f56bfccc4824e8c jdk8-b61
From bb35ccdbc39d8f72d3346e3a9f167e58a58ea2d9 Mon Sep 17 00:00:00 2001
From: David Katleman
Date: Thu, 25 Oct 2012 09:54:03 -0700
Subject: [PATCH 56/56] Added tag jdk8-b62 for changeset f0d59eea9c70
---
jdk/.hgtags | 1 +
1 file changed, 1 insertion(+)
diff --git a/jdk/.hgtags b/jdk/.hgtags
index c0a4c320b0f..de1a543ff2e 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -183,3 +183,4 @@ d94613ac03d8de375ef60493e2bb76dbd30d875d jdk8-b58
abad1f417bd3df4296631fc943cd3b7f5062c88a jdk8-b59
cec8fa02f15634acd7d02d04b0b2d8c044cdbaaa jdk8-b60
61ddb3fd000a09ab05bff1940b0ac211661e94cf jdk8-b61
+50b8b17449d200c66bfd68fb4f3a9197432c9e2b jdk8-b62