diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/make/data/tzdata/europe
--- a/jdk/make/data/tzdata/europe Thu May 15 10:25:51 2014 -0700
+++ b/jdk/make/data/tzdata/europe Thu May 15 10:41:25 2014 -0700
@@ -2989,6 +2989,10 @@
# From Alexander Krivenyshev (2014-03-17):
# time change at 2:00 (2am) on March 30, 2014
# http://vz.ru/news/2014/3/17/677464.html
+# From Paul Eggert (2014-03-30):
+# Simferopol and Sevastopol reportedly changed their central town clocks
+# late the previous day, but this appears to have been ceremonial
+# and the discrepancies are small enough to not worry about.
2:00 EU EE%sT 2014 Mar 30 2:00
4:00 - MSK
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/make/gensrc/GensrcMisc.gmk
--- a/jdk/make/gensrc/GensrcMisc.gmk Thu May 15 10:25:51 2014 -0700
+++ b/jdk/make/gensrc/GensrcMisc.gmk Thu May 15 10:41:25 2014 -0700
@@ -62,25 +62,6 @@
##########################################################################################
-ifeq ($(OPENJDK_TARGET_OS_API), posix)
- UPSUFFIX := $(OPENJDK_TARGET_OS)
- ifeq ($(OPENJDK_TARGET_OS), macosx)
- UPSUFFIX := bsd
- endif
- # UNIXProcess.java is different for solaris and linux. We need to copy
- # the correct UNIXProcess.java over to $(JDK_OUTPUTDIR)/gensrc/java/lang/.
-
- $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java: \
- $(JDK_TOPDIR)/src/solaris/classes/java/lang/UNIXProcess.java.$(UPSUFFIX)
- $(ECHO) $(LOG_INFO) Copying UNIXProcess.java.$(OPENJDK_TARGET_OS) to java/lang/UNIXProcess.java
- $(call install-file)
- $(CHMOD) u+rw $@
-
- GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java
-endif
-
-##########################################################################################
-
GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java
GENSRC_SOR_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/ch
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/make/profile-rtjar-includes.txt
--- a/jdk/make/profile-rtjar-includes.txt Thu May 15 10:25:51 2014 -0700
+++ b/jdk/make/profile-rtjar-includes.txt Thu May 15 10:41:25 2014 -0700
@@ -100,9 +100,7 @@
PROFILE_2_RTJAR_EXCLUDE_TYPES :=
-PROFILE_2_INCLUDE_METAINF_SERVICES := \
- META-INF/services/sun.util.spi.XmlPropertiesProvider
-
+PROFILE_2_INCLUDE_METAINF_SERVICES :=
PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
com/sun/jmx \
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 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 com.sun.tools.attach;
+
+import java.io.IOException;
+
+/**
+ * Exception type to signal that an attach operation failed in the target VM.
+ *
+ * This exception can be thrown by the various operations of
+ * {@link com.sun.tools.attach.VirtualMachine} when the operation
+ * fails in the target VM. If there is a communication error,
+ * a regular IOException will be thrown.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public class AttachOperationFailedException extends IOException {
+
+ private static final long serialVersionUID = 2140308168167478043L;
+
+ /**
+ * Constructs an AttachOperationFailedException
with
+ * the specified detail message.
+ *
+ * @param s the detail message.
+ */
+ public AttachOperationFailedException(String message) {
+ super(message);
+ }
+}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java
--- a/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -564,8 +564,15 @@
*
* @return The system properties
*
+ * @throws AttachOperationFailedException
+ * If the target virtual machine is unable to complete the
+ * attach operation. A more specific error message will be
+ * given by {@link AttachOperationFailedException#getMessage()}.
+ *
* @throws IOException
- * If an I/O error occurs
+ * If an I/O error occurs, a communication error for example,
+ * that cannot be identified as an error to indicate that the
+ * operation failed in the target VM.
*
* @see java.lang.System#getProperties
* @see #loadAgentLibrary
@@ -591,8 +598,15 @@
*
* @return The agent properties
*
+ * @throws AttachOperationFailedException
+ * If the target virtual machine is unable to complete the
+ * attach operation. A more specific error message will be
+ * given by {@link AttachOperationFailedException#getMessage()}.
+ *
* @throws IOException
- * If an I/O error occurs
+ * If an I/O error occurs, a communication error for example,
+ * that cannot be identified as an error to indicate that the
+ * operation failed in the target VM.
*/
public abstract Properties getAgentProperties() throws IOException;
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/Character.java
--- a/jdk/src/share/classes/java/lang/Character.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/Character.java Thu May 15 10:41:25 2014 -0700
@@ -4498,7 +4498,6 @@
* Character case is ignored for all of the valid script names.
* The en_US locale's case mapping rules are used to provide
* case-insensitive string comparisons for script name validation.
- *
*
* @param scriptName A {@code UnicodeScript} name.
* @return The {@code UnicodeScript} constant identified
@@ -5503,7 +5502,7 @@
* '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
* '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
*
- *
Many other Unicode characters are uppercase too.
+ *
Many other Unicode characters are uppercase too.
*
* @param codePoint the character (Unicode code point) to be tested.
* @return {@code true} if the character is uppercase;
@@ -5581,7 +5580,7 @@
*
{@code LATIN CAPITAL LETTER N WITH SMALL LETTER J}
* {@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z}
*
- * Many other Unicode characters are titlecase too.
+ *
Many other Unicode characters are titlecase too.
*
* @param codePoint the character (Unicode code point) to be tested.
* @return {@code true} if the character is titlecase;
@@ -6777,7 +6776,6 @@
*
It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR.
* It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR.
*
- *
*
* @param codePoint the character (Unicode code point) to be tested.
* @return {@code true} if the character is a Java whitespace
@@ -7121,7 +7119,6 @@
/**
* Converts the character (Unicode code point) argument to uppercase using
* information from the UnicodeData file.
- *
*
* @param codePoint the character (Unicode code point) to be converted.
* @return either the uppercase equivalent of the character, if
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/ConditionalSpecialCasing.java
--- a/jdk/src/share/classes/java/lang/ConditionalSpecialCasing.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/ConditionalSpecialCasing.java Thu May 15 10:41:25 2014 -0700
@@ -62,6 +62,7 @@
//# Conditional mappings
//# ================================================================================
new Entry(0x03A3, new char[]{0x03C2}, new char[]{0x03A3}, null, FINAL_CASED), // # GREEK CAPITAL LETTER SIGMA
+ new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, null, 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
//# ================================================================================
//# Locale-sensitive mappings
@@ -77,8 +78,8 @@
//# ================================================================================
//# Turkish and Azeri
-// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
-// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
+ new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
+ new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
new Entry(0x0307, new char[]{}, new char[]{0x0307}, "tr", AFTER_I), // # COMBINING DOT ABOVE
new Entry(0x0307, new char[]{}, new char[]{0x0307}, "az", AFTER_I), // # COMBINING DOT ABOVE
new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "tr", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I
@@ -147,21 +148,25 @@
private static char[] lookUpTable(String src, int index, Locale locale, boolean bLowerCasing) {
HashSet set = entryTable.get(new Integer(src.codePointAt(index)));
+ char[] ret = null;
if (set != null) {
Iterator iter = set.iterator();
String currentLang = locale.getLanguage();
while (iter.hasNext()) {
Entry entry = iter.next();
- String conditionLang= entry.getLanguage();
+ String conditionLang = entry.getLanguage();
if (((conditionLang == null) || (conditionLang.equals(currentLang))) &&
isConditionMet(src, index, locale, entry.getCondition())) {
- return (bLowerCasing ? entry.getLowerCase() : entry.getUpperCase());
+ ret = bLowerCasing ? entry.getLowerCase() : entry.getUpperCase();
+ if (conditionLang != null) {
+ break;
+ }
}
}
}
- return null;
+ return ret;
}
private static boolean isConditionMet(String src, int index, Locale locale, int condition) {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/Math.java
--- a/jdk/src/share/classes/java/lang/Math.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/Math.java Thu May 15 10:41:25 2014 -0700
@@ -1048,7 +1048,6 @@
* whereas {@code (-4 / 3) == -1}.
*
*
- *
*
* @param x the dividend
* @param y the divisor
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/Runtime.java
--- a/jdk/src/share/classes/java/lang/Runtime.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/Runtime.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -83,7 +83,7 @@
* blocks indefinitely.
*
*
The {@link System#exit(int) System.exit} method is the
- * conventional and convenient means of invoking this method.
+ * conventional and convenient means of invoking this method.
*
* @param status
* Termination status. By convention, a nonzero status code
@@ -180,7 +180,7 @@
* method goes awry by, for example, corrupting internal data structures or
* attempting to access nonexistent memory. If the virtual machine aborts
* then no guarantee can be made about whether or not any shutdown hooks
- * will be run.
+ * will be run.
*
* @param hook
* An initialized but unstarted {@link Thread} object
@@ -248,7 +248,7 @@
* hooks to be started and does not run uninvoked finalizers if
* finalization-on-exit has been enabled. If the shutdown sequence has
* already been initiated then this method does not wait for any running
- * shutdown hooks or finalizers to finish their work.
+ * shutdown hooks or finalizers to finish their work.
*
* @param status
* Termination status. By convention, a nonzero status code
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/SecurityManager.java
--- a/jdk/src/share/classes/java/lang/SecurityManager.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/SecurityManager.java Thu May 15 10:41:25 2014 -0700
@@ -1242,7 +1242,6 @@
* super.checkPropertiesAccess
* at the point the overridden method would normally throw an
* exception.
- *
*
* @exception SecurityException if the calling thread does not have
* permission to access or modify the system properties.
@@ -1320,7 +1319,6 @@
* super.checkPrintJobAccess
* at the point the overridden method would normally throw an
* exception.
- *
*
* @exception SecurityException if the calling thread does not have
* permission to initiate a print job request.
@@ -1566,7 +1564,6 @@
* super.checkSetFactory
* at the point the overridden method would normally throw an
* exception.
- *
*
* @exception SecurityException if the calling thread does not have
* permission to specify a socket factory or a stream
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/String.java
--- a/jdk/src/share/classes/java/lang/String.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/String.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2014, 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
@@ -2583,6 +2583,9 @@
if (cp == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
return toLowerCaseEx(result, i, locale, false);
}
+ if (cp == '\u0130') { // LATIN CAPITAL LETTER I WITH DOT ABOVE
+ return toLowerCaseEx(result, i, locale, true);
+ }
cp = Character.toLowerCase(cp);
if (!Character.isBmpCodePoint(cp)) {
return toLowerCaseEx(result, i, locale, false);
@@ -2650,7 +2653,7 @@
* LATIN SMALL LETTER DOTLESS I character.
* To obtain correct results for locale insensitive strings, use
* {@code toLowerCase(Locale.ROOT)}.
- *
+ *
* @return the {@code String}, converted to lowercase.
* @see java.lang.String#toLowerCase(Locale)
*/
@@ -2812,7 +2815,7 @@
* LATIN CAPITAL LETTER I WITH DOT ABOVE character.
* To obtain correct results for locale insensitive strings, use
* {@code toUpperCase(Locale.ROOT)}.
- *
+ *
* @return the {@code String}, converted to uppercase.
* @see java.lang.String#toUpperCase(Locale)
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/System.java
--- a/jdk/src/share/classes/java/lang/System.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/System.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2014, 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
@@ -133,7 +133,6 @@
*
First, if there is a security manager, its checkPermission
* method is called with a RuntimePermission("setIO")
permission
* to see if it's ok to reassign the "standard" input stream.
- *
*
* @param in the new standard input stream.
*
@@ -762,7 +761,6 @@
* permission. This may result in a SecurityException being thrown.
* If no exception is thrown, the specified property is set to the given
* value.
- *
*
* @param key the name of the system property.
* @param value the value of the system property.
@@ -801,7 +799,6 @@
* is called with a PropertyPermission(key, "write")
* permission. This may result in a SecurityException being thrown.
* If no exception is thrown, the specified property is removed.
- *
*
* @param key the name of the system property to be removed.
* @return the previous string value of the system property,
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/classes/java/lang/instrument/package.html
--- a/jdk/src/share/classes/java/lang/instrument/package.html Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/classes/java/lang/instrument/package.html Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
" +
- ""+
- "" +
- "" +
- "" +
- "";
-
- /**
- * Version number for the format of exported properties files.
- */
- private static final String EXTERNAL_XML_VERSION = "1.0";
-
- @Override
- public void load(Properties props, InputStream in)
- throws IOException, InvalidPropertiesFormatException
- {
- Document doc = null;
- try {
- doc = getLoadingDoc(in);
- } catch (SAXException saxe) {
- throw new InvalidPropertiesFormatException(saxe);
- }
- Element propertiesElement = doc.getDocumentElement();
- String xmlVersion = propertiesElement.getAttribute("version");
- if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
- throw new InvalidPropertiesFormatException(
- "Exported Properties file format version " + xmlVersion +
- " is not supported. This java installation can read" +
- " versions " + EXTERNAL_XML_VERSION + " or older. You" +
- " may need to install a newer version of JDK.");
- importProperties(props, propertiesElement);
- }
-
- static Document getLoadingDoc(InputStream in)
- throws SAXException, IOException
- {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setIgnoringElementContentWhitespace(true);
- dbf.setValidating(true);
- dbf.setCoalescing(true);
- dbf.setIgnoringComments(true);
- try {
- DocumentBuilder db = dbf.newDocumentBuilder();
- db.setEntityResolver(new Resolver());
- db.setErrorHandler(new EH());
- InputSource is = new InputSource(in);
- return db.parse(is);
- } catch (ParserConfigurationException x) {
- throw new Error(x);
- }
- }
-
- static void importProperties(Properties props, Element propertiesElement) {
- NodeList entries = propertiesElement.getChildNodes();
- int numEntries = entries.getLength();
- int start = numEntries > 0 &&
- entries.item(0).getNodeName().equals("comment") ? 1 : 0;
- for (int i=start; i e : props.entrySet()) {
- final Object k = e.getKey();
- final Object v = e.getValue();
- if (k instanceof String && v instanceof String) {
- Element entry = (Element)properties.appendChild(
- doc.createElement("entry"));
- entry.setAttribute("key", (String)k);
- entry.appendChild(doc.createTextNode((String)v));
- }
- }
- }
- emitDocument(doc, os, encoding);
- }
-
- static void emitDocument(Document doc, OutputStream os, String encoding)
- throws IOException
- {
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer t = null;
- try {
- t = tf.newTransformer();
- t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, PROPS_DTD_URI);
- t.setOutputProperty(OutputKeys.INDENT, "yes");
- t.setOutputProperty(OutputKeys.METHOD, "xml");
- t.setOutputProperty(OutputKeys.ENCODING, encoding);
- } catch (TransformerConfigurationException tce) {
- assert(false);
- }
- DOMSource doms = new DOMSource(doc);
- StreamResult sr = new StreamResult(os);
- try {
- t.transform(doms, sr);
- } catch (TransformerException te) {
- throw new IOException(te);
- }
- }
-
- private static class Resolver implements EntityResolver {
- public InputSource resolveEntity(String pid, String sid)
- throws SAXException
- {
- if (sid.equals(PROPS_DTD_URI)) {
- InputSource is;
- is = new InputSource(new StringReader(PROPS_DTD));
- is.setSystemId(PROPS_DTD_URI);
- return is;
- }
- throw new SAXException("Invalid system identifier: " + sid);
- }
- }
-
- private static class EH implements ErrorHandler {
- public void error(SAXParseException x) throws SAXException {
- throw x;
- }
- public void fatalError(SAXParseException x) throws SAXException {
- throw x;
- }
- public void warning(SAXParseException x) throws SAXException {
- throw x;
- }
- }
-
-}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/share/lib/security/java.policy
--- a/jdk/src/share/lib/security/java.policy Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/share/lib/security/java.policy Thu May 15 10:41:25 2014 -0700
@@ -1,7 +1,39 @@
+// permissions required by each component
+grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
+ permission java.io.FilePermission "<>", "read,write,delete";
+ permission java.lang.RuntimePermission "fileSystemProvider";
+ permission java.util.PropertyPermission "*", "read";
+};
-// Standard extensions get all permissions by default
+grant codeBase "file:${java.home}/lib/ext/cldrdata.jar" {
+ permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*";
+ permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*";
+ permission java.util.PropertyPermission "*", "read";
+};
+
+grant codeBase "file:${java.home}/lib/ext/localedata.jar" {
+ permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*";
+ permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*";
+ permission java.util.PropertyPermission "*", "read";
+};
-grant codeBase "file:${{java.ext.dirs}}/*" {
+grant codeBase "file:${java.home}/lib/ext/dnsns.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/nashorn.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
permission java.security.AllPermission;
};
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/java/lang/UNIXProcess.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/java/lang/UNIXProcess.java Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,827 @@
+/*
+ * Copyright (c) 1995, 2014, 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.lang;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.security.AccessController;
+import static java.security.AccessController.doPrivileged;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * java.lang.Process subclass in the UNIX environment.
+ *
+ * @author Mario Wolczko and Ross Knippel.
+ * @author Konstantin Kladko (ported to Linux and Bsd)
+ * @author Martin Buchholz
+ * @author Volker Simonis (ported to AIX)
+ */
+final class UNIXProcess extends Process {
+ private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
+ = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
+
+ private final int pid;
+ private int exitcode;
+ private boolean hasExited;
+
+ private /* final */ OutputStream stdin;
+ private /* final */ InputStream stdout;
+ private /* final */ InputStream stderr;
+
+ // only used on Solaris
+ private /* final */ DeferredCloseInputStream stdout_inner_stream;
+
+ private static enum LaunchMechanism {
+ // order IS important!
+ FORK,
+ POSIX_SPAWN,
+ VFORK
+ }
+
+ private static enum Platform {
+
+ LINUX(LaunchMechanism.VFORK, LaunchMechanism.FORK),
+
+ BSD(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),
+
+ SOLARIS(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),
+
+ AIX(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK);
+
+ final LaunchMechanism defaultLaunchMechanism;
+ final Set validLaunchMechanisms;
+
+ Platform(LaunchMechanism ... launchMechanisms) {
+ this.defaultLaunchMechanism = launchMechanisms[0];
+ this.validLaunchMechanisms =
+ EnumSet.copyOf(Arrays.asList(launchMechanisms));
+ }
+
+ private String helperPath(String javahome, String osArch) {
+ switch (this) {
+ case SOLARIS:
+ if (osArch.equals("x86")) { osArch = "i386"; }
+ else if (osArch.equals("x86_64")) { osArch = "amd64"; }
+ // fall through...
+ case LINUX:
+ case AIX:
+ return javahome + "/lib/" + osArch + "/jspawnhelper";
+
+ case BSD:
+ return javahome + "/lib/jspawnhelper";
+
+ default:
+ throw new AssertionError("Unsupported platform: " + this);
+ }
+ }
+
+ String helperPath() {
+ return AccessController.doPrivileged(
+ (PrivilegedAction) () ->
+ helperPath(System.getProperty("java.home"),
+ System.getProperty("os.arch"))
+ );
+ }
+
+ LaunchMechanism launchMechanism() {
+ return AccessController.doPrivileged(
+ (PrivilegedAction) () -> {
+ String s = System.getProperty(
+ "jdk.lang.Process.launchMechanism");
+ LaunchMechanism lm;
+ if (s == null) {
+ lm = defaultLaunchMechanism;
+ s = lm.name().toLowerCase(Locale.ENGLISH);
+ } else {
+ try {
+ lm = LaunchMechanism.valueOf(
+ s.toUpperCase(Locale.ENGLISH));
+ } catch (IllegalArgumentException e) {
+ lm = null;
+ }
+ }
+ if (lm == null || !validLaunchMechanisms.contains(lm)) {
+ throw new Error(
+ s + " is not a supported " +
+ "process launch mechanism on this platform."
+ );
+ }
+ return lm;
+ }
+ );
+ }
+
+ static Platform get() {
+ String osName = AccessController.doPrivileged(
+ (PrivilegedAction) () -> System.getProperty("os.name")
+ );
+
+ if (osName.equals("Linux")) { return LINUX; }
+ if (osName.contains("OS X")) { return BSD; }
+ if (osName.equals("SunOS")) { return SOLARIS; }
+ if (osName.equals("AIX")) { return AIX; }
+
+ throw new Error(osName + " is not a supported OS platform.");
+ }
+ }
+
+ private static final Platform platform = Platform.get();
+ private static final LaunchMechanism launchMechanism = platform.launchMechanism();
+ private static final byte[] helperpath = toCString(platform.helperPath());
+
+ private static byte[] toCString(String s) {
+ if (s == null)
+ return null;
+ byte[] bytes = s.getBytes();
+ byte[] result = new byte[bytes.length + 1];
+ System.arraycopy(bytes, 0,
+ result, 0,
+ bytes.length);
+ result[result.length-1] = (byte)0;
+ return result;
+ }
+
+ /* this is for the reaping thread */
+ private native int waitForProcessExit(int pid);
+
+ /**
+ * Creates a process. Depending on the {@code mode} flag, this is done by
+ * one of the following mechanisms:
+ *
+ * 1 - fork(2) and exec(2)
+ * 2 - posix_spawn(3P)
+ * 3 - vfork(2) and exec(2)
+ *
+ * (4 - clone(2) and exec(2) - obsolete and currently disabled in native code)
+ *
+ * @param fds an array of three file descriptors.
+ * Indexes 0, 1, and 2 correspond to standard input,
+ * standard output and standard error, respectively. On
+ * input, a value of -1 means to create a pipe to connect
+ * child and parent processes. On output, a value which
+ * is not -1 is the parent pipe fd corresponding to the
+ * pipe which has been created. An element of this array
+ * is -1 on input if and only if it is not -1 on
+ * output.
+ * @return the pid of the subprocess
+ */
+ private native int forkAndExec(int mode, byte[] helperpath,
+ byte[] prog,
+ byte[] argBlock, int argc,
+ byte[] envBlock, int envc,
+ byte[] dir,
+ int[] fds,
+ boolean redirectErrorStream)
+ throws IOException;
+
+ /**
+ * The thread pool of "process reaper" daemon threads.
+ */
+ private static final Executor processReaperExecutor =
+ doPrivileged((PrivilegedAction) () -> {
+
+ ThreadGroup tg = Thread.currentThread().getThreadGroup();
+ while (tg.getParent() != null) tg = tg.getParent();
+ ThreadGroup systemThreadGroup = tg;
+
+ ThreadFactory threadFactory = grimReaper -> {
+ // Our thread stack requirement is quite modest.
+ Thread t = new Thread(systemThreadGroup, grimReaper,
+ "process reaper", 32768);
+ t.setDaemon(true);
+ // A small attempt (probably futile) to avoid priority inversion
+ t.setPriority(Thread.MAX_PRIORITY);
+ return t;
+ };
+
+ return Executors.newCachedThreadPool(threadFactory);
+ });
+
+ UNIXProcess(final byte[] prog,
+ final byte[] argBlock, final int argc,
+ final byte[] envBlock, final int envc,
+ final byte[] dir,
+ final int[] fds,
+ final boolean redirectErrorStream)
+ throws IOException {
+
+ pid = forkAndExec(launchMechanism.ordinal() + 1,
+ helperpath,
+ prog,
+ argBlock, argc,
+ envBlock, envc,
+ dir,
+ fds,
+ redirectErrorStream);
+
+ try {
+ doPrivileged((PrivilegedExceptionAction) () -> {
+ initStreams(fds);
+ return null;
+ });
+ } catch (PrivilegedActionException ex) {
+ throw (IOException) ex.getException();
+ }
+ }
+
+ static FileDescriptor newFileDescriptor(int fd) {
+ FileDescriptor fileDescriptor = new FileDescriptor();
+ fdAccess.set(fileDescriptor, fd);
+ return fileDescriptor;
+ }
+
+ void initStreams(int[] fds) throws IOException {
+ switch (platform) {
+ case LINUX:
+ case BSD:
+ stdin = (fds[0] == -1) ?
+ ProcessBuilder.NullOutputStream.INSTANCE :
+ new ProcessPipeOutputStream(fds[0]);
+
+ stdout = (fds[1] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new ProcessPipeInputStream(fds[1]);
+
+ stderr = (fds[2] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new ProcessPipeInputStream(fds[2]);
+
+ processReaperExecutor.execute(() -> {
+ int exitcode = waitForProcessExit(pid);
+
+ synchronized (this) {
+ this.exitcode = exitcode;
+ this.hasExited = true;
+ this.notifyAll();
+ }
+
+ if (stdout instanceof ProcessPipeInputStream)
+ ((ProcessPipeInputStream) stdout).processExited();
+
+ if (stderr instanceof ProcessPipeInputStream)
+ ((ProcessPipeInputStream) stderr).processExited();
+
+ if (stdin instanceof ProcessPipeOutputStream)
+ ((ProcessPipeOutputStream) stdin).processExited();
+ });
+ break;
+
+ case SOLARIS:
+ stdin = (fds[0] == -1) ?
+ ProcessBuilder.NullOutputStream.INSTANCE :
+ new BufferedOutputStream(
+ new FileOutputStream(newFileDescriptor(fds[0])));
+
+ stdout = (fds[1] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new BufferedInputStream(
+ stdout_inner_stream =
+ new DeferredCloseInputStream(
+ newFileDescriptor(fds[1])));
+
+ stderr = (fds[2] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new DeferredCloseInputStream(newFileDescriptor(fds[2]));
+
+ /*
+ * For each subprocess forked a corresponding reaper task
+ * is submitted. That task is the only thread which waits
+ * for the subprocess to terminate and it doesn't hold any
+ * locks while doing so. This design allows waitFor() and
+ * exitStatus() to be safely executed in parallel (and they
+ * need no native code).
+ */
+ processReaperExecutor.execute(() -> {
+ int exitcode = waitForProcessExit(pid);
+
+ synchronized (this) {
+ this.exitcode = exitcode;
+ this.hasExited = true;
+ this.notifyAll();
+ }
+ });
+ break;
+
+ case AIX:
+ stdin = (fds[0] == -1) ?
+ ProcessBuilder.NullOutputStream.INSTANCE :
+ new ProcessPipeOutputStream(fds[0]);
+
+ stdout = (fds[1] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new DeferredCloseProcessPipeInputStream(fds[1]);
+
+ stderr = (fds[2] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new DeferredCloseProcessPipeInputStream(fds[2]);
+
+ processReaperExecutor.execute(() -> {
+ int exitcode = waitForProcessExit(pid);
+
+ synchronized (this) {
+ this.exitcode = exitcode;
+ this.hasExited = true;
+ this.notifyAll();
+ }
+
+ if (stdout instanceof DeferredCloseProcessPipeInputStream)
+ ((DeferredCloseProcessPipeInputStream) stdout).processExited();
+
+ if (stderr instanceof DeferredCloseProcessPipeInputStream)
+ ((DeferredCloseProcessPipeInputStream) stderr).processExited();
+
+ if (stdin instanceof ProcessPipeOutputStream)
+ ((ProcessPipeOutputStream) stdin).processExited();
+ });
+ break;
+
+ default: throw new AssertionError("Unsupported platform: " + platform);
+ }
+ }
+
+ public OutputStream getOutputStream() {
+ return stdin;
+ }
+
+ public InputStream getInputStream() {
+ return stdout;
+ }
+
+ public InputStream getErrorStream() {
+ return stderr;
+ }
+
+ public synchronized int waitFor() throws InterruptedException {
+ while (!hasExited) {
+ wait();
+ }
+ return exitcode;
+ }
+
+ @Override
+ public synchronized boolean waitFor(long timeout, TimeUnit unit)
+ throws InterruptedException
+ {
+ if (hasExited) return true;
+ if (timeout <= 0) return false;
+
+ long timeoutAsNanos = unit.toNanos(timeout);
+ long startTime = System.nanoTime();
+ long rem = timeoutAsNanos;
+
+ while (!hasExited && (rem > 0)) {
+ wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
+ rem = timeoutAsNanos - (System.nanoTime() - startTime);
+ }
+ return hasExited;
+ }
+
+ public synchronized int exitValue() {
+ if (!hasExited) {
+ throw new IllegalThreadStateException("process hasn't exited");
+ }
+ return exitcode;
+ }
+
+ private static native void destroyProcess(int pid, boolean force);
+
+ private void destroy(boolean force) {
+ switch (platform) {
+ case LINUX:
+ case BSD:
+ case AIX:
+ // There is a risk that pid will be recycled, causing us to
+ // kill the wrong process! So we only terminate processes
+ // that appear to still be running. Even with this check,
+ // there is an unavoidable race condition here, but the window
+ // is very small, and OSes try hard to not recycle pids too
+ // soon, so this is quite safe.
+ synchronized (this) {
+ if (!hasExited)
+ destroyProcess(pid, force);
+ }
+ try { stdin.close(); } catch (IOException ignored) {}
+ try { stdout.close(); } catch (IOException ignored) {}
+ try { stderr.close(); } catch (IOException ignored) {}
+ break;
+
+ case SOLARIS:
+ // There is a risk that pid will be recycled, causing us to
+ // kill the wrong process! So we only terminate processes
+ // that appear to still be running. Even with this check,
+ // there is an unavoidable race condition here, but the window
+ // is very small, and OSes try hard to not recycle pids too
+ // soon, so this is quite safe.
+ synchronized (this) {
+ if (!hasExited)
+ destroyProcess(pid, force);
+ try {
+ stdin.close();
+ if (stdout_inner_stream != null)
+ stdout_inner_stream.closeDeferred(stdout);
+ if (stderr instanceof DeferredCloseInputStream)
+ ((DeferredCloseInputStream) stderr)
+ .closeDeferred(stderr);
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ break;
+
+ default: throw new AssertionError("Unsupported platform: " + platform);
+ }
+ }
+
+ public void destroy() {
+ destroy(false);
+ }
+
+ @Override
+ public Process destroyForcibly() {
+ destroy(true);
+ return this;
+ }
+
+ @Override
+ public synchronized boolean isAlive() {
+ return !hasExited;
+ }
+
+ private static native void init();
+
+ static {
+ init();
+ }
+
+ /**
+ * A buffered input stream for a subprocess pipe file descriptor
+ * that allows the underlying file descriptor to be reclaimed when
+ * the process exits, via the processExited hook.
+ *
+ * This is tricky because we do not want the user-level InputStream to be
+ * closed until the user invokes close(), and we need to continue to be
+ * able to read any buffered data lingering in the OS pipe buffer.
+ */
+ private static class ProcessPipeInputStream extends BufferedInputStream {
+ private final Object closeLock = new Object();
+
+ ProcessPipeInputStream(int fd) {
+ super(new FileInputStream(newFileDescriptor(fd)));
+ }
+ private static byte[] drainInputStream(InputStream in)
+ throws IOException {
+ int n = 0;
+ int j;
+ byte[] a = null;
+ while ((j = in.available()) > 0) {
+ a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
+ n += in.read(a, n, j);
+ }
+ return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
+ }
+
+ /** Called by the process reaper thread when the process exits. */
+ synchronized void processExited() {
+ synchronized (closeLock) {
+ try {
+ InputStream in = this.in;
+ // this stream is closed if and only if: in == null
+ if (in != null) {
+ byte[] stragglers = drainInputStream(in);
+ in.close();
+ this.in = (stragglers == null) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new ByteArrayInputStream(stragglers);
+ }
+ } catch (IOException ignored) {}
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ // BufferedInputStream#close() is not synchronized unlike most other
+ // methods. Synchronizing helps avoid race with processExited().
+ synchronized (closeLock) {
+ super.close();
+ }
+ }
+ }
+
+ /**
+ * A buffered output stream for a subprocess pipe file descriptor
+ * that allows the underlying file descriptor to be reclaimed when
+ * the process exits, via the processExited hook.
+ */
+ private static class ProcessPipeOutputStream extends BufferedOutputStream {
+ ProcessPipeOutputStream(int fd) {
+ super(new FileOutputStream(newFileDescriptor(fd)));
+ }
+
+ /** Called by the process reaper thread when the process exits. */
+ synchronized void processExited() {
+ OutputStream out = this.out;
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException ignored) {
+ // We know of no reason to get an IOException, but if
+ // we do, there's nothing else to do but carry on.
+ }
+ this.out = ProcessBuilder.NullOutputStream.INSTANCE;
+ }
+ }
+ }
+
+ // A FileInputStream that supports the deferment of the actual close
+ // operation until the last pending I/O operation on the stream has
+ // finished. This is required on Solaris because we must close the stdin
+ // and stdout streams in the destroy method in order to reclaim the
+ // underlying file descriptors. Doing so, however, causes any thread
+ // currently blocked in a read on one of those streams to receive an
+ // IOException("Bad file number"), which is incompatible with historical
+ // behavior. By deferring the close we allow any pending reads to see -1
+ // (EOF) as they did before.
+ //
+ private static class DeferredCloseInputStream extends FileInputStream
+ {
+ DeferredCloseInputStream(FileDescriptor fd) {
+ super(fd);
+ }
+
+ private Object lock = new Object(); // For the following fields
+ private boolean closePending = false;
+ private int useCount = 0;
+ private InputStream streamToClose;
+
+ private void raise() {
+ synchronized (lock) {
+ useCount++;
+ }
+ }
+
+ private void lower() throws IOException {
+ synchronized (lock) {
+ useCount--;
+ if (useCount == 0 && closePending) {
+ streamToClose.close();
+ }
+ }
+ }
+
+ // stc is the actual stream to be closed; it might be this object, or
+ // it might be an upstream object for which this object is downstream.
+ //
+ private void closeDeferred(InputStream stc) throws IOException {
+ synchronized (lock) {
+ if (useCount == 0) {
+ stc.close();
+ } else {
+ closePending = true;
+ streamToClose = stc;
+ }
+ }
+ }
+
+ public void close() throws IOException {
+ synchronized (lock) {
+ useCount = 0;
+ closePending = false;
+ }
+ super.close();
+ }
+
+ public int read() throws IOException {
+ raise();
+ try {
+ return super.read();
+ } finally {
+ lower();
+ }
+ }
+
+ public int read(byte[] b) throws IOException {
+ raise();
+ try {
+ return super.read(b);
+ } finally {
+ lower();
+ }
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ raise();
+ try {
+ return super.read(b, off, len);
+ } finally {
+ lower();
+ }
+ }
+
+ public long skip(long n) throws IOException {
+ raise();
+ try {
+ return super.skip(n);
+ } finally {
+ lower();
+ }
+ }
+
+ public int available() throws IOException {
+ raise();
+ try {
+ return super.available();
+ } finally {
+ lower();
+ }
+ }
+ }
+
+ /**
+ * A buffered input stream for a subprocess pipe file descriptor
+ * that allows the underlying file descriptor to be reclaimed when
+ * the process exits, via the processExited hook.
+ *
+ * This is tricky because we do not want the user-level InputStream to be
+ * closed until the user invokes close(), and we need to continue to be
+ * able to read any buffered data lingering in the OS pipe buffer.
+ *
+ * On AIX this is especially tricky, because the 'close()' system call
+ * will block if another thread is at the same time blocked in a file
+ * operation (e.g. 'read()') on the same file descriptor. We therefore
+ * combine 'ProcessPipeInputStream' approach used on Linux and Bsd
+ * with the DeferredCloseInputStream approach used on Solaris. This means
+ * that every potentially blocking operation on the file descriptor
+ * increments a counter before it is executed and decrements it once it
+ * finishes. The 'close()' operation will only be executed if there are
+ * no pending operations. Otherwise it is deferred after the last pending
+ * operation has finished.
+ *
+ */
+ private static class DeferredCloseProcessPipeInputStream
+ extends BufferedInputStream {
+
+ private final Object closeLock = new Object();
+ private int useCount = 0;
+ private boolean closePending = false;
+
+ DeferredCloseProcessPipeInputStream(int fd) {
+ super(new FileInputStream(newFileDescriptor(fd)));
+ }
+
+ private InputStream drainInputStream(InputStream in)
+ throws IOException {
+ int n = 0;
+ int j;
+ byte[] a = null;
+ synchronized (closeLock) {
+ if (buf == null) // asynchronous close()?
+ return null; // discard
+ j = in.available();
+ }
+ while (j > 0) {
+ a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
+ synchronized (closeLock) {
+ if (buf == null) // asynchronous close()?
+ return null; // discard
+ n += in.read(a, n, j);
+ j = in.available();
+ }
+ }
+ return (a == null) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n));
+ }
+
+ /** Called by the process reaper thread when the process exits. */
+ synchronized void processExited() {
+ try {
+ InputStream in = this.in;
+ if (in != null) {
+ InputStream stragglers = drainInputStream(in);
+ in.close();
+ this.in = stragglers;
+ }
+ } catch (IOException ignored) { }
+ }
+
+ private void raise() {
+ synchronized (closeLock) {
+ useCount++;
+ }
+ }
+
+ private void lower() throws IOException {
+ synchronized (closeLock) {
+ useCount--;
+ if (useCount == 0 && closePending) {
+ closePending = false;
+ super.close();
+ }
+ }
+ }
+
+ @Override
+ public int read() throws IOException {
+ raise();
+ try {
+ return super.read();
+ } finally {
+ lower();
+ }
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ raise();
+ try {
+ return super.read(b);
+ } finally {
+ lower();
+ }
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ raise();
+ try {
+ return super.read(b, off, len);
+ } finally {
+ lower();
+ }
+ }
+
+ @Override
+ public long skip(long n) throws IOException {
+ raise();
+ try {
+ return super.skip(n);
+ } finally {
+ lower();
+ }
+ }
+
+ @Override
+ public int available() throws IOException {
+ raise();
+ try {
+ return super.available();
+ } finally {
+ lower();
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ // BufferedInputStream#close() is not synchronized unlike most other
+ // methods. Synchronizing helps avoid racing with drainInputStream().
+ synchronized (closeLock) {
+ if (useCount == 0) {
+ super.close();
+ }
+ else {
+ closePending = true;
+ }
+ }
+ }
+ }
+}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/java/lang/UNIXProcess.java.aix
--- a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.aix Thu May 15 10:25:51 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,504 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, 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.lang;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import static java.security.AccessController.doPrivileged;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- * @author Konstantin Kladko (ported to Linux)
- * @author Martin Buchholz
- * @author Volker Simonis (ported to AIX)
- */
-final class UNIXProcess extends Process {
- private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
- = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
- private final int pid;
- private int exitcode;
- private boolean hasExited;
-
- private /* final */ OutputStream stdin;
- private /* final */ InputStream stdout;
- private /* final */ InputStream stderr;
-
- private static enum LaunchMechanism {
- FORK(1),
- POSIX_SPAWN(2);
-
- private int value;
- LaunchMechanism(int x) {value = x;}
- };
-
- /* On AIX, the default is to spawn */
- private static final LaunchMechanism launchMechanism;
- private static byte[] helperpath;
-
- private static byte[] toCString(String s) {
- if (s == null)
- return null;
- byte[] bytes = s.getBytes();
- byte[] result = new byte[bytes.length + 1];
- System.arraycopy(bytes, 0,
- result, 0,
- bytes.length);
- result[result.length-1] = (byte)0;
- return result;
- }
-
- static {
- launchMechanism = AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public LaunchMechanism run() {
- String javahome = System.getProperty("java.home");
- String osArch = System.getProperty("os.arch");
-
- helperpath = toCString(javahome + "/lib/" + osArch + "/jspawnhelper");
- String s = System.getProperty(
- "jdk.lang.Process.launchMechanism", "posix_spawn");
-
- try {
- return LaunchMechanism.valueOf(s.toUpperCase());
- } catch (IllegalArgumentException e) {
- throw new Error(s + " is not a supported " +
- "process launch mechanism on this platform.");
- }
- }
- });
- }
-
- /* this is for the reaping thread */
- private native int waitForProcessExit(int pid);
-
- /**
- * Create a process. Depending on the mode flag, this is done by
- * one of the following mechanisms.
- * - fork(2) and exec(2)
- * - clone(2) and exec(2)
- * - vfork(2) and exec(2)
- *
- * @param fds an array of three file descriptors.
- * Indexes 0, 1, and 2 correspond to standard input,
- * standard output and standard error, respectively. On
- * input, a value of -1 means to create a pipe to connect
- * child and parent processes. On output, a value which
- * is not -1 is the parent pipe fd corresponding to the
- * pipe which has been created. An element of this array
- * is -1 on input if and only if it is not -1 on
- * output.
- * @return the pid of the subprocess
- */
- private native int forkAndExec(int mode, byte[] helperpath,
- byte[] prog,
- byte[] argBlock, int argc,
- byte[] envBlock, int envc,
- byte[] dir,
- int[] fds,
- boolean redirectErrorStream)
- throws IOException;
-
- /**
- * The thread factory used to create "process reaper" daemon threads.
- */
- private static class ProcessReaperThreadFactory implements ThreadFactory {
- private final static ThreadGroup group = getRootThreadGroup();
-
- private static ThreadGroup getRootThreadGroup() {
- return doPrivileged(new PrivilegedAction () {
- public ThreadGroup run() {
- ThreadGroup root = Thread.currentThread().getThreadGroup();
- while (root.getParent() != null)
- root = root.getParent();
- return root;
- }});
- }
-
- public Thread newThread(Runnable grimReaper) {
- // Our thread stack requirement is quite modest.
- Thread t = new Thread(group, grimReaper, "process reaper", 32768);
- t.setDaemon(true);
- // A small attempt (probably futile) to avoid priority inversion
- t.setPriority(Thread.MAX_PRIORITY);
- return t;
- }
- }
-
- /**
- * The thread pool of "process reaper" daemon threads.
- */
- private static final Executor processReaperExecutor =
- doPrivileged(new PrivilegedAction() {
- public Executor run() {
- return Executors.newCachedThreadPool
- (new ProcessReaperThreadFactory());
- }});
-
- UNIXProcess(final byte[] prog,
- final byte[] argBlock, final int argc,
- final byte[] envBlock, final int envc,
- final byte[] dir,
- final int[] fds,
- final boolean redirectErrorStream)
- throws IOException {
-
- pid = forkAndExec(launchMechanism.value,
- helperpath,
- prog,
- argBlock, argc,
- envBlock, envc,
- dir,
- fds,
- redirectErrorStream);
-
- try {
- doPrivileged(new PrivilegedExceptionAction() {
- public Void run() throws IOException {
- initStreams(fds);
- return null;
- }});
- } catch (PrivilegedActionException ex) {
- throw (IOException) ex.getException();
- }
- }
-
- static FileDescriptor newFileDescriptor(int fd) {
- FileDescriptor fileDescriptor = new FileDescriptor();
- fdAccess.set(fileDescriptor, fd);
- return fileDescriptor;
- }
-
- void initStreams(int[] fds) throws IOException {
- stdin = (fds[0] == -1) ?
- ProcessBuilder.NullOutputStream.INSTANCE :
- new ProcessPipeOutputStream(fds[0]);
-
- stdout = (fds[1] == -1) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ProcessPipeInputStream(fds[1]);
-
- stderr = (fds[2] == -1) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ProcessPipeInputStream(fds[2]);
-
- processReaperExecutor.execute(new Runnable() {
- public void run() {
- int exitcode = waitForProcessExit(pid);
- UNIXProcess.this.processExited(exitcode);
- }});
- }
-
- void processExited(int exitcode) {
- synchronized (this) {
- this.exitcode = exitcode;
- hasExited = true;
- notifyAll();
- }
-
- if (stdout instanceof ProcessPipeInputStream)
- ((ProcessPipeInputStream) stdout).processExited();
-
- if (stderr instanceof ProcessPipeInputStream)
- ((ProcessPipeInputStream) stderr).processExited();
-
- if (stdin instanceof ProcessPipeOutputStream)
- ((ProcessPipeOutputStream) stdin).processExited();
- }
-
- public OutputStream getOutputStream() {
- return stdin;
- }
-
- public InputStream getInputStream() {
- return stdout;
- }
-
- public InputStream getErrorStream() {
- return stderr;
- }
-
- public synchronized int waitFor() throws InterruptedException {
- while (!hasExited) {
- wait();
- }
- return exitcode;
- }
-
- @Override
- public synchronized boolean waitFor(long timeout, TimeUnit unit)
- throws InterruptedException
- {
- if (hasExited) return true;
- if (timeout <= 0) return false;
-
- long timeoutAsNanos = unit.toNanos(timeout);
- long startTime = System.nanoTime();
- long rem = timeoutAsNanos;
-
- while (!hasExited && (rem > 0)) {
- wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
- rem = timeoutAsNanos - (System.nanoTime() - startTime);
- }
- return hasExited;
- }
-
- public synchronized int exitValue() {
- if (!hasExited) {
- throw new IllegalThreadStateException("process hasn't exited");
- }
- return exitcode;
- }
-
- private static native void destroyProcess(int pid, boolean force);
- private void destroy(boolean force) {
- // There is a risk that pid will be recycled, causing us to
- // kill the wrong process! So we only terminate processes
- // that appear to still be running. Even with this check,
- // there is an unavoidable race condition here, but the window
- // is very small, and OSes try hard to not recycle pids too
- // soon, so this is quite safe.
- synchronized (this) {
- if (!hasExited)
- destroyProcess(pid, force);
- }
- try { stdin.close(); } catch (IOException ignored) {}
- try { stdout.close(); } catch (IOException ignored) {}
- try { stderr.close(); } catch (IOException ignored) {}
- }
-
- public void destroy() {
- destroy(false);
- }
-
- @Override
- public Process destroyForcibly() {
- destroy(true);
- return this;
- }
-
- @Override
- public synchronized boolean isAlive() {
- return !hasExited;
- }
-
- private static native void init();
-
- static {
- init();
- }
-
- /**
- * A buffered input stream for a subprocess pipe file descriptor
- * that allows the underlying file descriptor to be reclaimed when
- * the process exits, via the processExited hook.
- *
- * This is tricky because we do not want the user-level InputStream to be
- * closed until the user invokes close(), and we need to continue to be
- * able to read any buffered data lingering in the OS pipe buffer.
- *
- * On AIX this is especially tricky, because the 'close()' system call
- * will block if another thread is at the same time blocked in a file
- * operation (e.g. 'read()') on the same file descriptor. We therefore
- * combine this 'ProcessPipeInputStream' with the DeferredCloseInputStream
- * approach used on Solaris (see "UNIXProcess.java.solaris"). This means
- * that every potentially blocking operation on the file descriptor
- * increments a counter before it is executed and decrements it once it
- * finishes. The 'close()' operation will only be executed if there are
- * no pending operations. Otherwise it is deferred after the last pending
- * operation has finished.
- *
- */
- static class ProcessPipeInputStream extends BufferedInputStream {
- private final Object closeLock = new Object();
- private int useCount = 0;
- private boolean closePending = false;
-
- ProcessPipeInputStream(int fd) {
- super(new FileInputStream(newFileDescriptor(fd)));
- }
-
- private InputStream drainInputStream(InputStream in)
- throws IOException {
- int n = 0;
- int j;
- byte[] a = null;
- synchronized (closeLock) {
- if (buf == null) // asynchronous close()?
- return null; // discard
- j = in.available();
- }
- while (j > 0) {
- a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
- synchronized (closeLock) {
- if (buf == null) // asynchronous close()?
- return null; // discard
- n += in.read(a, n, j);
- j = in.available();
- }
- }
- return (a == null) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n));
- }
-
- /** Called by the process reaper thread when the process exits. */
- synchronized void processExited() {
- try {
- InputStream in = this.in;
- if (in != null) {
- InputStream stragglers = drainInputStream(in);
- in.close();
- this.in = stragglers;
- }
- } catch (IOException ignored) { }
- }
-
- private void raise() {
- synchronized (closeLock) {
- useCount++;
- }
- }
-
- private void lower() throws IOException {
- synchronized (closeLock) {
- useCount--;
- if (useCount == 0 && closePending) {
- closePending = false;
- super.close();
- }
- }
- }
-
- @Override
- public int read() throws IOException {
- raise();
- try {
- return super.read();
- } finally {
- lower();
- }
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- raise();
- try {
- return super.read(b);
- } finally {
- lower();
- }
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- raise();
- try {
- return super.read(b, off, len);
- } finally {
- lower();
- }
- }
-
- @Override
- public long skip(long n) throws IOException {
- raise();
- try {
- return super.skip(n);
- } finally {
- lower();
- }
- }
-
- @Override
- public int available() throws IOException {
- raise();
- try {
- return super.available();
- } finally {
- lower();
- }
- }
-
- @Override
- public void close() throws IOException {
- // BufferedInputStream#close() is not synchronized unlike most other methods.
- // Synchronizing helps avoid racing with drainInputStream().
- synchronized (closeLock) {
- if (useCount == 0) {
- super.close();
- }
- else {
- closePending = true;
- }
- }
- }
- }
-
- /**
- * A buffered output stream for a subprocess pipe file descriptor
- * that allows the underlying file descriptor to be reclaimed when
- * the process exits, via the processExited hook.
- */
- static class ProcessPipeOutputStream extends BufferedOutputStream {
- ProcessPipeOutputStream(int fd) {
- super(new FileOutputStream(newFileDescriptor(fd)));
- }
-
- /** Called by the process reaper thread when the process exits. */
- synchronized void processExited() {
- OutputStream out = this.out;
- if (out != null) {
- try {
- out.close();
- } catch (IOException ignored) {
- // We know of no reason to get an IOException, but if
- // we do, there's nothing else to do but carry on.
- }
- this.out = ProcessBuilder.NullOutputStream.INSTANCE;
- }
- }
- }
-}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/java/lang/UNIXProcess.java.bsd
--- a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.bsd Thu May 15 10:25:51 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, 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.lang;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import static java.security.AccessController.doPrivileged;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- * @author Konstantin Kladko (ported to Bsd)
- * @author Martin Buchholz
- */
-final class UNIXProcess extends Process {
- private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
- = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
- private final int pid;
- private int exitcode;
- private boolean hasExited;
-
- private /* final */ OutputStream stdin;
- private /* final */ InputStream stdout;
- private /* final */ InputStream stderr;
-
- private static enum LaunchMechanism {
- FORK(1),
- POSIX_SPAWN(2);
-
- private int value;
- LaunchMechanism(int x) {value = x;}
- };
-
- /* On BSD, the default is to spawn */
- private static final LaunchMechanism launchMechanism;
- private static byte[] helperpath;
-
- private static byte[] toCString(String s) {
- if (s == null)
- return null;
- byte[] bytes = s.getBytes();
- byte[] result = new byte[bytes.length + 1];
- System.arraycopy(bytes, 0,
- result, 0,
- bytes.length);
- result[result.length-1] = (byte)0;
- return result;
- }
-
- static {
- launchMechanism = AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public LaunchMechanism run() {
- String javahome = System.getProperty("java.home");
-
- helperpath = toCString(javahome + "/lib/jspawnhelper");
- String s = System.getProperty(
- "jdk.lang.Process.launchMechanism", "posix_spawn");
-
- try {
- return LaunchMechanism.valueOf(s.toUpperCase());
- } catch (IllegalArgumentException e) {
- throw new Error(s + " is not a supported " +
- "process launch mechanism on this platform.");
- }
- }
- });
- }
-
- /* this is for the reaping thread */
- private native int waitForProcessExit(int pid);
-
- /**
- * Create a process. Depending on the mode flag, this is done by
- * one of the following mechanisms.
- * - fork(2) and exec(2)
- * - posix_spawn(2)
- *
- * @param fds an array of three file descriptors.
- * Indexes 0, 1, and 2 correspond to standard input,
- * standard output and standard error, respectively. On
- * input, a value of -1 means to create a pipe to connect
- * child and parent processes. On output, a value which
- * is not -1 is the parent pipe fd corresponding to the
- * pipe which has been created. An element of this array
- * is -1 on input if and only if it is not -1 on
- * output.
- * @return the pid of the subprocess
- */
- private native int forkAndExec(int mode, byte[] helperpath,
- byte[] prog,
- byte[] argBlock, int argc,
- byte[] envBlock, int envc,
- byte[] dir,
- int[] fds,
- boolean redirectErrorStream)
- throws IOException;
-
- /**
- * The thread factory used to create "process reaper" daemon threads.
- */
- private static class ProcessReaperThreadFactory implements ThreadFactory {
- private final static ThreadGroup group = getRootThreadGroup();
-
- private static ThreadGroup getRootThreadGroup() {
- return doPrivileged(new PrivilegedAction () {
- public ThreadGroup run() {
- ThreadGroup root = Thread.currentThread().getThreadGroup();
- while (root.getParent() != null)
- root = root.getParent();
- return root;
- }});
- }
-
- public Thread newThread(Runnable grimReaper) {
- // Our thread stack requirement is quite modest.
- Thread t = new Thread(group, grimReaper, "process reaper", 32768);
- t.setDaemon(true);
- // A small attempt (probably futile) to avoid priority inversion
- t.setPriority(Thread.MAX_PRIORITY);
- return t;
- }
- }
-
- /**
- * The thread pool of "process reaper" daemon threads.
- */
- private static final Executor processReaperExecutor =
- doPrivileged(new PrivilegedAction() {
- public Executor run() {
- return Executors.newCachedThreadPool
- (new ProcessReaperThreadFactory());
- }});
-
- UNIXProcess(final byte[] prog,
- final byte[] argBlock, final int argc,
- final byte[] envBlock, final int envc,
- final byte[] dir,
- final int[] fds,
- final boolean redirectErrorStream)
- throws IOException {
-
- pid = forkAndExec(launchMechanism.value,
- helperpath,
- prog,
- argBlock, argc,
- envBlock, envc,
- dir,
- fds,
- redirectErrorStream);
-
- try {
- doPrivileged(new PrivilegedExceptionAction() {
- public Void run() throws IOException {
- initStreams(fds);
- return null;
- }});
- } catch (PrivilegedActionException ex) {
- throw (IOException) ex.getException();
- }
- }
-
- static FileDescriptor newFileDescriptor(int fd) {
- FileDescriptor fileDescriptor = new FileDescriptor();
- fdAccess.set(fileDescriptor, fd);
- return fileDescriptor;
- }
-
- void initStreams(int[] fds) throws IOException {
- stdin = (fds[0] == -1) ?
- ProcessBuilder.NullOutputStream.INSTANCE :
- new ProcessPipeOutputStream(fds[0]);
-
- stdout = (fds[1] == -1) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ProcessPipeInputStream(fds[1]);
-
- stderr = (fds[2] == -1) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ProcessPipeInputStream(fds[2]);
-
- processReaperExecutor.execute(new Runnable() {
- public void run() {
- int exitcode = waitForProcessExit(pid);
- UNIXProcess.this.processExited(exitcode);
- }});
- }
-
- void processExited(int exitcode) {
- synchronized (this) {
- this.exitcode = exitcode;
- hasExited = true;
- notifyAll();
- }
-
- if (stdout instanceof ProcessPipeInputStream)
- ((ProcessPipeInputStream) stdout).processExited();
-
- if (stderr instanceof ProcessPipeInputStream)
- ((ProcessPipeInputStream) stderr).processExited();
-
- if (stdin instanceof ProcessPipeOutputStream)
- ((ProcessPipeOutputStream) stdin).processExited();
- }
-
- public OutputStream getOutputStream() {
- return stdin;
- }
-
- public InputStream getInputStream() {
- return stdout;
- }
-
- public InputStream getErrorStream() {
- return stderr;
- }
-
- public synchronized int waitFor() throws InterruptedException {
- while (!hasExited) {
- wait();
- }
- return exitcode;
- }
-
- @Override
- public synchronized boolean waitFor(long timeout, TimeUnit unit)
- throws InterruptedException
- {
- if (hasExited) return true;
- if (timeout <= 0) return false;
-
- long timeoutAsNanos = unit.toNanos(timeout);
- long startTime = System.nanoTime();
- long rem = timeoutAsNanos;
-
- while (!hasExited && (rem > 0)) {
- wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
- rem = timeoutAsNanos - (System.nanoTime() - startTime);
- }
- return hasExited;
- }
-
- public synchronized int exitValue() {
- if (!hasExited) {
- throw new IllegalThreadStateException("process hasn't exited");
- }
- return exitcode;
- }
-
- private static native void destroyProcess(int pid, boolean force);
- private void destroy(boolean force) {
- // There is a risk that pid will be recycled, causing us to
- // kill the wrong process! So we only terminate processes
- // that appear to still be running. Even with this check,
- // there is an unavoidable race condition here, but the window
- // is very small, and OSes try hard to not recycle pids too
- // soon, so this is quite safe.
- synchronized (this) {
- if (!hasExited)
- destroyProcess(pid, force);
- }
- try { stdin.close(); } catch (IOException ignored) {}
- try { stdout.close(); } catch (IOException ignored) {}
- try { stderr.close(); } catch (IOException ignored) {}
- }
-
- public void destroy() {
- destroy(false);
- }
-
- @Override
- public Process destroyForcibly() {
- destroy(true);
- return this;
- }
-
- @Override
- public synchronized boolean isAlive() {
- return !hasExited;
- }
-
- private static native void init();
-
- static {
- init();
- }
-
- /**
- * A buffered input stream for a subprocess pipe file descriptor
- * that allows the underlying file descriptor to be reclaimed when
- * the process exits, via the processExited hook.
- *
- * This is tricky because we do not want the user-level InputStream to be
- * closed until the user invokes close(), and we need to continue to be
- * able to read any buffered data lingering in the OS pipe buffer.
- */
- static class ProcessPipeInputStream extends BufferedInputStream {
- private final Object closeLock = new Object();
-
- ProcessPipeInputStream(int fd) {
- super(new FileInputStream(newFileDescriptor(fd)));
- }
- private static byte[] drainInputStream(InputStream in)
- throws IOException {
- int n = 0;
- int j;
- byte[] a = null;
- while ((j = in.available()) > 0) {
- a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
- n += in.read(a, n, j);
- }
- return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
- }
-
- /** Called by the process reaper thread when the process exits. */
- synchronized void processExited() {
- synchronized (closeLock) {
- try {
- InputStream in = this.in;
- // this stream is closed if and only if: in == null
- if (in != null) {
- byte[] stragglers = drainInputStream(in);
- in.close();
- this.in = (stragglers == null) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ByteArrayInputStream(stragglers);
- }
- } catch (IOException ignored) {}
- }
- }
-
- @Override
- public void close() throws IOException {
- // BufferedInputStream#close() is not synchronized unlike most other methods.
- // Synchronizing helps avoid race with processExited().
- synchronized (closeLock) {
- super.close();
- }
- }
- }
-
- /**
- * A buffered output stream for a subprocess pipe file descriptor
- * that allows the underlying file descriptor to be reclaimed when
- * the process exits, via the processExited hook.
- */
- static class ProcessPipeOutputStream extends BufferedOutputStream {
- ProcessPipeOutputStream(int fd) {
- super(new FileOutputStream(newFileDescriptor(fd)));
- }
-
- /** Called by the process reaper thread when the process exits. */
- synchronized void processExited() {
- OutputStream out = this.out;
- if (out != null) {
- try {
- out.close();
- } catch (IOException ignored) {
- // We know of no reason to get an IOException, but if
- // we do, there's nothing else to do but carry on.
- }
- this.out = ProcessBuilder.NullOutputStream.INSTANCE;
- }
- }
- }
-}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/java/lang/UNIXProcess.java.linux
--- a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.linux Thu May 15 10:25:51 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,410 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, 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.lang;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import static java.security.AccessController.doPrivileged;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- * @author Konstantin Kladko (ported to Linux)
- * @author Martin Buchholz
- */
-final class UNIXProcess extends Process {
- private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
- = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
- private final int pid;
- private int exitcode;
- private boolean hasExited;
-
- private /* final */ OutputStream stdin;
- private /* final */ InputStream stdout;
- private /* final */ InputStream stderr;
-
- private static enum LaunchMechanism {
- FORK(1),
- VFORK(3);
-
- private int value;
- LaunchMechanism(int x) {value = x;}
- };
-
- /* default is VFORK on Linux */
- private static final LaunchMechanism launchMechanism;
- private static byte[] helperpath;
-
- private static byte[] toCString(String s) {
- if (s == null)
- return null;
- byte[] bytes = s.getBytes();
- byte[] result = new byte[bytes.length + 1];
- System.arraycopy(bytes, 0,
- result, 0,
- bytes.length);
- result[result.length-1] = (byte)0;
- return result;
- }
-
- static {
- launchMechanism = AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public LaunchMechanism run() {
- String javahome = System.getProperty("java.home");
- String osArch = System.getProperty("os.arch");
-
- helperpath = toCString(javahome + "/lib/" + osArch + "/jspawnhelper");
- String s = System.getProperty(
- "jdk.lang.Process.launchMechanism", "vfork");
-
- try {
- return LaunchMechanism.valueOf(s.toUpperCase());
- } catch (IllegalArgumentException e) {
- throw new Error(s + " is not a supported " +
- "process launch mechanism on this platform.");
- }
- }
- });
- }
-
- /* this is for the reaping thread */
- private native int waitForProcessExit(int pid);
-
- /**
- * Create a process. Depending on the mode flag, this is done by
- * one of the following mechanisms.
- * - fork(2) and exec(2)
- * - clone(2) and exec(2)
- * - vfork(2) and exec(2)
- *
- * @param fds an array of three file descriptors.
- * Indexes 0, 1, and 2 correspond to standard input,
- * standard output and standard error, respectively. On
- * input, a value of -1 means to create a pipe to connect
- * child and parent processes. On output, a value which
- * is not -1 is the parent pipe fd corresponding to the
- * pipe which has been created. An element of this array
- * is -1 on input if and only if it is not -1 on
- * output.
- * @return the pid of the subprocess
- */
- private native int forkAndExec(int mode, byte[] helperpath,
- byte[] prog,
- byte[] argBlock, int argc,
- byte[] envBlock, int envc,
- byte[] dir,
- int[] fds,
- boolean redirectErrorStream)
- throws IOException;
-
- /**
- * The thread factory used to create "process reaper" daemon threads.
- */
- private static class ProcessReaperThreadFactory implements ThreadFactory {
- private final static ThreadGroup group = getRootThreadGroup();
-
- private static ThreadGroup getRootThreadGroup() {
- return doPrivileged(new PrivilegedAction () {
- public ThreadGroup run() {
- ThreadGroup root = Thread.currentThread().getThreadGroup();
- while (root.getParent() != null)
- root = root.getParent();
- return root;
- }});
- }
-
- public Thread newThread(Runnable grimReaper) {
- // Our thread stack requirement is quite modest.
- Thread t = new Thread(group, grimReaper, "process reaper", 32768);
- t.setDaemon(true);
- // A small attempt (probably futile) to avoid priority inversion
- t.setPriority(Thread.MAX_PRIORITY);
- return t;
- }
- }
-
- /**
- * The thread pool of "process reaper" daemon threads.
- */
- private static final Executor processReaperExecutor =
- doPrivileged(new PrivilegedAction() {
- public Executor run() {
- return Executors.newCachedThreadPool
- (new ProcessReaperThreadFactory());
- }});
-
- UNIXProcess(final byte[] prog,
- final byte[] argBlock, final int argc,
- final byte[] envBlock, final int envc,
- final byte[] dir,
- final int[] fds,
- final boolean redirectErrorStream)
- throws IOException {
-
- pid = forkAndExec(launchMechanism.value,
- helperpath,
- prog,
- argBlock, argc,
- envBlock, envc,
- dir,
- fds,
- redirectErrorStream);
-
- try {
- doPrivileged(new PrivilegedExceptionAction() {
- public Void run() throws IOException {
- initStreams(fds);
- return null;
- }});
- } catch (PrivilegedActionException ex) {
- throw (IOException) ex.getException();
- }
- }
-
- static FileDescriptor newFileDescriptor(int fd) {
- FileDescriptor fileDescriptor = new FileDescriptor();
- fdAccess.set(fileDescriptor, fd);
- return fileDescriptor;
- }
-
- void initStreams(int[] fds) throws IOException {
- stdin = (fds[0] == -1) ?
- ProcessBuilder.NullOutputStream.INSTANCE :
- new ProcessPipeOutputStream(fds[0]);
-
- stdout = (fds[1] == -1) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ProcessPipeInputStream(fds[1]);
-
- stderr = (fds[2] == -1) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ProcessPipeInputStream(fds[2]);
-
- processReaperExecutor.execute(new Runnable() {
- public void run() {
- int exitcode = waitForProcessExit(pid);
- UNIXProcess.this.processExited(exitcode);
- }});
- }
-
- void processExited(int exitcode) {
- synchronized (this) {
- this.exitcode = exitcode;
- hasExited = true;
- notifyAll();
- }
-
- if (stdout instanceof ProcessPipeInputStream)
- ((ProcessPipeInputStream) stdout).processExited();
-
- if (stderr instanceof ProcessPipeInputStream)
- ((ProcessPipeInputStream) stderr).processExited();
-
- if (stdin instanceof ProcessPipeOutputStream)
- ((ProcessPipeOutputStream) stdin).processExited();
- }
-
- public OutputStream getOutputStream() {
- return stdin;
- }
-
- public InputStream getInputStream() {
- return stdout;
- }
-
- public InputStream getErrorStream() {
- return stderr;
- }
-
- public synchronized int waitFor() throws InterruptedException {
- while (!hasExited) {
- wait();
- }
- return exitcode;
- }
-
- @Override
- public synchronized boolean waitFor(long timeout, TimeUnit unit)
- throws InterruptedException
- {
- if (hasExited) return true;
- if (timeout <= 0) return false;
-
- long timeoutAsNanos = unit.toNanos(timeout);
- long startTime = System.nanoTime();
- long rem = timeoutAsNanos;
-
- while (!hasExited && (rem > 0)) {
- wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
- rem = timeoutAsNanos - (System.nanoTime() - startTime);
- }
- return hasExited;
- }
-
- public synchronized int exitValue() {
- if (!hasExited) {
- throw new IllegalThreadStateException("process hasn't exited");
- }
- return exitcode;
- }
-
- private static native void destroyProcess(int pid, boolean force);
- private void destroy(boolean force) {
- // There is a risk that pid will be recycled, causing us to
- // kill the wrong process! So we only terminate processes
- // that appear to still be running. Even with this check,
- // there is an unavoidable race condition here, but the window
- // is very small, and OSes try hard to not recycle pids too
- // soon, so this is quite safe.
- synchronized (this) {
- if (!hasExited)
- destroyProcess(pid, force);
- }
- try { stdin.close(); } catch (IOException ignored) {}
- try { stdout.close(); } catch (IOException ignored) {}
- try { stderr.close(); } catch (IOException ignored) {}
- }
-
- public void destroy() {
- destroy(false);
- }
-
- @Override
- public Process destroyForcibly() {
- destroy(true);
- return this;
- }
-
- @Override
- public synchronized boolean isAlive() {
- return !hasExited;
- }
-
- private static native void init();
-
- static {
- init();
- }
-
- /**
- * A buffered input stream for a subprocess pipe file descriptor
- * that allows the underlying file descriptor to be reclaimed when
- * the process exits, via the processExited hook.
- *
- * This is tricky because we do not want the user-level InputStream to be
- * closed until the user invokes close(), and we need to continue to be
- * able to read any buffered data lingering in the OS pipe buffer.
- */
- static class ProcessPipeInputStream extends BufferedInputStream {
- private final Object closeLock = new Object();
-
- ProcessPipeInputStream(int fd) {
- super(new FileInputStream(newFileDescriptor(fd)));
- }
- private static byte[] drainInputStream(InputStream in)
- throws IOException {
- int n = 0;
- int j;
- byte[] a = null;
- while ((j = in.available()) > 0) {
- a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
- n += in.read(a, n, j);
- }
- return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
- }
-
- /** Called by the process reaper thread when the process exits. */
- synchronized void processExited() {
- synchronized (closeLock) {
- try {
- InputStream in = this.in;
- // this stream is closed if and only if: in == null
- if (in != null) {
- byte[] stragglers = drainInputStream(in);
- in.close();
- this.in = (stragglers == null) ?
- ProcessBuilder.NullInputStream.INSTANCE :
- new ByteArrayInputStream(stragglers);
- }
- } catch (IOException ignored) {}
- }
- }
-
- @Override
- public void close() throws IOException {
- // BufferedInputStream#close() is not synchronized unlike most other methods.
- // Synchronizing helps avoid race with processExited().
- synchronized (closeLock) {
- super.close();
- }
- }
- }
-
- /**
- * A buffered output stream for a subprocess pipe file descriptor
- * that allows the underlying file descriptor to be reclaimed when
- * the process exits, via the processExited hook.
- */
- static class ProcessPipeOutputStream extends BufferedOutputStream {
- ProcessPipeOutputStream(int fd) {
- super(new FileOutputStream(newFileDescriptor(fd)));
- }
-
- /** Called by the process reaper thread when the process exits. */
- synchronized void processExited() {
- OutputStream out = this.out;
- if (out != null) {
- try {
- out.close();
- } catch (IOException ignored) {
- // We know of no reason to get an IOException, but if
- // we do, there's nothing else to do but carry on.
- }
- this.out = ProcessBuilder.NullOutputStream.INSTANCE;
- }
- }
- }
-}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/java/lang/UNIXProcess.java.solaris
--- a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.solaris Thu May 15 10:25:51 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, 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.lang;
-
-import java.io.*;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/* java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- */
-
-final class UNIXProcess extends Process {
- private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
- = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
- private final int pid;
- private int exitcode;
- private boolean hasExited;
-
- private OutputStream stdin_stream;
- private InputStream stdout_stream;
- private DeferredCloseInputStream stdout_inner_stream;
- private InputStream stderr_stream;
-
- private static enum LaunchMechanism {
- FORK(1),
- POSIX_SPAWN(2);
-
- private int value;
- LaunchMechanism(int x) {value = x;}
- };
-
- /* On Solaris, the default is to spawn */
- private static final LaunchMechanism launchMechanism;
- private static byte[] helperpath;
-
- private static byte[] toCString(String s) {
- if (s == null)
- return null;
- byte[] bytes = s.getBytes();
- byte[] result = new byte[bytes.length + 1];
- System.arraycopy(bytes, 0,
- result, 0,
- bytes.length);
- result[result.length-1] = (byte)0;
- return result;
- }
-
- static {
- launchMechanism = AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public LaunchMechanism run() {
- String javahome = System.getProperty("java.home");
- String osArch = System.getProperty("os.arch");
- if (osArch.equals("x86")) {
- osArch = "i386";
- } else if (osArch.equals("x86_64")) {
- osArch = "amd64";
- }
-
- helperpath = toCString(javahome + "/lib/" + osArch + "/jspawnhelper");
- String s = System.getProperty(
- "jdk.lang.Process.launchMechanism", "posix_spawn");
-
- try {
- return LaunchMechanism.valueOf(s.toUpperCase());
- } catch (IllegalArgumentException e) {
- throw new Error(s + " is not a supported " +
- "process launch mechanism on this platform.");
- }
- }
- });
- }
-
- /* this is for the reaping thread */
- private native int waitForProcessExit(int pid);
-
- /**
- * Create a process. Depending on the mode flag, this is done by
- * one of the following mechanisms.
- * - fork(2) and exec(2)
- * - posix_spawn(2)
- *
- * @param std_fds array of file descriptors. Indexes 0, 1, and
- * 2 correspond to standard input, standard output and
- * standard error, respectively. On input, a value of -1
- * means to create a pipe to connect child and parent
- * processes. On output, a value which is not -1 is the
- * parent pipe fd corresponding to the pipe which has
- * been created. An element of this array is -1 on input
- * if and only if it is not -1 on output.
- * @return the pid of the subprocess
- */
- private native int forkAndExec(int mode, byte[] helperpath,
- byte[] prog,
- byte[] argBlock, int argc,
- byte[] envBlock, int envc,
- byte[] dir,
- int[] std_fds,
- boolean redirectErrorStream)
- throws IOException;
-
- UNIXProcess(final byte[] prog,
- final byte[] argBlock, int argc,
- final byte[] envBlock, int envc,
- final byte[] dir,
- final int[] std_fds,
- final boolean redirectErrorStream)
- throws IOException {
- pid = forkAndExec(launchMechanism.value,
- helperpath,
- prog,
- argBlock, argc,
- envBlock, envc,
- dir,
- std_fds,
- redirectErrorStream);
-
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() { public Void run() {
- if (std_fds[0] == -1)
- stdin_stream = ProcessBuilder.NullOutputStream.INSTANCE;
- else {
- FileDescriptor stdin_fd = new FileDescriptor();
- fdAccess.set(stdin_fd, std_fds[0]);
- stdin_stream = new BufferedOutputStream(
- new FileOutputStream(stdin_fd));
- }
-
- if (std_fds[1] == -1)
- stdout_stream = ProcessBuilder.NullInputStream.INSTANCE;
- else {
- FileDescriptor stdout_fd = new FileDescriptor();
- fdAccess.set(stdout_fd, std_fds[1]);
- stdout_inner_stream = new DeferredCloseInputStream(stdout_fd);
- stdout_stream = new BufferedInputStream(stdout_inner_stream);
- }
-
- if (std_fds[2] == -1)
- stderr_stream = ProcessBuilder.NullInputStream.INSTANCE;
- else {
- FileDescriptor stderr_fd = new FileDescriptor();
- fdAccess.set(stderr_fd, std_fds[2]);
- stderr_stream = new DeferredCloseInputStream(stderr_fd);
- }
-
- return null; }});
-
- /*
- * For each subprocess forked a corresponding reaper thread
- * is started. That thread is the only thread which waits
- * for the subprocess to terminate and it doesn't hold any
- * locks while doing so. This design allows waitFor() and
- * exitStatus() to be safely executed in parallel (and they
- * need no native code).
- */
-
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() { public Void run() {
- Thread t = new Thread("process reaper") {
- public void run() {
- int res = waitForProcessExit(pid);
- synchronized (UNIXProcess.this) {
- hasExited = true;
- exitcode = res;
- UNIXProcess.this.notifyAll();
- }
- }
- };
- t.setDaemon(true);
- t.start();
- return null; }});
- }
-
- public OutputStream getOutputStream() {
- return stdin_stream;
- }
-
- public InputStream getInputStream() {
- return stdout_stream;
- }
-
- public InputStream getErrorStream() {
- return stderr_stream;
- }
-
- public synchronized int waitFor() throws InterruptedException {
- while (!hasExited) {
- wait();
- }
- return exitcode;
- }
-
- @Override
- public synchronized boolean waitFor(long timeout, TimeUnit unit)
- throws InterruptedException
- {
- if (hasExited) return true;
- if (timeout <= 0) return false;
-
- long timeoutAsNanos = unit.toNanos(timeout);
- long startTime = System.nanoTime();
- long rem = timeoutAsNanos;
-
- while (!hasExited && (rem > 0)) {
- wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
- rem = timeoutAsNanos - (System.nanoTime() - startTime);
- }
- return hasExited;
- }
-
- public synchronized int exitValue() {
- if (!hasExited) {
- throw new IllegalThreadStateException("process hasn't exited");
- }
- return exitcode;
- }
-
- private static native void destroyProcess(int pid, boolean force);
- private synchronized void destroy(boolean force) {
- // There is a risk that pid will be recycled, causing us to
- // kill the wrong process! So we only terminate processes
- // that appear to still be running. Even with this check,
- // there is an unavoidable race condition here, but the window
- // is very small, and OSes try hard to not recycle pids too
- // soon, so this is quite safe.
- if (!hasExited)
- destroyProcess(pid, force);
- try {
- stdin_stream.close();
- if (stdout_inner_stream != null)
- stdout_inner_stream.closeDeferred(stdout_stream);
- if (stderr_stream instanceof DeferredCloseInputStream)
- ((DeferredCloseInputStream) stderr_stream)
- .closeDeferred(stderr_stream);
- } catch (IOException e) {
- // ignore
- }
- }
-
- public void destroy() {
- destroy(false);
- }
-
- @Override
- public Process destroyForcibly() {
- destroy(true);
- return this;
- }
-
- @Override
- public synchronized boolean isAlive() {
- return !hasExited;
- }
-
- // A FileInputStream that supports the deferment of the actual close
- // operation until the last pending I/O operation on the stream has
- // finished. This is required on Solaris because we must close the stdin
- // and stdout streams in the destroy method in order to reclaim the
- // underlying file descriptors. Doing so, however, causes any thread
- // currently blocked in a read on one of those streams to receive an
- // IOException("Bad file number"), which is incompatible with historical
- // behavior. By deferring the close we allow any pending reads to see -1
- // (EOF) as they did before.
- //
- private static class DeferredCloseInputStream
- extends FileInputStream
- {
-
- private DeferredCloseInputStream(FileDescriptor fd) {
- super(fd);
- }
-
- private Object lock = new Object(); // For the following fields
- private boolean closePending = false;
- private int useCount = 0;
- private InputStream streamToClose;
-
- private void raise() {
- synchronized (lock) {
- useCount++;
- }
- }
-
- private void lower() throws IOException {
- synchronized (lock) {
- useCount--;
- if (useCount == 0 && closePending) {
- streamToClose.close();
- }
- }
- }
-
- // stc is the actual stream to be closed; it might be this object, or
- // it might be an upstream object for which this object is downstream.
- //
- private void closeDeferred(InputStream stc) throws IOException {
- synchronized (lock) {
- if (useCount == 0) {
- stc.close();
- } else {
- closePending = true;
- streamToClose = stc;
- }
- }
- }
-
- public void close() throws IOException {
- synchronized (lock) {
- useCount = 0;
- closePending = false;
- }
- super.close();
- }
-
- public int read() throws IOException {
- raise();
- try {
- return super.read();
- } finally {
- lower();
- }
- }
-
- public int read(byte[] b) throws IOException {
- raise();
- try {
- return super.read(b);
- } finally {
- lower();
- }
- }
-
- public int read(byte[] b, int off, int len) throws IOException {
- raise();
- try {
- return super.read(b, off, len);
- } finally {
- lower();
- }
- }
-
- public long skip(long n) throws IOException {
- raise();
- try {
- return super.skip(n);
- } finally {
- lower();
- }
- }
-
- public int available() throws IOException {
- raise();
- try {
- return super.available();
- } finally {
- lower();
- }
- }
-
- }
-
- private static native void init();
-
- static {
- init();
- }
-}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java
--- a/jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -24,14 +24,14 @@
*/
package sun.tools.attach;
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.spi.AttachProvider;
+
import java.io.InputStream;
import java.io.IOException;
import java.io.File;
-import java.util.Properties;
/*
* Bsd implementation of HotSpotVirtualMachine
@@ -191,6 +191,8 @@
}
if (completionStatus != 0) {
+ // read from the stream and use that as the error message
+ String message = readErrorMessage(sis);
sis.close();
// In the event of a protocol mismatch then the target VM
@@ -205,7 +207,11 @@
if (cmd.equals("load")) {
throw new AgentLoadException("Failed to load agent library");
} else {
- throw new IOException("Command failed in target VM");
+ if (message == null) {
+ throw new AttachOperationFailedException("Command failed in target VM");
+ } else {
+ throw new AttachOperationFailedException(message);
+ }
}
}
@@ -237,8 +243,9 @@
if ((off < 0) || (off > bs.length) || (len < 0) ||
((off + len) > bs.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
- } else if (len == 0)
+ } else if (len == 0) {
return 0;
+ }
return BsdVirtualMachine.read(s, bs, off, len);
}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java
--- a/jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -24,14 +24,14 @@
*/
package sun.tools.attach;
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.spi.AttachProvider;
+
import java.io.InputStream;
import java.io.IOException;
import java.io.File;
-import java.util.Properties;
/*
* Linux implementation of HotSpotVirtualMachine
@@ -207,6 +207,8 @@
}
if (completionStatus != 0) {
+ // read from the stream and use that as the error message
+ String message = readErrorMessage(sis);
sis.close();
// In the event of a protocol mismatch then the target VM
@@ -221,7 +223,11 @@
if (cmd.equals("load")) {
throw new AgentLoadException("Failed to load agent library");
} else {
- throw new IOException("Command failed in target VM");
+ if (message == null) {
+ throw new AttachOperationFailedException("Command failed in target VM");
+ } else {
+ throw new AttachOperationFailedException(message);
+ }
}
}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java
--- a/jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -24,15 +24,15 @@
*/
package sun.tools.attach;
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.spi.AttachProvider;
+
import java.io.InputStream;
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;
-import java.util.Properties;
/*
* Solaris implementation of HotSpotVirtualMachine.
@@ -147,11 +147,17 @@
// If non-0 it means an error but we need to special-case the
// "load" command to ensure that the right exception is thrown.
if (completionStatus != 0) {
+ // read from the stream and use that as the error message
+ String message = readErrorMessage(sis);
sis.close();
if (cmd.equals("load")) {
throw new AgentLoadException("Failed to load agent library");
} else {
- throw new IOException("Command failed in target VM");
+ if (message == null) {
+ throw new AttachOperationFailedException("Command failed in target VM");
+ } else {
+ throw new AttachOperationFailedException(message);
+ }
}
}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c
--- a/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -200,14 +200,14 @@
len = remaining;
}
- RESTARTABLE(read(fd, buf+off, len), n);
+ RESTARTABLE(read(fd, buf, len), n);
if (n == -1) {
JNU_ThrowIOExceptionWithLastError(env, "read");
} else {
if (n == 0) {
n = -1; // EOF
} else {
- (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
+ (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
}
}
return n;
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c
--- a/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c Thu May 15 10:41:25 2014 -0700
@@ -418,14 +418,14 @@
len = remaining;
}
- RESTARTABLE(read(fd, buf+off, len), n);
+ RESTARTABLE(read(fd, buf, len), n);
if (n == -1) {
JNU_ThrowIOExceptionWithLastError(env, "read");
} else {
if (n == 0) {
n = -1; // EOF
} else {
- (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
+ (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
}
}
return n;
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c
--- a/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -161,14 +161,14 @@
len = remaining;
}
- RESTARTABLE(read(fd, buf+off, len), n);
+ RESTARTABLE(read(fd, buf, len), n);
if (n == -1) {
JNU_ThrowIOExceptionWithLastError(env, "read");
} else {
if (n == 0) {
n = -1; // EOF
} else {
- (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
+ (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
}
}
return n;
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java
--- a/jdk/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -24,15 +24,15 @@
*/
package sun.tools.attach;
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.spi.AttachProvider;
+
import sun.tools.attach.HotSpotVirtualMachine;
+
import java.io.IOException;
-import java.io.File;
import java.io.InputStream;
-import java.util.Properties;
import java.util.Random;
public class WindowsVirtualMachine extends HotSpotVirtualMachine {
@@ -105,11 +105,17 @@
// read completion status
int status = readInt(is);
if (status != 0) {
+ // read from the stream and use that as the error message
+ String message = readErrorMessage(is);
// special case the load command so that the right exception is thrown
if (cmd.equals("load")) {
throw new AgentLoadException("Failed to load agent library");
} else {
- throw new IOException("Command failed in target VM");
+ if (message == null) {
+ throw new AttachOperationFailedException("Command failed in target VM");
+ } else {
+ throw new AttachOperationFailedException(message);
+ }
}
}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/windows/lib/security/java.policy
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/lib/security/java.policy Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,3 @@
+grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
+ permission java.security.AllPermission;
+};
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
--- a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Thu May 15 10:25:51 2014 -0700
+++ b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Thu May 15 10:41:25 2014 -0700
@@ -343,7 +343,7 @@
if (nread == 0) {
return (jint)-1; // EOF
} else {
- (*env)->SetByteArrayRegion(env, ba, off, (jint)nread, (jbyte *)(buf+off));
+ (*env)->SetByteArrayRegion(env, ba, off, (jint)nread, (jbyte *)(buf));
}
}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/TEST.groups
--- a/jdk/test/TEST.groups Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/TEST.groups Thu May 15 10:41:25 2014 -0700
@@ -97,7 +97,8 @@
jdk_nio = \
java/nio \
- sun/nio
+ sun/nio \
+ jdk/nio
jdk_net = \
java/net \
@@ -203,7 +204,6 @@
com/sun/jndi \
com/sun/corba \
lib/testlibrary \
- jdk/nio/zipfs \
sample
#
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java Thu May 15 10:41:25 2014 -0700
@@ -26,6 +26,7 @@
* @bug 8028994
* @author Staffan Larsen
* @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main CheckOrigin
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/com/sun/tools/attach/BasicTests.java
--- a/jdk/test/com/sun/tools/attach/BasicTests.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/com/sun/tools/attach/BasicTests.java Thu May 15 10:41:25 2014 -0700
@@ -38,7 +38,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build Agent BadAgent RedefineAgent Application Shutdown RedefineDummy RunnerUtil
+ * @run build jdk.testlibrary.* Agent BadAgent RedefineAgent Application Shutdown RedefineDummy RunnerUtil
* @run main BasicTests
*
* This test will perform a number of basic attach tests.
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/com/sun/tools/attach/PermissionTest.java
--- a/jdk/test/com/sun/tools/attach/PermissionTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/com/sun/tools/attach/PermissionTest.java Thu May 15 10:41:25 2014 -0700
@@ -34,7 +34,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build Application Shutdown
+ * @run build jdk.testlibrary.* Application Shutdown
* @run main PermissionTest
*
* Unit test for Attach API -
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/com/sun/tools/attach/ProviderTest.java
--- a/jdk/test/com/sun/tools/attach/ProviderTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/com/sun/tools/attach/ProviderTest.java Thu May 15 10:41:25 2014 -0700
@@ -33,7 +33,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build SimpleProvider
+ * @run build jdk.testlibrary.* SimpleProvider
* @run main ProviderTest
*
* The test will attach and detach to/from the running Application.
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java
--- a/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java Thu May 15 10:41:25 2014 -0700
@@ -26,6 +26,7 @@
* @summary BufferedInputStream calculates negative array size with large
* streams and mark
* @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main/othervm LargeCopyWithMark
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/lang/ProcessBuilder/SecurityManagerClinit.java
--- a/jdk/test/java/lang/ProcessBuilder/SecurityManagerClinit.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/lang/ProcessBuilder/SecurityManagerClinit.java Thu May 15 10:41:25 2014 -0700
@@ -54,9 +54,6 @@
System.getProperty("java.home") +
File.separator + "bin" + File.separator + "java";
- // A funky contrived security setup, just for bug repro purposes.
- java.security.Security.setProperty("package.access", "java.util");
-
final Policy policy =
new Policy
(new FilePermission("<>", "execute"),
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/lang/String/ToLowerCase.java
--- a/jdk/test/java/lang/String/ToLowerCase.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/lang/String/ToLowerCase.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, 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
@@ -23,7 +23,7 @@
/*
@test
- @bug 4217441 4533872 4900935 8020037 8032012
+ @bug 4217441 4533872 4900935 8020037 8032012 8041791
@summary toLowerCase should lower-case Greek Sigma correctly depending
on the context (final/non-final). Also it should handle
Locale specific (lt, tr, and az) lowercasings and supplementary
@@ -72,8 +72,10 @@
// I-dot tests
test("\u0130", turkish, "i");
test("\u0130", az, "i");
- test("\u0130", lt, "i");
- test("\u0130", Locale.US, "i");
+ test("\u0130", lt, "\u0069\u0307");
+ test("\u0130", Locale.US, "\u0069\u0307");
+ test("\u0130", Locale.JAPAN, "\u0069\u0307");
+ test("\u0130", Locale.ROOT, "\u0069\u0307");
// Remove dot_above in the sequence I + dot_above (Turkish and Azeri)
test("I\u0307", turkish, "i");
@@ -111,6 +113,12 @@
if (cp >= Character.MIN_HIGH_SURROGATE && cp <= Character.MAX_HIGH_SURROGATE) {
continue;
}
+ if (cp == 0x0130) {
+ // Although UnicodeData.txt has the lower case char as \u0069, it should be
+ // handled with the rules in SpecialCasing.txt, i.e., \u0069\u0307 in
+ // non Turkic locales.
+ continue;
+ }
int lowerCase = Character.toLowerCase(cp);
if (lowerCase == -1) { //Character.ERROR
continue;
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java
--- a/jdk/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java Thu May 15 10:41:25 2014 -0700
@@ -30,7 +30,7 @@
* @bug 6289149
* @summary test when the agent's class is missing the premain() function.
* @library /lib/testlibrary
- * @run build DummyMain
+ * @run build jdk.testlibrary.* DummyMain
* @run shell ../MakeJAR3.sh NoPremainAgent
* @run main NoPremainAgentTest
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/lang/instrument/PremainClass/PremainClassTest.java
--- a/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.java Thu May 15 10:41:25 2014 -0700
@@ -30,7 +30,7 @@
* @bug 5055293
* @summary Test non ascii characters in the Premain-Class attribute.
* @library /lib/testlibrary
- * @run build DummyMain
+ * @run build jdk.testlibrary.* DummyMain
* @run main PremainClassTest
*/
public class PremainClassTest {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java
--- a/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java Thu May 15 10:41:25 2014 -0700
@@ -30,7 +30,7 @@
* @bug 6289149
* @summary test when the agent's class has a zero arg premain() function.
* @library /lib/testlibrary
- * @run build DummyMain
+ * @run build jdk.testlibrary.* DummyMain
* @run shell ../MakeJAR3.sh ZeroArgPremainAgent
* @run main ZeroArgPremainAgentTest
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
--- a/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java Thu May 15 10:41:25 2014 -0700
@@ -31,7 +31,7 @@
* @author Mandy Chung
*
* @library /lib/testlibrary/
- * @build CollectionUsageThreshold MemoryUtil RunUtil
+ * @build jdk.testlibrary.* CollectionUsageThreshold MemoryUtil RunUtil
* @run main/timeout=300 CollectionUsageThreshold
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java Thu May 15 10:41:25 2014 -0700
@@ -31,7 +31,7 @@
* @author Mandy Chung
*
* @library /lib/testlibrary/
- * @build LowMemoryTest MemoryUtil RunUtil
+ * @build jdk.testlibrary.* LowMemoryTest MemoryUtil RunUtil
* @run main/timeout=600 LowMemoryTest
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/net/Authenticator/B8034170.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/Authenticator/B8034170.java Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2014, 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.net.*;
+import java.util.*;
+
+/**
+ * @test
+ * @bug 8034170
+ * @summary Digest authentication interop issue
+ * @run main/othervm B8034170 unquoted
+ * @run main/othervm -Dhttp.auth.digest.quoteParameters=true B8034170 quoted
+ */
+
+public class B8034170 {
+
+ static boolean expectQuotes;
+
+ static class BasicServer extends Thread {
+
+ ServerSocket server;
+
+ Socket s;
+ InputStream is;
+ OutputStream os;
+
+ static final String realm = "wallyworld";
+
+ String reply1 = "HTTP/1.1 401 Unauthorized\r\n"+
+ "WWW-Authenticate: Digest realm=\""+realm+"\", qop=\"auth\"" +
+ ", nonce=\"8989de95ea2402b64d73cecdb15da255\"" +
+ ", opaque=\"bbfb4c9ee92ddccc73521c3e6e841ba2\"\r\n\r\n";
+
+ String OKreply = "HTTP/1.1 200 OK\r\n"+
+ "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
+ "Server: Apache/1.3.14 (Unix)\r\n" +
+ "Connection: close\r\n" +
+ "Content-Type: text/plain; charset=iso-8859-1\r\n" +
+ "Content-Length: 10\r\n\r\n";
+
+ String ERRreply = "HTTP/1.1 500 Internal server error\r\n"+
+ "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
+ "Server: Apache/1.3.14 (Unix)\r\n" +
+ "Connection: close\r\n" +
+ "Content-Length: 0\r\n\r\n";
+
+ BasicServer (ServerSocket s) {
+ server = s;
+ }
+
+ int readAll (Socket s, byte[] buf) throws IOException {
+ int pos = 0;
+ InputStream is = s.getInputStream ();
+ // wait two seconds for request, as client doesn't close
+ // the connection
+ s.setSoTimeout(2000);
+ try {
+ int n;
+ while ((n=is.read(buf, pos, buf.length-pos)) > 0)
+ pos +=n;
+ } catch (SocketTimeoutException x) { }
+ return pos;
+ }
+
+ public void run () {
+ byte[] buf = new byte[5000];
+ try {
+ System.out.println ("Server 1: accept");
+ s = server.accept ();
+ System.out.println ("accepted");
+ os = s.getOutputStream();
+ os.write (reply1.getBytes());
+ readAll (s, buf);
+ s.close ();
+
+ System.out.println ("Server 2: accept");
+ s = server.accept ();
+ System.out.println ("accepted");
+ os = s.getOutputStream();
+ int count = readAll (s, buf);
+ String reply = new String(buf, 0, count);
+
+ boolean error;
+
+ if (expectQuotes) {
+ error = false;
+ if (!reply.contains("qop=\"auth\"")) {
+ System.out.println ("Expecting quoted qop. Not found");
+ error = true;
+ }
+ if (!reply.contains("algorithm=\"MD5\"")) {
+ System.out.println ("Expecting quoted algorithm. Not found");
+ error = true;
+ }
+ } else {
+ error = false;
+ if (!reply.contains("qop=auth")) {
+ System.out.println ("Expecting unquoted qop. Not found");
+ error = true;
+ }
+ if (!reply.contains("algorithm=MD5")) {
+ System.out.println ("Expecting unquoted algorithm. Not found");
+ error = true;
+ }
+ }
+ if (error) {
+ os.write(ERRreply.getBytes());
+ os.flush();
+ s.close();
+ } else {
+ os.write((OKreply+"HelloWorld").getBytes());
+ os.flush();
+ s.close();
+ }
+ }
+ catch (Exception e) {
+ System.out.println (e);
+ }
+ finished ();
+ }
+
+ public synchronized void finished () {
+ notifyAll();
+ }
+
+ }
+
+ static class MyAuthenticator3 extends Authenticator {
+ PasswordAuthentication pw;
+ MyAuthenticator3 () {
+ super ();
+ pw = new PasswordAuthentication ("user", "passwordNotCheckedAnyway".toCharArray());
+ }
+
+ public PasswordAuthentication getPasswordAuthentication ()
+ {
+ System.out.println ("Auth called");
+ return pw;
+ }
+ }
+
+
+ static void read (InputStream is) throws IOException {
+ int c;
+ System.out.println ("reading");
+ while ((c=is.read()) != -1) {
+ System.out.write (c);
+ }
+ System.out.println ("");
+ System.out.println ("finished reading");
+ }
+
+ public static void main (String args[]) throws Exception {
+ expectQuotes = args[0].equals("quoted");
+
+ MyAuthenticator3 auth = new MyAuthenticator3 ();
+ Authenticator.setDefault (auth);
+ ServerSocket ss = new ServerSocket (0);
+ int port = ss.getLocalPort ();
+ BasicServer server = new BasicServer (ss);
+ synchronized (server) {
+ server.start();
+ System.out.println ("client 1");
+ URL url = new URL ("http://localhost:"+port+"/d1/d2/d3/foo.html");
+ URLConnection urlc = url.openConnection ();
+ InputStream is = urlc.getInputStream ();
+ read (is);
+ is.close ();
+ }
+ }
+}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/net/URLPermission/nstest/lookup.sh
--- a/jdk/test/java/net/URLPermission/nstest/lookup.sh Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh Thu May 15 10:41:25 2014 -0700
@@ -26,7 +26,7 @@
# @library /lib/testlibrary
# @compile -XDignore.symbol.file=true SimpleNameService.java
# LookupTest.java SimpleNameServiceDescriptor.java
-# @build jdk.testlibrary.Utils
+# @build jdk.testlibrary.*
# @run shell/timeout=50 lookup.sh
#
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/util/Properties/CompatibilityTest.java
--- a/jdk/test/java/util/Properties/CompatibilityTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/util/Properties/CompatibilityTest.java Thu May 15 10:41:25 2014 -0700
@@ -25,8 +25,6 @@
* @test
* @bug 8005280 8004371
* @summary Compatibility test
- * @run main CompatibilityTest
- * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider CompatibilityTest
*/
import java.io.FileInputStream;
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/util/Properties/ConcurrentLoadAndStoreXML.java
--- a/jdk/test/java/util/Properties/ConcurrentLoadAndStoreXML.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/util/Properties/ConcurrentLoadAndStoreXML.java Thu May 15 10:41:25 2014 -0700
@@ -25,9 +25,6 @@
* @bug 8005281
* @summary Test that the Properties storeToXML and loadFromXML methods are
* thread safe
- * @run main ConcurrentLoadAndStoreXML
- * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider ConcurrentLoadAndStoreXML
-
*/
import java.io.*;
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/util/Properties/CustomProvider.java
--- a/jdk/test/java/util/Properties/CustomProvider.java Thu May 15 10:25:51 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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
- * @bug 8000354
- * @summary Test
- * @compile -XDignore.symbol.file CustomProvider.java MyXmlPropertiesProvider.java
- * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=MyXmlPropertiesProvider CustomProvider
- */
-
-import java.util.*;
-import java.io.*;
-
-/**
- * Sanity test to verify that the property sun.util.spi.XmlPropertiesProvider
- * can be used to specify a custom provider for loading/storing properties
- * in XML format.
- */
-public class CustomProvider {
-
- public static void main(String[] args) throws IOException {
- String provider = System.getProperty("sun.util.spi.XmlPropertiesProvider");
- assertTrue(provider != null, "sun.util.spi.XmlPropertiesProvider not set");
-
- OutputStream out = new ByteArrayOutputStream();
- InputStream in = new ByteArrayInputStream(new byte[100]);
-
- Properties props;
-
- props = new Properties();
- props.loadFromXML(in);
-
- props = System.getProperties();
- props.storeToXML(out, "comment");
- props.storeToXML(out, "comment", "UTF-8");
-
- // check that the provider's load and store methods have been invoked
-
- assertTrue(MyXmlPropertiesProvider.createCount() == 1,
- "Provider should only be created once");
- assertTrue(MyXmlPropertiesProvider.loadCount() == 1,
- "load method expected to be called once");
- assertTrue(MyXmlPropertiesProvider.storeCount() == 2,
- "store method expected to be called twice");
- }
-
- static void assertTrue(boolean b, String msg) {
- if (!b) throw new RuntimeException(msg);
- }
-}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/util/Properties/LoadAndStoreXML.java
--- a/jdk/test/java/util/Properties/LoadAndStoreXML.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/util/Properties/LoadAndStoreXML.java Thu May 15 10:41:25 2014 -0700
@@ -23,16 +23,28 @@
/*
* @test
- * @bug 8000354 8000685 8004371
+ * @bug 8000354 8000685 8004371 8043119
* @summary Basic test of storeToXML and loadToXML
- * @run main LoadAndStoreXML
- * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider LoadAndStoreXML
*/
-import java.io.*;
-import java.util.*;
-import java.security.*;
-import java.nio.file.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.InvalidPropertiesFormatException;
+import java.util.Properties;
+import java.util.PropertyPermission;
public class LoadAndStoreXML {
@@ -66,6 +78,50 @@
}
/**
+ * A {@code ByteArrayInputStream} that allows testing if the
+ * {@code close} method has been invoked.
+ */
+ static class TestInputStream extends ByteArrayInputStream {
+ private boolean closed;
+
+ TestInputStream(byte[] buf) {
+ super(buf);
+ }
+
+ boolean isOpen() {
+ return !closed;
+ }
+
+ public void close() throws IOException {
+ try {
+ super.close();
+ } finally {
+ closed = true;
+ }
+ }
+ }
+
+ /**
+ * A {@code ByteArrayOutputStream} that allows testing if the
+ * {@code close} method has been invoked.
+ */
+ static class TestOutputStream extends ByteArrayOutputStream {
+ private boolean closed;
+
+ boolean isOpen() {
+ return !closed;
+ }
+
+ public void close() throws IOException {
+ try {
+ super.close();
+ } finally {
+ closed = true;
+ }
+ }
+ }
+
+ /**
* Sanity test that properties saved with Properties#storeToXML can be
* read with Properties#loadFromXML.
*/
@@ -79,12 +135,16 @@
props.put("k4", "\u7532\u9aa8\u6587");
props.put("k5", "/lib/jaxp.properties");
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ TestOutputStream out = new TestOutputStream();
props.storeToXML(out, null, encoding);
+ if (!out.isOpen())
+ throw new RuntimeException("OutputStream closed by storeToXML");
Properties p = new Properties();
- ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+ TestInputStream in = new TestInputStream(out.toByteArray());
p.loadFromXML(in);
+ if (in.isOpen())
+ throw new RuntimeException("InputStream not closed by loadFromXML");
if (!p.equals(props)) {
System.err.println("stored: " + props);
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/util/Properties/LoadAndStoreXMLWithDefaults.java
--- a/jdk/test/java/util/Properties/LoadAndStoreXMLWithDefaults.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/java/util/Properties/LoadAndStoreXMLWithDefaults.java Thu May 15 10:41:25 2014 -0700
@@ -35,58 +35,17 @@
*/
public class LoadAndStoreXMLWithDefaults {
- public static enum StoreMethod {
- // Note: this case will test the default provider when available,
- // and the basic provider when it's not.
- PROPERTIES {
- @Override
- public String writeToXML(Properties p) throws IOException {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- p.storeToXML(baos, "Test 8016344");
- return baos.toString();
- }
- @Override
- public Properties loadFromXML(String xml, Properties defaults)
- throws IOException {
- final ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("UTF-8"));
- Properties p = new Properties(defaults);
- p.loadFromXML(bais);
- return p;
- }
- },
- // Note: this case always test the basic provider, which is always available.
- // so sometimes it's just a dup with the previous case...
- BASICPROVIDER {
- @Override
- public String writeToXML(Properties p) throws IOException {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- jdk.internal.util.xml.BasicXmlPropertiesProvider provider =
- new jdk.internal.util.xml.BasicXmlPropertiesProvider();
- provider.store(p, baos, "Test 8016344", "UTF-8");
- return baos.toString();
- }
- @Override
- public Properties loadFromXML(String xml, Properties defaults)
- throws IOException {
- final ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("UTF-8"));
- Properties p = new Properties(defaults);
- jdk.internal.util.xml.BasicXmlPropertiesProvider provider =
- new jdk.internal.util.xml.BasicXmlPropertiesProvider();
- provider.load(p, bais);
- return p;
- }
- };
- public abstract String writeToXML(Properties p) throws IOException;
- public abstract Properties loadFromXML(String xml, Properties defaults)
- throws IOException;
- public String displayName() {
- switch(this) {
- case PROPERTIES: return "Properties.storeToXML";
- case BASICPROVIDER: return "BasicXmlPropertiesProvider.store";
- default:
- throw new UnsupportedOperationException(this.name());
- }
- }
+ static String writeToXML(Properties props) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ props.storeToXML(baos, "Test 8016344");
+ return baos.toString();
+ }
+
+ static Properties loadFromXML(String xml, Properties defaults) throws IOException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("UTF-8"));
+ Properties props = new Properties(defaults);
+ props.loadFromXML(bais);
+ return props;
}
static enum Objects { OBJ1, OBJ2, OBJ3 };
@@ -106,63 +65,59 @@
p3.setProperty("p1.and.p2.and.p3.prop", "prop9-p3");
p3.setProperty("p2.and.p3.prop", "prop10-p3");
- for (StoreMethod m : StoreMethod.values()) {
- System.out.println("Testing with " + m.displayName());
- Properties P1 = m.loadFromXML(m.writeToXML(p1), null);
- Properties P2 = m.loadFromXML(m.writeToXML(p2), P1);
- Properties P3 = m.loadFromXML(m.writeToXML(p3), P2);
+ Properties P1 = loadFromXML(writeToXML(p1), null);
+ Properties P2 = loadFromXML(writeToXML(p2), P1);
+ Properties P3 = loadFromXML(writeToXML(p3), P2);
- testResults(m, p1, P1, p2, P2, p3, P3);
+ testResults(p1, P1, p2, P2, p3, P3);
- // Now check that properties whose keys or values are objects
- // are skipped.
+ // Now check that properties whose keys or values are objects
+ // are skipped.
- System.out.println("Testing with " + m.displayName() + " and Objects");
- P1.put("p1.object.prop", Objects.OBJ1);
- P1.put(Objects.OBJ1, "p1.object.prop");
- P1.put("p2.object.prop", "p2.object.prop");
- P2.put("p2.object.prop", Objects.OBJ2);
- P2.put(Objects.OBJ2, "p2.object.prop");
- P3.put("p3.object.prop", Objects.OBJ3);
- P3.put(Objects.OBJ3, "p3.object.prop");
+ P1.put("p1.object.prop", Objects.OBJ1);
+ P1.put(Objects.OBJ1, "p1.object.prop");
+ P1.put("p2.object.prop", "p2.object.prop");
+ P2.put("p2.object.prop", Objects.OBJ2);
+ P2.put(Objects.OBJ2, "p2.object.prop");
+ P3.put("p3.object.prop", Objects.OBJ3);
+ P3.put(Objects.OBJ3, "p3.object.prop");
- Properties PP1 = m.loadFromXML(m.writeToXML(P1), null);
- Properties PP2 = m.loadFromXML(m.writeToXML(P2), PP1);
- Properties PP3 = m.loadFromXML(m.writeToXML(P3), PP2);
+ Properties PP1 = loadFromXML(writeToXML(P1), null);
+ Properties PP2 = loadFromXML(writeToXML(P2), PP1);
+ Properties PP3 = loadFromXML(writeToXML(P3), PP2);
- p1.setProperty("p2.object.prop", "p2.object.prop");
- try {
- testResults(m, p1, PP1, p2, PP2, p3, PP3);
- } finally {
- p1.remove("p2.object.prop");
- }
+ p1.setProperty("p2.object.prop", "p2.object.prop");
+ try {
+ testResults(p1, PP1, p2, PP2, p3, PP3);
+ } finally {
+ p1.remove("p2.object.prop");
}
}
- public static void testResults(StoreMethod m, Properties... pps) {
+ public static void testResults(Properties... pps) {
for (int i=0 ; i < pps.length ; i += 2) {
if (!pps[i].equals(pps[i+1])) {
- System.err.println(m.displayName() +": P" + (i/2+1)
+ System.err.println("P" + (i/2+1)
+ " Reloaded properties differ from original");
System.err.println("\toriginal: " + pps[i]);
System.err.println("\treloaded: " + pps[i+1]);
- throw new RuntimeException(m.displayName() +": P" + (i/2+1)
+ throw new RuntimeException("P" + (i/2+1)
+ " Reloaded properties differ from original");
}
if (!pps[i].keySet().equals(pps[i+1].keySet())) {
- System.err.println(m.displayName() +": P" + (i/2+1)
+ System.err.println("P" + (i/2+1)
+ " Reloaded property names differ from original");
System.err.println("\toriginal: " + pps[i].keySet());
System.err.println("\treloaded: " + pps[i+1].keySet());
- throw new RuntimeException(m.displayName() +": P" + (i/2+1)
+ throw new RuntimeException("P" + (i/2+1)
+ " Reloaded property names differ from original");
}
if (!pps[i].stringPropertyNames().equals(pps[i+1].stringPropertyNames())) {
- System.err.println(m.displayName() +": P" + (i/2+1)
+ System.err.println("P" + (i/2+1)
+ " Reloaded string property names differ from original");
System.err.println("\toriginal: " + pps[i].stringPropertyNames());
System.err.println("\treloaded: " + pps[i+1].stringPropertyNames());
- throw new RuntimeException(m.displayName() +": P" + (i/2+1)
+ throw new RuntimeException("P" + (i/2+1)
+ " Reloaded string property names differ from original");
}
}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/java/util/Properties/MyXmlPropertiesProvider.java
--- a/jdk/test/java/util/Properties/MyXmlPropertiesProvider.java Thu May 15 10:25:51 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.util.*;
-import java.io.*;
-
-public class MyXmlPropertiesProvider
- extends sun.util.spi.XmlPropertiesProvider
-{
- private static int createCount;
- private static int loadCount;
- private static int storeCount;
-
- static int createCount() { return createCount; }
- static int loadCount() { return loadCount; }
- static int storeCount() { return storeCount; }
-
- public MyXmlPropertiesProvider() {
- createCount++;
- }
-
- @Override
- public void load(Properties props, InputStream in)
- throws IOException, InvalidPropertiesFormatException
- {
- loadCount++;
- }
-
- @Override
- public void store(Properties props, OutputStream out,
- String comment, String encoding)
- throws IOException
- {
- storeCount++;
- }
-}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/javax/management/monitor/StartStopTest.java
--- a/jdk/test/javax/management/monitor/StartStopTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/javax/management/monitor/StartStopTest.java Thu May 15 10:41:25 2014 -0700
@@ -28,7 +28,7 @@
* monitors are started and stopped in a loop.
* @author Luis-Miguel Alventosa
* @library /lib/testlibrary
- * @run build jdk.testlibrary.Utils
+ * @build jdk.testlibrary.*
* @run clean StartStopTest
* @run build StartStopTest
* @run main/othervm/timeout=300 StartStopTest 1
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/jdk/nio/zipfs/Basic.java
--- a/jdk/test/jdk/nio/zipfs/Basic.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/Basic.java Thu May 15 10:41:25 2014 -0700
@@ -31,8 +31,11 @@
/**
*
* @test
- * @bug 8038500
+ * @bug 8038500 8040059
* @summary Basic test for zip provider
+ *
+ * @run main Basic
+ * @run main/othervm/policy=test.policy Basic
*/
public class Basic {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/jdk/nio/zipfs/PathOps.java
--- a/jdk/test/jdk/nio/zipfs/PathOps.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/PathOps.java Thu May 15 10:41:25 2014 -0700
@@ -29,8 +29,11 @@
/**
*
* @test
- * @bug 8038500
+ * @bug 8038500 8040059
* @summary Tests path operations for zip provider.
+ *
+ * @run main PathOps
+ * @run main/othervm/policy=test.policy.readonly PathOps
*/
public class PathOps {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/jdk/nio/zipfs/ZFSTests.java
--- a/jdk/test/jdk/nio/zipfs/ZFSTests.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/ZFSTests.java Thu May 15 10:41:25 2014 -0700
@@ -22,8 +22,11 @@
*/
/* @test
- @bug 7156873
- @summary ZipFileSystem regression tests
+ * @bug 7156873 8040059
+ * @summary ZipFileSystem regression tests
+ *
+ * @run main ZFSTests
+ * @run main/othervm/policy=test.policy ZFSTests
*/
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/jdk/nio/zipfs/ZipFSTester.java
--- a/jdk/test/jdk/nio/zipfs/ZipFSTester.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/ZipFSTester.java Thu May 15 10:41:25 2014 -0700
@@ -40,8 +40,10 @@
*
* @test
* @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
- * 7157656 8002390 7012868 7012856 8015728 8038500
+ * 7157656 8002390 7012868 7012856 8015728 8038500 8040059
* @summary Test Zip filesystem provider
+ * @run main ZipFSTester
+ * @run main/othervm/policy=test.policy ZipFSTester
*/
public class ZipFSTester {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/jdk/nio/zipfs/test.policy
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/nio/zipfs/test.policy Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,16 @@
+grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
+ permission java.io.FilePermission "<>", "read,write";
+ permission java.lang.RuntimePermission "fileSystemProvider";
+ permission java.util.PropertyPermission "*", "read";
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
+ permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
+};
+
+grant {
+ permission java.io.FilePermission "<>","read,write,delete";
+ permission java.util.PropertyPermission "test.jdk","read";
+ permission java.util.PropertyPermission "test.src","read";
+ permission java.util.PropertyPermission "user.dir","read";
+};
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/jdk/nio/zipfs/test.policy.readonly
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/nio/zipfs/test.policy.readonly Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,12 @@
+grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
+ permission java.io.FilePermission "<>", "read,write";
+ permission java.lang.RuntimePermission "fileSystemProvider";
+ permission java.util.PropertyPermission "*", "read";
+};
+
+grant {
+ permission java.io.FilePermission "<>","read";
+ permission java.util.PropertyPermission "test.jdk","read";
+ permission java.util.PropertyPermission "test.src","read";
+ permission java.util.PropertyPermission "user.dir","read";
+};
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/lib/security/java.policy/Ext_AllPolicy.java
--- a/jdk/test/lib/security/java.policy/Ext_AllPolicy.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/lib/security/java.policy/Ext_AllPolicy.java Thu May 15 10:41:25 2014 -0700
@@ -30,12 +30,24 @@
import java.security.*;
public class Ext_AllPolicy {
- public static void main (String[] args) {
- FilePermission mine = new FilePermission("/tmp/bar", "read");
- SecurityManager sm = System.getSecurityManager();
+ public static void main (String[] args) {
+ boolean allPerms = args.length == 1 && args[0].equals("AllPermission");
+ FilePermission mine = new FilePermission("/tmp/bar", "read");
+ SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(mine);
+ if (sm != null) {
+ try {
+ sm.checkPermission(mine);
+ if (!allPerms) {
+ // Default has no privilege.
+ throw new RuntimeException(mine + " expected to deny access");
}
+ } catch (AccessControlException e) {
+ if (allPerms) {
+ // expected all permissions granted
+ throw e;
+ }
+ }
}
+ }
}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/lib/security/java.policy/Ext_AllPolicy.sh
--- a/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh Thu May 15 10:41:25 2014 -0700
@@ -22,7 +22,7 @@
#
# @test
-# @bug 4215035
+# @bug 4215035 8040059
# @summary standard extensions path is hard-coded in default system policy file
#
# @build Ext_AllPolicy
@@ -81,6 +81,9 @@
rm Ext_AllPolicy.class
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \
- -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy
+ -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy || exit 10
+${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \
+ -Djava.security.policy=${TESTSRC}${FS}test.policy \
+ -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy AllPermission
exit $?
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/lib/security/java.policy/test.policy
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/security/java.policy/test.policy Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,3 @@
+grant codeBase "file:${{java.ext.dirs}}/*" {
+ permission java.security.AllPermission;
+};
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java
--- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java Thu May 15 10:41:25 2014 -0700
@@ -41,7 +41,7 @@
* @test
* @bug 6434402 8004926
* @library /lib/testlibrary
- * @build jdk.testlibrary.ProcessTools
+ * @build jdk.testlibrary.*
* @build TestManager TestApplication CustomLauncherTest
* @run main/othervm CustomLauncherTest
* @author Jaroslav Bachorik
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Thu May 15 10:41:25 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -616,7 +616,7 @@
final boolean[] checks = new boolean[3];
jcmd(
line -> {
- if (line.equals("java.lang.RuntimeException: Invalid agent state")) {
+ if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
checks[0] = true;
}
},
@@ -627,7 +627,7 @@
jcmd(
line -> {
- if (line.equals("java.lang.RuntimeException: Invalid agent state")) {
+ if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
checks[1] = true;
}
},
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java
--- a/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java Thu May 15 10:41:25 2014 -0700
@@ -28,6 +28,7 @@
* @author Robert Field
* @library /lib/testlibrary
* @compile -XDignore.symbol.file ManyNewInstanceAnonTest.java
+ * @build jdk.testlibrary.*
* @run main ClassFileInstaller ManyNewInstanceAnonTest
* @run main/othervm -Xbootclasspath/a:. -Xverify:all ManyNewInstanceAnonTest
* @run main/othervm -Xbootclasspath/a:. -Xverify:all -Dsun.reflection.noInflation=true ManyNewInstanceAnonTest
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/security/validator/ConstructorTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/validator/ConstructorTest.java Thu May 15 10:41:25 2014 -0700
@@ -0,0 +1,467 @@
+/*
+ * Copyright (c) 2014, 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
+ * @bug 6996377
+ * @summary shrink duplicate code in the constructor of PKIXValidator
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.security.cert.TrustAnchor;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.X509CertSelector;
+import javax.security.auth.x500.X500Principal;
+import java.util.Date;
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Enumeration;
+import java.util.Collection;
+import sun.security.validator.Validator;
+import sun.security.validator.PKIXValidator;
+
+public class ConstructorTest {
+
+ // COMMON-OPTS: All certs created with the following common options:
+ // -keystore -storepass -keypass -keyalg rsa
+ // -keysize 2048 -validity 720 -sigalg sha256withrsa
+
+ // keytool -alias root -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC3jCCAcagAwIBAgIEInKZgjANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwRS\n" +
+ "b290MB4XDTE0MDUwODE4MjcwOFoXDTE2MDQyNzE4MjcwOFowDzENMAsGA1UEAxME\n" +
+ "Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIzgMkrCZD7PuoFb\n" +
+ "fmtAd2+Td6nA9sgBd8Z3NjQgP6nwyn79svaVV9XAVLTrLian72wV/1Kbq/6HUXQQ\n" +
+ "AqyUAvobDwXeIAmE4+D7qcZxiEJgVNr2Ddv1bbS8Y0/Ta72qzjFiEPMO3Y2GP52C\n" +
+ "ssKQpsdNttHfM9c73cKUspobc3p51k2lkynheshCSNOWxR/Rvsl/gcbEFg8vIEHV\n" +
+ "oJPwKSrABc4sWiiXQj0yLVW+DKVEFuWNqqitcikQLZFpgOYv8P1SjhJFkcA9s0oN\n" +
+ "sbvKO2VF141h161i0AFddTsGE85A3j42qEdwQ0cs9gyAoeU865TFvxCuhSqSgJ3a\n" +
+ "Mdgn7ssCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw\n" +
+ "HQYDVR0OBBYEFFQY2UJynMSoS7Tf/+DvNPp/ZxXfMA0GCSqGSIb3DQEBCwUAA4IB\n" +
+ "AQAeXRQnEhxNl8lrcGY1U1LbIdrNMlGnc0JbgwiVYwRlE3+u4GvDae1VueXyY6nw\n" +
+ "8m63H3Q/Do9/72aw2Q0FSwvDg+k5ssj+gXQ3Gyx8xsVPJEG0TizOSwnWiZtWu65w\n" +
+ "14p5TB8P8wdPEs6sfE9oheiKhDRjBZHIfqMd4DaBiM9N9qHpSwTJc02BB2KnGwga\n" +
+ "yiYNJbce7GFKn/exryj972n/Nl4xy1WdZrRwTBbV21/GINw+xdXn1+FD95EGqGlr\n" +
+ "Sb4+G7U7Ydo+xFpVQnrqxZe98pI5W2bG7VSKvIzcPxfL5/tjwtNaqhiD7wIBNHVx\n" +
+ "ZeJevm41O9qFQEdXNyVGpB+u\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias int -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String INTERMED =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC/jCCAeagAwIBAgIEDkzdijANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwRS\n" +
+ "b290MB4XDTE0MDUwODE4MjcyNFoXDTE2MDQyNzE4MjcyNFowDjEMMAoGA1UEAxMD\n" +
+ "SW50MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwslILfgvXPxdRgu8\n" +
+ "4SnrZJsSzb/XvYwYGAKTSvsDaI1nXypBbwDGz87+YPpZSJcExcS8I8GBKqN6kXIh\n" +
+ "YvJ9yMGJX8wdwoMQpw2ZfJpzfw9Nqtlhv8/q5kPlaDghJ+nGNwy5lyYNOzDMVht0\n" +
+ "1XQG65C+l7m52lDJ478tGRZEFkx0aTh2QUBI59iNji6r2Buyeiijhg4YBrvIlYLK\n" +
+ "OAHxru4N/Y2Cq3ECUUvm7Lf8tM8yrINS8FLT+pmNcLj8AKkGW8cFFaiGPMyon0/m\n" +
+ "4iJB7ZaeG+BGm9TvBv93cphAsM2tY+S+P/dLfI01ltucibPkSglmquUSA0xW9ilv\n" +
+ "PEYWqQIDAQABo2MwYTAfBgNVHSMEGDAWgBRUGNlCcpzEqEu03//g7zT6f2cV3zAP\n" +
+ "BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU1jeG+pzz\n" +
+ "WnHa+0PfJNw9JTrZaoMwDQYJKoZIhvcNAQELBQADggEBABRshh0oJ8Dq87Tgcf3w\n" +
+ "ERVZ/uDWKj76UXWQ3uvKMhnNxKN/vs1rCfhovkptn39CXndOb8m6UkvmMjDtJsiO\n" +
+ "Oq/DiR6NngCy5yJ5hMuBsdQ2QVvdiqG4Sb+vOaQ2TNQNEHEWC7sB0ztImjxlqDtq\n" +
+ "yvof5pd8pHeZJNyDo5cHw1cpoUI9GLz6CK5i0wUlBvsYERIX5aRqxqdtKgBefHFN\n" +
+ "S2ChTRB16A5C1h+Lu79KnoeS33lZt1VeebIA7hvaHkqhGGpncutEYgT8QNFFpjM8\n" +
+ "yFCjZG+ZuUD/s5hd/xHnPdJzR+RWVKMjjVCTpnni3+NHXo2fh0G8YFhdHQ2F/YFI\n" +
+ "ig0=\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias user -ext ku:c=digitalSignature
+ // -ext eku=clientAuth
+ private static final String USER =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIDAjCCAeqgAwIBAgIEKgsK2DANBgkqhkiG9w0BAQsFADAOMQwwCgYDVQQDEwNJ\n" +
+ "bnQwHhcNMTQwNTA4MTgyNzI3WhcNMTYwNDI3MTgyNzI3WjAPMQ0wCwYDVQQDEwRV\n" +
+ "c2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArBFLJZ1liQAEkEyJ\n" +
+ "9vAiViRXtDDV+lc62DR4DBj1/Vsw9djVOxmwDKM0+jj83F4Qn9vulr+xp2aZzx4Y\n" +
+ "GiJgbtoxPvZmwNv4MPCNX+fgl/+C0nFKOoSYfHb/tK0Jj6u8HOmQqkbSmGJd/yRL\n" +
+ "qavapRvhS94tFhiNK7wwLAK9AZ+r7cTEBtUSqfaS7mY7tUsERcZs6z3+rmsuxWw6\n" +
+ "/xnNTIVWjdUSbEnjZCdkfZ0cjFONotL6aKoa6YXzohzgA5c3SJZqscEaz4yPkMvl\n" +
+ "7bGy7cn6xjfbb5V3oNqo1dtF3Jm8zp0q8Zgvc47l+DAoGIHSpDhPGX+qSWOTwRla\n" +
+ "QT6NDwIDAQABo2cwZTAfBgNVHSMEGDAWgBTWN4b6nPNacdr7Q98k3D0lOtlqgzAT\n" +
+ "BgNVHSUEDDAKBggrBgEFBQcDAjAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFE/p\n" +
+ "UEn8+capIj2+V+7GoxUhdVnWMA0GCSqGSIb3DQEBCwUAA4IBAQBkEyFJ/1CCMoU3\n" +
+ "C1sYoq4Wt36z3e4Z2rMjfpFXcagqOQaq+hq+/eG8gDE50tOp30nZF7BxSv0RKnxa\n" +
+ "KSkrKcupwgPJOZZWVR6ycV3xWm4QleLuDJh3NdK0o8vvIwLQP47fXURzEXTpGodl\n" +
+ "+hGx7jcghsOKftBDCaleywam4jcZ5YPfp5Ayev0pK/Euf0kZgZAhRM33uJVVfEns\n" +
+ "UotoGK7SL6hZMCrreVlXygof19p531Ps5xMqu0y2u2xztjVQJ+gPU5zcYbjByUl+\n" +
+ "pY+wDPb8XU1EoLl7J5UyayXlk0c3KG/5f+CrVi2HtRfCcKLBf8/MH6OFIpX9O77p\n" +
+ "Qq3r+W/l\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias red-ta-key -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String RED_ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC5jCCAc6gAwIBAgIEWK8vRTANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDEwhS\n" +
+ "ZWQgUm9vdDAeFw0xNDA1MDgxODI3MTNaFw0xNjA0MjcxODI3MTNaMBMxETAPBgNV\n" +
+ "BAMTCFJlZCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjpMy\n" +
+ "Qh5yq4R3DrwsWaBZoCR+gda4a1PjGpjlQW/Au6R3hwUDAunkQIz/sX1CnLLJ7cks\n" +
+ "4m6ba2wjYE3NbVP9D3HozLAv2ErB75/F3evRu5UvzkGLkamyHJBY0xEyFyOaD4MC\n" +
+ "hhlo8dDEY++YL8Od+m4i56fYXQlTT94u20I+6hZxeIpJxFSHyouZg06jb+URibi0\n" +
+ "e7I3JApWghgcDfgEXZWlCmB8IswYPdd+XWRFDNc4rSWueRP+SeQOFx9x1jM6+skP\n" +
+ "DGLpuaChO7cqsUxYnsEx9zhdxQ+v4V3vOye/GigpRaO7WvgPB4g5sYhFlwZ/tp+A\n" +
+ "KQebXExXCGOOQUoFEwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB\n" +
+ "/wQEAwIBBjAdBgNVHQ4EFgQUYL8o0Ku7Irg33xzCgA4q1PFz6IQwDQYJKoZIhvcN\n" +
+ "AQELBQADggEBAGSVpI7Qmb0oupBCs+tXlJ4/+TX6eBGcHydaT/2hlgEEdT7S7y6O\n" +
+ "iMC8C8wlEKTLZ6MJSxjeFTIO62OkTjCsGtk+BHTaE81QL5rxjGFkvtuQrwck8gHg\n" +
+ "fAb7daF9ZVLz6B8+cX047xZHx9ZGM/ID+GJg/3fk17WA2BhW1Xkzskby5AWpBDol\n" +
+ "i6+zEod0uZhpHiWwVSfHlEA+rnkhW632oVaVNNDkeUhsCxrU0k7nlQx8bG5bmUso\n" +
+ "1MaPP1kRKvcy0UGx6q3s8pcrKw0X1S66n7HV+WbQebg83U0MVE1r/J0Cfi0jMS/x\n" +
+ "ZUVXs7rjCGFhwfiT/kybKD8adrGHSmLhKs0=\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias orange-ta-key -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String ORANGE_ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC7DCCAdSgAwIBAgIEQPSszTANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtP\n" +
+ "cmFuZ2UgUm9vdDAeFw0xNDA1MDgxODI3MTRaFw0xNjA0MjcxODI3MTRaMBYxFDAS\n" +
+ "BgNVBAMTC09yYW5nZSBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+ "AQEAknfh3lKWVQxl2w/eRSza6+0+zeTtMkQFCEFpGJsisDK5XOU1HcJMP4QUteWM\n" +
+ "tg1SGO9bjpiKqJ7JVRnzOC3q6erBj2LmwpWW7p12tg6ENOQfsy6tRZLlQWMFGBkT\n" +
+ "Tatsg9HwKpr6itvk2wERh18AcIqSjtN94kGTljP1qf9gMd31G5d/HyG6EwMZukJm\n" +
+ "4/EFpzh3fVwr/EN1WzrYlsBOA+3Tru/k0p8wP6Bomrx1vAEUqRWSLWxsa7we76jL\n" +
+ "H/kMkyWENyjd/A2c5CwscoG+KSx9cifYnSqrUAmpY88KKuZG2Y1+9ablUEwXW4Gh\n" +
+ "RYLCGIgxp6NrtFG/eUcDBgtEwQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+ "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUPvRE9j3GPGcc3dNGrVrQoWDb9RMwDQYJ\n" +
+ "KoZIhvcNAQELBQADggEBADjPTuHXMbXc2Kn+i+dnBiQCWcjzaox4KWV4MNO7vkvi\n" +
+ "ADBk5/vVM+HTzwL+gZNwE96/agcOzwHZ8/Dz4aA3zzmAmQB4bt+pUa0iyGvX6+F5\n" +
+ "IH1kd4kBnSBMc76fRcEJnebhrXFgTlps5VELMVcEOn3Q4nt+gVfXmPStTkFjM1/4\n" +
+ "fQggsScLpE2TVkk3oS52NIzG/vyBIt3W0gX20hlQobA2vziJDx8xy/+qe5igyp5F\n" +
+ "WScwSQE8qeuoDJYJRxpxZ7kq8NiHxfGPw5Hjn518zBz2VKJOsJYmckAMFIdS//kM\n" +
+ "NUysH6gFksW/PHy75QkbtD4OFtb2zp01ERuf5OoJavs=\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias yellow-ta-key -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String YELLOW_ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC7DCCAdSgAwIBAgIEfLA7azANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtZ\n" +
+ "ZWxsb3cgUm9vdDAeFw0xNDA1MDgxODI3MTZaFw0xNjA0MjcxODI3MTZaMBYxFDAS\n" +
+ "BgNVBAMTC1llbGxvdyBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+ "AQEAgLMOpzIR8LyALox2AvItM42VjFDp1EyHU0faJZCpwVbQPJ2f+8Gr7XuTv1uZ\n" +
+ "Ixe6JjcyGNHZG0NuFmMFbK2Y7cg3PdQBjcm+x68iSWzyEUuhytSKSLUt6i+xAg+9\n" +
+ "h9UGXlBNarVjWq63tPt8HK/YHxt9Ber0iriF3SEUsgMOzRrLw1mw35SmgidRp19y\n" +
+ "yNXlgQfylEAVtYD9IYhxTm/j9NL3rTgqXiKjvNAVjAUrD2I2nK5WQqO2hmQr9x/9\n" +
+ "EqgIK03dw0ps7/XL+gpd+zwGZqDr9pbFnko4badiE4AJqPlm6u/Tdc0dSkLu/oXq\n" +
+ "Ex4iqtM0TP5+oeDXGZv6EprzKQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+ "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUp0/g/PqT9jDVGKSsBh997Kg9KBIwDQYJ\n" +
+ "KoZIhvcNAQELBQADggEBAG4vr5UkWUEA9qNU6wBNg5yySS6KhNVyBDMReyX6qsz6\n" +
+ "yUIeGU/UC8LwdB+Tl3S+FZyUlsx+gwh1n0ei7eOV58cCeWmZ3sUWvLTwsY9iBNyt\n" +
+ "HkItOCDO+JEjgo7OhEBlzYkD4MkwAjaYnT4tU41BSnlTR4+jK77f/b1oMVzDv2tL\n" +
+ "+JAiem04TEoGO97uZ94l6gKwwGO35uejGEUPhFPLtxo+yR2QQqX0S8smG88pCQ82\n" +
+ "6XscdvRTjSfkuI3LiqNORS0fGZ3ykxDCkDLZZ1mSg1h2/3xOUEbFQ0phhMrnr2Rl\n" +
+ "mWNGYCam2jns4qmMnbzPIwQduvRkz1O1lusbLNFpcdY=\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias green-ta-key -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String GREEN_ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC6jCCAdKgAwIBAgIENWwt8TANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwpH\n" +
+ "cmVlbiBSb290MB4XDTE0MDUwODE4MjcxOFoXDTE2MDQyNzE4MjcxOFowFTETMBEG\n" +
+ "A1UEAxMKR3JlZW4gUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" +
+ "AKHvh3FRJghpNtLqIk5UDSGkcA3rtEygRsFa51ucwNQ1x4SXOVnsNHZZW66RuKOn\n" +
+ "6wjS8+xctNnMIy1XNXa2nlAswQVe75xX0jfGMB4w0MlaqLK9HrU479WrWmrBjz/P\n" +
+ "vvHY8x1CIfTMjOtLO9yxbYQrXsEz6JKxAz6/+ErbkvUjBynezZdJNXgURVz5HmFx\n" +
+ "e/SUbSALX+Kx+/+hXggaQdwlrpoDl/Nqm6S1iR5xtdZB1CEauIwFDSWOG1TjR1Hp\n" +
+ "8OSGb0AhwwM5FzIxevwgKke6WHFKf5p4lcpiQZqmhgqyFbARUfUjYX3WzQTmrJ/q\n" +
+ "87OMIJasvmkNEYkNbrSmI9kCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" +
+ "HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHG7s0KrfUsnl/3/UGYbCrdXTZtcMA0GCSqG\n" +
+ "SIb3DQEBCwUAA4IBAQBUe18kbDHeqsxM17ahr30hvjdxMkYLkLcGoSOlSI8sFBu6\n" +
+ "jG4JZvvFXw2ZqMQTLSALvsSZ9wkfS8tDCNEHRvCB6aqW4tjp9ddkfe+56WINzTv6\n" +
+ "Ibqwg2JGsOzWttpUA5OPLfODbMqOYzT101toF3sKteX0yyiF/SfMTXR5Jv0uo/dp\n" +
+ "sFeJtWFfhy/Q0jiEAz945BBoSHCIF7Fs4vcls7gNJxfap66W8lamjzFyMDsnlz+b\n" +
+ "sSLWZmvwM+R/RfL1Q3LPCcZWLiP9WSAO4hUoju1E9WeWHHjlPwJJ/iRECL9cnHRt\n" +
+ "Z7/kOlNLGxKvpEbY4xqH0zE07UWPCCBlemk/6jlO\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias blue-ta-key -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String BLUE_ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC6DCCAdCgAwIBAgIEX3XC9zANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDEwlC\n" +
+ "bHVlIFJvb3QwHhcNMTQwNTA4MTgyNzIwWhcNMTYwNDI3MTgyNzIwWjAUMRIwEAYD\n" +
+ "VQQDEwlCbHVlIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCY\n" +
+ "pc4r8mfgGGeiYlvHSrEIlp6djHS489P7eqoQRqmS5U/I0lLGNu7QZsY240a9a84S\n" +
+ "2t6VpZID5juK8AF2v4psShsqgfj+RjVev8FJE/D5j8B4QZ+HmbLJIl80f+YOPaLG\n" +
+ "HX1eNktLx3S2gkIKHVdn7q3o4DdXBO+YdaBA56lL4l+dWFtto65+5Sjy4yfyvWJz\n" +
+ "MylXjP/wiC0T3C0NcQX3AIu2tjY2u9lrVbem2rIi0kPFIoYvstKiqXMc/sRf2CfO\n" +
+ "it5k629HsbvdACVRZFxU3Lz25oP4HGz1kq1cpiIS+W3gQQmCKu9XqzpNRThG0SEL\n" +
+ "jaH9E4pZDnZiRCr+Mxm1AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P\n" +
+ "AQH/BAQDAgEGMB0GA1UdDgQWBBS5ebHO4iamr3n0+KtxJYAitg9QcTANBgkqhkiG\n" +
+ "9w0BAQsFAAOCAQEAGjh/UzERw+skEK4zM1zfL1RsZnUlFu7mTbOBGgccewHWC+MM\n" +
+ "AQbLo0m4NTEbRoW6fFcAESgE61ZZBLkmhcjXBunNJq6O1hMDpppYA806eG6GcZmK\n" +
+ "rLOZljxx4D1YC17vMEVsMF9XgIj5dLWceJjotZzNxe+miwXLEkxaGIMe/n2VtCoR\n" +
+ "BSrGrAeCsFZ7G2NRWUxUEVJrhLnVZJDt6fHd43BCVnV191PyF5TuB08nijyCoJoS\n" +
+ "/WJkYHxx3vUUfDE5E4UE+iY80BHnAPxiNKwO3XsWjeqbJ8PS+5AvShdG5QdFBhKe\n" +
+ "/tJTZLs0UEubKdaWd5ZgsXP3913bJm/mBo+eJA==\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias indigo-ta-key -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String INDIGO_ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC7DCCAdSgAwIBAgIESdUmczANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtJ\n" +
+ "bmRpZ28gUm9vdDAeFw0xNDA1MDgxODI3MjFaFw0xNjA0MjcxODI3MjFaMBYxFDAS\n" +
+ "BgNVBAMTC0luZGlnbyBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+ "AQEA2opDa3wDxQrX6GjffbDGtXyvKw0/vhZTeus4cxdZIYF3CWkGbeurDIhPUKRO\n" +
+ "Azact0SECJuMXVxkB5vQKBmHRByNh8ugFfzXWi7/rteXTNjLNKnzVr8plbMvzwM7\n" +
+ "zjIgm0mTRbwv6gZmUbgfmO9FCB8zlV4hYbYbFTJn7GlVPpqZkZNNMTyJkOPxMzXD\n" +
+ "yaToxyR0uY3cMv9pmks3GxU2XoGTFuqptbL9XFSpwrm5BRfWuJDP1t8moLHQZ5iu\n" +
+ "tkCz6MVYcrhTlV/UY0PSGcmUvAu83sNBfIGjme0RIiERy02gLJnSZ/M9r1ukCUJE\n" +
+ "Z6At+9TsNCYNPgW5vcjNLO63/wIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+ "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU8eJ+kMmanqF+IcAQTjxSMv+VR7kwDQYJ\n" +
+ "KoZIhvcNAQELBQADggEBAGRB4C5qYXXJJnEGzJZf8S974SaeLmEvHlmaQPOuCxME\n" +
+ "tCeBoWQqD9qTDVy39izzjA4uE/fCMVCkyr1QL+588dtMI8jJfbzx+TxnlDWlJcMM\n" +
+ "5J8EJPNEy7eR6qqpFncvjmbXzf16XfzL9qSXwHYCvpo25nEEH801y2njJE2gGzZT\n" +
+ "raYRFuwzsZLiSV5TyO5MbRXiZLebDXfE/wXukor87pjGpx1/kevjH/g66OpaIBzu\n" +
+ "IfLePEOekTKXHF1zL89uYHwpUVCzfhO5hNQlSsTCuBkBifSTYm4ixoATi/C2kqze\n" +
+ "WHUK179u1+7v6xRONLQxe1JDftdlHHVg7DSeTY59euo=\n" +
+ "-----END CERTIFICATE-----\n";
+
+ // keytool -alias violet-ta-key -ext bc:critical=ca:true
+ // -ext ku:critical=keyCertSign,cRLSign
+ private static final String VIOLET_ROOT =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIC7DCCAdSgAwIBAgIEXwgmLDANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtW\n" +
+ "aW9sZXQgUm9vdDAeFw0xNDA1MDgxODI3MjNaFw0xNjA0MjcxODI3MjNaMBYxFDAS\n" +
+ "BgNVBAMTC1Zpb2xldCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+ "AQEAvElr11MoHUNfnx6nBy4NSXFFzA68g57ohTt+sspEn3wzuPErugMypReHLhtH\n" +
+ "CTrs45T0KU8P4Gi5QHnsBs8yC3QCHNPugo2A4zP+ciTqp+1gRNxQ9wzKSzCoseJg\n" +
+ "RMQflGFzuEe7gWwYfrsDfD1sJCubfBtBUFCSYf1ZSZbdEMrc3RPtC35Ge+3XRxFZ\n" +
+ "KdzH8l7gQTtgAmRQmK+i4jwzSHV/Iu2yiRdhjqIZUezf3pYFfJlmfAY5ruQBKkc+\n" +
+ "KRgdmKanpLbmAo/+3q6snt8V09CoQ+6Cz+P9P0yOxiiwr/6jg9WtHA3ujvtf3dGj\n" +
+ "EeB8SmzXHFZErQIn+QbrJ3/izwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+ "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUlxlHI8JTrX86r4ezgDLICo6rApowDQYJ\n" +
+ "KoZIhvcNAQELBQADggEBALnfWZx6LC9vDMI8vBH/vbyk2ZQtiQFRt3kbwKtlrw65\n" +
+ "/bqeGXcQ1Lh9gDzp+uGYSfuDNvtJO6xmfny0W5j5WQVJxs+iWyoJfYxeG0kBZut+\n" +
+ "hbxJPlehBwhveuznZbeTN3RXeBi8MSxnBD/WC1e2rnfnrxoLfYZ1BSUP8LaIzC32\n" +
+ "vd6WCgnJRXputlGvnOoAT1WduWonhd7lCoqbtZksw7o0smuAn2mSnod8j948rzzt\n" +
+ "uDQVao/3tCyoX4NSom2hWooPltk5FTdF9cZKfbaU5TPV+U30RN7/UWY/dCvL1fMq\n" +
+ "1kvtJbkh+UMHvszHOxlgjk+3J76Wx0PFjNaIfbj2bmk=\n" +
+ "-----END CERTIFICATE-----\n";
+
+ public static final String[] rootArrayPEM = { RED_ROOT, ORANGE_ROOT,
+ YELLOW_ROOT, GREEN_ROOT, BLUE_ROOT, INDIGO_ROOT, VIOLET_ROOT, ROOT };
+
+ /**
+ * @param args {cacerts keystore, cert chain}
+ */
+ public static void main(String[] args) throws Exception {
+ Set trustedCertSet = new HashSet<>();
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ for (String pemCert : rootArrayPEM) {
+ trustedCertSet.add(makeCertFromPEM(pemCert));
+ }
+
+ testCtorByCollection(trustedCertSet);
+
+ testCtorByPKIXBuilderParams(trustedCertSet);
+ }
+
+ public static X509Certificate makeCertFromPEM(String pemCert)
+ throws CertificateException {
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ ByteArrayInputStream is = new ByteArrayInputStream(pemCert.getBytes());
+
+ return ((X509Certificate)cf.generateCertificate(is));
+ }
+
+ public static void showValidatedChain(Validator v, X509Certificate[] chain,
+ Set otherCerts) throws Exception {
+ for (X509Certificate cert : v.validate(chain, otherCerts)) {
+ System.out.println("\tSubj: " + cert.getSubjectX500Principal() +
+ " Iss: " + cert.getIssuerX500Principal());
+ }
+ }
+
+ public static Set makeTrustAnchorSet(
+ Set certSet) throws Exception {
+ Set anchors = new HashSet<>();
+
+ for (Certificate cert : certSet) {
+ anchors.add(new TrustAnchor((X509Certificate)cert, null));
+ }
+
+ return anchors;
+ }
+
+ public static void testCtorByCollection(Set certSet)
+ throws Exception {
+ Validator valOK;
+ Validator valNoGood;
+ X509Certificate[] chain = new X509Certificate[1];
+ Set intermeds = new HashSet<>();
+
+ // Case 1: Make a PKIXValidator with valid arguments
+ // Expected result: Well-formed PKIXValidator
+ System.out.println("Constructor test 1: Valid inputs");
+ valOK = Validator.getInstance(Validator.TYPE_PKIX,
+ Validator.VAR_GENERIC, certSet);
+
+ // Convert our user cert from PEM format, then do the same for
+ // its intermediate signer and add that as a helper for path building
+ chain[0] = makeCertFromPEM(USER);
+ intermeds.add(makeCertFromPEM(INTERMED));
+ PKIXBuilderParameters pbParams = ((PKIXValidator)valOK).getParameters();
+ pbParams.setDate(new Date(1426399200000L)); // 03-15-2014 6:00:00 GMT
+
+ // See if we can build a trusted path to a root to make sure
+ // everything still works as expected.
+ showValidatedChain(valOK, chain, intermeds);
+
+ // Case 2: Make a PKIXValidator with null anchor list.
+ // Expected result: throw NullPointerException
+ System.out.println("Constructor test 2: null trustedCerts");
+ try {
+ valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+ Validator.VAR_GENERIC, (Collection)null);
+ // Throw something non Runtime-related to indicate we shouldn't
+ // have succeeded on construction.
+ throw new IOException(
+ "Constructor did not throw NullPointerException");
+ } catch (NullPointerException npe) {
+ System.out.println("\tCaught Exception (" + npe.toString() +
+ ") [PASS])");
+ }
+
+ // Case 3: Try putting a null reference into a populated TA List
+ // Expected result: throw NullPointerException
+ System.out.println("Constructor test 3: null in trustedCerts list");
+ try {
+ certSet.add(null);
+ valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+ Validator.VAR_GENERIC, certSet);
+ // Throw something non Runtime-related to indicate we shouldn't
+ // have succeeded on construction.
+ throw new IOException("Constructor did not throw RuntimeException");
+ } catch (NullPointerException npe) {
+ System.out.println("\tCaught Exception (" + npe.toString() +
+ ") [PASS])");
+ } finally {
+ // Return the certSet list to its original state
+ certSet.remove(null);
+ }
+
+ // Case 4: Provide an empty List as the X509Certificate collection
+ // Expected result: throw RuntimeException
+ System.out.println("Constructor test 4: empty trustedCerts list");
+ try {
+ valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+ Validator.VAR_GENERIC, new ArrayList());
+ // Throw something non Runtime-related to indicate we shouldn't
+ // have succeeded on construction.
+ throw new IOException("Constructor did not throw RuntimeException");
+ } catch (RuntimeException re) {
+ System.out.println("\tCaught RuntimeException (" + re.toString() +
+ ") [PASS])");
+ }
+
+ // Case 5: Provide an invalid variant
+ // Expected result: successful construction.
+ // Note: subsequent calls to validate may throw CertificateException
+ // if the submitted chain has a length > 1.
+ System.out.println("Constructor test 5: Unsupported variant");
+ valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+ "BogusVariant", certSet);
+ System.out.println("\tSuccessful construction [PASS]");
+
+ // Case 6: Provide a null variant
+ // Expected result: throw NullPointerException
+ System.out.println("Constructor test 6: null variant");
+ try {
+ valNoGood = Validator.getInstance(Validator.TYPE_PKIX, null,
+ certSet);
+ // Throw something non Runtime-related to indicate we shouldn't
+ // have succeeded on construction.
+ throw new IOException(
+ "Constructor did not throw NullPointerException");
+ } catch (NullPointerException npe) {
+ System.out.println("\tCaught RuntimeException (" + npe.toString() +
+ ") [PASS])");
+ }
+ }
+
+ public static void testCtorByPKIXBuilderParams(Set certSet)
+ throws Exception {
+ Set taSet = makeTrustAnchorSet(certSet);
+ Validator valOK;
+ Validator valNoGood;
+ X509Certificate[] chain = new X509Certificate[1];
+ Set intermeds = new HashSet<>();
+
+ // Case 7: Make a PKIXValidator with valid arguments
+ // Expected result: Well-formed PKIXValidator object
+ System.out.println("Constructor test 7: Valid inputs");
+
+ // Set up the PKIXBuilderParameters
+ X509CertSelector sel = new X509CertSelector();
+ sel.setSubject("CN=User");
+ PKIXBuilderParameters pbParams = new PKIXBuilderParameters(taSet, sel);
+ pbParams.setRevocationEnabled(false);
+ pbParams.setDate(new Date(1426399200000L)); // 03-15-2014 6:00:00 GMT
+
+ valOK = Validator.getInstance(Validator.TYPE_PKIX,
+ Validator.VAR_GENERIC, pbParams);
+
+ // Convert our user cert from PEM format, then do the same for
+ // its intermediate signer and add that as a helper for path building
+ chain[0] = makeCertFromPEM(USER);
+ intermeds.add(makeCertFromPEM(INTERMED));
+
+ showValidatedChain(valOK, chain, intermeds);
+
+ // Case 8: Make a PKIXValidator but provide a null PKIXBuilderParameters
+ // Expected result: throw NullPointerException
+ System.out.println("Constructor test 8: null params");
+ try {
+ valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+ Validator.VAR_GENERIC, (PKIXBuilderParameters)null);
+ // Throw something non Runtime-related to indicate we shouldn't
+ // have succeeded on construction.
+ throw new IOException(
+ "Constructor did not throw NullPointerException");
+ } catch (NullPointerException npe) {
+ System.out.println("\tCaught RuntimeException (" + npe.toString() +
+ ") [PASS])");
+ }
+ }
+}
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/tools/jcmd/TestJcmdDefaults.java
--- a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java Thu May 15 10:41:25 2014 -0700
@@ -39,6 +39,7 @@
* @test
* @bug 7104647
* @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main TestJcmdDefaults
*/
public class TestJcmdDefaults {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/tools/jcmd/TestJcmdSanity.java
--- a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java Thu May 15 10:41:25 2014 -0700
@@ -40,6 +40,7 @@
* @test
* @bug 7104647 7154822
* @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main TestJcmdSanity
*/
public class TestJcmdSanity {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/tools/jmap/BasicJMapTest.java
--- a/jdk/test/sun/tools/jmap/BasicJMapTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/tools/jmap/BasicJMapTest.java Thu May 15 10:41:25 2014 -0700
@@ -34,6 +34,7 @@
* @bug 6321286
* @summary Unit test for jmap utility
* @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main BasicJMapTest
*/
public class BasicJMapTest {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/tools/jstack/BasicJStackTest.java
--- a/jdk/test/sun/tools/jstack/BasicJStackTest.java Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/tools/jstack/BasicJStackTest.java Thu May 15 10:41:25 2014 -0700
@@ -32,6 +32,7 @@
* @bug 6260070
* @summary Unit test for jstack utility
* @library /lib/testlibrary
+ * @build jdk.testlibrary.*
* @run main BasicJStackTest
*/
public class BasicJStackTest {
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/util/calendar/zi/tzdata/VERSION
--- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION Thu May 15 10:41:25 2014 -0700
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2014b
+tzdata2014c
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/util/calendar/zi/tzdata/africa
--- a/jdk/test/sun/util/calendar/zi/tzdata/africa Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/africa Thu May 15 10:41:25 2014 -0700
@@ -358,11 +358,54 @@
# http://www.worldtimezone.com/dst_news/dst_news_egypt02.html
#
+# From Ahmad El-Dardiry (2014-05-07):
+# Egypt is to change back to Daylight system on May 15
+# http://english.ahram.org.eg/NewsContent/1/64/100735/Egypt/Politics-/Egypts-government-to-reapply-daylight-saving-time-.aspx
+
+# From Gunther Vermier (2015-05-13):
+# our Egypt office confirms that the change will be at 15 May "midnight" (24:00)
+
+# From Paul Eggert (2014-05-13):
+# Sarah El Deeb and Lee Keath of AP report that the Egyptian government says
+# the change is because of blackouts in Cairo, even though Ahram Online (cited
+# above) says DST had no affect on electricity consumption. The AP story says
+# DST will not be observed during Ramadan. There is no information about when
+# DST will end. See:
+# http://abcnews.go.com/International/wireStory/el-sissi-pushes-egyptians-line-23614833
+#
+# For now, guess that later transitions will use 2010's rules, and that
+# Egypt will agree with Morocco (see below) about the date Ramadan starts and
+# ends, though (unlike Morocco) it will switch at 00:00 standard time. In
+# Egypt the spring-forward transitions are removed for 2020-2022, when the
+# guessed spring-forward date falls during the estimated Ramadan, and all
+# transitions removed for 2023-2038, where the estimated Ramadan falls entirely
+# outside the guessed daylight-saving time. Ramadan intrudes on the guessed
+# DST starting in 2039, but that's beyond our somewhat-arbitrary cutoff.
+
Rule Egypt 2008 only - Aug lastThu 23:00s 0 -
Rule Egypt 2009 only - Aug 20 23:00s 0 -
Rule Egypt 2010 only - Aug 11 0:00 0 -
Rule Egypt 2010 only - Sep 10 0:00 1:00 S
Rule Egypt 2010 only - Sep lastThu 23:00s 0 -
+Rule Egypt 2014 only - May 15 24:00 1:00 S
+Rule Egypt 2014 only - Jun 29 0:00s 0 -
+Rule Egypt 2014 only - Jul 29 0:00s 1:00 S
+Rule Egypt 2014 max - Sep lastThu 23:00s 0 -
+Rule Egypt 2015 2019 - Apr lastFri 0:00s 1:00 S
+Rule Egypt 2015 only - Jun 18 0:00s 0 -
+Rule Egypt 2015 only - Jul 18 0:00s 1:00 S
+Rule Egypt 2016 only - Jun 7 0:00s 0 -
+Rule Egypt 2016 only - Jul 7 0:00s 1:00 S
+Rule Egypt 2017 only - May 27 0:00s 0 -
+Rule Egypt 2017 only - Jun 26 0:00s 1:00 S
+Rule Egypt 2018 only - May 16 0:00s 0 -
+Rule Egypt 2018 only - Jun 15 0:00s 1:00 S
+Rule Egypt 2019 only - May 6 0:00s 0 -
+Rule Egypt 2019 only - Jun 5 0:00s 1:00 S
+Rule Egypt 2020 only - May 24 0:00s 1:00 S
+Rule Egypt 2021 only - May 13 0:00s 1:00 S
+Rule Egypt 2022 only - May 3 0:00s 1:00 S
+Rule Egypt 2023 max - Apr lastFri 0:00s 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Cairo 2:05:09 - LMT 1900 Oct
diff -r bd93e54b6654 -r 2e754d3dbdf2 jdk/test/sun/util/calendar/zi/tzdata/asia
--- a/jdk/test/sun/util/calendar/zi/tzdata/asia Thu May 15 10:25:51 2014 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/asia Thu May 15 10:41:25 2014 -0700
@@ -1370,22 +1370,6 @@
# "Jordan will switch to winter time on Friday, October 27".
#
-# From Phil Pizzey (2009-04-02):
-# ...I think I may have spotted an error in the timezone data for
-# Jordan.
-# The current (2009d) asia file shows Jordan going to daylight
-# saving
-# time on the last Thursday in March.
-#
-# Rule Jordan 2000 max - Mar lastThu 0:00s 1:00 S
-#
-# However timeanddate.com, which I usually find reliable, shows Jordan
-# going to daylight saving time on the last Friday in March since 2002.
-# Please see
-#