--- a/jdk/make/gensrc/GensrcProperties.gmk Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/make/gensrc/GensrcProperties.gmk Tue Feb 24 10:52:02 2015 -0800
@@ -53,15 +53,21 @@
# Param 1 - Variable to add targets to, must not contain space
# Param 2 - Properties files to process
# Param 3 - The super class for the generated classes
+# Param 4 - Module path root, defaults to $(JDK_TOPDIR)/src
define SetupCompileProperties
$1_SRCS := $2
$1_CLASS := $3
+ $1_MODULE_PATH_ROOT := $4
+
+ ifeq ($$($1_MODULE_PATH_ROOT), )
+ $1_MODULE_PATH_ROOT := $(JDK_TOPDIR)/src
+ endif
# Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
# to .../support/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
# Strip away prefix and suffix, leaving for example only:
# "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
- $1_JAVAS := $$(patsubst $(JDK_TOPDIR)/src/%, \
+ $1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \
$(SUPPORT_OUTPUTDIR)/gensrc/%, \
$$(patsubst %.properties, %.java, \
$$(subst /$(OPENJDK_TARGET_OS)/classes,, \
--- a/jdk/src/java.base/share/classes/java/net/URL.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/net/URL.java Tue Feb 24 10:52:02 2015 -0800
@@ -27,8 +27,15 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.spi.URLStreamHandlerProvider;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Hashtable;
-import java.util.StringTokenizer;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
+
import sun.security.util.SecurityConstants;
/**
@@ -248,23 +255,19 @@
* stream protocol handler.
* <li>If no {@code URLStreamHandlerFactory} has yet been set up,
* or if the factory's {@code createURLStreamHandler} method
- * returns {@code null}, then the constructor finds the
- * value of the system property:
- * <blockquote><pre>
- * java.protocol.handler.pkgs
- * </pre></blockquote>
- * If the value of that system property is not {@code null},
- * it is interpreted as a list of packages separated by a vertical
- * slash character '{@code |}'. The constructor tries to load
- * the class named:
- * <blockquote><pre>
- * <<i>package</i>>.<<i>protocol</i>>.Handler
- * </pre></blockquote>
- * where <<i>package</i>> is replaced by the name of the package
- * and <<i>protocol</i>> is replaced by the name of the protocol.
- * If this class does not exist, or if the class exists but it is not
- * a subclass of {@code URLStreamHandler}, then the next package
- * in the list is tried.
+ * returns {@code null}, then the {@linkplain java.util.ServiceLoader
+ * ServiceLoader} mechanism is used to locate {@linkplain
+ * java.net.spi.URLStreamHandlerProvider URLStreamHandlerProvider}
+ * implementations using the system class
+ * loader. The order that providers are located is implementation
+ * specific, and an implementation is free to cache the located
+ * providers. A {@linkplain java.util.ServiceConfigurationError
+ * ServiceConfigurationError}, {@code Error} or {@code RuntimeException}
+ * thrown from the {@code createURLStreamHandler}, if encountered, will
+ * be propagated to the calling thread. The {@code
+ * createURLStreamHandler} method of each provider, if instantiated, is
+ * invoked, with the protocol string, until a provider returns non-null,
+ * or all providers have been exhausted.
* <li>If the previous step fails to find a protocol handler, then the
* constructor tries to load a built-in protocol handler.
* If this class does not exist, or if the class exists but it is not a
@@ -277,8 +280,12 @@
* <blockquote><pre>
* http, https, file, and jar
* </pre></blockquote>
- * Protocol handlers for additional protocols may also be
- * available.
+ * Protocol handlers for additional protocols may also be available.
+ * Some protocol handlers, for example those used for loading platform
+ * classes or classes on the class path, may not be overridden. The details
+ * of such restrictions, and when those restrictions apply (during
+ * initialization of the runtime for example), are implementation specific
+ * and therefore not specified
*
* <p>No validation of the inputs is performed by this constructor.
*
@@ -1107,20 +1114,115 @@
}
handlers.clear();
- // ensure the core protocol handlers are loaded before setting
- // a custom URLStreamHandlerFactory
- ensureHandlersLoaded("jrt", "jar", "file");
-
// safe publication of URLStreamHandlerFactory with volatile write
factory = fac;
}
}
+ private static final URLStreamHandlerFactory defaultFactory = new DefaultFactory();
+
+ private static class DefaultFactory implements URLStreamHandlerFactory {
+ private static String PREFIX = "sun.net.www.protocol";
+
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ String name = PREFIX + "." + protocol + ".Handler";
+ try {
+ Class<?> c = Class.forName(name);
+ return (URLStreamHandler)c.newInstance();
+ } catch (ClassNotFoundException x) {
+ // ignore
+ } catch (Exception e) {
+ // For compatibility, all Exceptions are ignored.
+ // any number of exceptions can get thrown here
+ }
+ return null;
+ }
+ }
+
+ private static Iterator<URLStreamHandlerProvider> providers() {
+ return new Iterator<URLStreamHandlerProvider>() {
+
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ ServiceLoader<URLStreamHandlerProvider> sl =
+ ServiceLoader.load(URLStreamHandlerProvider.class, cl);
+ Iterator<URLStreamHandlerProvider> i = sl.iterator();
+
+ URLStreamHandlerProvider next = null;
+
+ private boolean getNext() {
+ while (next == null) {
+ try {
+ if (!i.hasNext())
+ return false;
+ next = i.next();
+ } catch (ServiceConfigurationError sce) {
+ if (sce.getCause() instanceof SecurityException) {
+ // Ignore security exceptions
+ continue;
+ }
+ throw sce;
+ }
+ }
+ return true;
+ }
+
+ public boolean hasNext() {
+ return getNext();
+ }
+
+ public URLStreamHandlerProvider next() {
+ if (!getNext())
+ throw new NoSuchElementException();
+ URLStreamHandlerProvider n = next;
+ next = null;
+ return n;
+ }
+ };
+ }
+
+ // Thread-local gate to prevent recursive provider lookups
+ private static ThreadLocal<Object> gate = new ThreadLocal<>();
+
+ private static URLStreamHandler lookupViaProviders(final String protocol) {
+ if (!sun.misc.VM.isBooted())
+ return null;
+
+ if (gate.get() != null)
+ throw new Error("Circular loading of URL stream handler providers detected");
+
+ gate.set(gate);
+ try {
+ return AccessController.doPrivileged(
+ new PrivilegedAction<URLStreamHandler>() {
+ public URLStreamHandler run() {
+ Iterator<URLStreamHandlerProvider> itr = providers();
+ while (itr.hasNext()) {
+ URLStreamHandlerProvider f = itr.next();
+ URLStreamHandler h = f.createURLStreamHandler(protocol);
+ if (h != null)
+ return h;
+ }
+ return null;
+ }
+ });
+ } finally {
+ gate.set(null);
+ }
+ }
+
+ private static final String[] NON_OVERRIDEABLE_PROTOCOLS = {"file", "jrt"};
+ private static boolean isOverrideable(String protocol) {
+ for (String p : NON_OVERRIDEABLE_PROTOCOLS)
+ if (protocol.equalsIgnoreCase(p))
+ return false;
+ return true;
+ }
+
/**
* A table of protocol handlers.
*/
static Hashtable<String,URLStreamHandler> handlers = new Hashtable<>();
- private static Object streamHandlerLock = new Object();
+ private static final Object streamHandlerLock = new Object();
/**
* Returns the Stream Handler.
@@ -1129,66 +1231,33 @@
static URLStreamHandler getURLStreamHandler(String protocol) {
URLStreamHandler handler = handlers.get(protocol);
- if (handler == null) {
+
+ if (handler != null) {
+ return handler;
+ }
- boolean checkedWithFactory = false;
+ URLStreamHandlerFactory fac;
+ boolean checkedWithFactory = false;
+ if (isOverrideable(protocol)) {
// Use the factory (if any). Volatile read makes
// URLStreamHandlerFactory appear fully initialized to current thread.
- URLStreamHandlerFactory fac = factory;
+ fac = factory;
if (fac != null) {
handler = fac.createURLStreamHandler(protocol);
checkedWithFactory = true;
}
- // Try java protocol handler
- if (handler == null) {
- String packagePrefixList = null;
-
- packagePrefixList
- = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction(
- protocolPathProp,""));
- if (packagePrefixList != "") {
- packagePrefixList += "|";
- }
-
- // REMIND: decide whether to allow the "null" class prefix
- // or not.
- packagePrefixList += "sun.net.www.protocol";
-
- StringTokenizer packagePrefixIter =
- new StringTokenizer(packagePrefixList, "|");
-
- while (handler == null &&
- packagePrefixIter.hasMoreTokens()) {
+ if (handler == null && !protocol.equalsIgnoreCase("jar")) {
+ handler = lookupViaProviders(protocol);
+ }
+ }
- String packagePrefix =
- packagePrefixIter.nextToken().trim();
- try {
- String clsName = packagePrefix + "." + protocol +
- ".Handler";
- Class<?> cls = null;
- try {
- cls = Class.forName(clsName);
- } catch (ClassNotFoundException e) {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- if (cl != null) {
- cls = cl.loadClass(clsName);
- }
- }
- if (cls != null) {
- handler =
- (URLStreamHandler)cls.newInstance();
- }
- } catch (Exception e) {
- // any number of exceptions can get thrown here
- }
- }
- }
-
- synchronized (streamHandlerLock) {
-
+ synchronized (streamHandlerLock) {
+ if (handler == null) {
+ // Try the built-in protocol handler
+ handler = defaultFactory.createURLStreamHandler(protocol);
+ } else {
URLStreamHandler handler2 = null;
// Check again with hashtable just in case another
@@ -1202,7 +1271,7 @@
// Check with factory if another thread set a
// factory since our last check
if (!checkedWithFactory && (fac = factory) != null) {
- handler2 = fac.createURLStreamHandler(protocol);
+ handler2 = fac.createURLStreamHandler(protocol);
}
if (handler2 != null) {
@@ -1211,30 +1280,18 @@
// this thread created.
handler = handler2;
}
+ }
- // Insert this handler into the hashtable
- if (handler != null) {
- handlers.put(protocol, handler);
- }
-
+ // Insert this handler into the hashtable
+ if (handler != null) {
+ handlers.put(protocol, handler);
}
}
return handler;
-
}
/**
- * Ensures that the given protocol handlers are loaded
- */
- private static void ensureHandlersLoaded(String... protocols) {
- for (String protocol: protocols) {
- getURLStreamHandler(protocol);
- }
- }
-
-
- /**
* WriteObject is called to save the state of the URL to an
* ObjectOutputStream. The handler is not saved since it is
* specific to this system.
--- a/jdk/src/java.base/share/classes/java/net/URLStreamHandlerFactory.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/net/URLStreamHandlerFactory.java Tue Feb 24 10:52:02 2015 -0800
@@ -44,7 +44,9 @@
*
* @param protocol the protocol ("{@code ftp}",
* "{@code http}", "{@code nntp}", etc.).
- * @return a {@code URLStreamHandler} for the specific protocol.
+ * @return a {@code URLStreamHandler} for the specific protocol, or {@code
+ * null} if this factory cannot create a handler for the specific
+ * protocol
* @see java.net.URLStreamHandler
*/
URLStreamHandler createURLStreamHandler(String protocol);
--- a/jdk/src/java.base/share/classes/java/net/package-info.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/net/package-info.java Tue Feb 24 10:52:02 2015 -0800
@@ -143,13 +143,11 @@
* a similar URL will try to instantiate the handler for the specified protocol;
* if it doesn't exist an exception will be thrown.
* <p>By default the protocol handlers are loaded dynamically from the default
- * location. It is, however, possible to add to the search path by setting
- * the {@code java.protocol.handler.pkgs} system property. For instance if
- * it is set to {@code myapp.protocols}, then the URL code will try, in the
- * case of http, first to load {@code myapp.protocols.http.Handler}, then,
- * if this fails, {@code http.Handler} from the default location.
- * <p>Note that the Handler class <b>has to</b> be a subclass of the abstract
- * class {@link java.net.URLStreamHandler}.</p>
+ * location. It is, however, possible to deploy additional protocols handlers
+ * as {@link java.util.ServiceLoader services}. Service providers of type
+ * {@linkplain java.net.spi.URLStreamHandlerProvider} are located at
+ * runtime, as specified in the {@linkplain
+ * java.net.URL#URL(String,String,int,String) URL constructor}.
* <h2>Additional Specification</h2>
* <ul>
* <li><a href="doc-files/net-properties.html">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015, 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 java.net.spi;
+
+import java.net.URLStreamHandlerFactory;
+
+/**
+ * URL stream handler service-provider class.
+ *
+ *<p> A URL stream handler provider is a concrete subclass of this class that
+ * has a zero-argument constructor. URL stream handler providers may be
+ * installed in an instance of the Java platform by adding them to the
+ * application class path.
+ *
+ * <p> A URL stream handler provider identifies itself with a
+ * provider-configuration file named java.net.spi.URLStreamHandlerProvider in
+ * the resource directory META-INF/services. The file should contain a list of
+ * fully-qualified concrete URL stream handler provider class names, one per
+ * line.
+ *
+ * @since 1.9
+ */
+public abstract class URLStreamHandlerProvider
+ implements URLStreamHandlerFactory
+{
+ private static Void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("setFactory"));
+ return null;
+ }
+ private URLStreamHandlerProvider(Void ignore) { }
+
+ /**
+ * Initializes a new URL stream handler provider.
+ *
+ * @throws SecurityException
+ * If a security manager has been installed and it denies
+ * {@link RuntimePermission}{@code ("setFactory")}.
+ */
+ protected URLStreamHandlerProvider() {
+ this(checkPermission());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/net/spi/package-info.java Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+/**
+ * Service-provider classes for the <tt>{@link java.net}</tt> package.
+ *
+ * <p> Only developers who are defining new URL stream handler providers
+ * should need to make direct use of this package.
+ *
+ * @since 1.9
+ */
+
+package java.net.spi;
--- a/jdk/src/java.base/share/classes/java/security/acl/Acl.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/security/acl/Acl.java Tue Feb 24 10:52:02 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, 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
@@ -68,11 +68,7 @@
*
* The {@code java.security.acl } package provides the
* interfaces to the ACL and related data structures (ACL entries,
- * groups, permissions, etc.), and the {@code sun.security.acl }
- * classes provide a default implementation of the interfaces. For
- * example, {@code java.security.acl.Acl } provides the
- * interface to an ACL and the {@code sun.security.acl.AclImpl }
- * class provides the default implementation of the interface.<p>
+ * groups, permissions, etc.).<p>
*
* The {@code java.security.acl.Acl } interface extends the
* {@code java.security.acl.Owner } interface. The Owner
--- a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java Tue Feb 24 10:52:02 2015 -0800
@@ -848,7 +848,7 @@
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
- * call chains, or even {@code StackOverflowException}.
+ * call chains, or even {@code StackOverflowError}.
*
* @param a the first stream
* @param b the second stream
--- a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java Tue Feb 24 10:52:02 2015 -0800
@@ -837,7 +837,7 @@
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
- * call chains, or even {@code StackOverflowException}.
+ * call chains, or even {@code StackOverflowError}.
*
* @param a the first stream
* @param b the second stream
--- a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java Tue Feb 24 10:52:02 2015 -0800
@@ -845,7 +845,7 @@
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
- * call chains, or even {@code StackOverflowException}.
+ * call chains, or even {@code StackOverflowError}.
*
* @param a the first stream
* @param b the second stream
--- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java Tue Feb 24 10:52:02 2015 -0800
@@ -1079,7 +1079,7 @@
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
- * call chains, or even {@code StackOverflowException}.
+ * call chains, or even {@code StackOverflowError}.
*
* @param <T> The type of stream elements
* @param a the first stream
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java Tue Feb 24 10:52:02 2015 -0800
@@ -180,8 +180,7 @@
* @since 1.8
*/
public ZipEntry setLastModifiedTime(FileTime time) {
- Objects.requireNonNull(name, "time");
- this.mtime = time;
+ this.mtime = Objects.requireNonNull(time, "lastModifiedTime");
this.time = time.to(TimeUnit.MILLISECONDS);
return this;
}
@@ -227,8 +226,7 @@
* @since 1.8
*/
public ZipEntry setLastAccessTime(FileTime time) {
- Objects.requireNonNull(name, "time");
- this.atime = time;
+ this.atime = Objects.requireNonNull(time, "lastAccessTime");
return this;
}
@@ -265,8 +263,7 @@
* @since 1.8
*/
public ZipEntry setCreationTime(FileTime time) {
- Objects.requireNonNull(name, "time");
- this.ctime = time;
+ this.ctime = Objects.requireNonNull(time, "creationTime");
return this;
}
--- a/jdk/src/java.base/share/classes/sun/security/acl/AclEntryImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 1996, 2011, 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.security.acl;
-
-import java.util.*;
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * This is a class that describes one entry that associates users
- * or groups with permissions in the ACL.
- * The entry may be used as a way of granting or denying permissions.
- * @author Satish Dharmaraj
- */
-public class AclEntryImpl implements AclEntry {
- private Principal user = null;
- private Vector<Permission> permissionSet = new Vector<>(10, 10);
- private boolean negative = false;
-
- /**
- * Construct an ACL entry that associates a user with permissions
- * in the ACL.
- * @param user The user that is associated with this entry.
- */
- public AclEntryImpl(Principal user) {
- this.user = user;
- }
-
- /**
- * Construct a null ACL entry
- */
- public AclEntryImpl() {
- }
-
- /**
- * Sets the principal in the entity. If a group or a
- * principal had already been set, a false value is
- * returned, otherwise a true value is returned.
- * @param user The user that is associated with this entry.
- * @return true if the principal is set, false if there is
- * one already.
- */
- public boolean setPrincipal(Principal user) {
- if (this.user != null)
- return false;
- this.user = user;
- return true;
- }
-
- /**
- * This method sets the ACL to have negative permissions.
- * That is the user or group is denied the permission set
- * specified in the entry.
- */
- public void setNegativePermissions() {
- negative = true;
- }
-
- /**
- * Returns true if this is a negative ACL.
- */
- public boolean isNegative() {
- return negative;
- }
-
- /**
- * A principal or a group can be associated with multiple
- * permissions. This method adds a permission to the ACL entry.
- * @param permission The permission to be associated with
- * the principal or the group in the entry.
- * @return true if the permission was added, false if the
- * permission was already part of the permission set.
- */
- public boolean addPermission(Permission permission) {
-
- if (permissionSet.contains(permission))
- return false;
-
- permissionSet.addElement(permission);
-
- return true;
- }
-
- /**
- * The method disassociates the permission from the Principal
- * or the Group in this ACL entry.
- * @param permission The permission to be disassociated with
- * the principal or the group in the entry.
- * @return true if the permission is removed, false if the
- * permission is not part of the permission set.
- */
- public boolean removePermission(Permission permission) {
- return permissionSet.removeElement(permission);
- }
-
- /**
- * Checks if the passed permission is part of the allowed
- * permission set in this entry.
- * @param permission The permission that has to be part of
- * the permission set in the entry.
- * @return true if the permission passed is part of the
- * permission set in the entry, false otherwise.
- */
- public boolean checkPermission(Permission permission) {
- return permissionSet.contains(permission);
- }
-
- /**
- * return an enumeration of the permissions in this ACL entry.
- */
- public Enumeration<Permission> permissions() {
- return permissionSet.elements();
- }
-
- /**
- * Return a string representation of the contents of the ACL entry.
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- if (negative)
- s.append("-");
- else
- s.append("+");
- if (user instanceof Group)
- s.append("Group.");
- else
- s.append("User.");
- s.append(user + "=");
- Enumeration<Permission> e = permissions();
- while(e.hasMoreElements()) {
- Permission p = e.nextElement();
- s.append(p);
- if (e.hasMoreElements())
- s.append(",");
- }
- return new String(s);
- }
-
- /**
- * Clones an AclEntry.
- */
- @SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
- public synchronized Object clone() {
- AclEntryImpl cloned;
- cloned = new AclEntryImpl(user);
- cloned.permissionSet = (Vector<Permission>) permissionSet.clone();
- cloned.negative = negative;
- return cloned;
- }
-
- /**
- * Return the Principal associated in this ACL entry.
- * The method returns null if the entry uses a group
- * instead of a principal.
- */
- public Principal getPrincipal() {
- return user;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/security/acl/AclImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 1996, 2011, 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.security.acl;
-
-import java.io.*;
-import java.util.*;
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * An Access Control List (ACL) is encapsulated by this class.
- * @author Satish Dharmaraj
- */
-public class AclImpl extends OwnerImpl implements Acl {
- //
- // Maintain four tables. one each for positive and negative
- // ACLs. One each depending on whether the entity is a group
- // or principal.
- //
- private Hashtable<Principal, AclEntry> allowedUsersTable =
- new Hashtable<>(23);
- private Hashtable<Principal, AclEntry> allowedGroupsTable =
- new Hashtable<>(23);
- private Hashtable<Principal, AclEntry> deniedUsersTable =
- new Hashtable<>(23);
- private Hashtable<Principal, AclEntry> deniedGroupsTable =
- new Hashtable<>(23);
- private String aclName = null;
- private Vector<Permission> zeroSet = new Vector<>(1,1);
-
-
- /**
- * Constructor for creating an empty ACL.
- */
- public AclImpl(Principal owner, String name) {
- super(owner);
- try {
- setName(owner, name);
- } catch (Exception e) {}
- }
-
- /**
- * Sets the name of the ACL.
- * @param caller the principal who is invoking this method.
- * @param name the name of the ACL.
- * @exception NotOwnerException if the caller principal is
- * not on the owners list of the Acl.
- */
- public void setName(Principal caller, String name)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- aclName = name;
- }
-
- /**
- * Returns the name of the ACL.
- * @return the name of the ACL.
- */
- public String getName() {
- return aclName;
- }
-
- /**
- * Adds an ACL entry to this ACL. An entry associates a
- * group or a principal with a set of permissions. Each
- * user or group can have one positive ACL entry and one
- * negative ACL entry. If there is one of the type (negative
- * or positive) already in the table, a false value is returned.
- * The caller principal must be a part of the owners list of
- * the ACL in order to invoke this method.
- * @param caller the principal who is invoking this method.
- * @param entry the ACL entry that must be added to the ACL.
- * @return true on success, false if the entry is already present.
- * @exception NotOwnerException if the caller principal
- * is not on the owners list of the Acl.
- */
- public synchronized boolean addEntry(Principal caller, AclEntry entry)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- Hashtable<Principal, AclEntry> aclTable = findTable(entry);
- Principal key = entry.getPrincipal();
-
- if (aclTable.get(key) != null)
- return false;
-
- aclTable.put(key, entry);
- return true;
- }
-
- /**
- * Removes an ACL entry from this ACL.
- * The caller principal must be a part of the owners list of the ACL
- * in order to invoke this method.
- * @param caller the principal who is invoking this method.
- * @param entry the ACL entry that must be removed from the ACL.
- * @return true on success, false if the entry is not part of the ACL.
- * @exception NotOwnerException if the caller principal is not
- * the owners list of the Acl.
- */
- public synchronized boolean removeEntry(Principal caller, AclEntry entry)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- Hashtable<Principal, AclEntry> aclTable = findTable(entry);
- Principal key = entry.getPrincipal();
-
- AclEntry o = aclTable.remove(key);
- return (o != null);
- }
-
- /**
- * This method returns the set of allowed permissions for the
- * specified principal. This set of allowed permissions is calculated
- * as follows:
- *
- * If there is no entry for a group or a principal an empty permission
- * set is assumed.
- *
- * The group positive permission set is the union of all
- * the positive permissions of each group that the individual belongs to.
- * The group negative permission set is the union of all
- * the negative permissions of each group that the individual belongs to.
- * If there is a specific permission that occurs in both
- * the postive permission set and the negative permission set,
- * it is removed from both. The group positive and negatoive permission
- * sets are calculated.
- *
- * The individial positive permission set and the individual negative
- * permission set is then calculated. Again abscence of an entry means
- * the empty set.
- *
- * The set of permissions granted to the principal is then calculated using
- * the simple rule: Individual permissions always override the Group permissions.
- * Specifically, individual negative permission set (specific
- * denial of permissions) overrides the group positive permission set.
- * And the individual positive permission set override the group negative
- * permission set.
- *
- * @param user the principal for which the ACL entry is returned.
- * @return The resulting permission set that the principal is allowed.
- */
- public synchronized Enumeration<Permission> getPermissions(Principal user) {
-
- Enumeration<Permission> individualPositive;
- Enumeration<Permission> individualNegative;
- Enumeration<Permission> groupPositive;
- Enumeration<Permission> groupNegative;
-
- //
- // canonicalize the sets. That is remove common permissions from
- // positive and negative sets.
- //
- groupPositive =
- subtract(getGroupPositive(user), getGroupNegative(user));
- groupNegative =
- subtract(getGroupNegative(user), getGroupPositive(user));
- individualPositive =
- subtract(getIndividualPositive(user), getIndividualNegative(user));
- individualNegative =
- subtract(getIndividualNegative(user), getIndividualPositive(user));
-
- //
- // net positive permissions is individual positive permissions
- // plus (group positive - individual negative).
- //
- Enumeration<Permission> temp1 =
- subtract(groupPositive, individualNegative);
- Enumeration<Permission> netPositive =
- union(individualPositive, temp1);
-
- // recalculate the enumeration since we lost it in performing the
- // subtraction
- //
- individualPositive =
- subtract(getIndividualPositive(user), getIndividualNegative(user));
- individualNegative =
- subtract(getIndividualNegative(user), getIndividualPositive(user));
-
- //
- // net negative permissions is individual negative permissions
- // plus (group negative - individual positive).
- //
- temp1 = subtract(groupNegative, individualPositive);
- Enumeration<Permission> netNegative = union(individualNegative, temp1);
-
- return subtract(netPositive, netNegative);
- }
-
- /**
- * This method checks whether or not the specified principal
- * has the required permission. If permission is denied
- * permission false is returned, a true value is returned otherwise.
- * This method does not authenticate the principal. It presumes that
- * the principal is a valid authenticated principal.
- * @param principal the name of the authenticated principal
- * @param permission the permission that the principal must have.
- * @return true of the principal has the permission desired, false
- * otherwise.
- */
- public boolean checkPermission(Principal principal, Permission permission)
- {
- Enumeration<Permission> permSet = getPermissions(principal);
- while (permSet.hasMoreElements()) {
- Permission p = permSet.nextElement();
- if (p.equals(permission))
- return true;
- }
- return false;
- }
-
- /**
- * returns an enumeration of the entries in this ACL.
- */
- public synchronized Enumeration<AclEntry> entries() {
- return new AclEnumerator(this,
- allowedUsersTable, allowedGroupsTable,
- deniedUsersTable, deniedGroupsTable);
- }
-
- /**
- * return a stringified version of the
- * ACL.
- */
- public String toString() {
- StringBuilder sb = new StringBuilder();
- Enumeration<AclEntry> entries = entries();
- while (entries.hasMoreElements()) {
- AclEntry entry = entries.nextElement();
- sb.append(entry.toString().trim());
- sb.append("\n");
- }
-
- return sb.toString();
- }
-
- //
- // Find the table that this entry belongs to. There are 4
- // tables that are maintained. One each for postive and
- // negative ACLs and one each for groups and users.
- // This method figures out which
- // table is the one that this AclEntry belongs to.
- //
- private Hashtable<Principal, AclEntry> findTable(AclEntry entry) {
- Hashtable<Principal, AclEntry> aclTable = null;
-
- Principal p = entry.getPrincipal();
- if (p instanceof Group) {
- if (entry.isNegative())
- aclTable = deniedGroupsTable;
- else
- aclTable = allowedGroupsTable;
- } else {
- if (entry.isNegative())
- aclTable = deniedUsersTable;
- else
- aclTable = allowedUsersTable;
- }
- return aclTable;
- }
-
- //
- // returns the set e1 U e2.
- //
- private static Enumeration<Permission> union(Enumeration<Permission> e1,
- Enumeration<Permission> e2) {
- Vector<Permission> v = new Vector<>(20, 20);
-
- while (e1.hasMoreElements())
- v.addElement(e1.nextElement());
-
- while (e2.hasMoreElements()) {
- Permission o = e2.nextElement();
- if (!v.contains(o))
- v.addElement(o);
- }
-
- return v.elements();
- }
-
- //
- // returns the set e1 - e2.
- //
- private Enumeration<Permission> subtract(Enumeration<Permission> e1,
- Enumeration<Permission> e2) {
- Vector<Permission> v = new Vector<>(20, 20);
-
- while (e1.hasMoreElements())
- v.addElement(e1.nextElement());
-
- while (e2.hasMoreElements()) {
- Permission o = e2.nextElement();
- if (v.contains(o))
- v.removeElement(o);
- }
-
- return v.elements();
- }
-
- private Enumeration<Permission> getGroupPositive(Principal user) {
- Enumeration<Permission> groupPositive = zeroSet.elements();
- Enumeration<Principal> e = allowedGroupsTable.keys();
- while (e.hasMoreElements()) {
- Group g = (Group)e.nextElement();
- if (g.isMember(user)) {
- AclEntry ae = allowedGroupsTable.get(g);
- groupPositive = union(ae.permissions(), groupPositive);
- }
- }
- return groupPositive;
- }
-
- private Enumeration<Permission> getGroupNegative(Principal user) {
- Enumeration<Permission> groupNegative = zeroSet.elements();
- Enumeration<Principal> e = deniedGroupsTable.keys();
- while (e.hasMoreElements()) {
- Group g = (Group)e.nextElement();
- if (g.isMember(user)) {
- AclEntry ae = deniedGroupsTable.get(g);
- groupNegative = union(ae.permissions(), groupNegative);
- }
- }
- return groupNegative;
- }
-
- private Enumeration<Permission> getIndividualPositive(Principal user) {
- Enumeration<Permission> individualPositive = zeroSet.elements();
- AclEntry ae = allowedUsersTable.get(user);
- if (ae != null)
- individualPositive = ae.permissions();
- return individualPositive;
- }
-
- private Enumeration<Permission> getIndividualNegative(Principal user) {
- Enumeration<Permission> individualNegative = zeroSet.elements();
- AclEntry ae = deniedUsersTable.get(user);
- if (ae != null)
- individualNegative = ae.permissions();
- return individualNegative;
- }
-}
-
-final class AclEnumerator implements Enumeration<AclEntry> {
- Acl acl;
- Enumeration<AclEntry> u1, u2, g1, g2;
-
- AclEnumerator(Acl acl, Hashtable<?,AclEntry> u1, Hashtable<?,AclEntry> g1,
- Hashtable<?,AclEntry> u2, Hashtable<?,AclEntry> g2) {
- this.acl = acl;
- this.u1 = u1.elements();
- this.u2 = u2.elements();
- this.g1 = g1.elements();
- this.g2 = g2.elements();
- }
-
- public boolean hasMoreElements() {
- return (u1.hasMoreElements() ||
- u2.hasMoreElements() ||
- g1.hasMoreElements() ||
- g2.hasMoreElements());
- }
-
- public AclEntry nextElement()
- {
- AclEntry o;
- synchronized (acl) {
- if (u1.hasMoreElements())
- return u1.nextElement();
- if (u2.hasMoreElements())
- return u2.nextElement();
- if (g1.hasMoreElements())
- return g1.nextElement();
- if (g2.hasMoreElements())
- return g2.nextElement();
- }
- throw new NoSuchElementException("Acl Enumerator");
- }
-}
--- a/jdk/src/java.base/share/classes/sun/security/acl/AllPermissionsImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 1996, 1997, 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.security.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * This class implements the principal interface for the set of all permissions.
- * @author Satish Dharmaraj
- */
-public class AllPermissionsImpl extends PermissionImpl {
-
- public AllPermissionsImpl(String s) {
- super(s);
- }
-
- /**
- * This function returns true if the permission passed matches the permission represented in
- * this interface.
- * @param another The Permission object to compare with.
- * @returns true always
- */
- public boolean equals(Permission another) {
- return true;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/security/acl/GroupImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 1996, 2011, 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.security.acl;
-
-import java.util.*;
-import java.security.*;
-import java.security.acl.*;
-
-/**
- * This class implements a group of principals.
- * @author Satish Dharmaraj
- */
-public class GroupImpl implements Group {
- private Vector<Principal> groupMembers = new Vector<>(50, 100);
- private String group;
-
- /**
- * Constructs a Group object with no members.
- * @param groupName the name of the group
- */
- public GroupImpl(String groupName) {
- this.group = groupName;
- }
-
- /**
- * adds the specified member to the group.
- * @param user The principal to add to the group.
- * @return true if the member was added - false if the
- * member could not be added.
- */
- public boolean addMember(Principal user) {
- if (groupMembers.contains(user))
- return false;
-
- // do not allow groups to be added to itself.
- if (group.equals(user.toString()))
- throw new IllegalArgumentException();
-
- groupMembers.addElement(user);
- return true;
- }
-
- /**
- * removes the specified member from the group.
- * @param user The principal to remove from the group.
- * @param true if the principal was removed false if
- * the principal was not a member
- */
- public boolean removeMember(Principal user) {
- return groupMembers.removeElement(user);
- }
-
- /**
- * returns the enumeration of the members in the group.
- */
- public Enumeration<? extends Principal> members() {
- return groupMembers.elements();
- }
-
- /**
- * This function returns true if the group passed matches
- * the group represented in this interface.
- * @param another The group to compare this group to.
- */
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof Group == false) {
- return false;
- }
- Group another = (Group)obj;
- return group.equals(another.toString());
- }
-
- // equals(Group) for compatibility
- public boolean equals(Group another) {
- return equals((Object)another);
- }
-
- /**
- * Prints a stringified version of the group.
- */
- public String toString() {
- return group;
- }
-
- /**
- * return a hashcode for the principal.
- */
- public int hashCode() {
- return group.hashCode();
- }
-
- /**
- * returns true if the passed principal is a member of the group.
- * @param member The principal whose membership must be checked for.
- * @return true if the principal is a member of this group,
- * false otherwise
- */
- public boolean isMember(Principal member) {
-
- //
- // if the member is part of the group (common case), return true.
- // if not, recursively search depth first in the group looking for the
- // principal.
- //
- if (groupMembers.contains(member)) {
- return true;
- } else {
- Vector<Group> alreadySeen = new Vector<>(10);
- return isMemberRecurse(member, alreadySeen);
- }
- }
-
- /**
- * return the name of the principal.
- */
- public String getName() {
- return group;
- }
-
- //
- // This function is the recursive search of groups for this
- // implementation of the Group. The search proceeds building up
- // a vector of already seen groups. Only new groups are considered,
- // thereby avoiding loops.
- //
- boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) {
- Enumeration<? extends Principal> e = members();
- while (e.hasMoreElements()) {
- boolean mem = false;
- Principal p = (Principal) e.nextElement();
-
- // if the member is in this collection, return true
- if (p.equals(member)) {
- return true;
- } else if (p instanceof GroupImpl) {
- //
- // if not recurse if the group has not been checked already.
- // Can call method in this package only if the object is an
- // instance of this class. Otherwise call the method defined
- // in the interface. (This can lead to a loop if a mixture of
- // implementations form a loop, but we live with this improbable
- // case rather than clutter the interface by forcing the
- // implementation of this method.)
- //
- GroupImpl g = (GroupImpl) p;
- alreadySeen.addElement(this);
- if (!alreadySeen.contains(g))
- mem = g.isMemberRecurse(member, alreadySeen);
- } else if (p instanceof Group) {
- Group g = (Group) p;
- if (!alreadySeen.contains(g))
- mem = g.isMember(member);
- }
-
- if (mem)
- return mem;
- }
- return false;
- }
-}
--- a/jdk/src/java.base/share/classes/sun/security/acl/OwnerImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 1996, 2006, 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.security.acl;
-
-import java.util.*;
-import java.security.*;
-import java.security.acl.*;
-
-/**
- * Class implementing the Owner interface. The
- * initial owner principal is configured as
- * part of the constructor.
- * @author Satish Dharmaraj
- */
-public class OwnerImpl implements Owner {
- private Group ownerGroup;
-
- public OwnerImpl(Principal owner) {
- ownerGroup = new GroupImpl("AclOwners");
- ownerGroup.addMember(owner);
- }
-
- /**
- * Adds an owner. Owners can modify ACL contents and can disassociate
- * ACLs from the objects they protect in the AclConfig interface.
- * The caller principal must be a part of the owners list of the ACL in
- * order to invoke this method. The initial owner is configured
- * at ACL construction time.
- * @param caller the principal who is invoking this method.
- * @param owner The owner that should be added to the owners list.
- * @return true if success, false if already an owner.
- * @exception NotOwnerException if the caller principal is not on
- * the owners list of the Acl.
- */
- public synchronized boolean addOwner(Principal caller, Principal owner)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- ownerGroup.addMember(owner);
- return false;
- }
-
- /**
- * Delete owner. If this is the last owner in the ACL, an exception is
- * raised.
- * The caller principal must be a part of the owners list of the ACL in
- * order to invoke this method.
- * @param caller the principal who is invoking this method.
- * @param owner The owner to be removed from the owners list.
- * @return true if the owner is removed, false if the owner is not part
- * of the owners list.
- * @exception NotOwnerException if the caller principal is not on
- * the owners list of the Acl.
- * @exception LastOwnerException if there is only one owner left in the group, then
- * deleteOwner would leave the ACL owner-less. This exception is raised in such a case.
- */
- public synchronized boolean deleteOwner(Principal caller, Principal owner)
- throws NotOwnerException, LastOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- Enumeration<? extends Principal> e = ownerGroup.members();
- //
- // check if there is atleast 2 members left.
- //
- Object o = e.nextElement();
- if (e.hasMoreElements())
- return ownerGroup.removeMember(owner);
- else
- throw new LastOwnerException();
-
- }
-
- /**
- * returns if the given principal belongs to the owner list.
- * @param owner The owner to check if part of the owners list
- * @return true if the passed principal is in the owner list, false if not.
- */
- public synchronized boolean isOwner(Principal owner) {
- return ownerGroup.isMember(owner);
- }
-}
--- a/jdk/src/java.base/share/classes/sun/security/acl/PermissionImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1996, 1999, 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.security.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * The PermissionImpl class implements the permission
- * interface for permissions that are strings.
- * @author Satish Dharmaraj
- */
-public class PermissionImpl implements Permission {
-
- private String permission;
-
- /**
- * Construct a permission object using a string.
- * @param permission the stringified version of the permission.
- */
- public PermissionImpl(String permission) {
- this.permission = permission;
- }
-
- /**
- * This function returns true if the object passed matches the permission
- * represented in this interface.
- * @param another The Permission object to compare with.
- * @return true if the Permission objects are equal, false otherwise
- */
- public boolean equals(Object another) {
- if (another instanceof Permission) {
- Permission p = (Permission) another;
- return permission.equals(p.toString());
- } else {
- return false;
- }
- }
-
- /**
- * Prints a stringified version of the permission.
- * @return the string representation of the Permission.
- */
- public String toString() {
- return permission;
- }
-
- /**
- * Returns a hashcode for this PermissionImpl.
- *
- * @return a hashcode for this PermissionImpl.
- */
- public int hashCode() {
- return toString().hashCode();
- }
-
-}
--- a/jdk/src/java.base/share/classes/sun/security/acl/PrincipalImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1996, 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.security.acl;
-
-import java.security.*;
-
-/**
- * This class implements the principal interface.
- *
- * @author Satish Dharmaraj
- */
-public class PrincipalImpl implements Principal {
-
- private String user;
-
- /**
- * Construct a principal from a string user name.
- * @param user The string form of the principal name.
- */
- public PrincipalImpl(String user) {
- this.user = user;
- }
-
- /**
- * This function returns true if the object passed matches
- * the principal represented in this implementation
- * @param another the Principal to compare with.
- * @return true if the Principal passed is the same as that
- * encapsulated in this object, false otherwise
- */
- public boolean equals(Object another) {
- if (another instanceof PrincipalImpl) {
- PrincipalImpl p = (PrincipalImpl) another;
- return user.equals(p.toString());
- } else
- return false;
- }
-
- /**
- * Prints a stringified version of the principal.
- */
- public String toString() {
- return user;
- }
-
- /**
- * return a hashcode for the principal.
- */
- public int hashCode() {
- return user.hashCode();
- }
-
- /**
- * return the name of the principal.
- */
- public String getName() {
- return user;
- }
-
-}
--- a/jdk/src/java.base/share/classes/sun/security/acl/WorldGroupImpl.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1996, 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.security.acl;
-
-import java.security.*;
-
-/**
- * This class implements a group of principals.
- * @author Satish Dharmaraj
- */
-public class WorldGroupImpl extends GroupImpl {
-
- public WorldGroupImpl(String s) {
- super(s);
- }
-
- /**
- * returns true for all passed principals
- * @param member The principal whose membership must be checked in this Group.
- * @return true always since this is the "world" group.
- */
- public boolean isMember(Principal member) {
- return true;
- }
-}
--- a/jdk/src/java.management/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.management/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Tue Feb 24 10:52:02 2015 -0800
@@ -45,7 +45,7 @@
* All methods throw a {@code NullPointerException} if any input argument is
* {@code null} unless it's stated otherwise.
*
- * @see ManagementFactory#getPlatformMXBeans(Class)
+ * @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
*/
@jdk.Exported
public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
--- a/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java Tue Feb 24 10:52:02 2015 -0800
@@ -31,12 +31,13 @@
import static java.lang.Thread.State.*;
/**
- * Thread information. <tt>ThreadInfo</tt> contains the information
+ * Thread information. {@code ThreadInfo} contains the information
* about a thread including:
* <h3>General thread information</h3>
* <ul>
* <li>Thread ID.</li>
* <li>Name of the thread.</li>
+ * <li>Whether a thread is a daemon thread</li>
* </ul>
*
* <h3>Execution information</h3>
@@ -57,6 +58,7 @@
* <li>List of object monitors locked by the thread.</li>
* <li>List of <a href="LockInfo.html#OwnableSynchronizer">
* ownable synchronizers</a> locked by the thread.</li>
+ * <li>Thread priority</li>
* </ul>
*
* <h4><a name="SyncStats">Synchronization Statistics</a></h4>
@@ -78,7 +80,7 @@
* the system, not for synchronization control.
*
* <h4>MXBean Mapping</h4>
- * <tt>ThreadInfo</tt> is mapped to a {@link CompositeData CompositeData}
+ * {@code ThreadInfo} is mapped to a {@link CompositeData CompositeData}
* with attributes as specified in
* the {@link #from from} method.
*
@@ -100,9 +102,11 @@
private String lockName;
private long lockOwnerId;
private String lockOwnerName;
+ private boolean daemon;
private boolean inNative;
private boolean suspended;
private Thread.State threadState;
+ private int priority;
private StackTraceElement[] stackTrace;
private MonitorInfo[] lockedMonitors;
private LockInfo[] lockedSynchronizers;
@@ -229,6 +233,8 @@
this.blockedTime = blockedTime;
this.waitedCount = waitedCount;
this.waitedTime = waitedTime;
+ this.daemon = t.isDaemon();
+ this.priority = t.getPriority();
if (lockObj == null) {
this.lock = null;
@@ -256,7 +262,7 @@
}
/*
- * Constructs a <tt>ThreadInfo</tt> object from a
+ * Constructs a {@code ThreadInfo} object from a
* {@link CompositeData CompositeData}.
*/
private ThreadInfo(CompositeData cd) {
@@ -277,7 +283,7 @@
stackTrace = ticd.stackTrace();
// 6.0 attributes
- if (ticd.isCurrentVersion()) {
+ if (ticd.hasV6()) {
lock = ticd.lockInfo();
lockedMonitors = ticd.lockedMonitors();
lockedSynchronizers = ticd.lockedSynchronizers();
@@ -300,10 +306,20 @@
lockedMonitors = EMPTY_MONITORS;
lockedSynchronizers = EMPTY_SYNCS;
}
+
+ // 9.0 attributes
+ if (ticd.isCurrentVersion()) {
+ daemon = ticd.isDaemon();
+ priority = ticd.getPriority();
+ } else {
+ // Not ideal, but unclear what else we can do.
+ daemon = false;
+ priority = Thread.NORM_PRIORITY;
+ }
}
/**
- * Returns the ID of the thread associated with this <tt>ThreadInfo</tt>.
+ * Returns the ID of the thread associated with this {@code ThreadInfo}.
*
* @return the ID of the associated thread.
*/
@@ -312,7 +328,7 @@
}
/**
- * Returns the name of the thread associated with this <tt>ThreadInfo</tt>.
+ * Returns the name of the thread associated with this {@code ThreadInfo}.
*
* @return the name of the associated thread.
*/
@@ -321,9 +337,9 @@
}
/**
- * Returns the state of the thread associated with this <tt>ThreadInfo</tt>.
+ * Returns the state of the thread associated with this {@code ThreadInfo}.
*
- * @return <tt>Thread.State</tt> of the associated thread.
+ * @return {@code Thread.State} of the associated thread.
*/
public Thread.State getThreadState() {
return threadState;
@@ -331,13 +347,13 @@
/**
* Returns the approximate accumulated elapsed time (in milliseconds)
- * that the thread associated with this <tt>ThreadInfo</tt>
+ * that the thread associated with this {@code ThreadInfo}
* has blocked to enter or reenter a monitor
* since thread contention monitoring is enabled.
* I.e. the total accumulated time the thread has been in the
* {@link java.lang.Thread.State#BLOCKED BLOCKED} state since thread
* contention monitoring was last enabled.
- * This method returns <tt>-1</tt> if thread contention monitoring
+ * This method returns {@code -1} if thread contention monitoring
* is disabled.
*
* <p>The Java virtual machine may measure the time with a high
@@ -345,8 +361,8 @@
* the thread contention monitoring is reenabled.
*
* @return the approximate accumulated elapsed time in milliseconds
- * that a thread entered the <tt>BLOCKED</tt> state;
- * <tt>-1</tt> if thread contention monitoring is disabled.
+ * that a thread entered the {@code BLOCKED} state;
+ * {@code -1} if thread contention monitoring is disabled.
*
* @throws java.lang.UnsupportedOperationException if the Java
* virtual machine does not support this operation.
@@ -360,13 +376,13 @@
/**
* Returns the total number of times that
- * the thread associated with this <tt>ThreadInfo</tt>
+ * the thread associated with this {@code ThreadInfo}
* blocked to enter or reenter a monitor.
* I.e. the number of times a thread has been in the
* {@link java.lang.Thread.State#BLOCKED BLOCKED} state.
*
* @return the total number of times that the thread
- * entered the <tt>BLOCKED</tt> state.
+ * entered the {@code BLOCKED} state.
*/
public long getBlockedCount() {
return blockedCount;
@@ -374,14 +390,14 @@
/**
* Returns the approximate accumulated elapsed time (in milliseconds)
- * that the thread associated with this <tt>ThreadInfo</tt>
+ * that the thread associated with this {@code ThreadInfo}
* has waited for notification
* since thread contention monitoring is enabled.
* I.e. the total accumulated time the thread has been in the
* {@link java.lang.Thread.State#WAITING WAITING}
* or {@link java.lang.Thread.State#TIMED_WAITING TIMED_WAITING} state
* since thread contention monitoring is enabled.
- * This method returns <tt>-1</tt> if thread contention monitoring
+ * This method returns {@code -1} if thread contention monitoring
* is disabled.
*
* <p>The Java virtual machine may measure the time with a high
@@ -389,9 +405,9 @@
* the thread contention monitoring is reenabled.
*
* @return the approximate accumulated elapsed time in milliseconds
- * that a thread has been in the <tt>WAITING</tt> or
- * <tt>TIMED_WAITING</tt> state;
- * <tt>-1</tt> if thread contention monitoring is disabled.
+ * that a thread has been in the {@code WAITING} or
+ * {@code TIMED_WAITING} state;
+ * {@code -1} if thread contention monitoring is disabled.
*
* @throws java.lang.UnsupportedOperationException if the Java
* virtual machine does not support this operation.
@@ -405,29 +421,29 @@
/**
* Returns the total number of times that
- * the thread associated with this <tt>ThreadInfo</tt>
+ * the thread associated with this {@code ThreadInfo}
* waited for notification.
* I.e. the number of times that a thread has been
* in the {@link java.lang.Thread.State#WAITING WAITING}
* or {@link java.lang.Thread.State#TIMED_WAITING TIMED_WAITING} state.
*
* @return the total number of times that the thread
- * was in the <tt>WAITING</tt> or <tt>TIMED_WAITING</tt> state.
+ * was in the {@code WAITING} or {@code TIMED_WAITING} state.
*/
public long getWaitedCount() {
return waitedCount;
}
/**
- * Returns the <tt>LockInfo</tt> of an object for which
- * the thread associated with this <tt>ThreadInfo</tt>
+ * Returns the {@code LockInfo} of an object for which
+ * the thread associated with this {@code ThreadInfo}
* is blocked waiting.
* A thread can be blocked waiting for one of the following:
* <ul>
* <li>an object monitor to be acquired for entering or reentering
* a synchronization block/method.
* <br>The thread is in the {@link java.lang.Thread.State#BLOCKED BLOCKED}
- * state waiting to enter the <tt>synchronized</tt> statement
+ * state waiting to enter the {@code synchronized} statement
* or method.
* </li>
* <li>an object monitor to be notified by another thread.
@@ -448,11 +464,11 @@
* or a {@link java.util.concurrent.locks.Condition Condition}.</li>
* </ul>
*
- * <p>This method returns <tt>null</tt> if the thread is not in any of
+ * <p>This method returns {@code null} if the thread is not in any of
* the above conditions.
*
- * @return <tt>LockInfo</tt> of an object for which the thread
- * is blocked waiting if any; <tt>null</tt> otherwise.
+ * @return {@code LockInfo} of an object for which the thread
+ * is blocked waiting if any; {@code null} otherwise.
* @since 1.6
*/
public LockInfo getLockInfo() {
@@ -462,19 +478,19 @@
/**
* Returns the {@link LockInfo#toString string representation}
* of an object for which the thread associated with this
- * <tt>ThreadInfo</tt> is blocked waiting.
+ * {@code ThreadInfo} is blocked waiting.
* This method is equivalent to calling:
* <blockquote>
* <pre>
* getLockInfo().toString()
* </pre></blockquote>
*
- * <p>This method will return <tt>null</tt> if this thread is not blocked
+ * <p>This method will return {@code null} if this thread is not blocked
* waiting for any object or if the object is not owned by any thread.
*
* @return the string representation of the object on which
* the thread is blocked if any;
- * <tt>null</tt> otherwise.
+ * {@code null} otherwise.
*
* @see #getLockInfo
*/
@@ -484,14 +500,14 @@
/**
* Returns the ID of the thread which owns the object
- * for which the thread associated with this <tt>ThreadInfo</tt>
+ * for which the thread associated with this {@code ThreadInfo}
* is blocked waiting.
- * This method will return <tt>-1</tt> if this thread is not blocked
+ * This method will return {@code -1} if this thread is not blocked
* waiting for any object or if the object is not owned by any thread.
*
* @return the thread ID of the owner thread of the object
* this thread is blocked on;
- * <tt>-1</tt> if this thread is not blocked
+ * {@code -1} if this thread is not blocked
* or if the object is not owned by any thread.
*
* @see #getLockInfo
@@ -502,14 +518,14 @@
/**
* Returns the name of the thread which owns the object
- * for which the thread associated with this <tt>ThreadInfo</tt>
+ * for which the thread associated with this {@code ThreadInfo}
* is blocked waiting.
- * This method will return <tt>null</tt> if this thread is not blocked
+ * This method will return {@code null} if this thread is not blocked
* waiting for any object or if the object is not owned by any thread.
*
* @return the name of the thread that owns the object
* this thread is blocked on;
- * <tt>null</tt> if this thread is not blocked
+ * {@code null} if this thread is not blocked
* or if the object is not owned by any thread.
*
* @see #getLockInfo
@@ -520,7 +536,7 @@
/**
* Returns the stack trace of the thread
- * associated with this <tt>ThreadInfo</tt>.
+ * associated with this {@code ThreadInfo}.
* If no stack trace was requested for this thread info, this method
* will return a zero-length array.
* If the returned array is of non-zero length then the first element of
@@ -532,42 +548,67 @@
* <p>Some Java virtual machines may, under some circumstances, omit one
* or more stack frames from the stack trace. In the extreme case,
* a virtual machine that has no stack trace information concerning
- * the thread associated with this <tt>ThreadInfo</tt>
+ * the thread associated with this {@code ThreadInfo}
* is permitted to return a zero-length array from this method.
*
- * @return an array of <tt>StackTraceElement</tt> objects of the thread.
+ * @return an array of {@code StackTraceElement} objects of the thread.
*/
public StackTraceElement[] getStackTrace() {
return stackTrace;
}
/**
- * Tests if the thread associated with this <tt>ThreadInfo</tt>
- * is suspended. This method returns <tt>true</tt> if
+ * Tests if the thread associated with this {@code ThreadInfo}
+ * is suspended. This method returns {@code true} if
* {@link Thread#suspend} has been called.
*
- * @return <tt>true</tt> if the thread is suspended;
- * <tt>false</tt> otherwise.
+ * @return {@code true} if the thread is suspended;
+ * {@code false} otherwise.
*/
public boolean isSuspended() {
return suspended;
}
/**
- * Tests if the thread associated with this <tt>ThreadInfo</tt>
+ * Tests if the thread associated with this {@code ThreadInfo}
* is executing native code via the Java Native Interface (JNI).
* The JNI native code does not include
* the virtual machine support code or the compiled native
* code generated by the virtual machine.
*
- * @return <tt>true</tt> if the thread is executing native code;
- * <tt>false</tt> otherwise.
+ * @return {@code true} if the thread is executing native code;
+ * {@code false} otherwise.
*/
public boolean isInNative() {
return inNative;
}
/**
+ * Tests if the thread associated with this {@code ThreadInfo} is
+ * a {@linkplain Thread#isDaemon daemon thread}.
+ *
+ * @return {@code true} if the thread is a daemon thread,
+ * {@code false} otherwise.
+ * @see Thread#isDaemon
+ * @since 1.9
+ */
+ public boolean isDaemon() {
+ return daemon;
+ }
+
+ /**
+ * Returns the {@linkplain Thread#getPriority() thread priority} of the
+ * thread associated with this {@code ThreadInfo}.
+ *
+ * @return The priority of the thread associated with this
+ * {@code ThreadInfo}.
+ * @since 1.9
+ */
+ public int getPriority() {
+ return priority;
+ }
+
+ /**
* Returns a string representation of this thread info.
* The format of this string depends on the implementation.
* The returned string will typically include
@@ -580,6 +621,8 @@
*/
public String toString() {
StringBuilder sb = new StringBuilder("\"" + getThreadName() + "\"" +
+ (daemon ? " daemon" : "") +
+ " prio=" + priority +
" Id=" + getThreadId() + " " +
getThreadState());
if (getLockName() != null) {
@@ -647,9 +690,9 @@
private static final int MAX_FRAMES = 8;
/**
- * Returns a <tt>ThreadInfo</tt> object represented by the
- * given <tt>CompositeData</tt>.
- * The given <tt>CompositeData</tt> must contain the following attributes
+ * Returns a {@code ThreadInfo} object represented by the
+ * given {@code CompositeData}.
+ * The given {@code CompositeData} must contain the following attributes
* unless otherwise specified below:
* <blockquote>
* <table border summary="The attributes and their types the given CompositeData contains">
@@ -659,67 +702,67 @@
* </tr>
* <tr>
* <td>threadId</td>
- * <td><tt>java.lang.Long</tt></td>
+ * <td>{@code java.lang.Long}</td>
* </tr>
* <tr>
* <td>threadName</td>
- * <td><tt>java.lang.String</tt></td>
+ * <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>threadState</td>
- * <td><tt>java.lang.String</tt></td>
+ * <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>suspended</td>
- * <td><tt>java.lang.Boolean</tt></td>
+ * <td>{@code java.lang.Boolean}</td>
* </tr>
* <tr>
* <td>inNative</td>
- * <td><tt>java.lang.Boolean</tt></td>
+ * <td>{@code java.lang.Boolean}</td>
* </tr>
* <tr>
* <td>blockedCount</td>
- * <td><tt>java.lang.Long</tt></td>
+ * <td>{@code java.lang.Long}</td>
* </tr>
* <tr>
* <td>blockedTime</td>
- * <td><tt>java.lang.Long</tt></td>
+ * <td>{@code java.lang.Long}</td>
* </tr>
* <tr>
* <td>waitedCount</td>
- * <td><tt>java.lang.Long</tt></td>
+ * <td>{@code java.lang.Long}</td>
* </tr>
* <tr>
* <td>waitedTime</td>
- * <td><tt>java.lang.Long</tt></td>
+ * <td>{@code java.lang.Long}</td>
* </tr>
* <tr>
* <td>lockInfo</td>
- * <td><tt>javax.management.openmbean.CompositeData</tt>
+ * <td>{@code javax.management.openmbean.CompositeData}
* - the mapped type for {@link LockInfo} as specified in the
* {@link LockInfo#from} method.
* <p>
- * If <tt>cd</tt> does not contain this attribute,
- * the <tt>LockInfo</tt> object will be constructed from
- * the value of the <tt>lockName</tt> attribute. </td>
+ * If {@code cd} does not contain this attribute,
+ * the {@code LockInfo} object will be constructed from
+ * the value of the {@code lockName} attribute. </td>
* </tr>
* <tr>
* <td>lockName</td>
- * <td><tt>java.lang.String</tt></td>
+ * <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>lockOwnerId</td>
- * <td><tt>java.lang.Long</tt></td>
+ * <td>{@code java.lang.Long}</td>
* </tr>
* <tr>
* <td>lockOwnerName</td>
- * <td><tt>java.lang.String</tt></td>
+ * <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td><a name="StackTrace">stackTrace</a></td>
- * <td><tt>javax.management.openmbean.CompositeData[]</tt>
+ * <td>{@code javax.management.openmbean.CompositeData[]}
* <p>
- * Each element is a <tt>CompositeData</tt> representing
+ * Each element is a {@code CompositeData} representing
* StackTraceElement containing the following attributes:
* <blockquote>
* <table cellspacing=1 cellpadding=0 summary="The attributes and their types the given CompositeData contains">
@@ -729,23 +772,23 @@
* </tr>
* <tr>
* <td>className</td>
- * <td><tt>java.lang.String</tt></td>
+ * <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>methodName</td>
- * <td><tt>java.lang.String</tt></td>
+ * <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>fileName</td>
- * <td><tt>java.lang.String</tt></td>
+ * <td>{@code java.lang.String}</td>
* </tr>
* <tr>
* <td>lineNumber</td>
- * <td><tt>java.lang.Integer</tt></td>
+ * <td>{@code java.lang.Integer}</td>
* </tr>
* <tr>
* <td>nativeMethod</td>
- * <td><tt>java.lang.Boolean</tt></td>
+ * <td>{@code java.lang.Boolean}</td>
* </tr>
* </table>
* </blockquote>
@@ -753,35 +796,43 @@
* </tr>
* <tr>
* <td>lockedMonitors</td>
- * <td><tt>javax.management.openmbean.CompositeData[]</tt>
+ * <td>{@code javax.management.openmbean.CompositeData[]}
* whose element type is the mapped type for
* {@link MonitorInfo} as specified in the
* {@link MonitorInfo#from Monitor.from} method.
* <p>
- * If <tt>cd</tt> does not contain this attribute,
+ * If {@code cd} does not contain this attribute,
* this attribute will be set to an empty array. </td>
* </tr>
* <tr>
* <td>lockedSynchronizers</td>
- * <td><tt>javax.management.openmbean.CompositeData[]</tt>
+ * <td>{@code javax.management.openmbean.CompositeData[]}
* whose element type is the mapped type for
* {@link LockInfo} as specified in the {@link LockInfo#from} method.
* <p>
- * If <tt>cd</tt> does not contain this attribute,
+ * If {@code cd} does not contain this attribute,
* this attribute will be set to an empty array. </td>
* </tr>
+ * <tr>
+ * <td>daemon</td>
+ * <td>{@code java.lang.Boolean}</td>
+ * </tr>
+ * <tr>
+ * <td>priority</td>
+ * <td>{@code java.lang.Integer}</td>
+ * </tr>
* </table>
* </blockquote>
*
- * @param cd <tt>CompositeData</tt> representing a <tt>ThreadInfo</tt>
+ * @param cd {@code CompositeData} representing a {@code ThreadInfo}
*
- * @throws IllegalArgumentException if <tt>cd</tt> does not
- * represent a <tt>ThreadInfo</tt> with the attributes described
+ * @throws IllegalArgumentException if {@code cd} does not
+ * represent a {@code ThreadInfo} with the attributes described
* above.
*
- * @return a <tt>ThreadInfo</tt> object represented
- * by <tt>cd</tt> if <tt>cd</tt> is not <tt>null</tt>;
- * <tt>null</tt> otherwise.
+ * @return a {@code ThreadInfo} object represented
+ * by {@code cd} if {@code cd} is not {@code null};
+ * {@code null} otherwise.
*/
public static ThreadInfo from(CompositeData cd) {
if (cd == null) {
@@ -798,12 +849,12 @@
/**
* Returns an array of {@link MonitorInfo} objects, each of which
* represents an object monitor currently locked by the thread
- * associated with this <tt>ThreadInfo</tt>.
+ * associated with this {@code ThreadInfo}.
* If no locked monitor was requested for this thread info or
* no monitor is locked by the thread, this method
* will return a zero-length array.
*
- * @return an array of <tt>MonitorInfo</tt> objects representing
+ * @return an array of {@code MonitorInfo} objects representing
* the object monitors locked by the thread.
*
* @since 1.6
@@ -816,11 +867,11 @@
* Returns an array of {@link LockInfo} objects, each of which
* represents an <a href="LockInfo.html#OwnableSynchronizer">ownable
* synchronizer</a> currently locked by the thread associated with
- * this <tt>ThreadInfo</tt>. If no locked synchronizer was
+ * this {@code ThreadInfo}. If no locked synchronizer was
* requested for this thread info or no synchronizer is locked by
* the thread, this method will return a zero-length array.
*
- * @return an array of <tt>LockInfo</tt> objects representing
+ * @return an array of {@code LockInfo} objects representing
* the ownable synchronizers locked by the thread.
*
* @since 1.6
--- a/jdk/src/java.management/share/classes/sun/management/AgentConfigurationError.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.management/share/classes/sun/management/AgentConfigurationError.java Tue Feb 24 10:52:02 2015 -0800
@@ -87,26 +87,6 @@
"agent.err.connector.server.io.error";
public static final String INVALID_OPTION =
"agent.err.invalid.option";
- public static final String INVALID_SNMP_PORT =
- "agent.err.invalid.snmp.port";
- public static final String INVALID_SNMP_TRAP_PORT =
- "agent.err.invalid.snmp.trap.port";
- public static final String UNKNOWN_SNMP_INTERFACE =
- "agent.err.unknown.snmp.interface";
- public static final String SNMP_ACL_FILE_NOT_SET =
- "agent.err.acl.file.notset";
- public static final String SNMP_ACL_FILE_NOT_FOUND =
- "agent.err.acl.file.notfound";
- public static final String SNMP_ACL_FILE_NOT_READABLE =
- "agent.err.acl.file.not.readable";
- public static final String SNMP_ACL_FILE_READ_FAILED =
- "agent.err.acl.file.read.failed";
- public static final String SNMP_ACL_FILE_ACCESS_NOT_RESTRICTED =
- "agent.err.acl.file.access.notrestricted";
- public static final String SNMP_ADAPTOR_START_FAILED =
- "agent.err.snmp.adaptor.start.failed";
- public static final String SNMP_MIB_INIT_FAILED =
- "agent.err.snmp.mib.init.failed";
public static final String INVALID_STATE =
"agent.err.invalid.state";
--- a/jdk/src/java.management/share/classes/sun/management/ThreadInfoCompositeData.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.management/share/classes/sun/management/ThreadInfoCompositeData.java Tue Feb 24 10:52:02 2015 -0800
@@ -43,23 +43,30 @@
private final ThreadInfo threadInfo;
private final CompositeData cdata;
private final boolean currentVersion;
+ private final boolean hasV6;
private ThreadInfoCompositeData(ThreadInfo ti) {
this.threadInfo = ti;
this.currentVersion = true;
this.cdata = null;
+ this.hasV6 = true;
}
private ThreadInfoCompositeData(CompositeData cd) {
this.threadInfo = null;
this.currentVersion = ThreadInfoCompositeData.isCurrentVersion(cd);
this.cdata = cd;
+ this.hasV6 = ThreadInfoCompositeData.hasV6(cd);
}
public ThreadInfo getThreadInfo() {
return threadInfo;
}
+ public boolean hasV6() {
+ return hasV6;
+ }
+
public boolean isCurrentVersion() {
return currentVersion;
}
@@ -124,6 +131,8 @@
threadInfo.isInNative(),
lockedMonitorsData,
lockedSyncsData,
+ threadInfo.isDaemon(),
+ threadInfo.getPriority(),
};
try {
@@ -151,6 +160,8 @@
private static final String STACK_TRACE = "stackTrace";
private static final String SUSPENDED = "suspended";
private static final String IN_NATIVE = "inNative";
+ private static final String DAEMON = "daemon";
+ private static final String PRIORITY = "priority";
private static final String LOCKED_MONITORS = "lockedMonitors";
private static final String LOCKED_SYNCS = "lockedSynchronizers";
@@ -171,6 +182,8 @@
IN_NATIVE,
LOCKED_MONITORS,
LOCKED_SYNCS,
+ DAEMON,
+ PRIORITY,
};
// New attributes added in 6.0 ThreadInfo
@@ -180,9 +193,16 @@
LOCKED_SYNCS,
};
+ private static final String[] threadInfoV9Attributes = {
+ DAEMON,
+ PRIORITY,
+ };
+
// Current version of ThreadInfo
private static final CompositeType threadInfoCompositeType;
// Previous version of ThreadInfo
+ private static final CompositeType threadInfoV6CompositeType;
+ // Previous-previous version of ThreadInfo
private static final CompositeType threadInfoV5CompositeType;
private static final CompositeType lockInfoCompositeType;
static {
@@ -193,7 +213,7 @@
String[] itemNames =
threadInfoCompositeType.keySet().toArray(new String[0]);
int numV5Attributes = threadInfoItemNames.length -
- threadInfoV6Attributes.length;
+ threadInfoV6Attributes.length - threadInfoV9Attributes.length;
String[] v5ItemNames = new String[numV5Attributes];
String[] v5ItemDescs = new String[numV5Attributes];
OpenType<?>[] v5ItemTypes = new OpenType<?>[numV5Attributes];
@@ -213,6 +233,31 @@
v5ItemNames,
v5ItemDescs,
v5ItemTypes);
+
+
+ // Form a CompositeType for JDK 6.0 ThreadInfo version
+ int numV6Attributes = threadInfoItemNames.length -
+ threadInfoV9Attributes.length;
+ String[] v6ItemNames = new String[numV6Attributes];
+ String[] v6ItemDescs = new String[numV6Attributes];
+ OpenType<?>[] v6ItemTypes = new OpenType<?>[numV6Attributes];
+ i = 0;
+ for (String n : itemNames) {
+ if (isV5Attribute(n) || isV6Attribute(n)) {
+ v6ItemNames[i] = n;
+ v6ItemDescs[i] = threadInfoCompositeType.getDescription(n);
+ v6ItemTypes[i] = threadInfoCompositeType.getType(n);
+ i++;
+ }
+ }
+
+ threadInfoV6CompositeType =
+ new CompositeType("java.lang.management.ThreadInfo",
+ "Java SE 6 java.lang.management.ThreadInfo",
+ v6ItemNames,
+ v6ItemDescs,
+ v6ItemTypes);
+
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
@@ -236,6 +281,20 @@
return false;
}
}
+ for (String n : threadInfoV9Attributes) {
+ if (itemName.equals(n)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean isV6Attribute(String itemName) {
+ for (String n : threadInfoV9Attributes) {
+ if (itemName.equals(n)) {
+ return false;
+ }
+ }
return true;
}
@@ -247,6 +306,15 @@
return isTypeMatched(threadInfoCompositeType, cd.getCompositeType());
}
+ private static boolean hasV6(CompositeData cd) {
+ if (cd == null) {
+ throw new NullPointerException("Null CompositeData");
+ }
+
+ return isTypeMatched(threadInfoCompositeType, cd.getCompositeType()) ||
+ isTypeMatched(threadInfoV6CompositeType, cd.getCompositeType());
+ }
+
public long threadId() {
return getLong(cdata, THREAD_ID);
}
@@ -304,6 +372,14 @@
return getBoolean(cdata, IN_NATIVE);
}
+ public boolean isDaemon() {
+ return getBoolean(cdata, DAEMON);
+ }
+
+ public int getPriority(){
+ return getInt(cdata, PRIORITY);
+ }
+
public StackTraceElement[] stackTrace() {
CompositeData[] stackTraceData =
(CompositeData[]) cdata.get(STACK_TRACE);
@@ -368,9 +444,10 @@
if (!isTypeMatched(threadInfoCompositeType, type)) {
currentVersion = false;
// check if cd is an older version
- if (!isTypeMatched(threadInfoV5CompositeType, type)) {
- throw new IllegalArgumentException(
- "Unexpected composite type for ThreadInfo");
+ if (!isTypeMatched(threadInfoV5CompositeType, type) &&
+ !isTypeMatched(threadInfoV6CompositeType, type)) {
+ throw new IllegalArgumentException(
+ "Unexpected composite type for ThreadInfo");
}
}
--- a/jdk/src/java.management/share/classes/sun/management/resources/agent.properties Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/java.management/share/classes/sun/management/resources/agent.properties Tue Feb 24 10:52:02 2015 -0800
@@ -1,4 +1,3 @@
-#
#
# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -24,9 +23,6 @@
# questions.
#
-# Localizations for Level names. For the US locale
-# these are the same as the non-localized level name.
-
agent.err.error = Error
agent.err.exception = Exception thrown by the agent
agent.err.warning = Warning
@@ -67,27 +63,9 @@
agent.err.connector.server.io.error = JMX connector server communication error
agent.err.invalid.option = Invalid option specified
-agent.err.invalid.snmp.port = Invalid com.sun.management.snmp.port number
-agent.err.invalid.snmp.trap.port = Invalid com.sun.management.snmp.trap number
-agent.err.unknown.snmp.interface = Unknown SNMP interface
-agent.err.acl.file.notset = No SNMP ACL file is specified but com.sun.management.snmp.acl=true
-agent.err.acl.file.notfound = SNMP ACL file not found
-agent.err.acl.file.not.readable = SNMP ACL file not readable
-agent.err.acl.file.read.failed = Failed in reading SNMP ACL file
-agent.err.acl.file.access.notrestricted = Password file read access must be restricted
-
-agent.err.snmp.adaptor.start.failed = Failed to start SNMP adaptor with address
-agent.err.snmp.mib.init.failed = Failed to initialize SNMP MIB with error
jmxremote.ConnectorBootstrap.starting = Starting JMX Connector Server:
jmxremote.ConnectorBootstrap.noAuthentication = No Authentication
jmxremote.ConnectorBootstrap.ready = JMX Connector ready at: {0}
jmxremote.ConnectorBootstrap.password.readonly = Password file read access must be restricted: {0}
jmxremote.ConnectorBootstrap.file.readonly = File read access must be restricted: {0}
-
-jmxremote.AdaptorBootstrap.getTargetList.processing = Processing ACL
-jmxremote.AdaptorBootstrap.getTargetList.adding = Adding target: {0}
-jmxremote.AdaptorBootstrap.getTargetList.starting = Starting Adaptor Server:
-jmxremote.AdaptorBootstrap.getTargetList.initialize1 = Adaptor ready.
-jmxremote.AdaptorBootstrap.getTargetList.initialize2 = SNMP Adaptor ready on: {0}:{1}
-jmxremote.AdaptorBootstrap.getTargetList.terminate = terminate {0}
--- a/jdk/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java Tue Feb 24 10:52:02 2015 -0800
@@ -46,7 +46,7 @@
* Constructs an <code>AttachOperationFailedException</code> with
* the specified detail message.
*
- * @param s the detail message.
+ * @param message the detail message.
*/
public AttachOperationFailedException(String message) {
super(message);
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java Tue Feb 24 10:52:02 2015 -0800
@@ -145,7 +145,7 @@
* not be done from the client's event handler thread.
* <p>
* The resumption of other threads during the invocation can be prevented
- * by specifying the {@link #INVOKE_SINGLE_THREADED}
+ * by specifying the {@link ClassType#INVOKE_SINGLE_THREADED}
* bit flag in the <code>options</code> argument; however,
* there is no protection against or recovery from the deadlocks
* described above, so this option should be used with great caution.
--- a/jdk/test/TEST.groups Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/TEST.groups Tue Feb 24 10:52:02 2015 -0800
@@ -1,4 +1,4 @@
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2015, 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
@@ -567,7 +567,6 @@
javax/smartcardio \
javax/sql/rowset \
javax/xml/crypto \
- sun/security/acl \
sun/security/jgss \
sun/security/krb5 \
java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java \
--- a/jdk/test/java/lang/management/CompositeData/ThreadInfoCompositeData.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/java/lang/management/CompositeData/ThreadInfoCompositeData.java Tue Feb 24 10:52:02 2015 -0800
@@ -147,6 +147,11 @@
info.getLockOwnerName() + " expected = " +
values[LOCK_OWNER_NAME]);
}
+ if (!values[DAEMON].equals(info.isDaemon())) {
+ throw new RuntimeException("Daemon = " +
+ info.isDaemon() + " expected = " +
+ values[DAEMON]);
+ }
checkStackTrace(info.getStackTrace());
@@ -258,8 +263,11 @@
private static final int SUSPENDED = 11;
private static final int IN_NATIVE = 12;
private static final int NUM_V5_ATTS = 13;
- // JDK 6.0 ThreadInfo attribtues
+ // JDK 6.0 ThreadInfo attributes
private static final int LOCK_INFO = 13;
+ // JDK 9.0 ThreadInfo attributes
+ private static final int DAEMON = 14;
+ private static final int PRIORITY = 15;
private static final String[] validItemNames = {
"threadId",
@@ -276,6 +284,8 @@
"suspended",
"inNative",
"lockInfo",
+ "daemon",
+ "priority",
};
private static OpenType[] validItemTypes = {
@@ -293,6 +303,8 @@
SimpleType.BOOLEAN,
SimpleType.BOOLEAN,
null, // CompositeType for LockInfo
+ SimpleType.BOOLEAN,
+ SimpleType.INTEGER,
};
private static Object[] values = {
@@ -310,6 +322,8 @@
new Boolean(false),
new Boolean(false),
null, // To be initialized to lockInfoCD
+ new Boolean(false),
+ Thread.NORM_PRIORITY,
};
private static final String[] steItemNames = {
@@ -381,6 +395,8 @@
"suspended",
"inNative",
"lockInfo",
+ "daemon",
+ "priority",
};
private static final OpenType[] badItemTypes = {
SimpleType.LONG,
@@ -397,6 +413,8 @@
SimpleType.BOOLEAN,
SimpleType.BOOLEAN,
SimpleType.LONG, // bad type
+ SimpleType.BOOLEAN,
+ SimpleType.INTEGER,
};
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadDaemonTest.java Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * 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.
+ */
+
+import java.lang.management.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+/*
+ * @test
+ * @bug 6588467
+ * @summary Basic test of ThreadInfo.isDaemon
+ * @author Jeremy Manson
+ */
+public class ThreadDaemonTest {
+
+ public static void main(String[] args) throws Exception {
+ final int NUM_THREADS = 20;
+ final String THREAD_PREFIX = "ThreadDaemonTest-";
+
+ final CountDownLatch started = new CountDownLatch(NUM_THREADS);
+ final CountDownLatch finished = new CountDownLatch(1);
+ final AtomicReference<Exception> fail = new AtomicReference<>(null);
+
+ Thread[] allThreads = new Thread[NUM_THREADS];
+ ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
+ Random rand = new Random();
+
+ for (int i = 0; i < NUM_THREADS; i++) {
+ allThreads[i] = new Thread(new Runnable() {
+ public void run() {
+ try {
+ started.countDown();
+ finished.await();
+ } catch (InterruptedException e) {
+ fail.set(new Exception(
+ "Unexpected InterruptedException"));
+ }
+ }
+ }, THREAD_PREFIX + i);
+ allThreads[i].setDaemon(rand.nextBoolean());
+ allThreads[i].start();
+ }
+
+ started.await();
+ try {
+ ThreadInfo[] allThreadInfos = mbean.dumpAllThreads(false, false);
+ int count = 0;
+ for (int i = 0; i < allThreadInfos.length; i++) {
+ String threadName = allThreadInfos[i].getThreadName();
+ if (threadName.startsWith(THREAD_PREFIX)) {
+ count++;
+ String[] nameAndNumber = threadName.split("-");
+ int threadNum = Integer.parseInt(nameAndNumber[1]);
+ if (allThreads[threadNum].isDaemon() !=
+ allThreadInfos[i].isDaemon()) {
+ throw new RuntimeException(
+ allThreads[threadNum] + " is not like " +
+ allThreadInfos[i] + ". TEST FAILED.");
+ }
+ }
+ }
+ if (count != NUM_THREADS) {
+ throw new RuntimeException("Wrong number of threads examined");
+ }
+ }
+ finally { finished.countDown(); }
+
+ for (int i = 0; i < NUM_THREADS; i++) {
+ allThreads[i].join();
+ }
+ if (fail.get() != null) {
+ throw fail.get();
+ }
+ }
+}
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadDump.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadDump.java Tue Feb 24 10:52:02 2015 -0800
@@ -34,6 +34,7 @@
public static void printThreadInfo(ThreadInfo ti) {
StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" +
+ (ti.isDaemon() ? " daemon" : "") +
" Id=" + ti.getThreadId() +
" in " + ti.getThreadState());
if (ti.getLockName() != null) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * 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.
+ */
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import jdk.testlibrary.FileUtils;
+import jdk.testlibrary.JDKToolFinder;
+import static java.lang.String.format;
+import static java.util.Arrays.asList;
+
+/*
+ * @test
+ * @bug 8064924
+ * @summary Basic test for URLStreamHandlerProvider
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
+ * @compile Basic.java Child.java
+ * @run main Basic
+ */
+
+public class Basic {
+
+ static final Path TEST_SRC = Paths.get(System.getProperty("test.src", "."));
+ static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", "."));
+
+ public static void main(String[] args) throws Throwable {
+ unknownProtocol("foo", UNKNOWN);
+ unknownProtocol("bar", UNKNOWN);
+ viaProvider("baz", KNOWN);
+ viaProvider("bert", KNOWN);
+ viaProvider("ernie", UNKNOWN, "-Djava.security.manager");
+ viaProvider("curly", UNKNOWN, "-Djava.security.manager");
+ viaProvider("larry", KNOWN, "-Djava.security.manager",
+ "-Djava.security.policy=" + TEST_SRC + File.separator + "basic.policy");
+ viaProvider("moe", KNOWN, "-Djava.security.manager",
+ "-Djava.security.policy=" + TEST_SRC + File.separator + "basic.policy");
+ viaBadProvider("tom", SCE);
+ viaBadProvider("jerry", SCE);
+ }
+
+ static final Consumer<Result> KNOWN = r -> {
+ if (r.exitValue != 0 || !r.output.isEmpty())
+ throw new RuntimeException(r.output);
+ };
+ static final Consumer<Result> UNKNOWN = r -> {
+ if (r.exitValue == 0 ||
+ !r.output.contains("java.net.MalformedURLException: unknown protocol")) {
+ throw new RuntimeException("exitValue: "+ r.exitValue + ", output:[" +r.output +"]");
+ }
+ };
+ static final Consumer<Result> SCE = r -> {
+ if (r.exitValue == 0 ||
+ !r.output.contains("java.util.ServiceConfigurationError")) {
+ throw new RuntimeException("exitValue: "+ r.exitValue + ", output:[" +r.output +"]");
+ }
+ };
+
+ static void unknownProtocol(String protocol, Consumer<Result> resultChecker) {
+ System.out.println("\nTesting " + protocol);
+ Result r = java(Collections.emptyList(), asList(TEST_CLASSES),
+ "Child", protocol);
+ resultChecker.accept(r);
+ }
+
+ static void viaProvider(String protocol, Consumer<Result> resultChecker,
+ String... sysProps)
+ throws Exception
+ {
+ viaProviderWithTemplate(protocol, resultChecker,
+ TEST_SRC.resolve("provider.template"),
+ sysProps);
+ }
+
+ static void viaBadProvider(String protocol, Consumer<Result> resultChecker,
+ String... sysProps)
+ throws Exception
+ {
+ viaProviderWithTemplate(protocol, resultChecker,
+ TEST_SRC.resolve("bad.provider.template"),
+ sysProps);
+ }
+
+ static void viaProviderWithTemplate(String protocol,
+ Consumer<Result> resultChecker,
+ Path template, String... sysProps)
+ throws Exception
+ {
+ System.out.println("\nTesting " + protocol);
+ Path testRoot = Paths.get("URLStreamHandlerProvider-" + protocol);
+ if (Files.exists(testRoot))
+ FileUtils.deleteFileTreeWithRetry(testRoot);
+ Files.createDirectory(testRoot);
+
+ Path srcPath = Files.createDirectory(testRoot.resolve("src"));
+ Path srcClass = createProvider(protocol, template, srcPath);
+
+ Path build = Files.createDirectory(testRoot.resolve("build"));
+ javac(build, srcClass);
+ createServices(build, protocol);
+ Path testJar = testRoot.resolve("test.jar");
+ jar(testJar, build);
+
+ List<String> props = new ArrayList<>();
+ for (String p : sysProps)
+ props.add(p);
+
+ Result r = java(props, asList(testJar, TEST_CLASSES),
+ "Child", protocol);
+
+ resultChecker.accept(r);
+ }
+
+ static String platformPath(String p) { return p.replace("/", File.separator); }
+ static String binaryName(String name) { return name.replace(".", "/"); }
+
+ static final String SERVICE_IMPL_PREFIX = "net.java.openjdk.test";
+
+ static void createServices(Path dst, String protocol) throws IOException {
+ Path services = Files.createDirectories(dst.resolve("META-INF")
+ .resolve("services"));
+
+ final String implName = SERVICE_IMPL_PREFIX + "." + protocol + ".Provider";
+ Path s = services.resolve("java.net.spi.URLStreamHandlerProvider");
+ FileWriter fw = new FileWriter(s.toFile());
+ try {
+ fw.write(implName);
+ } finally {
+ fw.close();
+ }
+ }
+
+ static Path createProvider(String protocol, Path srcTemplate, Path dst)
+ throws IOException
+ {
+ String pkg = SERVICE_IMPL_PREFIX + "." + protocol;
+ Path classDst = dst.resolve(platformPath(binaryName(pkg)));
+ Files.createDirectories(classDst);
+ Path classPath = classDst.resolve("Provider.java");
+
+ List<String> lines = Files.lines(srcTemplate)
+ .map(s -> s.replaceAll("\\$package", pkg))
+ .map(s -> s.replaceAll("\\$protocol", protocol))
+ .collect(Collectors.toList());
+ Files.write(classPath, lines);
+
+ return classPath;
+ }
+
+ static void jar(Path jarName, Path jarRoot) { String jar = getJDKTool("jar");
+ ProcessBuilder p = new ProcessBuilder(jar, "cf", jarName.toString(),
+ "-C", jarRoot.toString(), ".");
+ quickFail(run(p));
+ }
+
+ static void javac(Path dest, Path... sourceFiles) throws IOException {
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ try (StandardJavaFileManager fileManager =
+ compiler.getStandardFileManager(null, null, null)) {
+
+ List<File> files = Stream.of(sourceFiles)
+ .map(p -> p.toFile())
+ .collect(Collectors.toList());
+ List<File> dests = Stream.of(dest)
+ .map(p -> p.toFile())
+ .collect(Collectors.toList());
+ Iterable<? extends JavaFileObject> compilationUnits =
+ fileManager.getJavaFileObjectsFromFiles(files);
+ fileManager.setLocation(StandardLocation.CLASS_OUTPUT, dests);
+ JavaCompiler.CompilationTask task =
+ compiler.getTask(null, fileManager, null, null, null, compilationUnits);
+ boolean passed = task.call();
+ if (!passed)
+ throw new RuntimeException("Error compiling " + files);
+ }
+ }
+
+ static void quickFail(Result r) {
+ if (r.exitValue != 0)
+ throw new RuntimeException(r.output);
+ }
+
+ static Result java(List<String> sysProps, Collection<Path> classpath,
+ String classname, String arg) {
+ String java = getJDKTool("java");
+
+ List<String> commands = new ArrayList<>();
+ commands.add(java);
+ for (String prop : sysProps)
+ commands.add(prop);
+
+ String cp = classpath.stream()
+ .map(Path::toString)
+ .collect(Collectors.joining(File.pathSeparator));
+ commands.add("-cp");
+ commands.add(cp);
+ commands.add(classname);
+ commands.add(arg);
+
+ return run(new ProcessBuilder(commands));
+ }
+
+ static Result run(ProcessBuilder pb) {
+ Process p = null;
+ System.out.println("running: " + pb.command());
+ try {
+ p = pb.start();
+ } catch (IOException e) {
+ throw new RuntimeException(
+ format("Couldn't start process '%s'", pb.command()), e);
+ }
+
+ String output;
+ try {
+ output = toString(p.getInputStream(), p.getErrorStream());
+ } catch (IOException e) {
+ throw new RuntimeException(
+ format("Couldn't read process output '%s'", pb.command()), e);
+ }
+
+ try {
+ p.waitFor();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(
+ format("Process hasn't finished '%s'", pb.command()), e);
+ }
+
+ return new Result(p.exitValue(), output);
+ }
+
+ static final String DEFAULT_IMAGE_BIN = System.getProperty("java.home")
+ + File.separator + "bin" + File.separator;
+
+ static String getJDKTool(String name) {
+ try {
+ return JDKToolFinder.getJDKTool(name);
+ } catch (Exception x) {
+ return DEFAULT_IMAGE_BIN + name;
+ }
+ }
+
+ static String toString(InputStream... src) throws IOException {
+ StringWriter dst = new StringWriter();
+ Reader concatenated =
+ new InputStreamReader(
+ new SequenceInputStream(
+ Collections.enumeration(asList(src))));
+ copy(concatenated, dst);
+ return dst.toString();
+ }
+
+ static void copy(Reader src, Writer dst) throws IOException {
+ int len;
+ char[] buf = new char[1024];
+ try {
+ while ((len = src.read(buf)) != -1)
+ dst.write(buf, 0, len);
+ } finally {
+ try {
+ src.close();
+ } catch (IOException ignored1) {
+ } finally {
+ try {
+ dst.close();
+ } catch (IOException ignored2) {
+ }
+ }
+ }
+ }
+
+ static class Result {
+ final int exitValue;
+ final String output;
+
+ private Result(int exitValue, String output) {
+ this.exitValue = exitValue;
+ this.output = output;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/Child.java Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * 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.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class Child {
+
+ public static void main(String[] args) throws MalformedURLException {
+ if (args.length != 1) {
+ System.err.println("Usage: java Child <protocol>");
+ return;
+ }
+ String protocol = args[0];
+ URL url = new URL(protocol + "://");
+
+ // toExternalForm should return the protocol string
+ String s = url.toExternalForm();
+ if (!s.equals(protocol)) {
+ System.err.println("Expected url.toExternalForm to return "
+ + protocol + ", but got: " + s);
+ System.exit(1);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/bad.provider.template Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * 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 $package;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.spi.URLStreamHandlerProvider;
+
+public class Provider extends URLStreamHandlerProvider {
+
+ public Provider(String someRandomArg) { // No no-args constructor
+ super();
+ }
+
+ @Override
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/basic.policy Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * 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.
+ */
+
+ grant {
+ permission java.lang.RuntimePermission "setFactory";
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/provider.template Tue Feb 24 10:52:02 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * 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 $package;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.spi.URLStreamHandlerProvider;
+
+public class Provider extends URLStreamHandlerProvider {
+
+ private static final String PROTOCOL = "$protocol";
+
+ @Override
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ if (!PROTOCOL.equals(protocol))
+ return null;
+
+ return new Handler();
+ }
+
+ static class Handler extends URLStreamHandler {
+ public URLConnection openConnection(URL u) throws java.io.IOException {
+ return null;
+ }
+
+ public String toExternalForm(URL u) { return PROTOCOL; }
+ }
+}
--- a/jdk/test/java/util/zip/TestExtraTime.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/java/util/zip/TestExtraTime.java Tue Feb 24 10:52:02 2015 -0800
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 4759491 6303183 7012868 8015666 8023713
+ * @bug 4759491 6303183 7012868 8015666 8023713 8068790
* @summary Test ZOS and ZIS timestamp in extra field correctly
*/
@@ -69,6 +69,8 @@
test(mtime, atime, ctime, tz, extra);
}
}
+
+ testNullHandling();
}
static void test(FileTime mtime, FileTime atime, FileTime ctime,
@@ -154,4 +156,26 @@
}
}
}
+
+ static void testNullHandling() {
+ ZipEntry ze = new ZipEntry("TestExtraTime.java");
+ try {
+ ze.setLastAccessTime(null);
+ throw new RuntimeException("setLastAccessTime(null) should throw NPE");
+ } catch (NullPointerException ignored) {
+ // pass
+ }
+ try {
+ ze.setCreationTime(null);
+ throw new RuntimeException("setCreationTime(null) should throw NPE");
+ } catch (NullPointerException ignored) {
+ // pass
+ }
+ try {
+ ze.setLastModifiedTime(null);
+ throw new RuntimeException("setLastModifiedTime(null) should throw NPE");
+ } catch (NullPointerException ignored) {
+ // pass
+ }
+ }
}
--- a/jdk/test/javax/net/ssl/FixingJavadocs/ComURLNulls.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/ComURLNulls.java Tue Feb 24 10:52:02 2015 -0800
@@ -46,12 +46,23 @@
public class ComURLNulls {
+ private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
+ private static String SUPPORTED_PROTOCOL = "https";
+
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
+ return null;
+
+ return new com.sun.net.ssl.internal.www.protocol.https.Handler();
+ }
+ }
+
public static void main(String[] args) throws Exception {
HostnameVerifier reservedHV =
HttpsURLConnection.getDefaultHostnameVerifier();
try {
- System.setProperty("java.protocol.handler.pkgs",
- "com.sun.net.ssl.internal.www.protocol");
+ URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
+
/**
* This test does not establish any connection to the specified
* URL, hence a dummy URL is used.
--- a/jdk/test/sun/management/AgentCheckTest.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/sun/management/AgentCheckTest.java Tue Feb 24 10:52:02 2015 -0800
@@ -39,12 +39,6 @@
{"jmxremote.ConnectorBootstrap.noAuthentication", "", ""},
{"jmxremote.ConnectorBootstrap.ready", "Phony JMXServiceURL", ""},
{"jmxremote.ConnectorBootstrap.password.readonly", "Phony passwordFileName", ""},
- {"jmxremote.AdaptorBootstrap.getTargetList.processing", "", ""},
- {"jmxremote.AdaptorBootstrap.getTargetList.adding", "Phony target", ""},
- {"jmxremote.AdaptorBootstrap.getTargetList.starting", "", ""},
- {"jmxremote.AdaptorBootstrap.getTargetList.initialize1", "", ""},
- {"jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Phony hostname", "Phony port"},
- {"jmxremote.AdaptorBootstrap.getTargetList.terminate", "Phony exception", ""},
};
boolean pass = true;
--- a/jdk/test/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java Tue Feb 24 10:52:02 2015 -0800
@@ -188,6 +188,17 @@
}
}
+ private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
+ private static String SUPPORTED_PROTOCOL = "https";
+
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
+ return null;
+
+ return new com.sun.net.ssl.internal.www.protocol.https.Handler();
+ }
+ }
+
/*
* Define the client side of the test.
*
@@ -205,8 +216,7 @@
HostnameVerifier reservedHV =
HttpsURLConnection.getDefaultHostnameVerifier();
try {
- System.setProperty("java.protocol.handler.pkgs",
- "com.sun.net.ssl.internal.www.protocol");
+ URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
URL url = new URL("https://" + "localhost:" + serverPort +
--- a/jdk/test/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java Fri Feb 20 14:14:09 2015 -0800
+++ b/jdk/test/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java Tue Feb 24 10:52:02 2015 -0800
@@ -186,6 +186,17 @@
}
}
+ private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
+ private static String SUPPORTED_PROTOCOL = "https";
+
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
+ return null;
+
+ return new com.sun.net.ssl.internal.www.protocol.https.Handler();
+ }
+ }
+
/*
* Define the client side of the test.
*
@@ -200,8 +211,7 @@
Thread.sleep(50);
}
- System.setProperty("java.protocol.handler.pkgs",
- "com.sun.net.ssl.internal.www.protocol");
+ URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
System.setProperty("https.cipherSuites",
"SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
--- a/jdk/test/sun/security/acl/PermissionImpl/PermissionEqualsHashCode.java Fri Feb 20 14:14:09 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1999, 2007, 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.
- *
- * 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.
- */
-
-/*
- * @test
- * @author Gary Ellison
- * @bug 4170635
- * @summary Verify equals()/hashCode() contract honored
- */
-
-import java.io.*;
-
-import sun.security.acl.*;
-
-
-public class PermissionEqualsHashCode {
-
- public static void main(String[] args) throws Exception {
-
- PermissionImpl p1 = new PermissionImpl("permissionPermission");
- PermissionImpl p2 = new PermissionImpl("permissionPermission");
-
-
- // the test
- if ( (p1.equals(p2)) == (p1.hashCode()==p2.hashCode()) )
- System.out.println("PASSED");
- else
- throw new Exception("Failed equals()/hashCode() contract");
-
- }
-}