# HG changeset patch # User amurillo # Date 1474056901 25200 # Node ID 6268665d2fd768748aabe90af315c0f5090a42a7 # Parent 07736e140bce5d7eefe48bf6a1ca2c123a9d1746# Parent adaf04f6b6516a957b2558be62af516882965d5e Merge diff -r 07736e140bce -r 6268665d2fd7 .hgtags --- a/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -378,3 +378,4 @@ e17429a7e843c4a4ed3651458d0f950970edcbcc jdk-9+133 a71210c0d9800eb6925b61ecd6198abd554f90ee jdk-9+134 e384420383a5b79fa0012ebcb25d8f83cff7f777 jdk-9+135 +1b4b5d01aa11edf24b6fadbe3d2f3e411e3b02cd jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 .hgtags-top-repo --- a/.hgtags-top-repo Fri Sep 16 12:09:53 2016 -0500 +++ b/.hgtags-top-repo Fri Sep 16 13:15:01 2016 -0700 @@ -378,3 +378,4 @@ be1218f792a450dfb5d4b1f82616b9d95a6a732e jdk-9+133 065724348690eda41fc69112278d8da6dcde548c jdk-9+134 82b94cb5f342319d2cda77f9fa59703ad7fde576 jdk-9+135 +3ec350f5f32af249b59620d7e37b54bdcd77b233 jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 corba/.hgtags --- a/corba/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/corba/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -378,3 +378,4 @@ 2021bfedf1c478a4808a7711a6090682a12f4c0e jdk-9+133 1a497f5ca0cfd88115cc7daa8af8a62b8741caf2 jdk-9+134 094d0db606db976045f594dba47d4593b715cc81 jdk-9+135 +aa053a3faf266c12b4fd5272da431a3e08e4a3e3 jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 hotspot/.hgtags --- a/hotspot/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/hotspot/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -538,3 +538,4 @@ a25e0fb6033245ab075136e744d362ce765464cd jdk-9+133 b8b694c6b4d2ab0939aed7adaf0eec1ac321a085 jdk-9+134 3b1c4562953db47e36b237a500f368d5c9746d47 jdk-9+135 +a20da289f646ee44440695b81abc0548330e4ca7 jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 jaxp/.hgtags --- a/jaxp/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -378,3 +378,4 @@ 9490ba2e5e41685c858a0ca2a6ec87611eb011c6 jdk-9+133 1c6c21d87aa459d82425e1fddc9ce8647aebde34 jdk-9+134 f695240370c77a25fed88225a392e7d530cb4d78 jdk-9+135 +f1eafcb0eb7182b937bc93f214d8cabd01ec4d59 jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java Fri Sep 16 13:15:01 2016 -0700 @@ -61,9 +61,19 @@ * catalog resolution outside of a parsing context. It may be shared * between several parsers and the application.

* + * @deprecated This class and the JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API should + * migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. + * * @author Michael Glavassevich, IBM * */ +@Deprecated(since="9", forRemoval=true) public class XMLCatalogResolver implements XMLEntityResolver, EntityResolver2, LSResourceResolver { diff -r 07736e140bce -r 6268665d2fd7 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java Fri Sep 16 13:15:01 2016 -0700 @@ -178,6 +178,14 @@ * * @see CatalogReader * @see CatalogEntry + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM @@ -187,6 +195,7 @@ *

Derived from public domain code originally published by Arbortext, * Inc.

*/ +@Deprecated(since="9", forRemoval=true) public class Catalog { /** The BASE Catalog Entry type. */ public static final int BASE = CatalogEntry.addEntryType("BASE", 1); diff -r 07736e140bce -r 6268665d2fd7 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java Fri Sep 16 13:15:01 2016 -0700 @@ -110,13 +110,21 @@ * * * @see Catalog + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM * * @version 1.0 */ - +@Deprecated(since="9", forRemoval=true) public class CatalogManager { private static final String pFiles = "xml.catalog.files"; private static final String pVerbosity = "xml.catalog.verbosity"; diff -r 07736e140bce -r 6268665d2fd7 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java Fri Sep 16 13:15:01 2016 -0700 @@ -37,12 +37,21 @@ * suffix-based matching and an external RFC2483 resolver. * * @see Catalog + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM * * @version 1.0 */ +@Deprecated(since="9", forRemoval=true) public class Resolver extends Catalog { /** * The URISUFFIX Catalog Entry type. diff -r 07736e140bce -r 6268665d2fd7 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java Fri Sep 16 13:15:01 2016 -0700 @@ -52,12 +52,21 @@ * @see Catalog * @see org.xml.sax.EntityResolver * @see javax.xml.transform.URIResolver + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM * * @version 1.0 */ +@Deprecated(since="9", forRemoval=true) public class CatalogResolver implements EntityResolver, URIResolver { /** Make the parser Namespace aware? */ public boolean namespaceAware = true; diff -r 07736e140bce -r 6268665d2fd7 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java Fri Sep 16 13:15:01 2016 -0700 @@ -25,7 +25,7 @@ import java.io.File; import java.io.StringReader; - +import javax.xml.stream.XMLResolver; import javax.xml.transform.Source; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; @@ -42,7 +42,7 @@ /** * @test - * @bug 8158084 8162438 8162442 + * @bug 8158084 8162438 8162442 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport * @run testng/othervm catalog.CatalogSupport @@ -114,6 +114,15 @@ } /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXA") + public void testStAXA(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. */ @@ -212,6 +221,20 @@ }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXA") + public Object[][] getDataStAX() { + + return new Object[][]{ + {false, true, xml_catalog, xml_system, null, expectedWCatalog}, + {false, true, xml_catalog, xml_system, null, expectedWResolver}, + {true, true, xml_catalog, xml_system, null, expectedWResolver} + }; + } + MyEntityHandler getMyEntityHandler(String elementName, String[] systemIds, InputSource... returnValues) { return new MyEntityHandler(systemIds, returnValues, elementName); } @@ -262,8 +285,8 @@ SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); @@ -271,8 +294,7 @@ XmlInput[] returnValues = {new XmlInput(null, dtd_system, null), new XmlInput(null, xsd_val_test, null)}; LSResourceResolver resolver = new SourceResolver(null, systemIds, returnValues); - StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax3 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); return new Object[][]{ // use catalog diff -r 07736e140bce -r 6268665d2fd7 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java Fri Sep 16 13:15:01 2016 -0700 @@ -30,6 +30,7 @@ import java.io.StringReader; import javax.xml.catalog.CatalogFeatures.Feature; +import javax.xml.stream.XMLResolver; import javax.xml.transform.Source; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; @@ -47,7 +48,7 @@ /* * @test - * @bug 8158084 8162438 8162442 + * @bug 8158084 8162438 8162442 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport1 * @run testng/othervm catalog.CatalogSupport1 @@ -110,6 +111,15 @@ } /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC") + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. */ @@ -190,6 +200,18 @@ } /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + + return new Object[][]{ + {false, true, null, xml_system, null, expectedWCatalog}, + }; + } + + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver */ @@ -218,8 +240,8 @@ SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); @@ -227,8 +249,7 @@ XmlInput[] returnValues = {new XmlInput(null, dtd_system, null), new XmlInput(null, xsd_val_test, null)}; LSResourceResolver resolver = new SourceResolver(null, systemIds, returnValues); - StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax3 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); return new Object[][]{ // use catalog diff -r 07736e140bce -r 6268665d2fd7 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java Fri Sep 16 13:15:01 2016 -0700 @@ -30,6 +30,8 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; +import javax.xml.stream.XMLResolver; +import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; @@ -50,7 +52,7 @@ /* * @test - * @bug 8158084 8162438 8162442 8163535 + * @bug 8158084 8162438 8162442 8163535 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport2 * @run testng/othervm catalog.CatalogSupport2 @@ -129,6 +131,15 @@ } /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC") + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAXNegative(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. */ @@ -205,6 +216,17 @@ } /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + return new Object[][]{ + {false, true, xml_catalog, xml_system, null, "null"}, + }; + } + + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver */ @@ -233,8 +255,8 @@ SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); diff -r 07736e140bce -r 6268665d2fd7 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java Fri Sep 16 13:15:01 2016 -0700 @@ -29,6 +29,8 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; +import javax.xml.stream.XMLResolver; +import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; @@ -49,7 +51,7 @@ /* * @test - * @bug 8158084 8162438 8162442 8163535 + * @bug 8158084 8162438 8162442 8163535 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport3 * @run testng/othervm catalog.CatalogSupport3 @@ -125,6 +127,15 @@ } /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC") + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAXNegative(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. */ @@ -206,6 +217,17 @@ } /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + return new Object[][]{ + {true, false, xml_catalog, xml_system, null, "null"}, + }; + } + + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver */ @@ -234,8 +256,8 @@ SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); diff -r 07736e140bce -r 6268665d2fd7 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java Fri Sep 16 13:15:01 2016 -0700 @@ -28,7 +28,7 @@ import java.io.File; import java.io.StringReader; - +import javax.xml.stream.XMLResolver; import javax.xml.transform.Source; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; @@ -46,7 +46,7 @@ /** * @test - * @bug 8158084 8162438 8162442 + * @bug 8158084 8162438 8162442 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport4 * @run testng/othervm catalog.CatalogSupport4 @@ -118,6 +118,15 @@ } /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXA") + public void testStAXA(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. */ @@ -199,6 +208,18 @@ }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXA") + public Object[][] getDataStAX() { + + return new Object[][]{ + {true, true, xml_catalog, xml_system, null, expectedWCatalog}, + }; + } + MyEntityHandler getMyEntityHandler(String elementName, String[] systemIds, InputSource... returnValues) { return new MyEntityHandler(systemIds, returnValues, elementName); } @@ -230,8 +251,8 @@ SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, true, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, true, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); @@ -241,8 +262,8 @@ {false, true, true, ds, null, null, null, xml_catalog}, {true, false, true, ss, null, null, xml_catalog, null}, {false, true, true, ss, null, null, null, xml_catalog}, - {true, false, true, stax, null, null, xml_catalog, null}, - {false, true, true, stax1, null, null, null, xml_catalog}, + {true, false, true, stax, null, null, xml_catalog, xml_catalog}, + {false, true, true, stax1, null, null, xml_catalog, xml_catalog}, {true, false, true, source, null, null, xml_catalog, null}, {false, true, true, source, null, null, null, xml_catalog}, }; diff -r 07736e140bce -r 6268665d2fd7 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java Fri Sep 16 13:15:01 2016 -0700 @@ -25,6 +25,8 @@ import java.io.File; import java.io.StringReader; +import javax.xml.stream.XMLResolver; +import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; @@ -43,7 +45,7 @@ /* * @test - * @bug 8158084 8163232 + * @bug 8158084 8163232 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport5 * @run testng/othervm catalog.CatalogSupport5 @@ -107,6 +109,15 @@ } /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC", expectedExceptions = XMLStreamException.class) + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. */ @@ -183,6 +194,18 @@ } /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + + return new Object[][]{ + {false, true, xml_bogus_catalog, xml_system, null, expectedWCatalog}, + }; + } + + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver */ @@ -211,8 +234,8 @@ SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); diff -r 07736e140bce -r 6268665d2fd7 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java Fri Sep 16 13:15:01 2016 -0700 @@ -319,6 +319,31 @@ } /* + Verifies the Catalog support on StAX parser. + */ + public void testStAX(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + + XMLStreamReader streamReader = getStreamReader( + setUseCatalog, useCatalog, catalog, xml, resolver); + String text = getText(streamReader, XMLStreamConstants.CHARACTERS); + assertEquals(expected, text.trim(), "Catalog support for StAX"); + } + + /* + Verifies that the Catalog support for StAX parser is disabled when + USE_CATALOG == false. + */ + public void testStAXNegative(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + + XMLStreamReader streamReader = getStreamReader( + setUseCatalog, useCatalog, catalog, xml, resolver); + String text = getText(streamReader, XMLStreamConstants.ENTITY_REFERENCE); + assertEquals(expected, text.trim(), "Catalog support for StAX"); + } + + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. */ @@ -514,15 +539,24 @@ * * @param xmlFile the XML source file * @param xmlFileId the systemId of the source + * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set + * through the factory + * @param useCatalog the value of USE_CATALOG + * @param catalog a catalog * @return a StAXSource * @throws XMLStreamException * @throws FileNotFoundException */ - StAXSource getStaxSource(String xmlFile, String xmlFileId) { + StAXSource getStaxSource(String xmlFile, String xmlFileId, boolean setUseCatalog, + boolean useCatalog, String catalog) { StAXSource ss = null; try { - ss = new StAXSource( - XMLInputFactory.newFactory().createXMLEventReader( + XMLInputFactory xif = XMLInputFactory.newFactory(); + if (setUseCatalog) { + xif.setProperty(XMLConstants.USE_CATALOG, useCatalog); + } + xif.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); + ss = new StAXSource(xif.createXMLEventReader( xmlFileId, new FileInputStream(xmlFile))); } catch (Exception e) {} @@ -531,6 +565,10 @@ /** * Creates an XMLStreamReader. + * + * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set + * through the factory + * @param useCatalog the value of USE_CATALOG * @param catalog the path to a catalog * @param xml the xml to be parsed * @param resolver a resolver to be set on the reader @@ -542,9 +580,17 @@ String catalog, String xml, XMLResolver resolver) throws FileNotFoundException, XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); - factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); + if (catalog != null) { + factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); + } + + factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true); factory.setProperty(XMLInputFactory.IS_COALESCING, true); - factory.setProperty(XMLInputFactory.RESOLVER, resolver); + + if (resolver != null) { + factory.setProperty(XMLInputFactory.RESOLVER, resolver); + } + if (setUseCatalog) { factory.setProperty(XMLConstants.USE_CATALOG, useCatalog); } @@ -560,17 +606,28 @@ * @return the text of the first element * @throws XMLStreamException */ - String getText(XMLStreamReader streamReader) throws XMLStreamException { + String getText(XMLStreamReader streamReader, int type) throws XMLStreamException { + StringBuilder text = new StringBuilder(); + StringBuilder entityRef = new StringBuilder(); + while(streamReader.hasNext()){ - int eventType = streamReader.next() ; - if(eventType == XMLStreamConstants.START_ELEMENT){ - eventType = streamReader.next() ; - if(eventType == XMLStreamConstants.CHARACTERS){ - return streamReader.getText() ; - } + int eventType = streamReader.next(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + break; + case XMLStreamConstants.CHARACTERS: + text.append(streamReader.getText()); + break; + case XMLStreamConstants.ENTITY_REFERENCE: + entityRef.append(streamReader.getText()); + break; } } - return null; + if (type == XMLStreamConstants.CHARACTERS) { + return text.toString(); + } else { + return entityRef.toString(); + } } /** diff -r 07736e140bce -r 6268665d2fd7 jaxws/.hgtags --- a/jaxws/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/jaxws/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -381,3 +381,4 @@ 05e99eefda2b58d1ed176e411302d9d6b35dca16 jdk-9+133 ab1d78d395d4cb8be426ff181211da1a4085cf01 jdk-9+134 22631824f55128a7ab6605493b3001a37af6a168 jdk-9+135 +09ec13a99f50a4a346180d1e3b0fd8bc1ee399ce jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 jdk/.hgtags --- a/jdk/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -378,3 +378,4 @@ 3cdae27c90b5e41afe75eab904fda19fac076330 jdk-9+133 803adcd526d74ae0b64948d1f8260c2dbe514779 jdk-9+134 021369229cfd0b5feb76834b2ea498f47f43c0f3 jdk-9+135 +54c5931849a33a363e03fdffa141503f5cc4779d jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 jdk/make/data/currency/CurrencyData.properties --- a/jdk/make/data/currency/CurrencyData.properties Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/make/data/currency/CurrencyData.properties Fri Sep 16 13:15:01 2016 -0700 @@ -32,14 +32,14 @@ # Version of the currency code information in this class. # It is a serial number that accompanies with each amendment. -dataVersion=160 +dataVersion=162 # List of all valid ISO 4217 currency codes. # To ensure compatibility, do not remove codes. all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036-\ AWG533-AYM945-AZM031-AZN944-BAM977-BBD052-BDT050-BEF056-BGL100-BGN975-BHD048-BIF108-\ - BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-\ + BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-BYN933-\ BZD084-CAD124-CDF976-CHE947-CHF756-CHW948-CLF990-CLP152-CNY156-COP170-COU970-CRC188-CSD891-CUP192-CUC931-\ CVE132-CYP196-CZK203-DEM276-DJF262-DKK208-DOP214-DZD012-EEK233-EGP818-\ ERN232-ESP724-ETB230-EUR978-FIM246-FJD242-FKP238-FRF250-GBP826-GEL981-\ @@ -119,7 +119,7 @@ # BARBADOS BB=BBD # BELARUS -BY=BYR +BY=BYN # BELGIUM BE=EUR # BELIZE diff -r 07736e140bce -r 6268665d2fd7 jdk/make/mapfiles/libattach/mapfile-linux --- a/jdk/make/mapfiles/libattach/mapfile-linux Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/make/mapfiles/libattach/mapfile-linux Fri Sep 16 13:15:01 2016 -0700 @@ -30,8 +30,6 @@ Java_sun_tools_attach_VirtualMachineImpl_checkPermissions; Java_sun_tools_attach_VirtualMachineImpl_close; Java_sun_tools_attach_VirtualMachineImpl_connect; - Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager; - Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads; Java_sun_tools_attach_VirtualMachineImpl_open; Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo; Java_sun_tools_attach_VirtualMachineImpl_sendQuitToChildrenOf; diff -r 07736e140bce -r 6268665d2fd7 jdk/make/mapfiles/libjava/mapfile-vers --- a/jdk/make/mapfiles/libjava/mapfile-vers Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/make/mapfiles/libjava/mapfile-vers Fri Sep 16 13:15:01 2016 -0700 @@ -176,6 +176,9 @@ Java_java_lang_ProcessHandleImpl_00024Info_info0; Java_java_lang_ProcessImpl_init; Java_java_lang_ProcessImpl_forkAndExec; + Java_java_lang_ref_Reference_getAndClearReferencePendingList; + Java_java_lang_ref_Reference_hasReferencePendingList; + Java_java_lang_ref_Reference_waitForReferencePendingList; Java_java_lang_reflect_Array_get; Java_java_lang_reflect_Array_getBoolean; Java_java_lang_reflect_Array_getByte; diff -r 07736e140bce -r 6268665d2fd7 jdk/make/mapfiles/libjpeg/mapfile-vers --- a/jdk/make/mapfiles/libjpeg/mapfile-vers Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/make/mapfiles/libjpeg/mapfile-vers Fri Sep 16 13:15:01 2016 -0700 @@ -42,6 +42,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader; Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader; Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_clearNativeReadAbortFlag; Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initWriterIDs; Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter; Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/aix/native/libnet/aix_close.c --- a/jdk/src/java.base/aix/native/libnet/aix_close.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/aix/native/libnet/aix_close.c Fri Sep 16 13:15:01 2016 -0700 @@ -410,6 +410,10 @@ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK)); +} + int NET_ReadV(int s, const struct iovec * vector, int count) { BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); } @@ -503,8 +507,8 @@ * Auto restarts with adjusted timeout if interrupted by * signal other than our wakeup signal. */ -int NET_Timeout(int s, long timeout) { - long prevtime = 0, newtime; +int NET_Timeout0(int s, long timeout, long currentTime) { + long prevtime = currentTime, newtime; struct timeval t; fdEntry_t *fdEntry = getFdEntry(s); @@ -516,14 +520,6 @@ return -1; } - /* - * Pick up current time as may need to adjust timeout - */ - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = t.tv_sec * 1000 + t.tv_usec / 1000; - } - for(;;) { struct pollfd pfd; int rv; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/linux/native/libnet/linux_close.c --- a/jdk/src/java.base/linux/native/libnet/linux_close.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/linux/native/libnet/linux_close.c Fri Sep 16 13:15:01 2016 -0700 @@ -367,6 +367,10 @@ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) ); +} + int NET_ReadV(int s, const struct iovec * vector, int count) { BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); } @@ -406,8 +410,8 @@ * Auto restarts with adjusted timeout if interrupted by * signal other than our wakeup signal. */ -int NET_Timeout(int s, long timeout) { - long prevtime = 0, newtime; +int NET_Timeout0(int s, long timeout, long currentTime) { + long prevtime = currentTime, newtime; struct timeval t; fdEntry_t *fdEntry = getFdEntry(s); @@ -419,14 +423,6 @@ return -1; } - /* - * Pick up current time as may need to adjust timeout - */ - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = t.tv_sec * 1000 + t.tv_usec / 1000; - } - for(;;) { struct pollfd pfd; int rv; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/macosx/native/libnet/bsd_close.c --- a/jdk/src/java.base/macosx/native/libnet/bsd_close.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/macosx/native/libnet/bsd_close.c Fri Sep 16 13:15:01 2016 -0700 @@ -371,6 +371,10 @@ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT)); +} + int NET_ReadV(int s, const struct iovec * vector, int count) { BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); } @@ -410,8 +414,8 @@ * Auto restarts with adjusted timeout if interrupted by * signal other than our wakeup signal. */ -int NET_Timeout(int s, long timeout) { - long prevtime = 0, newtime; +int NET_Timeout0(int s, long timeout, long currentTime) { + long prevtime = currentTime, newtime; struct timeval t, *tp = &t; fd_set fds; fd_set* fdsp = NULL; @@ -432,9 +436,6 @@ */ if (timeout > 0) { /* Timed */ - struct timeval now; - gettimeofday(&now, NULL); - prevtime = now.tv_sec * 1000 + now.tv_usec / 1000; t.tv_sec = timeout / 1000; t.tv_usec = (timeout % 1000) * 1000; } else if (timeout < 0) { diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/java/lang/ref/Reference.java --- a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -110,22 +110,6 @@ private transient Reference discovered; /* used by VM */ - /* Object used to synchronize with the garbage collector. The collector - * must acquire this lock at the beginning of each collection cycle. It is - * therefore critical that any code holding this lock complete as quickly - * as possible, allocate no new objects, and avoid calling user code. - */ - private static class Lock { } - private static Lock lock = new Lock(); - - - /* List of References waiting to be enqueued. The collector adds - * References to this list, while the Reference-handler thread removes - * them. This list is protected by the above lock object. The - * list uses the discovered field to link its elements. - */ - private static Reference pending = null; - /* High-priority thread to enqueue pending References */ private static class ReferenceHandler extends Thread { @@ -139,10 +123,9 @@ } static { - // pre-load and initialize InterruptedException and Cleaner classes - // so that we don't get into trouble later in the run loop if there's - // memory shortage while loading/initializing them lazily. - ensureClassInitialized(InterruptedException.class); + // pre-load and initialize Cleaner class so that we don't + // get into trouble later in the run loop if there's + // memory shortage while loading/initializing it lazily. ensureClassInitialized(Cleaner.class); } @@ -152,72 +135,80 @@ public void run() { while (true) { - tryHandlePending(true); + processPendingReferences(); } } } - /** - * Try handle pending {@link Reference} if there is one.

- * Return {@code true} as a hint that there might be another - * {@link Reference} pending or {@code false} when there are no more pending - * {@link Reference}s at the moment and the program can do some other - * useful work instead of looping. - * - * @param waitForNotify if {@code true} and there was no pending - * {@link Reference}, wait until notified from VM - * or interrupted; if {@code false}, return immediately - * when there is no pending {@link Reference}. - * @return {@code true} if there was a {@link Reference} pending and it - * was processed, or we waited for notification and either got it - * or thread was interrupted before being notified; - * {@code false} otherwise. + /* Atomically get and clear (set to null) the VM's pending list. + */ + private static native Reference getAndClearReferencePendingList(); + + /* Test whether the VM's pending list contains any entries. + */ + private static native boolean hasReferencePendingList(); + + /* Wait until the VM's pending list may be non-null. */ - static boolean tryHandlePending(boolean waitForNotify) { - Reference r; - Cleaner c; - try { - synchronized (lock) { - if (pending != null) { - r = pending; - // 'instanceof' might throw OutOfMemoryError sometimes - // so do this before un-linking 'r' from the 'pending' chain... - c = r instanceof Cleaner ? (Cleaner) r : null; - // unlink 'r' from 'pending' chain - pending = r.discovered; - r.discovered = null; - } else { - // The waiting on the lock may cause an OutOfMemoryError - // because it may try to allocate exception objects. - if (waitForNotify) { - lock.wait(); - } - // retry if waited - return waitForNotify; + private static native void waitForReferencePendingList(); + + private static final Object processPendingLock = new Object(); + private static boolean processPendingActive = false; + + private static void processPendingReferences() { + // Only the singleton reference processing thread calls + // waitForReferencePendingList() and getAndClearReferencePendingList(). + // These are separate operations to avoid a race with other threads + // that are calling waitForReferenceProcessing(). + waitForReferencePendingList(); + Reference pendingList; + synchronized (processPendingLock) { + pendingList = getAndClearReferencePendingList(); + processPendingActive = true; + } + while (pendingList != null) { + Reference ref = pendingList; + pendingList = ref.discovered; + ref.discovered = null; + + if (ref instanceof Cleaner) { + ((Cleaner)ref).clean(); + // Notify any waiters that progress has been made. + // This improves latency for nio.Bits waiters, which + // are the only important ones. + synchronized (processPendingLock) { + processPendingLock.notifyAll(); } + } else { + ReferenceQueue q = ref.queue; + if (q != ReferenceQueue.NULL) q.enqueue(ref); } - } catch (OutOfMemoryError x) { - // Give other threads CPU time so they hopefully drop some live references - // and GC reclaims some space. - // Also prevent CPU intensive spinning in case 'r instanceof Cleaner' above - // persistently throws OOME for some time... - Thread.yield(); - // retry - return true; - } catch (InterruptedException x) { - // retry - return true; + } + // Notify any waiters of completion of current round. + synchronized (processPendingLock) { + processPendingActive = false; + processPendingLock.notifyAll(); } + } - // Fast path for cleaners - if (c != null) { - c.clean(); - return true; + // Wait for progress in reference processing. + // + // Returns true after waiting (for notification from the reference + // processing thread) if either (1) the VM has any pending + // references, or (2) the reference processing thread is + // processing references. Otherwise, returns false immediately. + private static boolean waitForReferenceProcessing() + throws InterruptedException + { + synchronized (processPendingLock) { + if (processPendingActive || hasReferencePendingList()) { + // Wait for progress, not necessarily completion. + processPendingLock.wait(); + return true; + } else { + return false; + } } - - ReferenceQueue q = r.queue; - if (q != ReferenceQueue.NULL) q.enqueue(r); - return true; } static { @@ -236,8 +227,10 @@ // provide access in SharedSecrets SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() { @Override - public boolean tryHandlePendingReference() { - return tryHandlePending(false); + public boolean waitForReferenceProcessing() + throws InterruptedException + { + return Reference.waitForReferenceProcessing(); } }); } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/java/nio/Bits.java --- a/jdk/src/java.base/share/classes/java/nio/Bits.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/java/nio/Bits.java Fri Sep 16 13:15:01 2016 -0700 @@ -131,23 +131,38 @@ } final JavaLangRefAccess jlra = SharedSecrets.getJavaLangRefAccess(); - - // retry while helping enqueue pending Reference objects - // which includes executing pending Cleaner(s) which includes - // Cleaner(s) that free direct buffer memory - while (jlra.tryHandlePendingReference()) { - if (tryReserveMemory(size, cap)) { - return; - } - } - - // trigger VM's Reference processing - System.gc(); - - // a retry loop with exponential back-off delays - // (this gives VM some time to do it's job) boolean interrupted = false; try { + + // Retry allocation until success or there are no more + // references (including Cleaners that might free direct + // buffer memory) to process and allocation still fails. + boolean refprocActive; + do { + try { + refprocActive = jlra.waitForReferenceProcessing(); + } catch (InterruptedException e) { + // Defer interrupts and keep trying. + interrupted = true; + refprocActive = true; + } + if (tryReserveMemory(size, cap)) { + return; + } + } while (refprocActive); + + // trigger VM's Reference processing + System.gc(); + + // A retry loop with exponential back-off delays. + // Sometimes it would suffice to give up once reference + // processing is complete. But if there are many threads + // competing for memory, this gives more opportunities for + // any given thread to make progress. In particular, this + // seems to be enough for a stress test like + // DirectBufferAllocTest to (usually) succeed, while + // without it that test likely fails. Since failure here + // ends in OOME, there's no need to hurry. long sleepTime = 1; int sleeps = 0; while (true) { @@ -157,14 +172,14 @@ if (sleeps >= MAX_SLEEPS) { break; } - if (!jlra.tryHandlePendingReference()) { - try { + try { + if (!jlra.waitForReferenceProcessing()) { Thread.sleep(sleepTime); sleepTime <<= 1; sleeps++; - } catch (InterruptedException e) { - interrupted = true; } + } catch (InterruptedException e) { + interrupted = true; } } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/java/util/ListResourceBundle.java --- a/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -206,5 +206,5 @@ lookup = temp; } - private Map lookup = null; + private volatile Map lookup = null; } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java --- a/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -46,8 +46,6 @@ import java.nio.charset.MalformedInputException; import java.nio.charset.StandardCharsets; import java.nio.charset.UnmappableCharacterException; -import java.security.AccessController; -import java.util.Locale; import sun.security.action.GetPropertyAction; import sun.util.PropertyResourceBundleCharset; import sun.util.ResourceBundleEnumeration; @@ -236,5 +234,5 @@ // ==================privates==================== - private Map lookup; + private final Map lookup; } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/java/util/jar/JarFile.java --- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java Fri Sep 16 13:15:01 2016 -0700 @@ -536,19 +536,6 @@ * @return an ordered {@code Stream} of entries in this jar file * @throws IllegalStateException if the jar file has been closed * @since 1.8 - * - * @apiNote A versioned view of the stream obtained from a {@code JarFile} - * configured to process a multi-release jar file can be created with code - * similar to the following: - *
-     * {@code
-     *     Stream versionedStream(JarFile jf) {
-     *         return jf.stream().map(JarEntry::getName)
-     *                  .filter(name -> !name.startsWith("META-INF/versions/"))
-     *                  .map(jf::getJarEntry);
-     *     }
-     * }
-     * 
*/ public Stream stream() { return StreamSupport.stream(Spliterators.spliterator( @@ -571,7 +558,7 @@ private ZipEntry getVersionedEntry(ZipEntry ze) { ZipEntry vze = null; - if (BASE_VERSION_MAJOR < versionMajor && !ze.isDirectory()) { + if (BASE_VERSION_MAJOR < versionMajor) { String name = ze.getName(); if (!name.startsWith(META_INF)) { vze = searchForVersionedEntry(versionMajor, name); diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -28,12 +28,12 @@ public interface JavaLangRefAccess { /** - * Help ReferenceHandler thread process next pending - * {@link java.lang.ref.Reference} + * Wait for progress in {@link java.lang.ref.Reference} + * processing. If there aren't any pending {@link + * java.lang.ref.Reference}s, return immediately. * - * @return {@code true} if there was a pending reference and it - * was enqueue-ed or {@code false} if there was no - * pending reference + * @return {@code true} if there were any pending + * {@link java.lang.ref.Reference}s, {@code false} otherwise. */ - boolean tryHandlePendingReference(); + boolean waitForReferenceProcessing() throws InterruptedException; } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Fri Sep 16 13:15:01 2016 -0700 @@ -1197,6 +1197,9 @@ if (hostClass == null || data == null) { throw new NullPointerException(); } + if (hostClass.isArray() || hostClass.isPrimitive()) { + throw new IllegalArgumentException(); + } return defineAnonymousClass0(hostClass, data, cpPatches); } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016, 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 jdk.internal.util.jar; + +import java.util.Objects; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Stream; + +public class VersionedStream { + private static final String META_INF_VERSIONS = "META-INF/versions/"; + + /** + * Returns a stream of versioned entries, derived from the base names of + * all entries in a multi-release {@code JarFile} that are present either in + * the base directory or in any versioned directory with a version number + * less than or equal to the {@code Runtime.Version::major} that the + * {@code JarFile} was opened with. These versioned entries are aliases + * for the real entries -- i.e. the names are base names and the content + * may come from a versioned directory entry. If the {@code jarFile} is not + * a multi-release jar, a stream of all entries is returned. + * + * @param jf the input JarFile + * @return stream of entries + * @since 9 + */ + public static Stream stream(JarFile jf) { + if (jf.isMultiRelease()) { + int version = jf.getVersion().major(); + return jf.stream() + .map(je -> getBaseSuffix(je, version)) + .filter(Objects::nonNull) + .distinct() + .map(jf::getJarEntry); + } + return jf.stream(); + } + + private static String getBaseSuffix(JarEntry je, int version) { + String name = je.getName(); + if (name.startsWith(META_INF_VERSIONS)) { + int len = META_INF_VERSIONS.length(); + int index = name.indexOf('/', len); + if (index == -1 || index == (name.length() - 1)) { + // filter out META-INF/versions/* and META-INF/versions/*/ + return null; + } + try { + if (Integer.parseInt(name, len, index, 10) > version) { + // not an integer + return null; + } + } catch (NumberFormatException x) { + // silently remove malformed entries + return null; + } + // We know name looks like META-INF/versions/*/* + return name.substring(index + 1); + } + return name; + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/module-info.java --- a/jdk/src/java.base/share/classes/module-info.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/module-info.java Fri Sep 16 13:15:01 2016 -0700 @@ -143,7 +143,8 @@ exports jdk.internal.org.objectweb.asm.signature to jdk.scripting.nashorn; exports jdk.internal.loader to - java.instrument; + java.instrument, + java.logging; exports jdk.internal.math to java.desktop; exports jdk.internal.module to diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties Fri Sep 16 13:15:01 2016 -0700 @@ -103,34 +103,42 @@ # Translators please note do not translate the options themselves java.launcher.X.usage=\ -\ -Xmixed mixed mode execution (default)\n\ -\ -Xint interpreted mode execution only\n\ +\ -Xbatch disable background compilation\n\ \ -Xbootclasspath/a:\n\ \ append to end of bootstrap class path\n\ +\ -Xcheck:jni perform additional checks for JNI functions\n\ +\ -Xcomp forces compilation of methods on first invocation\n\ +\ -Xdebug provided for backward compatibility\n\ \ -Xdiag show additional diagnostic messages\n\ \ -Xdiag:resolver show resolver diagnostic messages\n\ -\ -Xnoclassgc disable class garbage collection\n\ +\ -Xdisable-@files disable further argument file expansion\n\ +\ -Xfuture enable strictest checks, anticipating future default\n\ +\ -Xint interpreted mode execution only\n\ +\ -Xinternalversion\n\ +\ displays more detailed JVM version information than the\n\ +\ -version option\n\ \ -Xloggc: log GC status to a file with time stamps\n\ -\ -Xbatch disable background compilation\n\ +\ -Xmixed mixed mode execution (default)\n\ +\ -Xmn sets the initial and maximum size (in bytes) of the heap\n\ +\ for the young generation (nursery)\n\ \ -Xms set initial Java heap size\n\ \ -Xmx set maximum Java heap size\n\ -\ -Xss set java thread stack size\n\ +\ -Xnoclassgc disable class garbage collection\n\ \ -Xprof output cpu profiling data\n\ -\ -Xfuture enable strictest checks, anticipating future default\n\ \ -Xrs reduce use of OS signals by Java/VM (see documentation)\n\ -\ -Xcheck:jni perform additional checks for JNI functions\n\ +\ -Xshare:auto use shared class data if possible (default)\n\ \ -Xshare:off do not attempt to use shared class data\n\ -\ -Xshare:auto use shared class data if possible (default)\n\ \ -Xshare:on require using shared class data, otherwise fail.\n\ \ -XshowSettings show all settings and continue\n\ \ -XshowSettings:all\n\ \ show all settings and continue\n\ -\ -XshowSettings:vm show all vm related settings and continue\n\ +\ -XshowSettings:locale\n\ +\ show all locale related settings and continue\n\ \ -XshowSettings:properties\n\ \ show all property settings and continue\n\ -\ -XshowSettings:locale\n\ -\ show all locale related settings and continue\n\ -\ -Xdisable-@files disable further argument file expansion\n\ +\ -XshowSettings:vm show all vm related settings and continue\n\ +\ -Xss set java thread stack size\n\ +\ -Xverify sets the mode of the bytecode verifier\n\ \ --add-reads =(,)*\n\ \ updates to read , regardless\n\ \ of module declaration. \n\ diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java Fri Sep 16 13:15:01 2016 -0700 @@ -125,7 +125,9 @@ * to get the jarFile, and set it as our permission. */ if (getUseCaches()) { + boolean oldUseCaches = jarFileURLConnection.getUseCaches(); jarFileURLConnection = factory.getConnection(jarFile); + jarFileURLConnection.setUseCaches(oldUseCaches); } if ((entryName != null)) { diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, 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 @@ -125,7 +125,7 @@ ("Exception while encoding OCSPRequest", e); } OCSPResponse ocspResponse = check(Collections.singletonList(certId), - responderURI, issuerCert, null, null, + responderURI, new OCSPResponse.IssuerInfo(issuerCert), null, null, Collections.emptyList()); return (RevocationStatus)ocspResponse.getSingleResponse(certId); } @@ -173,7 +173,8 @@ ("Exception while encoding OCSPRequest", e); } OCSPResponse ocspResponse = check(Collections.singletonList(certId), - responderURI, issuerCert, responderCert, date, extensions); + responderURI, new OCSPResponse.IssuerInfo(issuerCert), + responderCert, date, extensions); return (RevocationStatus) ocspResponse.getSingleResponse(certId); } @@ -182,7 +183,7 @@ * * @param certIds the CertIds to be checked * @param responderURI the URI of the OCSP responder - * @param issuerCert the issuer's certificate + * @param issuerInfo the issuer's certificate and/or subject and public key * @param responderCert the OCSP responder's certificate * @param date the time the validity of the OCSP responder's certificate * should be checked against. If null, the current time is used. @@ -195,8 +196,8 @@ * @throws CertPathValidatorException if an exception occurs while * encoding the OCSP Request or validating the OCSP Response */ - static OCSPResponse check(List certIds, URI responderURI, - X509Certificate issuerCert, + static OCSPResponse check(List certIds, URI responderURI, + OCSPResponse.IssuerInfo issuerInfo, X509Certificate responderCert, Date date, List extensions) throws IOException, CertPathValidatorException @@ -214,7 +215,7 @@ ocspResponse = new OCSPResponse(response); // verify the response - ocspResponse.verify(certIds, issuerCert, responderCert, date, + ocspResponse.verify(certIds, issuerInfo, responderCert, date, nonce); } catch (IOException ioe) { throw new CertPathValidatorException( diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -41,6 +41,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import javax.security.auth.x500.X500Principal; @@ -373,8 +374,8 @@ } } - void verify(List certIds, X509Certificate issuerCert, - X509Certificate responderCert, Date date, byte[] nonce) + void verify(List certIds, IssuerInfo issuerInfo, + X509Certificate responderCert, Date date, byte[] nonce) throws CertPathValidatorException { switch (responseStatus) { @@ -414,7 +415,9 @@ // Add the Issuing CA cert and/or Trusted Responder cert to the list // of certs from the OCSP response try { - certs.add(X509CertImpl.toImpl(issuerCert)); + if (issuerInfo.getCertificate() != null) { + certs.add(X509CertImpl.toImpl(issuerInfo.getCertificate())); + } if (responderCert != null) { certs.add(X509CertImpl.toImpl(responderCert)); } @@ -464,7 +467,10 @@ // Check whether the signer cert returned by the responder is trusted if (signerCert != null) { // Check if the response is signed by the issuing CA - if (signerCert.equals(issuerCert)) { + if (signerCert.getSubjectX500Principal().equals( + issuerInfo.getName()) && + signerCert.getPublicKey().equals( + issuerInfo.getPublicKey())) { if (debug != null) { debug.println("OCSP response is signed by the target's " + "Issuing CA"); @@ -481,7 +487,7 @@ // Check if the response is signed by an authorized responder } else if (signerCert.getIssuerX500Principal().equals( - issuerCert.getSubjectX500Principal())) { + issuerInfo.getName())) { // Check for the OCSPSigning key purpose try { @@ -502,7 +508,8 @@ // Check algorithm constraints specified in security property // "jdk.certpath.disabledAlgorithms". AlgorithmChecker algChecker = new AlgorithmChecker( - new TrustAnchor(issuerCert, null)); + new TrustAnchor(issuerInfo.getName(), + issuerInfo.getPublicKey(), null)); algChecker.init(false); algChecker.check(signerCert, Collections.emptySet()); @@ -540,7 +547,7 @@ // verify the signature try { - signerCert.verify(issuerCert.getPublicKey()); + signerCert.verify(issuerInfo.getPublicKey()); if (debug != null) { debug.println("OCSP response is signed by an " + "Authorized Responder"); @@ -971,4 +978,86 @@ return sb.toString(); } } + + /** + * Helper class that allows consumers to pass in issuer information. This + * will always consist of the issuer's name and public key, but may also + * contain a certificate if the originating data is in that form. + */ + static final class IssuerInfo { + private final X509Certificate certificate; + private final X500Principal name; + private final PublicKey pubKey; + + IssuerInfo(X509Certificate issuerCert) { + certificate = Objects.requireNonNull(issuerCert, + "Constructor requires non-null certificate"); + name = certificate.getSubjectX500Principal(); + pubKey = certificate.getPublicKey(); + } + + IssuerInfo(X500Principal subjectName, PublicKey key) { + certificate = null; + name = Objects.requireNonNull(subjectName, + "Constructor requires non-null subject"); + pubKey = Objects.requireNonNull(key, + "Constructor requires non-null public key"); + } + + IssuerInfo(TrustAnchor anchor) { + certificate = anchor.getTrustedCert(); + if (certificate != null) { + name = certificate.getSubjectX500Principal(); + pubKey = certificate.getPublicKey(); + } else { + name = anchor.getCA(); + pubKey = anchor.getCAPublicKey(); + } + } + + /** + * Get the certificate in this IssuerInfo if present. + * + * @return the {@code X509Certificate} used to create this IssuerInfo + * object, or {@code null} if a certificate was not used in its + * creation. + */ + X509Certificate getCertificate() { + return certificate; + } + + /** + * Get the name of this issuer. + * + * @return an {@code X500Principal} corresponding to this issuer's + * name. If derived from an issuer's {@code X509Certificate} this + * would be equivalent to the certificate subject name. + */ + X500Principal getName() { + return name; + } + + /** + * Get the public key for this issuer. + * + * @return a {@code PublicKey} for this issuer. + */ + PublicKey getPublicKey() { + return pubKey; + } + + /** + * Create a string representation of this IssuerInfo. + * + * @return a {@code String} form of this IssuerInfo object. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Issuer Info:\n"); + sb.append("Name: ").append(name.toString()).append("\n"); + sb.append("Public Key:\n").append(pubKey.toString()).append("\n"); + return sb.toString(); + } + } } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -61,12 +61,12 @@ private List certStores; private Map ocspResponses; private List ocspExtensions; - private boolean legacy; + private final boolean legacy; private LinkedList softFailExceptions = new LinkedList<>(); // state variables - private X509Certificate issuerCert; + private OCSPResponse.IssuerInfo issuerInfo; private PublicKey prevPubKey; private boolean crlSignFlag; private int certIndex; @@ -301,9 +301,9 @@ CertPathValidatorException("forward checking not supported"); } if (anchor != null) { - issuerCert = anchor.getTrustedCert(); - prevPubKey = (issuerCert != null) ? issuerCert.getPublicKey() - : anchor.getCAPublicKey(); + issuerInfo = new OCSPResponse.IssuerInfo(anchor); + prevPubKey = issuerInfo.getPublicKey(); + } crlSignFlag = true; if (params != null && params.certPath() != null) { @@ -437,7 +437,7 @@ private void updateState(X509Certificate cert) throws CertPathValidatorException { - issuerCert = cert; + issuerInfo = new OCSPResponse.IssuerInfo(cert); // Make new public key if parameters are missing PublicKey pubKey = cert.getPublicKey(); @@ -708,14 +708,8 @@ OCSPResponse response = null; CertId certId = null; try { - if (issuerCert != null) { - certId = new CertId(issuerCert, - currCert.getSerialNumberObject()); - } else { - // must be an anchor name and key - certId = new CertId(anchor.getCA(), anchor.getCAPublicKey(), - currCert.getSerialNumberObject()); - } + certId = new CertId(issuerInfo.getName(), issuerInfo.getPublicKey(), + currCert.getSerialNumberObject()); // check if there is a cached OCSP response available byte[] responseBytes = ocspResponses.get(cert); @@ -732,8 +726,8 @@ nonce = ext.getValue(); } } - response.verify(Collections.singletonList(certId), issuerCert, - responderCert, params.date(), nonce); + response.verify(Collections.singletonList(certId), issuerInfo, + responderCert, params.date(), nonce); } else { URI responderURI = (this.responderURI != null) @@ -746,8 +740,8 @@ } response = OCSP.check(Collections.singletonList(certId), - responderURI, issuerCert, responderCert, - null, ocspExtensions); + responderURI, issuerInfo, + responderCert, null, ocspExtensions); } } catch (IOException e) { throw new CertPathValidatorException( diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties --- a/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties Fri Sep 16 13:15:01 2016 -0700 @@ -92,6 +92,7 @@ BTN=BTN BWP=BWP BYB=BYB +BYN=BYN BYR=BYR BZD=BZD CAD=CAD @@ -310,8 +311,9 @@ bsd=Bahamian Dollar btn=Bhutanese Ngultrum bwp=Botswanan Pula -byb=Belarusian New Ruble (1994-1999) -byr=Belarusian Ruble +byb=Belarusian Ruble (1994-1999) +byn=Belarusian Ruble +byr=Belarusian Ruble (2000-2016) bzd=Belize Dollar cad=Canadian Dollar cdf=Congolese Franc @@ -399,7 +401,7 @@ mtl=Maltese Lira mur=Mauritian Rupee mvr=Maldivian Rufiyaa -mwk=Malawian Kwacha +mwk=Malawian Malawi Kwacha mxn=Mexican Peso mxv=Mexican Investment Unit myr=Malaysian Ringgit @@ -414,7 +416,7 @@ nzd=New Zealand Dollar omr=Omani Rial pab=Panamanian Balboa -pen=Peruvian Nuevo Sol +pen=Peruvian Sol pgk=Papua New Guinean Kina php=Philippine Peso pkr=Pakistani Rupee diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/native/include/jvm.h --- a/jdk/src/java.base/share/native/include/jvm.h Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/native/include/jvm.h Fri Sep 16 13:15:01 2016 -0700 @@ -282,6 +282,18 @@ JVM_GetSystemPackages(JNIEnv *env); /* + * java.lang.ref.Reference + */ +JNIEXPORT jobject JNICALL +JVM_GetAndClearReferencePendingList(JNIEnv *env); + +JNIEXPORT jboolean JNICALL +JVM_HasReferencePendingList(JNIEnv *env); + +JNIEXPORT void JNICALL +JVM_WaitForReferencePendingList(JNIEnv *env); + +/* * java.io.ObjectInputStream */ JNIEXPORT jobject JNICALL diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/native/libjava/Reference.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/native/libjava/Reference.c Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016, 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. + */ + +#include "jvm.h" +#include "java_lang_ref_Reference.h" + +JNIEXPORT jobject JNICALL +Java_java_lang_ref_Reference_getAndClearReferencePendingList(JNIEnv *env, jclass ignore) +{ + return JVM_GetAndClearReferencePendingList(env); +} + +JNIEXPORT jboolean JNICALL +Java_java_lang_ref_Reference_hasReferencePendingList(JNIEnv *env, jclass ignore) +{ + return JVM_HasReferencePendingList(env); +} + +JNIEXPORT void JNICALL +Java_java_lang_ref_Reference_waitForReferencePendingList(JNIEnv *env, jclass ignore) +{ + JVM_WaitForReferencePendingList(env); +} diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/share/native/libjli/java.h --- a/jdk/src/java.base/share/native/libjli/java.h Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/share/native/libjli/java.h Fri Sep 16 13:15:01 2016 -0700 @@ -112,6 +112,9 @@ jboolean GetApplicationHome(char *buf, jint bufsize); +jboolean +GetApplicationHomeFromDll(char *buf, jint bufsize); + #define GetArch() GetArchPath(CURRENT_DATA_MODEL) /* diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/solaris/native/libnet/solaris_close.c --- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c Fri Sep 16 13:15:01 2016 -0700 @@ -35,7 +35,7 @@ if (1) { \ do { \ _result = _cmd; \ - } while((_result == -1) && (errno == EINTR)); \ + } while((_result == -1) && (errno == EINTR)); \ return _result; \ } \ } while(0) @@ -44,6 +44,10 @@ RESTARTABLE_RETURN_INT(recv(s, buf, len, 0)); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + RESTARTABLE_RETURN_INT(recv(s, buf, len, MSG_DONTWAIT)); +} + int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { RESTARTABLE_RETURN_INT(recvfrom(s, buf, len, flags, from, fromlen)); @@ -86,19 +90,14 @@ RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout)); } -int NET_Timeout(int s, long timeout) { +int NET_Timeout0(int s, long timeout, long currentTime) { int result; struct timeval t; - long prevtime, newtime; + long prevtime = currentTime, newtime; struct pollfd pfd; pfd.fd = s; pfd.events = POLLIN; - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = (t.tv_sec * 1000) + t.tv_usec / 1000; - } - for(;;) { result = poll(&pfd, 1, timeout); if (result < 0 && errno == EINTR) { diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/unix/native/libjava/TimeZone_md.c --- a/jdk/src/java.base/unix/native/libjava/TimeZone_md.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/unix/native/libjava/TimeZone_md.c Fri Sep 16 13:15:01 2016 -0700 @@ -128,13 +128,20 @@ char *dbuf = NULL; char *tz = NULL; int res; + long name_max = 0; dirp = opendir(dir); if (dirp == NULL) { return NULL; } - entry = (struct dirent64 *) malloc((size_t) pathconf(dir, _PC_NAME_MAX)); + name_max = pathconf(dir, _PC_NAME_MAX); + // If pathconf did not work, fall back to a mimimum buffer size. + if (name_max < 1024) { + name_max = 1024; + } + + entry = (struct dirent64 *)malloc(offsetof(struct dirent64, d_name) + name_max + 1); if (entry == NULL) { (void) closedir(dirp); return NULL; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/unix/native/libjli/java_md_common.c --- a/jdk/src/java.base/unix/native/libjli/java_md_common.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/unix/native/libjli/java_md_common.c Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -25,8 +25,49 @@ #include "java.h" /* - * If app is "/foo/bin/javac", or "/foo/bin/sparcv9/javac" then put - * "/foo" into buf. + * Find the last occurrence of a string + */ +char* findLastPathComponent(char *buffer, const char *comp) { + char* t = buffer; + char* p = NULL; + size_t l = JLI_StrLen(comp); + t = JLI_StrStr(t, comp); + + while (t != NULL) { + p = t; + t += l; + t = JLI_StrStr(t, comp); + } + return p; +} + +/* + * Removes the trailing file name and any intermediate platform + * directories, if any, and its enclosing directory. + * Ex: if a buffer contains "/foo/bin/javac" or "/foo/bin/x64/javac", the + * truncated resulting buffer will contain "/foo". + */ +jboolean +TruncatePath(char *buf) +{ + // try bin directory, maybe an executable + char *p = findLastPathComponent(buf, "/bin/"); + if (p != NULL) { + *p = '\0'; + return JNI_TRUE; + } + // try lib directory, maybe a library + p = findLastPathComponent(buf, "/lib/"); + if (p != NULL) { + *p = '\0'; + return JNI_TRUE; + } + return JNI_FALSE; +} + +/* + * Retrieves the path to the JRE home by locating the executable file + * of the current process and then truncating the path to the executable */ jboolean GetApplicationHome(char *buf, jint bufsize) @@ -38,26 +79,27 @@ } else { return JNI_FALSE; } + return TruncatePath(buf); +} - if (JLI_StrRChr(buf, '/') == 0) { - buf[0] = '\0'; - return JNI_FALSE; - } - *(JLI_StrRChr(buf, '/')) = '\0'; /* executable file */ - if (JLI_StrLen(buf) < 4 || JLI_StrRChr(buf, '/') == 0) { - buf[0] = '\0'; - return JNI_FALSE; +/* + * Retrieves the path to the JRE home by locating the + * shared library and then truncating the path to it. + */ +jboolean +GetApplicationHomeFromDll(char *buf, jint bufsize) +{ + /* try to find ourselves instead */ + Dl_info info; + if (dladdr((void*)&GetApplicationHomeFromDll, &info) != 0) { + char *path = realpath(info.dli_fname, buf); + if (path == buf) { + return TruncatePath(buf); + } } - if (JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0) - *(JLI_StrRChr(buf, '/')) = '\0'; /* sparcv9 or amd64 */ - if (JLI_StrLen(buf) < 4 || JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0) { - buf[0] = '\0'; - return JNI_FALSE; - } - *(JLI_StrRChr(buf, '/')) = '\0'; /* bin */ + return JNI_FALSE; +} - return JNI_TRUE; -} /* * Return true if the named program exists */ diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/unix/native/libjli/java_md_solinux.c --- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -666,6 +666,7 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative) { char libjava[MAXPATHLEN]; + struct stat s; if (GetApplicationHome(path, pathsize)) { /* Is JRE co-located with the application? */ @@ -688,6 +689,14 @@ } } + if (GetApplicationHomeFromDll(path, pathsize)) { + JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/%s/" JAVA_DLL, path, arch); + if (stat(libjava, &s) == 0) { + JLI_TraceLauncher("JRE path is %s\n", path); + return JNI_TRUE; + } + } + if (!speculative) JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); return JNI_FALSE; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/unix/native/libnet/SocketInputStream.c --- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c Fri Sep 16 13:15:01 2016 -0700 @@ -35,7 +35,6 @@ #include "java_net_SocketInputStream.h" - /************************************************************************ * SocketInputStream */ @@ -52,6 +51,40 @@ IO_fd_fdID = NET_GetFileDescriptorID(env); } +static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) { + int result = 0; + long prevtime = NET_GetCurrentTime(), newtime; + while (timeout > 0) { + result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime); + if (result <= 0) { + if (result == 0) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", "Read timed out"); + } else if (result == -1) { + if (errno == EBADF) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); + } else if (errno == ENOMEM) { + JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed"); + } else { + JNU_ThrowByNameWithMessageAndLastError + (env, JNU_JAVANETPKG "SocketException", "select/poll failed"); + } + } + return -1; + } + result = NET_NonBlockingRead(fd, bufP, len); + if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) { + newtime = NET_GetCurrentTime(); + timeout -= newtime - prevtime; + if (timeout > 0) { + prevtime = newtime; + } + } else { + break; + } + } + return result; +} + /* * Class: java_net_SocketInputStream * Method: socketRead0 @@ -98,32 +131,18 @@ } else { bufP = BUF; } - if (timeout) { - nread = NET_Timeout(fd, timeout); - if (nread <= 0) { - if (nread == 0) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", - "Read timed out"); - } else if (nread == -1) { - if (errno == EBADF) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); - } else if (errno == ENOMEM) { - JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed"); - } else { - JNU_ThrowByNameWithMessageAndLastError - (env, JNU_JAVANETPKG "SocketException", "select/poll failed"); - } - } + nread = NET_ReadWithTimeout(env, fd, bufP, len, timeout); + if ((*env)->ExceptionCheck(env)) { if (bufP != BUF) { free(bufP); } - return -1; + return nread; } + } else { + nread = NET_Read(fd, bufP, len); } - nread = NET_Read(fd, bufP, len); - if (nread <= 0) { if (nread < 0) { @@ -143,7 +162,6 @@ JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException", "Operation interrupted"); break; - default: JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Read failed"); diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/unix/native/libnet/net_util_md.c --- a/jdk/src/java.base/unix/native/libnet/net_util_md.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c Fri Sep 16 13:15:01 2016 -0700 @@ -33,6 +33,7 @@ #include #include #include +#include #ifndef _ALLBSD_SOURCE #include @@ -1669,3 +1670,18 @@ return timeout; } + +long NET_GetCurrentTime() { + struct timeval time; + gettimeofday(&time, NULL); + return (time.tv_sec * 1000 + time.tv_usec / 1000); +} + +int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) { + return NET_Timeout0(s, timeout, currentTime); +} + +int NET_Timeout(int s, long timeout) { + long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0; + return NET_Timeout0(s, timeout, currentTime); +} diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/unix/native/libnet/net_util_md.h --- a/jdk/src/java.base/unix/native/libnet/net_util_md.h Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h Fri Sep 16 13:15:01 2016 -0700 @@ -35,7 +35,11 @@ #include int NET_Timeout(int s, long timeout); +int NET_Timeout0(int s, long timeout, long currentTime); int NET_Read(int s, void* buf, size_t len); +int NET_NonBlockingRead(int s, void* buf, size_t len); +int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime); +long NET_GetCurrentTime(); int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); int NET_ReadV(int s, const struct iovec * vector, int count); diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/windows/native/libjli/java_md.c --- a/jdk/src/java.base/windows/native/libjli/java_md.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/windows/native/libjli/java_md.c Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -348,7 +348,6 @@ JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); return JNI_FALSE; - } /* @@ -423,11 +422,11 @@ *JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */ if ((cp = JLI_StrRChr(buf, '\\')) == 0) { /* This happens if the application is in a drive root, and - * there is no bin directory. */ + * there is no bin directory. */ buf[0] = '\0'; return JNI_FALSE; } - *cp = '\0'; /* remove the bin\ part */ + *cp = '\0'; /* remove the bin\ part */ return JNI_TRUE; } @@ -449,16 +448,16 @@ jboolean GetApplicationHomeFromDll(char *buf, jint bufsize) { - HMODULE hModule; - DWORD dwFlags = - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; + HMODULE module; + DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; - if (GetModuleHandleEx(dwFlags, (LPCSTR)&GetJREPath, &hModule) == 0) { - return JNI_FALSE; - }; - GetModuleFileName(hModule, buf, bufsize); - return TruncatePath(buf); + if (GetModuleHandleEx(flags, (LPCSTR)&GetJREPath, &module) != 0) { + if (GetModuleFileName(module, buf, bufsize) != 0) { + return TruncatePath(buf); + } + } + return JNI_FALSE; } /* diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.base/windows/native/libjli/java_md.h --- a/jdk/src/java.base/windows/native/libjli/java_md.h Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.base/windows/native/libjli/java_md.h Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -54,7 +54,4 @@ int UnsetEnv(char *name); -jboolean -GetApplicationHomeFromDll(char *buf, jint bufsize); - #endif /* JAVA_MD_H */ diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Fri Sep 16 13:15:01 2016 -0700 @@ -187,6 +187,7 @@ updateAlwaysOnTopState(); updateMinimumSize(); + updateFocusableWindowState(); final Shape shape = getTarget().getShape(); if (shape != null) { diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Fri Sep 16 13:15:01 2016 -0700 @@ -63,6 +63,7 @@ private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename); private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled); private static native void nativeSynthesizeMouseEnteredExitedEvents(); + private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType); private static native void nativeDispose(long nsWindowPtr); private static native void nativeEnterFullScreenMode(long nsWindowPtr); private static native void nativeExitFullScreenMode(long nsWindowPtr); @@ -825,6 +826,13 @@ return; } + if (blocked) { + // We are going to show a modal window. Previously displayed window will be + // blocked/disabled. So we have to send mouse exited event to it now, since + // all mouse events are discarded for blocked/disabled windows. + nativeSynthesizeMouseEnteredExitedEvents(getNSWindowPtr(), CocoaConstants.NSMouseExited); + } + nativeSetEnabled(getNSWindowPtr(), !blocked); checkBlockingAndOrder(); } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Fri Sep 16 13:15:01 2016 -0700 @@ -1333,9 +1333,9 @@ /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSynthesizeMouseEnteredExitedEvents - * Signature: (J)V + * Signature: ()V */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__ (JNIEnv *env, jclass clazz) { JNF_COCOA_ENTER(env); @@ -1349,6 +1349,29 @@ /* * Class: sun_lwawt_macosx_CPlatformWindow + * Method: nativeSynthesizeMouseEnteredExitedEvents + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__JI +(JNIEnv *env, jclass clazz, jlong windowPtr, jint eventType) +{ +JNF_COCOA_ENTER(env); + + if (eventType == NSMouseEntered || eventType == NSMouseExited) { + NSWindow *nsWindow = OBJC(windowPtr); + + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ + [AWTWindow synthesizeMouseEnteredExitedEvents:nsWindow withType:eventType]; + }]; + } else { + [JNFException raise:env as:kIllegalArgumentException reason:"unknown event type"]; + } + +JNF_COCOA_EXIT(env); +} + +/* + * Class: sun_lwawt_macosx_CPlatformWindow * Method: _toggleFullScreenMode * Signature: (J)V */ diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java --- a/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java Fri Sep 16 13:15:01 2016 -0700 @@ -447,6 +447,7 @@ * @param shape the new 'mixing-cutout' shape * @throws NullPointerException if the component argument is {@code null} */ + @Deprecated(since = "9") public static void setComponentMixingCutoutShape(Component component, Shape shape) { diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -749,6 +749,10 @@ checkIndex(imageIndex); clearAbortRequest(); processImageStarted(imageIndex); + if (abortRequested()) { + processReadAborted(); + return bi; + } if (param == null) param = getDefaultReadParam(); @@ -1005,9 +1009,6 @@ int j = isBottomUp ? (height -1)*bytesPerScanline : 0; for (int i=0; i + * The {@code shape} argument may have the following values: + *
    + *
  • {@code null} - reverts the default cutout shape (the rectangle equal + * to the component's {@code getBounds()}) + *
  • empty-shape - does not cut out anything from heavyweight + * components. This makes the given lightweight component effectively + * transparent. Note that descendants of the lightweight component still + * affect the shapes of heavyweight components. An example of an + * empty-shape is {@code new Rectangle()}. + *
  • non-empty-shape - the given shape will be cut out from + * heavyweight components. + *
+ *

+ * The most common example when the 'mixing-cutout' shape is needed is a + * glass pane component. The {@link JRootPane#setGlassPane()} method + * automatically sets the empty-shape as the 'mixing-cutout' shape + * for the given glass pane component. If a developer needs some other + * 'mixing-cutout' shape for the glass pane (which is rare), this must be + * changed manually after installing the glass pane to the root pane. + *

+ * Note that the 'mixing-cutout' shape neither affects painting, nor the + * mouse events handling for the given component. It is used exclusively + * for the purposes of the Heavyweight/Lightweight Components Mixing + * feature. + * + * @param shape the new 'mixing-cutout' shape + * @since 9 + */ + void setMixingCutoutShape(Shape shape) { + Region region = shape == null ? null : Region.getInstance(shape, null); + + synchronized (getTreeLock()) { + boolean needShowing = false; + boolean needHiding = false; + + if (!isNonOpaqueForMixing()) { + needHiding = true; + } + + mixingCutoutRegion = region; + + if (!isNonOpaqueForMixing()) { + needShowing = true; + } + + if (isMixingNeeded()) { + if (needHiding) { + mixOnHiding(isLightweight()); + } + if (needShowing) { + mixOnShowing(); + } + } + } + } + // ****************** END OF MIXING CODE ******************************** // Note that the method is overriden in the Window class, diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/java/awt/Taskbar.java --- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java Fri Sep 16 13:15:01 2016 -0700 @@ -273,9 +273,7 @@ } /** - * Requests user attention to the specified window until it is activated. - * - * On an already active window requesting attention does nothing. + * Requests user attention to the specified window. * * @param w window * @throws SecurityException if a security manager exists and it denies the diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/java/awt/Toolkit.java --- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java Fri Sep 16 13:15:01 2016 -0700 @@ -208,7 +208,7 @@ /** * Returns whether dynamic layout of Containers on resize is currently - * enabled on the underlying operating system and/or window manager). If the + * enabled on the underlying operating system and/or window manager. If the * platform supports it, {@code setDynamicLayout(boolean)} may be used to * programmatically enable or disable platform dynamic layout. Regardless of * whether that toggling is supported, or whether {@code true} or {@code diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java --- a/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java Fri Sep 16 13:15:01 2016 -0700 @@ -49,9 +49,7 @@ default void requestUserAttention(boolean enabled, final boolean critical) {} /** - * Requests user attention to the specified window until it is activated. - * - * On an already active window requesting attention does nothing. + * Requests user attention to the specified window. * * @param w window */ diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java --- a/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -26,15 +26,11 @@ import java.awt.Component; import java.awt.Container; -import java.awt.Window; import java.util.*; import java.awt.FocusTraversalPolicy; import sun.util.logging.PlatformLogger; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import sun.security.action.GetPropertyAction; import java.security.AccessController; -import java.security.PrivilegedAction; /** * A FocusTraversalPolicy that determines traversal order by sorting the @@ -100,27 +96,10 @@ * See: JDK-8048887 */ private static final boolean legacySortingFTPEnabled; - private static final Method legacyMergeSortMethod; static { legacySortingFTPEnabled = "true".equals(AccessController.doPrivileged( new GetPropertyAction("swing.legacySortingFTPEnabled", "true"))); - legacyMergeSortMethod = legacySortingFTPEnabled ? - AccessController.doPrivileged(new PrivilegedAction() { - public Method run() { - try { - Method m = java.util.Arrays.class.getDeclaredMethod("legacyMergeSort", - new Class[]{Object[].class, - Comparator.class}); - m.setAccessible(true); - return m; - } catch (NoSuchMethodException e) { - // using default sorting algo - return null; - } - } - }) : - null; } /** @@ -169,30 +148,25 @@ private void enumerateAndSortCycle(Container focusCycleRoot, List cycle) { if (focusCycleRoot.isShowing()) { enumerateCycle(focusCycleRoot, cycle); - if (!legacySortingFTPEnabled || - !legacySort(cycle, comparator)) - { - Collections.sort(cycle, comparator); + if (legacySortingFTPEnabled) { + legacySort(cycle, comparator); + } else { + cycle.sort(comparator); } } } - private boolean legacySort(List l, Comparator c) { - if (legacyMergeSortMethod == null) - return false; - - Object[] a = l.toArray(); - try { - legacyMergeSortMethod.invoke(null, a, c); - } catch (IllegalAccessException | InvocationTargetException e) { - return false; + private void legacySort(List l, + Comparator c) { + if (c != null && l.size() > 1) { + Component[] a = l.toArray(new Component[l.size()]); + mergeSort(a.clone(), a, 0, a.length, 0, c); + ListIterator i = l.listIterator(); + for (Component e : a) { + i.next(); + i.set(e); + } } - ListIterator i = l.listIterator(); - for (Object e : a) { - i.next(); - i.set((Component)e); - } - return true; } @SuppressWarnings("deprecation") @@ -665,6 +639,48 @@ protected boolean accept(Component aComponent) { return fitnessTestPolicy.accept(aComponent); } + + // merge sort implementation copied from java.utils.Arrays + private void mergeSort(T[] src, T[] dest, + int low, int high, int off, + Comparator c) { + int length = high - low; + + // Insertion sort on smallest arrays + if (length < 7) { + for (int i=low; ilow && c.compare(dest[j-1], dest[j])>0; j--) { + T t = dest[j]; + dest[j] = dest[j-1]; + dest[j-1] = t; + } + return; + } + + // Recursively sort halves of dest into src + int destLow = low; + int destHigh = high; + low += off; + high += off; + int mid = (low + high) >>> 1; + mergeSort(dest, src, low, mid, -off, c); + mergeSort(dest, src, mid, high, -off, c); + + // If list is already sorted, just copy from src to dest. This is an + // optimization that results in faster sorts for nearly ordered lists. + if (c.compare(src[mid-1], src[mid]) <= 0) { + System.arraycopy(src, low, dest, destLow, length); + return; + } + + // Merge sorted halves (now in src) into dest + for(int i = destLow, p = low, q = mid; i < destHigh; i++) { + if (q >= high || p < mid && c.compare(src[p], src[q]) <= 0) + dest[i] = src[p++]; + else + dest[i] = src[q++]; + } + } } // Create our own subclass and change accept to public so that we can call diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -1603,13 +1603,18 @@ blockIncrement = 1; } + int tickSpacing = getTickSpacing(); if (slider.getSnapToTicks()) { - int tickSpacing = getTickSpacing(); if (blockIncrement < tickSpacing) { blockIncrement = tickSpacing; } } + else { + if (tickSpacing > 0) { + blockIncrement = tickSpacing; + } + } int delta = blockIncrement * ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL); slider.setValue(slider.getValue() + delta); diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Fri Sep 16 13:15:01 2016 -0700 @@ -391,21 +391,8 @@ } private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon) { - ButtonModel model = b.getModel(); - Icon icon = null; - if (model.isSelected()) { - icon = getIcon(b, b.getRolloverSelectedIcon(), null, - SynthConstants.MOUSE_OVER | SynthConstants.SELECTED); - if (icon == null) { - icon = getIcon(b, b.getSelectedIcon(), null, - SynthConstants.SELECTED); - } - } - if (icon == null) { - icon = getIcon(b, b.getRolloverIcon(), defaultIcon, - SynthConstants.MOUSE_OVER); - } - return icon; + return getSpecificIcon(b, b.getRolloverSelectedIcon(), b.getRolloverIcon(), + defaultIcon, SynthConstants.MOUSE_OVER); } private Icon getPressedIcon(AbstractButton b, Icon defaultIcon) { @@ -414,21 +401,44 @@ } private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon) { - ButtonModel model = b.getModel(); + return getSpecificIcon(b, b.getDisabledSelectedIcon(), b.getDisabledIcon(), + defaultIcon, SynthConstants.DISABLED); + } + + private Icon getSpecificIcon(AbstractButton b, Icon specificSelectedIcon, + Icon specificIcon, Icon defaultIcon, + int state) { + boolean selected = b.getModel().isSelected(); Icon icon = null; - if (model.isSelected()) { - icon = getIcon(b, b.getDisabledSelectedIcon(), null, - SynthConstants.DISABLED | SynthConstants.SELECTED); + + if (selected) { + icon = specificSelectedIcon; if (icon == null) { - icon = getIcon(b, b.getSelectedIcon(), null, - SynthConstants.SELECTED); + icon = b.getSelectedIcon(); } } + if (icon == null) { - icon = getIcon(b, b.getDisabledIcon(), defaultIcon, - SynthConstants.DISABLED); + icon = specificIcon; + } + + if (icon != null) { + return icon; } - return icon; + + if (defaultIcon == null || defaultIcon instanceof UIResource) { + if (selected) { + icon = getSynthIcon(b, state | SynthConstants.SELECTED); + if (icon == null) { + icon = getSynthIcon(b, SynthConstants.SELECTED); + } + } + if (icon == null) { + icon = getSynthIcon(b, state); + } + } + + return icon != null ? icon : defaultIcon; } /** diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java --- a/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java Fri Sep 16 13:15:01 2016 -0700 @@ -550,13 +550,16 @@ return charinfo; } + private static final boolean DEBUG = FontUtilities.debugFonts(); /* * This takes the glyph info record obtained from the glyph vector and converts it into a similar record * adjusted to represent character data instead. For economy we don't use glyph info records in this processing. * * Here are some constraints: * - there can be more glyphs than characters (glyph insertion, perhaps based on normalization, has taken place) -* - there can not be fewer glyphs than characters (0xffff glyphs are inserted for characters ligaturized away) +* - there can be fewer glyphs than characters +* Some layout engines may insert 0xffff glyphs for characters ligaturized away, but +* not all do, and it cannot be relied upon. * - each glyph maps to a single character, when multiple glyphs exist for a character they all map to it, but * no two characters map to the same glyph * - multiple glyphs mapping to the same character need not be in sequence (thai, tamil have split characters) @@ -578,7 +581,8 @@ * * The algorithm works in the following way: * 1) we scan the glyphs ltr or rtl based on the bidi run direction -* 2) we can work in place, since we always consume a glyph for each char we write +* 2) Since the may be fewer glyphs than chars we cannot work in place. +* A new array is allocated for output. * a) if the line is ltr, we start writing at position 0 until we finish, there may be leftver space * b) if the line is rtl and 1-1, we start writing at position numChars/glyphs - 1 until we finish at 0 * c) otherwise if we don't finish at 0, we have to copy the data down @@ -594,7 +598,7 @@ * iii) the x advance is the distance to the maximum x + adv of all glyphs whose advance is not zero * iv) the y advance is the baseline * v) vis x,y,w,h tightly encloses the vis x,y,w,h of all the glyphs with nonzero w and h -* 4) we can make some simple optimizations if we know some things: +* 4) In the future, we can make some simple optimizations to avoid copying if we know some things: * a) if the mapping is 1-1, unidirectional, and there are no zero-adv glyphs, we just return the glyphinfo * b) if the mapping is 1-1, unidirectional, we just adjust the remaining glyphs to originate at right/left of the base * c) if the mapping is 1-1, we compute the base position and advance as we go, then go back to adjust the remaining glyphs @@ -625,23 +629,20 @@ System.out.println(source); } - /* - if ((gv.getDescriptionFlags() & 0x7) == 0) { - return glyphinfo; - } - */ - int numGlyphs = gv.getNumGlyphs(); if (numGlyphs == 0) { return glyphinfo; } int[] indices = gv.getGlyphCharIndices(0, numGlyphs, null); + float[] charInfo = new float[source.getLength() * numvals]; - boolean DEBUG = false; if (DEBUG) { System.err.println("number of glyphs: " + numGlyphs); + System.err.println("glyphinfo.len: " + glyphinfo.length); + System.err.println("indices.len: " + indices.length); for (int i = 0; i < numGlyphs; ++i) { System.err.println("g: " + i + + " v: " + gv.getGlyphCode(i) + ", x: " + glyphinfo[i*numvals+posx] + ", a: " + glyphinfo[i*numvals+advx] + ", n: " + indices[i]); @@ -650,22 +651,19 @@ int minIndex = indices[0]; // smallest index seen this cluster int maxIndex = minIndex; // largest index seen this cluster - int nextMin = 0; // expected smallest index for this cluster int cp = 0; // character position - int cx = 0; // character index (logical) + int cc = 0; int gp = 0; // glyph position int gx = 0; // glyph index (visual) int gxlimit = numGlyphs; // limit of gx, when we reach this we're done int pdelta = numvals; // delta for incrementing positions int xdelta = 1; // delta for incrementing indices - boolean ltr = (source.getLayoutFlags() & 0x1) == 0; - if (!ltr) { + boolean rtl = (source.getLayoutFlags() & 0x1) == 1; + if (rtl) { minIndex = indices[numGlyphs - 1]; maxIndex = minIndex; - nextMin = 0; // still logical - cp = glyphinfo.length - numvals; - cx = 0; // still logical + cp = charInfo.length - numvals; gp = glyphinfo.length - numvals; gx = numGlyphs - 1; gxlimit = -1; @@ -693,47 +691,36 @@ float cposl = 0, cposr = 0, cvisl = 0, cvist = 0, cvisr = 0, cvisb = 0; float baseline = 0; - // record if we have to copy data even when no cluster - boolean mustCopy = false; - while (gx != gxlimit) { // start of new cluster - boolean haveCopy = false; int clusterExtraGlyphs = 0; minIndex = indices[gx]; maxIndex = minIndex; + cposl = glyphinfo[gp + posx]; + cposr = cposl + glyphinfo[gp + advx]; + cvisl = glyphinfo[gp + visx]; + cvist = glyphinfo[gp + visy]; + cvisr = cvisl + glyphinfo[gp + visw]; + cvisb = cvist + glyphinfo[gp + vish]; + // advance to next glyph gx += xdelta; gp += pdelta; - /* - while (gx != gxlimit && (glyphinfo[gp + advx] == 0 || - minIndex != nextMin || indices[gx] <= maxIndex)) { - */ while (gx != gxlimit && ((glyphinfo[gp + advx] == 0) || - (minIndex != nextMin) || (indices[gx] <= maxIndex) || (maxIndex - minIndex > clusterExtraGlyphs))) { - // initialize base data first time through, using base glyph - if (!haveCopy) { - int gps = gp - pdelta; - cposl = glyphinfo[gps + posx]; - cposr = cposl + glyphinfo[gps + advx]; - cvisl = glyphinfo[gps + visx]; - cvist = glyphinfo[gps + visy]; - cvisr = cvisl + glyphinfo[gps + visw]; - cvisb = cvist + glyphinfo[gps + vish]; - - haveCopy = true; + ++clusterExtraGlyphs; // have an extra glyph in this cluster + if (DEBUG) { + System.err.println("gp=" +gp +" adv=" + glyphinfo[gp + advx] + + " gx="+ gx+ " i[gx]="+indices[gx] + + " clusterExtraGlyphs="+clusterExtraGlyphs); } - // have an extra glyph in this cluster - ++clusterExtraGlyphs; - // adjust advance only if new glyph has non-zero advance float radvx = glyphinfo[gp + advx]; if (radvx != 0) { @@ -764,110 +751,90 @@ // done with cluster, gx and gp are set for next glyph if (DEBUG) { - System.out.println("minIndex = " + minIndex + ", maxIndex = " + maxIndex); + System.err.println("minIndex = " + minIndex + ", maxIndex = " + maxIndex); } - nextMin = maxIndex + 1; - - // do common character adjustments - glyphinfo[cp + posy] = baseline; - glyphinfo[cp + advy] = 0; + // save adjustments to the base character and do common adjustments. + charInfo[cp + posx] = cposl; + charInfo[cp + posy] = baseline; + charInfo[cp + advx] = cposr - cposl; + charInfo[cp + advy] = 0; + charInfo[cp + visx] = cvisl; + charInfo[cp + visy] = cvist; + charInfo[cp + visw] = cvisr - cvisl; + charInfo[cp + vish] = cvisb - cvist; + cc++; - if (haveCopy) { - // save adjustments to the base character - glyphinfo[cp + posx] = cposl; - glyphinfo[cp + advx] = cposr - cposl; - glyphinfo[cp + visx] = cvisl; - glyphinfo[cp + visy] = cvist; - glyphinfo[cp + visw] = cvisr - cvisl; - glyphinfo[cp + vish] = cvisb - cvist; + /* We may have consumed multiple glyphs for this char position. + * Map those extra consumed glyphs to char positions that would follow + * up to the index prior to that which begins the next cluster. + * If we have reached the last glyph (reached gxlimit) then we need to + * map remaining unmapped chars to the same location as the last one. + */ + int tgt; + if (gx == gxlimit) { + tgt = charInfo.length / numvals; + } else { + tgt = indices[gx]-1; + } + if (DEBUG) { + System.err.println("gx=" + gx + " gxlimit=" + gxlimit + + " charInfo.len=" + charInfo.length + + " tgt=" + tgt + " cc=" + cc + " cp=" + cp); + } + while (cc < tgt) { + if (rtl) { + // if rtl, characters to left of base, else to right. reuse cposr. + cposr = cposl; + } + cvisr -= cvisl; // reuse, convert to deltas. + cvisb -= cvist; - // compare number of chars read with number of glyphs read. - // if more glyphs than chars, set mustCopy to true, as we'll always have - // to copy the data from here on out. - if (maxIndex - minIndex < clusterExtraGlyphs) { - mustCopy = true; + cp += pdelta; + + if (cp < 0 || cp >= charInfo.length) { + if (DEBUG) { + System.err.println("Error : cp=" + cp + + " charInfo.length=" + charInfo.length); + } + break; } - // Fix the characters that follow the base character. - // New values are all the same. Note we fix the number of characters - // we saw, not the number of glyphs we saw. - if (minIndex < maxIndex) { - if (!ltr) { - // if rtl, characters to left of base, else to right. reuse cposr. - cposr = cposl; - } - cvisr -= cvisl; // reuse, convert to deltas. - cvisb -= cvist; - - int iMinIndex = minIndex, icp = cp / 8; - - while (minIndex < maxIndex) { - ++minIndex; - cx += xdelta; - cp += pdelta; - - if (cp < 0 || cp >= glyphinfo.length) { - if (DEBUG) System.out.println("minIndex = " + iMinIndex + ", maxIndex = " + maxIndex + ", cp = " + icp); - } - - glyphinfo[cp + posx] = cposr; - glyphinfo[cp + posy] = baseline; - glyphinfo[cp + advx] = 0; - glyphinfo[cp + advy] = 0; - glyphinfo[cp + visx] = cvisl; - glyphinfo[cp + visy] = cvist; - glyphinfo[cp + visw] = cvisr; - glyphinfo[cp + vish] = cvisb; - } + if (DEBUG) { + System.err.println("Insert charIndex " + cc + " at pos="+cp); } - - // no longer using this copy - haveCopy = false; - } else if (mustCopy) { - // out of synch, so we have to copy all the time now - int gpr = gp - pdelta; - - glyphinfo[cp + posx] = glyphinfo[gpr + posx]; - glyphinfo[cp + advx] = glyphinfo[gpr + advx]; - glyphinfo[cp + visx] = glyphinfo[gpr + visx]; - glyphinfo[cp + visy] = glyphinfo[gpr + visy]; - glyphinfo[cp + visw] = glyphinfo[gpr + visw]; - glyphinfo[cp + vish] = glyphinfo[gpr + vish]; + charInfo[cp + posx] = cposr; + charInfo[cp + posy] = baseline; + charInfo[cp + advx] = 0; + charInfo[cp + advy] = 0; + charInfo[cp + visx] = cvisl; + charInfo[cp + visy] = cvist; + charInfo[cp + visw] = cvisr; + charInfo[cp + vish] = cvisb; + cc++; } - // else glyphinfo is already at the correct character position, and is unchanged, so just leave it - - // reset for new cluster - cp += pdelta; - cx += xdelta; - } - - if (mustCopy && !ltr) { - // data written to wrong end of array, need to shift down - - cp -= pdelta; // undo last increment, get start of valid character data in array - System.arraycopy(glyphinfo, cp, glyphinfo, 0, glyphinfo.length - cp); + cp += pdelta; // reset for new cluster } if (DEBUG) { - char[] chars = source.getChars(); - int start = source.getStart(); - int length = source.getLength(); - System.out.println("char info for " + length + " characters"); - for(int i = 0; i < length * numvals;) { - System.out.println(" ch: " + Integer.toHexString(chars[start + v2l(i / numvals)]) + - " x: " + glyphinfo[i++] + - " y: " + glyphinfo[i++] + - " xa: " + glyphinfo[i++] + - " ya: " + glyphinfo[i++] + - " l: " + glyphinfo[i++] + - " t: " + glyphinfo[i++] + - " w: " + glyphinfo[i++] + - " h: " + glyphinfo[i++]); + char[] chars = source.getChars(); + int start = source.getStart(); + int length = source.getLength(); + System.err.println("char info for " + length + " characters"); + + for (int i = 0; i < length * numvals;) { + System.err.println(" ch: " + Integer.toHexString(chars[start + v2l(i / numvals)]) + + " x: " + charInfo[i++] + + " y: " + charInfo[i++] + + " xa: " + charInfo[i++] + + " ya: " + charInfo[i++] + + " l: " + charInfo[i++] + + " t: " + charInfo[i++] + + " w: " + charInfo[i++] + + " h: " + charInfo[i++]); } } - - return glyphinfo; + return charInfo; } /** diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/sun/print/DialogOwner.java --- a/jdk/src/java.desktop/share/classes/sun/print/DialogOwner.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/sun/print/DialogOwner.java Fri Sep 16 13:15:01 2016 -0700 @@ -25,9 +25,11 @@ package sun.print; +import java.awt.Dialog; import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttribute; import java.awt.Frame; +import java.awt.Window; /** * Class DialogOwner is a printing attribute class that identifies @@ -42,7 +44,7 @@ public final class DialogOwner implements PrintRequestAttribute { - private Frame dlgOwner; + private Window dlgOwner; /** * Construct a new dialog owner attribute with the given frame. @@ -53,11 +55,19 @@ dlgOwner = frame; } + /** + * Construct a new dialog owner attribute with the given dialog. + * + * @param dialog the dialog that owns the print dialog + */ + public DialogOwner(Dialog dialog) { + dlgOwner = dialog; + } /** * Returns the string table for class DialogOwner. */ - public Frame getOwner() { + public Window getOwner() { return dlgOwner; } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java --- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Fri Sep 16 13:15:01 2016 -0700 @@ -30,7 +30,6 @@ import java.awt.Color; import java.awt.Dialog; import java.awt.Frame; -import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; @@ -39,7 +38,6 @@ import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; -import java.awt.geom.Area; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -55,7 +53,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Locale; import sun.awt.image.ByteInterleavedRaster; @@ -74,7 +71,6 @@ import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.ResolutionSyntax; import javax.print.attribute.Size2DSyntax; -import javax.print.attribute.standard.Chromaticity; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DialogTypeSelection; @@ -96,11 +92,6 @@ import javax.print.attribute.standard.SheetCollate; import javax.print.attribute.standard.Sides; -import sun.print.PageableDoc; -import sun.print.ServiceDialog; -import sun.print.SunPrinterJobService; -import sun.print.SunPageSelection; - /** * A class which rasterizes a printer job. * @@ -836,9 +827,16 @@ Rectangle gcBounds = gc.getBounds(); int x = gcBounds.x+50; int y = gcBounds.y+50; - ServiceDialog pageDialog = new ServiceDialog(gc, x, y, service, - DocFlavor.SERVICE_FORMATTED.PAGEABLE, - attributes, (Frame)null); + ServiceDialog pageDialog; + if (w instanceof Frame) { + pageDialog = new ServiceDialog(gc, x, y, service, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + attributes,(Frame)w); + } else { + pageDialog = new ServiceDialog(gc, x, y, service, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + attributes, (Dialog)w); + } Rectangle dlgBounds = pageDialog.getBounds(); // if portion of dialog is not within the gc boundary @@ -944,6 +942,14 @@ Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); if (w != null) { grCfg = w.getGraphicsConfiguration(); + /* Add DialogOwner attribute to set the owner of this print dialog + * only if it is not set already + * (it might be set in java.awt.PrintJob.printDialog) + */ + if (attributes.get(DialogOwner.class) == null) { + attributes.add(w instanceof Frame ? new DialogOwner((Frame)w) : + new DialogOwner((Dialog)w)); + } } else { grCfg = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); @@ -1001,6 +1007,10 @@ // temporarily add an attribute pointing back to this job. PrinterJobWrapper jobWrapper = new PrinterJobWrapper(this); attributes.add(jobWrapper); + PageRanges pgRng = (PageRanges)attributes.get(PageRanges.class); + if (pgRng == null && mDocument.getNumberOfPages() > 1) { + attributes.add(new PageRanges(1, mDocument.getNumberOfPages())); + } try { newService = ServiceUI.printDialog(gc, x, y, @@ -1014,6 +1024,7 @@ attributes); } attributes.remove(PrinterJobWrapper.class); + attributes.remove(DialogOwner.class); if (newService == null) { return false; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java --- a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java Fri Sep 16 13:15:01 2016 -0700 @@ -107,13 +107,16 @@ ImageCache cache = getCache(key); Image image = cache.getImage(key, config, w, h, args); int attempts = 0; + VolatileImage volatileImage = (image instanceof VolatileImage) + ? (VolatileImage) image + : null; do { boolean draw = false; - if (image instanceof VolatileImage) { + if (volatileImage != null) { // See if we need to recreate the image - switch (((VolatileImage)image).validate(config)) { + switch (volatileImage.validate(config)) { case VolatileImage.IMAGE_INCOMPATIBLE: - ((VolatileImage)image).flush(); + volatileImage.flush(); image = null; break; case VolatileImage.IMAGE_RESTORED: @@ -126,11 +129,14 @@ image = createImage(c, w, h, config, args); cache.setImage(key, config, w, h, args, image); draw = true; + volatileImage = (image instanceof VolatileImage) + ? (VolatileImage) image + : null; } if (draw) { // Render to the Image Graphics2D g2 = (Graphics2D) image.getGraphics(); - if (w != baseWidth || h != baseHeight) { + if (volatileImage == null && (w != baseWidth || h != baseHeight)) { g2.scale((double) w / baseWidth, (double) h / baseHeight); } paintToImage(c, image, g2, baseWidth, baseHeight, args); @@ -140,8 +146,8 @@ // If we did this 3 times and the contents are still lost // assume we're painting to a VolatileImage that is bogus and // give up. Presumably we'll be called again to paint. - } while ((image instanceof VolatileImage) && - ((VolatileImage)image).contentsLost() && ++attempts < 3); + } while ((volatileImage != null) && + volatileImage.contentsLost() && ++attempts < 3); return image; } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c Fri Sep 16 13:15:01 2016 -0700 @@ -40,6 +40,7 @@ static jfieldID gvdGlyphsFID = 0; static jfieldID gvdPositionsFID = 0; static jfieldID gvdIndicesFID = 0; +static jmethodID gvdGrowMID = 0; static int jniInited = 0; static void getFloat(JNIEnv* env, jobject pt, jfloat *x, jfloat *y) { @@ -63,73 +64,88 @@ CHECK_NULL_RETURN(gvdGlyphsFID = (*env)->GetFieldID(env, gvdClass, "_glyphs", "[I"), 0); CHECK_NULL_RETURN(gvdPositionsFID = (*env)->GetFieldID(env, gvdClass, "_positions", "[F"), 0); CHECK_NULL_RETURN(gvdIndicesFID = (*env)->GetFieldID(env, gvdClass, "_indices", "[I"), 0); + CHECK_NULL_RETURN(gvdGrowMID = (*env)->GetMethodID(env, gvdClass, "grow", "()V"), 0); jniInited = 1; return jniInited; } // gmask is the composite font slot mask // baseindex is to be added to the character (code point) index. -int storeGVData(JNIEnv* env, - jobject gvdata, jint slot, jint baseIndex, jobject startPt, - int glyphCount, hb_glyph_info_t *glyphInfo, - hb_glyph_position_t *glyphPos, hb_direction_t direction, - float devScale) { +jboolean storeGVData(JNIEnv* env, + jobject gvdata, jint slot, + jint baseIndex, int offset, jobject startPt, + int charCount, int glyphCount, hb_glyph_info_t *glyphInfo, + hb_glyph_position_t *glyphPos, float devScale) { - int i; + int i, needToGrow; float x=0, y=0; - float startX, startY; - float scale = 1.0f/64.0f/devScale; + float startX, startY, advX, advY; + float scale = 1.0f / HBFloatToFixedScale / devScale; unsigned int* glyphs; float* positions; - int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv; + int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv, maxStore; unsigned int* indices; jarray glyphArray, posArray, inxArray; if (!init_JNI_IDs(env)) { - return 0; + return JNI_FALSE; } initialCount = (*env)->GetIntField(env, gvdata, gvdCountFID); - glyphArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdGlyphsFID); - posArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdPositionsFID); - - if (glyphArray == NULL || posArray == NULL) - { - JNU_ThrowArrayIndexOutOfBoundsException(env, ""); - return 0; - } - - // The Java code catches the IIOBE and expands the storage - // and re-invokes layout. I suppose this is expected to be rare - // because at least in a single threaded case there should be - // re-use of the same container, but it is a little wasteful/distateful. - glyphArrayLen = (*env)->GetArrayLength(env, glyphArray); - posArrayLen = (*env)->GetArrayLength(env, posArray); - maxGlyphs = glyphCount + initialCount; - if ((maxGlyphs > glyphArrayLen) || - (maxGlyphs * 2 + 2 > posArrayLen)) - { - JNU_ThrowArrayIndexOutOfBoundsException(env, ""); - return 0; - } + do { + glyphArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdGlyphsFID); + posArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdPositionsFID); + inxArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdIndicesFID); + if (glyphArray == NULL || posArray == NULL || inxArray == NULL) { + JNU_ThrowArrayIndexOutOfBoundsException(env, ""); + return JNI_FALSE; + } + glyphArrayLen = (*env)->GetArrayLength(env, glyphArray); + posArrayLen = (*env)->GetArrayLength(env, posArray); + maxGlyphs = (charCount > glyphCount) ? charCount : glyphCount; + maxStore = maxGlyphs + initialCount; + needToGrow = (maxStore > glyphArrayLen) || + (maxStore * 2 + 2 > posArrayLen); + if (needToGrow) { + (*env)->CallVoidMethod(env, gvdata, gvdGrowMID); + if ((*env)->ExceptionCheck(env)) { + return JNI_FALSE; + } + } + } while (needToGrow); getFloat(env, startPt, &startX, &startY); glyphs = (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, glyphArray, NULL); + if (glyphs == NULL) { + return JNI_FALSE; + } positions = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, posArray, NULL); + if (positions == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); + return JNI_FALSE; + } + indices = + (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, inxArray, NULL); + if (indices == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); + (*env)->ReleasePrimitiveArrayCritical(env, posArray, positions, 0); + return JNI_FALSE; + } + for (i = 0; i < glyphCount; i++) { int storei = i + initialCount; - int index = glyphInfo[i].codepoint | slot; - if (iReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); (*env)->ReleasePrimitiveArrayCritical(env, posArray, positions, 0); - putFloat(env, startPt,positions[(storeadv*2)],positions[(storeadv*2)+1] ); - inxArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdIndicesFID); - indices = - (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, inxArray, NULL); - for (i = 0; i < glyphCount; i++) { - int cluster = glyphInfo[i].cluster; - if (direction == HB_DIRECTION_LTR) { - // I need to understand what hb does when processing a substring - // I expected the cluster index to be from the start of the text - // to process. - // Instead it appears to be from the start of the whole thing. - indices[i+initialCount] = cluster; - } else { - indices[i+initialCount] = baseIndex + glyphCount -1 -i; - } - } (*env)->ReleasePrimitiveArrayCritical(env, inxArray, indices, 0); - (*env)->SetIntField(env, gvdata, gvdCountFID, initialCount+glyphCount); - return initialCount+glyphCount; + putFloat(env, startPt, advX, advY); + (*env)->SetIntField(env, gvdata, gvdCountFID, storeadv); + + return JNI_TRUE; } static float euclidianDistance(float a, float b) @@ -226,7 +229,9 @@ } -#define TYPO_RTL 0x80000000 +#define TYPO_KERN 0x00000001 +#define TYPO_LIGA 0x00000002 +#define TYPO_RTL 0x80000000 JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape (JNIEnv *env, jclass cls, @@ -255,10 +260,11 @@ hb_glyph_info_t *glyphInfo; hb_glyph_position_t *glyphPos; hb_direction_t direction = HB_DIRECTION_LTR; - hb_feature_t *features = NULL; + hb_feature_t *features = NULL; int featureCount = 0; - - int i; + char* kern = (flags & TYPO_KERN) ? "kern" : "-kern"; + char* liga = (flags & TYPO_LIGA) ? "liga" : "-liga"; + jboolean ret; unsigned int buflen; JDKFontInfo *jdkFontInfo = @@ -281,6 +287,8 @@ direction = HB_DIRECTION_RTL; } hb_buffer_set_direction(buffer, direction); + hb_buffer_set_cluster_level(buffer, + HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS); chars = (*env)->GetCharArrayElements(env, text, NULL); if ((*env)->ExceptionCheck(env)) { @@ -293,36 +301,26 @@ hb_buffer_add_utf16(buffer, chars, len, offset, limit-offset); + features = calloc(2, sizeof(hb_feature_t)); + if (features) { + hb_feature_from_string(kern, -1, &features[featureCount++]); + hb_feature_from_string(liga, -1, &features[featureCount++]); + } + hb_shape_full(hbfont, buffer, features, featureCount, 0); glyphCount = hb_buffer_get_length(buffer); glyphInfo = hb_buffer_get_glyph_infos(buffer, 0); glyphPos = hb_buffer_get_glyph_positions(buffer, &buflen); - for (i = 0; i < glyphCount; i++) { - int index = glyphInfo[i].codepoint; - int xadv = (glyphPos[i].x_advance); - int yadv = (glyphPos[i].y_advance); - } - // On "input" HB assigns a cluster index to each character in UTF-16. - // On output where a sequence of characters have been mapped to - // a glyph they are all mapped to the cluster index of the first character. - // The next cluster index will be that of the first character in the - // next cluster. So cluster indexes may 'skip' on output. - // This can also happen if there are supplementary code-points - // such that two UTF-16 characters are needed to make one codepoint. - // In RTL text you need to count down. - // So the following code tries to build the reverse map as expected - // by calling code. - storeGVData(env, gvdata, slot, baseIndex, startPt, - glyphCount, glyphInfo, glyphPos, direction, - jdkFontInfo->devScale); + ret = storeGVData(env, gvdata, slot, baseIndex, offset, startPt, + limit - offset, glyphCount, glyphInfo, glyphPos, + jdkFontInfo->devScale); hb_buffer_destroy (buffer); hb_font_destroy(hbfont); free((void*)jdkFontInfo); if (features != NULL) free(features); (*env)->ReleaseCharArrayElements(env, text, chars, JNI_ABORT); - - return JNI_TRUE; + return ret; } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc Fri Sep 16 13:15:01 2016 -0700 @@ -55,10 +55,6 @@ return (*glyph != 0); } -// This is also define in freetypescaler.c and similar macros are -// in fontscalerdefs.h. Consider tidying this up. -#define FloatToF26Dot6(x) ((unsigned int) ((x)*64)) - static hb_position_t hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, void *font_data, @@ -84,7 +80,7 @@ fadv *= jdkFontInfo->devScale; env->DeleteLocalRef(pt); - return FloatToF26Dot6(fadv); // should this round ? + return HBFloatToFixed(fadv); } static hb_position_t @@ -111,7 +107,7 @@ fadv = env->GetFloatField(pt, sunFontIDs.yFID); env->DeleteLocalRef(pt); - return FloatToF26Dot6(fadv); // should this round ? + return HBFloatToFixed(fadv); } @@ -205,8 +201,8 @@ *x = 0; *y = 0; return true; } - *x = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.xFID)); - *y = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.yFID)); + *x = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.xFID)); + *y = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.yFID)); env->DeleteLocalRef(pt); return true; @@ -325,8 +321,8 @@ _hb_jdk_get_font_funcs (), jdkFontInfo, (hb_destroy_func_t) _do_nothing); hb_font_set_scale (font, - FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale), - FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale)); + HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale), + HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale)); return font; } @@ -343,8 +339,8 @@ hb_face_destroy(face); hb_font_set_scale(font, - FloatToF26Dot6(jdkFontInfo->ptSize), - FloatToF26Dot6(jdkFontInfo->ptSize)); + HBFloatToFixed(jdkFontInfo->ptSize), + HBFloatToFixed(jdkFontInfo->ptSize)); return font; } #endif diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h Fri Sep 16 13:15:01 2016 -0700 @@ -48,6 +48,10 @@ } JDKFontInfo; +// Use 16.16 for better precision than 26.6 +#define HBFloatToFixedScale ((float)(1 << 16)) +#define HBFloatToFixed(f) ((unsigned int)((f) * HBFloatToFixedScale)) + /* * Note: * diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c --- a/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c Fri Sep 16 13:15:01 2016 -0700 @@ -2162,6 +2162,25 @@ } JNIEXPORT void JNICALL +Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_clearNativeReadAbortFlag + (JNIEnv *env, + jobject this, + jlong ptr) { + + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); + + if (data == NULL) { + JNU_ThrowByName(env, + "java/lang/IllegalStateException", + "Attempting to use reader after dispose()"); + return; + } + + data->abortFlag = JNI_FALSE; + +} + +JNIEXPORT void JNICALL Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead (JNIEnv *env, jobject this, diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Fri Sep 16 13:15:01 2016 -0700 @@ -1570,6 +1570,10 @@ Integer.valueOf(getMultiClickTime())); desktopProperties.put("awt.mouse.numButtons", Integer.valueOf(getNumberOfButtons())); + if(SunGraphicsEnvironment.isUIScaleEnabled()) { + addPropertyChangeListener("gnome.Xft/DPI", evt -> + localEnv.displayChanged()); + } } } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Fri Sep 16 13:15:01 2016 -0700 @@ -63,7 +63,7 @@ private SunDisplayChanger topLevels = new SunDisplayChanger(); private DisplayMode origDisplayMode; private boolean shutdownHookRegistered; - private final int scale; + private int scale; public X11GraphicsDevice(int screennum) { this.screen = screennum; @@ -488,6 +488,7 @@ * X11GraphicsEnvironment when the display mode has been changed. */ public synchronized void displayChanged() { + scale = initScaleFactor(); // On X11 the visuals do not change, and therefore we don't need // to reset the defaultConfig, config, doubleBufferVisuals, // neither do we need to reset the native data. diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c --- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c Fri Sep 16 13:15:01 2016 -0700 @@ -148,7 +148,7 @@ void *scale = fp_g_variant_get_child_value(entry, 1); if (screen && scale) { char *name = fp_g_variant_get_string(screen, NULL); - if (name && strcmp(name, output_name)) { + if (name && !strcmp(name, output_name)) { result = fp_g_variant_get_int32(scale) / 8.; } fp_g_variant_unref(screen); diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Fri Sep 16 13:15:01 2016 -0700 @@ -2181,7 +2181,8 @@ JNIEXPORT jdouble JNICALL Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor (JNIEnv *env, jobject this, jint screen) { - char *name = get_output_screen_name(env, screen); + // in case of Xinerama individual screen scales are not supported + char *name = get_output_screen_name(env, usingXinerama ? 0 : screen); double scale = getNativeScaleFactor(name); if (name) { free(name); diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ -303,10 +303,10 @@ if (bb instanceof DestSurfaceProvider) { Surface s = ((DestSurfaceProvider)bb).getDestSurface(); if (s instanceof AccelSurface) { - final int w = bb.getWidth(null); - final int h = bb.getHeight(null); final boolean arr[] = { false }; final AccelSurface as = (AccelSurface)s; + final int w = as.getBounds().width; + final int h = as.getBounds().height; RenderQueue rq = as.getContext().getRenderQueue(); rq.lock(); try { diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java Fri Sep 16 13:15:01 2016 -0700 @@ -478,9 +478,12 @@ } DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class); - Frame ownerFrame = (dlgOwner != null) ? dlgOwner.getOwner() : null; + Window owner = (dlgOwner != null) ? dlgOwner.getOwner() : null; - WPrintDialog dialog = new WPrintDialog(ownerFrame, this); + WPrintDialog dialog = (owner instanceof Frame) ? + new WPrintDialog((Frame)owner, this) : + new WPrintDialog((Dialog)owner, this); + dialog.setRetVal(false); dialog.setVisible(true); boolean prv = dialog.getRetVal(); @@ -498,8 +501,9 @@ title = rb.getString("dialog.printtofile"); } catch (MissingResourceException e) { } - FileDialog fileDialog = new FileDialog(ownerFrame, title, - FileDialog.SAVE); + FileDialog fileDialog = (owner instanceof Frame) ? + new FileDialog((Frame)owner, title, FileDialog.SAVE) : + new FileDialog((Dialog)owner, title, FileDialog.SAVE); URI destURI = dest.getURI(); // Old code destURI.getPath() would return null for "file:out.prn" @@ -531,10 +535,17 @@ ((pFile != null) && (!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) { - (new PrintToFileErrorDialog(ownerFrame, + if (owner instanceof Frame) { + (new PrintToFileErrorDialog((Frame)owner, ServiceDialog.getMsg("dialog.owtitle"), ServiceDialog.getMsg("dialog.writeerror")+" "+fullName, ServiceDialog.getMsg("button.ok"))).setVisible(true); + } else { + (new PrintToFileErrorDialog((Dialog)owner, + ServiceDialog.getMsg("dialog.owtitle"), + ServiceDialog.getMsg("dialog.writeerror")+" "+fullName, + ServiceDialog.getMsg("button.ok"))).setVisible(true); + } fileDialog.setVisible(true); fileName = fileDialog.getFile(); diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp --- a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Fri Sep 16 13:15:01 2016 -0700 @@ -753,10 +753,15 @@ } void rescale(SIZE *size) { - HWND hWnd = ::GetDesktopWindow(); - HDC hDC = ::GetDC(hWnd); - int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); - int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + static int dpiX = -1; + static int dpiY = -1; + if (dpiX == -1 || dpiY == -1) { + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); + dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + ::ReleaseDC(hWnd, hDC); + } if (dpiX !=0 && dpiX != 96) { float invScaleX = 96.0f / dpiX; @@ -766,7 +771,6 @@ float invScaleY = 96.0f / dpiY; size->cy = ROUND_TO_INT(size->cy * invScaleY); } - ::ReleaseDC(hWnd, hDC); } /* diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp Fri Sep 16 13:15:01 2016 -0700 @@ -88,11 +88,16 @@ } void getInvScale(float &invScaleX, float &invScaleY) { - HWND hWnd = ::GetDesktopWindow(); - HDC hDC = ::GetDC(hWnd); - int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); - int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); - ::ReleaseDC(hWnd, hDC); + static int dpiX = -1; + static int dpiY = -1; + if (dpiX == -1 || dpiY == -1) { + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); + dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + ::ReleaseDC(hWnd, hDC); + } + invScaleX = (dpiX == 0.0f) ? 1.0f : 96.0f / dpiX; invScaleY = (dpiY == 0.0f) ? 1.0f : 96.0f / dpiY; } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp Fri Sep 16 13:15:01 2016 -0700 @@ -108,7 +108,7 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_flashWindow (JNIEnv *, jobject, jlong window) { - AwtWindow::FlashWindowEx((HWND) window, 3, 0, FLASHW_TIMERNOFG); + ::FlashWindow((HWND) window, TRUE); } /* diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.logging/share/classes/java/util/logging/Level.java --- a/jdk/src/java.logging/share/classes/java/util/logging/Level.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.logging/share/classes/java/util/logging/Level.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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,13 +24,22 @@ */ package java.util.logging; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; import java.lang.reflect.Module; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.ResourceBundle; +import java.util.function.Function; +import jdk.internal.loader.ClassLoaderValue; /** * The Level class defines a set of standard logging levels that @@ -177,6 +186,10 @@ */ public static final Level ALL = new Level("ALL", Integer.MIN_VALUE, defaultBundle); + private static final Level[] standardLevels = { + OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL + }; + /** * Create a named Level with a given integer value. *

@@ -267,7 +280,8 @@ // or its defining class loader, if it's unnamed module, // of this Level instance that can be a custom Level subclass; Module module = this.getClass().getModule(); - ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale, module); + ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, + newLocale, module); final String localizedName = rb.getString(name); final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName); @@ -350,12 +364,12 @@ throw new NullPointerException(); } - KnownLevel level; + Optional level; // Look for a known Level with the given non-localized name. - level = KnownLevel.findByName(name); - if (level != null) { - return level.mirroredLevel; + level = KnownLevel.findByName(name, KnownLevel::mirrored); + if (level.isPresent()) { + return level.get(); } // Now, check if the given name is an integer. If so, @@ -363,21 +377,24 @@ // if necessary create one. try { int x = Integer.parseInt(name); - level = KnownLevel.findByValue(x); - if (level == null) { + level = KnownLevel.findByValue(x, KnownLevel::mirrored); + if (!level.isPresent()) { // add new Level Level levelObject = new Level(name, x); - level = KnownLevel.findByValue(x); + // There's no need to use a reachability fence here because + // KnownLevel keeps a strong reference on the level when + // level.getClass() == Level.class. + return KnownLevel.findByValue(x, KnownLevel::mirrored).get(); } - return level.mirroredLevel; } catch (NumberFormatException ex) { // Not an integer. // Drop through. } - level = KnownLevel.findByLocalizedLevelName(name); - if (level != null) { - return level.mirroredLevel; + level = KnownLevel.findByLocalizedLevelName(name, + KnownLevel::mirrored); + if (level.isPresent()) { + return level.get(); } return null; @@ -408,15 +425,13 @@ // Serialization magic to prevent "doppelgangers". // This is a performance optimization. private Object readResolve() { - KnownLevel o = KnownLevel.matches(this); - if (o != null) { - return o.levelObject; + Optional level = KnownLevel.matches(this); + if (level.isPresent()) { + return level.get(); } - // Woops. Whoever sent us this object knows // about a new log level. Add it to our list. - Level level = new Level(this.name, this.value, this.resourceBundleName); - return level; + return new Level(this.name, this.value, this.resourceBundleName); } /** @@ -450,12 +465,12 @@ // Check that name is not null. name.length(); - KnownLevel level; + Optional level; // Look for a known Level with the given non-localized name. - level = KnownLevel.findByName(name); - if (level != null) { - return level.levelObject; + level = KnownLevel.findByName(name, KnownLevel::referent); + if (level.isPresent()) { + return level.get(); } // Now, check if the given name is an integer. If so, @@ -463,13 +478,16 @@ // if necessary create one. try { int x = Integer.parseInt(name); - level = KnownLevel.findByValue(x); - if (level == null) { - // add new Level - Level levelObject = new Level(name, x); - level = KnownLevel.findByValue(x); + level = KnownLevel.findByValue(x, KnownLevel::referent); + if (level.isPresent()) { + return level.get(); } - return level.levelObject; + // add new Level. + Level levelObject = new Level(name, x); + // There's no need to use a reachability fence here because + // KnownLevel keeps a strong reference on the level when + // level.getClass() == Level.class. + return KnownLevel.findByValue(x, KnownLevel::referent).get(); } catch (NumberFormatException ex) { // Not an integer. // Drop through. @@ -478,9 +496,9 @@ // Finally, look for a known level with the given localized name, // in the current default locale. // This is relatively expensive, but not excessively so. - level = KnownLevel.findByLocalizedLevelName(name); - if (level != null) { - return level.levelObject; + level = KnownLevel.findByLocalizedLevelName(name, KnownLevel::referent); + if (level .isPresent()) { + return level.get(); } // OK, we've tried everything and failed @@ -530,22 +548,67 @@ // If Level.getName, Level.getLocalizedName, Level.getResourceBundleName methods // were final, the following KnownLevel implementation can be removed. // Future API change should take this into consideration. - static final class KnownLevel { + static final class KnownLevel extends WeakReference { private static Map> nameToLevels = new HashMap<>(); private static Map> intToLevels = new HashMap<>(); - final Level levelObject; // instance of Level class or Level subclass + private static final ReferenceQueue QUEUE = new ReferenceQueue<>(); + + // CUSTOM_LEVEL_CLV is used to register custom level instances with + // their defining class loader, so that they are garbage collected + // if and only if their class loader is no longer strongly + // referenced. + private static final ClassLoaderValue> CUSTOM_LEVEL_CLV = + new ClassLoaderValue<>(); + final Level mirroredLevel; // mirror of the custom Level KnownLevel(Level l) { - this.levelObject = l; + super(l, QUEUE); if (l.getClass() == Level.class) { this.mirroredLevel = l; } else { // this mirrored level object is hidden - this.mirroredLevel = new Level(l.name, l.value, l.resourceBundleName, false); + this.mirroredLevel = new Level(l.name, l.value, + l.resourceBundleName, false); } } + Optional mirrored() { + return Optional.of(mirroredLevel); + } + + Optional referent() { + return Optional.ofNullable(get()); + } + + private void remove() { + Optional.ofNullable(nameToLevels.get(mirroredLevel.name)) + .ifPresent((x) -> x.remove(this)); + Optional.ofNullable(intToLevels.get(mirroredLevel.value)) + .ifPresent((x) -> x.remove(this)); + } + + // Remove all stale KnownLevel instances + static synchronized void purge() { + Reference ref; + while ((ref = QUEUE.poll()) != null) { + if (ref instanceof KnownLevel) { + ((KnownLevel)ref).remove(); + } + } + } + + private static void registerWithClassLoader(Level customLevel) { + PrivilegedAction pa = + () -> customLevel.getClass().getClassLoader(); + PrivilegedAction pn = customLevel.getClass()::getName; + final String name = AccessController.doPrivileged(pn); + final ClassLoader cl = AccessController.doPrivileged(pa); + CUSTOM_LEVEL_CLV.computeIfAbsent(cl, (c, v) -> new ArrayList<>()) + .add(customLevel); + } + static synchronized void add(Level l) { + purge(); // the mirroredLevel object is always added to the list // before the custom Level instance KnownLevel o = new KnownLevel(l); @@ -562,24 +625,36 @@ intToLevels.put(l.value, list); } list.add(o); + + // keep the custom level reachable from its class loader + // This will ensure that custom level values are not GC'ed + // until there class loader is GC'ed. + if (o.mirroredLevel != l) { + registerWithClassLoader(l); + } + } // Returns a KnownLevel with the given non-localized name. - static synchronized KnownLevel findByName(String name) { - List list = nameToLevels.get(name); - if (list != null) { - return list.get(0); - } - return null; + static synchronized Optional findByName(String name, + Function> selector) { + purge(); + return nameToLevels.getOrDefault(name, Collections.emptyList()) + .stream() + .map(selector) + .flatMap(Optional::stream) + .findFirst(); } // Returns a KnownLevel with the given value. - static synchronized KnownLevel findByValue(int value) { - List list = intToLevels.get(value); - if (list != null) { - return list.get(0); - } - return null; + static synchronized Optional findByValue(int value, + Function> selector) { + purge(); + return intToLevels.getOrDefault(value, Collections.emptyList()) + .stream() + .map(selector) + .flatMap(Optional::stream) + .findFirst(); } // Returns a KnownLevel with the given localized name matching @@ -587,32 +662,34 @@ // from the resourceBundle associated with the Level object). // This method does not call Level.getLocalizedName() that may // be overridden in a subclass implementation - static synchronized KnownLevel findByLocalizedLevelName(String name) { - for (List levels : nameToLevels.values()) { - for (KnownLevel l : levels) { - String lname = l.levelObject.getLocalizedLevelName(); - if (name.equals(lname)) { - return l; - } - } - } - return null; + static synchronized Optional findByLocalizedLevelName(String name, + Function> selector) { + purge(); + return nameToLevels.values().stream() + .flatMap(List::stream) + .map(selector) + .flatMap(Optional::stream) + .filter(l -> name.equals(l.getLocalizedLevelName())) + .findFirst(); } - static synchronized KnownLevel matches(Level l) { + static synchronized Optional matches(Level l) { + purge(); List list = nameToLevels.get(l.name); if (list != null) { - for (KnownLevel level : list) { - Level other = level.mirroredLevel; + for (KnownLevel ref : list) { + Level levelObject = ref.get(); + if (levelObject == null) continue; + Level other = ref.mirroredLevel; if (l.value == other.value && (l.resourceBundleName == other.resourceBundleName || (l.resourceBundleName != null && l.resourceBundleName.equals(other.resourceBundleName)))) { - return level; + return Optional.of(levelObject); } } } - return null; + return Optional.empty(); } } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java --- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -1707,25 +1707,6 @@ throw new UnsupportedOperationException("Not supported yet."); } - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, - OperationsException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, - ReflectionException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(String className, ObjectName loaderName, - byte[] data) throws InstanceNotFoundException, OperationsException, - ReflectionException { - throw new UnsupportedOperationException("Not supported yet."); - } - public ClassLoaderRepository getClassLoaderRepository() { throw new UnsupportedOperationException("Not supported yet."); } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java --- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -98,32 +98,6 @@ * This method should never be called. * Usually throws UnsupportedOperationException. */ - @Deprecated - public ObjectInputStream deserialize(ObjectName name, byte[] data) - throws InstanceNotFoundException, OperationsException; - - /** - * This method should never be called. - * Usually throws UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(String className, byte[] data) - throws OperationsException, ReflectionException; - - /** - * This method should never be called. - * Usually hrows UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(String className, - ObjectName loaderName, byte[] data) - throws InstanceNotFoundException, OperationsException, - ReflectionException; - - /** - * This method should never be called. - * Usually throws UnsupportedOperationException. - */ public ClassLoaderRepository getClassLoaderRepository(); } diff -r 07736e140bce -r 6268665d2fd7 jdk/src/java.management/share/classes/javax/management/MBeanServer.java --- a/jdk/src/java.management/share/classes/javax/management/MBeanServer.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/java.management/share/classes/javax/management/MBeanServer.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -655,6 +655,8 @@ * used for the de-serialization. * @param data The byte array to be de-sererialized. * + * @implSpec This method throws {@link UnsupportedOperationException} by default. + * * @return The de-serialized object stream. * * @exception InstanceNotFoundException The MBean specified is not @@ -665,10 +667,11 @@ * @deprecated Use {@link #getClassLoaderFor getClassLoaderFor} to * obtain the appropriate class loader for deserialization. */ - @Deprecated - public ObjectInputStream deserialize(ObjectName name, byte[] data) - throws InstanceNotFoundException, OperationsException; - + @Deprecated(since="1.5") + default public ObjectInputStream deserialize(ObjectName name, byte[] data) + throws InstanceNotFoundException, OperationsException { + throw new UnsupportedOperationException("Not supported."); + } /** *

De-serializes a byte array in the context of a given MBean @@ -682,6 +685,8 @@ * used for the de-serialization. * @param data The byte array to be de-sererialized. * + * @implSpec This method throws {@link UnsupportedOperationException} by default. + * * @return The de-serialized object stream. * * @exception OperationsException Any of the usual Input/Output @@ -692,9 +697,11 @@ * @deprecated Use {@link #getClassLoaderRepository} to obtain the * class loader repository and use it to deserialize. */ - @Deprecated - public ObjectInputStream deserialize(String className, byte[] data) - throws OperationsException, ReflectionException; + @Deprecated(since="1.5") + default public ObjectInputStream deserialize(String className, byte[] data) + throws OperationsException, ReflectionException { + throw new UnsupportedOperationException("Not supported."); + } /** @@ -711,6 +718,8 @@ * loading the specified class. If null, the MBean Server's class * loader will be used. * + * @implSpec This method throws {@link UnsupportedOperationException} by default. + * * @return The de-serialized object stream. * * @exception InstanceNotFoundException The specified class loader @@ -723,12 +732,14 @@ * @deprecated Use {@link #getClassLoader getClassLoader} to obtain * the class loader for deserialization. */ - @Deprecated - public ObjectInputStream deserialize(String className, + @Deprecated(since="1.5") + default public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, - ReflectionException; + ReflectionException { + throw new UnsupportedOperationException("Not supported."); + } /** *

Return the {@link java.lang.ClassLoader} that was used for diff -r 07736e140bce -r 6268665d2fd7 jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java --- a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java Fri Sep 16 13:15:01 2016 -0700 @@ -308,10 +308,6 @@ //-- native methods - static native boolean isLinuxThreads(); - - static native int getLinuxThreadsManager(int pid) throws IOException; - static native void sendQuitToChildrenOf(int pid) throws IOException; static native void sendQuitTo(int pid) throws IOException; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c --- a/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c Fri Sep 16 13:15:01 2016 -0700 @@ -195,113 +195,6 @@ } /* - * Class: sun_tools_attach_VirtualMachineImpl - * Method: isLinuxThreads - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads - (JNIEnv *env, jclass cls) -{ -# ifndef _CS_GNU_LIBPTHREAD_VERSION -# define _CS_GNU_LIBPTHREAD_VERSION 3 -# endif - size_t n; - char* s; - jboolean res; - - n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0); - if (n <= 0) { - /* glibc before 2.3.2 only has LinuxThreads */ - return JNI_TRUE; - } - - s = (char *)malloc(n); - if (s == NULL) { - JNU_ThrowOutOfMemoryError(env, "malloc failed"); - return JNI_TRUE; - } - confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n); - - /* - * If the LIBPTHREAD version include "NPTL" then we know we - * have the new threads library and not LinuxThreads - */ - res = (jboolean)(strstr(s, "NPTL") == NULL); - free(s); - return res; -} - -/* - * Structure and callback function used to count the children of - * a given process, and record the pid of the "manager thread". - */ -typedef struct { - pid_t ppid; - int count; - pid_t mpid; -} ChildCountContext; - -static void ChildCountCallback(const pid_t pid, void* user_data) { - ChildCountContext* context = (ChildCountContext*)user_data; - if (getParent(pid) == context->ppid) { - context->count++; - /* - * Remember the pid of the first child. If the final count is - * one then this is the pid of the LinuxThreads manager. - */ - if (context->count == 1) { - context->mpid = pid; - } - } -} - -/* - * Class: sun_tools_attach_VirtualMachineImpl - * Method: getLinuxThreadsManager - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager - (JNIEnv *env, jclass cls, jint pid) -{ - ChildCountContext context; - - /* - * Iterate over all processes to find how many children 'pid' has - */ - context.ppid = pid; - context.count = 0; - context.mpid = (pid_t)0; - forEachProcess(ChildCountCallback, (void*)&context); - - /* - * If there's no children then this is likely the pid of the primordial - * created by the launcher - in that case the LinuxThreads manager is the - * parent of this process. - */ - if (context.count == 0) { - pid_t parent = getParent(pid); - if ((int)parent > 0) { - return (jint)parent; - } - } - - /* - * There's one child so this is likely the embedded VM case where the - * the primordial thread == LinuxThreads initial thread. The LinuxThreads - * manager in that case is the child. - */ - if (context.count == 1) { - return (jint)context.mpid; - } - - /* - * If we get here it's most likely we were given the wrong pid - */ - JNU_ThrowIOException(env, "Unable to get pid of LinuxThreads manager thread"); - return -1; -} - -/* * Structure and callback function used to send a QUIT signal to all * children of a given process */ diff -r 07736e140bce -r 6268665d2fd7 jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java Fri Sep 16 13:15:01 2016 -0700 @@ -993,32 +993,39 @@ return minorVersion; } - private void getConstantPoolInfo() { + private byte[] getConstantPoolInfo() { JDWP.ReferenceType.ConstantPool jdwpCPool; if (!vm.canGetConstantPool()) { throw new UnsupportedOperationException(); } if (constantPoolInfoGotten) { - return; - } else { - try { - jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this); - } catch (JDWPException exc) { - if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) { - constanPoolCount = 0; - constantPoolBytesRef = null; - constantPoolInfoGotten = true; - return; - } else { - throw exc.toJDIException(); - } + if (constantPoolBytesRef == null) { + return null; + } + byte[] cpbytes = constantPoolBytesRef.get(); + if (cpbytes != null) { + return cpbytes; } - byte[] cpbytes; - constanPoolCount = jdwpCPool.count; - cpbytes = jdwpCPool.bytes; - constantPoolBytesRef = new SoftReference(cpbytes); - constantPoolInfoGotten = true; } + + try { + jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this); + } catch (JDWPException exc) { + if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) { + constanPoolCount = 0; + constantPoolBytesRef = null; + constantPoolInfoGotten = true; + return null; + } else { + throw exc.toJDIException(); + } + } + byte[] cpbytes; + constanPoolCount = jdwpCPool.count; + cpbytes = jdwpCPool.bytes; + constantPoolBytesRef = new SoftReference(cpbytes); + constantPoolInfoGotten = true; + return cpbytes; } public int constantPoolCount() { @@ -1031,13 +1038,13 @@ } public byte[] constantPool() { + byte[] cpbytes; try { - getConstantPoolInfo(); + cpbytes = getConstantPoolInfo(); } catch (RuntimeException exc) { throw exc; } - if (constantPoolBytesRef != null) { - byte[] cpbytes = constantPoolBytesRef.get(); + if (cpbytes != null) { /* * Arrays are always modifiable, so it is a little unsafe * to return the cached bytecodes directly; instead, we diff -r 07736e140bce -r 6268665d2fd7 jdk/src/jdk.jdi/share/classes/module-info.java --- a/jdk/src/jdk.jdi/share/classes/module-info.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/jdk.jdi/share/classes/module-info.java Fri Sep 16 13:15:01 2016 -0700 @@ -25,6 +25,7 @@ module jdk.jdi { requires jdk.attach; + requires jdk.jdwp.agent; exports com.sun.jdi; exports com.sun.jdi.connect; diff -r 07736e140bce -r 6268665d2fd7 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java Fri Sep 16 13:15:01 2016 -0700 @@ -55,6 +55,7 @@ import java.util.Optional; import java.util.Properties; import java.util.Set; +import java.util.stream.Collectors; import jdk.tools.jlink.internal.BasicImageWriter; import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile; import jdk.tools.jlink.internal.ExecutableImage; @@ -159,7 +160,7 @@ } i++; } - props.setProperty("MODULES", builder.toString()); + props.setProperty("MODULES", quote(builder.toString())); } @Override @@ -188,7 +189,8 @@ storeFiles(modules, release); - if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) { + if (root.getFileSystem().supportedFileAttributeViews() + .contains("posix")) { // launchers in the bin directory need execute permission. // On Windows, "bin" also subdirectories containing jvm.dll. if (Files.isDirectory(bin)) { @@ -217,19 +219,38 @@ } } + // Parse version string and return a string that includes only version part + // leaving "pre", "build" information. See also: java.lang.Runtime.Version. + private static String parseVersion(String str) { + return Runtime.Version.parse(str). + version(). + stream(). + map(Object::toString). + collect(Collectors.joining(".")); + } + + private static String quote(String str) { + return "\"" + str + "\""; + } + private Properties releaseProperties(ResourcePool pool) throws IOException { Properties props = new Properties(); Optional javaBase = pool.moduleView().findModule("java.base"); javaBase.ifPresent(mod -> { // fill release information available from transformed "java.base" module! ModuleDescriptor desc = mod.descriptor(); - desc.osName().ifPresent(s -> props.setProperty("OS_NAME", s)); - desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", s)); - desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", s)); - props.setProperty("JAVA_VERSION", System.getProperty("java.version")); + desc.osName().ifPresent(s -> { + props.setProperty("OS_NAME", quote(s)); + this.targetOsName = s; + }); + desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", quote(s))); + desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", quote(s))); + desc.version().ifPresent(s -> props.setProperty("JAVA_VERSION", + quote(parseVersion(s.toString())))); + desc.version().ifPresent(s -> props.setProperty("JAVA_FULL_VERSION", + quote(s.toString()))); }); - this.targetOsName = props.getProperty("OS_NAME"); if (this.targetOsName == null) { throw new PluginException("TargetPlatform attribute is missing for java.base module"); } @@ -282,8 +303,8 @@ StandardOpenOption.CREATE_NEW)) { writer.write(sb.toString()); } - if (Files.getFileStore(root.resolve("bin")) - .supportsFileAttributeView(PosixFileAttributeView.class)) { + if (root.resolve("bin").getFileSystem() + .supportedFileAttributeViews().contains("posix")) { setExecutable(cmd); } // generate .bat file for Windows diff -r 07736e140bce -r 6268665d2fd7 jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties Fri Sep 16 13:15:01 2016 -0700 @@ -35,4 +35,5 @@ # This notice and attribution to Taligent may not be removed. # Taligent is a registered trademark of Taligent, Inc. +BYN=\u0420\u0443\u0431 BYR=\u0420\u0443\u0431 diff -r 07736e140bce -r 6268665d2fd7 jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties --- a/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties Fri Sep 16 13:15:01 2016 -0700 @@ -265,8 +265,6 @@ No constructor matching {0} found in {1}. javac.err.wrong.number.args=\ Wrong number of arguments in {0}. -javac.err.wrong.number.args=\ - Wrong number of arguments in {0}. javac.err.forward.ref=\ Can''t make forward reference to {0} in {1}. javac.err.array.dim.missing=\ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/ProblemList.txt --- a/jdk/test/ProblemList.txt Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/ProblemList.txt Fri Sep 16 13:15:01 2016 -0700 @@ -159,7 +159,6 @@ # jdk_net - java/net/MulticastSocket/NoLoopbackPackets.java 7122846 macosx-all java/net/MulticastSocket/SetLoopbackMode.java 7122846 macosx-all @@ -217,66 +216,6 @@ sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all -sun/security/pkcs11/Cipher/ReinitCipher.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestRSACipher.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestRSACipherWrap.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestRawRSACipher.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestSymmCiphers.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/TestDH.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/TestInterop.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/TestShort.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java 8077138 windows-all -sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java 8077138 windows-all -sun/security/pkcs11/KeyGenerator/DESParity.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 8077138,8023434 windows-all -sun/security/pkcs11/Mac/MacKAT.java 8077138,8023434 windows-all -sun/security/pkcs11/Mac/MacSameTest.java 8077138,8023434 windows-all -sun/security/pkcs11/Mac/ReinitMac.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/ByteBuffers.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/DigestKAT.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/ReinitDigest.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/TestCloning.java 8077138,8023434 windows-all -sun/security/pkcs11/Provider/ConfigQuotedString.sh 8077138,8023434 windows-all -sun/security/pkcs11/Provider/Login.sh 8077138,8023434 windows-all -sun/security/pkcs11/SampleTest.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/AddPrivateKey.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/AddTrustedCert.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/Crypto.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/GetPrivateKey.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/JksSetPrivateKey.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/LoadKeystore.java 8077138,8023434 windows-all -sun/security/pkcs11/SecureRandom/Basic.java 8077138,8023434 windows-all -sun/security/pkcs11/SecureRandom/TestDeserialization.java 8077138,8023434 windows-all -sun/security/pkcs11/Serialize/SerializeProvider.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/ByteBuffers.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/ReinitSignature.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/TestDSA.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/TestDSAKeyLength.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/TestRSAKeyLength.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/ReadCertificates.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/ReadPKCS12.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestCurves.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDH.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDH2.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDSA.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDSA2.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECGenSpec.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/KeyWrap.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestCACerts.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestKeyFactory.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestSignatures.java 8077138,8023434 windows-all -sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestKeyMaterial.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestLeadingZeroesP11.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestPRF.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434 windows-all - sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java 8161232 macosx-all @@ -312,8 +251,6 @@ tools/launcher/FXLauncherTest.java 8068049 linux-all,macosx-all -tools/pack200/Pack200Props.java 8155857 generic-all - ############################################################################ # jdk_jdi @@ -328,9 +265,6 @@ com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-all -com/sun/jdi/ClassesByName2Test.java 8160833 generic-all -com/sun/jdi/RedefineCrossEvent.java 8160833 generic-all - ############################################################################ # jdk_time @@ -357,9 +291,11 @@ sun/tools/jhsdb/BasicLauncherTest.java 8160376 macosx-all +sun/tools/jhsdb/HeapDumpTest.java 8160376 macosx-all + sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8160376 macosx-all -sun/tools/jps/TestJpsJar.java 8160923 generic-all +sun/tools/jps/TestJpsJar.java 8165500 generic-all sun/tools/jps/TestJpsJarRelative.java 6456333 generic-all diff -r 07736e140bce -r 6268665d2fd7 jdk/test/com/sun/jdi/ConstantPoolInfoGC.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/com/sun/jdi/ConstantPoolInfoGC.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 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 6822627 + * @summary Test that ReferenceType.constantPool does not produce an NPE + * + * @author Egor Ushakov + * + * @modules jdk.jdi/com.sun.tools.jdi + * @run build TestScaffold VMConnection + * @run compile -g ConstantPoolInfoGC.java + * @run main/othervm ConstantPoolInfoGC + */ + +import com.sun.jdi.ReferenceType; +import com.sun.tools.jdi.ReferenceTypeImpl; + +import java.lang.ref.Reference; +import java.lang.reflect.Field; +import java.util.Arrays; + + /********** target program **********/ + +class ConstantPoolGCTarg { + public static void main(String[] args){ + System.out.println("Anything"); + } +} + + /********** test program **********/ + +public class ConstantPoolInfoGC extends TestScaffold { + ReferenceType targetClass; + + ConstantPoolInfoGC(String args[]) { + super(args); + } + + public static void main(String[] args) throws Exception { + new ConstantPoolInfoGC(args).startTests(); + } + + /********** test core **********/ + + protected void runTests() throws Exception { + targetClass = startToMain("ConstantPoolGCTarg").location().declaringType(); + + if (vm().canGetConstantPool()) { + byte[] cpbytes = targetClass.constantPool(); + + // imitate SoftReference cleared + Field constantPoolBytesRef = ReferenceTypeImpl.class.getDeclaredField("constantPoolBytesRef"); + constantPoolBytesRef.setAccessible(true); + Reference softRef = (Reference) constantPoolBytesRef.get(targetClass); + softRef.clear(); + + byte[] cpbytes2 = targetClass.constantPool(); + if (!Arrays.equals(cpbytes, cpbytes2)) { + failure("Consequent constantPool results vary, first was : " + cpbytes + ", now: " + cpbytes2); + }; + + } else { + System.out.println("can get constant pool version not supported"); + } + + + /* + * resume until end + */ + listenUntilVMDisconnect(); + + /* + * deal with results of test + * if anything has called failure("foo") testFailed will be true + */ + if (!testFailed) { + println("ConstantPoolInfoGC: passed"); + } else { + throw new Exception("ConstantPoolInfoGC: failed"); + } + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016, 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. + */ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +/* + @test + @bug 8160570 + @summary Tests that a modal dialog receives WINDOW_ACTIVATED & WINDOW_GAINED_FOCUS on first show. +*/ +public class ModalDialogActivationTest { + static final Object lock = new Object(); + static volatile boolean activated; + static volatile boolean focused; + + public static void main(String[] args) throws InterruptedException { + EventQueue.invokeLater(() -> runGUI()); + + long time = System.currentTimeMillis(); + synchronized (lock) { + while (!activated || !focused) { + lock.wait(5000); + if (System.currentTimeMillis() - time >= 5000) break; + } + } + if (!activated || !focused) { + throw new RuntimeException("Test FAILED: activated: " + activated + ", focused: " + focused); + } + System.out.println("Test PASSED"); + } + + static void runGUI() { + JFrame f = new JFrame("frame"); + final JDialog d = new MyModalDialog(f, "dialog"); + d.addWindowListener(new WindowAdapter() { + @Override + public void windowActivated(WindowEvent e) { + synchronized (lock) { + activated = true; + lock.notifyAll(); + } + } + }); + d.addWindowFocusListener(new WindowAdapter() { + @Override + public void windowGainedFocus(WindowEvent e) { + synchronized (lock) { + focused = true; + lock.notifyAll(); + } + } + }); + f.setVisible(true); + d.setVisible(true); + } + + static class MyModalDialog extends JDialog { + public MyModalDialog(Frame owner, String title)ª { + super(owner, title, true); + } + + @Override + public boolean getFocusableWindowState() { + try { + // let Toolkit thread go ahead + Thread.sleep(100); + } catch (InterruptedException ignore) { + } + return super.getFocusableWindowState(); + } + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java --- a/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 8048887 + @bug 8048887 8164937 @summary Tests SortingFTP for an exception caused by the tim-sort algo. @author anton.tarasov: area=awt.focus @run main JDK8048887 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2016, 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 + * @key headful + * @bug 8050478 + * @summary Cursor not updating correctly after closing a modal dialog. + * The root cause of the issue was the lack of a mouse exit event + * during displaying of a modal dialog. + * @author Dmitry Markov + * @library ../../regtesthelpers + * @build Util + * @run main ModalDialogEnterExitEventsTest + */ + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.concurrent.atomic.AtomicInteger; + +import test.java.awt.regtesthelpers.Util; + +public class ModalDialogEnterExitEventsTest { + private static volatile AtomicInteger mouseEnterCount = new AtomicInteger(); + private static volatile AtomicInteger mouseExitCount = new AtomicInteger(); + + private static JFrame frame; + private static JButton openButton; + private static JButton closeButton; + + public static void main(String[] args) { + Robot robot = Util.createRobot(); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + Util.waitForIdle(robot); + + Util.clickOnComp(frame, robot, 500); + Util.waitForIdle(robot); + + mouseEnterCount.set(0); + mouseExitCount.set(0); + + Util.clickOnComp(openButton, robot, 500); + Util.waitForIdle(robot); + if (mouseExitCount.get() != 1) { + throw new RuntimeException("Test FAILED. Wrong number of MouseExited events = " + mouseExitCount.get()); + } + + Util.clickOnComp(closeButton, robot, 500); + Util.waitForIdle(robot); + if (mouseEnterCount.get() != 1) { + throw new RuntimeException("Test FAILED. Wrong number of MouseEntered events = "+ mouseEnterCount.get()); + } + } + + private static void createAndShowGUI() { + frame = new JFrame("ModalDialogEnterExitEventsTest"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(new FlowLayout()); + frame.addMouseListener(new MouseAdapter() { + @Override + public void mouseExited(MouseEvent e) { + mouseExitCount.getAndIncrement(); + } + + @Override + public void mouseEntered(MouseEvent e) { + mouseEnterCount.getAndIncrement(); + } + }); + openButton = new JButton("Open Dialog"); + openButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JDialog dialog = new JDialog(frame, "Modal Dialog", true); + dialog.setLayout(new FlowLayout()); + closeButton = new JButton("Close"); + closeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + dialog.add(closeButton); + dialog.setSize(200, 200); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + } + }); + frame.add(openButton); + frame.setExtendedState(Frame.MAXIMIZED_BOTH); + frame.setVisible(true); + } +} + diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016, 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 + * @summary Test getGlyphCharIndex() results from layout + * @bug 8152680 + */ + +import java.awt.Font; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; + +public class GetGlyphCharIndexTest { + public static void main(String[] args) { + Font font = new Font(Font.MONOSPACED, Font.PLAIN, 12); + FontRenderContext frc = new FontRenderContext(null, false, false); + GlyphVector gv = font.layoutGlyphVector(frc, "abc".toCharArray(), 1, 3, + Font.LAYOUT_LEFT_TO_RIGHT); + int idx0 = gv.getGlyphCharIndex(0); + if (idx0 != 0) { + throw new RuntimeException("Expected 0, got " + idx0); + } + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,143 @@ +/* + * Copyright (c) 1999, 2016, 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 4175418 8158924 + * @author John Raley + * @summary This insures that bug 4175418: Font substitution in TextLayout / + * LineBreakMeasurer is inconsistent has been fixed. The problem was + * that text was measured in one Font, but lines were produced + * in a different font. + */ + +/* + * (C) Copyright IBM Corp. 1999, All Rights Reserved + */ + +import java.text.AttributedString; +import java.awt.font.LineBreakMeasurer; +import java.awt.font.TextLayout; +import java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; + +/** + * This insures that bug 4175418: Font substitution in TextLayout / + * LineBreakMeasurer is inconsistent has been fixed. The problem was + * that text was measured in one Font, but lines were produced + * in a different font. One symptom of this problem is that lines are + * either too short or too long. This test line-breaks a paragraph + * and checks the line lengths to make sure breaks were chosen well. + * This can be checked because the paragraph is so simple. + */ +public class TestLineBreakWithFontSub { + + public static void main(String[] args) { + + new TestLineBreakWithFontSub().test(); + System.out.println("Line break / font substitution test PASSED"); + } + + private static final String WORD = "word"; + private static final String SPACING = " "; + // The Hebrew character in this string can trigger font substitution + private static final String MIXED = "A\u05D0"; + + private static final int NUM_WORDS = 12; + + private static final FontRenderContext DEFAULT_FRC = + new FontRenderContext(null, false, false); + + public void test() { + + // construct a paragraph as follows: MIXED + [SPACING + WORD] + ... + StringBuffer text = new StringBuffer(MIXED); + for (int i=0; i < NUM_WORDS; i++) { + text.append(SPACING); + text.append(WORD); + } + + AttributedString attrString = new AttributedString(text.toString()); + attrString.addAttribute(TextAttribute.SIZE, new Float(24.0)); + + LineBreakMeasurer measurer = new LineBreakMeasurer(attrString.getIterator(), + DEFAULT_FRC); + + // get width of a space-word sequence, in context + int sequenceLength = WORD.length()+SPACING.length(); + measurer.setPosition(text.length() - sequenceLength); + + TextLayout layout = measurer.nextLayout(10000.0f); + + if (layout.getCharacterCount() != sequenceLength) { + throw new Error("layout length is incorrect!"); + } + + final float sequenceAdvance = layout.getVisibleAdvance(); + + float wrappingWidth = sequenceAdvance * 2; + + // now run test with a variety of widths + while (wrappingWidth < (sequenceAdvance*NUM_WORDS)) { + measurer.setPosition(0); + checkMeasurer(measurer, + wrappingWidth, + sequenceAdvance, + text.length()); + wrappingWidth += sequenceAdvance / 5; + } + } + + /** + * Iterate through measurer and check that every line is + * not too long and not too short, but just right. + */ + private void checkMeasurer(LineBreakMeasurer measurer, + float wrappingWidth, + float sequenceAdvance, + int endPosition) { + + do { + TextLayout layout = measurer.nextLayout(wrappingWidth); + float visAdvance = layout.getVisibleAdvance(); + + // Check that wrappingWidth-sequenceAdvance < visAdvance + // Also, if we're not at the end of the paragraph, + // check that visAdvance <= wrappingWidth + + if (visAdvance > wrappingWidth) { + // line is too long for given wrapping width + throw new Error("layout is too long"); + } + + if (measurer.getPosition() < endPosition) { + if (visAdvance <= wrappingWidth - sequenceAdvance) { + // line is too short for given wrapping width; + // another word would have fit + throw new Error("room for more words on line. diff=" + + (wrappingWidth - sequenceAdvance - visAdvance)); + } + } + } while (measurer.getPosition() != endPosition); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 1998, 2016, 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 4178145 8144015 +*/ + +/* + * Copyright 1998 IBM Corp. All Rights Reserved. + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.awt.font.TextHitInfo; +import java.awt.font.FontRenderContext; +import java.util.Hashtable; + +/** + * This test ensures that TextLayout will not place a caret within + * an Arabic lam-alef ligature, and will correctly caret through + * bidirectional text with numbers. + */ + +public class LigatureCaretTest { + + public static void main(String[] args) { + + //testBidiWithNumbers(); + testLamAlef(); + System.out.println("LigatureCaretTest PASSED"); + } + + // These values are for TextLayout constructors + private static final Hashtable map = new Hashtable(); + static { + map.put(TextAttribute.FONT, new Font("Lucida Sans", Font.PLAIN, 24)); + } + private static final FontRenderContext frc = + new FontRenderContext(null, false, false); + + /** + * Caret through text mixed-direction text and check the results. + * If the test fails an Error is thrown. + * @exception an Error is thrown if the test fails + */ + public static void testBidiWithNumbers() { + + String bidiWithNumbers = "abc\u05D0\u05D1\u05D2123abc"; + // visual order for the text: + // abc123abc + + int[] carets = { 0, 1, 2, 3, 7, 8, 6, 5, 4, 9, 10, 11, 12 }; + TextLayout layout = new TextLayout(bidiWithNumbers, map, frc); + + // Caret through TextLayout in both directions and check results. + for (int i=0; i < carets.length-1; i++) { + + TextHitInfo hit = layout.getNextRightHit(carets[i]); + if (hit.getInsertionIndex() != carets[i+1]) { + throw new Error("right hit failed within layout"); + } + } + + if (layout.getNextRightHit(carets[carets.length-1]) != null) { + throw new Error("right hit failed at end of layout"); + } + + for (int i=carets.length-1; i > 0; i--) { + + TextHitInfo hit = layout.getNextLeftHit(carets[i]); + if (hit.getInsertionIndex() != carets[i-1]) { + throw new Error("left hit failed within layout"); + } + } + + if (layout.getNextLeftHit(carets[0]) != null) { + throw new Error("left hit failed at end of layout"); + } + } + + /** + * Ensure proper careting and hit-testing behavior with + * a lam-alef ligature. + * If the test fails, an Error is thrown. + * @exception an Error is thrown if the test fails + */ + public static void testLamAlef() { + + // lam-alef form a mandantory ligature. + final String lamAlef = "\u0644\u0627"; + final String ltrText = "abcd"; + + // Create a TextLayout with just a lam-alef sequence. There + // should only be two valid caret positions: one at + // insertion offset 0 and the other at insertion offset 2. + TextLayout layout = new TextLayout(lamAlef, map, frc); + + TextHitInfo hit; + + hit = layout.getNextLeftHit(0); + if (hit.getInsertionIndex() != 2) { + throw new Error("Left hit failed. Hit:" + hit); + } + + hit = layout.getNextRightHit(2); + if (hit.getInsertionIndex() != 0) { + throw new Error("Right hit failed. Hit:" + hit); + } + + hit = layout.hitTestChar(layout.getAdvance()/2, 0); + if (hit.getInsertionIndex() != 0 && hit.getInsertionIndex() != 2) { + throw new Error("Hit-test allowed incorrect caret. Hit:" + hit); + } + + + // Create a TextLayout with some left-to-right text + // before the lam-alef sequence. There should not be + // a caret position between the lam and alef. + layout = new TextLayout(ltrText+lamAlef, map, frc); + + final int ltrLen = ltrText.length(); + final int layoutLen = layout.getCharacterCount(); + + for (int i=0; i < ltrLen; i++) { + hit = layout.getNextRightHit(i); + if (hit.getInsertionIndex() != i+1) { + throw new Error("Right hit failed in ltr text."); + } + } + + hit = layout.getNextRightHit(ltrLen); + if (layoutLen != hit.getInsertionIndex()) { + throw new Error("Right hit failed at direction boundary."); + } + + hit = layout.getNextLeftHit(layoutLen); + if (hit.getInsertionIndex() != ltrLen) { + throw new Error("Left hit failed at end of text."); + } + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/font/TextLayout/TestJustification.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/font/TextLayout/TestJustification.html Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,52 @@ + + + + +Test Justification + + + +

Test Justification

+
+

Five lines of text should appear, all justified to the same width, +followed by a sixth line containing only roman characters and no spaces +which is not justified, and instead is centered. +Carets should appear between all characters. Pass the test if this is +true. +

+ +alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." +Your browser is completely ignoring the <APPLET> tag! + + + + diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/font/TextLayout/TestJustification.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/font/TextLayout/TestJustification.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,249 @@ +/* + * Copyright (c) 1999, 2016, 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. + */ + +/* + * + * See TestJustification.html for main test. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.font.*; +import java.awt.geom.*; +import java.text.*; + +public class TestJustification extends Applet { + JustificationPanel panel; + + public void init() { + setLayout(new BorderLayout()); + panel = new JustificationPanel("Bitstream Cyberbit"); + add("Center", panel); + } + + public void destroy() { + remove(panel); + } + + // calls system.exit, not for use in tests. + public static void main(String args[]) { + TestJustification justificationTest = new TestJustification(); + justificationTest.init(); + justificationTest.start(); + + Frame f = new Frame("Test Justification"); + f.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + f.add("Center", justificationTest); + f.setSize(500, 500); + f.show(); + } + + public String getAppletInfo() { + return "Test TextLayout.getJustifiedLayout()"; + } + + static class JustificationPanel extends Panel { + TextLayout[] layouts; + String fontname; + float height; + float oldfsize; + + AttributedCharacterIterator lineText; + TextLayout[] lines; + int linecount; + float oldwidth; + + JustificationPanel(String fontname) { + this.fontname = fontname; + } + + private static final String[] texts = { + "This is an english Highlighting demo.", "Highlighting", + "This is an arabic \u0627\u0628\u062a\u062c \u062e\u0644\u0627\u062e demo.", "arabic \u0627\u0628\u062a\u062c", + "This is a hebrew \u05d0\u05d1\u05d2 \u05d3\u05d4\u05d5 demo.", "hebrew \u05d0\u05d1\u05d2", + "This is a cjk \u4e00\u4e01\u4e02\uac00\uac01\uc4fa\uf900\uf901\uf902 demo.", "cjk", + "NoSpaceCJK:\u4e00\u4e01\u4e02and\uac00\uac01\uc4faand\uf900\uf901\uf902", "No", + "NoSpaceRoman", "Space" + }; + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D)g; + + Dimension d = getSize(); + Insets insets = getInsets(); + + float w = d.width - insets.left - insets.right; + float h = d.height - insets.top - insets.bottom; + int fsize = (int)w/25; + + FontRenderContext frc = g2d.getFontRenderContext(); + + if (layouts == null || fsize != oldfsize) { + oldfsize = fsize; + + Font f0 = new Font(fontname, Font.PLAIN, fsize); + Font f1 = new Font(fontname, Font.ITALIC, (int)(fsize * 1.5)); + + if (layouts == null) { + layouts = new TextLayout[texts.length / 2]; + } + + height = 0; + for (int i = 0; i < layouts.length; ++i) { + String text = texts[i*2]; + String target = texts[i*2+1]; + + AttributedString astr = new AttributedString(text); + astr.addAttribute(TextAttribute.FONT, f0, 0, text.length()); + + int start = text.indexOf(target); + int limit = start + target.length(); + astr.addAttribute(TextAttribute.FONT, f1, start, limit); + + TextLayout layout = new TextLayout(astr.getIterator(), frc); + + layout = layout.getJustifiedLayout(w - 20); + + layouts[i] = layout; + + height += layout.getAscent() + layout.getDescent() + layout.getLeading(); + } + } + + g2d.setColor(Color.white); + g2d.fill(new Rectangle.Float(insets.left, insets.top, w, h)); + + float basey = 20; + + for (int i = 0; i < layouts.length; ++i) { + TextLayout layout = layouts[i]; + + float la = layout.getAscent(); + float ld = layout.getDescent(); + float ll = layout.getLeading(); + float lw = layout.getAdvance(); + float lh = la + ld + ll; + float lx = (w - lw) / 2f; + float ly = basey + layout.getAscent(); + + g2d.setColor(Color.black); + g2d.translate(insets.left + lx, insets.top + ly); + + Rectangle2D bounds = new Rectangle2D.Float(0, -la, lw, lh); + g2d.draw(bounds); + + layout.draw(g2d, 0, 0); + + g2d.setColor(Color.red); + for (int j = 0, e = layout.getCharacterCount(); j <= e; ++j) { + Shape[] carets = layout.getCaretShapes(j, bounds); + g2d.draw(carets[0]); + } + + g2d.translate(-insets.left - lx, -insets.top - ly); + basey += layout.getAscent() + layout.getDescent() + layout.getLeading(); + } + + // add LineBreakMeasurer-generated layouts + + if (lineText == null) { + String text = "This is a long line of text that should be broken across multiple " + + "lines and then justified to fit the break width. This test should pass if " + + "these lines are justified to the same width, and fail otherwise. It should " + + "also format the hebrew (\u05d0\u05d1\u05d2 \u05d3\u05d4\u05d5) and arabic " + + "(\u0627\u0628\u062a\u062c \u062e\u0644\u0627\u062e) and CJK " + + "(\u4e00\u4e01\u4e02\uac00\uac01\uc4fa\u67b1\u67b2\u67b3\u67b4\u67b5\u67b6\u67b7" + + "\u67b8\u67b9) text correctly."; + + Float regular = new Float(16.0); + Float big = new Float(24.0); + AttributedString astr = new AttributedString(text); + astr.addAttribute(TextAttribute.SIZE, regular, 0, text.length()); + astr.addAttribute(TextAttribute.FAMILY, fontname, 0, text.length()); + + int ix = text.indexOf("broken"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("hebrew"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("arabic"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("CJK"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 3); + + lineText = astr.getIterator(); + } + + float width = w - 20; + if (lines == null || width != oldwidth) { + oldwidth = width; + + lines = new TextLayout[10]; + linecount = 0; + + LineBreakMeasurer measurer = new LineBreakMeasurer(lineText, frc); + + for (;;) { + TextLayout layout = measurer.nextLayout(width); + if (layout == null) { + break; + } + + // justify all but last line + if (linecount > 0) { + lines[linecount - 1] = lines[linecount - 1].getJustifiedLayout(width); + } + + if (linecount == lines.length) { + TextLayout[] nlines = new TextLayout[lines.length * 2]; + System.arraycopy(lines, 0, nlines, 0, lines.length); + lines = nlines; + } + + lines[linecount++] = layout; + } + } + + float basex = insets.left + 10; + basey += 10; + g2d.setColor(Color.black); + + for (int i = 0; i < linecount; ++i) { + TextLayout layout = lines[i]; + + basey += layout.getAscent(); + float adv = layout.getAdvance(); + float dx = layout.isLeftToRight() ? 0 : width - adv; + + layout.draw(g2d, basex + dx, basey); + + basey += layout.getDescent() + layout.getLeading(); + } + } + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/font/TextLayout/VisibleAdvance.java --- a/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java Fri Sep 16 13:15:01 2016 -0700 @@ -29,7 +29,7 @@ /* @test * @summary verify TextLine advance - * @bug 6582460 + * @bug 6582460 8164818 */ /* diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/print/PrinterJob/PrintDlgPageable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/print/PrinterJob/PrintDlgPageable.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2016, 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 4885375 + * @summary Verifies if PageRanges To Field is populated based on Pageable + * for COMMON print dialog + * @run main/manual PrintDlgPageable + */ +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Pageable; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.DialogTypeSelection; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class PrintDlgPageable implements Printable { + + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(PrintDlgPageable::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(30000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Print Dialog does not " + + "`reflect Copies or Page Ranges"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void printTest() { + PrinterJob pj = PrinterJob.getPrinterJob(); + PageableHandler handler = new PageableHandler(); + pj.setPageable(handler); + + PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); + pSet.add(DialogTypeSelection.COMMON); + pj.printDialog(pSet); + } + + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " Visual inspection of print dialog is required.\n" + + " A print dialog will be shown.\n " + + " Please verify Page Range is populated \n" + + " with \"From\" 1 and \"To\" 5.\n" + + " If ok, press PASS else press FAIL"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + } + + @Override + public int print(Graphics g, PageFormat pf, int pi) throws PrinterException { + return NO_SUCH_PAGE; + } +} + +class PageableHandler implements Pageable { + + PageFormat pf = new PageFormat(); + + @Override + public int getNumberOfPages() { + return 5; + } + + @Override + public Printable getPrintable(int pageIndex) { + return new PrintDlgPageable(); + } + + @Override + public PageFormat getPageFormat(int pageIndex) { + return pf; + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java --- a/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,8 +21,7 @@ * questions. */ /* - * @test - * @bug 6357887 + * @bug 6357887 8165146 * @summary Verifies if selected printertray is used * @requires (os.family == "linux" | os.family == "solaris") * @run main/manual TestMediaTraySelection diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/print/PrinterJob/TestPageDlgFrameAssociation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/print/PrinterJob/TestPageDlgFrameAssociation.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2016, 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 7064425 6948907 + * @summary Verifies if owner Frame is associated with page dialog of PrinterJob + * @run main/manual TestPageDlgFrameAssociation + */ +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestPageDlgFrameAssociation { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static Button print; + private static Frame frame; + private static boolean start; + private static Thread t; + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestPageDlgFrameAssociation::frameTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Page dialog not disposed." + + " Page dialog is not associated with owner Frame`"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void frameTest() { + Panel panel =new Panel(); + + print = new Button("PageDialog"); + print.setActionCommand("PageDialog"); + print.addActionListener((e) -> { + PrinterJob job = PrinterJob.getPrinterJob(); + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + t.start(); + start = true; + PageFormat pf = job.pageDialog(aset); + }); + + panel.add(print); + + frame = new Frame("Test Frame"); + frame.setLayout (new BorderLayout ()); + frame.add(panel,"South"); + frame.pack(); + frame.setVisible(true); + + t = new Thread (() -> { + if (start) { + try { + Thread.sleep(5000); + } catch (InterruptedException ex) {} + frame.dispose(); + } + }); + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " A Frame with PageDialog Button is shown. Press PageDialog.\n" + + " A page dialog will be shown. Do not press any button.\n" + + " After 5 secs the frame along with this page dialog will be disposed.\n" + + " If the page dialog is not disposed, press FAIL else press PASS"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/awt/print/PrinterJob/TestPrintDlgFrameAssociation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/print/PrinterJob/TestPrintDlgFrameAssociation.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2016, 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 7064425 6948907 + * @summary Verifies if owner Frame is associated with print dialog of PrinterJob + * @run main/manual TestPrintDlgFrameAssociation + */ +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PrinterJob; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestPrintDlgFrameAssociation { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static Button print; + private static Frame frame; + private static boolean start; + private static Thread t; + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestPrintDlgFrameAssociation::frameTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Print dialog not disposed." + + " Print dialog is not associated with owner Frame`"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void frameTest() { + Panel panel =new Panel(); + + print = new Button("PrintDialog"); + print.setActionCommand("PrintDialog"); + print.addActionListener((e) -> { + PrinterJob job = PrinterJob.getPrinterJob(); + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + t.start(); + start = true; + job.printDialog(aset); + }); + + panel.add(print); + + frame = new Frame("Test Frame"); + frame.setLayout (new BorderLayout ()); + frame.add(panel,"South"); + frame.pack(); + frame.setVisible(true); + + t = new Thread (() -> { + if (start) { + try { + Thread.sleep(5000); + } catch (InterruptedException ex) {} + frame.dispose(); + } + }); + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " A Frame with PrintDialog Button is shown. Press PrintDialog.\n" + + " A print dialog will be shown. Do not press any button.\n" + + " After 5 secs the frame along with this print dialog will be disposed.\n" + + " If the print dialog is not disposed, press FAIL else press PASS"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/lang/Class/GetModuleTest.java --- a/jdk/test/java/lang/Class/GetModuleTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/lang/Class/GetModuleTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -101,11 +101,8 @@ return new Object[][] { { GetModuleTest.class, null }, - { GetModuleTest[].class, null }, { Object.class, null }, - { Object[].class, null }, { Component.class, null }, - { Component[].class, null }, }; } @@ -117,7 +114,7 @@ public void testGetModuleOnVMAnonymousClass(Class hostClass, String ignore) { // choose a class name in the same package as the host class - String prefix = packageName(hostClass); + String prefix = hostClass.getPackageName(); if (prefix.length() > 0) prefix = prefix.replace('.', '/') + "/"; String className = prefix + "Anon"; @@ -136,17 +133,6 @@ assertTrue(anonClass.getModule() == hostClass.getModule()); } - private static String packageName(Class c) { - if (c.isArray()) { - return packageName(c.getComponentType()); - } else { - String name = c.getName(); - int dot = name.lastIndexOf('.'); - if (dot == -1) return ""; - return name.substring(0, dot); - } - } - private static int constantPoolSize(byte[] classFile) { return ((classFile[8] & 0xFF) << 8) | (classFile[9] & 0xFF); } diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/lang/invoke/VMAnonymousClass.java --- a/jdk/test/java/lang/invoke/VMAnonymousClass.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/lang/invoke/VMAnonymousClass.java Fri Sep 16 13:15:01 2016 -0700 @@ -57,9 +57,9 @@ @Test public void testJavaLangInvoke() throws Throwable { test("java/lang/invoke"); } @Test public void testProhibitedJavaPkg() throws Throwable { try { - test("java/prohibited"); - } catch (SecurityException e) { - return; + test("java/prohibited"); + } catch (IllegalArgumentException e) { + return; } throw new RuntimeException("Expected SecurityException"); } @@ -72,10 +72,17 @@ if (pkg.equals("java/prohibited")) { VMAnonymousClass sampleclass = new VMAnonymousClass(); host_class = (Class)sampleclass.getClass(); + } else if (pkg.equals("java/lang")) { + host_class = Object.class; + } else if (pkg.equals("java/util")) { + host_class = java.util.ArrayList.class; + } else if (pkg.equals("jdk/internal/misc")) { + host_class = jdk.internal.misc.Signal.class; + } else if (pkg.equals("java/lang/invoke")) { + host_class = java.lang.invoke.CallSite.class; } else { - host_class = Object.class; + throw new RuntimeException("Unexpected pkg: " + pkg); } - // Define VM anonymous class Class anonClass = unsafe.defineAnonymousClass(host_class, bytes, null); diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/lang/management/ThreadMXBean/Locks.java --- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -26,27 +26,28 @@ * @bug 4530538 * @summary Basic unit test of ThreadInfo.getLockName() * and ThreadInfo.getLockOwnerName() + * @library /lib/testlibrary * @author Mandy Chung * @author Jaroslav Bachorik * - * @library /lib/testlibrary * @modules java.management * @build jdk.testlibrary.* * @run main/othervm Locks */ - import java.lang.management.*; +import java.util.Arrays; +import java.util.Optional; import java.util.concurrent.Phaser; +import java.util.function.Predicate; import jdk.testlibrary.LockFreeLogManager; public class Locks { - private static final Object objA = new Object(); - private static final Object objB = new Object(); - private static final Object objC = new Object(); - private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean(); - private static final LockFreeLogManager logger = new LockFreeLogManager(); - private static boolean testFailed = false; + private static final Object OBJA = new Object(); + private static final Object OBJB = new Object(); + private static final EnhancedWaiter OBJC = new EnhancedWaiter(); + private static final ThreadMXBean TM = ManagementFactory.getThreadMXBean(); + private static final LockFreeLogManager LOGGER = new LockFreeLogManager(); private static String getLockName(Object lock) { if (lock == null) return null; @@ -56,67 +57,103 @@ } private static void assertNoLock(Thread t) { - long tid = t.getId(); - ThreadInfo info = tm.getThreadInfo(tid); - String result = info.getLockName(); + if (t == null) { + return; + } + Optional result = Arrays.asList( + TM.getThreadInfo(TM.getAllThreadIds(), true, true)). + stream(). + filter(tInfo -> (tInfo != null && tInfo.getLockOwnerName() != null) + ? tInfo.getLockOwnerName().equals(t.getName()) : false). + findAny(); + if (result.isPresent()) { + throw new RuntimeException("Thread " + t.getName() + " is not " + + "supposed to be hold any lock. Currently owning lock : " + + result.get().getLockName()); + } + } - if (result != null) { - throw new RuntimeException("Thread " + t.getName() + " is not supposed to hold any lock. " + - "Currently owning lock: " + result); + /* + * Handy debug function to check if error condition is because of test code or not. + */ + private static void printStackTrace(Thread thread) { + if (thread == null) { + return; + } + StackTraceElement[] stackTrace = thread.getStackTrace(); + log("Stack dump : Thread -> " + thread.getName()); + for (StackTraceElement stackTraceEl : stackTrace) { + log("\t" + stackTraceEl.toString()); } } - private static void checkBlockedObject(Thread t, Object lock, Thread owner, - Thread.State expectedState) { + private static void assertThreadState(Thread t, Thread.State expectedState) { long tid = t.getId(); - ThreadInfo info = tm.getThreadInfo(tid); - String result = info.getLockName(); - String expectedLock = (lock != null ? getLockName(lock) : null); - String expectedOwner = (owner != null ? owner.getName() : null); + if (expectedState == Thread.State.BLOCKED + && TM.getThreadInfo(tid).getThreadState() != Thread.State.BLOCKED) { + int retryCount = 0; + printStackTrace(t); + while (TM.getThreadInfo(tid).getThreadState() != Thread.State.BLOCKED) { + if (retryCount++ > 500) { + printStackTrace(t); + throw new RuntimeException("Thread " + t.getName() + " is at " + + TM.getThreadInfo(tid).getThreadState() + " state but is expected to " + + "be in Thread.State = " + expectedState); + } + goSleep(100); + } + } + if (!TM.getThreadInfo(tid).getThreadState().equals(expectedState)) { + printStackTrace(t); + throw new RuntimeException("Thread " + t.getName() + " is at " + + TM.getThreadInfo(tid).getThreadState() + " state but is expected to " + + "be in Thread.State = " + expectedState); + } + } - if (lock != null) { - if (expectedState == Thread.State.BLOCKED) { - int retryCount=0; - while(info.getThreadState() != Thread.State.BLOCKED) { - if (retryCount++ > 500) { - throw new RuntimeException("Thread " + t.getName() + - " is expected to block on " + expectedLock + - " but got " + result + - " Thread.State = " + info.getThreadState()); - } - goSleep(100); - info = tm.getThreadInfo(tid); - result = info.getLockName(); + /* + * Do slow check if thread is blocked on a lock. It is possible that last thread + * to come out of Phaser might still be in Phaser call stack (Unsafe.park) and + * hence might eventually acquire expected lock. + */ + private static void checkBlockedObject(Thread t, Object lock, Thread owner) { + long tid = t.getId(); + String result = TM.getThreadInfo(tid).getLockName(); + final String expectedLock = (lock != null ? getLockName(lock) : null); + Predicate p = (res) -> ((res != null && !res.equals(expectedLock)) + || (res == null && expectedLock != null)); + + if (p.test(result)) { + printStackTrace(t); + int retryCount = 0; + while (p.test(result)) { + if (retryCount++ > 500) { + printStackTrace(t); + throw new RuntimeException("Thread " + t.getName() + " is blocked on " + + expectedLock + " but got " + result); } - } - if (expectedState == Thread.State.WAITING && - info.getThreadState() != Thread.State.WAITING) { - throw new RuntimeException("Thread " + t.getName() + - " is expected to wait on " + expectedLock + - " but got " + result + - " Thread.State = " + info.getThreadState()); + goSleep(100); + result = TM.getThreadInfo(tid).getLockName(); } } - if ((result != null && !result.equals(expectedLock)) || - (result == null && expectedLock != null)) { - throw new RuntimeException("Thread " + t.getName() + " is blocked on " + - expectedLock + " but got " + result); - } - result = info.getLockOwnerName(); - if ((result != null && !result.equals(expectedOwner)) || - (result == null && expectedOwner != null)) { - throw new RuntimeException("Owner of " + lock + " should be " + - expectedOwner + " but got " + result); + result = TM.getThreadInfo(tid).getLockOwnerName(); + final String expectedOwner = (owner != null ? owner.getName() : null); + + p = (res) -> ((res != null && !res.equals(expectedOwner)) + || (res == null && expectedOwner != null)); + if (p.test(result)) { + printStackTrace(t); + throw new RuntimeException("Owner of " + lock + " should be " + + expectedOwner + " but got " + result); } } - private static void goSleep(long ms) { + private static void goSleep(long ms){ try { Thread.sleep(ms); - } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; + } catch (InterruptedException ex) { + throw new RuntimeException(ex); } } @@ -128,14 +165,15 @@ super("LockAThread"); this.p = p; } + @Override public void run() { - synchronized(objA) { - // stop here for LockBThread to hold objB - log("LockAThread about to block on objB"); + synchronized(OBJA) { + // block here while LockBThread holds OBJB + log("LockAThread about to block on OBJB"); p.arriveAndAwaitAdvance(); // Phase 1 (blocking) - synchronized(objB) { + synchronized(OBJB) { dummyCounter++; - }; + } } p.arriveAndAwaitAdvance(); // Phase 2 (blocking) log("LockAThread about to exit"); @@ -150,14 +188,15 @@ super("LockBThread"); this.p = p; } + @Override public void run() { - synchronized(objB) { - log("LockBThread about to block on objC"); + synchronized(OBJB) { + log("LockBThread about to block on OBJC"); p.arriveAndAwaitAdvance(); // Phase 1 (blocking) - // Signal main thread about to block on objC - synchronized(objC) { + // Signal main thread about to block on OBJC + synchronized(OBJC) { dummyCounter++; - }; + } } p.arriveAndAwaitAdvance(); // Phase 2 (blocking) log("LockBThread about to exit"); @@ -166,9 +205,30 @@ } } + /* + * Must be invoked from within a synchronized context + */ + private static class EnhancedWaiter { + + boolean isNotified = false; + + public void doWait() throws InterruptedException { + while (!isNotified) { + wait(); + } + isNotified = false; + } + + public void doNotify() { + isNotified = true; + notify(); + } + } + private static WaitingThread waiter; private static final Object ready = new Object(); private static CheckerThread checker; + static class WaitingThread extends Thread { private final Phaser p; @@ -180,17 +240,16 @@ } @Override public void run() { - synchronized(objC) { - log("WaitingThread about to wait on objC"); + synchronized(OBJC) { + log("WaitingThread about to wait on OBJC"); try { - // Signal checker thread, about to wait on objC. + // Signal checker thread, about to wait on OBJC. waiting = false; p.arriveAndAwaitAdvance(); // Phase 1 (waiting) waiting = true; - objC.wait(); + OBJC.doWait(); } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; + throw new RuntimeException(e); // Do not continue test } // block until CheckerThread finishes checking @@ -202,19 +261,18 @@ dummyCounter++; } } - synchronized(objC) { + synchronized(OBJC) { try { - // signal checker thread, about to wait on objC + // signal checker thread, about to wait on OBJC waiting = false; p.arriveAndAwaitAdvance(); // Phase 3 (waiting) waiting = true; - objC.wait(); + OBJC.doWait(); } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; + throw new RuntimeException(e); } } - log("WaitingThread about to exit waiting on objC 2"); + log("WaitingThread about to exit waiting on OBJC 2"); } public void waitForWaiting() { @@ -241,85 +299,87 @@ super("CheckerThread"); } + @Override public void run() { - synchronized (ready) { - // wait until WaitingThread about to wait for objC + synchronized(ready) { + // wait until WaitingThread about to wait for OBJC waiter.waitForWaiting(); // Phase 1 (waiting) - checkBlockedObject(waiter, objC, null, Thread.State.WAITING); + assertThreadState(waiter, Thread.State.WAITING); + checkBlockedObject(waiter, OBJC, null); - synchronized (objC) { - objC.notify(); + synchronized(OBJC) { + OBJC.doNotify(); } - // wait for waiter thread to about to enter // synchronized object ready. waiter.waitForBlocked(); // Phase 2 (waiting) - checkBlockedObject(waiter, ready, this, Thread.State.BLOCKED); + assertThreadState(waiter, Thread.State.BLOCKED); + checkBlockedObject(waiter, ready, this); } // wait for signal from waiting thread that it is about - // wait for objC. + // wait for OBJC. waiter.waitForWaiting(); // Phase 3 (waiting) - synchronized(objC) { - checkBlockedObject(waiter, objC, Thread.currentThread(), Thread.State.WAITING); - objC.notify(); + synchronized(OBJC) { + assertThreadState(waiter, Thread.State.WAITING); + checkBlockedObject(waiter, OBJC, Thread.currentThread()); + OBJC.doNotify(); } - } } public static void main(String args[]) throws Exception { - Thread mainThread = Thread.currentThread(); + try { + Thread mainThread = Thread.currentThread(); - // Test uncontested case - LockAThread t1; - LockBThread t2; - - Phaser p = new Phaser(3); - synchronized(objC) { - // Make sure the main thread is not holding any lock - assertNoLock(mainThread); + // Test uncontested case + LockAThread t1; + LockBThread t2; - // Test deadlock case - // t1 holds lockA and attempts to lock B - // t2 holds lockB and attempts to lock C - - t1 = new LockAThread(p); - t1.start(); + Phaser p = new Phaser(3); + synchronized(OBJC) { + // Make sure the main thread is not holding any lock + assertNoLock(mainThread); - t2 = new LockBThread(p); - t2.start(); + // Test deadlock case + // t1 holds lockA and attempts to lock B + // t2 holds lockB and attempts to lock C + t1 = new LockAThread(p); + t1.start(); - p.arriveAndAwaitAdvance(); // Phase 1 (blocking) - checkBlockedObject(t2, objC, mainThread, Thread.State.BLOCKED); - checkBlockedObject(t1, objB, t2, Thread.State.BLOCKED); + t2 = new LockBThread(p); + t2.start(); - long[] expectedThreads = new long[3]; - expectedThreads[0] = t1.getId(); // blocked on lockB - expectedThreads[1] = t2.getId(); // owner of lockB blocking on lockC - expectedThreads[2] = mainThread.getId(); // owner of lockC - findThreadsBlockedOn(objB, expectedThreads); - } - p.arriveAndAwaitAdvance(); // Phase 2 (blocking) + p.arriveAndAwaitAdvance(); // Phase 1 (blocking) + assertThreadState(t2, Thread.State.BLOCKED); + checkBlockedObject(t2, OBJC, mainThread); + assertThreadState(t1, Thread.State.BLOCKED); + checkBlockedObject(t1, OBJB, t2); - p = new Phaser(2); - // Test Object.wait() case - waiter = new WaitingThread(p); - waiter.start(); + long[] expectedThreads = new long[3]; + expectedThreads[0] = t1.getId(); // blocked on lockB + expectedThreads[1] = t2.getId(); // owner of lockB blocking on lockC + expectedThreads[2] = mainThread.getId(); // owner of lockC + findThreadsBlockedOn(OBJB, expectedThreads); + } + p.arriveAndAwaitAdvance(); // Phase 2 (blocking) - checker = new CheckerThread(); - checker.start(); + p = new Phaser(2); + // Test Object.wait() case + waiter = new WaitingThread(p); + waiter.start(); + + checker = new CheckerThread(); + checker.start(); - try { - waiter.join(); - checker.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; - } - - if (testFailed) { - throw new RuntimeException("TEST FAILED."); + try { + waiter.join(); + checker.join(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } finally { // log all the messages to STDOUT + System.out.println(LOGGER.toString()); } System.out.println("Test passed."); } @@ -335,9 +395,9 @@ throw new RuntimeException("TEST FAILED: " + lock + " expected to have owner"); } - for (int j = 0; j < infos.length; j++) { - if (infos[j].getThreadId() == threadId) { - ownerInfo = infos[j]; + for (ThreadInfo info1 : infos) { + if (info1.getThreadId() == threadId) { + ownerInfo = info1; break; } } @@ -349,11 +409,11 @@ throws Exception { String lock = getLockName(o); // Check with ThreadInfo with no stack trace (i.e. no safepoint) - ThreadInfo[] infos = tm.getThreadInfo(tm.getAllThreadIds()); + ThreadInfo[] infos = TM.getThreadInfo(TM.getAllThreadIds()); doCheck(infos, lock, expectedThreads); // Check with ThreadInfo with stack trace - infos = tm.getThreadInfo(tm.getAllThreadIds(), 1); + infos = TM.getThreadInfo(TM.getAllThreadIds(), 1); doCheck(infos, lock, expectedThreads); } @@ -376,7 +436,7 @@ long[] threads = new long[10]; int count = 0; threads[count++] = ownerInfo.getThreadId(); - while (ownerInfo != null && ownerInfo.getThreadState() == Thread.State.BLOCKED) { + while (ownerInfo.getThreadState() == Thread.State.BLOCKED) { ownerInfo = findOwnerInfo(infos, lock); threads[count++] = ownerInfo.getThreadId(); log(" Owner = %s id = %d", @@ -407,6 +467,6 @@ } private static void log(String format, Object ... args) { - logger.log(format + "%n", args); + LOGGER.log(format + "%n", args); } } diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,292 @@ +/* + * Copyright (c) 2004, 2016, 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 8132926 + * @summary PKIXParameters built with public key form of TrustAnchor causes + * NPE during cert path building/validation + * @run main ValWithAnchorByName + */ + +import java.io.ByteArrayInputStream; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.CertPath; +import java.security.cert.CertPathValidator; +import java.security.cert.PKIXParameters; +import java.security.cert.PKIXRevocationChecker; +import java.security.cert.TrustAnchor; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +// To get certpath debugging, add -Djava.security.debug=certpath + +public class ValWithAnchorByName { + + // The following certificates and OCSP responses were captured from + // a test run that used certificates and responses generated by + // sun.security.testlibrary.CertificateBuilder and + // sun.security.testlibrary.SimpleOCSPServer. + + // Subject: CN=SSLCertificate, O=SomeCompany + // Issuer: CN=Intermediate CA Cert, O=SomeCompany + // Validity: Tue Aug 30 14:37:19 PDT 2016 to Wed Aug 30 14:37:19 PDT 2017 + private static final String EE_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIIDnTCCAoWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTEUMBIGA1UEChMLU29t\n" + + "ZUNvbXBhbnkxHTAbBgNVBAMTFEludGVybWVkaWF0ZSBDQSBDZXJ0MB4XDTE2MDgz\n" + + "MDIxMzcxOVoXDTE3MDgzMDIxMzcxOVowLzEUMBIGA1UEChMLU29tZUNvbXBhbnkx\n" + + "FzAVBgNVBAMTDlNTTENlcnRpZmljYXRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + + "MIIBCgKCAQEAjgv8KKE4CO0rbCjRLA1hXjRiSq30jeusCJ8frbRG+QOBgQ3j6jgc\n" + + "vk5wG1aTu7R4AFn0/HRDMzP9ZbRlZVIbJUTd8YiaNyZeyWapPnxHWrPCd5e1xopk\n" + + "ElieDdEH5FiLGtIrWy56CGA1hfQb1vUVYegyeY+TTtMFVHt0PrmMk4ZRgj/GtVNp\n" + + "BQQYIzaYAcrcWMeCn30ZrhaGAL1hsdgmEVV1wsTD4JeNMSwLwMYem7fg8ondGZIR\n" + + "kZuGtuSdOHu4Xz+mgDNXTeX/Bp/dQFucxCG+FOOM9Hoz72RY2W8YqgL38RlnwYWp\n" + + "nUNxhXWFH6vyINRQVEu3IgahR6HXjxM7LwIDAQABo4G8MIG5MBQGA1UdEQQNMAuC\n" + + "CWxvY2FsaG9zdDAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9s\n" + + "b2NhbGhvc3Q6NDIzMzMwHwYDVR0jBBgwFoAUYT525lwHCI4CmuWs8a7poaeKRJ4w\n" + + "HQYDVR0OBBYEFCaQnOX4L1ovqyfeKuoay+kI+lXgMA4GA1UdDwEB/wQEAwIFoDAd\n" + + "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEB\n" + + "AD8dqQIqFasJcL8lm4mPTsBl0JgNiN8tQcXM7VCvcH+yDvEyh9vudDjuhpSORqPq\n" + + "f1o/EvJ+gfs269mBnYQujYRvmSd6EAcBntv5zn6amOh03o6PqTY9KaUC/mL9hB84\n" + + "Y5/LYioP16sME7egKnlrGUgKh0ZvGzm7c3SYx3Z5YoeFBOkZajc7Jm+cBw/uBQkF\n" + + "a9mLEczIvOgkq1wto8vr2ptH1gEuvFRcorN3muvq34bk40G08+AHlP3fCLFpI3FA\n" + + "IStJLJZRcO+Ib4sOcKuaBGnuMo/QVOCEMDUs6RgiWtSd93OZKFIUOASVp6YIkcSs\n" + + "5/rmc06sICqBjLfPEB68Jjw=\n" + + "-----END CERTIFICATE-----"; + + // Subject: CN=Intermediate CA Cert, O=SomeCompany + // Issuer: CN=Root CA Cert, O=SomeCompany + // Validity: Sun Aug 07 14:37:19 PDT 2016 to Tue Aug 07 14:37:19 PDT 2018 + private static final String INT_CA_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIIDdjCCAl6gAwIBAgIBZDANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + + "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDgwNzIxMzcxOVoX\n" + + "DTE4MDgwNzIxMzcxOVowNTEUMBIGA1UEChMLU29tZUNvbXBhbnkxHTAbBgNVBAMT\n" + + "FEludGVybWVkaWF0ZSBDQSBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" + + "CgKCAQEAnJR5CnE7GKlQjigExSJ6hHu302mc0PcA6TDgsIitPYD/r8RBbBuE51OQ\n" + + "7IP7AXmfPUV3/+pO/uxx6mgY5O6XeUl7KadhVPtPcL0BVVevCSOdTMVa3iV4zRpa\n" + + "C6Uy2ouUFnafKnDtlbieggyETUoNgVNJYA9L0XNhtSnENoLHC4Pq0v8OsNtsOWFR\n" + + "NiMTOA49NNDBw85WgPyFAxjqO4z0J0zxdWq3W4rSMB8xrkulv2Rvj3GcfYJK/ab8\n" + + "V1IJ6PMWCpujASY3BzvYPnN7BKuBjbWJPgZdPYfX1cxeG80u0tOuMfWWiNONSMSA\n" + + "7m9y304QA0gKqlrFFn9U4hU89kv1IwIDAQABo4GYMIGVMA8GA1UdEwEB/wQFMAMB\n" + + "Af8wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzABhhZodHRwOi8vbG9jYWxob3N0\n" + + "OjM5MTM0MB8GA1UdIwQYMBaAFJNMsejEyJUB9tiWycVczvpiMVQZMB0GA1UdDgQW\n" + + "BBRhPnbmXAcIjgKa5azxrumhp4pEnjAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcN\n" + + "AQELBQADggEBAE4nOFdW9OirPnRvxihQXYL9CXLuGQz5tr0XgN8wSY6Un9b6CRiK\n" + + "7obgIGimVdhvUC1qdRcwJqgOfJ2/jR5/5Qo0TVp+ww4dHNdUoj73tagJ7jTu0ZMz\n" + + "5Zdp0uwd4RD/syvTeVcbPc3m4awtgEvRgzpDMcSeKPZWInlo7fbnowKSAUAfO8de\n" + + "0cDkxEBkzPIzGNu256cdLZOqOK9wLJ9mQ0zKgi/2NsldNc2pl/6jkGpA6uL5lJsm\n" + + "fo9sDusWNHV1YggqjDQ19hrf40VuuC9GFl/qAW3marMuEzY/NiKVUxty1q1s48SO\n" + + "g5LoEPDDkbygOt7ICL3HYG1VufhC1Q2YY9c=\n" + + "-----END CERTIFICATE-----"; + + // Subject: CN=Root CA Cert, O=SomeCompany + // Issuer: CN=Root CA Cert, O=SomeCompany + // Validity: Fri Jul 08 14:37:18 PDT 2016 to Fri Jun 28 14:37:18 PDT 2019 + private static final String ROOT_CA_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + + "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDcwODIxMzcxOFoX\n" + + "DTE5MDYyODIxMzcxOFowLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMT\n" + + "DFJvb3QgQ0EgQ2VydDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIlN\n" + + "M3WYEqkU2elXEZrV9QSDbDKwyaLEHafLFciH8Edoag3q/7jEzFJxI7JZ831tdbWQ\n" + + "Bm6Hgo+8pvetOFW1BckL8eIjyOONP2CKfFaeMaozsWi1cgxa+rjpU/Rekc+zBqvv\n" + + "y4Sr97TwT6nQiLlgjC1nCfR1SVpO51qoDChS7n785rsKEZxw/p+kkVWSZffU7zN9\n" + + "c645cPg//L/kjiyeKMkaquGQOYS68gQgy8YZXQv1E3l/8e8Ci1s1DYA5wpCbaBqg\n" + + "Tw84Rr4zlUEQBgXzQlRt+mPzeaDpdG1EeGkXrcdkZ+0EMELoOVXOEn6VNsz6vT3I\n" + + "KrnvQBSnN06xq/iWwC0CAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME\n" + + "GDAWgBSTTLHoxMiVAfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUk0yx6MTIlQH22JbJ\n" + + "xVzO+mIxVBkwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAAi+Nl\n" + + "sxP9t2IhiZIHRJGSBZuQlXIjwYIwbq3ZWc/ApZ+0oxtl7DYQi5uRNt8/opcGNCHc\n" + + "IY0fG93SbkDubXbxPYBW6D/RUjbz59ZryaP5ym55p1MjHTOqy+AM8g41xNTJikc3\n" + + "UUFXXnckeFbawijCsb7vf71owzKuxgBXi9n1rmXXtncKoA/LrUVXoUlKefdgDnsU\n" + + "sl3Q29eibE3HSqziMMoAOLm0jjekFGWIgLeTtyRYR1d0dNaUwsHTrQpPjxxUTn1x\n" + + "sAPpXKfzPnsYAZeeiaaE75GwbWlHzrNinvxdZQd0zctpfBJfVqD/+lWANlw+rOaK\n" + + "J2GyCaJINsyaI/I2\n" + + "-----END CERTIFICATE-----"; + + // OCSP Response Status: successful (0x0) + // Response Type: Basic OCSP Response + // Version: 1 (0x0) + // Responder Id: CN=Intermediate CA Cert, O=SomeCompany + // Produced At: Sep 6 21:37:20 2016 GMT + // Responses: + // Certificate ID: + // Hash Algorithm: sha1 + // Issuer Name Hash: 7ED23D4396152EAB7D0C4AD8C1CA1418AA05DD54 + // Issuer Key Hash: 613E76E65C07088E029AE5ACF1AEE9A1A78A449E + // Serial Number: 1000 + // Cert Status: good + // This Update: Sep 6 21:37:20 2016 GMT + // Next Update: Sep 6 22:37:19 2016 GMT + private static final String EE_OCSP_RESP = + "MIIFbAoBAKCCBWUwggVhBgkrBgEFBQcwAQEEggVSMIIFTjCBtaE3MDUxFDASBgNV\n" + + "BAoTC1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydBgP\n" + + "MjAxNjA5MDYyMTM3MjBaMGUwYzA7MAkGBSsOAwIaBQAEFH7SPUOWFS6rfQxK2MHK\n" + + "FBiqBd1UBBRhPnbmXAcIjgKa5azxrumhp4pEngICEACAABgPMjAxNjA5MDYyMTM3\n" + + "MjBaoBEYDzIwMTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAF13\n" + + "cLwxDG8UYPIbzID86vZGOWUuv5c35VnvebMk/ajAUdpItDYshIQVi90Z8BB2TEi/\n" + + "wtx1aNkIv7db0uQ0NnRfvME8vG2PWbty36CNAYr/M5UVzUmELH2sGTyf2fKfNIUK\n" + + "Iya/NRxCqxLAc34NYH0YyGJ9VcDjbEMNSBAHIqDdBNqKUPnjn454yoivU2oEs294\n" + + "cGePMx3QLyPepMwUss8nW74yIF7vxfJ+KFDBGWNuZDRfXScsGIoeM0Vt9B+4fmnV\n" + + "nP4Dw6l3IwmQH4ppjg08qTKvyrXcF2dPDWa98Xw6bA5G085Z/b/6/6GpkvKx/q6i\n" + + "UqKwF7q5hkDcB+N4/5SgggN+MIIDejCCA3YwggJeoAMCAQICAWQwDQYJKoZIhvcN\n" + + "AQELBQAwLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0Eg\n" + + "Q2VydDAeFw0xNjA4MDcyMTM3MTlaFw0xODA4MDcyMTM3MTlaMDUxFDASBgNVBAoT\n" + + "C1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydDCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJyUeQpxOxipUI4oBMUieoR7t9Np\n" + + "nND3AOkw4LCIrT2A/6/EQWwbhOdTkOyD+wF5nz1Fd//qTv7scepoGOTul3lJeymn\n" + + "YVT7T3C9AVVXrwkjnUzFWt4leM0aWgulMtqLlBZ2nypw7ZW4noIMhE1KDYFTSWAP\n" + + "S9FzYbUpxDaCxwuD6tL/DrDbbDlhUTYjEzgOPTTQwcPOVoD8hQMY6juM9CdM8XVq\n" + + "t1uK0jAfMa5Lpb9kb49xnH2CSv2m/FdSCejzFgqbowEmNwc72D5zewSrgY21iT4G\n" + + "XT2H19XMXhvNLtLTrjH1lojTjUjEgO5vct9OEANICqpaxRZ/VOIVPPZL9SMCAwEA\n" + + "AaOBmDCBlTAPBgNVHRMBAf8EBTADAQH/MDIGCCsGAQUFBwEBBCYwJDAiBggrBgEF\n" + + "BQcwAYYWaHR0cDovL2xvY2FsaG9zdDozOTEzNDAfBgNVHSMEGDAWgBSTTLHoxMiV\n" + + "AfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUYT525lwHCI4CmuWs8a7poaeKRJ4wDgYD\n" + + "VR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQBOJzhXVvToqz50b8YoUF2C\n" + + "/Qly7hkM+ba9F4DfMEmOlJ/W+gkYiu6G4CBoplXYb1AtanUXMCaoDnydv40ef+UK\n" + + "NE1afsMOHRzXVKI+97WoCe407tGTM+WXadLsHeEQ/7Mr03lXGz3N5uGsLYBL0YM6\n" + + "QzHEnij2ViJ5aO3256MCkgFAHzvHXtHA5MRAZMzyMxjbtuenHS2TqjivcCyfZkNM\n" + + "yoIv9jbJXTXNqZf+o5BqQOri+ZSbJn6PbA7rFjR1dWIIKow0NfYa3+NFbrgvRhZf\n" + + "6gFt5mqzLhM2PzYilVMbctatbOPEjoOS6BDww5G8oDreyAi9x2BtVbn4QtUNmGPX"; + + // OCSP Response Status: successful (0x0) + // Response Type: Basic OCSP Response + // Version: 1 (0x0) + // Responder Id: O = SomeCompany, CN = Root CA Cert + // Produced At: Sep 6 21:37:20 2016 GMT + // Responses: + // Certificate ID: + // Hash Algorithm: sha1 + // Issuer Name Hash: C8ED9F4E9AC0052A978257C569E6A7C9C45F5CB5 + // Issuer Key Hash: 934CB1E8C4C89501F6D896C9C55CCEFA62315419 + // Serial Number: 64 + // Cert Status: good + // This Update: Sep 6 21:37:20 2016 GMT + // Next Update: Sep 6 22:37:19 2016 GMT + private static final String INT_CA_OCSP_RESP = + "MIIFJQoBAKCCBR4wggUaBgkrBgEFBQcwAQEEggULMIIFBzCBrKEvMC0xFDASBgNV\n" + + "BAoTC1NvbWVDb21wYW55MRUwEwYDVQQDEwxSb290IENBIENlcnQYDzIwMTYwOTA2\n" + + "MjEzNzIwWjBkMGIwOjAJBgUrDgMCGgUABBTI7Z9OmsAFKpeCV8Vp5qfJxF9ctQQU\n" + + "k0yx6MTIlQH22JbJxVzO+mIxVBkCAWSAABgPMjAxNjA5MDYyMTM3MjBaoBEYDzIw\n" + + "MTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAAgs8jpuEejPD8qO\n" + + "+xckvqMz/5pItOHaSB0xyPNpIapqjcDkLktJdBVq5XJWernO9DU+P7yr7TDbvo6h\n" + + "P5jBZklLz16Z1aRlEyow2jhelVjNl6nxoiij/6LOGK4tLHa8fK7hTB4Ykw22Bxzt\n" + + "LcbrU5jgUDhdZkTrs+rWM8nw7mVWIQYQfwzCMDZ5a02MxzhdwggJGRzqMrbhY/Q7\n" + + "RRUK3ohSgzHmLjVkvA0KeM/Px7EefzbEbww08fSsLybmBoIEbcckWSHkkXx4cuIR\n" + + "T9FiTz4Ms4r8qzPCo61qeklE2I5lfnfieROADV6sfwbul/0U1HqKhHVaxJ8yYw+T\n" + + "/FMxrUKgggNAMIIDPDCCAzgwggIgoAMCAQICAQEwDQYJKoZIhvcNAQELBQAwLTEU\n" + + "MBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0EgQ2VydDAeFw0x\n" + + "NjA3MDgyMTM3MThaFw0xOTA2MjgyMTM3MThaMC0xFDASBgNVBAoTC1NvbWVDb21w\n" + + "YW55MRUwEwYDVQQDEwxSb290IENBIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" + + "DwAwggEKAoIBAQCJTTN1mBKpFNnpVxGa1fUEg2wysMmixB2nyxXIh/BHaGoN6v+4\n" + + "xMxScSOyWfN9bXW1kAZuh4KPvKb3rThVtQXJC/HiI8jjjT9ginxWnjGqM7FotXIM\n" + + "Wvq46VP0XpHPswar78uEq/e08E+p0Ii5YIwtZwn0dUlaTudaqAwoUu5+/Oa7ChGc\n" + + "cP6fpJFVkmX31O8zfXOuOXD4P/y/5I4snijJGqrhkDmEuvIEIMvGGV0L9RN5f/Hv\n" + + "AotbNQ2AOcKQm2gaoE8POEa+M5VBEAYF80JUbfpj83mg6XRtRHhpF63HZGftBDBC\n" + + "6DlVzhJ+lTbM+r09yCq570AUpzdOsav4lsAtAgMBAAGjYzBhMA8GA1UdEwEB/wQF\n" + + "MAMBAf8wHwYDVR0jBBgwFoAUk0yx6MTIlQH22JbJxVzO+mIxVBkwHQYDVR0OBBYE\n" + + "FJNMsejEyJUB9tiWycVczvpiMVQZMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0B\n" + + "AQsFAAOCAQEAAIvjZbMT/bdiIYmSB0SRkgWbkJVyI8GCMG6t2VnPwKWftKMbZew2\n" + + "EIubkTbfP6KXBjQh3CGNHxvd0m5A7m128T2AVug/0VI28+fWa8mj+cpueadTIx0z\n" + + "qsvgDPIONcTUyYpHN1FBV153JHhW2sIowrG+73+9aMMyrsYAV4vZ9a5l17Z3CqAP\n" + + "y61FV6FJSnn3YA57FLJd0NvXomxNx0qs4jDKADi5tI43pBRliIC3k7ckWEdXdHTW\n" + + "lMLB060KT48cVE59cbAD6Vyn8z57GAGXnommhO+RsG1pR86zYp78XWUHdM3LaXwS\n" + + "X1ag//pVgDZcPqzmiidhsgmiSDbMmiPyNg=="; + + // Do path validation as if it is always Tue, 06 Sep 2016 22:12:21 GMT + // This value is within the lifetimes of all certificates and both OCSP + // responses. + private static final Date EVAL_DATE = new Date(1473199941000L); + + private static final Base64.Decoder DECODER = Base64.getMimeDecoder(); + + public static void main(String[] args) throws Exception { + TrustAnchor anchor; + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + X509Certificate rootCert = generateCertificate(cf, ROOT_CA_CERT); + X509Certificate eeCert = generateCertificate(cf, EE_CERT); + X509Certificate intCaCert = generateCertificate(cf, INT_CA_CERT); + List certList = new ArrayList() {{ + add(eeCert); + add(intCaCert); + }}; + + System.out.println("==== Certificate Path ====="); + for (X509Certificate c : certList) { + System.out.println(c + "\n"); + } + System.out.println("==========================="); + + System.out.println("===== Test 1: TA(X509Certificate) ====="); + anchor = new TrustAnchor(rootCert, null); + runTest(cf, certList, anchor); + + System.out.println("===== Test 2: TA(X500Principal, PublicKey ====="); + anchor = new TrustAnchor(rootCert.getSubjectX500Principal(), + rootCert.getPublicKey(), null); + runTest(cf, certList, anchor); + + System.out.println("===== Test 3: TA(String, PublicKey ====="); + anchor = new TrustAnchor(rootCert.getSubjectX500Principal().getName(), + rootCert.getPublicKey(), null); + runTest(cf, certList, anchor); + } + + private static void runTest(CertificateFactory cf, + List certList, TrustAnchor anchor) + throws Exception { + CertPath path = cf.generateCertPath(certList); + CertPathValidator validator = CertPathValidator.getInstance("PKIX"); + + System.out.println(anchor); + + // Attach the OCSP responses to a PKIXParameters object + PKIXRevocationChecker pkrev = + (PKIXRevocationChecker)validator.getRevocationChecker(); + Map responseMap = new HashMap<>(); + responseMap.put(certList.get(0), DECODER.decode(EE_OCSP_RESP)); + responseMap.put(certList.get(1), DECODER.decode(INT_CA_OCSP_RESP)); + pkrev.setOcspResponses(responseMap); + PKIXParameters params = + new PKIXParameters(Collections.singleton(anchor)); + params.addCertPathChecker(pkrev); + params.setDate(EVAL_DATE); + + validator.validate(path, params); + } + + private static X509Certificate generateCertificate(CertificateFactory cf, + String encoded) throws CertificateException { + ByteArrayInputStream is = new ByteArrayInputStream(encoded.getBytes()); + return (X509Certificate)cf.generateCertificate(is); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/sql/testng/TEST.properties --- a/jdk/test/java/sql/testng/TEST.properties Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/sql/testng/TEST.properties Fri Sep 16 13:15:01 2016 -0700 @@ -1,3 +1,4 @@ # JDBC unit tests uses TestNG TestNG.dirs = . +othervm.dirs = test/sql/othervm diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/sql/testng/test/sql/othervm/DriverManagerInitTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/sql/testng/test/sql/othervm/DriverManagerInitTests.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.sql.othervm; + +import java.io.BufferedReader; +import java.io.CharArrayReader; +import java.io.CharArrayWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.Driver; +import java.sql.DriverManager; +import java.util.Enumeration; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.testng.Assert.*; +import org.testng.annotations.Test; + +public class DriverManagerInitTests { + + /** + * Validate that when DriverManager loads the initial JDBC drivers, that the + * output from DriverManager.println is available by verifying that the + * String "JDBC DriverManager initialized" is found + */ + @Test + public void test() { + + CharArrayWriter cw = new CharArrayWriter(); + PrintWriter pw = new PrintWriter(cw); + DriverManager.setLogWriter(pw); + Enumeration drivers = DriverManager.getDrivers(); + + try (BufferedReader reader = new BufferedReader(new CharArrayReader(cw.toCharArray()))) { + boolean result + = reader.lines().anyMatch( + line -> line.matches(".*JDBC DriverManager initialized.*")); + assertTrue(result); + + } catch (IOException ex) { + Logger.getLogger(DriverManagerInitTests.class.getName()).log(Level.SEVERE, null, ex); + fail(); + } + + // Check to verify that we are not initializing a 2nd time + cw = new CharArrayWriter(); + pw = new PrintWriter(cw); + DriverManager.setLogWriter(pw); + drivers = DriverManager.getDrivers(); + + try (BufferedReader reader = new BufferedReader(new CharArrayReader(cw.toCharArray()))) { + boolean result + = reader.lines().noneMatch( + line -> line.matches(".*JDBC DriverManager initialized.*")); + assertTrue(result); + + } catch (IOException ex) { + Logger.getLogger(DriverManagerInitTests.class.getName()).log(Level.SEVERE, null, ex); + fail(); + } + + } + +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/Bug4322313.java --- a/jdk/test/java/text/Format/DateFormat/Bug4322313.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/Bug4322313.java Fri Sep 16 13:15:01 2016 -0700 @@ -50,110 +50,110 @@ Object[][] valids = { /* given ID offset format('z'), ('Z') index */ - {"GMT+03:04", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(9)}, - {"GMT+13:42", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(9)}, - {"GMT+00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, - {"GMT+1:11", new Long(-71 * mpm), "GMT+01:11", "+0111", new Integer(8)}, - {"GMT +13:42", new Long(0), "GMT", "+0000", new Integer(3)}, - {" GMT", new Long(0), "GMT", "+0000", new Integer(4)}, - {"+0304", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(5)}, - {"+1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(5)}, - {"+0000", new Long(0), "GMT+00:00", "+0000", new Integer(5)}, - {" +1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(6)}, + {"GMT+03:04", -184L * mpm, "GMT+03:04", "+0304", 9}, + {"GMT+13:42", -822L * mpm, "GMT+13:42", "+1342", 9}, + {"GMT+00:00", 0L, "GMT+00:00", "+0000", 9}, + {"GMT+1:11", -71L * mpm, "GMT+01:11", "+0111", 8}, + {"GMT +13:42", 0L, "GMT", "+0000", 3}, + {" GMT", 0L, "GMT", "+0000", 4}, + {"+0304", -184L * mpm, "GMT+03:04", "+0304", 5}, + {"+1342", -822L * mpm, "GMT+13:42", "+1342", 5}, + {"+0000", 0L, "GMT+00:00", "+0000", 5}, + {" +1342", -822L * mpm, "GMT+13:42", "+1342", 6}, /* ISO-LATIN-1 digits */ - {"GMT+\u0030\u0031:\u0032\u0033", new Long(-83 * mpm), "GMT+01:23", "+0123", new Integer(9)}, + {"GMT+\u0030\u0031:\u0032\u0033", -83L * mpm, "GMT+01:23", "+0123", 9}, /* In fact, this test case is skipped because TimeZone class can't * recognize TimeZone IDs like "+00234" or "-00234". */ - {"+00234", new Long(-23 * mpm), "GMT+00:23", "+0023", new Integer(5)}, + {"+00234", -23L * mpm, "GMT+00:23", "+0023", 5}, - {"GMT-03:04", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(9)}, - {"GMT-13:42", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(9)}, - {"GMT-00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, - {"GMT-1:11", new Long(71 * mpm), "GMT-01:11", "-0111", new Integer(8)}, - {"GMT -13:42", new Long(0), "GMT", "+0000", new Integer(3)}, - {"-0304", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(5)}, - {"-1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(5)}, - {" -1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(6)}, + {"GMT-03:04", 184L * mpm, "GMT-03:04", "-0304", 9}, + {"GMT-13:42", 822L * mpm, "GMT-13:42", "-1342", 9}, + {"GMT-00:00", 0L, "GMT+00:00", "+0000", 9}, + {"GMT-1:11", 71L * mpm, "GMT-01:11", "-0111", 8}, + {"GMT -13:42", 0L, "GMT", "+0000", 3}, + {"-0304", 184L * mpm, "GMT-03:04", "-0304", 5}, + {"-1342", 822L * mpm, "GMT-13:42", "-1342", 5}, + {" -1342", 822L * mpm, "GMT-13:42", "-1342", 6}, /* ISO-LATIN-1 digits */ - {"GMT-\u0030\u0031:\u0032\u0033", new Long(83 * mpm), "GMT-01:23", "-0123", new Integer(9)}, + {"GMT-\u0030\u0031:\u0032\u0033", 83L * mpm, "GMT-01:23", "-0123", 9}, /* In fact, this test case is skipped because TimeZone class can't * recognize TimeZone IDs like "+00234" or "-00234". */ - {"-00234", new Long(23 * mpm), "GMT+00:23", "-0023", new Integer(5)}, + {"-00234", 23L * mpm, "GMT+00:23", "-0023", 5}, }; Object[][] invalids = { /* given ID error index */ - {"GMT+8", new Integer(5)}, - {"GMT+18", new Integer(6)}, - {"GMT+208", new Integer(6)}, - {"GMT+0304", new Integer(6)}, - {"GMT+42195", new Integer(5)}, - {"GMT+5:8", new Integer(7)}, - {"GMT+23:60", new Integer(8)}, - {"GMT+11:1", new Integer(8)}, - {"GMT+24:13", new Integer(5)}, - {"GMT+421:950", new Integer(5)}, - {"GMT+0a:0A", new Integer(5)}, - {"GMT+ 13:42", new Integer(4)}, - {"GMT+13 :42", new Integer(6)}, - {"GMT+13: 42", new Integer(7)}, - {"GMT+-13:42", new Integer(4)}, - {"G M T", new Integer(0)}, - {"+8", new Integer(2)}, - {"+18", new Integer(3)}, - {"+208", new Integer(4)}, - {"+2360", new Integer(4)}, - {"+2413", new Integer(2)}, - {"+42195", new Integer(2)}, - {"+0AbC", new Integer(2)}, - {"+ 1342", new Integer(1)}, - {"+-1342", new Integer(1)}, - {"1342", new Integer(0)}, + {"GMT+8", 5}, + {"GMT+18", 6}, + {"GMT+208", 6}, + {"GMT+0304", 6}, + {"GMT+42195", 5}, + {"GMT+5:8", 7}, + {"GMT+23:60", 8}, + {"GMT+11:1", 8}, + {"GMT+24:13", 5}, + {"GMT+421:950", 5}, + {"GMT+0a:0A", 5}, + {"GMT+ 13:42", 4}, + {"GMT+13 :42", 6}, + {"GMT+13: 42", 7}, + {"GMT+-13:42", 4}, + {"G M T", 0}, + {"+8", 2}, + {"+18", 3}, + {"+208", 4}, + {"+2360", 4}, + {"+2413", 2}, + {"+42195", 2}, + {"+0AbC", 2}, + {"+ 1342", 1}, + {"+-1342", 1}, + {"1342", 0}, /* Arabic-Indic digits */ - {"GMT+\u0660\u0661:\u0662\u0663", new Integer(4)}, + {"GMT+\u0660\u0661:\u0662\u0663", 4}, /* Extended Arabic-Indic digits */ - {"GMT+\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, + {"GMT+\u06f0\u06f1:\u06f2\u06f3", 4}, /* Devanagari digits */ - {"GMT+\u0966\u0967:\u0968\u0969", new Integer(4)}, + {"GMT+\u0966\u0967:\u0968\u0969", 4}, /* Fullwidth digits */ - {"GMT+\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, + {"GMT+\uFF10\uFF11:\uFF12\uFF13", 4}, - {"GMT-8", new Integer(5)}, - {"GMT-18", new Integer(6)}, - {"GMT-208", new Integer(6)}, - {"GMT-0304", new Integer(6)}, - {"GMT-42195", new Integer(5)}, - {"GMT-5:8", new Integer(7)}, - {"GMT-23:60", new Integer(8)}, - {"GMT-11:1", new Integer(8)}, - {"GMT-24:13", new Integer(5)}, - {"GMT-421:950", new Integer(5)}, - {"GMT-0a:0A", new Integer(5)}, - {"GMT- 13:42", new Integer(4)}, - {"GMT-13 :42", new Integer(6)}, - {"GMT-13: 42", new Integer(7)}, - {"GMT-+13:42", new Integer(4)}, - {"-8", new Integer(2)}, - {"-18", new Integer(3)}, - {"-208", new Integer(4)}, - {"-2360", new Integer(4)}, - {"-2413", new Integer(2)}, - {"-42195", new Integer(2)}, - {"-0AbC", new Integer(2)}, - {"- 1342", new Integer(1)}, - {"--1342", new Integer(1)}, - {"-802", new Integer(2)}, + {"GMT-8", 5}, + {"GMT-18", 6}, + {"GMT-208", 6}, + {"GMT-0304", 6}, + {"GMT-42195", 5}, + {"GMT-5:8", 7}, + {"GMT-23:60", 8}, + {"GMT-11:1", 8}, + {"GMT-24:13", 5}, + {"GMT-421:950", 5}, + {"GMT-0a:0A", 5}, + {"GMT- 13:42", 4}, + {"GMT-13 :42", 6}, + {"GMT-13: 42", 7}, + {"GMT-+13:42", 4}, + {"-8", 2}, + {"-18", 3}, + {"-208", 4}, + {"-2360", 4}, + {"-2413", 2}, + {"-42195", 2}, + {"-0AbC", 2}, + {"- 1342", 1}, + {"--1342", 1}, + {"-802", 2}, /* Arabic-Indic digits */ - {"GMT-\u0660\u0661:\u0662\u0663", new Integer(4)}, + {"GMT-\u0660\u0661:\u0662\u0663", 4}, /* Extended Arabic-Indic digits */ - {"GMT-\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, + {"GMT-\u06f0\u06f1:\u06f2\u06f3", 4}, /* Devanagari digits */ - {"GMT-\u0966\u0967:\u0968\u0969", new Integer(4)}, + {"GMT-\u0966\u0967:\u0968\u0969", 4}, /* Fullwidth digits */ - {"GMT-\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, + {"GMT-\uFF10\uFF11:\uFF12\uFF13", 4}, }; try { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/Bug4736959.java --- a/jdk/test/java/text/Format/DateFormat/Bug4736959.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/Bug4736959.java Fri Sep 16 13:15:01 2016 -0700 @@ -30,6 +30,7 @@ import java.text.*; import java.util.*; +@SuppressWarnings("deprecation") public class Bug4736959 { /** * 4736959: JSpinner won't work for AM/PM field diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/Bug4823811.java --- a/jdk/test/java/text/Format/DateFormat/Bug4823811.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/Bug4823811.java Fri Sep 16 13:15:01 2016 -0700 @@ -685,8 +685,8 @@ testNumberFormatFormatting(nfEG, -456, "456-", "ar_EG"); System.out.println("*** DecimalFormat.parse test in ar_EG"); - testNumberFormatParsing(nfEG, "123-", new Long(-123), "ar_EG"); - testNumberFormatParsing(nfEG, "123--", new Long(-123), "ar_EG"); + testNumberFormatParsing(nfEG, "123-", -123L, "ar_EG"); + testNumberFormatParsing(nfEG, "123--",-123L, "ar_EG"); testNumberFormatParsingCheckException(nfEG, "-123", 0, "ar_EG"); System.out.println("*** DecimalFormat.format test in en_US"); @@ -694,8 +694,8 @@ testNumberFormatFormatting(nfUS, -456, "-456", "en_US"); System.out.println("*** DecimalFormat.parse test in en_US"); - testNumberFormatParsing(nfUS, "123-", new Long(123), "en_US"); - testNumberFormatParsing(nfUS, "-123", new Long(-123), "en_US"); + testNumberFormatParsing(nfUS, "123-", 123L, "en_US"); + testNumberFormatParsing(nfUS, "-123",-123L, "en_US"); testNumberFormatParsingCheckException(nfUS, "--123", 0, "en_US"); } diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/Bug4845901.java --- a/jdk/test/java/text/Format/DateFormat/Bug4845901.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/Bug4845901.java Fri Sep 16 13:15:01 2016 -0700 @@ -55,6 +55,7 @@ } } + @SuppressWarnings("deprecation") static void testParse(SimpleDateFormat sdf, String str, int expectedHour) { try { Date parsedDate = sdf.parse(str); diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/Bug6609750.java --- a/jdk/test/java/text/Format/DateFormat/Bug6609750.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/Bug6609750.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ Locale defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.US); + @SuppressWarnings("deprecation") Date[] dates = { new Date(9-1900, Calendar.JUNE, 12), new Date(99-1900, Calendar.JUNE, 12), diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/Bug6683975.java --- a/jdk/test/java/text/Format/DateFormat/Bug6683975.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/Bug6683975.java Fri Sep 16 13:15:01 2016 -0700 @@ -66,6 +66,7 @@ System.err.println("\tth_TH: " + str_th_TH); } + @SuppressWarnings("deprecation") Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0); str_th = df_th.format(date); if (!expected_th[style].equals(str_th)) { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/DateFormatRegression.java --- a/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java Fri Sep 16 13:15:01 2016 -0700 @@ -41,7 +41,7 @@ } public void Test4029195() { - + @SuppressWarnings("deprecation") Date today = new Date(); logln("today: " + today); @@ -74,19 +74,20 @@ public void Test4052408() { DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US); + @SuppressWarnings("deprecation") Date date = new Date(97, Calendar.MAY, 3, 8, 55); String str; logln(str = fmt.format(date)); if (!str.equals("5/3/97 8:55 AM")) errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str); - Hashtable expected = new Hashtable(); - expected.put(new Integer(DateFormat.MONTH_FIELD), "5"); - expected.put(new Integer(DateFormat.DATE_FIELD), "3"); - expected.put(new Integer(DateFormat.YEAR_FIELD), "97"); - expected.put(new Integer(DateFormat.HOUR1_FIELD), "8"); - expected.put(new Integer(DateFormat.MINUTE_FIELD), "55"); - expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM"); + Map expected = new HashMap<>(); + expected.put(DateFormat.MONTH_FIELD, "5"); + expected.put(DateFormat.DATE_FIELD, "3"); + expected.put(DateFormat.YEAR_FIELD, "97"); + expected.put(DateFormat.HOUR1_FIELD, "8"); + expected.put(DateFormat.MINUTE_FIELD, "55"); + expected.put(DateFormat.AM_PM_FIELD, "AM"); StringBuffer buf = new StringBuffer(); String fieldNames[] = { @@ -120,7 +121,7 @@ ", \"" + str + "\", " + pos.getBeginIndex() + ", " + pos.getEndIndex()); - String exp = (String) expected.get(new Integer(i)); + String exp = expected.get(i); if ((exp == null && str.length() == 0) || str.equals(exp)) logln(" ok"); @@ -135,6 +136,7 @@ /** * Verify the function of the [s|g]et2DigitYearStart() API. */ + @SuppressWarnings("deprecation") public void Test4056591() { try { SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US); @@ -255,6 +257,7 @@ if (!ok) errln("Fail: Lenient not working"); } + @SuppressWarnings("deprecation") public void Test4065240() { Date curDate; DateFormat shortdate, fulldate; @@ -297,6 +300,7 @@ Currently this bug breaks MessageFormat.toPattern */ + @SuppressWarnings("deprecation") public void Test4071441() { DateFormat fmtA = DateFormat.getInstance(); DateFormat fmtB = DateFormat.getInstance(); @@ -488,6 +492,7 @@ public void Test4101483() { SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US); FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD); + @SuppressWarnings("deprecation") Date d= new Date(9234567890L); StringBuffer buf = new StringBuffer(""); logln(sdf.format(d, buf, fp).toString()); @@ -508,6 +513,7 @@ public void Test4103340() { // choose a date that is the FIRST of some month // and some arbitrary time + @SuppressWarnings("deprecation") Date d=new Date(97, 3, 1, 1, 1, 1); SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US); @@ -538,6 +544,7 @@ sdf.applyPattern(pattern); logln("pattern: \"" + pattern + "\""); + @SuppressWarnings("deprecation") Object[] DATA = { "time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30), "time 10:x", new ParsePosition(0), null, @@ -698,6 +705,7 @@ String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'"; logln("pattern=" + pattern); SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US); + @SuppressWarnings("deprecation") String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0)); if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) { errln("Fail: result=" + result); @@ -711,6 +719,7 @@ * 'z' at end of date format throws index exception in SimpleDateFormat * CANNOT REPRODUCE THIS BUG ON 1.2FCS */ + @SuppressWarnings("deprecation") public void Test4151706() { SimpleDateFormat fmt = new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US); @@ -755,6 +764,7 @@ * Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US * as "EST" or "CST", not Australian "EST" and "CST". */ + @SuppressWarnings("deprecation") public void Test4406615() { Locale savedLocale = Locale.getDefault(); TimeZone savedTimeZone = TimeZone.getDefault(); @@ -823,6 +833,7 @@ * greater than "99", are treated as literal years. So "1/2/3456" * becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC. */ + @SuppressWarnings("deprecation") Object[] DATA = { "02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29), "01/23/01", new Date(2001-1900, Calendar.JANUARY, 23), @@ -878,6 +889,7 @@ DateFormat fmt = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(Locale.US)); fmt.getCalendar().setLenient(false); + @SuppressWarnings("deprecation") Date d = new Date(2000-1900, Calendar.FEBRUARY, 29); String s = fmt.format(d); logln(d + " x " + pattern + " => " + s); @@ -957,6 +969,7 @@ } } + @SuppressWarnings("deprecation") public void Test4253490() throws ParseException { SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US); @@ -1026,6 +1039,7 @@ public void Test4250359() { DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US); + @SuppressWarnings("deprecation") Date d = new Date(1999-1900, Calendar.DECEMBER, 25, 1, 2, 3); String s = df.format(d); @@ -1052,6 +1066,7 @@ // pick up another time zone when L10N is done to that file. TimeZone.setDefault(TimeZone.getTimeZone("PST")); SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN); + @SuppressWarnings("deprecation") String result = fmt.format(new Date(1999, 0, 1)); logln("format()=>" + result); if (!result.endsWith("PST")) { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java --- a/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -104,7 +104,7 @@ String pat = null; Date date = null; - Vector newArgs = new Vector(); + List newArgs = new ArrayList<>(); for (int i=0; i#.###E00", 'm'); - test(new Double(1234), "

1.234E03"); - test(new Double(0.1234), "

1.234Em01"); - test(new Double(-1234), "m

1.234E03"); - test(new Double(-0.1234), "m

1.234Em01"); + test(1234D, "

1.234E03"); + test(0.1234, "

1.234Em01"); + test(-1234D, "m

1.234E03"); + test(-0.1234, "m

1.234Em01"); prepareFormatter("

#.###E00;#.###E00", 'm'); - test(new Double(1234), "

1.234E03"); - test(new Double(0.1234), "

1.234Em01"); - test(new Double(-1234), "1.234E03"); - test(new Double(-0.1234), "1.234Em01"); + test(1234D, "

1.234E03"); + test(0.1234, "

1.234Em01"); + test(-1234D, "1.234E03"); + test(-0.1234, "1.234Em01"); prepareFormatter("#.###E00;

#.###E00", 'm'); - test(new Double(1234), "1.234E03"); - test(new Double(0.1234), "1.234Em01"); - test(new Double(-1234), "

1.234E03"); - test(new Double(-0.1234), "

1.234Em01"); + test(1234D, "1.234E03"); + test(0.1234, "1.234Em01"); + test(-1234D, "

1.234E03"); + test(-0.1234, "

1.234Em01"); prepareFormatter("

#.###E00;

-#.###E00", 'm'); - test(new Double(1234), "

1.234E03"); - test(new Double(0.1234), "

1.234Em01"); - test(new Double(-1234), "

m1.234E03"); - test(new Double(-0.1234), "

m1.234Em01"); + test(1234D, "

1.234E03"); + test(0.1234, "

1.234Em01"); + test(-1234D, "

m1.234E03"); + test(-0.1234, "

m1.234Em01"); - test(new Double(Double.POSITIVE_INFINITY), "

\u221e"); - test(new Double(Double.NEGATIVE_INFINITY), "

m\u221e"); - test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix - test(new Double(0.0), "

0E00"); - test(new Double(-0.0), "

m0E00"); // with the minus sign + test(Double.POSITIVE_INFINITY, "

\u221e"); + test(Double.NEGATIVE_INFINITY, "

m\u221e"); + test(Double.NaN, "\ufffd"); // without prefix and suffix + test(0.0, "

0E00"); + test(-0.0, "

m0E00"); // with the minus sign } static void test_BigDecimal() { @@ -151,19 +151,19 @@ dfs = df.getDecimalFormatSymbols(); /* Test with default pattern */ - test(new Long(123456789), "123,456,789"); - test(new Long(-123456789), "-123,456,789"); + test(123456789L, "123,456,789"); + test(-123456789L, "-123,456,789"); - test(new Long(0), "0"); - test(new Long(-0), "0"); + test(0L, "0"); + test(-0L, "0"); /* Specify a pattern and the minus sign. */ prepareFormatter("

#,###;

-#,###", 'm'); - test(new Long(123456789), "

123,456,789"); - test(new Long(-123456789), "

m123,456,789"); + test(123456789L, "

123,456,789"); + test(-123456789L, "

m123,456,789"); - test(new Long(0), "

0"); - test(new Long(-0), "

0"); + test(0L, "

0"); + test(-0L, "

0"); } static void test_BigInteger() { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/NumberFormat/Bug4944439.java --- a/jdk/test/java/text/Format/NumberFormat/Bug4944439.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/NumberFormat/Bug4944439.java Fri Sep 16 13:15:01 2016 -0700 @@ -84,7 +84,7 @@ } int index = s.indexOf('.'); - Long l = new Long(s.substring(0, index)); + Long l = Long.valueOf(s.substring(0, index)); if (!l.equals(number)) { err = true; System.err.println("Failed: DecimalFormat.parse(" + s + @@ -101,7 +101,7 @@ number.getClass().getName()); } - Double d = new Double(s); + Double d = Double.valueOf(s); if (!d.equals(number)) { err = true; System.err.println("Failed: DecimalFormat.parse(" + s + diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/NumberFormat/Bug4990596.java --- a/jdk/test/java/text/Format/NumberFormat/Bug4990596.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/NumberFormat/Bug4990596.java Fri Sep 16 13:15:01 2016 -0700 @@ -35,6 +35,7 @@ new DecimalFormat().format(new MutableInteger(0)); } + @SuppressWarnings("serial") public static class MutableInteger extends Number { public int value; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/NumberFormat/Bug6278616.java --- a/jdk/test/java/text/Format/NumberFormat/Bug6278616.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/NumberFormat/Bug6278616.java Fri Sep 16 13:15:01 2016 -0700 @@ -47,7 +47,7 @@ NumberFormat nf = NumberFormat.getInstance(); for (int j = 0; j < ints.length; j++) { - String s_i = nf.format(new Integer(ints[j])); + String s_i = nf.format(ints[j]); String s_ai = nf.format(new AtomicInteger(ints[j])); if (!s_i.equals(s_ai)) { throw new RuntimeException("format(AtomicInteger " + s_ai + @@ -57,7 +57,7 @@ } for (int j = 0; j < longs.length; j++) { - String s_l = nf.format(new Long(longs[j])); + String s_l = nf.format(longs[j]); String s_al = nf.format(new AtomicLong(longs[j])); if (!s_l.equals(s_al)) { throw new RuntimeException("format(AtomicLong " + s_al + diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/NumberFormat/NumberRegression.java --- a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java Fri Sep 16 13:15:01 2016 -0700 @@ -289,7 +289,7 @@ DecimalFormat df = new DecimalFormat(); Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0)); if (!d.toString().equals("123.55456")) { - errln("Result -> " + d.doubleValue()); + errln("Result -> " + d); } Locale.setDefault(savedLocale); } @@ -395,11 +395,11 @@ Locale.setDefault(Locale.US); DecimalFormat df = new DecimalFormat(); String str = "0.1234"; - Double d1 = new Double(str); + Double d1 = 0.1234; Double d2 = (Double) df.parse(str, new ParsePosition(0)); logln(d1.toString()); if (d2.doubleValue() != d1.doubleValue()) - errln("Bug 4095713 test failed, new double value : " + d2.doubleValue()); + errln("Bug 4095713 test failed, new double value : " + d2); Locale.setDefault(savedLocale); } @@ -870,7 +870,7 @@ DecimalFormat fmt = new DecimalFormat("#,##0.00"); StringBuffer formatted = new StringBuffer(); FieldPosition field = new FieldPosition(0); - Double num = new Double(1234.5); + Double num = 1234.5; fmt.format(num, formatted, field); if (field.getBeginIndex() != 0 && field.getEndIndex() != 5) errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex()); @@ -1416,7 +1416,7 @@ DecimalFormat fmt = new DecimalFormat("#", DecimalFormatSymbols.getInstance(Locale.US)); for (int i=0; i 0 != DATA[i] > 0) { errln("\"" + str + "\" parse(x " + fmt.getMultiplier() + ") => " + n); @@ -1637,15 +1637,15 @@ */ public void Test4217661() { Object[] DATA = { - new Double(0.001), "0", - new Double(1.001), "1", - new Double(0.006), "0.01", - new Double(1.006), "1.01", + 0.001, "0", + 1.001, "1", + 0.006, "0.01", + 1.006, "1.01", }; NumberFormat fmt = NumberFormat.getInstance(Locale.US); fmt.setMaximumFractionDigits(2); for (int i=0; i contents = parser.parse(new BufferedReader( new FileReader(file))); - Vector test = (Vector)contents.get("tests"); + List test = (List)contents.get("tests"); for (int counter = 0; counter < test.size(); counter++) { logln("creating: " + (counter / 2)); AttributedCharacterIterator iterator = - create((Hashtable)test.get(counter)); + create((Map)test.get(counter)); logln("verifying: " + (counter / 2)); - verify(iterator, (Hashtable)test.get(++counter)); + verify(iterator, (Map)test.get(++counter)); } } catch (IOException ioe) { errln("Error reading: " + ioe); } } - public void verify(AttributedCharacterIterator iterator,Hashtable table) { + @SuppressWarnings("unchecked") + public void verify(AttributedCharacterIterator iterator,Map table) { int length = Integer.parseInt((String)table.get("length")); // Verify the text @@ -185,10 +186,10 @@ for (int counter = 0; counter < length; counter++) { iterator.setIndex(counter); if (!verifyAttributes(iterator.getAttributes().keySet(), - makeAttributes((Vector)table.get(Integer. + makeAttributes((List)table.get(Integer. toString(counter))))) { errln("Attributes don't match at " + counter + " expecting " + - makeAttributes((Vector)table.get(Integer.toString + makeAttributes((List)table.get(Integer.toString (counter))) + " got " + iterator.getAttributes().keySet()); } @@ -196,10 +197,10 @@ for (int counter = length - 1; counter >= 0; counter--) { iterator.setIndex(counter); if (!verifyAttributes(iterator.getAttributes().keySet(), - makeAttributes((Vector)table.get(Integer. + makeAttributes((List)table.get(Integer. toString(counter))))) { errln("Attributes don't match at " + counter + " expecting " + - makeAttributes((Vector)table.get(Integer.toString + makeAttributes((List)table.get(Integer.toString (counter))) + " got " + iterator.getAttributes().keySet()); } @@ -207,31 +208,33 @@ verifyLimits(iterator, table); text = escapeIfNecessary((String)table.get("text")); - Vector fps = (Vector)table.get("fieldPositions"); + List fps = (List)table.get("fieldPositions"); if (fps != null) { for (int counter = 0; counter < fps.size(); counter++) { - verifyFieldPosition(counter, (Hashtable)fps.get(counter)); + verifyFieldPosition(counter,(Map)fps.get(counter)); } } } + @SuppressWarnings("unchecked") private void verifyLimits(AttributedCharacterIterator iterator, - Hashtable table) { - Vector limits = (Vector)table.get("limits"); + Map table) { + List limits = (List)table.get("limits"); if (limits != null) { for (int counter = 0; counter < limits.size(); counter++) { - verifyLimit(iterator, (Hashtable)limits.get(counter)); + verifyLimit(iterator, (Map)limits.get(counter)); } } } private void verifyLimit(AttributedCharacterIterator iterator, - Hashtable table) { + Map table) { int begin = Integer.parseInt((String)table.get("begin")); int end = Integer.parseInt((String)table.get("end")); - Set attrs = makeAttributes((Vector)table.get("attributes")); + @SuppressWarnings("unchecked") + Set attrs = makeAttributes((List)table.get("attributes")); String begin2S = (String)table.get("begin2"); int begin2 = (begin2S != null) ? Integer.parseInt(begin2S) : begin; String end2S = (String)table.get("end2"); @@ -262,9 +265,9 @@ } } - private boolean verifyAttributes(Set a, Set b) { - boolean aEmpty = (a.size() == 0); - boolean bEmpty = (b.size() == 0); + private boolean verifyAttributes(Set a, Set b) { + boolean aEmpty = a.isEmpty(); + boolean bEmpty = b.isEmpty(); if (aEmpty && bEmpty) { return true; @@ -284,14 +287,14 @@ return buffer.toString(); } - private void verifyFieldPosition(int index, Hashtable table) { + private void verifyFieldPosition(int index, Map table) { Object o = table.get("field"); int begin = Integer.parseInt((String)table.get("begin")); int end = Integer.parseInt((String)table.get("end")); if (o != null) { FieldPosition fp = new FieldPosition(((Integer) - lookupField((String)o)).intValue()); + lookupField((String)o))); verifyFieldPosition(fp, begin, end, index); } @@ -322,11 +325,11 @@ } } - public AttributedCharacterIterator create(Hashtable table) { + public AttributedCharacterIterator create(Map table) { format = (Format)createInstance((String)table.get("class"), - ((Vector)table.get("args")).toArray()); + ((List)table.get("args")).toArray()); value = createInstance((String)table.get("valueClass"), - ((Vector)table.get("valueArgs")).toArray()); + ((List)table.get("valueArgs")).toArray()); logln("Created format: " + format + " value " + value); AttributedCharacterIterator aci = format. @@ -343,11 +346,12 @@ private Object createInstance(String className, Object[] args) { if (className.equals("java.lang.reflect.Array")) { for (int counter = 0; counter < args.length; counter++) { - if (args[counter] instanceof Vector) { - Vector v = (Vector)args[counter]; + if (args[counter] instanceof List) { + @SuppressWarnings("unchecked") + List v = (List)args[counter]; args[counter] = createInstance((String)v.get(0), - ((Vector)v.get(1)).toArray()); + ((List)v.get(1)).toArray()); } } return args; @@ -361,9 +365,9 @@ } else if (className.equals("java.util.concurrent.atomic.AtomicLong")) { return new AtomicLong(Long.valueOf((String)args[0])); } else { - Class klass = lookupClass(className); - Constructor cons = klass.getConstructor( - new Class[] { String.class }); + Class klass = lookupClass(className); + Constructor cons = klass.getConstructor( + new Class[] { String.class }); Object value = cons.newInstance(args); return value; @@ -374,20 +378,20 @@ } } - private Class lookupClass(String name) throws ClassNotFoundException { + private Class lookupClass(String name) throws ClassNotFoundException { try { - Class klass = Class.forName(name); + Class klass = Class.forName(name); return klass; } catch (ClassNotFoundException e1) {} try { - Class klass = Class.forName("java.lang." + name); + Class klass = Class.forName("java.lang." + name); return klass; } catch (ClassNotFoundException e1) {} - Class klass = Class.forName("java.text." + name); + Class klass = Class.forName("java.text." + name); return klass; } @@ -397,7 +401,7 @@ try { int dotIndex = name.indexOf('.'); - Class klass = lookupClass(name.substring(0, dotIndex)); + Class klass = lookupClass(name.substring(0, dotIndex)); String fieldName = name.substring(dotIndex + 1); Field[] fields = klass.getFields(); @@ -429,8 +433,8 @@ return string; } - public Set makeAttributes(Vector names) { - HashSet set = new HashSet(Math.max(1, names.size())); + public Set makeAttributes(List names) { + Set set = new HashSet<>(Math.max(1, names.size())); for (int counter = 0; counter < names.size(); counter++) { set.add(makeAttribute((String)names.get(counter))); diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/text/Format/common/PParser.java --- a/jdk/test/java/text/Format/common/PParser.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/text/Format/common/PParser.java Fri Sep 16 13:15:01 2016 -0700 @@ -58,7 +58,7 @@ public PParser() { } - public Hashtable parse(Reader r) throws IOException { + public Map parse(Reader r) throws IOException { this.reader = r; bufferedToken = false; lineNumber = 0; @@ -91,23 +91,23 @@ } protected Object parseArray() throws IOException { - Vector array = new Vector(); - int token; + List array = new ArrayList<>(); + int token; while ((token = getToken()) != CLOSE_ARRAY) { if (token == MORE) { token = getToken(); } if (token != CLOSE_ARRAY) { - array.addElement(parseValue(token)); + array.add(parseValue(token)); } } return array; } - protected Hashtable parsePair() throws IOException { - Hashtable ht = new Hashtable(11); - int token; + protected Map parsePair() throws IOException { + Map ht = new HashMap<>(11); + int token; while ((token = getToken()) != CLOSE_PAIR) { if (token != STRING) { @@ -133,11 +133,12 @@ } protected int getToken() throws IOException { - int token = getToken(false, false); + int token = getToken(false, false); return token; } + @SuppressWarnings("fallthrough") protected int getToken(boolean wantsWS, boolean inString) throws IOException { if (bufferedToken) { @@ -225,31 +226,26 @@ throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column); } + @SuppressWarnings("unchecked") public static void dump(Object o) { if (o instanceof String) { System.out.print(o); - } else if(o instanceof Vector) { - Enumeration e = ((Vector)o).elements(); - + } else if(o instanceof List) { dump(" ("); - while (e.hasMoreElements()) { - dump(e.nextElement()); + ((List)o).forEach((l) -> { + dump(l); dump(" -- "); - } + }); dump(" )"); } else { - Hashtable ht = (Hashtable)o; - Enumeration e = ht.keys(); - + Map ht = (Map)o; dump(" {"); - while (e.hasMoreElements()) { - Object key = e.nextElement(); - - dump(key); + ht.keySet().forEach(l -> { + dump(l); dump(" = "); - dump(ht.get(key)); + dump(ht.get(l)); dump(";"); - } + }); dump(" }"); } } @@ -259,9 +255,9 @@ System.out.println("need filename"); } else { try { - FileReader fr = new FileReader(args[0]); - PParser parser = new PParser(); - Hashtable ht = parser.parse(fr); + FileReader fr = new FileReader(args[0]); + PParser parser = new PParser(); + Map ht = parser.parse(fr); dump(ht); System.out.println(); diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/util/Currency/ValidateISO4217.java --- a/jdk/test/java/util/Currency/ValidateISO4217.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/util/Currency/ValidateISO4217.java Fri Sep 16 13:15:01 2016 -0700 @@ -23,7 +23,7 @@ /* * @test * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759 - * 8039317 8074350 8074351 + * 8039317 8074350 8074351 8145952 * @summary Validate ISO 4217 data for Currency class. */ @@ -93,7 +93,7 @@ /* Codes that are obsolete, do not have related country */ static final String otherCodes = - "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CHE-CHW-CLF-COU-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR"; + "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR"; static boolean err = false; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/util/Currency/tablea1.txt --- a/jdk/test/java/util/Currency/tablea1.txt Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/util/Currency/tablea1.txt Fri Sep 16 13:15:01 2016 -0700 @@ -1,12 +1,12 @@ # # -# Amendments up until ISO 4217 AMENDMENT NUMBER 160 -# (As of 19 June 2015) +# Amendments up until ISO 4217 AMENDMENT NUMBER 162 +# (As of 30 Auguest 2016) # # Version FILEVERSION=3 -DATAVERSION=160 +DATAVERSION=162 # ISO 4217 currency data AF AFN 971 2 @@ -28,7 +28,7 @@ BH BHD 48 3 BD BDT 50 2 BB BBD 52 2 -BY BYR 974 0 +BY BYN 933 2 BE EUR 978 2 BZ BZD 84 2 BJ XOF 952 0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/util/logging/Level/CustomLevel.java --- a/jdk/test/java/util/logging/Level/CustomLevel.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/java/util/logging/Level/CustomLevel.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -22,12 +22,20 @@ */ import java.io.*; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; import java.util.*; import java.util.logging.*; /* * @test - * @bug 8026027 + * @bug 8026027 6543126 * @summary Test Level.parse to look up custom levels by name and its * localized name * @@ -41,23 +49,168 @@ private static final List levels = new ArrayList<>(); private static final String RB_NAME = "myresource"; + private static final String OTHERRB_NAME = "myresource2"; + + private static class CustomLevelReference extends WeakReference { + final String name; + final int value; + final String resourceBundleName; + public CustomLevelReference(Level level, ReferenceQueue queue) { + super(level, queue); + name = level.getName(); + value = level.intValue(); + resourceBundleName = level.getResourceBundleName(); + } + + @Override + public String toString() { + return "CustomLevelReference(\"" + name + "\", " + value + ", \"" + + resourceBundleName + "\")"; + } + + } + public static void main(String[] args) throws Exception { setupCustomLevels(); + setUpCustomLevelsOtherLoader(); // Level.parse will return the custom Level instance - ResourceBundle rb = ResourceBundle.getBundle(RB_NAME); for (Level level : levels) { + final ResourceBundle rb = getResourceBundle(level); String name = level.getName(); - if (!name.equals("WARNING") && !name.equals("INFO")) { + Level l = Level.parse(name); + if (!name.equals("WARNING") && !name.equals("INFO") + && !name.equals("SEVERE")) { // custom level whose name doesn't conflict with any standard one - checkCustomLevel(Level.parse(name), level); + checkCustomLevel(l, level); + } else if (l != Level.WARNING && l != Level.INFO && l != Level.SEVERE + || !name.equals(l.getName())) { + throw new RuntimeException("Unexpected level " + formatLevel(l)); } + System.out.println("Level.parse found expected level: " + + formatLevel(l)); String localizedName = rb.getString(level.getName()); - Level l = Level.parse(localizedName); + l = Level.parse(localizedName); if (l != level) { - throw new RuntimeException("Unexpected level " + l + " " + l.getClass()); + throw new RuntimeException("Unexpected level " + l + " " + + l.getClass() + " for " + localizedName + + " in " + rb.getBaseBundleName()); + } + } + + final long otherLevelCount = levels.stream() + .filter(CustomLevel::isCustomLoader) + .count(); + + // Now verify that custom level instances are correctly + // garbage collected when no longer referenced + ReferenceQueue queue = new ReferenceQueue<>(); + List refs = new ArrayList<>(); + List customRefs = new ArrayList<>(); + int otherLevels = 0; + while (!levels.isEmpty()) { + Level l = levels.stream().findAny().get(); + boolean isCustomLoader = isCustomLoader(l); + if (isCustomLoader) otherLevels++; + + CustomLevelReference ref = new CustomLevelReference(l, queue); + if (isCustomLoader) { + customRefs.add(ref); + } else { + refs.add(ref); + } + + // remove strong references to l + levels.remove(l); + l = null; + + // Run gc and wait for garbage collection + if (otherLevels == otherLevelCount) { + if (customRefs.size() != otherLevelCount) { + throw new RuntimeException("Test bug: customRefs.size() != " + + otherLevelCount); + } + waitForGC(customRefs, queue); } } + if (otherLevelCount != otherLevels || otherLevelCount == 0) { + throw new RuntimeException("Test bug: " + + "no or wrong count of levels loaded from custom loader"); + } + if (!customRefs.isEmpty()) { + throw new RuntimeException( + "Test bug: customRefs.size() should be empty!"); + } + while (!refs.isEmpty()) { + final Reference ref = refs.remove(0); + if (ref.get() == null) { + throw new RuntimeException("Unexpected garbage collection for " + + ref); + } + } + } + + private static void waitForGC(List customRefs, + ReferenceQueue queue) + throws InterruptedException + { + while (!customRefs.isEmpty()) { + Reference ref2; + do { + System.gc(); + Thread.sleep(100); + } while ((ref2 = queue.poll()) == null); + + // Check garbage collected reference + if (!customRefs.contains(ref2)) { + throw new RuntimeException("Unexpected reference: " + ref2); + } + CustomLevelReference ref = customRefs.remove(customRefs.indexOf(ref2)); + System.out.println(ref2 + " garbage collected"); + final String name = ref.name; + Level l; + try { + l = Level.parse(name); + if (!name.equals("SEVERE") + && !name.equals("INFO") + || !name.equals(l.getName())) { + throw new RuntimeException("Unexpected level " + + formatLevel(l)); + } else { + if (l == Level.WARNING || l == Level.INFO + || l == Level.SEVERE) { + System.out.println("Level.parse found expected level: " + + formatLevel(l)); + } else { + throw new RuntimeException("Unexpected level " + + formatLevel(l)); + } + } + } catch (IllegalArgumentException iae) { + if (!name.equals("WARNING") + && !name.equals("INFO") + && !name.equals("SEVERE")) { + System.out.println("Level.parse fired expected exception: " + + iae); + } else { + throw iae; + } + } + } + } + + private static boolean isCustomLoader(Level level) { + final ClassLoader cl = level.getClass().getClassLoader(); + return cl != null + && cl != ClassLoader.getPlatformClassLoader() + && cl != ClassLoader.getSystemClassLoader(); + } + + static ResourceBundle getResourceBundle(Level level) { + return isCustomLoader(level) + ? ResourceBundle.getBundle(OTHERRB_NAME, Locale.getDefault(), + level.getClass().getClassLoader()) + : ResourceBundle.getBundle(RB_NAME); } private static void setupCustomLevels() throws IOException { @@ -67,22 +220,53 @@ levels.add(new CustomLevel("WARNING", 1010, RB_NAME)); levels.add(new CustomLevel("INFO", 1000, RB_NAME)); } + + static void setUpCustomLevelsOtherLoader() + throws MalformedURLException, + ClassNotFoundException, NoSuchMethodException, + IllegalAccessException, InvocationTargetException + { + final String classes = System.getProperty("test.classes", + "build/classes"); + final String sources = System.getProperty("test.src", + "src"); + final URL curl = new File(classes).toURI().toURL(); + final URL surl = new File(sources).toURI().toURL(); + URLClassLoader loader = new URLClassLoader(new URL[] {curl, surl}, + ClassLoader.getPlatformClassLoader()); + Class customLevelClass = Class.forName("CustomLevel", false, loader); + Method m = customLevelClass.getMethod("setUpCustomLevelsOtherLoader", + List.class); + m.invoke(null, levels); + } + + public static void setUpCustomLevelsOtherLoader(List levels) { + levels.add(new CustomLevel("OTHEREMERGENCY", 1091, OTHERRB_NAME)); + levels.add(new CustomLevel("OTHERALERT", 1061, OTHERRB_NAME)); + levels.add(new CustomLevel("OTHERCRITICAL", 1031, OTHERRB_NAME)); + levels.add(new CustomLevel("SEVERE", 1011, OTHERRB_NAME)); + levels.add(new CustomLevel("INFO", 1000, OTHERRB_NAME)); + } + static void checkCustomLevel(Level level, Level expected) { // Level value must be the same if (!level.equals(expected)) { - throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + throw new RuntimeException(formatLevel(level) + " != " + + formatLevel(expected)); } if (!level.getName().equals(expected.getName())) { - throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + throw new RuntimeException(formatLevel(level) + " != " + + formatLevel(expected)); } // Level.parse is expected to return the custom Level if (level != expected) { - throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + throw new RuntimeException(formatLevel(level) + " != " + + formatLevel(expected)); } - ResourceBundle rb = ResourceBundle.getBundle(RB_NAME); + final ResourceBundle rb = getResourceBundle(level); String name = rb.getString(level.getName()); if (!level.getLocalizedName().equals(name)) { // must have the same localized name diff -r 07736e140bce -r 6268665d2fd7 jdk/test/java/util/logging/Level/myresource2.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/logging/Level/myresource2.properties Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,5 @@ +OTHEREMERGENCY=localized.otheremergency +OTHERALERT=localized.otheralert +OTHERCRITICAL=localized.othercritical +SEVERE=localized.severe +INFO=localized.info.2 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/imageio/ReadAbortTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/imageio/ReadAbortTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2016, 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 4924727 + * @summary Test verifies that if we call ImageReader.abort() in + * IIOReadProgressListener.imageStarted() or + * IIOReadProgressListener.imageProgress() are we + * calling IIOReadProgressListener.readAborted() for all readers. + * @run main ReadAbortTest + */ +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.Iterator; +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.event.IIOReadProgressListener; +import javax.imageio.stream.ImageInputStream; +import java.awt.Color; +import java.awt.Graphics2D; +import java.nio.file.Files; + +public class ReadAbortTest implements IIOReadProgressListener { + + ImageReader reader = null; + ImageInputStream iis = null; + BufferedImage bimg = null; + File file; + boolean startAbort = false; + boolean startAborted = false; + boolean progressAbort = false; + boolean progressAborted = false; + Color srccolor = Color.red; + int width = 100; + int heght = 100; + + public ReadAbortTest(String format) throws Exception { + try { + System.out.println("Test for format " + format); + bimg = new BufferedImage(width, heght, + BufferedImage.TYPE_INT_RGB); + + Graphics2D g = bimg.createGraphics(); + g.setColor(srccolor); + g.fillRect(0, 0, width, heght); + g.dispose(); + + file = File.createTempFile("src_", "." + format, new File(".")); + ImageIO.write(bimg, format, file); + ImageInputStream iis = ImageIO.createImageInputStream(file); + + Iterator iter = ImageIO.getImageReaders(iis); + while (iter.hasNext()) { + reader = (ImageReader) iter.next(); + break; + } + reader.setInput(iis); + reader.addIIOReadProgressListener(this); + + // Abort reading in IIOReadProgressListener.imageStarted(). + startAbort = true; + bimg = reader.read(0); + startAbort = false; + + // Abort reading in IIOReadProgressListener.imageProgress(). + progressAbort = true; + bimg = reader.read(0); + progressAbort = false; + + iis.close(); + /* + * All abort requests from imageStarted,imageProgress and + * imageComplete from IIOReadProgressListener should be reached + * otherwise throw RuntimeException. + */ + if (!(startAborted + && progressAborted)) { + throw new RuntimeException("All IIOReadProgressListener abort" + + " requests are not processed for format " + + format); + } + } catch (Exception e) { + throw e; + } finally { + Files.delete(file.toPath()); + } + } + + /* + * Abstract methods that we need to implement from + * IIOReadProgressListener, and relevant for this test case. + */ + @Override + public void imageStarted(ImageReader source, int imageIndex) { + System.out.println("imageStarted called"); + if (startAbort) { + source.abort(); + } + } + + @Override + public void imageProgress(ImageReader source, float percentageDone) { + System.out.println("imageProgress called"); + if (progressAbort) { + source.abort(); + } + } + + @Override + public void readAborted(ImageReader source) { + System.out.println("readAborted called"); + // Verify IIOReadProgressListener.imageStarted() abort request. + if (startAbort) { + System.out.println("imageStarted aborted "); + startAborted = true; + } + + // Verify IIOReadProgressListener.imageProgress() abort request. + if (progressAbort) { + System.out.println("imageProgress aborted "); + progressAborted = true; + } + } + + public static void main(String args[]) throws Exception { + final String[] formats = {"bmp", "png", "gif", "jpg", "tif"}; + for (String format : formats) { + new ReadAbortTest(format); + } + } + + /* + * Remaining abstract methods that we need to implement from + * IIOReadProgressListener, but not relevant for this test case. + */ + @Override + public void imageComplete(ImageReader source) { + } + + @Override + public void sequenceStarted(ImageReader reader, int i) { + } + + @Override + public void sequenceComplete(ImageReader reader) { + } + + @Override + public void thumbnailStarted(ImageReader reader, int i, int i1) { + } + + @Override + public void thumbnailProgress(ImageReader reader, float f) { + } + + @Override + public void thumbnailComplete(ImageReader reader) { + } +} + diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/CipherSuite.java --- a/jdk/test/javax/net/ssl/DTLS/CipherSuite.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/CipherSuite.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -30,6 +30,7 @@ * @key intermittent * @summary Datagram Transport Layer Security (DTLS) * @modules java.base/sun.security.util + * jdk.crypto.ec * @build DTLSOverDatagram * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA * @run main/othervm CipherSuite TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSBufferOverflowUnderflowTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSBufferOverflowUnderflowTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSBufferOverflowUnderflowTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS buffer overflow and underflow status when dealing with * application data. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.base/sun.security.util + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSBufferOverflowUnderflowTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSDataExchangeTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSDataExchangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSDataExchangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSEnginesClosureTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSEnginesClosureTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSEnginesClosureTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSHandshakeTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSHandshakeTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSHandshakeWithReplicatedPacketsTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeWithReplicatedPacketsTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeWithReplicatedPacketsTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites with replicated packets check. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSHandshakeWithReplicatedPacketsTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS incorrect app data packages unwrapping. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSIncorrectAppDataTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSMFLNTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSMFLNTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSMFLNTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSMFLNTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -26,6 +26,13 @@ * @bug 8043758 * @summary Testing DTLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS DTLSNotEnabledRC4Test */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * DTLSRehandshakeWithCipherChangeTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithDataExTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithDataExTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithDataExTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * data exchange. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSSequenceNumberTest * @run main/othervm -Dtest.security.protocol=DTLS diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.java --- a/jdk/test/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS DTLSUnsupportedCiphersTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10BufferOverflowUnderflowTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10BufferOverflowUnderflowTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10BufferOverflowUnderflowTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS buffer overflow and underflow status when dealing with * application data. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10BufferOverflowUnderflowTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10DataExchangeTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10EnginesClosureTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10HandshakeTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeWithReplicatedPacketsTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeWithReplicatedPacketsTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeWithReplicatedPacketsTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites with replicated packets check. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10HandshakeWithReplicatedPacketsTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS incorrect app data packages unwrapping. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSIncorrectAppDataTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10MFLNTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10MFLNTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10MFLNTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10MFLNTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10NotEnabledRC4Test.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10NotEnabledRC4Test.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10NotEnabledRC4Test.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -26,6 +26,13 @@ * @bug 8043758 * @summary Testing DTLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 DTLSv10NotEnabledRC4Test */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing DTLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10RehandshakeTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * DTLSv10RehandshakeWithCipherChangeTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithDataExTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithDataExTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithDataExTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10RehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10SequenceNumberTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10SequenceNumberTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10SequenceNumberTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * data exchange. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10SequenceNumberTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/DTLSv10/DTLSv10UnsupportedCiphersTest.java --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10UnsupportedCiphersTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10UnsupportedCiphersTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * DTLSv10UnsupportedCiphersTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -21,18 +21,19 @@ * questions. */ -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.List; -import javax.net.ssl.SSLContext; - /* * @test * @bug 8049432 8069038 * @summary New tests for TLS property jdk.tls.client.protocols * @summary javax/net/ssl/TLS/TLSClientPropertyTest.java needs to be * updated for JDK-8061210 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm TLSClientPropertyTest NoProperty * @run main/othervm TLSClientPropertyTest SSLv3 * @run main/othervm TLSClientPropertyTest TLSv1 @@ -41,6 +42,12 @@ * @run main/othervm TLSClientPropertyTest WrongProperty */ +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.List; +import javax.net.ssl.SSLContext; + /** * Sets the property jdk.tls.client.protocols to one of this protocols: * SSLv3,TLSv1,TLSv1.1,TLSv1.2 and TLSV(invalid) or removes this diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSDataExchangeTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSDataExchangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSDataExchangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSDataExchangeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSEnginesClosureTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSEnginesClosureTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSEnginesClosureTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSEnginesClosureTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSHandshakeTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSHandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSHandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSHandshakeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSMFLNTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSMFLNTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSMFLNTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSMFLNTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSNotEnabledRC4Test.java --- a/jdk/test/javax/net/ssl/TLS/TLSNotEnabledRC4Test.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSNotEnabledRC4Test.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -26,6 +26,13 @@ * @bug 8085979 * @summary Testing TLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS TLSNotEnabledRC4Test */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSRehandshakeTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSRehandshakeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS TLSRehandshakeWithCipherChangeTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithDataExTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithDataExTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithDataExTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSRehandshakeWithDataExTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLS/TLSUnsupportedCiphersTest.java --- a/jdk/test/javax/net/ssl/TLS/TLSUnsupportedCiphersTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLS/TLSUnsupportedCiphersTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS TLSUnsupportedCiphersTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSDataExchangeTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSDataExchangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSDataExchangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSDataExchangeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSEnginesClosureTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSEnginesClosureTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSEnginesClosureTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSEnginesClosureTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSHandshakeTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSHandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSHandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSHandshakeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSMFLNTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSMFLNTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSMFLNTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSMFLNTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSNotEnabledRC4Test.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSNotEnabledRC4Test.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSNotEnabledRC4Test.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -26,6 +26,13 @@ * @bug 8085979 * @summary Testing TLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 TLSNotEnabledRC4Test */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSRehandshakeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 TLSRehandshakeWithCipherChangeTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithDataExTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithDataExTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithDataExTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSRehandshakeWithDataExTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv1/TLSUnsupportedCiphersTest.java --- a/jdk/test/javax/net/ssl/TLSv1/TLSUnsupportedCiphersTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv1/TLSUnsupportedCiphersTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 TLSUnsupportedCiphersTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java --- a/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -33,14 +33,33 @@ * @bug 4873188 * @summary Support TLS 1.1 * @run main/othervm EmptyCertificateAuthorities + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import java.security.*; -import java.security.cert.*; -import javax.net.ssl.*; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.KeyStore; +import java.security.Security; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; public class EmptyCertificateAuthorities { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java --- a/jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -33,12 +33,25 @@ * @bug 4873188 * @summary Support TLS 1.1 * @run main/othervm ExportableBlockCipher + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import javax.net.ssl.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class ExportableBlockCipher { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java --- a/jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -32,13 +32,26 @@ * @test * @bug 4873188 * @summary Support TLS 1.1 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm ExportableStreamCipher * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import javax.net.ssl.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class ExportableStreamCipher { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java --- a/jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,13 @@ * @test * @bug 4873188 * @summary Support TLS 1.1 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm GenericBlockCipher * * SunJSSE does not support dynamic system properties, no way to re-use @@ -35,9 +42,12 @@ * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import javax.net.ssl.*; +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class GenericBlockCipher { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.java --- a/jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,13 @@ * @test * @bug 4873188 * @summary Support TLS 1.1 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm GenericStreamCipher * * SunJSSE does not support dynamic system properties, no way to re-use @@ -35,9 +42,13 @@ * @author Xuelei Fan */ -import java.io.*; +import java.io.InputStream; +import java.io.OutputStream; import java.security.Security; -import javax.net.ssl.*; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class GenericStreamCipher { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSDataExchangeTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSDataExchangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSDataExchangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSDataExchangeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSEnginesClosureTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSEnginesClosureTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSEnginesClosureTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSEnginesClosureTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSHandshakeTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSHandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSHandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSHandshakeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSMFLNTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSMFLNTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSMFLNTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSMFLNTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSNotEnabledRC4Test.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSNotEnabledRC4Test.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSNotEnabledRC4Test.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -26,6 +26,13 @@ * @bug 8085979 * @summary Testing TLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 TLSNotEnabledRC4Test */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,14 @@ * @summary Testing TLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSRehandshakeTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 TLSRehandshakeWithCipherChangeTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithDataExTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithDataExTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithDataExTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSRehandshakeWithDataExTest diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/TLSv11/TLSUnsupportedCiphersTest.java --- a/jdk/test/javax/net/ssl/TLSv11/TLSUnsupportedCiphersTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/TLSv11/TLSUnsupportedCiphersTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 TLSUnsupportedCiphersTest */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java --- a/jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -21,6 +21,15 @@ * questions. */ +/* + * @test + * @bug 8076221 + * @summary Check if weak cipher suites are disabled + * @modules jdk.crypto.ec + * @run main/othervm DisabledAlgorithms default + * @run main/othervm DisabledAlgorithms empty + */ + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; @@ -36,13 +45,6 @@ import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -/** - * @test - * @bug 8076221 - * @summary Check if weak cipher suites are disabled - * @run main/othervm DisabledAlgorithms default - * @run main/othervm DisabledAlgorithms empty - */ public class DisabledAlgorithms { private static final String pathToStores = "../etc"; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/net/ssl/ciphersuites/ECCurvesconstraints.java --- a/jdk/test/javax/net/ssl/ciphersuites/ECCurvesconstraints.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/net/ssl/ciphersuites/ECCurvesconstraints.java Fri Sep 16 13:15:01 2016 -0700 @@ -32,24 +32,29 @@ * @test * @bug 8148516 * @summary Improve the default strength of EC in JDK + * @modules jdk.crypyo.ec * @run main/othervm ECCurvesconstraints PKIX * @run main/othervm ECCurvesconstraints SunX509 */ -import java.net.*; -import java.util.*; -import java.io.*; -import javax.net.ssl.*; -import java.security.Security; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; -import java.security.cert.X509Certificate; import java.security.cert.CertificateFactory; -import java.security.spec.*; -import java.security.interfaces.*; +import java.security.interfaces.ECPrivateKey; +import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; - +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManagerFactory; public class ECCurvesconstraints { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/ExceptionTest.java --- a/jdk/test/javax/script/ExceptionTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/ExceptionTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 @@ -26,10 +26,14 @@ * @bug 6474943 6705893 * @summary Test that script engine exception messages are * available from ScriptException. + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import javax.script.Compilable; +import javax.script.CompiledScript; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; public class ExceptionTest { private static final String ERROR_MSG = "error from JavaScript"; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/JavaScriptScopeTest.java --- a/jdk/test/javax/script/JavaScriptScopeTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/JavaScriptScopeTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -28,9 +28,13 @@ * get affected by default scope assignments. Also, verify * that script globals can be created and accessed from Java * as well as JavaScript. + * @modules jdk.scripting.nashorn */ -import javax.script.*; +import javax.script.Bindings; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + public class JavaScriptScopeTest { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/NullUndefinedVarTest.java --- a/jdk/test/javax/script/NullUndefinedVarTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/NullUndefinedVarTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -26,9 +26,11 @@ * @bug 6346732 6705893 * @summary should be able to assign null and undefined * value to JavaScript global variables. + * @modules jdk.scripting.nashorn */ -import javax.script.*; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class NullUndefinedVarTest { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/PluggableContextTest.java --- a/jdk/test/javax/script/PluggableContextTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/PluggableContextTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 @@ -26,9 +26,12 @@ * @bug 6398614 6705893 * @summary Create a user defined ScriptContext and check * that script can access variables from non-standard scopes + * @modules jdk.scripting.nashorn */ -import javax.script.*; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class PluggableContextTest { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test1.java --- a/jdk/test/javax/script/Test1.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test1.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -26,10 +26,13 @@ * @bug 6249843 6705893 * @summary Create JavaScript engine and execute a simple script. * Tests script engine discovery mechanism. + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test1 { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test2.java --- a/jdk/test/javax/script/Test2.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test2.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -25,10 +25,13 @@ * @test * @bug 6249843 * @summary Test exposing a Java object to script + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test2 { public static class Testobj { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test3.java --- a/jdk/test/javax/script/Test3.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test3.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -25,11 +25,17 @@ * @test * @bug 6249843 6705893 * @summary Test engine and global scopes + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.Bindings; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.SimpleBindings; public class Test3 { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test4.java --- a/jdk/test/javax/script/Test4.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test4.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -25,10 +25,14 @@ * @test * @bug 6249843 6705893 * @summary Test script functions implementing Java interface + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test4 { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test5.java --- a/jdk/test/javax/script/Test5.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test5.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -25,10 +25,18 @@ * @test * @bug 6249843 6705893 * @summary Tests engine, global scopes and scope hiding. + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.Bindings; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.SimpleBindings; +import javax.script.SimpleScriptContext; public class Test5 { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test6.java --- a/jdk/test/javax/script/Test6.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test6.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -26,10 +26,16 @@ * @bug 6249843 6705893 * @summary Test basic script compilation. Value eval'ed from * compiled and interpreted scripts should be same. + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.Compilable; +import javax.script.CompiledScript; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test6 { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test7.java --- a/jdk/test/javax/script/Test7.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test7.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -25,10 +25,14 @@ * @test * @bug 6249843 6705893 * @summary Tests importPackage and java access in script + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test7 { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/script/Test8.java --- a/jdk/test/javax/script/Test8.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/script/Test8.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -25,10 +25,14 @@ * @test * @bug 6249843 6705893 * @summary Test invoking script function or method from Java + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test8 { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/swing/JColorChooser/Test7194184.java --- a/jdk/test/javax/swing/JColorChooser/Test7194184.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/swing/JColorChooser/Test7194184.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -25,19 +25,15 @@ * Portions Copyright (c) 2012 IBM Corporation */ -/* - * @test - * @key headful - * @bug 7194184 +/* @test + @key headful + * @bug 7194184 8163274 * @summary Tests JColorChooser Swatch keyboard accessibility. - * @author Sean Chou * @library ../regtesthelpers * @build Util - * @run main Test7194184 + * @run main/timeout=500 Test7194184 */ - import java.awt.Component; -import java.awt.AWTException; import java.awt.Color; import java.awt.Robot; import java.awt.event.KeyEvent; @@ -46,66 +42,81 @@ import javax.swing.JFrame; import javax.swing.SwingUtilities; -import java.util.concurrent.Callable; +public class Test7194184 { -public class Test7194184 implements Runnable { private static JFrame frame; private static JColorChooser colorChooser; - private static Color selectedColor; + private static Color testColor; + private static Color newColor; + + private static Robot robot; public static void main(String[] args) throws Exception { - testKeyBoardAccess(); + robot = new Robot(); + robot.setAutoWaitForIdle(true); + createUI(); + accessRecentSwatch(); + runRobot(); + testColorChooser(); + cleanUpUI(); } - private static void testKeyBoardAccess() throws Exception { - Robot robot = new Robot(); - - SwingUtilities.invokeLater(new Test7194184()); - robot.waitForIdle(); - + private static void createUI() throws Exception { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - selectedColor = colorChooser.getColor(); + String title = getClass().getName(); + frame = new JFrame(title); + colorChooser = new JColorChooser(); + frame.add(colorChooser); + frame.pack(); + frame.setVisible(true); + } + }); + } + private static void accessRecentSwatch() throws Exception { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { Component recentSwatchPanel = Util.findSubComponent(colorChooser, "RecentSwatchPanel"); if (recentSwatchPanel == null) { throw new RuntimeException("RecentSwatchPanel not found"); } recentSwatchPanel.requestFocusInWindow(); + testColor = colorChooser.getColor(); + } }); + } - robot.waitForIdle(); - + private static void runRobot() { // Tab to move the focus to MainSwatch Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); - // Select the color on right Util.hitKeys(robot, KeyEvent.VK_RIGHT); Util.hitKeys(robot, KeyEvent.VK_RIGHT); Util.hitKeys(robot, KeyEvent.VK_SPACE); - robot.waitForIdle(); + } + private static void testColorChooser() throws Exception { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { - frame.dispose(); - if (selectedColor == colorChooser.getColor()) { + newColor = colorChooser.getColor(); + if (newColor == testColor) { throw new RuntimeException("JColorChooser misses keyboard accessibility"); } } }); } - public void run() { - String title = getClass().getName(); - frame = new JFrame(title); - colorChooser = new JColorChooser(); - - frame.add(colorChooser); - frame.pack(); - frame.setVisible(true); + private static void cleanUpUI() throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame.dispose(); + } + }); } - } diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/swing/JSlider/SliderTick/SliderTickTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JSlider/SliderTick/SliderTickTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2016, 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 8009477 + * @summary Verify PageUp/PageDown key moves slider to Next/Previous minor tick. + * @run main/manual SliderTickTest + */ +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.concurrent.CountDownLatch; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.JButton; +import javax.swing.JFrame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.concurrent.TimeUnit; +import javax.swing.JSlider; + +public class SliderTickTest { + + public static void main(String args[]) throws Exception { + final CountDownLatch latch = new CountDownLatch(1); + TestUI test = new TestUI(latch); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + test.createUI(); + } catch (Exception ex) { + throw new RuntimeException("Exception while creating UI"); + } + } + }); + + boolean status = latch.await(5, TimeUnit.MINUTES); + + if (!status) { + System.out.println("Test timed out."); + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + test.disposeUI(); + } catch (Exception ex) { + throw new RuntimeException("Exception while disposing UI"); + } + } + }); + + if (test.testResult == false) { + throw new RuntimeException("Test Failed."); + } + } +} + +class TestUI { + + private static JFrame mainFrame; + private static JPanel mainControlPanel; + + private static JTextArea instructionTextArea; + + private static JPanel resultButtonPanel; + private static JButton passButton; + private static JButton failButton; + + private static GridBagLayout layout; + private final CountDownLatch latch; + public boolean testResult = false; + + public TestUI(CountDownLatch latch) throws Exception { + this.latch = latch; + } + + public final void createUI() throws Exception { + + mainFrame = new JFrame("SliderTickTest"); + + layout = new GridBagLayout(); + mainControlPanel = new JPanel(layout); + resultButtonPanel = new JPanel(layout); + + GridBagConstraints gbc = new GridBagConstraints(); + + // Create Test instructions + String instructions + = "INSTRUCTIONS:" + + "\n Click PageUp/PageDown key. If the slider indicator" + + "\n moves to Next/Previous immediate minor tick, then " + + "\n test passes else failed."; + + instructionTextArea = new JTextArea(); + instructionTextArea.setText(instructions); + instructionTextArea.setEnabled(false); + instructionTextArea.setDisabledTextColor(Color.black); + instructionTextArea.setBackground(Color.white); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainControlPanel.add(instructionTextArea, gbc); + + JSlider slider = new JSlider(0, 50); + slider.setMajorTickSpacing(10); + slider.setMinorTickSpacing(2); + slider.setPaintTicks(true); + slider.setPaintLabels(true); + slider.setValue(30); + slider.setBorder(BorderFactory.createTitledBorder("Ticks")); + gbc.gridx = 0; + gbc.gridy = 1; + mainControlPanel.add(slider, gbc); + + passButton = new JButton("Pass"); + passButton.setActionCommand("Pass"); + passButton.addActionListener((ActionEvent e) -> { + testResult = true; + mainFrame.dispose(); + latch.countDown(); + + }); + failButton = new JButton("Fail"); + failButton.setActionCommand("Fail"); + failButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + testResult = false; + mainFrame.dispose(); + latch.countDown(); + } + }); + gbc.gridx = 0; + gbc.gridy = 0; + resultButtonPanel.add(passButton, gbc); + gbc.gridx = 1; + gbc.gridy = 0; + resultButtonPanel.add(failButton, gbc); + + gbc.gridx = 0; + gbc.gridy = 2; + mainControlPanel.add(resultButtonPanel, gbc); + + mainFrame.add(mainControlPanel); + mainFrame.pack(); + mainFrame.setVisible(true); + } + + public void disposeUI() { + mainFrame.setVisible(false); + mainFrame.dispose(); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java --- a/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java Fri Sep 16 13:15:01 2016 -0700 @@ -25,6 +25,7 @@ /* * @test + * @bug 8144735 * @key headful * @summary Check if a per-pixel translucent and translucent window is dragged * and resized by mouse correctly diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2016, 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.awt.BorderLayout; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.util.List; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.plaf.metal.MetalLookAndFeel; + +/* + * @test + * @bug 8163193 + * @key headful + * @summary Metal L&F gradient is lighter on HiDPI display + * @run main/othervm -Dsun.java2d.uiScale=2 ButtonGradientTest + */ +public class ButtonGradientTest { + + private static JFrame frame; + private static JButton button; + + public static void main(String[] args) throws Exception { + try { + testGradient(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void testGradient() throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(ButtonGradientTest::createAndShowGUI); + robot.waitForIdle(); + + Rectangle rect = getButtonBounds(); + List gradient = (List) UIManager.get("Button.gradient"); + float ratio = ((Number) gradient.get(0)).floatValue(); + Color c1 = (Color) gradient.get(2); + Color c2 = (Color) gradient.get(3); + int mid = (int) (ratio * rect.height); + + Color gradientColor = getGradientColor(rect.width, mid, c1, c2); + int x = rect.x + rect.width / 2; + int y = rect.y + mid / 2; + Color buttonColor = robot.getPixelColor(x, y); + + if (!similarColors(buttonColor, gradientColor)) { + throw new RuntimeException("Button gradient is changed!"); + } + } + + private static void createAndShowGUI() { + + try { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame = new JFrame(); + frame.setSize(300, 300); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new BorderLayout()); + button = new JButton(""); + panel.add(button); + frame.getContentPane().add(panel); + frame.setVisible(true); + } + + private static Rectangle getButtonBounds() throws Exception { + Rectangle[] rectangles = new Rectangle[1]; + SwingUtilities.invokeAndWait(() -> { + rectangles[0] = button.getBounds(); + rectangles[0].setLocation(button.getLocationOnScreen()); + }); + return rectangles[0]; + } + + private static Color getGradientColor(int w, int h, Color c1, Color c2) { + GradientPaint gradient = new GradientPaint(0, 0, c1, 0, h, c2, true); + BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g = img.createGraphics(); + g.setPaint(gradient); + g.fillRect(0, 0, w, h); + g.dispose(); + return new Color(img.getRGB(w / 2, h / 2)); + } + + private static boolean similarColors(Color c1, Color c2) { + return similar(c1.getRed(), c2.getRed()) + && similar(c1.getGreen(), c2.getGreen()) + && similar(c1.getBlue(), c2.getBlue()); + } + + private static boolean similar(int i1, int i2) { + return Math.abs(i2 - i1) < 7; + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/swing/text/DevanagariEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/text/DevanagariEditor.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, 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 8151725 + * @summary Tests no exception creating a JEditorPane with Devanagari + */ + +import javax.swing.JEditorPane; + +public class DevanagariEditor { + public static void main(String[] args) { + new JEditorPane().setText("\u0930\u093E\u0915\u094D\u0937\u0938"); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2011, 2016, 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 6427244 8144240 + @summary Test that pressing HOME correctly moves caret in I18N document. + @author Sergey Groznyh + @library ../../../regtesthelpers + @build JRobot Util TestCase + @run main bug6427244 +*/ + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Shape; +import java.awt.event.KeyEvent; +import javax.swing.JFrame; +import javax.swing.JTextPane; +import javax.swing.SwingUtilities; +import javax.swing.text.Position; + +public class bug6427244 extends TestCase { + private static final JRobot ROBOT = JRobot.getRobot(); + + final static int TP_SIZE = 200; + final static String[] SPACES = new String[] { + "\u0020", // ASCII space + "\u2002", // EN space + "\u2003", // EM space + "\u2004", // THREE-PER-EM space + "\u2005", // ... etc. + "\u2006", + //"\u2007", + "\u2008", + "\u2009", + "\u200a", + "\u200b", + "\u205f", + "\u3000", + }; + final static String[] WORDS = new String[] { + "It", "is", "a", "long", "paragraph", "for", "testing", "GlyphPainter2\n\n", + }; + + public static void main(String[] args) { + bug6427244 t = new bug6427244(); + for (String space: SPACES) { + t.init(space); + t.runAllTests(); + } + + System.out.println("OK"); + } + + void init(final String space) { + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + String text = null; + for (String word: WORDS) { + if (text == null) { + text = ""; + } else { + text += space; + } + text += word; + } + tp = new JTextPane(); + tp.setText(text + + "Some arabic: \u062a\u0641\u0627\u062d and some not."); + if (jf == null) { + jf = new JFrame(); + jf.setTitle("bug6427244"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jf.setSize(TP_SIZE, TP_SIZE); + jf.setVisible(true); + } + Container c = jf.getContentPane(); + c.removeAll(); + c.add(tp); + c.invalidate(); + c.validate(); + dim = c.getSize(); + } + }); + Util.blockTillDisplayed(tp); + ROBOT.waitForIdle(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + public void testCaretPosition() { + Point p = tp.getLocationOnScreen(); + // the right-top corner position + p.x += (dim.width - 5); + p.y += 5; + ROBOT.mouseMove(p.x, p.y); + ROBOT.clickMouse(); + ROBOT.hitKey(KeyEvent.VK_HOME); + ROBOT.waitForIdle(); + // this will fail if caret moves out of the 1st line. + assertEquals(0, getCaretOrdinate()); + } + + int getCaretOrdinate() { + final int[] y = new int[1]; + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Shape s; + try { + s = tp.getUI().getRootView(tp).modelToView( + tp.getCaretPosition(), tp.getBounds(), + Position.Bias.Forward); + } catch (Exception e) { + throw new RuntimeException(e); + } + y[0] = s.getBounds().y; + } + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + return y[0]; + } + + JFrame jf; + JTextPane tp; + Dimension dim; +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2016, 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 8058575 + * @summary Test that bad host classes cause exceptions to get thrown. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.base/jdk.internal.org.objectweb.asm + * @run main TestBadHostClass + */ + + +import java.lang.*; +import java.lang.reflect.Field; +import jdk.internal.misc.Unsafe; +import jdk.test.lib.unsafe.UnsafeHelper; +import jdk.internal.org.objectweb.asm.ClassWriter; +import static jdk.internal.org.objectweb.asm.Opcodes.*; + +// Test that bad host classes cause exceptions. +public class TestBadHostClass { + + private static final Unsafe unsafe = Unsafe.getUnsafe(); + + private static String packageName(Class c) { + if (c.isArray()) { + return packageName(c.getComponentType()); + } else { + String name = c.getName(); + int dot = name.lastIndexOf('.'); + if (dot == -1) return ""; + return name.substring(0, dot); + } + } + + private static int constantPoolSize(byte[] classFile) { + return ((classFile[8] & 0xFF) << 8) | (classFile[9] & 0xFF); + } + + static public void badHostClass(Class hostClass) { + // choose a class name in the same package as the host class + String className; + if (hostClass != null) { + String prefix = packageName(hostClass); + if (prefix.length() > 0) + prefix = prefix.replace('.', '/') + "/"; + className = prefix + "Anon"; + } else { + className = "Anon"; + } + + // create the class + String superName = "java/lang/Object"; + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + + ClassWriter.COMPUTE_FRAMES); + cw.visit(V1_8, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, + className, null, superName, null); + byte[] classBytes = cw.toByteArray(); + int cpPoolSize = constantPoolSize(classBytes); + Class anonClass + = unsafe.defineAnonymousClass(hostClass, classBytes, new Object[cpPoolSize]); + } + + public static void main(String args[]) throws Exception { + // host class is an array of java.lang.Objects. + try { + badHostClass(Object[].class); + } catch (IllegalArgumentException ex) { + } + + // host class is an array of objects of this class. + try { + badHostClass(TestBadHostClass[].class); + } catch (IllegalArgumentException ex) { + } + + // host class is null. + try { + badHostClass(null); + } catch (NullPointerException ex) { + } + + // host class is a primitive array class. + try { + badHostClass(int[].class); + } catch (IllegalArgumentException ex) { + } + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/jdk/internal/util/jar/TestVersionedStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2016, 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 8163798 + * @summary basic tests for multi-release jar versioned streams + * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar + * @run testng TestVersionedStream + */ + +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.net.URI; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.zip.ZipFile; + +public class TestVersionedStream { + private String userdir; + + @BeforeClass + public void initialize() { + userdir = System.getProperty("user.dir", "."); + + // These are not real class files even though they end with .class. + // They are resource files so jar tool validation won't reject them. + // But they are what we want to test, especially q/Bar.class that + // could be in a concealed package if this was a modular multi-release + // jar. + createFiles( + "base/p/Foo.class", + "base/p/Main.class", + "v9/p/Foo.class", + "v10/p/Foo.class", + "v10/q/Bar.class", + "v11/p/Foo.class" + ); + + jar("cf mmr.jar -C base . --release 9 -C v9 . --release 10 -C v10 . --release 11 -C v11 ."); + + System.out.println("Contents of mmr.jar\n======="); + jar("tf mmr.jar"); + System.out.println("======="); + } + + @AfterClass + public void close() throws IOException { + Path root = Paths.get(userdir); + Files.walkFileTree(root, new SimpleFileVisitor<>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + if (!dir.equals(root)) { + Files.delete(dir); + } + return FileVisitResult.CONTINUE; + } + }); + } + + @DataProvider + public Object[][] data() { + List p = List.of( + "META-INF/", + "META-INF/MANIFEST.MF", + "p/", + "p/Foo.class", + "p/Main.class" + ); + List q = List.of( + "META-INF/", + "META-INF/MANIFEST.MF", + "p/", + "p/Foo.class", + "p/Main.class", + "q/", + "q/Bar.class" + ); + Runtime.Version rt = JarFile.runtimeVersion(); + return new Object[][] { + {Runtime.Version.parse("8"), p}, + {Runtime.Version.parse("9"), p}, + {Runtime.Version.parse("10"), q}, + {Runtime.Version.parse("11"), q}, + {JarFile.baseVersion(), p}, + {rt, rt.major() > 9 ? q : p} + }; + } + + @Test(dataProvider="data") + public void test(Runtime.Version version, List names) throws Exception { + try (JarFile jf = new JarFile(new File("mmr.jar"), false, ZipFile.OPEN_READ, version); + Stream jes = jdk.internal.util.jar.VersionedStream.stream(jf)) + { + Assert.assertNotNull(jes); + + List entries = jes.collect(Collectors.toList()); + + // verify the correct order + List enames = entries.stream() + .map(je -> je.getName()) + .collect(Collectors.toList()); + Assert.assertEquals(enames, names); + + // verify the contents + Map contents = new HashMap<>(); + contents.put("p/Main.class", "base/p/Main.class\n"); + if (version.major() > 9) { + contents.put("q/Bar.class", "v10/q/Bar.class\n"); + } + switch (version.major()) { + case 8: + contents.put("p/Foo.class", "base/p/Foo.class\n"); + break; + case 9: + contents.put("p/Foo.class", "v9/p/Foo.class\n"); + break; + case 10: + contents.put("p/Foo.class", "v10/p/Foo.class\n"); + break; + case 11: + contents.put("p/Foo.class", "v11/p/Foo.class\n"); + break; + default: + Assert.fail("Test out of date, please add more cases"); + } + + contents.entrySet().stream().forEach(e -> { + String name = e.getKey(); + int i = enames.indexOf(name); + Assert.assertTrue(i != -1, name + " not in enames"); + JarEntry je = entries.get(i); + try (InputStream is = jf.getInputStream(je)) { + String s = new String(is.readAllBytes()); + Assert.assertTrue(s.endsWith(e.getValue()), s); + } catch (IOException x) { + throw new UncheckedIOException(x); + } + }); + } + } + + private void createFiles(String... files) { + ArrayList list = new ArrayList(); + Arrays.stream(files) + .map(f -> "file:///" + userdir + "/" + f) + .map(f -> URI.create(f)) + .filter(u -> u != null) + .map(u -> Paths.get(u)) + .forEach(p -> { + try { + Files.createDirectories(p.getParent()); + Files.createFile(p); + list.clear(); + list.add(p.toString()); + Files.write(p, list); + } catch (IOException x) { + throw new UncheckedIOException(x); + }}); + } + + private void jar(String args) { + new sun.tools.jar.Main(System.out, System.err, "jar") + .run(args.split(" +")); + } + +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/jdk/nio/zipfs/jarfs/JFSTester.java --- a/jdk/test/jdk/nio/zipfs/jarfs/JFSTester.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/jdk/nio/zipfs/jarfs/JFSTester.java Fri Sep 16 13:15:01 2016 -0700 @@ -26,6 +26,7 @@ * @bug 8164389 * @summary walk entries in a jdk.nio.zipfs.JarFileSystem * @modules jdk.jartool/sun.tools.jar + * jdk.zipfs * @run testng JFSTester */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016, 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 6947916 + * @summary JarURLConnection does not handle useCaches correctly + * @run main/othervm JarURLConnectionUseCaches + */ + +import java.io.*; +import java.net.JarURLConnection; +import java.net.URL; +import java.util.jar.*; + +public class JarURLConnectionUseCaches { + public static void main( String[] args ) throws IOException { + JarOutputStream out = new JarOutputStream( + new FileOutputStream("usecache.jar")); + out.putNextEntry(new JarEntry("test.txt")); + out.write("Test txt file".getBytes()); + out.closeEntry(); + out.close(); + + URL url = new URL("jar:" + + new File(".").toURI().toString() + + "/usecache.jar!/test.txt"); + + JarURLConnection c1 = (JarURLConnection)url.openConnection(); + c1.setDefaultUseCaches( false ); + c1.setUseCaches( true ); + c1.connect(); + + JarURLConnection c2 = (JarURLConnection)url.openConnection(); + c2.setDefaultUseCaches( false ); + c2.setUseCaches( true ); + c2.connect(); + + c1.getInputStream().close(); + c2.getInputStream().read(); + c2.getInputStream().close(); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java --- a/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -31,6 +31,7 @@ * OID and algorithm transformation string should match. * Both could be able to be used to generate the algorithm instance. * @compile ../../TestSignatureOidHelper.java + * @modules jdk.crypto.ec * @run main TestSHAwithECDSASignatureOids */ public class TestSHAwithECDSASignatureOids { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/krb5/IPv6.java --- a/jdk/test/sun/security/krb5/IPv6.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/krb5/IPv6.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, 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 @@ -25,11 +25,16 @@ * @test * @bug 6877357 6885166 * @run main/othervm IPv6 + * @modules jdk.security.auth * @summary IPv6 address does not work */ import com.sun.security.auth.module.Krb5LoginModule; -import java.io.*; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.io.StringReader; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/krb5/auto/MaxRetries.java --- a/jdk/test/sun/security/krb5/auto/MaxRetries.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/krb5/auto/MaxRetries.java Fri Sep 16 13:15:01 2016 -0700 @@ -24,7 +24,6 @@ /* * @test * @bug 6844193 - * @key intermittent * @compile -XDignore.symbol.file MaxRetries.java * @run main/othervm/timeout=300 MaxRetries * @summary support max_retries in krb5.conf diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/krb5/auto/Unreachable.java --- a/jdk/test/sun/security/krb5/auto/Unreachable.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/krb5/auto/Unreachable.java Fri Sep 16 13:15:01 2016 -0700 @@ -24,7 +24,6 @@ /* * @test * @bug 7162687 8015595 - * @key intermittent * @summary enhance KDC server availability detection * @compile -XDignore.symbol.file Unreachable.java * @run main/othervm Unreachable diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Cipher/ReinitCipher.java --- a/jdk/test/sun/security/pkcs11/Cipher/ReinitCipher.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Cipher/ReinitCipher.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReinitCipher * @run main/othervm ReinitCipher sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java --- a/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6687725 * @summary Test internal PKCS5Padding impl with various error conditions. * @author Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestPKCS5PaddingError * @run main/othervm TestPKCS5PaddingError sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java --- a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898468 6994008 * @summary basic test for RSA cipher * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRSACipher * @run main/othervm TestRSACipher sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java --- a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6572331 6994008 * @summary basic test for RSA cipher key wrapping functionality * @author Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRSACipherWrap * @run main/othervm TestRSACipherWrap sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java --- a/jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6994008 * @summary basic test for RSA/ECB/NoPadding cipher * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRawRSACipher * @run main/othervm TestRawRSACipher sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java --- a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898461 6604496 * @summary basic test for symmetric ciphers with padding * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestSymmCiphers * @run main/othervm TestSymmCiphers sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java --- a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898484 6604496 8001284 * @summary basic test for symmetric ciphers with no padding * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestSymmCiphersNoPad * @run main/othervm TestSymmCiphersNoPad sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java --- a/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,21 +21,23 @@ * questions. */ -/** +/* * @test * @bug 8072452 * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm SupportedDHKeys * @run main/othervm SupportedDHKeys sm */ import java.math.BigInteger; - -import java.security.*; -import javax.crypto.*; -import javax.crypto.interfaces.*; -import javax.crypto.spec.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.Provider; +import javax.crypto.interfaces.DHPrivateKey; +import javax.crypto.interfaces.DHPublicKey; +import javax.crypto.spec.DHParameterSpec; public class SupportedDHKeys extends PKCS11Test { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyAgreement/TestDH.java --- a/jdk/test/sun/security/pkcs11/KeyAgreement/TestDH.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/TestDH.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4921804 6324825 * @summary Verify that DH works properly * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDH * @run main/othervm TestDH sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyAgreement/TestInterop.java --- a/jdk/test/sun/security/pkcs11/KeyAgreement/TestInterop.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/TestInterop.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,11 +21,12 @@ * questions. */ -/** +/* * @test * @bug 7146728 * @summary Interop test for DH with secret that has a leading 0x00 byte * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestInterop * @run main/othervm TestInterop sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyAgreement/TestShort.java --- a/jdk/test/sun/security/pkcs11/KeyAgreement/TestShort.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/TestShort.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4942494 7146728 * @summary KAT test for DH (normal and with secret that has leading a 0x00 byte) * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestShort * @run main/othervm TestShort sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java --- a/jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,21 +21,19 @@ * questions. */ -/** +/* * @test * @bug 8072452 * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm UnsupportedDHKeys * @run main/othervm UnsupportedDHKeys sm */ -import java.math.BigInteger; - -import java.security.*; -import javax.crypto.*; -import javax.crypto.interfaces.*; -import javax.crypto.spec.*; +import java.security.InvalidParameterException; +import java.security.KeyPairGenerator; +import java.security.Provider; public class UnsupportedDHKeys extends PKCS11Test { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyGenerator/DESParity.java --- a/jdk/test/sun/security/pkcs11/KeyGenerator/DESParity.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyGenerator/DESParity.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898479 * @summary Verify that the parity bits are set correctly * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm DESParity * @run main/othervm DESParity sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java --- a/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4917233 6461727 6490213 6720456 * @summary test the KeyGenerator * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestKeyGenerator * @run main/othervm TestKeyGenerator sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java --- a/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 7196382 8072452 * @summary Ensure that DH key pairs can be generated for 512 - 8192 bits * @author Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDH2048 * @run main/othervm TestDH2048 sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Mac/MacKAT.java --- a/jdk/test/sun/security/pkcs11/Mac/MacKAT.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Mac/MacKAT.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,6 +21,17 @@ * questions. */ +/* + * @test + * @bug 4846410 6313661 4963723 + * @summary Basic known-answer-test for Hmac algorithms + * @author Andreas Sterbenz + * @library .. + * @modules jdk.crypto.pkcs11 + * @run main/othervm MacKAT + * @run main/othervm MacKAT sm + */ + import java.io.UnsupportedEncodingException; import java.security.Provider; import java.util.Arrays; @@ -30,15 +41,6 @@ import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; -/** - * @test - * @bug 4846410 6313661 4963723 - * @summary Basic known-answer-test for Hmac algorithms - * @author Andreas Sterbenz - * @library .. - * @run main/othervm MacKAT - * @run main/othervm MacKAT sm - */ public class MacKAT extends PKCS11Test { private final static byte[] ALONG, BLONG, BKEY, BKEY_20, DDDATA_50, diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Mac/MacSameTest.java --- a/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,6 +21,18 @@ * questions. */ +/* + * @test + * @bug 8048603 + * @summary Check if doFinal and update operation result in same Mac + * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin + * @library .. + * @modules jdk.crypto.pkcs11 + * @run main/othervm MacSameTest + * @run main/othervm MacSameTest sm + * @key randomness + */ + import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; @@ -30,16 +42,6 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -/** - * @test - * @bug 8048603 - * @summary Check if doFinal and update operation result in same Mac - * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin - * @library .. - * @run main/othervm MacSameTest - * @run main/othervm MacSameTest sm - * @key randomness - */ public class MacSameTest extends PKCS11Test { private static final int MESSAGE_SIZE = 25; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Mac/ReinitMac.java --- a/jdk/test/sun/security/pkcs11/Mac/ReinitMac.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Mac/ReinitMac.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReinitMac * @run main/othervm ReinitMac sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/MessageDigest/ByteBuffers.java --- a/jdk/test/sun/security/pkcs11/MessageDigest/ByteBuffers.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/MessageDigest/ByteBuffers.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test the MessageDigest.update(ByteBuffer) method * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ByteBuffers * @run main/othervm ByteBuffers sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/MessageDigest/DigestKAT.java --- a/jdk/test/sun/security/pkcs11/MessageDigest/DigestKAT.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/MessageDigest/DigestKAT.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Basic known-answer-test for all our MessageDigest algorithms * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm DigestKAT * @run main/othervm DigestKAT sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/MessageDigest/ReinitDigest.java --- a/jdk/test/sun/security/pkcs11/MessageDigest/ReinitDigest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/MessageDigest/ReinitDigest.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReinitDigest * @run main/othervm ReinitDigest sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/MessageDigest/TestCloning.java --- a/jdk/test/sun/security/pkcs11/MessageDigest/TestCloning.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/MessageDigest/TestCloning.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6414899 * @summary Ensure the cloning functionality works. * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestCloning * @run main/othervm TestCloning sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/PKCS11Test.java --- a/jdk/test/sun/security/pkcs11/PKCS11Test.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java Fri Sep 16 13:15:01 2016 -0700 @@ -82,8 +82,6 @@ System.setProperty("closed.base", CLOSED_BASE); } - static String NSPR_PREFIX = ""; - // NSS version info public static enum ECCState { None, Basic, Extended }; static double nss_version = -1; @@ -294,7 +292,6 @@ String osName = props.getProperty("os.name"); if (osName.startsWith("Win")) { osName = "Windows"; - NSPR_PREFIX = "lib"; } else if (osName.equals("Mac OS X")) { osName = "MacOSX"; } @@ -342,9 +339,9 @@ static boolean loadNSPR(String libdir) throws Exception { // load NSS softoken dependencies in advance to avoid resolver issues - safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4")); - safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4")); - safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4")); + safeReload(libdir + System.mapLibraryName("nspr4")); + safeReload(libdir + System.mapLibraryName("plc4")); + safeReload(libdir + System.mapLibraryName("plds4")); safeReload(libdir + System.mapLibraryName("sqlite3")); safeReload(libdir + System.mapLibraryName("nssutil3")); return true; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Provider/Absolute.java --- a/jdk/test/sun/security/pkcs11/Provider/Absolute.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Provider/Absolute.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -20,13 +20,16 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/** +/* * @test * @bug 7003952 7191662 * @library .. + * @modules jdk.crypto.pkcs11 * @summary load DLLs and launch executables using fully qualified path */ -import java.security.*; + +import java.security.InvalidParameterException; +import java.security.Provider; public class Absolute { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/SampleTest.java --- a/jdk/test/sun/security/pkcs11/SampleTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/SampleTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -21,20 +21,16 @@ * questions. */ -/** +/* * @test * @bug 4000000 * @summary XXX todo * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 */ -import java.io.*; -import java.util.*; - -import java.security.*; - -import javax.crypto.*; +import java.security.Provider; public class SampleTest extends PKCS11Test { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Secmod/AddPrivateKey.java --- a/jdk/test/sun/security/pkcs11/Secmod/AddPrivateKey.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Secmod/AddPrivateKey.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6414980 * @summary Test that the PKCS#11 KeyStore handles RSA, DSA, and EC keys * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm AddPrivateKey * @run main/othervm AddPrivateKey sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Secmod/AddTrustedCert.java --- a/jdk/test/sun/security/pkcs11/Secmod/AddTrustedCert.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Secmod/AddTrustedCert.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6298106 * @summary make sure we can add a trusted cert to the NSS KeyStore module * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm AddTrustedCert * @run main/othervm AddTrustedCert sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Secmod/Crypto.java --- a/jdk/test/sun/security/pkcs11/Secmod/Crypto.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Secmod/Crypto.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6329006 * @summary verify that NSS no-db mode works correctly * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm Crypto * @run main/othervm Crypto sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Secmod/GetPrivateKey.java --- a/jdk/test/sun/security/pkcs11/Secmod/GetPrivateKey.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Secmod/GetPrivateKey.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6273877 6322208 6275523 * @summary make sure we can access the NSS softtoken KeyStore * and use a private key * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm GetPrivateKey * @run main/othervm GetPrivateKey sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Secmod/JksSetPrivateKey.java --- a/jdk/test/sun/security/pkcs11/Secmod/JksSetPrivateKey.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Secmod/JksSetPrivateKey.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6269847 * @summary store a NSS PKCS11 PrivateKeyEntry to JKS KeyStore throws confusing NPE * @author Wang Weijun * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm JksSetPrivateKey * @run main/othervm JksSetPrivateKey sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Secmod/LoadKeystore.java --- a/jdk/test/sun/security/pkcs11/Secmod/LoadKeystore.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Secmod/LoadKeystore.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,6 +21,16 @@ * questions. */ +/* + * @test + * @bug 8048622 8134232 + * @summary Checks that PKCS#11 keystore can't be loaded with wrong password + * @library ../ + * @modules jdk.crypto.pkcs11 + * @run main/othervm LoadKeystore + * @run main/othervm LoadKeystore sm policy + */ + import java.io.File; import java.io.IOException; import java.security.KeyStore; @@ -30,14 +40,6 @@ import java.security.UnrecoverableKeyException; import java.util.Collections; -/* - * @test - * @bug 8048622 8134232 - * @summary Checks that PKCS#11 keystore can't be loaded with wrong password - * @library ../ - * @run main/othervm LoadKeystore - * @run main/othervm LoadKeystore sm policy - */ public class LoadKeystore extends SecmodTest { public static void main(String[] args) throws Exception { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java --- a/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6298106 6275523 6420252 8059627 * @summary make sure we can access the NSS trust anchor module * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TrustAnchors * @run main/othervm TrustAnchors sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/SecureRandom/Basic.java --- a/jdk/test/sun/security/pkcs11/SecureRandom/Basic.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/SecureRandom/Basic.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6246411 * @summary basic test for PKCS#11 SecureRandom * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm Basic * @run main/othervm Basic sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/SecureRandom/TestDeserialization.java --- a/jdk/test/sun/security/pkcs11/SecureRandom/TestDeserialization.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/SecureRandom/TestDeserialization.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -21,15 +21,22 @@ * questions. */ -/** +/* * @test * @bug 6837847 * @summary Ensure a deserialized PKCS#11 SecureRandom is functional. * @library .. + * @modules jdk.crypto.pkcs11 */ -import java.security.*; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.security.SecureRandom; +import java.security.Security; public class TestDeserialization extends PKCS11Test { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Serialize/SerializeProvider.java --- a/jdk/test/sun/security/pkcs11/Serialize/SerializeProvider.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Serialize/SerializeProvider.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -21,18 +21,22 @@ * questions. */ -/** +/* * @test * @bug 4921802 * @summary Test that the SunPKCS11 provider can be serialized * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 */ -import java.io.*; -import java.util.*; - -import java.security.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.security.Provider; +import java.security.Security; public class SerializeProvider extends PKCS11Test { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Signature/ByteBuffers.java --- a/jdk/test/sun/security/pkcs11/Signature/ByteBuffers.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Signature/ByteBuffers.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test the Signature.update(ByteBuffer) method * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ByteBuffers * @run main/othervm ByteBuffers sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Signature/ReinitSignature.java --- a/jdk/test/sun/security/pkcs11/Signature/ReinitSignature.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Signature/ReinitSignature.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary test that reinitializing Signatures works correctly * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main ReinitSignature * @run main ReinitSignature * @run main ReinitSignature @@ -330,9 +331,13 @@ * @run main ReinitSignature */ -import java.util.*; - -import java.security.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.Provider; +import java.security.PublicKey; +import java.security.Signature; +import java.util.Random; public class ReinitSignature extends PKCS11Test { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Signature/TestDSA.java --- a/jdk/test/sun/security/pkcs11/Signature/TestDSA.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Signature/TestDSA.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary basic test of SHA1withDSA and RawDSA signing/verifying * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDSA * @run main/othervm TestDSA sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Signature/TestDSAKeyLength.java --- a/jdk/test/sun/security/pkcs11/Signature/TestDSAKeyLength.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Signature/TestDSAKeyLength.java Fri Sep 16 13:15:01 2016 -0700 @@ -28,6 +28,7 @@ * with unsupported key sizes * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDSAKeyLength * @run main/othervm TestDSAKeyLength sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/Signature/TestRSAKeyLength.java --- a/jdk/test/sun/security/pkcs11/Signature/TestRSAKeyLength.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/Signature/TestRSAKeyLength.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test %W% %E% * @bug 6695485 * @summary Make sure initSign/initVerify() check RSA key lengths * @author Yu-Ching Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRSAKeyLength * @run main/othervm TestRSAKeyLength sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/ReadCertificates.java --- a/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 6414980 8051972 * @summary Make sure that we can parse certificates using various named curves @@ -29,6 +29,7 @@ * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm ReadCertificates * @run main/othervm ReadCertificates sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java --- a/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Verify that we can parse ECPrivateKeys from PKCS#12 and use them @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReadPKCS12 * @run main/othervm ReadPKCS12 sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/TestECDH.java --- a/jdk/test/sun/security/pkcs11/ec/TestECDH.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/TestECDH.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Basic known answer test for ECDH * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm TestECDH * @run main/othervm TestECDH sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/TestECDH2.java --- a/jdk/test/sun/security/pkcs11/ec/TestECDH2.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/TestECDH2.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary basic test of ECDSA signatures for P-256 and P-384 from the @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @modules java.base/sun.security.util + * jdk.crypto.pkcs11 * @compile -XDignore.symbol.file TestECDH2.java * @run main/othervm TestECDH2 * @run main/othervm TestECDH2 sm diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/TestECDSA.java --- a/jdk/test/sun/security/pkcs11/ec/TestECDSA.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/TestECDSA.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 8042967 * @summary basic test of SHA1withECDSA and NONEwithECDSA signing/verifying @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestECDSA * @run main/othervm TestECDSA sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/TestECDSA2.java --- a/jdk/test/sun/security/pkcs11/ec/TestECDSA2.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/TestECDSA2.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary basic test of ECDSA signatures for P-256 and P-384 from the @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @modules java.base/sun.security.util + * jdk.crypto.pkcs11 * @compile -XDignore.symbol.file TestECDSA2.java * @run main/othervm TestECDSA2 * @run main/othervm TestECDSA2 sm diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/TestECGenSpec.java --- a/jdk/test/sun/security/pkcs11/ec/TestECGenSpec.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/TestECGenSpec.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Verify that we can use ECGenParameterSpec * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestECGenSpec * @run main/othervm TestECGenSpec sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java --- a/jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Test the P11ECKeyFactory * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestKeyFactory * @run main/othervm TestKeyFactory sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib Binary file jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz Binary file jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256 Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,1 @@ +9d23633683ab3cea14519a22a997bc7f5d8d9664b6342df492c194966184ce0d nss-3.16-with-nspr-4.10.4.tar.gz diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz Binary file jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz has changed diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256 --- a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256 Fri Sep 16 12:09:53 2016 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -d2374795528f9cf36de07bf7c77d8c8414bb5b4da12ee7c78a57ec90d68e3706 nss-3.16_nspr-4.10_src.tar.gz diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/rsa/KeyWrap.java --- a/jdk/test/sun/security/pkcs11/rsa/KeyWrap.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/rsa/KeyWrap.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6231216 * @summary Verify key wrapping (of extractable keys) works for RSA/PKCS1 * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm KeyWrap * @run main/othervm KeyWrap sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/rsa/TestCACerts.java --- a/jdk/test/sun/security/pkcs11/rsa/TestCACerts.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/rsa/TestCACerts.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test the new RSA provider can verify all the RSA certs in the cacerts file * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm TestCACerts * @run main/othervm TestCACerts sm TestCACerts.policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/rsa/TestKeyFactory.java --- a/jdk/test/sun/security/pkcs11/rsa/TestKeyFactory.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/rsa/TestKeyFactory.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test KeyFactory of the new RSA provider * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestKeyFactory * @run main/othervm TestKeyFactory sm rsakeys.ks.policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java --- a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Verify that the RSA KeyPairGenerator works (use -Dseed=X to set PRNG seed) @@ -29,6 +29,7 @@ * @library .. * @library /lib/testlibrary * @build jdk.testlibrary.* + * @modules jdk.crypto.pkcs11 * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator * sm TestKeyPairGenerator.policy diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/rsa/TestSignatures.java --- a/jdk/test/sun/security/pkcs11/rsa/TestSignatures.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/rsa/TestSignatures.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test signing/verifying using all the signature algorithms * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestSignatures * @run main/othervm TestSignatures sm rsakeys.ks.policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java --- a/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java Fri Sep 16 13:15:01 2016 -0700 @@ -33,6 +33,7 @@ * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" * ClientJSSEServerJSSE * @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java --- a/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6316539 * @summary Known-answer-test for TlsKeyMaterial generator * @author Andreas Sterbenz * @library .. * @modules java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestKeyMaterial * @run main/othervm TestKeyMaterial sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/tls/TestLeadingZeroesP11.java --- a/jdk/test/sun/security/pkcs11/tls/TestLeadingZeroesP11.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/tls/TestLeadingZeroesP11.java Fri Sep 16 13:15:01 2016 -0700 @@ -27,6 +27,7 @@ * @summary Need to strip leading zeros in TlsPremasterSecret of DHKeyAgreement * @library .. * @author Pasi Eronen + * @modules jdk.crypto.pkcs11 * @run main/othervm TestLeadingZeroesP11 * @run main/othervm TestLeadingZeroesP11 sm */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java --- a/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6316539 * @summary Known-answer-test for TlsMasterSecret generator @@ -29,6 +29,7 @@ * @library .. * @modules java.base/sun.security.internal.interfaces * java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestMasterSecret * @run main/othervm TestMasterSecret sm TestMasterSecret.policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/tls/TestPRF.java --- a/jdk/test/sun/security/pkcs11/tls/TestPRF.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/tls/TestPRF.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6316539 6345251 * @summary Basic known-answer-test for TlsPrf * @author Andreas Sterbenz * @library .. * @modules java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestPRF * @run main/othervm TestPRF sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/pkcs11/tls/TestPremaster.java --- a/jdk/test/sun/security/pkcs11/tls/TestPremaster.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/pkcs11/tls/TestPremaster.java Fri Sep 16 13:15:01 2016 -0700 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6316539 * @summary Basic tests for TlsRsaPremasterSecret generator * @author Andreas Sterbenz * @library .. * @modules java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestPremaster * @run main/othervm TestPremaster sm policy */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java --- a/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -69,7 +69,7 @@ // make JVM process References System.gc(); // help ReferenceHandler thread enqueue References - while (TestProxy.Reference_tryHandlePending(false)) {} + while (TestProxy.Reference_waitForReferenceProcessing()) { } // help run Finalizers System.runFinalization(); } @@ -103,11 +103,11 @@ /** * A proxy for (package)private static methods: * sun.security.provider.FileInputStreamPool.getInputStream - * java.lang.ref.Reference.tryHandlePending + * java.lang.ref.Reference.waitForReferenceProcessing */ static class TestProxy { private static final Method getInputStreamMethod; - private static final Method tryHandlePendingMethod; + private static final Method waitForReferenceProcessingMethod; static { try { @@ -118,9 +118,9 @@ "getInputStream", File.class); getInputStreamMethod.setAccessible(true); - tryHandlePendingMethod = Reference.class.getDeclaredMethod( - "tryHandlePending", boolean.class); - tryHandlePendingMethod.setAccessible(true); + waitForReferenceProcessingMethod = + Reference.class.getDeclaredMethod("waitForReferenceProcessing"); + waitForReferenceProcessingMethod.setAccessible(true); } catch (Exception e) { throw new Error(e); } @@ -146,13 +146,14 @@ } } - static boolean Reference_tryHandlePending(boolean waitForNotify) { + static boolean Reference_waitForReferenceProcessing() { try { - return (boolean) tryHandlePendingMethod - .invoke(null, waitForNotify); + return (boolean) waitForReferenceProcessingMethod.invoke(null); } catch (InvocationTargetException e) { Throwable te = e.getTargetException(); - if (te instanceof RuntimeException) { + if (te instanceof InterruptedException) { + return true; + } else if (te instanceof RuntimeException) { throw (RuntimeException) te; } else if (te instanceof Error) { throw (Error) te; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java --- a/jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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,6 +83,8 @@ import java.net.*; import java.security.*; import java.nio.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class SSLEngineBadBufferArrayAccess { @@ -103,9 +105,6 @@ private static boolean debug = false; private SSLContext sslc; private SSLEngine serverEngine; // server-side SSLEngine - private SSLSocket sslSocket; // client-side socket - private ServerSocket serverSocket; // server-side Socket, generates the... - private Socket socket; // server-side socket that will read private final byte[] serverMsg = "Hi there Client, I'm a Server".getBytes(); private final byte[] clientMsg = "Hello Server, I'm a Client".getBytes(); @@ -137,6 +136,21 @@ + "/" + trustStoreFile; /* + * Is the server ready to serve? + */ + private static final CountDownLatch serverCondition = new CountDownLatch(1); + + /* + * Is the client ready to handshake? + */ + private static final CountDownLatch clientCondition = new CountDownLatch(1); + + /* + * What's the server port? Use any free port by default + */ + private volatile int serverPort = 0; + + /* * Main entry point for this test. */ public static void main(String args[]) throws Exception { @@ -171,8 +185,13 @@ char[] passphrase = "passphrase".toCharArray(); - ks.load(new FileInputStream(keyFilename), passphrase); - ts.load(new FileInputStream(trustFilename), passphrase); + try (FileInputStream fis = new FileInputStream(keyFilename)) { + ks.load(fis, passphrase); + } + + try (FileInputStream fis = new FileInputStream(trustFilename)) { + ts.load(fis, passphrase); + } KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); @@ -207,127 +226,177 @@ private void runTest(boolean direct) throws Exception { boolean serverClose = direct; - serverSocket = new ServerSocket(0); - int port = serverSocket.getLocalPort(); - Thread thread = createClientThread(port, serverClose); + ServerSocket serverSocket = new ServerSocket(0); + serverPort = serverSocket.getLocalPort(); + + // Signal the client, the server is ready to accept connection. + serverCondition.countDown(); + + Thread clientThread = runClient(serverClose); + + // Try to accept a connection in 30 seconds. + Socket socket; + try { + serverSocket.setSoTimeout(30000); + socket = (Socket) serverSocket.accept(); + } catch (SocketTimeoutException ste) { + serverSocket.close(); + + // Ignore the test case if no connection within 30 seconds. + System.out.println( + "No incoming client connection in 30 seconds. " + + "Ignore in server side."); + return; + } + + // handle the connection + try { + // Is it the expected client connection? + // + // Naughty test cases or third party routines may try to + // connection to this server port unintentionally. In + // order to mitigate the impact of unexpected client + // connections and avoid intermittent failure, it should + // be checked that the accepted connection is really linked + // to the expected client. + boolean clientIsReady = + clientCondition.await(30L, TimeUnit.SECONDS); - socket = serverSocket.accept(); + if (clientIsReady) { + // Run the application in server side. + runServerApplication(socket, direct, serverClose); + } else { // Otherwise, ignore + // We don't actually care about plain socket connections + // for TLS communication testing generally. Just ignore + // the test if the accepted connection is not linked to + // the expected client or the client connection timeout + // in 30 seconds. + System.out.println( + "The client is not the expected one or timeout. " + + "Ignore in server side."); + } + } catch (Exception e) { + System.out.println("Server died ..."); + e.printStackTrace(System.out); + serverException = e; + } finally { + socket.close(); + serverSocket.close(); + } + + clientThread.join(); + + if (clientException != null || serverException != null) { + throw new RuntimeException("Test failed"); + } + } + + /* + * Define the server side application of the test for the specified socket. + */ + void runServerApplication(Socket socket, boolean direct, + boolean serverClose) throws Exception { + socket.setSoTimeout(500); - serverSocket.close(); createSSLEngine(); createBuffers(direct); - try { - boolean closed = false; + boolean closed = false; + + InputStream is = socket.getInputStream(); + OutputStream os = socket.getOutputStream(); + + SSLEngineResult serverResult; // results from last operation + + /* + * Examining the SSLEngineResults could be much more involved, + * and may alter the overall flow of the application. + * + * For example, if we received a BUFFER_OVERFLOW when trying + * to write to the output pipe, we could reallocate a larger + * pipe, but instead we wait for the peer to drain it. + */ + byte[] inbound = new byte[8192]; + byte[] outbound = new byte[8192]; - InputStream is = socket.getInputStream(); - OutputStream os = socket.getOutputStream(); + while (!isEngineClosed(serverEngine)) { + int len = 0; + + // Inbound data + log("================"); - SSLEngineResult serverResult; // results from last operation + // Read from the Client side. + try { + len = is.read(inbound); + if (len == -1) { + throw new Exception("Unexpected EOF"); + } + cTOs.put(inbound, 0, len); + } catch (SocketTimeoutException ste) { + // swallow. Nothing yet, probably waiting on us. + System.out.println("Warning: " + ste); + } + + cTOs.flip(); - /* - * Examining the SSLEngineResults could be much more involved, - * and may alter the overall flow of the application. - * - * For example, if we received a BUFFER_OVERFLOW when trying - * to write to the output pipe, we could reallocate a larger - * pipe, but instead we wait for the peer to drain it. - */ - byte[] inbound = new byte[8192]; - byte[] outbound = new byte[8192]; + serverResult = serverEngine.unwrap(cTOs, serverIn); + log("server unwrap: ", serverResult); + runDelegatedTasks(serverResult, serverEngine); + cTOs.compact(); + + // Outbound data + log("----"); + + serverResult = serverEngine.wrap(serverOut, sTOc); + log("server wrap: ", serverResult); + runDelegatedTasks(serverResult, serverEngine); + + sTOc.flip(); + + if ((len = sTOc.remaining()) != 0) { + sTOc.get(outbound, 0, len); + os.write(outbound, 0, len); + // Give the other side a chance to process + } + + sTOc.compact(); - while (!isEngineClosed(serverEngine)) { - int len = 0; - - // Inbound data - log("================"); + if (!closed && (serverOut.remaining() == 0)) { + closed = true; - // Read from the Client side. - try { - len = is.read(inbound); - if (len == -1) { - throw new Exception("Unexpected EOF"); - } - cTOs.put(inbound, 0, len); - } catch (SocketTimeoutException ste) { - // swallow. Nothing yet, probably waiting on us. + /* + * We'll alternate initiatating the shutdown. + * When the server initiates, it will take one more + * loop, but tests the orderly shutdown. + */ + if (serverClose) { + serverEngine.closeOutbound(); + } + } + + if (closed && isEngineClosed(serverEngine)) { + serverIn.flip(); + + /* + * A sanity check to ensure we got what was sent. + */ + if (serverIn.remaining() != clientMsg.length) { + throw new Exception("Client: Data length error -" + + " IF THIS FAILS, PLEASE REPORT THIS TO THE" + + " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + + " RELIABLY DUPLICATE."); } - cTOs.flip(); - - serverResult = serverEngine.unwrap(cTOs, serverIn); - log("server unwrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); - cTOs.compact(); - - // Outbound data - log("----"); - - serverResult = serverEngine.wrap(serverOut, sTOc); - log("server wrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); - - sTOc.flip(); - - if ((len = sTOc.remaining()) != 0) { - sTOc.get(outbound, 0, len); - os.write(outbound, 0, len); - // Give the other side a chance to process - } - - sTOc.compact(); - - if (!closed && (serverOut.remaining() == 0)) { - closed = true; - - /* - * We'll alternate initiatating the shutdown. - * When the server initiates, it will take one more - * loop, but tests the orderly shutdown. - */ - if (serverClose) { - serverEngine.closeOutbound(); + for (int i = 0; i < clientMsg.length; i++) { + if (clientMsg[i] != serverIn.get()) { + throw new Exception("Client: Data content error -" + + " IF THIS FAILS, PLEASE REPORT THIS TO THE" + + " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + + " RELIABLY DUPLICATE."); } } - - if (closed && isEngineClosed(serverEngine)) { - serverIn.flip(); - - /* - * A sanity check to ensure we got what was sent. - */ - if (serverIn.remaining() != clientMsg.length) { - throw new Exception("Client: Data length error -" + - " IF THIS FAILS, PLEASE REPORT THIS TO THE" + - " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + - " RELIABLY DUPLICATE."); - } - - for (int i = 0; i < clientMsg.length; i++) { - if (clientMsg[i] != serverIn.get()) { - throw new Exception("Client: Data content error -" + - " IF THIS FAILS, PLEASE REPORT THIS TO THE" + - " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + - " RELIABLY DUPLICATE."); - } - } - serverIn.compact(); - } - } - return; - } catch (Exception e) { - serverException = e; - } finally { - socket.close(); - - // Wait for the client to join up with us. - thread.join(); - if (serverException != null) { - throw serverException; - } - if (clientException != null) { - throw clientException; + serverIn.compact(); } } } @@ -336,57 +405,114 @@ * Create a client thread which does simple SSLSocket operations. * We'll write and read one data packet. */ - private Thread createClientThread(final int port, - final boolean serverClose) throws Exception { + private Thread runClient(final boolean serverClose) + throws Exception { Thread t = new Thread("ClientThread") { @Override public void run() { try { - Thread.sleep(1000); // Give server time to finish setup. - - sslSocket = (SSLSocket) sslc.getSocketFactory(). - createSocket("localhost", port); - OutputStream os = sslSocket.getOutputStream(); - InputStream is = sslSocket.getInputStream(); - - // write(byte[]) goes in one shot. - os.write(clientMsg); - - byte[] inbound = new byte[2048]; - int pos = 0; - - int len; -done: - while ((len = is.read(inbound, pos, 2048 - pos)) != -1) { - pos += len; - // Let the client do the closing. - if ((pos == serverMsg.length) && !serverClose) { - sslSocket.close(); - break done; - } - } - - if (pos != serverMsg.length) { - throw new Exception("Client: Data length error"); - } - - for (int i = 0; i < serverMsg.length; i++) { - if (inbound[i] != serverMsg[i]) { - throw new Exception("Client: Data content error"); - } - } + doClientSide(serverClose); } catch (Exception e) { + System.out.println("Client died ..."); + e.printStackTrace(System.out); clientException = e; } } }; + t.start(); return t; } /* + * Define the client side of the test. + */ + void doClientSide(boolean serverClose) throws Exception { + // Wait for server to get started. + // + // The server side takes care of the issue if the server cannot + // get started in 90 seconds. The client side would just ignore + // the test case if the serer is not ready. + boolean serverIsReady = + serverCondition.await(90L, TimeUnit.SECONDS); + if (!serverIsReady) { + System.out.println( + "The server is not ready yet in 90 seconds. " + + "Ignore in client side."); + return; + } + + SSLSocketFactory sslsf = sslc.getSocketFactory(); + try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) { + try { + sslSocket.connect( + new InetSocketAddress("localhost", serverPort), 15000); + } catch (IOException ioe) { + // The server side may be impacted by naughty test cases or + // third party routines, and cannot accept connections. + // + // Just ignore the test if the connection cannot be + // established. + System.out.println( + "Cannot make a connection in 15 seconds. " + + "Ignore in client side."); + return; + } + + // OK, here the client and server get connected. + + // Signal the server, the client is ready to communicate. + clientCondition.countDown(); + + // There is still a chance in theory that the server thread may + // wait client-ready timeout and then quit. The chance should + // be really rare so we don't consider it until it becomes a + // real problem. + + // Run the application in client side. + runClientApplication(sslSocket, serverClose); + } + } + + /* + * Define the server side application of the test for the specified socket. + */ + void runClientApplication(SSLSocket sslSocket, boolean serverClose) + throws Exception { + + OutputStream os = sslSocket.getOutputStream(); + InputStream is = sslSocket.getInputStream(); + + // write(byte[]) goes in one shot. + os.write(clientMsg); + + byte[] inbound = new byte[2048]; + int pos = 0; + + int len; + while ((len = is.read(inbound, pos, 2048 - pos)) != -1) { + pos += len; + // Let the client do the closing. + if ((pos == serverMsg.length) && !serverClose) { + sslSocket.close(); + break; + } + } + + if (pos != serverMsg.length) { + throw new Exception("Client: Data length error"); + } + + for (int i = 0; i < serverMsg.length; i++) { + if (inbound[i] != serverMsg[i]) { + throw new Exception("Client: Data content error"); + } + } + } + + /* * Using the SSLContext created during object creation, * create/configure the SSLEngines we'll use for this test. */ diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java --- a/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java Fri Sep 16 13:15:01 2016 -0700 @@ -26,6 +26,7 @@ * @bug 8138766 * @summary New default -sigalg for keytool * @modules java.base/sun.security.tools.keytool + * @modules jdk.crypto.ec * @run main/othervm DefaultSignatureAlgorithm RSA 1024 SHA256withRSA * @run main/othervm DefaultSignatureAlgorithm RSA 3072 SHA256withRSA * @run main/othervm DefaultSignatureAlgorithm RSA 3073 SHA384withRSA diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java --- a/jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java Fri Sep 16 13:15:01 2016 -0700 @@ -23,6 +23,15 @@ * questions. */ +/* + * @test + * @bug 8134708 + * @summary Check if LDAP resources from CRLDP and AIA extensions can be loaded + * @run main/othervm ExtensionsWithLDAP CRLDP ldap.host.for.crldp + * @modules jdk.security.auth + * @run main/othervm ExtensionsWithLDAP AIA ldap.host.for.aia + */ + import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -45,13 +54,6 @@ import java.util.Set; import java.util.function.Consumer; -/* - * @test - * @bug 8134708 - * @summary Check if LDAP resources from CRLDP and AIA extensions can be loaded - * @run main/othervm ExtensionsWithLDAP CRLDP ldap.host.for.crldp - * @run main/othervm ExtensionsWithLDAP AIA ldap.host.for.aia - */ public class ExtensionsWithLDAP { /* diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java --- a/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java Fri Sep 16 13:15:01 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -21,6 +21,17 @@ * questions. */ +/* + * @test + * @bug 8049237 + * @modules java.base/sun.security.x509 + * java.base/sun.security.util + * jdk.crypto.ec + * @summary This test generates V3 certificate with all the supported + * extensions. Writes back the generated certificate in to a file and checks for + * equality with the original certificate. + */ + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -28,7 +39,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; -import static java.lang.System.out; import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -50,15 +60,8 @@ import sun.security.util.ObjectIdentifier; import sun.security.x509.*; -/** - * @test - * @bug 8049237 - * @modules java.base/sun.security.x509 - * java.base/sun.security.util - * @summary This test generates V3 certificate with all the supported - * extensions. Writes back the generated certificate in to a file and checks for - * equality with the original certificate. - */ +import static java.lang.System.out; + public class V3Certificate { public static final String V3_FILE = "certV3"; diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/text/resources/LocaleData --- a/jdk/test/sun/text/resources/LocaleData Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/text/resources/LocaleData Fri Sep 16 13:15:01 2016 -0700 @@ -6403,8 +6403,8 @@ CurrencyNames//bif=Burundian Franc CurrencyNames//bob=Bolivian Boliviano CurrencyNames//btn=Bhutanese Ngultrum -CurrencyNames//byb=Belarusian New Ruble (1994-1999) -CurrencyNames//byr=Belarusian Ruble +CurrencyNames//byb=Belarusian Ruble (1994-1999) +CurrencyNames//byr=Belarusian Ruble (2000-2016) CurrencyNames//cdf=Congolese Franc CurrencyNames//clf=Chilean Unit of Account (UF) CurrencyNames//cny=Chinese Yuan @@ -6436,7 +6436,6 @@ CurrencyNames//mro=Mauritanian Ouguiya CurrencyNames//mur=Mauritian Rupee CurrencyNames//mvr=Maldivian Rufiyaa -CurrencyNames//mwk=Malawian Kwacha CurrencyNames//mxv=Mexican Investment Unit CurrencyNames//mzm=Mozambican Metical (1980-2006) CurrencyNames//mzn=Mozambican Metical @@ -6444,7 +6443,6 @@ CurrencyNames//nio=Nicaraguan C\u00f3rdoba CurrencyNames//nlg=Dutch Guilder CurrencyNames//omr=Omani Rial -CurrencyNames//pen=Peruvian Nuevo Sol CurrencyNames//pgk=Papua New Guinean Kina CurrencyNames//pkr=Pakistani Rupee CurrencyNames//pyg=Paraguayan Guarani @@ -8287,3 +8285,11 @@ # bug #8129361 CurrencyNames//hrk=Kuna + +# bug #8164784 +CurrencyNames//mwk=Malawian Malawi Kwacha +CurrencyNames//pen=Peruvian Sol + +# bug #8145952 +CurrencyNames//byn=Belarusian Ruble +CurrencyNames/be_BY/BYN=\u0420\u0443\u0431 diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/text/resources/LocaleDataTest.java --- a/jdk/test/sun/text/resources/LocaleDataTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/text/resources/LocaleDataTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -37,7 +37,7 @@ * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 * 7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695 * 8017142 8037343 8055222 8042126 8074791 8075173 8080774 8129361 8134916 - * 8145136 + * 8145136 8145952 8164784 * @summary Verify locale data * @modules java.base/sun.util.resources * @modules jdk.localedata diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/tools/jhsdb/BasicLauncherTest.java --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -31,12 +31,10 @@ * @run main BasicLauncherTest */ -import static jdk.testlibrary.Asserts.assertTrue; - import java.io.BufferedReader; import java.io.IOException; +import java.io.OutputStream; import java.io.InputStreamReader; -import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Arrays; @@ -84,15 +82,56 @@ ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); Process toolProcess = processBuilder.start(); - toolProcess.getOutputStream().write("quit\n".getBytes()); - toolProcess.getOutputStream().close(); + + try (OutputStream out = toolProcess.getOutputStream()) { + out.write("universe\n".getBytes()); + out.write("printmdo -a\n".getBytes()); + out.write("quit\n".getBytes()); + } // By default child process output stream redirected to pipe, so we are reading it in foreground. - BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream())); + Exception unexpected = null; + try (BufferedReader reader = + new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) { + String line; + String unexpectedMsg = + "One or more of 'VirtualCallData', 'CounterData', " + + "'ReceiverTypeData', 'bci', 'MethodData' " + + "or 'java/lang/Object' not found"; + boolean knownClassFound = false; + boolean knownProfileDataTypeFound = false; + boolean knownTokensFound = false; + + while ((line = reader.readLine()) != null) { + line = line.trim(); + System.out.println(line); - String line; - while ((line = reader.readLine()) != null) { - System.out.println(line.trim()); + if (line.contains("unknown subtype of CollectedHeap")) { + unexpected = new RuntimeException("CollectedHeap type should be known."); + break; + } + else if (line.contains("missing reason for ")) { + unexpected = new RuntimeException("missing reason for "); + break; + } + if (line.contains("VirtualCallData") || + line.contains("CounterData") || + line.contains("ReceiverTypeData")) { + knownProfileDataTypeFound = true; + } + if (line.contains("bci") || + line.contains("MethodData")) { + knownTokensFound = true; + } + if (line.contains("java/lang/Object")) { + knownClassFound = true; + } + } + if ((knownClassFound == false) || + (knownTokensFound == false) || + (knownProfileDataTypeFound == false)) { + unexpected = new RuntimeException(unexpectedMsg); + } } toolProcess.waitFor(); @@ -100,6 +139,14 @@ if (toolProcess.exitValue() != 0) { throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue()); } + + if (unexpected != null) { + throw unexpected; + } + + if (unexpected != null) { + throw unexpected; + } } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { @@ -183,21 +230,6 @@ Arrays.asList(toolArgs)); } - public static void testHeapDump() throws IOException { - File dump = new File("jhsdb.jmap.dump." + - System.currentTimeMillis() + ".hprof"); - if (dump.exists()) { - dump.delete(); - } - dump.deleteOnExit(); - - launch("heap written to", null, "jmap", - "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); - - assertTrue(dump.exists() && dump.isFile(), - "Could not create dump file " + dump.getAbsolutePath()); - } - public static void main(String[] args) throws IOException { @@ -216,8 +248,6 @@ "System Properties info not available", "jinfo"); launch("java.threads", null, "jsnap"); - testHeapDump(); - // The test throws RuntimeException on error. // IOException is thrown if LingeredApp can't start because of some bad // environment condition diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/tools/jhsdb/HeapDumpTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2016, 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 8163346 + * @summary Test hashing of extended characters in Serviceability Agent. + * @library /test/lib + * @library /lib/testlibrary + * @compile -encoding utf8 HeapDumpTest.java + * @run main/timeout=240 HeapDumpTest + */ + +import static jdk.testlibrary.Asserts.assertTrue; + +import java.io.IOException; +import java.io.File; +import java.util.List; +import java.util.Arrays; +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; +import jdk.test.lib.apps.LingeredApp; +import jdk.testlibrary.Platform; + +public class HeapDumpTest { + + private static LingeredAppWithExtendedChars theApp = null; + + /** + * + * @param vmArgs - tool arguments to launch jhsdb + * @return exit code of tool + */ + public static void launch(String expectedMessage, List toolArgs) + throws IOException { + + System.out.println("Starting LingeredApp"); + try { + theApp = new LingeredAppWithExtendedChars(); + LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp); + + System.out.println(theApp.\u00CB); + System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid()); + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); + + for (String cmd : toolArgs) { + launcher.addToolArg(cmd); + } + + launcher.addToolArg("--pid=" + Long.toString(theApp.getPid())); + + ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); + processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println("stdout:"); + System.out.println(output.getStdout()); + System.out.println("stderr:"); + System.out.println(output.getStderr()); + output.shouldContain(expectedMessage); + output.shouldHaveExitValue(0); + + } catch (Exception ex) { + throw new RuntimeException("Test ERROR " + ex, ex); + } finally { + LingeredApp.stopApp(theApp); + } + } + + public static void launch(String expectedMessage, String... toolArgs) + throws IOException { + + launch(expectedMessage, Arrays.asList(toolArgs)); + } + + public static void testHeapDump() throws IOException { + File dump = new File("jhsdb.jmap.heap." + + System.currentTimeMillis() + ".hprof"); + if (dump.exists()) { + dump.delete(); + } + + launch("heap written to", "jmap", + "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); + + assertTrue(dump.exists() && dump.isFile(), + "Could not create dump file " + dump.getAbsolutePath()); + + dump.delete(); + } + + public static void main(String[] args) + throws IOException { + + if (!Platform.shouldSAAttach()) { + // Silently skip the test if we don't have enough permissions to attach + System.err.println("Error! Insufficient permissions to attach - test skipped."); + return; + } + + + testHeapDump(); + + // The test throws RuntimeException on error. + // IOException is thrown if LingeredApp can't start because of some bad + // environment condition + System.out.println("Test PASSED"); + } +} diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016, 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 jdk.test.lib.apps.LingeredApp; + +public class LingeredAppWithExtendedChars extends LingeredApp { + + public static int \u00CB = 1; + + public static void main(String args[]) { + LingeredApp.main(args); + } + } diff -r 07736e140bce -r 6268665d2fd7 jdk/test/sun/tools/jps/TestJpsJar.java --- a/jdk/test/sun/tools/jps/TestJpsJar.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/sun/tools/jps/TestJpsJar.java Fri Sep 16 13:15:01 2016 -0700 @@ -38,7 +38,7 @@ * @library /lib/testlibrary * @modules jdk.jartool/sun.tools.jar * java.management - * @build jdk.testlibrary.* JpsHelper JpsBase + * @build JpsHelper JpsBase * @run main/othervm TestJpsJar */ public class TestJpsJar { diff -r 07736e140bce -r 6268665d2fd7 jdk/test/tools/jlink/IntegrationTest.java --- a/jdk/test/tools/jlink/IntegrationTest.java Fri Sep 16 12:09:53 2016 -0500 +++ b/jdk/test/tools/jlink/IntegrationTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -210,25 +210,29 @@ props.load(reader); } - if (props.getProperty("JAVA_VERSION") == null) { - throw new AssertionError("release file does not contain JAVA_VERSION"); - } - - if (props.getProperty("OS_NAME") == null) { - throw new AssertionError("release file does not contain OS_NAME"); - } - - if (props.getProperty("OS_ARCH") == null) { - throw new AssertionError("release file does not contain OS_ARCH"); - } - - if (props.getProperty("OS_VERSION") == null) { - throw new AssertionError("release file does not contain OS_VERSION"); - } + checkReleaseProperty(props, "JAVA_VERSION"); + checkReleaseProperty(props, "JAVA_FULL_VERSION"); + checkReleaseProperty(props, "OS_NAME"); + checkReleaseProperty(props, "OS_ARCH"); + checkReleaseProperty(props, "OS_VERSION"); if (!Files.exists(output.resolve("toto.txt"))) { throw new AssertionError("Post processing not called"); } } + + static void checkReleaseProperty(Properties props, String name) { + if (! props.containsKey(name)) { + throw new AssertionError("release file does not contain property : " + name); + } + + // property value is of min. length 3 and double quoted at the ends. + String value = props.getProperty(name); + if (value.length() < 3 || + value.charAt(0) != '"' || + value.charAt(value.length() - 1) != '"') { + throw new AssertionError("release property " + name + " is not quoted property"); + } + } } diff -r 07736e140bce -r 6268665d2fd7 langtools/.hgtags --- a/langtools/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -378,3 +378,4 @@ 7efa4b3477b2b93edbdb4abf827b74c6391f056e jdk-9+133 f08683786207a48b652266b3b7b908e6c863c3fc jdk-9+134 af5eb8f3ffd21288305a54ea177ffad75021a741 jdk-9+135 +c8f02f0ecbd7cd6700f47416e4b7e9d5ec20ad77 jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 langtools/make/tools/crules/MutableFieldsAnalyzer.java --- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java Fri Sep 16 13:15:01 2016 -0700 @@ -105,12 +105,12 @@ "configurationClass", "resolveRequiresAndUsesMethod"); ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Layer", "layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod"); + ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Module", + "addExportsMethod", "addUsesMethod", "getModuleMethod", "getUnnamedModuleMethod"); ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ServiceLoaderHelper", "loadMethod"); ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$VMHelper", "vmClass", "getRuntimeArgumentsMethod"); - ignoreFields("com.sun.tools.javac.util.ModuleHelper", - "addExportsMethod", "getUnnamedModuleMethod", "getModuleMethod"); } } diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Sep 16 13:15:01 2016 -0700 @@ -92,6 +92,7 @@ private final Attribute theUnfinishedDefaultValue; private final boolean allowRepeatedAnnos; + private final String sourceName; protected Annotate(Context context) { context.put(annotateKey, this); @@ -114,6 +115,7 @@ Source source = Source.instance(context); allowRepeatedAnnos = source.allowRepeatedAnnotations(); + sourceName = source.name; } /** Semaphore to delay annotation processing */ @@ -322,7 +324,7 @@ if (annotated.containsKey(a.type.tsym)) { if (!allowRepeatedAnnos) { - log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), "repeatable.annotations.not.supported.in.source"); + log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), "repeatable.annotations.not.supported.in.source", sourceName); } ListBuffer l = annotated.get(a.type.tsym); l = l.append(c); diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Sep 16 13:15:01 2016 -0700 @@ -2256,6 +2256,12 @@ types.erasure(owner.enclClass().asType())); } + boolean isProtectedInSuperClassOfEnclosingClassInOtherPackage() { + return ((tree.sym.flags() & PROTECTED) != 0 && + tree.sym.packge() != owner.packge() && + !owner.enclClass().isSubClass(tree.sym.owner, types)); + } + /** * Signature polymorphic methods need special handling. * e.g. MethodHandle.invoke() MethodHandle.invokeExact() @@ -2293,6 +2299,7 @@ needsVarArgsConversion() || isArrayOp() || isPrivateInOtherClass() || + isProtectedInSuperClassOfEnclosingClassInOtherPackage() || !receiverAccessible() || (tree.getMode() == ReferenceMode.NEW && tree.kind != ReferenceKind.ARRAY_CTOR && diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Fri Sep 16 13:15:01 2016 -0700 @@ -78,6 +78,7 @@ import com.sun.tools.javac.util.JDK9Wrappers.Configuration; import com.sun.tools.javac.util.JDK9Wrappers.Layer; import com.sun.tools.javac.util.JDK9Wrappers.ModuleFinder; +import com.sun.tools.javac.util.JDK9Wrappers.Module; import com.sun.tools.javac.util.JDK9Wrappers.ServiceLoaderHelper; import static java.nio.file.FileVisitOption.FOLLOW_LINKS; @@ -957,6 +958,7 @@ public ServiceLoader getServiceLoader(Location location, Class service) throws IOException { nullCheck(location); nullCheck(service); + Module.getModule(getClass()).addUses(service); if (location.isModuleLocation()) { Collection paths = locations.getLocation(location); ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[paths.size()])); diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Sep 16 13:15:01 2016 -0700 @@ -1232,7 +1232,7 @@ Chain exit = switchEnv.info.exit; if (exit != null) { code.resolve(exit); - exit.state.defined.excludeFrom(code.nextreg); + exit.state.defined.excludeFrom(limit); } // If we have not set the default offset, we do so now. diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Fri Sep 16 13:15:01 2016 -0700 @@ -79,6 +79,7 @@ import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.Iterators; import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.JDK9Wrappers.Module; import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Log; @@ -119,7 +120,6 @@ private final JavacTypes typeUtils; private final JavaCompiler compiler; private final Modules modules; - private final ModuleHelper moduleHelper; private final Types types; /** @@ -227,7 +227,6 @@ enter = Enter.instance(context); initialCompleter = ClassFinder.instance(context).getCompleter(); chk = Check.instance(context); - moduleHelper = ModuleHelper.instance(context); initProcessorLoader(); defaultModule = source.allowModules() && options.isUnset("noModules") @@ -265,7 +264,8 @@ ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) : fileManager.getClassLoader(CLASS_PATH); - moduleHelper.addExports(processorClassLoader); + if (options.isSet("accessInternalAPI")) + ModuleHelper.addExports(Module.getModule(getClass()), Module.getUnnamedModule(processorClassLoader)); if (processorClassLoader != null && processorClassLoader instanceof Closeable) { compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader); diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java Fri Sep 16 13:15:01 2016 -0700 @@ -130,6 +130,85 @@ } /** + * Wrapper class for java.lang.reflect.Module. To materialize a handle use the static factory + * methods Module#getModule(Class) or Module#getUnnamedModule(ClassLoader). + */ + public static class Module { + + private final Object theRealModule; + + private Module(Object module) { + this.theRealModule = module; + init(); + } + + public static Module getModule(Class clazz) { + try { + init(); + Object result = getModuleMethod.invoke(clazz, new Object[0]); + return new Module(result); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | SecurityException ex) { + throw new Abort(ex); + } + } + + public static Module getUnnamedModule(ClassLoader classLoader) { + try { + init(); + Object result = getUnnamedModuleMethod.invoke(classLoader, new Object[0]); + return new Module(result); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | SecurityException ex) { + throw new Abort(ex); + } + } + + public Module addExports(String pn, Module other) { + try { + addExportsMethod.invoke(theRealModule, new Object[] { pn, other.theRealModule}); + } catch (IllegalAccessException | InvocationTargetException ex) { + throw new Abort(ex); + } + return this; + } + + public Module addUses(Class st) { + try { + addUsesMethod.invoke(theRealModule, new Object[] { st }); + } catch (IllegalAccessException | InvocationTargetException ex) { + throw new Abort(ex); + } + return this; + } + + // ----------------------------------------------------------------------------------------- + // on java.lang.reflect.Module + private static Method addExportsMethod = null; + // on java.lang.reflect.Module + private static Method addUsesMethod = null; + // on java.lang.Class + private static Method getModuleMethod; + // on java.lang.ClassLoader + private static Method getUnnamedModuleMethod; + + private static void init() { + if (addExportsMethod == null) { + try { + Class moduleClass = Class.forName("java.lang.reflect.Module", false, null); + addUsesMethod = moduleClass.getDeclaredMethod("addUses", new Class[] { Class.class }); + addExportsMethod = moduleClass.getDeclaredMethod("addExports", + new Class[] { String.class, moduleClass }); + getModuleMethod = Class.class.getDeclaredMethod("getModule", new Class[0]); + getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule", new Class[0]); + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) { + throw new Abort(ex); + } + } + } + } + + /** * Wrapper class for java.lang.module.Configuration. */ public static final class Configuration { diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java Fri Sep 16 13:15:01 2016 -0700 @@ -25,88 +25,30 @@ package com.sun.tools.javac.util; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; +import com.sun.tools.javac.util.JDK9Wrappers.Module; public class ModuleHelper { - /** The context key for the module helper. */ - protected static final Context.Key moduleHelperKey = new Context.Key<>(); - - /** Get the JavaCompiler instance for this context. */ - public static ModuleHelper instance(Context context) { - ModuleHelper instance = context.get(moduleHelperKey); - if (instance == null) - instance = new ModuleHelper(context); - return instance; - } - - public ModuleHelper(Context context) { - context.put(moduleHelperKey, this); - Options options = Options.instance(context); - allowAccessToInternalAPI = options.isSet("accessInternalAPI"); - } - - final boolean allowAccessToInternalAPI; - private void exportPackageToModule(String packageName, Object target) - throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, - InvocationTargetException, IllegalAccessException { - if (addExportsMethod == null) { - Class moduleClass = Class.forName("java.lang.reflect.Module"); - addExportsMethod = moduleClass.getDeclaredMethod("addExports", - new Class[] { String.class, moduleClass }); - } - addExportsMethod.invoke(from, new Object[] { packageName, target }); - } + private static final String[] javacInternalPackages = new String[] { + "com.sun.tools.javac.api", + "com.sun.tools.javac.code", + "com.sun.tools.javac.comp", + "com.sun.tools.javac.file", + "com.sun.tools.javac.jvm", + "com.sun.tools.javac.main", + "com.sun.tools.javac.model", + "com.sun.tools.javac.parser", + "com.sun.tools.javac.platform", + "com.sun.tools.javac.processing", + "com.sun.tools.javac.tree", + "com.sun.tools.javac.util", - static final String[] javacInternalPackages = new String[] { - "com.sun.tools.javac.api", - "com.sun.tools.javac.code", - "com.sun.tools.javac.comp", - "com.sun.tools.javac.file", - "com.sun.tools.javac.jvm", - "com.sun.tools.javac.main", - "com.sun.tools.javac.model", - "com.sun.tools.javac.parser", - "com.sun.tools.javac.platform", - "com.sun.tools.javac.processing", - "com.sun.tools.javac.tree", - "com.sun.tools.javac.util", - - "com.sun.tools.doclint", + "com.sun.tools.doclint", }; - public void addExports(ClassLoader classLoader) { - try { - if (allowAccessToInternalAPI) { - if (from == null) { - if (getModuleMethod == null) { - getModuleMethod = Class.class.getDeclaredMethod("getModule", new Class[0]); - } - from = getModuleMethod.invoke(getClass(), new Object[0]); - } - if (getUnnamedModuleMethod == null) { - getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule", new Class[0]); - } - Object target = getUnnamedModuleMethod.invoke(classLoader, new Object[0]); - for (String pack: javacInternalPackages) { - exportPackageToModule(pack, target); - } - } - } catch (Exception e) { - // do nothing + public static void addExports(Module from, Module to) { + for (String pack: javacInternalPackages) { + from.addExports(pack, to); } } - - // a module instance - private Object from = null; - - // on java.lang.reflect.Module - private static Method addExportsMethod = null; - - // on java.lang.ClassLoader - private static Method getUnnamedModuleMethod = null; - - // on java.lang.Class - private static Method getModuleMethod = null; -} +} \ No newline at end of file diff -r 07736e140bce -r 6268665d2fd7 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Fri Sep 16 13:15:01 2016 -0700 @@ -263,18 +263,18 @@ if (ui.item.l !== noResult.l) { var url = ""; if (ui.item.category === catModules) { - url = "/" + ui.item.l + "-summary.html"; + url = ui.item.l + "-summary.html"; } else if (ui.item.category === catPackages) { url = ui.item.l.replace(/\./g, '/') + "/package-summary.html"; } else if (ui.item.category === catTypes) { if (ui.item.p === "") { - url = "/" + ui.item.l + ".html"; + url = ui.item.l + ".html"; } else { url = ui.item.p.replace(/\./g, '/') + "/" + ui.item.l + ".html"; } } else if (ui.item.category === catMembers) { if (ui.item.p === "") { - url = "/" + ui.item.c + ".html" + "#"; + url = ui.item.c + ".html" + "#"; } else { url = ui.item.p.replace(/\./g, '/') + "/" + ui.item.c + ".html" + "#"; } diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/SwitchExitStateTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/SwitchExitStateTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, 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 8160699 + * @summary Verify that having finished executing a switch statement live locals are exactly the same as it was upon entry of the switch. + * @run main SwitchExitStateTest + */ + +public class SwitchExitStateTest { + public static void main(String[] args) throws Exception { + switch (0) { + case 0: + String a = ""; + break; + default: + throw new Exception("Unknown "); + } + + switch (0) { + case 0: + String b = ""; + break; + default: + throw new Exception("Unknown "); + } + } +} \ No newline at end of file diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java --- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Fri Sep 16 12:09:53 2016 -0500 +++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Fri Sep 16 13:15:01 2016 -0700 @@ -106,12 +106,12 @@ // The following static fields are used for caches of information obtained // by reflective lookup, to avoid explicit references that are not available // when running javac on JDK 8. - ignore("com/sun/tools/javac/util/ModuleHelper", - "addExportsMethod", "getModuleMethod", "getUnnamedModuleMethod"); ignore("com/sun/tools/javac/util/JDK9Wrappers$Configuration", "resolveRequiresAndUsesMethod", "configurationClass"); ignore("com/sun/tools/javac/util/JDK9Wrappers$Layer", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod", "layerClass"); + ignore("com/sun/tools/javac/util/JDK9Wrappers$Module", + "addExportsMethod", "addUsesMethod", "getModuleMethod", "getUnnamedModuleMethod"); ignore("com/sun/tools/javac/util/JDK9Wrappers$ModuleFinder", "moduleFinderClass", "ofMethod"); ignore("com/sun/tools/javac/util/JDK9Wrappers$ServiceLoaderHelper", diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8138822 + * @summary test that only Java 8+ allows repeating annotations + * @compile WrongVersion.java + * @compile -Xlint:-options -source 8 WrongVersion.java + * @compile/fail/ref=WrongVersion7.out -XDrawDiagnostics -Xlint:-options -source 7 WrongVersion.java + * @compile/fail/ref=WrongVersion6.out -XDrawDiagnostics -Xlint:-options -source 6 WrongVersion.java + */ +import java.lang.annotation.Repeatable; + +@Ann(1) @Ann(2) +class C { +} + +@Repeatable(AnnContainer.class) +@interface Ann { + int value(); +} + +@interface AnnContainer { + Ann[] value(); +} diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,2 @@ +WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.6 +1 error diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,2 @@ +WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.7 +1 error diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/lambda/methodReference/ProtectedInaccessibleMethodRefTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/methodReference/ProtectedInaccessibleMethodRefTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 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 8138667 + * @summary Verify that javac emits suitable accessors when a method reference mentions a protected method that would need an accessor + * @run main ProtectedInaccessibleMethodRefTest + */ + + +import pack.SuperClass; + +import java.util.concurrent.Callable; + +public final class ProtectedInaccessibleMethodRefTest extends SuperClass { + + static String message = "NOT OK"; + + public void doTest() throws Exception { + new Callable() { + @Override + public Void call() throws Exception { + final Runnable r = ProtectedInaccessibleMethodRefTest.this::myDo; + r.run(); + return null; + } + }.call(); + + new Callable() { + @Override + public Void call() throws Exception { + final Runnable r = ProtectedInaccessibleMethodRefTest::myStaticDo; + r.run(); + return null; + } + }.call(); + } + + public void message(String s) { + message = s; + } + + public static void main(String[] args) throws Exception { + new ProtectedInaccessibleMethodRefTest().doTest(); + if (!message.equals("OK!")) + throw new AssertionError("Unexpected output"); + if (!sMessage.equals("OK!")) + throw new AssertionError("Unexpected output"); + } +} diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/lambda/methodReference/pack/SuperClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/methodReference/pack/SuperClass.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pack; + +public class SuperClass { + + public static String sMessage = "Not OK"; + + protected final void myDo() { + message("OK!"); + } + + protected static final void myStaticDo() { + sMessage = "OK!"; + } + + public void message(String s) { + } +} diff -r 07736e140bce -r 6268665d2fd7 langtools/test/tools/javac/modules/FileManagerGetServiceLoaderTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/modules/FileManagerGetServiceLoaderTest.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016, 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 8164742 + * @summary Test that jdk.compiler can materialize a service loader for arbitrary services + * @run main FileManagerGetServiceLoaderTest + */ + +import javax.tools.*; + +public class FileManagerGetServiceLoaderTest { + + public static void main(String... args) throws Exception { + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null); + + /* FileManagerGetServiceLoaderTest.class is not really a service, but that is + immaterial to the test which just verifies addUses would have been called + so module boundary is not an issue for a class outside of jdk.compiler + */ + java.util.ServiceLoader loader = fm.getServiceLoader(StandardLocation.CLASS_PATH, + FileManagerGetServiceLoaderTest.class); + if (loader == null) { + throw new AssertionError("Could not obtain service loader"); + } + } +} diff -r 07736e140bce -r 6268665d2fd7 make/Images.gmk --- a/make/Images.gmk Fri Sep 16 12:09:53 2016 -0500 +++ b/make/Images.gmk Fri Sep 16 13:15:01 2016 -0700 @@ -75,11 +75,6 @@ # Param 1 - The file containing the MODULES list define create-info-file - $(call info-file-item, "JAVA_VERSION", "$(VERSION_NUMBER)") - $(call info-file-item, "JAVA_FULL_VERSION", "$(VERSION_STRING)") - $(call info-file-item, "OS_NAME", "$(REQUIRED_OS_NAME)") - $(call info-file-item, "OS_VERSION", "$(REQUIRED_OS_VERSION)") - $(call info-file-item, "OS_ARCH", "$(OPENJDK_TARGET_CPU_LEGACY)") $(if $(JDK_ARCH_ABI_PROP_NAME), \ $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)")) $(call info-file-item, "SOURCE", "$(strip $(ALL_SOURCE_TIPS))") diff -r 07736e140bce -r 6268665d2fd7 nashorn/.hgtags --- a/nashorn/.hgtags Fri Sep 16 12:09:53 2016 -0500 +++ b/nashorn/.hgtags Fri Sep 16 13:15:01 2016 -0700 @@ -369,3 +369,4 @@ 3a924b820d02b108cf57b51e145b5150d1eedcca jdk-9+133 e05400ba935753c77697af936db24657eb811022 jdk-9+134 cb00d5ef023a18a66fcb4311ed4474d4145c66e9 jdk-9+135 +f11b8f5c4ccbf9c87d283815abac6c0117fba3c0 jdk-9+136 diff -r 07736e140bce -r 6268665d2fd7 test/lib/jdk/test/lib/Utils.java --- a/test/lib/jdk/test/lib/Utils.java Fri Sep 16 12:09:53 2016 -0500 +++ b/test/lib/jdk/test/lib/Utils.java Fri Sep 16 13:15:01 2016 -0700 @@ -25,7 +25,6 @@ import java.io.File; import java.io.IOException; -import java.lang.reflect.Field; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.ServerSocket; @@ -51,7 +50,6 @@ import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; -import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.assertTrue; import jdk.test.lib.process.ProcessTools; @@ -87,9 +85,16 @@ */ public static final String TEST_SRC = System.getProperty("test.src", "").trim(); - private static Unsafe unsafe = null; + /* + * Returns the value of 'test.jdk' system property + */ + public static final String TEST_JDK = System.getProperty("test.jdk"); /** + * Returns the value of 'test.classes' system property + */ + public static final String TEST_CLASSES = System.getProperty("test.classes", "."); + /** * Defines property name for seed value. */ public static final String SEED_PROPERTY_NAME = "jdk.test.lib.random.seed"; @@ -373,21 +378,6 @@ return new String(Files.readAllBytes(filePath)); } - /** - * @return Unsafe instance. - */ - public static synchronized Unsafe getUnsafe() { - if (unsafe == null) { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException("Unable to get Unsafe instance.", e); - } - } - return unsafe; - } private static final char[] hexArray = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; /** diff -r 07736e140bce -r 6268665d2fd7 test/lib/jdk/test/lib/unsafe/UnsafeHelper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java Fri Sep 16 13:15:01 2016 -0700 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.unsafe; + +import jdk.internal.misc.Unsafe; +import java.lang.reflect.Field; + + +/** + * Helper class for accessing the jdk.internal.misc.Unsafe functionality + */ +public final class UnsafeHelper { + private static Unsafe unsafe = null; + + /** + * @return Unsafe instance. + */ + public static synchronized Unsafe getUnsafe() { + if (unsafe == null) { + try { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + unsafe = (Unsafe) f.get(null); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException("Unable to get Unsafe instance.", e); + } + } + return unsafe; + } +} +