# HG changeset patch # User alanb # Date 1552136060 0 # Node ID b38f280d211404ac5902bbed95de0a65d45cd872 # Parent 3e39753ed05bb6f6de5e29fbc9294de8a98fe2c0# Parent 0324b3756aa261672d0f745b2a9a651fee69d262 Merge diff -r 3e39753ed05b -r b38f280d2114 .hgtags --- a/.hgtags Sat Mar 09 12:52:30 2019 +0000 +++ b/.hgtags Sat Mar 09 12:54:20 2019 +0000 @@ -547,3 +547,4 @@ c081f3ea6b9300265a4a34e38f970b1e3ddaae9f jdk-13+9 b67884871b5fff79c5ef3eb8ac74dd48d71ea9b1 jdk-12+33 8e069f7b4fabfe05d9f500783e6d56cb0196d25c jdk-13+10 +21ea4076a275a0f498afa517e9ee1b94a9cf0255 jdk-13+11 diff -r 3e39753ed05b -r b38f280d2114 doc/building.html --- a/doc/building.html Sat Mar 09 12:52:30 2019 +0000 +++ b/doc/building.html Sat Mar 09 12:54:20 2019 +0000 @@ -237,7 +237,7 @@

For rpm-based distributions (Fedora, Red Hat, etc), try this:

sudo yum groupinstall "Development Tools"

AIX

-

The regular builds by SAP is using AIX version 7.1, but AIX 5.3 is also supported. See the OpenJDK PowerPC Port Status Page for details.

+

Please consult the AIX section of the Supported Build Platforms OpenJDK Build Wiki page for details about which versions of AIX are supported.

Native Compiler (Toolchain) Requirements

Large portions of the JDK consists of native code, that needs to be compiled to be able to run on the target platform. In theory, toolchain and operating system should be independent factors, but in practice there's more or less a one-to-one correlation between target operating system and toolchain.

@@ -373,8 +373,7 @@

If you have multiple versions of Visual Studio installed, configure will by default pick the latest. You can request a specific version to be used by setting --with-toolchain-version, e.g. --with-toolchain-version=2015.

If you get LINK: fatal error LNK1123: failure during conversion to COFF: file invalid when building using Visual Studio 2010, you have encountered KB2757355, a bug triggered by a specific installation order. However, the solution suggested by the KB article does not always resolve the problem. See this stackoverflow discussion for other suggestions.

IBM XL C/C++

-

The regular builds by SAP is using version 12.1, described as IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72) Version: 12.01.0000.0017.

-

See the OpenJDK PowerPC Port Status Page for details.

+

Please consult the AIX section of the Supported Build Platforms OpenJDK Build Wiki page for details about which versions of XLC are supported.

Boot JDK Requirements

Paradoxically, building the JDK requires a pre-existing JDK. This is called the "boot JDK". The boot JDK does not, however, have to be a JDK built directly from the source code available in the OpenJDK Community. If you are porting the JDK to a new platform, chances are that there already exists another JDK for that platform that is usable as boot JDK.

The rule of thumb is that the boot JDK for building JDK major version N should be a JDK of major version N-1, so for building JDK 9 a JDK 8 would be suitable as boot JDK. However, the JDK should be able to "build itself", so an up-to-date build of the current JDK source is an acceptable alternative. If you are following the N-1 rule, make sure you've got the latest update version, since JDK 8 GA might not be able to build JDK 9 on all platforms.

diff -r 3e39753ed05b -r b38f280d2114 doc/building.md --- a/doc/building.md Sat Mar 09 12:52:30 2019 +0000 +++ b/doc/building.md Sat Mar 09 12:54:20 2019 +0000 @@ -295,9 +295,9 @@ ### AIX -The regular builds by SAP is using AIX version 7.1, but AIX 5.3 is also -supported. See the [OpenJDK PowerPC Port Status Page]( -http://cr.openjdk.java.net/~simonis/ppc-aix-port) for details. +Please consult the AIX section of the [Supported Build Platforms]( +https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms) OpenJDK +Build Wiki page for details about which versions of AIX are supported. ## Native Compiler (Toolchain) Requirements @@ -419,11 +419,10 @@ ### IBM XL C/C++ -The regular builds by SAP is using version 12.1, described as `IBM XL C/C++ for -AIX, V12.1 (5765-J02, 5725-C72) Version: 12.01.0000.0017`. +Please consult the AIX section of the [Supported Build Platforms]( +https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms) OpenJDK +Build Wiki page for details about which versions of XLC are supported. -See the [OpenJDK PowerPC Port Status Page]( -http://cr.openjdk.java.net/~simonis/ppc-aix-port) for details. ## Boot JDK Requirements diff -r 3e39753ed05b -r b38f280d2114 doc/testing.html --- a/doc/testing.html Sat Mar 09 12:52:30 2019 +0000 +++ b/doc/testing.html Sat Mar 09 12:54:20 2019 +0000 @@ -1,24 +1,19 @@ - + - - - + + + Testing the JDK - - + + -
+

Testing the JDK

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
setHostnameVerifierThe ability to set a callback which can decide whether to - * allow a mismatch between the host being connected to by - * an HttpsURLConnection and the common name field in - * server certificate. - * Malicious - * code can set a verifier that monitors host names visited by - * HttpsURLConnection requests or that allows server certificates - * with invalid common names. - *
getSSLSessionContextThe ability to get the SSLSessionContext of an SSLSession. - * Malicious code may monitor sessions which have been established - * with SSL peers or might invalidate sessions to slow down performance. - *
- * - * @see java.security.BasicPermission - * @see java.security.Permission - * @see java.security.Permissions - * @see java.security.PermissionCollection - * @see java.lang.SecurityManager - * - * - * @author Marianne Mueller - * @author Roland Schemers - * - * @deprecated As of JDK 1.4, this implementation-specific class was - * replaced by {@link javax.net.ssl.SSLPermission}. - */ -@Deprecated(since="1.4") -public final class SSLPermission extends BasicPermission { - - private static final long serialVersionUID = -2583684302506167542L; - - /** - * Creates a new SSLPermission with the specified name. - * The name is the symbolic name of the SSLPermission, such as - * "setDefaultAuthenticator", etc. An asterisk - * may appear at the end of the name, following a ".", or by itself, to - * signify a wildcard match. - * - * @param name the name of the SSLPermission. - */ - - public SSLPermission(String name) - { - super(name); - } - - /** - * Creates a new SSLPermission object with the specified name. - * The name is the symbolic name of the SSLPermission, and the - * actions String is currently unused and should be null. This - * constructor exists for use by the Policy object - * to instantiate new Permission objects. - * - * @param name the name of the SSLPermission. - * @param actions should be null. - */ - - public SSLPermission(String name, String actions) - { - super(name, actions); - } -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/SSLSecurity.java --- a/src/java.base/share/classes/com/sun/net/ssl/SSLSecurity.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,699 +0,0 @@ -/* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * NOTE: this file was copied from javax.net.ssl.SSLSecurity, - * but was heavily modified to allow com.sun.* users to - * access providers written using the javax.sun.* APIs. - */ - -package com.sun.net.ssl; - -import java.util.*; -import java.io.*; -import java.security.*; -import java.security.Provider.Service; -import java.net.Socket; - -import sun.security.jca.*; - -/** - * This class instantiates implementations of JSSE engine classes from - * providers registered with the java.security.Security object. - * - * @author Jan Luehe - * @author Jeff Nisewanger - * @author Brad Wetmore - */ - -final class SSLSecurity { - - /* - * Don't let anyone instantiate this. - */ - private SSLSecurity() { - } - - - // ProviderList.getService() is not accessible now, implement our own loop - private static Service getService(String type, String alg) { - ProviderList list = Providers.getProviderList(); - for (Provider p : list.providers()) { - Service s = p.getService(type, alg); - if (s != null) { - return s; - } - } - return null; - } - - /** - * The body of the driver for the getImpl method. - */ - private static Object[] getImpl1(String algName, String engineType, - Service service) throws NoSuchAlgorithmException - { - Provider provider = service.getProvider(); - String className = service.getClassName(); - Class implClass; - try { - ClassLoader cl = provider.getClass().getClassLoader(); - if (cl == null) { - // system class - implClass = Class.forName(className); - } else { - implClass = cl.loadClass(className); - } - } catch (ClassNotFoundException e) { - throw new NoSuchAlgorithmException("Class " + className + - " configured for " + - engineType + - " not found: " + - e.getMessage()); - } catch (SecurityException e) { - throw new NoSuchAlgorithmException("Class " + className + - " configured for " + - engineType + - " cannot be accessed: " + - e.getMessage()); - } - - /* - * JSSE 1.0, 1.0.1, and 1.0.2 used the com.sun.net.ssl API as the - * API was being developed. As JSSE was folded into the main - * release, it was decided to promote the com.sun.net.ssl API to - * be javax.net.ssl. It is desired to keep binary compatibility - * with vendors of JSSE implementation written using the - * com.sun.net.sll API, so we do this magic to handle everything. - * - * API used Implementation used Supported? - * ======== =================== ========== - * com.sun javax Yes - * com.sun com.sun Yes - * javax javax Yes - * javax com.sun Not Currently - * - * Make sure the implementation class is a subclass of the - * corresponding engine class. - * - * In wrapping these classes, there's no way to know how to - * wrap all possible classes that extend the TrustManager/KeyManager. - * We only wrap the x509 variants. - */ - - try { // catch instantiation errors - - /* - * (The following Class.forName()s should alway work, because - * this class and all the SPI classes in javax.crypto are - * loaded by the same class loader.) That is, unless they - * give us a SPI class that doesn't exist, say SSLFoo, - * or someone has removed classes from the java.base module. - */ - - Class typeClassJavax; - Class typeClassCom; - Object obj = null; - - /* - * Odds are more likely that we have a javax variant, try this - * first. - */ - if (((typeClassJavax = Class.forName("javax.net.ssl." + - engineType + "Spi")) != null) && - (checkSuperclass(implClass, typeClassJavax))) { - - if (engineType.equals("SSLContext")) { - obj = new SSLContextSpiWrapper(algName, provider); - } else if (engineType.equals("TrustManagerFactory")) { - obj = new TrustManagerFactorySpiWrapper(algName, provider); - } else if (engineType.equals("KeyManagerFactory")) { - obj = new KeyManagerFactorySpiWrapper(algName, provider); - } else { - /* - * We should throw an error if we get - * something totally unexpected. Don't ever - * expect to see this one... - */ - throw new IllegalStateException( - "Class " + implClass.getName() + - " unknown engineType wrapper:" + engineType); - } - - } else if (((typeClassCom = Class.forName("com.sun.net.ssl." + - engineType + "Spi")) != null) && - (checkSuperclass(implClass, typeClassCom))) { - obj = service.newInstance(null); - } - - if (obj != null) { - return new Object[] { obj, provider }; - } else { - throw new NoSuchAlgorithmException( - "Couldn't locate correct object or wrapper: " + - engineType + " " + algName); - } - - } catch (ClassNotFoundException e) { - IllegalStateException exc = new IllegalStateException( - "Engine Class Not Found for " + engineType); - exc.initCause(e); - throw exc; - } - } - - /** - * Returns an array of objects: the first object in the array is - * an instance of an implementation of the requested algorithm - * and type, and the second object in the array identifies the provider - * of that implementation. - * The provName argument can be null, in which case all - * configured providers will be searched in order of preference. - */ - static Object[] getImpl(String algName, String engineType, String provName) - throws NoSuchAlgorithmException, NoSuchProviderException - { - Service service; - if (provName != null) { - ProviderList list = Providers.getProviderList(); - Provider prov = list.getProvider(provName); - if (prov == null) { - throw new NoSuchProviderException("No such provider: " + - provName); - } - service = prov.getService(engineType, algName); - } else { - service = getService(engineType, algName); - } - if (service == null) { - throw new NoSuchAlgorithmException("Algorithm " + algName - + " not available"); - } - return getImpl1(algName, engineType, service); - } - - - /** - * Returns an array of objects: the first object in the array is - * an instance of an implementation of the requested algorithm - * and type, and the second object in the array identifies the provider - * of that implementation. - * The prov argument can be null, in which case all - * configured providers will be searched in order of preference. - */ - static Object[] getImpl(String algName, String engineType, Provider prov) - throws NoSuchAlgorithmException - { - Service service = prov.getService(engineType, algName); - if (service == null) { - throw new NoSuchAlgorithmException("No such algorithm: " + - algName); - } - return getImpl1(algName, engineType, service); - } - - /* - * Checks whether one class is the superclass of another - */ - private static boolean checkSuperclass(Class subclass, Class superclass) { - if ((subclass == null) || (superclass == null)) - return false; - - while (!subclass.equals(superclass)) { - subclass = subclass.getSuperclass(); - if (subclass == null) { - return false; - } - } - return true; - } - - /* - * Return at most the first "resize" elements of an array. - * - * Didn't want to use java.util.Arrays, as PJava may not have it. - */ - static Object[] truncateArray(Object[] oldArray, Object[] newArray) { - - for (int i = 0; i < newArray.length; i++) { - newArray[i] = oldArray[i]; - } - - return newArray; - } - -} - - -/* - * ================================================================= - * The remainder of this file is for the wrapper and wrapper-support - * classes. When SSLSecurity finds something which extends the - * javax.net.ssl.*Spi, we need to go grab a real instance of the - * thing that the Spi supports, and wrap into a com.sun.net.ssl.*Spi - * object. This also mean that anything going down into the SPI - * needs to be wrapped, as well as anything coming back up. - */ -@SuppressWarnings("deprecation") -final class SSLContextSpiWrapper extends SSLContextSpi { - - private javax.net.ssl.SSLContext theSSLContext; - - SSLContextSpiWrapper(String algName, Provider prov) throws - NoSuchAlgorithmException { - theSSLContext = javax.net.ssl.SSLContext.getInstance(algName, prov); - } - - @SuppressWarnings("deprecation") - protected void engineInit(KeyManager[] kma, TrustManager[] tma, - SecureRandom sr) throws KeyManagementException { - - // Keep track of the actual number of array elements copied - int dst; - int src; - javax.net.ssl.KeyManager[] kmaw; - javax.net.ssl.TrustManager[] tmaw; - - // Convert com.sun.net.ssl.kma to a javax.net.ssl.kma - // wrapper if need be. - if (kma != null) { - kmaw = new javax.net.ssl.KeyManager[kma.length]; - for (src = 0, dst = 0; src < kma.length; ) { - /* - * These key managers may implement both javax - * and com.sun interfaces, so if they do - * javax, there's no need to wrap them. - */ - if (!(kma[src] instanceof javax.net.ssl.KeyManager)) { - /* - * Do we know how to convert them? If not, oh well... - * We'll have to drop them on the floor in this - * case, cause we don't know how to handle them. - * This will be pretty rare, but put here for - * completeness. - */ - if (kma[src] instanceof X509KeyManager) { - kmaw[dst] = (javax.net.ssl.KeyManager) - new X509KeyManagerJavaxWrapper( - (X509KeyManager)kma[src]); - dst++; - } - } else { - // We can convert directly, since they implement. - kmaw[dst] = (javax.net.ssl.KeyManager)kma[src]; - dst++; - } - src++; - } - - /* - * If dst != src, there were more items in the original array - * than in the new array. Compress the new elements to avoid - * any problems down the road. - */ - if (dst != src) { - kmaw = (javax.net.ssl.KeyManager []) - SSLSecurity.truncateArray(kmaw, - new javax.net.ssl.KeyManager [dst]); - } - } else { - kmaw = null; - } - - // Now do the same thing with the TrustManagers. - if (tma != null) { - tmaw = new javax.net.ssl.TrustManager[tma.length]; - - for (src = 0, dst = 0; src < tma.length; ) { - /* - * These key managers may implement both...see above... - */ - if (!(tma[src] instanceof javax.net.ssl.TrustManager)) { - // Do we know how to convert them? - if (tma[src] instanceof X509TrustManager) { - tmaw[dst] = (javax.net.ssl.TrustManager) - new X509TrustManagerJavaxWrapper( - (X509TrustManager)tma[src]); - dst++; - } - } else { - tmaw[dst] = (javax.net.ssl.TrustManager)tma[src]; - dst++; - } - src++; - } - - if (dst != src) { - tmaw = (javax.net.ssl.TrustManager []) - SSLSecurity.truncateArray(tmaw, - new javax.net.ssl.TrustManager [dst]); - } - } else { - tmaw = null; - } - - theSSLContext.init(kmaw, tmaw, sr); - } - - protected javax.net.ssl.SSLSocketFactory - engineGetSocketFactory() { - return theSSLContext.getSocketFactory(); - } - - protected javax.net.ssl.SSLServerSocketFactory - engineGetServerSocketFactory() { - return theSSLContext.getServerSocketFactory(); - } - -} - -@SuppressWarnings("deprecation") -final class TrustManagerFactorySpiWrapper extends TrustManagerFactorySpi { - - private javax.net.ssl.TrustManagerFactory theTrustManagerFactory; - - TrustManagerFactorySpiWrapper(String algName, Provider prov) throws - NoSuchAlgorithmException { - theTrustManagerFactory = - javax.net.ssl.TrustManagerFactory.getInstance(algName, prov); - } - - protected void engineInit(KeyStore ks) throws KeyStoreException { - theTrustManagerFactory.init(ks); - } - - protected TrustManager[] engineGetTrustManagers() { - - int dst; - int src; - - javax.net.ssl.TrustManager[] tma = - theTrustManagerFactory.getTrustManagers(); - - TrustManager[] tmaw = new TrustManager[tma.length]; - - for (src = 0, dst = 0; src < tma.length; ) { - if (!(tma[src] instanceof com.sun.net.ssl.TrustManager)) { - // We only know how to wrap X509TrustManagers, as - // TrustManagers don't have any methods to wrap. - if (tma[src] instanceof javax.net.ssl.X509TrustManager) { - tmaw[dst] = (TrustManager) - new X509TrustManagerComSunWrapper( - (javax.net.ssl.X509TrustManager)tma[src]); - dst++; - } - } else { - tmaw[dst] = (TrustManager)tma[src]; - dst++; - } - src++; - } - - if (dst != src) { - tmaw = (TrustManager []) - SSLSecurity.truncateArray(tmaw, new TrustManager [dst]); - } - - return tmaw; - } - -} - -@SuppressWarnings("deprecation") -final class KeyManagerFactorySpiWrapper extends KeyManagerFactorySpi { - - private javax.net.ssl.KeyManagerFactory theKeyManagerFactory; - - KeyManagerFactorySpiWrapper(String algName, Provider prov) throws - NoSuchAlgorithmException { - theKeyManagerFactory = - javax.net.ssl.KeyManagerFactory.getInstance(algName, prov); - } - - protected void engineInit(KeyStore ks, char[] password) - throws KeyStoreException, NoSuchAlgorithmException, - UnrecoverableKeyException { - theKeyManagerFactory.init(ks, password); - } - - protected KeyManager[] engineGetKeyManagers() { - - int dst; - int src; - - javax.net.ssl.KeyManager[] kma = - theKeyManagerFactory.getKeyManagers(); - - KeyManager[] kmaw = new KeyManager[kma.length]; - - for (src = 0, dst = 0; src < kma.length; ) { - if (!(kma[src] instanceof com.sun.net.ssl.KeyManager)) { - // We only know how to wrap X509KeyManagers, as - // KeyManagers don't have any methods to wrap. - if (kma[src] instanceof javax.net.ssl.X509KeyManager) { - kmaw[dst] = (KeyManager) - new X509KeyManagerComSunWrapper( - (javax.net.ssl.X509KeyManager)kma[src]); - dst++; - } - } else { - kmaw[dst] = (KeyManager)kma[src]; - dst++; - } - src++; - } - - if (dst != src) { - kmaw = (KeyManager []) - SSLSecurity.truncateArray(kmaw, new KeyManager [dst]); - } - - return kmaw; - } - -} - -// ================================= - -@SuppressWarnings("deprecation") -final class X509KeyManagerJavaxWrapper implements - javax.net.ssl.X509KeyManager { - - private X509KeyManager theX509KeyManager; - - X509KeyManagerJavaxWrapper(X509KeyManager obj) { - theX509KeyManager = obj; - } - - public String[] getClientAliases(String keyType, Principal[] issuers) { - return theX509KeyManager.getClientAliases(keyType, issuers); - } - - public String chooseClientAlias(String[] keyTypes, Principal[] issuers, - Socket socket) { - String retval; - - if (keyTypes == null) { - return null; - } - - /* - * Scan the list, look for something we can pass back. - */ - for (int i = 0; i < keyTypes.length; i++) { - if ((retval = theX509KeyManager.chooseClientAlias(keyTypes[i], - issuers)) != null) - return retval; - } - return null; - - } - - /* - * JSSE 1.0.x was only socket based, but it's possible someone might - * want to install a really old provider. We should at least - * try to be nice. - */ - public String chooseEngineClientAlias( - String[] keyTypes, Principal[] issuers, - javax.net.ssl.SSLEngine engine) { - String retval; - - if (keyTypes == null) { - return null; - } - - /* - * Scan the list, look for something we can pass back. - */ - for (int i = 0; i < keyTypes.length; i++) { - if ((retval = theX509KeyManager.chooseClientAlias(keyTypes[i], - issuers)) != null) - return retval; - } - - return null; - } - - public String[] getServerAliases(String keyType, Principal[] issuers) { - return theX509KeyManager.getServerAliases(keyType, issuers); - } - - public String chooseServerAlias(String keyType, Principal[] issuers, - Socket socket) { - - if (keyType == null) { - return null; - } - return theX509KeyManager.chooseServerAlias(keyType, issuers); - } - - /* - * JSSE 1.0.x was only socket based, but it's possible someone might - * want to install a really old provider. We should at least - * try to be nice. - */ - public String chooseEngineServerAlias( - String keyType, Principal[] issuers, - javax.net.ssl.SSLEngine engine) { - - if (keyType == null) { - return null; - } - return theX509KeyManager.chooseServerAlias(keyType, issuers); - } - - public java.security.cert.X509Certificate[] - getCertificateChain(String alias) { - return theX509KeyManager.getCertificateChain(alias); - } - - public PrivateKey getPrivateKey(String alias) { - return theX509KeyManager.getPrivateKey(alias); - } -} - -@SuppressWarnings("deprecation") -final class X509TrustManagerJavaxWrapper implements - javax.net.ssl.X509TrustManager { - - private X509TrustManager theX509TrustManager; - - X509TrustManagerJavaxWrapper(X509TrustManager obj) { - theX509TrustManager = obj; - } - - public void checkClientTrusted( - java.security.cert.X509Certificate[] chain, String authType) - throws java.security.cert.CertificateException { - if (!theX509TrustManager.isClientTrusted(chain)) { - throw new java.security.cert.CertificateException( - "Untrusted Client Certificate Chain"); - } - } - - public void checkServerTrusted( - java.security.cert.X509Certificate[] chain, String authType) - throws java.security.cert.CertificateException { - if (!theX509TrustManager.isServerTrusted(chain)) { - throw new java.security.cert.CertificateException( - "Untrusted Server Certificate Chain"); - } - } - - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return theX509TrustManager.getAcceptedIssuers(); - } -} - -@SuppressWarnings("deprecation") -final class X509KeyManagerComSunWrapper implements X509KeyManager { - - private javax.net.ssl.X509KeyManager theX509KeyManager; - - X509KeyManagerComSunWrapper(javax.net.ssl.X509KeyManager obj) { - theX509KeyManager = obj; - } - - public String[] getClientAliases(String keyType, Principal[] issuers) { - return theX509KeyManager.getClientAliases(keyType, issuers); - } - - public String chooseClientAlias(String keyType, Principal[] issuers) { - String [] keyTypes = new String [] { keyType }; - return theX509KeyManager.chooseClientAlias(keyTypes, issuers, null); - } - - public String[] getServerAliases(String keyType, Principal[] issuers) { - return theX509KeyManager.getServerAliases(keyType, issuers); - } - - public String chooseServerAlias(String keyType, Principal[] issuers) { - return theX509KeyManager.chooseServerAlias(keyType, issuers, null); - } - - public java.security.cert.X509Certificate[] - getCertificateChain(String alias) { - return theX509KeyManager.getCertificateChain(alias); - } - - public PrivateKey getPrivateKey(String alias) { - return theX509KeyManager.getPrivateKey(alias); - } -} - -@SuppressWarnings("deprecation") -final class X509TrustManagerComSunWrapper implements X509TrustManager { - - private javax.net.ssl.X509TrustManager theX509TrustManager; - - X509TrustManagerComSunWrapper(javax.net.ssl.X509TrustManager obj) { - theX509TrustManager = obj; - } - - public boolean isClientTrusted( - java.security.cert.X509Certificate[] chain) { - try { - theX509TrustManager.checkClientTrusted(chain, "UNKNOWN"); - return true; - } catch (java.security.cert.CertificateException e) { - return false; - } - } - - public boolean isServerTrusted( - java.security.cert.X509Certificate[] chain) { - try { - theX509TrustManager.checkServerTrusted(chain, "UNKNOWN"); - return true; - } catch (java.security.cert.CertificateException e) { - return false; - } - } - - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return theX509TrustManager.getAcceptedIssuers(); - } -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/TrustManager.java --- a/src/java.base/share/classes/com/sun/net/ssl/TrustManager.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2000, 2017, 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. - */ - -/* - * NOTE: this file was copied from javax.net.ssl.TrustManager - */ - -package com.sun.net.ssl; - -/** - * Base interface for JSSE trust managers which manage - * authentication trust decisions for different types of - * authentication material. - * - * @deprecated As of JDK 1.4, this implementation-specific class was - * replaced by {@link javax.net.ssl.TrustManager}. - */ -@Deprecated(since="1.4") -public interface TrustManager { -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java --- a/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2000, 2017, 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. - */ - -/* - * NOTE: this file was copied from javax.net.ssl.TrustManagerFactory - */ - -package com.sun.net.ssl; - -import java.security.*; - -/** - * This class acts as a factory for trust managers based on a - * source of trust material. Each trust manager manages a specific - * type of trust material for use by secure sockets. The trust - * material is based on a KeyStore and/or provider specific sources. - * - * @deprecated As of JDK 1.4, this implementation-specific class was - * replaced by {@link javax.net.ssl.TrustManagerFactory}. - */ -@Deprecated(since="1.4") -public class TrustManagerFactory { - // The provider - private Provider provider; - - // The provider implementation (delegate) - private TrustManagerFactorySpi factorySpi; - - // The name of the trust management algorithm. - private String algorithm; - - /** - *

The default TrustManager can be changed by setting the value of the - * {@code sun.ssl.trustmanager.type} security property to the desired name. - * - * @return the default type as specified by the - * {@code sun.ssl.trustmanager.type} security property, or an - * implementation-specific default if no such property exists. - * - * @see java.security.Security security properties - */ - public static final String getDefaultAlgorithm() { - String type; - type = AccessController.doPrivileged(new PrivilegedAction<>() { - public String run() { - return Security.getProperty("sun.ssl.trustmanager.type"); - } - }); - if (type == null) { - type = "SunX509"; - } - return type; - - } - - /** - * Creates a TrustManagerFactory object. - * - * @param factorySpi the delegate - * @param provider the provider - * @param algorithm the algorithm - */ - protected TrustManagerFactory(TrustManagerFactorySpi factorySpi, - Provider provider, String algorithm) { - this.factorySpi = factorySpi; - this.provider = provider; - this.algorithm = algorithm; - } - - /** - * Returns the algorithm name of this TrustManagerFactory - * object. - * - *

This is the same name that was specified in one of the - * getInstance calls that created this - * TrustManagerFactory object. - * - * @return the algorithm name of this TrustManagerFactory - * object. - */ - public final String getAlgorithm() { - return this.algorithm; - } - - /** - * Generates a TrustManagerFactory object that implements the - * specified trust management algorithm. - * If the default provider package provides an implementation of the - * requested trust management algorithm, an instance of - * TrustManagerFactory containing that implementation is - * returned. If the algorithm is not available in the default provider - * package, other provider packages are searched. - * - * @param algorithm the standard name of the requested trust management - * algorithm. - * - * @return the new TrustManagerFactory object - * - * @exception NoSuchAlgorithmException if the specified algorithm is not - * available in the default provider package or any of the other provider - * packages that were searched. - */ - public static final TrustManagerFactory getInstance(String algorithm) - throws NoSuchAlgorithmException - { - try { - Object[] objs = SSLSecurity.getImpl(algorithm, - "TrustManagerFactory", (String) null); - return new TrustManagerFactory((TrustManagerFactorySpi)objs[0], - (Provider)objs[1], - algorithm); - } catch (NoSuchProviderException e) { - throw new NoSuchAlgorithmException(algorithm + " not found"); - } - } - - /** - * Generates a TrustManagerFactory object for the specified - * trust management algorithm from the specified provider. - * - * @param algorithm the standard name of the requested trust management - * algorithm. - * @param provider the name of the provider - * - * @return the new TrustManagerFactory object - * - * @exception NoSuchAlgorithmException if the specified algorithm is not - * available from the specified provider. - * @exception NoSuchProviderException if the specified provider has not - * been configured. - */ - public static final TrustManagerFactory getInstance(String algorithm, - String provider) - throws NoSuchAlgorithmException, NoSuchProviderException - { - if (provider == null || provider.isEmpty()) - throw new IllegalArgumentException("missing provider"); - Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory", - provider); - return new TrustManagerFactory((TrustManagerFactorySpi)objs[0], - (Provider)objs[1], algorithm); - } - - /** - * Generates a TrustManagerFactory object for the specified - * trust management algorithm from the specified provider. - * - * @param algorithm the standard name of the requested trust management - * algorithm. - * @param provider an instance of the provider - * - * @return the new TrustManagerFactory object - * - * @exception NoSuchAlgorithmException if the specified algorithm is not - * available from the specified provider. - */ - public static final TrustManagerFactory getInstance(String algorithm, - Provider provider) - throws NoSuchAlgorithmException - { - if (provider == null) - throw new IllegalArgumentException("missing provider"); - Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory", - provider); - return new TrustManagerFactory((TrustManagerFactorySpi)objs[0], - (Provider)objs[1], algorithm); - } - - /** - * Returns the provider of this TrustManagerFactory object. - * - * @return the provider of this TrustManagerFactory object - */ - public final Provider getProvider() { - return this.provider; - } - - - /** - * Initializes this factory with a source of certificate - * authorities and related trust material. The - * provider may also include a provider-specific source - * of key material. - * - * @param ks the key store or null - */ - public void init(KeyStore ks) throws KeyStoreException { - factorySpi.engineInit(ks); - } - - /** - * Returns one trust manager for each type of trust material. - * @return the trust managers - */ - public TrustManager[] getTrustManagers() { - return factorySpi.engineGetTrustManagers(); - } -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactorySpi.java --- a/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactorySpi.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2000, 2017, 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. - */ - -/* - * NOTE: this file was copied from javax.net.ssl.TrustManagerFactorySpi - */ - -package com.sun.net.ssl; - -import java.security.*; - -/** - * This class defines the Service Provider Interface (SPI) - * for the TrustManagerFactory class. - * - *

All the abstract methods in this class must be implemented by each - * cryptographic service provider who wishes to supply the implementation - * of a particular trust manager factory. - * - * @deprecated As of JDK 1.4, this implementation-specific class was - * replaced by {@link javax.net.ssl.TrustManagerFactorySpi}. - */ -@Deprecated(since="1.4") -public abstract class TrustManagerFactorySpi { - /** - * Initializes this factory with a source of certificate - * authorities and related trust material. The - * provider may also include a provider-specific source - * of key material. - * - * @param ks the key store or null - */ - protected abstract void engineInit(KeyStore ks) throws KeyStoreException; - - /** - * Returns one trust manager for each type of trust material. - * @return the trust managers - */ - protected abstract TrustManager[] engineGetTrustManagers(); -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/X509KeyManager.java --- a/src/java.base/share/classes/com/sun/net/ssl/X509KeyManager.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2000, 2017, 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. - */ - -/* - * NOTE: this file was copied from javax.net.ssl.X509KeyManager - */ - -package com.sun.net.ssl; - -import java.security.KeyManagementException; -import java.security.PrivateKey; -import java.security.Principal; -import java.security.cert.X509Certificate; - -/** - * Instances of this interface manage which X509 certificate-based - * key pairs are used to authenticate the local side of a secure - * socket. The individual entries are identified by unique alias names. - * - * @deprecated As of JDK 1.4, this implementation-specific class was - * replaced by {@link javax.net.ssl.X509KeyManager}. - */ -@Deprecated(since="1.4") -public interface X509KeyManager extends KeyManager { - /** - * Get the matching aliases for authenticating the client side of a secure - * socket given the public key type and the list of - * certificate issuer authorities recognized by the peer (if any). - * - * @param keyType the key algorithm type name - * @param issuers the list of acceptable CA issuer subject names - * @return the matching alias names - */ - public String[] getClientAliases(String keyType, Principal[] issuers); - - /** - * Choose an alias to authenticate the client side of a secure - * socket given the public key type and the list of - * certificate issuer authorities recognized by the peer (if any). - * - * @param keyType the key algorithm type name - * @param issuers the list of acceptable CA issuer subject names - * @return the alias name for the desired key - */ - public String chooseClientAlias(String keyType, Principal[] issuers); - - /** - * Get the matching aliases for authenticating the server side of a secure - * socket given the public key type and the list of - * certificate issuer authorities recognized by the peer (if any). - * - * @param keyType the key algorithm type name - * @param issuers the list of acceptable CA issuer subject names - * @return the matching alias names - */ - public String[] getServerAliases(String keyType, Principal[] issuers); - - /** - * Choose an alias to authenticate the server side of a secure - * socket given the public key type and the list of - * certificate issuer authorities recognized by the peer (if any). - * - * @param keyType the key algorithm type name - * @param issuers the list of acceptable CA issuer subject names - * @return the alias name for the desired key - */ - public String chooseServerAlias(String keyType, Principal[] issuers); - - /** - * Returns the certificate chain associated with the given alias. - * - * @param alias the alias name - * - * @return the certificate chain (ordered with the user's certificate first - * and the root certificate authority last) - */ - public X509Certificate[] getCertificateChain(String alias); - - /* - * Returns the key associated with the given alias. - * - * @param alias the alias name - * - * @return the requested key - */ - public PrivateKey getPrivateKey(String alias); -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/X509TrustManager.java --- a/src/java.base/share/classes/com/sun/net/ssl/X509TrustManager.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2000, 2017, 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. - */ - -/* - * NOTE: this file was copied from javax.net.ssl.X509TrustManager - */ - -package com.sun.net.ssl; - -import java.security.cert.X509Certificate; - -/** - * Instance of this interface manage which X509 certificates - * may be used to authenticate the remote side of a secure - * socket. Decisions may be based on trusted certificate - * authorities, certificate revocation lists, online - * status checking or other means. - * - * @deprecated As of JDK 1.4, this implementation-specific class was - * replaced by {@link javax.net.ssl.X509TrustManager}. - */ -@Deprecated(since="1.4") -public interface X509TrustManager extends TrustManager { - /** - * Given the partial or complete certificate chain - * provided by the peer, build a certificate path - * to a trusted root and return true if it can be - * validated and is trusted for client SSL authentication. - * - * @param chain the peer certificate chain - */ - public boolean isClientTrusted(X509Certificate[] chain); - - /** - * Given the partial or complete certificate chain - * provided by the peer, build a certificate path - * to a trusted root and return true if it can be - * validated and is trusted for server SSL authentication. - * - * @param chain the peer certificate chain - */ - public boolean isServerTrusted(X509Certificate[] chain); - - /** - * Return an array of certificate authority certificates - * which are trusted for authenticating peers. - * - * @return the acceptable CA issuer certificates - */ - public X509Certificate[] getAcceptedIssuers(); -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/internal/ssl/Provider.java --- a/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/Provider.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.net.ssl.internal.ssl; - -import sun.security.ssl.SunJSSE; - -/** - * Main class for the SunJSSE provider. The actual code was moved to the - * class sun.security.ssl.SunJSSE, but for backward compatibility we - * continue to use this class as the main Provider class. - */ -@Deprecated(since="9") -public final class Provider extends SunJSSE { - - private static final long serialVersionUID = 3231825739635378733L; - - // standard constructor - public Provider() { - super(); - } - - /** - * Installs the JSSE provider. - */ - public static synchronized void install() { - /* nop. Remove this method in the future. */ - } - -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/internal/ssl/X509ExtendedTrustManager.java --- a/src/java.base/share/classes/com/sun/net/ssl/internal/ssl/X509ExtendedTrustManager.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.net.ssl.internal.ssl; - -import javax.net.ssl.X509TrustManager; - -import java.security.cert.X509Certificate; -import java.security.cert.CertificateException; - -/** - * Instance of this class is an extension of X509TrustManager. - *

- * Note that this class is referenced by the Deploy workspace. Any updates - * must make sure that they do not cause any breakage there. - *

- * It takes the responsiblity of checking the peer identity with its - * principal declared in the cerificate. - *

- * The class provides an alternative to HostnameVerifer. - * If application customizes its HostnameVerifer for - * HttpsURLConnection, the peer identity will be checked - * by the customized HostnameVerifer; otherwise, it will - * be checked by the extended trust manager. - *

- * RFC2830 defines the server identification specification for "LDAP" - * algorithm. RFC2818 defines both the server identification and the - * client identification specification for "HTTPS" algorithm. - * - * @see X509TrustManager - * @see HostnameVerifier - * - * @since 1.6 - * @author Xuelei Fan - */ -@Deprecated(since="9") -public abstract class X509ExtendedTrustManager implements X509TrustManager { - /** - * Constructor used by subclasses only. - */ - protected X509ExtendedTrustManager() { - } - - /** - * Given the partial or complete certificate chain provided by the - * peer, check its identity and build a certificate path to a trusted - * root, return if it can be validated and is trusted for client SSL - * authentication based on the authentication type. - *

- * The authentication type is determined by the actual certificate - * used. For instance, if RSAPublicKey is used, the authType - * should be "RSA". Checking is case-sensitive. - *

- * The algorithm parameter specifies the client identification protocol - * to use. If the algorithm and the peer hostname are available, the - * peer hostname is checked against the peer's identity presented in - * the X509 certificate, in order to prevent masquerade attacks. - * - * @param chain the peer certificate chain - * @param authType the authentication type based on the client certificate - * @param hostname the peer hostname - * @param algorithm the identification algorithm - * @throws IllegalArgumentException if null or zero-length chain - * is passed in for the chain parameter or if null or zero-length - * string is passed in for the authType parameter - * @throws CertificateException if the certificate chain is not trusted - * by this TrustManager. - */ - public abstract void checkClientTrusted(X509Certificate[] chain, - String authType, String hostname, String algorithm) - throws CertificateException; - - /** - * Given the partial or complete certificate chain provided by the - * peer, check its identity and build a certificate path to a trusted - * root, return if it can be validated and is trusted for server SSL - * authentication based on the authentication type. - *

- * The authentication type is the key exchange algorithm portion - * of the cipher suites represented as a String, such as "RSA", - * "DHE_DSS". Checking is case-sensitive. - *

- * The algorithm parameter specifies the server identification protocol - * to use. If the algorithm and the peer hostname are available, the - * peer hostname is checked against the peer's identity presented in - * the X509 certificate, in order to prevent masquerade attacks. - * - * @param chain the peer certificate chain - * @param authType the key exchange algorithm used - * @param hostname the peer hostname - * @param algorithm the identification algorithm - * @throws IllegalArgumentException if null or zero-length chain - * is passed in for the chain parameter or if null or zero-length - * string is passed in for the authType parameter - * @throws CertificateException if the certificate chain is not trusted - * by this TrustManager. - */ - public abstract void checkServerTrusted(X509Certificate[] chain, - String authType, String hostname, String algorithm) - throws CertificateException; -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.java --- a/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.net.ssl.internal.www.protocol.https; - -import java.net.URL; -import java.net.Proxy; -import java.io.IOException; -import java.util.Collection; -import java.util.List; -import java.util.Iterator; - -import java.security.Principal; -import java.security.cert.*; - -import javax.security.auth.x500.X500Principal; - -import sun.security.util.HostnameChecker; -import sun.security.util.DerValue; -import sun.security.x509.X500Name; - -import sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection; - -/** - * This class was introduced to provide an additional level of - * abstraction between javax.net.ssl.HttpURLConnection and - * com.sun.net.ssl.HttpURLConnection objects.

- * - * javax.net.ssl.HttpURLConnection is used in the new sun.net version - * of protocol implementation (this one) - * com.sun.net.ssl.HttpURLConnection is used in the com.sun version. - * - */ -@Deprecated(since="9") -@SuppressWarnings("deprecation") // HttpsURLConnection is deprecated -public class DelegateHttpsURLConnection extends AbstractDelegateHttpsURLConnection { - - // we need a reference to the HttpsURLConnection to get - // the properties set there - // we also need it to be public so that it can be referenced - // from sun.net.www.protocol.http.HttpURLConnection - // this is for ResponseCache.put(URI, URLConnection) - // second parameter needs to be cast to javax.net.ssl.HttpsURLConnection - // instead of AbstractDelegateHttpsURLConnection - - public com.sun.net.ssl.HttpsURLConnection httpsURLConnection; - - DelegateHttpsURLConnection(URL url, - sun.net.www.protocol.http.Handler handler, - com.sun.net.ssl.HttpsURLConnection httpsURLConnection) - throws IOException { - this(url, null, handler, httpsURLConnection); - } - - DelegateHttpsURLConnection(URL url, Proxy p, - sun.net.www.protocol.http.Handler handler, - com.sun.net.ssl.HttpsURLConnection httpsURLConnection) - throws IOException { - super(url, p, handler); - this.httpsURLConnection = httpsURLConnection; - } - - protected javax.net.ssl.SSLSocketFactory getSSLSocketFactory() { - return httpsURLConnection.getSSLSocketFactory(); - } - - protected javax.net.ssl.HostnameVerifier getHostnameVerifier() { - // note: getHostnameVerifier() never returns null - return new VerifierWrapper(httpsURLConnection.getHostnameVerifier()); - } - - /* - * Called by layered delegator's finalize() method to handle closing - * the underlying object. - */ - protected void dispose() throws Throwable { - super.finalize(); - } -} - -class VerifierWrapper implements javax.net.ssl.HostnameVerifier { - @SuppressWarnings("deprecation") - private com.sun.net.ssl.HostnameVerifier verifier; - - @SuppressWarnings("deprecation") - VerifierWrapper(com.sun.net.ssl.HostnameVerifier verifier) { - this.verifier = verifier; - } - - /* - * In com.sun.net.ssl.HostnameVerifier the method is defined - * as verify(String urlHostname, String certHostname). - * This means we need to extract the hostname from the X.509 certificate - * in this wrapper. - */ - public boolean verify(String hostname, javax.net.ssl.SSLSession session) { - try { - Certificate[] serverChain = session.getPeerCertificates(); - if ((serverChain == null) || (serverChain.length == 0)) { - return false; - } - if (serverChain[0] instanceof X509Certificate == false) { - return false; - } - X509Certificate serverCert = (X509Certificate)serverChain[0]; - String serverName = getServername(serverCert); - if (serverName == null) { - return false; - } - return verifier.verify(hostname, serverName); - } catch (javax.net.ssl.SSLPeerUnverifiedException e) { - return false; - } - } - - /* - * Extract the name of the SSL server from the certificate. - * - * Note this code is essentially a subset of the hostname extraction - * code in HostnameChecker. - */ - private static String getServername(X509Certificate peerCert) { - try { - // compare to subjectAltNames if dnsName is present - Collection> subjAltNames = peerCert.getSubjectAlternativeNames(); - if (subjAltNames != null) { - for (Iterator> itr = subjAltNames.iterator(); itr.hasNext(); ) { - List next = itr.next(); - if (((Integer)next.get(0)).intValue() == 2) { - // compare dNSName with host in url - String dnsName = ((String)next.get(1)); - return dnsName; - } - } - } - - // else check against common name in the subject field - X500Name subject = HostnameChecker.getSubjectX500Name(peerCert); - - DerValue derValue = subject.findMostSpecificAttribute - (X500Name.commonName_oid); - if (derValue != null) { - try { - String name = derValue.getAsString(); - return name; - } catch (IOException e) { - // ignore - } - } - } catch (java.security.cert.CertificateException e) { - // ignore - } - return null; - } - -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/Handler.java --- a/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/Handler.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.net.ssl.internal.www.protocol.https; - -import java.io.IOException; -import java.net.URL; -import java.net.Proxy; - -/** - * This class exists for compatibility with previous JSSE releases - * only. The HTTPS implementation can now be found in - * sun.net.www.protocol.https. - * - */ -@Deprecated(since="9") -public class Handler extends sun.net.www.protocol.https.Handler { - - public Handler() { - super(); - } - - public Handler(String proxy, int port) { - super(proxy, port); - } - - protected java.net.URLConnection openConnection(URL u) throws IOException { - return openConnection(u, (Proxy)null); - } - - protected java.net.URLConnection openConnection(URL u, Proxy p) throws IOException { - return new HttpsURLConnectionOldImpl(u, p, this); - } -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnectionOldImpl.java --- a/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnectionOldImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,506 +0,0 @@ -/* - * Copyright (c) 1996, 2017, 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. - */ - -/* - * NOTE: This class lives in the package sun.net.www.protocol.https. - * There is a copy in com.sun.net.ssl.internal.www.protocol.https for JSSE - * 1.0.2 compatibility. It is 100% identical except the package and extends - * lines. Any changes should be made to be class in sun.net.* and then copied - * to com.sun.net.*. - */ - -// For both copies of the file, uncomment one line and comment the other -// package sun.net.www.protocol.https; -package com.sun.net.ssl.internal.www.protocol.https; - -import java.net.URL; -import java.net.Proxy; -import java.net.ProtocolException; -import java.net.MalformedURLException; -import java.io.*; -import java.net.Authenticator; -import javax.net.ssl.*; -import java.security.Permission; -import java.util.Map; -import java.util.List; -import sun.net.www.http.HttpClient; - -/** - * A class to represent an HTTP connection to a remote object. - * - * Ideally, this class should subclass and inherit the http handler - * implementation, but it can't do so because that class have the - * wrong Java Type. Thus it uses the delegate (aka, the - * Adapter/Wrapper design pattern) to reuse code from the http - * handler. - * - * Since it would use a delegate to access - * sun.net.www.protocol.http.HttpURLConnection functionalities, it - * needs to implement all public methods in it's super class and all - * the way to Object. - * - */ - -// For both copies of the file, uncomment one line and comment the other -// public class HttpsURLConnectionImpl -// extends javax.net.ssl.HttpsURLConnection { -@Deprecated(since="9") -@SuppressWarnings("deprecation") // HttpsURLConnection is deprecated -public class HttpsURLConnectionOldImpl - extends com.sun.net.ssl.HttpsURLConnection { - - private DelegateHttpsURLConnection delegate; - -// For both copies of the file, uncomment one line and comment the other -// HttpsURLConnectionImpl(URL u, Handler handler) throws IOException { - HttpsURLConnectionOldImpl(URL u, Handler handler) throws IOException { - this(u, null, handler); - } - - static URL checkURL(URL u) throws IOException { - if (u != null) { - if (u.toExternalForm().indexOf('\n') > -1) { - throw new MalformedURLException("Illegal character in URL"); - } - } - return u; - } -// For both copies of the file, uncomment one line and comment the other -// HttpsURLConnectionImpl(URL u, Handler handler) throws IOException { - HttpsURLConnectionOldImpl(URL u, Proxy p, Handler handler) throws IOException { - super(checkURL(u)); - delegate = new DelegateHttpsURLConnection(url, p, handler, this); - } - - /** - * Create a new HttpClient object, bypassing the cache of - * HTTP client objects/connections. - * - * @param url the URL being accessed - */ - protected void setNewClient(URL url) throws IOException { - delegate.setNewClient(url, false); - } - - /** - * Obtain a HttpClient object. Use the cached copy if specified. - * - * @param url the URL being accessed - * @param useCache whether the cached connection should be used - * if present - */ - protected void setNewClient(URL url, boolean useCache) - throws IOException { - delegate.setNewClient(url, useCache); - } - - /** - * Create a new HttpClient object, set up so that it uses - * per-instance proxying to the given HTTP proxy. This - * bypasses the cache of HTTP client objects/connections. - * - * @param url the URL being accessed - * @param proxyHost the proxy host to use - * @param proxyPort the proxy port to use - */ - protected void setProxiedClient(URL url, String proxyHost, int proxyPort) - throws IOException { - delegate.setProxiedClient(url, proxyHost, proxyPort); - } - - /** - * Obtain a HttpClient object, set up so that it uses per-instance - * proxying to the given HTTP proxy. Use the cached copy of HTTP - * client objects/connections if specified. - * - * @param url the URL being accessed - * @param proxyHost the proxy host to use - * @param proxyPort the proxy port to use - * @param useCache whether the cached connection should be used - * if present - */ - protected void setProxiedClient(URL url, String proxyHost, int proxyPort, - boolean useCache) throws IOException { - delegate.setProxiedClient(url, proxyHost, proxyPort, useCache); - } - - /** - * Implements the HTTP protocol handler's "connect" method, - * establishing an SSL connection to the server as necessary. - */ - public void connect() throws IOException { - delegate.connect(); - } - - /** - * Used by subclass to access "connected" variable. Since we are - * delegating the actual implementation to "delegate", we need to - * delegate the access of "connected" as well. - */ - protected boolean isConnected() { - return delegate.isConnected(); - } - - /** - * Used by subclass to access "connected" variable. Since we are - * delegating the actual implementation to "delegate", we need to - * delegate the access of "connected" as well. - */ - protected void setConnected(boolean conn) { - delegate.setConnected(conn); - } - - /** - * Returns the cipher suite in use on this connection. - */ - public String getCipherSuite() { - return delegate.getCipherSuite(); - } - - /** - * Returns the certificate chain the client sent to the - * server, or null if the client did not authenticate. - */ - public java.security.cert.Certificate [] - getLocalCertificates() { - return delegate.getLocalCertificates(); - } - - /** - * Returns the server's certificate chain, or throws - * SSLPeerUnverified Exception if - * the server did not authenticate. - */ - public java.security.cert.Certificate [] - getServerCertificates() throws SSLPeerUnverifiedException { - return delegate.getServerCertificates(); - } - - /* - * Allowable input/output sequences: - * [interpreted as POST/PUT] - * - get output, [write output,] get input, [read input] - * - get output, [write output] - * [interpreted as GET] - * - get input, [read input] - * Disallowed: - * - get input, [read input,] get output, [write output] - */ - - public synchronized OutputStream getOutputStream() throws IOException { - return delegate.getOutputStream(); - } - - public synchronized InputStream getInputStream() throws IOException { - return delegate.getInputStream(); - } - - public InputStream getErrorStream() { - return delegate.getErrorStream(); - } - - /** - * Disconnect from the server. - */ - public void disconnect() { - delegate.disconnect(); - } - - public boolean usingProxy() { - return delegate.usingProxy(); - } - - /** - * Returns an unmodifiable Map of the header fields. - * The Map keys are Strings that represent the - * response-header field names. Each Map value is an - * unmodifiable List of Strings that represents - * the corresponding field values. - * - * @return a Map of header fields - * @since 1.4 - */ - public Map> getHeaderFields() { - return delegate.getHeaderFields(); - } - - /** - * Gets a header field by name. Returns null if not known. - * @param name the name of the header field - */ - public String getHeaderField(String name) { - return delegate.getHeaderField(name); - } - - /** - * Gets a header field by index. Returns null if not known. - * @param n the index of the header field - */ - public String getHeaderField(int n) { - return delegate.getHeaderField(n); - } - - /** - * Gets a header field by index. Returns null if not known. - * @param n the index of the header field - */ - public String getHeaderFieldKey(int n) { - return delegate.getHeaderFieldKey(n); - } - - /** - * Sets request property. If a property with the key already - * exists, overwrite its value with the new value. - * @param value the value to be set - */ - public void setRequestProperty(String key, String value) { - delegate.setRequestProperty(key, value); - } - - /** - * Adds a general request property specified by a - * key-value pair. This method will not overwrite - * existing values associated with the same key. - * - * @param key the keyword by which the request is known - * (e.g., "accept"). - * @param value the value associated with it. - * @see #getRequestProperties(java.lang.String) - * @since 1.4 - */ - public void addRequestProperty(String key, String value) { - delegate.addRequestProperty(key, value); - } - - /** - * Overwrite super class method - */ - public int getResponseCode() throws IOException { - return delegate.getResponseCode(); - } - - public String getRequestProperty(String key) { - return delegate.getRequestProperty(key); - } - - /** - * Returns an unmodifiable Map of general request - * properties for this connection. The Map keys - * are Strings that represent the request-header - * field names. Each Map value is a unmodifiable List - * of Strings that represents the corresponding - * field values. - * - * @return a Map of the general request properties for this connection. - * @throws IllegalStateException if already connected - * @since 1.4 - */ - public Map> getRequestProperties() { - return delegate.getRequestProperties(); - } - - /* - * We support JDK 1.2.x so we can't count on these from JDK 1.3. - * We override and supply our own version. - */ - public void setInstanceFollowRedirects(boolean shouldFollow) { - delegate.setInstanceFollowRedirects(shouldFollow); - } - - public boolean getInstanceFollowRedirects() { - return delegate.getInstanceFollowRedirects(); - } - - public void setRequestMethod(String method) throws ProtocolException { - delegate.setRequestMethod(method); - } - - public String getRequestMethod() { - return delegate.getRequestMethod(); - } - - public String getResponseMessage() throws IOException { - return delegate.getResponseMessage(); - } - - public long getHeaderFieldDate(String name, long Default) { - return delegate.getHeaderFieldDate(name, Default); - } - - public Permission getPermission() throws IOException { - return delegate.getPermission(); - } - - public URL getURL() { - return delegate.getURL(); - } - - public int getContentLength() { - return delegate.getContentLength(); - } - - public long getContentLengthLong() { - return delegate.getContentLengthLong(); - } - - public String getContentType() { - return delegate.getContentType(); - } - - public String getContentEncoding() { - return delegate.getContentEncoding(); - } - - public long getExpiration() { - return delegate.getExpiration(); - } - - public long getDate() { - return delegate.getDate(); - } - - public long getLastModified() { - return delegate.getLastModified(); - } - - public int getHeaderFieldInt(String name, int Default) { - return delegate.getHeaderFieldInt(name, Default); - } - - public long getHeaderFieldLong(String name, long Default) { - return delegate.getHeaderFieldLong(name, Default); - } - - public Object getContent() throws IOException { - return delegate.getContent(); - } - - @SuppressWarnings("rawtypes") - public Object getContent(Class[] classes) throws IOException { - return delegate.getContent(classes); - } - - public String toString() { - return delegate.toString(); - } - - public void setDoInput(boolean doinput) { - delegate.setDoInput(doinput); - } - - public boolean getDoInput() { - return delegate.getDoInput(); - } - - public void setDoOutput(boolean dooutput) { - delegate.setDoOutput(dooutput); - } - - public boolean getDoOutput() { - return delegate.getDoOutput(); - } - - public void setAllowUserInteraction(boolean allowuserinteraction) { - delegate.setAllowUserInteraction(allowuserinteraction); - } - - public boolean getAllowUserInteraction() { - return delegate.getAllowUserInteraction(); - } - - public void setUseCaches(boolean usecaches) { - delegate.setUseCaches(usecaches); - } - - public boolean getUseCaches() { - return delegate.getUseCaches(); - } - - public void setIfModifiedSince(long ifmodifiedsince) { - delegate.setIfModifiedSince(ifmodifiedsince); - } - - public long getIfModifiedSince() { - return delegate.getIfModifiedSince(); - } - - public boolean getDefaultUseCaches() { - return delegate.getDefaultUseCaches(); - } - - public void setDefaultUseCaches(boolean defaultusecaches) { - delegate.setDefaultUseCaches(defaultusecaches); - } - - /* - * finalize (dispose) the delegated object. Otherwise - * sun.net.www.protocol.http.HttpURLConnection's finalize() - * would have to be made public. - */ - protected void finalize() throws Throwable { - delegate.dispose(); - } - - public boolean equals(Object obj) { - return delegate.equals(obj); - } - - public int hashCode() { - return delegate.hashCode(); - } - - public void setConnectTimeout(int timeout) { - delegate.setConnectTimeout(timeout); - } - - public int getConnectTimeout() { - return delegate.getConnectTimeout(); - } - - public void setReadTimeout(int timeout) { - delegate.setReadTimeout(timeout); - } - - public int getReadTimeout() { - return delegate.getReadTimeout(); - } - - public void setFixedLengthStreamingMode (int contentLength) { - delegate.setFixedLengthStreamingMode(contentLength); - } - - public void setFixedLengthStreamingMode(long contentLength) { - delegate.setFixedLengthStreamingMode(contentLength); - } - - public void setChunkedStreamingMode (int chunklen) { - delegate.setChunkedStreamingMode(chunklen); - } - - @Override - public void setAuthenticator(Authenticator auth) { - delegate.setAuthenticator(auth); - } -} diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/com/sun/net/ssl/package-info.java --- a/src/java.base/share/classes/com/sun/net/ssl/package-info.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Provides classes related to creating and configuring secure socket - * factories. These classes are used with the Sun reference - * implementation of the Java Secure Socket Extension (JSSE). - */ -package com.sun.net.ssl; diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/lang/AbstractStringBuilder.java --- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java Sat Mar 09 12:54:20 2019 +0000 @@ -93,13 +93,16 @@ /** * Creates an AbstractStringBuilder with the specified coder and with - * the initial capacity equal to the smaller of (capacity + addition) + * the initial capacity equal to the smaller of (length + addition) * and Integer.MAX_VALUE. */ - AbstractStringBuilder(byte coder, int capacity, int addition) { + AbstractStringBuilder(byte coder, int length, int addition) { + if (length < 0) { + throw new NegativeArraySizeException("Negative length: " + length); + } this.coder = coder; - capacity = (capacity < Integer.MAX_VALUE - addition) - ? capacity + addition : Integer.MAX_VALUE; + int capacity = (length < Integer.MAX_VALUE - addition) + ? length + addition : Integer.MAX_VALUE; value = (coder == LATIN1) ? new byte[capacity] : StringUTF16.newBytesFor(capacity); } diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/lang/StringBuffer.java --- a/src/java.base/share/classes/java/lang/StringBuffer.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/lang/StringBuffer.java Sat Mar 09 12:54:20 2019 +0000 @@ -157,10 +157,6 @@ * as the specified {@code CharSequence}. The initial capacity of * the string buffer is {@code 16} plus the length of the * {@code CharSequence} argument. - *

- * If the length of the specified {@code CharSequence} is - * less than or equal to zero, then an empty buffer of capacity - * {@code 16} is returned. * * @param seq the sequence to copy. * @since 1.5 diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/nio/Buffer.java --- a/src/java.base/share/classes/java/nio/Buffer.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/nio/Buffer.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -134,8 +134,9 @@ * it already contains: It leaves the limit unchanged and sets the position * to zero.

* - *
  • {@link #slice} creates a subsequence of a buffer: It leaves the - * limit and the position unchanged.

  • + *
  • The {@link #slice} and {@link #slice(int,int) slice(index,length)} + * methods create a subsequence of a buffer: They leave the limit and the + * position unchanged.

  • * *
  • {@link #duplicate} creates a shallow copy of a buffer: It leaves * the limit and the position unchanged.

  • @@ -600,6 +601,39 @@ public abstract Buffer slice(); /** + * Creates a new buffer whose content is a shared subsequence of + * this buffer's content. + * + *

    The content of the new buffer will start at position {@code index} + * in this buffer, and will contain {@code length} elements. Changes to + * this buffer's content will be visible in the new buffer, and vice versa; + * the two buffers' position, limit, and mark values will be independent. + * + *

    The new buffer's position will be zero, its capacity and its limit + * will be {@code length}, its mark will be undefined. The new buffer will + * be direct if, and only if, this buffer is direct, and it will be + * read-only if, and only if, this buffer is read-only.

    + * + * @param index + * The position in this buffer at which the content of the new + * buffer will start; must be non-negative and no larger than + * {@link #limit() limit()} + * + * @param length + * The number of elements the new buffer will contain; must be + * non-negative and no larger than {@code limit() - index} + * + * @return The new buffer + * + * @throws IndexOutOfBoundsException + * If {@code index} is negative or greater than {@code limit()}, + * {@code length} is negative, or {@code length > limit() - index} + * + * @since 13 + */ + public abstract Buffer slice(int index, int length); + + /** * Creates a new buffer that shares this buffer's content. * *

    The content of the new buffer will be that of this buffer. Changes diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template --- a/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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,9 +27,9 @@ package java.nio; +import java.util.Objects; import jdk.internal.misc.Unsafe; - class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private extends {#if[ro]?ByteBufferAs}$Type$Buffer{#if[ro]?$BO$} { @@ -85,6 +85,18 @@ return new ByteBufferAs$Type$Buffer$RW$$BO$(bb, -1, 0, rem, rem, addr); } + @Override + public $Type$Buffer slice(int index, int length) { + Objects.checkIndex(index, limit() + 1); + Objects.checkIndex(length, limit() - index + 1); + return new ByteBufferAs$Type$Buffer$RW$$BO$(bb, + -1, + 0, + length, + length, + byteOffset(index)); + } + public $Type$Buffer duplicate() { return new ByteBufferAs$Type$Buffer$RW$$BO$(bb, this.markValue(), diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template --- a/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000 @@ -218,14 +218,17 @@ return new Direct$Type$Buffer$RW$$BO$(this, -1, 0, rem, rem, off); } -#if[byte] - public $Type$Buffer slice(int pos, int lim) { - assert (pos >= 0); - assert (pos <= lim); - int rem = lim - pos; - return new Direct$Type$Buffer$RW$$BO$(this, -1, 0, rem, rem, pos); + @Override + public $Type$Buffer slice(int index, int length) { + Objects.checkIndex(index, limit() + 1); + Objects.checkIndex(length, limit() - index + 1); + return new Direct$Type$Buffer$RW$$BO$(this, + -1, + 0, + length, + length, + index); } -#end[byte] public $Type$Buffer duplicate() { return new Direct$Type$Buffer$RW$$BO$(this, diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template --- a/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000 @@ -27,6 +27,8 @@ package java.nio; +import java.util.Objects; + /** #if[rw] * A read/write Heap$Type$Buffer. @@ -38,8 +40,6 @@ #end[rw] */ -import java.util.Objects; - class Heap$Type$Buffer$RW$ extends {#if[ro]?Heap}$Type$Buffer { @@ -112,19 +112,17 @@ this.position() + offset); } -#if[byte] - $Type$Buffer slice(int pos, int lim) { - assert (pos >= 0); - assert (pos <= lim); - int rem = lim - pos; + @Override + public $Type$Buffer slice(int index, int length) { + Objects.checkIndex(index, limit() + 1); + Objects.checkIndex(length, limit() - index + 1); return new Heap$Type$Buffer$RW$(hb, -1, 0, - rem, - rem, - pos + offset); + length, + length, + index + offset); } -#end[byte] public $Type$Buffer duplicate() { return new Heap$Type$Buffer$RW$(hb, diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/nio/StringCharBuffer.java --- a/src/java.base/share/classes/java/nio/StringCharBuffer.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/nio/StringCharBuffer.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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,6 +25,7 @@ package java.nio; +import java.util.Objects; // ## If the sequence is a string, use reflection to share its array @@ -51,6 +52,18 @@ offset + this.position()); } + @Override + public CharBuffer slice(int index, int length) { + Objects.checkIndex(index, limit() + 1); + Objects.checkIndex(length, limit() - index + 1); + return new StringCharBuffer(str, + -1, + 0, + length, + length, + offset + index); + } + private StringCharBuffer(CharSequence s, int mark, int pos, diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/nio/X-Buffer.java.template --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template Sat Mar 09 12:54:20 2019 +0000 @@ -547,6 +547,46 @@ public abstract $Type$Buffer slice(); /** + * Creates a new $type$ buffer whose content is a shared subsequence of + * this buffer's content. + * + *

    The content of the new buffer will start at position {@code index} + * in this buffer, and will contain {@code length} elements. Changes to + * this buffer's content will be visible in the new buffer, and vice versa; + * the two buffers' position, limit, and mark values will be independent. + * + *

    The new buffer's position will be zero, its capacity and its limit + * will be {@code length}, its mark will be undefined, and its byte order + * will be +#if[byte] + * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. +#else[byte] + * identical to that of this buffer. +#end[byte] + * The new buffer will be direct if, and only if, this buffer is direct, + * and it will be read-only if, and only if, this buffer is read-only.

    + * + * @param index + * The position in this buffer at which the content of the new + * buffer will start; must be non-negative and no larger than + * {@link #limit() limit()} + * + * @param length + * The number of elements the new buffer will contain; must be + * non-negative and no larger than {@code limit() - index} + * + * @return The new buffer + * + * @throws IndexOutOfBoundsException + * If {@code index} is negative or greater than {@code limit()}, + * {@code length} is negative, or {@code length > limit() - index} + * + * @since 13 + */ + @Override + public abstract $Type$Buffer slice(int index, int length); + + /** * Creates a new $type$ buffer that shares this buffer's content. * *

    The content of the new buffer will be that of this buffer. Changes @@ -1950,11 +1990,9 @@ aligned_pos = aligned_lim = pos; } - return slice(aligned_pos, aligned_lim); + return slice(aligned_pos, aligned_lim - aligned_pos); } - abstract ByteBuffer slice(int pos, int lim); - // #BIN // // Binary-data access methods for short, char, int, long, float, diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/security/Security.java --- a/src/java.base/share/classes/java/security/Security.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/security/Security.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -201,7 +201,7 @@ private static void initializeStatic() { props.put("security.provider.1", "sun.security.provider.Sun"); props.put("security.provider.2", "sun.security.rsa.SunRsaSign"); - props.put("security.provider.3", "com.sun.net.ssl.internal.ssl.Provider"); + props.put("security.provider.3", "sun.security.ssl.SunJSSE"); props.put("security.provider.4", "com.sun.crypto.provider.SunJCE"); props.put("security.provider.5", "sun.security.jgss.SunProvider"); props.put("security.provider.6", "com.sun.security.sasl.Provider"); diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/security/Signature.java --- a/src/java.base/share/classes/java/security/Signature.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/security/Signature.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -285,7 +285,6 @@ signatureInfo.put("sun.security.rsa.RSASignature$SHA384withRSA", TRUE); signatureInfo.put("sun.security.rsa.RSASignature$SHA512withRSA", TRUE); signatureInfo.put("sun.security.rsa.RSAPSSSignature", TRUE); - signatureInfo.put("com.sun.net.ssl.internal.ssl.RSASignature", TRUE); signatureInfo.put("sun.security.pkcs11.P11Signature", TRUE); } diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/java/util/JapaneseImperialCalendar.java --- a/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -1022,9 +1022,11 @@ String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); - // If the ERA value is null, then + // If the ERA value is null or empty, then // try to get its name or abbreviation from the Era instance. - if (name == null && field == ERA && fieldValue < eras.length) { + if ((name == null || name.isEmpty()) && + field == ERA && + fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java --- a/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -71,10 +71,6 @@ * Create a new HttpClient object, bypassing the cache of * HTTP client objects/connections. * - * Note: this method is changed from protected to public because - * the com.sun.ssl.internal.www.protocol.https handler reuses this - * class for its actual implemantation - * * @param url the URL being accessed */ public void setNewClient (URL url) @@ -85,10 +81,6 @@ /** * Obtain a HttpClient object. Use the cached copy if specified. * - * Note: this method is changed from protected to public because - * the com.sun.ssl.internal.www.protocol.https handler reuses this - * class for its actual implemantation - * * @param url the URL being accessed * @param useCache whether the cached connection should be used * if present @@ -107,10 +99,6 @@ * per-instance proxying to the given HTTP proxy. This * bypasses the cache of HTTP client objects/connections. * - * Note: this method is changed from protected to public because - * the com.sun.ssl.internal.www.protocol.https handler reuses this - * class for its actual implemantation - * * @param url the URL being accessed * @param proxyHost the proxy host to use * @param proxyPort the proxy port to use @@ -125,10 +113,6 @@ * proxying to the given HTTP proxy. Use the cached copy of HTTP * client objects/connections if specified. * - * Note: this method is changed from protected to public because - * the com.sun.ssl.internal.www.protocol.https handler reuses this - * class for its actual implemantation - * * @param url the URL being accessed * @param proxyHost the proxy host to use * @param proxyPort the proxy port to use diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java --- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,17 +23,7 @@ * questions. */ -/* - * NOTE: This class lives in the package sun.net.www.protocol.https. - * There is a copy in com.sun.net.ssl.internal.www.protocol.https for JSSE - * 1.0.2 compatibility. It is 100% identical except the package and extends - * lines. Any changes should be made to be class in sun.net.* and then copied - * to com.sun.net.*. - */ - -// For both copies of the file, uncomment one line and comment the other package sun.net.www.protocol.https; -// package com.sun.net.ssl.internal.www.protocol.https; import java.net.URL; import java.net.Proxy; @@ -64,21 +54,13 @@ * the way to Object. * */ - -// For both copies of the file, uncomment one line and comment the -// other. The differences between the two copies are introduced for -// plugin, and it is marked as such. public class HttpsURLConnectionImpl extends javax.net.ssl.HttpsURLConnection { -// public class HttpsURLConnectionOldImpl -// extends com.sun.net.ssl.HttpsURLConnection { // NOTE: made protected for plugin so that subclass can set it. protected DelegateHttpsURLConnection delegate; -// For both copies of the file, uncomment one line and comment the other HttpsURLConnectionImpl(URL u, Handler handler) throws IOException { -// HttpsURLConnectionOldImpl(URL u, Handler handler) throws IOException { this(u, null, handler); } @@ -90,9 +72,8 @@ } return u; } -// For both copies of the file, uncomment one line and comment the other + HttpsURLConnectionImpl(URL u, Proxy p, Handler handler) throws IOException { -// HttpsURLConnectionOldImpl(URL u, Proxy p, Handler handler) throws IOException { super(checkURL(u)); delegate = new DelegateHttpsURLConnection(url, p, handler, this); } diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/security/jca/ProviderConfig.java --- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -178,8 +178,12 @@ p = new sun.security.rsa.SunRsaSign(); } else if (provName.equals("SunJCE") || provName.equals("com.sun.crypto.provider.SunJCE")) { p = new com.sun.crypto.provider.SunJCE(); - } else if (provName.equals("SunJSSE") || provName.equals("com.sun.net.ssl.internal.ssl.Provider")) { - p = new com.sun.net.ssl.internal.ssl.Provider(); + } else if (provName.equals("SunJSSE") || + provName.equals("com.sun.net.ssl.internal.ssl.Provider")) { + // com.sun.net.ssl.internal.ssl.Provider is the legacy SunJSSE + // provider implementation. For compatibility, let's continue to + // support the legacy name for a while. + p = new sun.security.ssl.SunJSSE(); } else if (provName.equals("Apple") || provName.equals("apple.security.AppleProvider")) { // need to use reflection since this class only exists on MacOsx p = AccessController.doPrivileged(new PrivilegedAction() { diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/security/provider/PolicyFile.java --- a/src/java.base/share/classes/sun/security/provider/PolicyFile.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/security/provider/PolicyFile.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URI; +import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.security.*; @@ -37,7 +38,6 @@ import java.security.cert.X509Certificate; import javax.security.auth.Subject; import javax.security.auth.x500.X500Principal; -import java.io.FilePermission; import java.net.SocketPermission; import java.net.NetPermission; import java.util.concurrent.ConcurrentHashMap; @@ -273,23 +273,6 @@ private static Set badPolicyURLs = Collections.newSetFromMap(new ConcurrentHashMap()); - // The default.policy file - private static final URL DEFAULT_POLICY_URL = - AccessController.doPrivileged(new PrivilegedAction<>() { - @Override - public URL run() { - String sep = File.separator; - try { - return Path.of(StaticProperty.javaHome(), - "lib", "security", - "default.policy").toUri().toURL(); - } catch (MalformedURLException mue) { - // should not happen - throw new Error("Malformed default.policy URL: " + mue); - } - } - }); - /** * Initializes the Policy object and reads the default policy * configuration file(s) into the Policy object. @@ -349,13 +332,10 @@ private void initPolicyFile(final PolicyInfo newInfo, final URL url) { // always load default.policy - if (debug != null) { - debug.println("reading " + DEFAULT_POLICY_URL); - } AccessController.doPrivileged(new PrivilegedAction<>() { @Override public Void run() { - init(DEFAULT_POLICY_URL, newInfo, true); + initDefaultPolicy(newInfo); return null; } }); @@ -373,7 +353,7 @@ AccessController.doPrivileged(new PrivilegedAction<>() { @Override public Void run() { - if (init(url, newInfo, false) == false) { + if (init(url, newInfo) == false) { // use static policy if all else fails initStaticPolicy(newInfo); } @@ -429,7 +409,7 @@ if (debug != null) { debug.println("reading "+policyURL); } - if (init(policyURL, newInfo, false)) { + if (init(policyURL, newInfo)) { loaded_policy = true; } } catch (Exception e) { @@ -472,7 +452,7 @@ if (debug != null) { debug.println("reading " + policy_url); } - if (init(policy_url, newInfo, false)) { + if (init(policy_url, newInfo)) { loaded_policy = true; } } catch (Exception e) { @@ -492,11 +472,34 @@ return loadedPolicy; } + private void initDefaultPolicy(PolicyInfo newInfo) { + Path defaultPolicy = Path.of(StaticProperty.javaHome(), + "lib", + "security", + "default.policy"); + if (debug != null) { + debug.println("reading " + defaultPolicy); + } + try (BufferedReader br = Files.newBufferedReader(defaultPolicy)) { + + PolicyParser pp = new PolicyParser(expandProperties); + pp.read(br); + + Enumeration enum_ = pp.grantElements(); + while (enum_.hasMoreElements()) { + PolicyParser.GrantEntry ge = enum_.nextElement(); + addGrantEntry(ge, null, newInfo); + } + } catch (Exception e) { + throw new InternalError("Failed to load default.policy", e); + } + } + /** * Reads a policy configuration into the Policy object using a * Reader object. */ - private boolean init(URL policy, PolicyInfo newInfo, boolean defPolicy) { + private boolean init(URL policy, PolicyInfo newInfo) { // skip parsing policy file if it has been previously parsed and // has syntax errors @@ -537,9 +540,6 @@ } return true; } catch (PolicyParser.ParsingException pe) { - if (defPolicy) { - throw new InternalError("Failed to load default.policy", pe); - } // record bad policy file to avoid later reparsing it badPolicyURLs.add(policy); Object[] source = {policy, pe.getNonlocalizedMessage()}; @@ -549,9 +549,6 @@ pe.printStackTrace(); } } catch (Exception e) { - if (defPolicy) { - throw new InternalError("Failed to load default.policy", e); - } if (debug != null) { debug.println("error parsing "+policy); debug.println(e.toString()); diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java --- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/security/ssl/SunJSSE.java --- a/src/java.base/share/classes/sun/security/ssl/SunJSSE.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/security/ssl/SunJSSE.java Sat Mar 09 12:54:20 2019 +0000 @@ -58,7 +58,7 @@ * FIPS mode. * */ -public abstract class SunJSSE extends java.security.Provider { +public class SunJSSE extends java.security.Provider { private static final long serialVersionUID = 3231825739635378733L; @@ -66,9 +66,8 @@ "(PKCS12, SunX509/PKIX key/trust factories, " + "SSLv3/TLSv1/TLSv1.1/TLSv1.2/TLSv1.3/DTLSv1.0/DTLSv1.2)"; - protected SunJSSE() { + public SunJSSE() { super("SunJSSE", PROVIDER_VER, info); - subclassCheck(); registerAlgorithms(); } @@ -136,12 +135,4 @@ ps("KeyStore", "PKCS12", "sun.security.pkcs12.PKCS12KeyStore", null, null); } - - // com.sun.net.ssl.internal.ssl.Provider has been deprecated since JDK 9 - @SuppressWarnings("deprecation") - private void subclassCheck() { - if (getClass() != com.sun.net.ssl.internal.ssl.Provider.class) { - throw new AssertionError("Illegal subclass: " + getClass()); - } - } } diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java --- a/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -73,31 +73,28 @@ @Override protected String[] getDisplayNameArray(String id, Locale locale) { - String tzid = TimeZoneNameUtility.canonicalTZID(id).orElse(id); - String[] namesSuper = super.getDisplayNameArray(tzid, locale); + // Use English for the ROOT locale + locale = locale.equals(Locale.ROOT) ? Locale.ENGLISH : locale; + String[] namesSuper = super.getDisplayNameArray(id, locale); - if (Objects.nonNull(namesSuper)) { + if (namesSuper == null) { + // try canonical id instead + namesSuper = super.getDisplayNameArray( + TimeZoneNameUtility.canonicalTZID(id).orElse(id), + locale); + } + + if (namesSuper != null) { // CLDR's resource bundle has an translated entry for this id. // Fix up names if needed, either missing or no-inheritance namesSuper[INDEX_TZID] = id; - // Check if standard long name exists. If not, try to retrieve the name - // from language only locale resources. E.g., "Europe/London" - // for en-GB only contains DST names - if (!exists(namesSuper, INDEX_STD_LONG) && !locale.getCountry().isEmpty()) { - String[] names = - getDisplayNameArray(id, Locale.forLanguageTag(locale.getLanguage())); - if (exists(names, INDEX_STD_LONG)) { - namesSuper[INDEX_STD_LONG] = names[INDEX_STD_LONG]; - } - } - for(int i = INDEX_STD_LONG; i < namesSuper.length; i++) { // index 0 is the 'id' itself switch (namesSuper[i]) { case "": // Fill in empty elements deriveFallbackName(namesSuper, i, locale, - namesSuper[INDEX_DST_LONG].isEmpty()); + !exists(namesSuper, INDEX_DST_LONG)); break; case NO_INHERITANCE_MARKER: // CLDR's "no inheritance marker" @@ -141,16 +138,19 @@ // Derive fallback time zone name according to LDML's logic private void deriveFallbackNames(String[] names, Locale locale) { + boolean noDST = !exists(names, INDEX_DST_LONG); for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) { - deriveFallbackName(names, i, locale, false); + deriveFallbackName(names, i, locale, noDST); } } private void deriveFallbackName(String[] names, int index, Locale locale, boolean noDST) { + String id = names[INDEX_TZID]; + if (exists(names, index)) { if (names[index].equals(NO_INHERITANCE_MARKER)) { // CLDR's "no inheritance marker" - names[index] = toGMTFormat(names[INDEX_TZID], + names[index] = toGMTFormat(id, index == INDEX_DST_LONG || index == INDEX_DST_SHORT, index % 2 != 0, locale); } @@ -160,8 +160,8 @@ // Check if COMPAT can substitute the name if (LocaleProviderAdapter.getAdapterPreference().contains(Type.JRE)) { String[] compatNames = (String[])LocaleProviderAdapter.forJRE() - .getLocaleResources(locale) - .getTimeZoneNames(names[INDEX_TZID]); + .getLocaleResources(mapChineseLocale(locale)) + .getTimeZoneNames(id); if (compatNames != null) { for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) { // Assumes COMPAT has no empty slots @@ -184,9 +184,8 @@ } // last resort - String id = names[INDEX_TZID].toUpperCase(Locale.ROOT); - if (!id.startsWith("UT")) { - names[index] = toGMTFormat(names[INDEX_TZID], + if (!id.toUpperCase(Locale.ROOT).startsWith("UT")) { + names[index] = toGMTFormat(id, index == INDEX_DST_LONG || index == INDEX_DST_SHORT, index % 2 != 0, locale); @@ -290,4 +289,33 @@ String.format(l, hourFormat, offset / 60, offset % 60)); } } + + // Mapping CLDR's Simplified/Traditional Chinese resources + // to COMPAT's zh-CN/TW + private Locale mapChineseLocale(Locale locale) { + if (locale.getLanguage() == "zh") { + switch (locale.getScript()) { + case "Hans": + return Locale.CHINA; + case "Hant": + return Locale.TAIWAN; + case "": + // no script, guess from country code. + switch (locale.getCountry()) { + case "": + case "CN": + case "SG": + return Locale.CHINA; + case "HK": + case "MO": + case "TW": + return Locale.TAIWAN; + } + break; + } + } + + // no need to map + return locale; + } } diff -r 3e39753ed05b -r b38f280d2114 src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -56,7 +56,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import sun.security.action.GetPropertyAction; -import sun.util.calendar.ZoneInfo; import sun.util.resources.LocaleData; import sun.util.resources.OpenListResourceBundle; import sun.util.resources.ParallelListResourceBundle; @@ -271,17 +270,31 @@ if (Objects.isNull(data) || Objects.isNull(val = data.get())) { TimeZoneNamesBundle tznb = localeData.getTimeZoneNames(locale); - if (tznb.containsKey(key)) { - if (key.startsWith(TZNB_EXCITY_PREFIX)) { + if (key.startsWith(TZNB_EXCITY_PREFIX)) { + if (tznb.containsKey(key)) { val = tznb.getString(key); assert val instanceof String; trace("tznb: %s key: %s, val: %s\n", tznb, key, val); + } + } else { + String[] names = null; + if (tznb.containsKey(key)) { + names = tznb.getStringArray(key); } else { - String[] names = tznb.getStringArray(key); + var tz = TimeZoneNameUtility.canonicalTZID(key).orElse(key); + if (tznb.containsKey(tz)) { + names = tznb.getStringArray(tz); + } + } + + if (names != null) { + names[0] = key; trace("tznb: %s key: %s, names: %s, %s, %s, %s, %s, %s, %s\n", tznb, key, names[0], names[1], names[2], names[3], names[4], names[5], names[6]); val = names; } + } + if (val != null) { cache.put(cacheKey, new ResourceReference(cacheKey, val, referenceQueue)); } @@ -321,8 +334,6 @@ } if (type == LocaleProviderAdapter.Type.CLDR) { - // Add aliases data for CLDR - Map aliases = ZoneInfo.getAliasTable(); // Note: TimeZoneNamesBundle creates a String[] on each getStringArray call. // Add timezones which are not present in this keyset, @@ -335,9 +346,10 @@ if (keyset.contains(tzid)) { val = rb.getStringArray(tzid); } else { - String tz = aliases.get(tzid); - if (keyset.contains(tz)) { - val = rb.getStringArray(tz); + var canonID = TimeZoneNameUtility.canonicalTZID(tzid) + .orElse(tzid); + if (keyset.contains(canonID)) { + val = rb.getStringArray(canonID); } } val[0] = tzid; diff -r 3e39753ed05b -r b38f280d2114 src/java.base/unix/native/libjli/java_md_solinux.c --- a/src/java.base/unix/native/libjli/java_md_solinux.c Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.base/unix/native/libjli/java_md_solinux.c Sat Mar 09 12:54:20 2019 +0000 @@ -303,6 +303,9 @@ #ifdef SETENV_REQUIRED jboolean mustsetenv = JNI_FALSE; +#ifdef __solaris__ + char *llp64 = NULL; /* existing LD_LIBRARY_PATH_64 setting */ +#endif // __solaris__ char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */ char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */ char* newpath = NULL; /* path on new LD_LIBRARY_PATH */ @@ -367,7 +370,12 @@ * any. */ +#ifdef __solaris__ + llp64 = getenv("LD_LIBRARY_PATH_64"); + runpath = (llp64 == NULL) ? getenv(LD_LIBRARY_PATH) : llp64; +#else runpath = getenv(LD_LIBRARY_PATH); +#endif /* __solaris__ */ /* runpath contains current effective LD_LIBRARY_PATH setting */ { /* New scope to declare local variable */ @@ -440,6 +448,14 @@ * once at startup, so we have to re-exec the current executable * to get the changed environment variable to have an effect. */ +#ifdef __solaris__ + /* + * new LD_LIBRARY_PATH took over for LD_LIBRARY_PATH_64 + */ + if (llp64 != NULL) { + UnsetEnv("LD_LIBRARY_PATH_64"); + } +#endif // __solaris__ newenvp = environ; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java --- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java Sat Mar 09 12:54:20 2019 +0000 @@ -148,7 +148,8 @@ * @return String with Base64 encoding */ public static final String encode(BigInteger big) { - return encode(getBytes(big, big.bitLength())); + byte[] bytes = XMLUtils.getBytes(big, big.bitLength()); + return XMLUtils.encodeToString(bytes); } /** @@ -214,9 +215,9 @@ * @return a decoded BigInteger * @throws Base64DecodingException */ - public static BigInteger decodeBigIntegerFromString(String base64str) - throws Base64DecodingException { - return new BigInteger(1, Base64.decode(base64str)); + public static final BigInteger decodeBigIntegerFromText(Text text) + throws Base64DecodingException { + return new BigInteger(1, Base64.decode(text.getData())); } /** diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java --- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Sat Mar 09 12:54:20 2019 +0000 @@ -28,6 +28,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; +import java.util.Base64; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -443,6 +444,25 @@ } } + public static String encodeToString(byte[] bytes) { + if (ignoreLineBreaks) { + return Base64.getEncoder().encodeToString(bytes); + } + return Base64.getMimeEncoder().encodeToString(bytes); + } + + public static byte[] decode(String encodedString) { + return Base64.getMimeDecoder().decode(encodedString); + } + + public static byte[] decode(byte[] encodedBytes) { + return Base64.getMimeDecoder().decode(encodedBytes); + } + + public static boolean isIgnoreLineBreaks() { + return ignoreLineBreaks; + } + /** * Method convertNodelistToSet * diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,19 +29,23 @@ import java.security.SignatureException; import java.security.spec.AlgorithmParameterSpec; import javax.xml.crypto.MarshalException; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.SignatureMethod; +import javax.xml.crypto.dsig.SignedInfo; import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.XMLSignatureException; import javax.xml.crypto.dsig.XMLSignContext; import javax.xml.crypto.dsig.XMLValidateContext; import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * An abstract class representing a SignatureMethod. Subclasses implement * a specific XML DSig signature algorithm. */ -abstract class AbstractDOMSignatureMethod extends BaseStructure +abstract class AbstractDOMSignatureMethod extends DOMStructure implements SignatureMethod { // denotes the type of signature algorithm @@ -65,7 +69,7 @@ * as the passed in signature is improperly encoded * @throws XMLSignatureException if an unexpected error occurs */ - abstract boolean verify(Key key, DOMSignedInfo si, byte[] sig, + abstract boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException; @@ -83,7 +87,7 @@ * the wrong type, or parameters are missing, etc * @throws XMLSignatureException if an unexpected error occurs */ - abstract byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context) + abstract byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException; /** @@ -101,16 +105,21 @@ * This method invokes the {@link #marshalParams marshalParams} * method to marshal any algorithm-specific parameters. */ - public void marshal(XmlWriter xwriter, String dsPrefix) + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "SignatureMethod", XMLSignature.XMLNS); - xwriter.writeAttribute("", "", "Algorithm", getAlgorithm()); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + + Element smElem = DOMUtils.createElement(ownerDoc, "SignatureMethod", + XMLSignature.XMLNS, dsPrefix); + DOMUtils.setAttribute(smElem, "Algorithm", getAlgorithm()); if (getParameterSpec() != null) { - marshalParams(xwriter, dsPrefix); + marshalParams(smElem, dsPrefix); } - xwriter.writeEndElement(); // "SignatureMethod" + + parent.appendChild(smElem); } /** @@ -123,7 +132,7 @@ * @param paramsPrefix the algorithm parameters prefix to use * @throws MarshalException if the parameters cannot be marshalled */ - void marshalParams(XmlWriter xwriter, String paramsPrefix) + void marshalParams(Element parent, String paramsPrefix) throws MarshalException { throw new MarshalException("no parameters should " + diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java Sat Mar 09 12:54:20 2019 +0000 @@ -69,7 +69,6 @@ return params; } - @Override public void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException { @@ -88,7 +87,6 @@ ownerDoc = DOMUtils.getOwnerDocument(transformElem); } - @Override public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java Sat Mar 09 12:54:20 2019 +0000 @@ -45,7 +45,6 @@ this.xi = xi; } - @Override public XMLSignatureInput getXMLSignatureInput() { return xi; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java Sat Mar 09 12:54:20 2019 +0000 @@ -67,7 +67,6 @@ return params; } - @Override public void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException { @@ -86,7 +85,6 @@ ownerDoc = DOMUtils.getOwnerDocument(transformElem); } - @Override public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException { @@ -105,7 +103,6 @@ ownerDoc = DOMUtils.getOwnerDocument(transformElem); } - @Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { @@ -115,7 +112,6 @@ return transformIt(data, xc, null); } - @Override public Data transform(Data data, XMLCryptoContext xc, OutputStream os) throws TransformException { @@ -206,7 +202,6 @@ } } - @Override public final boolean isFeatureSupported(String feature) { if (feature == null) { throw new NullPointerException(); diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/BaseStructure.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/BaseStructure.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jcp.xml.dsig.internal.dom; - -import javax.xml.crypto.XMLStructure; - -import org.w3c.dom.Node; - -public abstract class BaseStructure implements XMLStructure { - - /** - * Just return the text of the immediate child of a node. - * - * @param node - * @return the text of a Node - */ - public static String textOfNode(Node node) { - return node.getFirstChild().getNodeValue(); - } - - public final boolean isFeatureSupported(String feature) { - if (feature == null) { - throw new NullPointerException(); - } else { - return false; - } - } - -} diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java Sat Mar 09 12:54:20 2019 +0000 @@ -48,7 +48,6 @@ public static final String C14N_11_WITH_COMMENTS = "http://www.w3.org/2006/12/xml-c14n11#WithComments"; - @Override public void init(TransformParameterSpec params) throws InvalidAlgorithmParameterException { if (params != null) { @@ -57,7 +56,6 @@ } } - @Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java Sat Mar 09 12:54:20 2019 +0000 @@ -44,7 +44,6 @@ */ public final class DOMCanonicalXMLC14NMethod extends ApacheCanonicalizer { - @Override public void init(TransformParameterSpec params) throws InvalidAlgorithmParameterException { if (params != null) { @@ -53,7 +52,6 @@ } } - @Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,101 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + */ +/* + * $Id$ + */ +package org.jcp.xml.dsig.internal.dom; + +import java.math.BigInteger; +import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; + +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; +import org.w3c.dom.Node; +import org.w3c.dom.Text; + +/** + * A DOM-based representation of the XML CryptoBinary simple type + * as defined in the W3C specification for XML-Signature Syntax and Processing. + * The XML Schema Definition is defined as: + * + *

    + * <simpleType name="CryptoBinary"> + * <restriction base = "base64Binary"> + * </restriction> + * </simpleType> + * + * + * @author Sean Mullan + */ +public final class DOMCryptoBinary extends DOMStructure { + + private final BigInteger bigNum; + private final String value; + + /** + * Create a DOMCryptoBinary instance from the specified + * BigInteger + * + * @param bigNum the arbitrary-length integer + * @throws NullPointerException if bigNum is null + */ + public DOMCryptoBinary(BigInteger bigNum) { + if (bigNum == null) { + throw new NullPointerException("bigNum is null"); + } + this.bigNum = bigNum; + // convert to bitstring + byte[] bytes = XMLUtils.getBytes(bigNum, bigNum.bitLength()); + value = XMLUtils.encodeToString(bytes); + } + + /** + * Creates a DOMCryptoBinary from a node. + * + * @param cbNode a CryptoBinary text node + * @throws MarshalException if value cannot be decoded (invalid format) + */ + public DOMCryptoBinary(Node cbNode) throws MarshalException { + value = cbNode.getNodeValue(); + try { + bigNum = new BigInteger(1, XMLUtils.decode(((Text) cbNode).getData())); + } catch (Exception ex) { + throw new MarshalException(ex); + } + } + + /** + * Returns the BigInteger that this object contains. + * + * @return the BigInteger that this object contains + */ + public BigInteger getBigNum() { + return bigNum; + } + + @Override + public void marshal(Node parent, String prefix, DOMCryptoContext context) + throws MarshalException { + parent.appendChild + (DOMUtils.getOwnerDocument(parent).createTextNode(value)); + } +} diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,18 +29,21 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec; import java.security.InvalidAlgorithmParameterException; import java.security.spec.AlgorithmParameterSpec; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * DOM-based abstract implementation of DigestMethod. * */ -public abstract class DOMDigestMethod extends BaseStructure +public abstract class DOMDigestMethod extends DOMStructure implements DigestMethod { static final String SHA224 = @@ -147,7 +150,6 @@ } } - @Override public final AlgorithmParameterSpec getParameterSpec() { return params; } @@ -175,17 +177,21 @@ * This method invokes the abstract {@link #marshalParams marshalParams} * method to marshal any algorithm-specific parameters. */ - public static void marshal(XmlWriter xwriter, DigestMethod digest, String prefix) + @Override + public void marshal(Node parent, String prefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(prefix, "DigestMethod", XMLSignature.XMLNS); - xwriter.writeAttribute("", "", "Algorithm", digest.getAlgorithm()); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + + Element dmElem = DOMUtils.createElement(ownerDoc, "DigestMethod", + XMLSignature.XMLNS, prefix); + DOMUtils.setAttribute(dmElem, "Algorithm", getAlgorithm()); - // this is totally over-engineered - nothing implements marshalParams. - if (digest.getParameterSpec() != null && digest instanceof DOMDigestMethod) { - ( (DOMDigestMethod) digest).marshalParams(xwriter, prefix); + if (params != null) { + marshalParams(dmElem, prefix); } - xwriter.writeEndElement(); // "DigestMethod" + + parent.appendChild(dmElem); } @Override @@ -226,7 +232,7 @@ * @param the namespace prefix to use * @throws MarshalException if the parameters cannot be marshalled */ - void marshalParams(XmlWriter xwriter, String prefix) + void marshalParams(Element parent, String prefix) throws MarshalException { throw new MarshalException("no parameters should " + @@ -248,11 +254,9 @@ SHA1(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return DigestMethod.SHA1; } - @Override String getMessageDigestAlgorithm() { return "SHA-1"; } @@ -284,11 +288,9 @@ SHA256(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return DigestMethod.SHA256; } - @Override String getMessageDigestAlgorithm() { return "SHA-256"; } @@ -302,11 +304,9 @@ SHA384(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return SHA384; } - @Override String getMessageDigestAlgorithm() { return "SHA-384"; } @@ -320,11 +320,9 @@ SHA512(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return DigestMethod.SHA512; } - @Override String getMessageDigestAlgorithm() { return "SHA-512"; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java Sat Mar 09 12:54:20 2019 +0000 @@ -38,7 +38,6 @@ */ public final class DOMEnvelopedTransform extends ApacheTransform { - @Override public void init(TransformParameterSpec params) throws InvalidAlgorithmParameterException { if (params != null) { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java Sat Mar 09 12:54:20 2019 +0000 @@ -50,7 +50,6 @@ */ public final class DOMExcC14NMethod extends ApacheCanonicalizer { - @Override public void init(TransformParameterSpec params) throws InvalidAlgorithmParameterException { @@ -63,7 +62,6 @@ } } - @Override public void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException { @@ -109,12 +107,20 @@ return; } - XmlWriterToTree xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), transformElem); - - String prefix = - DOMUtils.getNSPrefix(context, CanonicalizationMethod.EXCLUSIVE); - xwriter.writeStartElement(prefix, "InclusiveNamespaces", CanonicalizationMethod.EXCLUSIVE); - xwriter.writeNamespace(prefix, CanonicalizationMethod.EXCLUSIVE); + String prefix = DOMUtils.getNSPrefix(context, + CanonicalizationMethod.EXCLUSIVE); + Element eElem = DOMUtils.createElement(ownerDoc, + "InclusiveNamespaces", + CanonicalizationMethod.EXCLUSIVE, + prefix); + if (prefix == null || prefix.length() == 0) { + eElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", + CanonicalizationMethod.EXCLUSIVE); + } else { + eElem.setAttributeNS("http://www.w3.org/2000/xmlns/", + "xmlns:" + prefix, + CanonicalizationMethod.EXCLUSIVE); + } ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec; StringBuilder prefixListAttr = new StringBuilder(""); @@ -125,16 +131,15 @@ prefixListAttr.append(" "); } } - xwriter.writeAttribute("", "", "PrefixList", prefixListAttr.toString()); + DOMUtils.setAttribute(eElem, "PrefixList", prefixListAttr.toString()); this.inclusiveNamespaces = prefixListAttr.toString(); - xwriter.writeEndElement(); // "InclusiveNamespaces" + transformElem.appendChild(eElem); } public String getParamsNSURI() { return CanonicalizationMethod.EXCLUSIVE; } - @Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java Sat Mar 09 12:54:20 2019 +0000 @@ -42,6 +42,7 @@ import java.security.spec.AlgorithmParameterSpec; import javax.crypto.Mac; import javax.crypto.SecretKey; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.jcp.xml.dsig.internal.MacOutputStream; @@ -117,30 +118,32 @@ } } - @Override public final AlgorithmParameterSpec getParameterSpec() { return params; } - @Override SignatureMethodParameterSpec unmarshalParams(Element paramsElem) throws MarshalException { - outputLength = Integer.parseInt(textOfNode(paramsElem)); + outputLength = Integer.parseInt(paramsElem.getFirstChild().getNodeValue()); outputLengthSet = true; LOG.debug("unmarshalled outputLength: {}", outputLength); return new HMACParameterSpec(outputLength); } - @Override - void marshalParams(XmlWriter xwriter, String prefix) + void marshalParams(Element parent, String prefix) throws MarshalException { - xwriter.writeTextElement(prefix, "HMACOutputLength", XMLSignature.XMLNS, String.valueOf(outputLength)); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element hmacElem = DOMUtils.createElement(ownerDoc, "HMACOutputLength", + XMLSignature.XMLNS, prefix); + hmacElem.appendChild(ownerDoc.createTextNode + (String.valueOf(outputLength))); + + parent.appendChild(hmacElem); } - @Override - boolean verify(Key key, DOMSignedInfo si, byte[] sig, + boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { @@ -162,14 +165,13 @@ ("HMACOutputLength must not be less than " + getDigestLength()); } hmac.init(key); - si.canonicalize(context, new MacOutputStream(hmac)); + ((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac)); byte[] result = hmac.doFinal(); return MessageDigest.isEqual(sig, result); } - @Override - byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context) + byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { @@ -190,11 +192,10 @@ ("HMACOutputLength must not be less than " + getDigestLength()); } hmac.init(key); - si.canonicalize(context, new MacOutputStream(hmac)); + ((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac)); return hmac.doFinal(); } - @Override boolean paramsEqual(AlgorithmParameterSpec spec) { if (getParameterSpec() == spec) { return true; @@ -207,7 +208,6 @@ return outputLength == ospec.getOutputLength(); } - @Override Type getAlgorithmType() { return Type.HMAC; } @@ -225,15 +225,12 @@ SHA1(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return SignatureMethod.HMAC_SHA1; } - @Override String getJCAAlgorithm() { return "HmacSHA1"; } - @Override int getDigestLength() { return 160; } @@ -269,15 +266,12 @@ SHA256(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return HMAC_SHA256; } - @Override String getJCAAlgorithm() { return "HmacSHA256"; } - @Override int getDigestLength() { return 256; } @@ -291,15 +285,12 @@ SHA384(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return HMAC_SHA384; } - @Override String getJCAAlgorithm() { return "HmacSHA384"; } - @Override int getDigestLength() { return 384; } @@ -313,15 +304,12 @@ SHA512(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return HMAC_SHA512; } - @Override String getJCAAlgorithm() { return "HmacSHA512"; } - @Override int getDigestLength() { return 512; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java Sat Mar 09 12:54:20 2019 +0000 @@ -36,10 +36,13 @@ import javax.xml.crypto.MarshalException; import javax.xml.crypto.XMLCryptoContext; import javax.xml.crypto.XMLStructure; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.dom.DOMSignContext; import javax.xml.crypto.dsig.keyinfo.KeyInfo; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -47,7 +50,7 @@ * DOM-based implementation of KeyInfo. * */ -public final class DOMKeyInfo extends BaseStructure implements KeyInfo { +public final class DOMKeyInfo extends DOMStructure implements KeyInfo { private final String id; private final List keyInfoTypes; @@ -101,7 +104,14 @@ Provider provider) throws MarshalException { - id = DOMUtils.getIdAttributeValue(kiElem, "Id"); + // get Id attribute, if specified + Attr attr = kiElem.getAttributeNodeNS(null, "Id"); + if (attr != null) { + id = attr.getValue(); + kiElem.setIdAttributeNode(attr, true); + } else { + id = null; + } // get all children nodes List content = new ArrayList<>(); @@ -134,17 +144,14 @@ keyInfoTypes = Collections.unmodifiableList(content); } - @Override public String getId() { return id; } - @Override public List getContent() { return keyInfoTypes; } - @Override public void marshal(XMLStructure parent, XMLCryptoContext context) throws MarshalException { @@ -155,44 +162,62 @@ throw new ClassCastException("parent must be of type DOMStructure"); } - internalMarshal( (javax.xml.crypto.dom.DOMStructure) parent, context); - } - - private void internalMarshal(javax.xml.crypto.dom.DOMStructure parent, XMLCryptoContext context) - throws MarshalException { - Node pNode = parent.getNode(); + Node pNode = ((javax.xml.crypto.dom.DOMStructure)parent).getNode(); String dsPrefix = DOMUtils.getSignaturePrefix(context); + Element kiElem = DOMUtils.createElement + (DOMUtils.getOwnerDocument(pNode), "KeyInfo", + XMLSignature.XMLNS, dsPrefix); + if (dsPrefix == null || dsPrefix.length() == 0) { + kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/", + "xmlns", XMLSignature.XMLNS); + } else { + kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/", + "xmlns:" + dsPrefix, XMLSignature.XMLNS); + } Node nextSibling = null; if (context instanceof DOMSignContext) { nextSibling = ((DOMSignContext)context).getNextSibling(); } - - XmlWriterToTree xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), pNode, nextSibling); - marshalInternal(xwriter, this, dsPrefix, context, true); + marshal(pNode, kiElem, nextSibling, dsPrefix, (DOMCryptoContext)context); } - public static void marshal(XmlWriter xwriter, KeyInfo ki, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - marshalInternal(xwriter, ki, dsPrefix, context, false); + @Override + public void marshal(Node parent, String dsPrefix, + DOMCryptoContext context) + throws MarshalException + { + marshal(parent, null, dsPrefix, context); } - private static void marshalInternal(XmlWriter xwriter, KeyInfo ki, - String dsPrefix, XMLCryptoContext context, boolean declareNamespace) throws MarshalException { + public void marshal(Node parent, Node nextSibling, String dsPrefix, + DOMCryptoContext context) + throws MarshalException + { + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element kiElem = DOMUtils.createElement(ownerDoc, "KeyInfo", + XMLSignature.XMLNS, dsPrefix); + marshal(parent, kiElem, nextSibling, dsPrefix, context); + } - xwriter.writeStartElement(dsPrefix, "KeyInfo", XMLSignature.XMLNS); - if (declareNamespace) { - xwriter.writeNamespace(dsPrefix, XMLSignature.XMLNS); + private void marshal(Node parent, Element kiElem, Node nextSibling, + String dsPrefix, DOMCryptoContext context) + throws MarshalException + { + // create and append KeyInfoType elements + for (XMLStructure kiType : keyInfoTypes) { + if (kiType instanceof DOMStructure) { + ((DOMStructure)kiType).marshal(kiElem, dsPrefix, context); + } else { + DOMUtils.appendChild(kiElem, + ((javax.xml.crypto.dom.DOMStructure)kiType).getNode()); + } } - xwriter.writeIdAttribute("", "", "Id", ki.getId()); - // create and append KeyInfoType elements - List keyInfoTypes = getContent(ki); - for (XMLStructure kiType : keyInfoTypes) { - xwriter.marshalStructure(kiType, dsPrefix, context); - } + // append id attribute + DOMUtils.setAttributeID(kiElem, "Id", id); - xwriter.writeEndElement(); // "KeyInfo" + parent.insertBefore(kiElem, nextSibling); } @Override diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java Sat Mar 09 12:54:20 2019 +0000 @@ -31,15 +31,24 @@ import java.math.BigInteger; import java.security.KeyException; import java.security.PublicKey; +import java.security.interfaces.ECPublicKey; import java.security.interfaces.DSAPublicKey; -import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAPublicKey; import java.util.List; -import javax.xml.crypto.*; +import javax.xml.crypto.MarshalException; +import javax.xml.crypto.URIDereferencer; +import javax.xml.crypto.XMLStructure; import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.XMLSignature; -import javax.xml.crypto.dsig.keyinfo.*; +import javax.xml.crypto.dsig.keyinfo.KeyInfo; +import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory; +import javax.xml.crypto.dsig.keyinfo.KeyName; +import javax.xml.crypto.dsig.keyinfo.KeyValue; +import javax.xml.crypto.dsig.keyinfo.PGPData; +import javax.xml.crypto.dsig.keyinfo.RetrievalMethod; +import javax.xml.crypto.dsig.keyinfo.X509Data; +import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -53,24 +62,20 @@ public DOMKeyInfoFactory() { } - @Override @SuppressWarnings("rawtypes") public KeyInfo newKeyInfo(List content) { return newKeyInfo(content, null); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public KeyInfo newKeyInfo(List content, String id) { return new DOMKeyInfo(content, id); } - @Override public KeyName newKeyName(String name) { return new DOMKeyName(name); } - @Override public KeyValue newKeyValue(PublicKey key) throws KeyException { String algorithm = key.getAlgorithm(); if ("DSA".equals(algorithm)) { @@ -84,30 +89,25 @@ } } - @Override public PGPData newPGPData(byte[] keyId) { return newPGPData(keyId, null, null); } - @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) { return new DOMPGPData(keyId, keyPacket, other); } - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "rawtypes", "unchecked" }) public PGPData newPGPData(byte[] keyPacket, List other) { return new DOMPGPData(keyPacket, other); } - @Override public RetrievalMethod newRetrievalMethod(String uri) { return newRetrievalMethod(uri, null, null); } - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "rawtypes", "unchecked" }) public RetrievalMethod newRetrievalMethod(String uri, String type, List transforms) { if (uri == null) { @@ -116,8 +116,7 @@ return new DOMRetrievalMethod(uri, type, transforms); } - @Override - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes" }) public X509Data newX509Data(List content) { return new DOMX509Data(content); } @@ -128,7 +127,6 @@ return new DOMX509IssuerSerial(issuerName, serialNumber); } - @Override public boolean isFeatureSupported(String feature) { if (feature == null) { throw new NullPointerException(); @@ -137,7 +135,6 @@ } } - @Override public URIDereferencer getURIDereferencer() { return DOMURIDereferencer.INSTANCE; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java Sat Mar 09 12:54:20 2019 +0000 @@ -28,15 +28,20 @@ */ package org.jcp.xml.dsig.internal.dom; +import javax.xml.crypto.MarshalException; +import javax.xml.crypto.dom.DOMCryptoContext; +import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.keyinfo.KeyName; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * DOM-based implementation of KeyName. * */ -public final class DOMKeyName extends BaseStructure implements KeyName { +public final class DOMKeyName extends DOMStructure implements KeyName { private final String name; @@ -59,12 +64,23 @@ * @param knElem a KeyName element */ public DOMKeyName(Element knElem) { - name = textOfNode(knElem); + name = knElem.getFirstChild().getNodeValue(); + } + + public String getName() { + return name; } @Override - public String getName() { - return name; + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) + throws MarshalException + { + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + // prepend namespace prefix, if necessary + Element knElem = DOMUtils.createElement(ownerDoc, "KeyName", + XMLSignature.XMLNS, dsPrefix); + knElem.appendChild(ownerDoc.createTextNode(name)); + parent.appendChild(knElem); } @Override diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,6 +29,7 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dsig.keyinfo.KeyValue; @@ -53,16 +54,17 @@ import java.security.spec.KeySpec; import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; -import java.util.Base64; import com.sun.org.apache.xml.internal.security.utils.XMLUtils; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * DOM-based implementation of KeyValue. * */ -public abstract class DOMKeyValue extends BaseStructure implements KeyValue { +public abstract class DOMKeyValue extends DOMStructure implements KeyValue { private static final String XMLDSIG_11_XMLNS = "http://www.w3.org/2009/xmldsig11#"; @@ -102,7 +104,6 @@ } } - @Override public PublicKey getPublicKey() throws KeyException { if (publicKey == null) { throw new KeyException("can't convert KeyValue to PublicKey"); @@ -111,17 +112,22 @@ } } - public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + // create KeyValue element - xwriter.writeStartElement(dsPrefix, "KeyValue", XMLSignature.XMLNS); - marshalPublicKey(xwriter, publicKey, dsPrefix, context); - xwriter.writeEndElement(); // "KeyValue" + Element kvElem = DOMUtils.createElement(ownerDoc, "KeyValue", + XMLSignature.XMLNS, dsPrefix); + marshalPublicKey(kvElem, ownerDoc, dsPrefix, context); + + parent.appendChild(kvElem); } - abstract void marshalPublicKey(XmlWriter xwriter, K key, String dsPrefix, - XMLCryptoContext context) throws MarshalException; + abstract void marshalPublicKey(Node parent, Document doc, String dsPrefix, + DOMCryptoContext context) throws MarshalException; abstract K unmarshalKeyValue(Element kvtElem) throws MarshalException; @@ -162,25 +168,13 @@ public static BigInteger decode(Element elem) throws MarshalException { try { - String base64str = BaseStructure.textOfNode(elem); - return new BigInteger(1, Base64.getMimeDecoder().decode(base64str)); + String base64str = elem.getFirstChild().getNodeValue(); + return new BigInteger(1, XMLUtils.decode(base64str)); } catch (Exception ex) { throw new MarshalException(ex); } } - public static void writeBase64BigIntegerElement( - XmlWriter xwriter, String prefix, String localName, String namespaceURI, BigInteger value - ) { - byte[] bytes = XMLUtils.getBytes(value, value.bitLength()); - xwriter.writeTextElement(prefix, localName, namespaceURI, Base64.getMimeEncoder().encodeToString(bytes)); - } - - public static void marshal(XmlWriter xwriter, BigInteger bigNum) { - byte[] bytes = XMLUtils.getBytes(bigNum, bigNum.bitLength()); - xwriter.writeCharacters(Base64.getMimeEncoder().encodeToString(bytes)); - } - @Override public int hashCode() { int result = 17; @@ -193,25 +187,36 @@ static final class RSA extends DOMKeyValue { // RSAKeyValue CryptoBinaries + private DOMCryptoBinary modulus, exponent; private KeyFactory rsakf; RSA(RSAPublicKey key) throws KeyException { super(key); + RSAPublicKey rkey = key; + exponent = new DOMCryptoBinary(rkey.getPublicExponent()); + modulus = new DOMCryptoBinary(rkey.getModulus()); } RSA(Element elem) throws MarshalException { super(elem); } - @Override - void marshalPublicKey(XmlWriter xwriter, RSAPublicKey publicKey, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "RSAKeyValue", XMLSignature.XMLNS); - - writeBase64BigIntegerElement(xwriter, dsPrefix, "Modulus", XMLSignature.XMLNS, publicKey.getModulus()); - writeBase64BigIntegerElement(xwriter, dsPrefix, "Exponent", XMLSignature.XMLNS, publicKey.getPublicExponent()); - - xwriter.writeEndElement(); // "RSAKeyValue" + void marshalPublicKey(Node parent, Document doc, String dsPrefix, + DOMCryptoContext context) throws MarshalException { + Element rsaElem = DOMUtils.createElement(doc, "RSAKeyValue", + XMLSignature.XMLNS, + dsPrefix); + Element modulusElem = DOMUtils.createElement(doc, "Modulus", + XMLSignature.XMLNS, + dsPrefix); + Element exponentElem = DOMUtils.createElement(doc, "Exponent", + XMLSignature.XMLNS, + dsPrefix); + modulus.marshal(modulusElem, dsPrefix, context); + exponent.marshal(exponentElem, dsPrefix, context); + rsaElem.appendChild(modulusElem); + rsaElem.appendChild(exponentElem); + parent.appendChild(rsaElem); } @Override @@ -241,10 +246,17 @@ static final class DSA extends DOMKeyValue { // DSAKeyValue CryptoBinaries + private DOMCryptoBinary p, q, g, y; //, seed, pgen; private KeyFactory dsakf; DSA(DSAPublicKey key) throws KeyException { super(key); + DSAPublicKey dkey = key; + DSAParams params = dkey.getParams(); + p = new DOMCryptoBinary(params.getP()); + q = new DOMCryptoBinary(params.getQ()); + g = new DOMCryptoBinary(params.getG()); + y = new DOMCryptoBinary(dkey.getY()); } DSA(Element elem) throws MarshalException { @@ -252,21 +264,31 @@ } @Override - void marshalPublicKey(XmlWriter xwriter, DSAPublicKey publicKey, String dsPrefix, - XMLCryptoContext context) + void marshalPublicKey(Node parent, Document doc, String dsPrefix, + DOMCryptoContext context) throws MarshalException { - DSAParams params = publicKey.getParams(); - - xwriter.writeStartElement(dsPrefix, "DSAKeyValue", XMLSignature.XMLNS); - + Element dsaElem = DOMUtils.createElement(doc, "DSAKeyValue", + XMLSignature.XMLNS, + dsPrefix); // parameters J, Seed & PgenCounter are not included - writeBase64BigIntegerElement(xwriter, dsPrefix, "P", XMLSignature.XMLNS, params.getP()); - writeBase64BigIntegerElement(xwriter, dsPrefix, "Q", XMLSignature.XMLNS, params.getQ()); - writeBase64BigIntegerElement(xwriter, dsPrefix, "G", XMLSignature.XMLNS, params.getG()); - writeBase64BigIntegerElement(xwriter, dsPrefix, "Y", XMLSignature.XMLNS, publicKey.getY() ); - - xwriter.writeEndElement(); // "DSAKeyValue" + Element pElem = DOMUtils.createElement(doc, "P", XMLSignature.XMLNS, + dsPrefix); + Element qElem = DOMUtils.createElement(doc, "Q", XMLSignature.XMLNS, + dsPrefix); + Element gElem = DOMUtils.createElement(doc, "G", XMLSignature.XMLNS, + dsPrefix); + Element yElem = DOMUtils.createElement(doc, "Y", XMLSignature.XMLNS, + dsPrefix); + p.marshal(pElem, dsPrefix, context); + q.marshal(qElem, dsPrefix, context); + g.marshal(gElem, dsPrefix, context); + y.marshal(yElem, dsPrefix, context); + dsaElem.appendChild(pElem); + dsaElem.appendChild(qElem); + dsaElem.appendChild(gElem); + dsaElem.appendChild(yElem); + parent.appendChild(dsaElem); } @Override @@ -316,8 +338,7 @@ } static final class EC extends DOMKeyValue { - - // ECKeyValue CryptoBinaries + // ECKeyValue CryptoBinaries private byte[] ecPublicKey; private KeyFactory eckf; private ECParameterSpec ecParams; @@ -460,27 +481,35 @@ } @Override - void marshalPublicKey(XmlWriter xwriter, ECPublicKey publicKey, String dsPrefix, - XMLCryptoContext context) + void marshalPublicKey(Node parent, Document doc, String dsPrefix, + DOMCryptoContext context) throws MarshalException { String prefix = DOMUtils.getNSPrefix(context, XMLDSIG_11_XMLNS); - xwriter.writeStartElement(prefix, "ECKeyValue", XMLDSIG_11_XMLNS); - - xwriter.writeStartElement(prefix, "NamedCurve", XMLDSIG_11_XMLNS); - xwriter.writeNamespace(prefix, XMLDSIG_11_XMLNS); + Element ecKeyValueElem = DOMUtils.createElement(doc, "ECKeyValue", + XMLDSIG_11_XMLNS, + prefix); + Element namedCurveElem = DOMUtils.createElement(doc, "NamedCurve", + XMLDSIG_11_XMLNS, + prefix); + Element publicKeyElem = DOMUtils.createElement(doc, "PublicKey", + XMLDSIG_11_XMLNS, + prefix); String oid = getCurveOid(ecParams); if (oid == null) { throw new MarshalException("Invalid ECParameterSpec"); } - xwriter.writeAttribute("", "", "URI", "urn:oid:" + oid); - xwriter.writeEndElement(); - - xwriter.writeStartElement(prefix, "PublicKey", XMLDSIG_11_XMLNS); - String encoded = Base64.getMimeEncoder().encodeToString(ecPublicKey); - xwriter.writeCharacters(encoded); - xwriter.writeEndElement(); // "PublicKey" - xwriter.writeEndElement(); // "ECKeyValue" + DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid); + String qname = (prefix == null || prefix.length() == 0) + ? "xmlns" : "xmlns:" + prefix; + namedCurveElem.setAttributeNS("http://www.w3.org/2000/xmlns/", + qname, XMLDSIG_11_XMLNS); + ecKeyValueElem.appendChild(namedCurveElem); + String encoded = XMLUtils.encodeToString(ecPublicKey); + publicKeyElem.appendChild + (DOMUtils.getOwnerDocument(publicKeyElem).createTextNode(encoded)); + ecKeyValueElem.appendChild(publicKeyElem); + parent.appendChild(ecKeyValueElem); } @Override @@ -526,7 +555,7 @@ try { String content = XMLUtils.getFullTextChildrenFromElement(curElem); - ecPoint = decodePoint(Base64.getMimeDecoder().decode(content), + ecPoint = decodePoint(XMLUtils.decode(content), ecParams.getCurve()); } catch (IOException ioe) { throw new MarshalException("Invalid EC Point", ioe); @@ -574,21 +603,23 @@ } static final class Unknown extends DOMKeyValue { - private XMLStructure externalPublicKey; + private javax.xml.crypto.dom.DOMStructure externalPublicKey; Unknown(Element elem) throws MarshalException { super(elem); } + @Override PublicKey unmarshalKeyValue(Element kvElem) throws MarshalException { externalPublicKey = new javax.xml.crypto.dom.DOMStructure(kvElem); return null; } + @Override - void marshalPublicKey(XmlWriter xwriter, PublicKey publicKey, String dsPrefix, - XMLCryptoContext context) + void marshalPublicKey(Node parent, Document doc, String dsPrefix, + DOMCryptoContext context) throws MarshalException { - xwriter.marshalStructure(externalPublicKey, dsPrefix, context); + parent.appendChild(externalPublicKey.getNode()); } } } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,18 +29,21 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import java.security.Provider; import java.util.*; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * DOM-based implementation of Manifest. * */ -public final class DOMManifest extends BaseStructure implements Manifest { +public final class DOMManifest extends DOMStructure implements Manifest { private final List references; private final String id; @@ -58,7 +61,7 @@ * @throws ClassCastException if {@code references} contains any * entries that are not of type {@link Reference} */ - public DOMManifest(List references, String id) { + public DOMManifest(List references, String id) { if (references == null) { throw new NullPointerException("references cannot be null"); } @@ -114,7 +117,6 @@ this.references = Collections.unmodifiableList(refs); } - @Override public String getId() { return id; } @@ -129,18 +131,21 @@ return references; } - public static void marshal(XmlWriter xwriter, Manifest manif, String dsPrefix, XMLCryptoContext context) - throws MarshalException { - xwriter.writeStartElement(dsPrefix, "Manifest", XMLSignature.XMLNS); - xwriter.writeIdAttribute("", "", "Id", manif.getId()); + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) + throws MarshalException + { + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element manElem = DOMUtils.createElement(ownerDoc, "Manifest", + XMLSignature.XMLNS, dsPrefix); + + DOMUtils.setAttributeID(manElem, "Id", id); // add references - @SuppressWarnings("unchecked") - List references = manif.getReferences(); for (Reference ref : references) { - ((DOMReference)ref).marshal(xwriter, dsPrefix, context); + ((DOMReference)ref).marshal(manElem, dsPrefix, context); } - xwriter.writeEndElement(); // "Manifest" + parent.appendChild(manElem); } @Override diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java Sat Mar 09 12:54:20 2019 +0000 @@ -31,9 +31,11 @@ import java.util.*; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.keyinfo.PGPData; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -43,7 +45,7 @@ * DOM-based implementation of PGPData. * */ -public final class DOMPGPData extends BaseStructure implements PGPData { +public final class DOMPGPData extends DOMStructure implements PGPData { private final byte[] keyId; private final byte[] keyPacket; @@ -156,10 +158,10 @@ String namespace = childElem.getNamespaceURI(); if ("PGPKeyID".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { String content = XMLUtils.getFullTextChildrenFromElement(childElem); - pgpKeyId = Base64.getMimeDecoder().decode(content); + pgpKeyId = XMLUtils.decode(content); } else if ("PGPKeyPacket".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { String content = XMLUtils.getFullTextChildrenFromElement(childElem); - pgpKeyPacket = Base64.getMimeDecoder().decode(content); + pgpKeyPacket = XMLUtils.decode(content); } else { other.add (new javax.xml.crypto.dom.DOMStructure(childElem)); @@ -172,21 +174,56 @@ this.externalElements = Collections.unmodifiableList(other); } - @Override public byte[] getKeyId() { return keyId == null ? null : keyId.clone(); } - @Override public byte[] getKeyPacket() { return keyPacket == null ? null : keyPacket.clone(); } - @Override public List getExternalElements() { return externalElements; } + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) + throws MarshalException + { + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element pdElem = DOMUtils.createElement(ownerDoc, "PGPData", + XMLSignature.XMLNS, dsPrefix); + + // create and append PGPKeyID element + if (keyId != null) { + Element keyIdElem = DOMUtils.createElement(ownerDoc, "PGPKeyID", + XMLSignature.XMLNS, + dsPrefix); + keyIdElem.appendChild + (ownerDoc.createTextNode(XMLUtils.encodeToString(keyId))); + pdElem.appendChild(keyIdElem); + } + + // create and append PGPKeyPacket element + if (keyPacket != null) { + Element keyPktElem = DOMUtils.createElement(ownerDoc, + "PGPKeyPacket", + XMLSignature.XMLNS, + dsPrefix); + keyPktElem.appendChild + (ownerDoc.createTextNode(XMLUtils.encodeToString(keyPacket))); + pdElem.appendChild(keyPktElem); + } + + // create and append any elements + for (XMLStructure extElem : externalElements) { + DOMUtils.appendChild(pdElem, ((javax.xml.crypto.dom.DOMStructure) + extElem).getNode()); + } + + parent.appendChild(pdElem); + } + /** * We assume packets use the new format packet syntax, as specified in * section 4 of RFC 2440. diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java Sat Mar 09 12:54:20 2019 +0000 @@ -37,6 +37,7 @@ import javax.xml.crypto.*; import javax.xml.crypto.dsig.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dom.DOMURIReference; import java.io.*; @@ -46,6 +47,7 @@ import java.util.*; import org.w3c.dom.Attr; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -54,6 +56,7 @@ import org.jcp.xml.dsig.internal.DigesterOutputStream; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; /** * DOM-based implementation of Reference. @@ -242,7 +245,7 @@ // unmarshal DigestValue Element dvElem = DOMUtils.getNextSiblingElement(dmElem, "DigestValue", XMLSignature.XMLNS); String content = XMLUtils.getFullTextChildrenFromElement(dvElem); - this.digestValue = Base64.getMimeDecoder().decode(content); + this.digestValue = XMLUtils.decode(content); // check for extra elements if (DOMUtils.getNextSiblingElement(dvElem) != null) { @@ -252,7 +255,14 @@ // unmarshal attributes this.uri = DOMUtils.getAttributeValue(refElem, "URI"); - this.id = DOMUtils.getIdAttributeValue(refElem, "Id"); + + Attr attr = refElem.getAttributeNodeNS(null, "Id"); + if (attr != null) { + this.id = attr.getValue(); + refElem.setIdAttributeNode(attr, true); + } else { + this.id = null; + } this.type = DOMUtils.getAttributeValue(refElem, "Type"); this.here = refElem.getAttributeNodeNS(null, "URI"); @@ -263,76 +273,80 @@ this.provider = provider; } - @Override public DigestMethod getDigestMethod() { return digestMethod; } - @Override public String getId() { return id; } - @Override public String getURI() { return uri; } - @Override public String getType() { return type; } - @Override public List getTransforms() { return Collections.unmodifiableList(allTransforms); } - @Override public byte[] getDigestValue() { return digestValue == null ? null : digestValue.clone(); } - @Override public byte[] getCalculatedDigestValue() { return calcDigestValue == null ? null : calcDigestValue.clone(); } @Override - public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { LOG.debug("Marshalling Reference"); - xwriter.writeStartElement(dsPrefix, "Reference", XMLSignature.XMLNS); - XMLStructure refStruct = xwriter.getCurrentNodeAsStructure(); - refElem = (Element) ((javax.xml.crypto.dom.DOMStructure) refStruct).getNode(); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + refElem = DOMUtils.createElement(ownerDoc, "Reference", + XMLSignature.XMLNS, dsPrefix); // set attributes - xwriter.writeIdAttribute("", "", "Id", id); - here = xwriter.writeAttribute("", "", "URI", uri); - xwriter.writeAttribute("", "", "Type", type); + DOMUtils.setAttributeID(refElem, "Id", id); + DOMUtils.setAttribute(refElem, "URI", uri); + DOMUtils.setAttribute(refElem, "Type", type); // create and append Transforms element if (!allTransforms.isEmpty()) { - xwriter.writeStartElement(dsPrefix, "Transforms", XMLSignature.XMLNS); + Element transformsElem = DOMUtils.createElement(ownerDoc, + "Transforms", + XMLSignature.XMLNS, + dsPrefix); + refElem.appendChild(transformsElem); for (Transform transform : allTransforms) { - xwriter.marshalStructure(transform, dsPrefix, context); + ((DOMStructure)transform).marshal(transformsElem, + dsPrefix, context); } - xwriter.writeEndElement(); // "Transforms" } // create and append DigestMethod element - DOMDigestMethod.marshal(xwriter, digestMethod, dsPrefix); + ((DOMDigestMethod)digestMethod).marshal(refElem, dsPrefix, context); // create and append DigestValue element LOG.debug("Adding digestValueElem"); - xwriter.writeStartElement(dsPrefix, "DigestValue", XMLSignature.XMLNS); + Element digestValueElem = DOMUtils.createElement(ownerDoc, + "DigestValue", + XMLSignature.XMLNS, + dsPrefix); if (digestValue != null) { - xwriter.writeCharacters(Base64.getMimeEncoder().encodeToString(digestValue)); + digestValueElem.appendChild + (ownerDoc.createTextNode(XMLUtils.encodeToString(digestValue))); + } - xwriter.writeEndElement(); // "DigestValue" - xwriter.writeEndElement(); // "Reference" + refElem.appendChild(digestValueElem); + + parent.appendChild(refElem); + here = refElem.getAttributeNodeNS(null, "URI"); } public void digest(XMLSignContext signContext) @@ -347,7 +361,7 @@ digestValue = transform(data, signContext); // insert digestValue into DigestValue element - String encodedDV = Base64.getMimeEncoder().encodeToString(digestValue); + String encodedDV = XMLUtils.encodeToString(digestValue); LOG.debug("Reference object uri = {}", uri); Element digestElem = DOMUtils.getLastChildElement(refElem); if (digestElem == null) { @@ -361,7 +375,6 @@ LOG.debug("Reference digesting completed"); } - @Override public boolean validate(XMLValidateContext validateContext) throws XMLSignatureException { @@ -375,8 +388,8 @@ calcDigestValue = transform(data, validateContext); if (LOG.isDebugEnabled()) { - LOG.debug("Expected digest: " + Base64.getMimeEncoder().encodeToString(digestValue)); - LOG.debug("Actual digest: " + Base64.getMimeEncoder().encodeToString(calcDigestValue)); + LOG.debug("Expected digest: " + XMLUtils.encodeToString(digestValue)); + LOG.debug("Actual digest: " + XMLUtils.encodeToString(calcDigestValue)); } validationStatus = Arrays.equals(digestValue, calcDigestValue); @@ -384,12 +397,10 @@ return validationStatus; } - @Override public Data getDereferencedData() { return derefData; } - @Override public InputStream getDigestInputStream() { return dis; } @@ -516,8 +527,8 @@ } else { transformsElem = DOMUtils.getFirstChildElement(refElem); } - XmlWriter xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), transformsElem); - t.marshal(xwriter, dsPrefix, context); + t.marshal(transformsElem, dsPrefix, + (DOMCryptoContext)context); allTransforms.add(t); xi.updateOutputStream(os, true); } else { @@ -550,7 +561,6 @@ } } - @Override public Node getHere() { return here; } @@ -614,7 +624,6 @@ try { final Set s = xsi.getNodeSet(); return new NodeSetData() { - @Override public Iterator iterator() { return s.iterator(); } }; } catch (Exception e) { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java Sat Mar 09 12:54:20 2019 +0000 @@ -52,6 +52,7 @@ import javax.xml.crypto.URIReferenceException; import javax.xml.crypto.XMLCryptoContext; import javax.xml.crypto.XMLStructure; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dom.DOMURIReference; import javax.xml.crypto.dsig.Transform; import javax.xml.crypto.dsig.XMLSignature; @@ -179,50 +180,53 @@ } } - @Override public String getURI() { return uri; } - @Override public String getType() { return type; } - @Override public List getTransforms() { return transforms; } @Override - public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "RetrievalMethod", XMLSignature.XMLNS); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element rmElem = DOMUtils.createElement(ownerDoc, "RetrievalMethod", + XMLSignature.XMLNS, dsPrefix); - // TODO - see whether it is important to capture the "here" attribute as part of the - // marshalling - do any of the tests fail? // add URI and Type attributes - here = xwriter.writeAttribute("", "", "URI", uri); - xwriter.writeAttribute("", "", "Type", type); + DOMUtils.setAttribute(rmElem, "URI", uri); + DOMUtils.setAttribute(rmElem, "Type", type); // add Transforms elements if (!transforms.isEmpty()) { - xwriter.writeStartElement(dsPrefix, "Transforms", XMLSignature.XMLNS); + Element transformsElem = DOMUtils.createElement(ownerDoc, + "Transforms", + XMLSignature.XMLNS, + dsPrefix); + rmElem.appendChild(transformsElem); for (Transform transform : transforms) { - ((DOMTransform)transform).marshal(xwriter, dsPrefix, context); + ((DOMTransform)transform).marshal(transformsElem, + dsPrefix, context); } - xwriter.writeEndElement(); // "Transforms" } - xwriter.writeEndElement(); // "RetrievalMethod" + + parent.appendChild(rmElem); + + // save here node + here = rmElem.getAttributeNodeNS(null, "URI"); } - @Override public Node getHere() { return here; } - @Override public Data dereference(XMLCryptoContext context) throws URIReferenceException { @@ -244,7 +248,7 @@ // pass dereferenced data through Transforms try { for (Transform transform : transforms) { - data = transform.transform(data, context); + data = ((DOMTransform)transform).transform(data, context); } } catch (Exception e) { throw new URIReferenceException(e); diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java Sat Mar 09 12:54:20 2019 +0000 @@ -224,7 +224,6 @@ } } - @Override public final AlgorithmParameterSpec getParameterSpec() { return params; } @@ -246,8 +245,7 @@ : Signature.getInstance(getJCAAlgorithm(), p); } - @Override - boolean verify(Key key, DOMSignedInfo si, byte[] sig, + boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException { @@ -276,7 +274,7 @@ byte[] s; try (SignerOutputStream outputStream = new SignerOutputStream(signature)) { - si.canonicalize(context, outputStream); + ((DOMSignedInfo)si).canonicalize(context, outputStream); // Do any necessary format conversions s = preVerifyFormat(key, sig); } catch (IOException ioe) { @@ -314,8 +312,7 @@ } } - @Override - byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context) + byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { if (key == null || si == null) { @@ -341,7 +338,7 @@ LOG.debug("JCA Algorithm: {}", getJCAAlgorithm()); try (SignerOutputStream outputStream = new SignerOutputStream(signature)) { - si.canonicalize(context, outputStream); + ((DOMSignedInfo)si).canonicalize(context, outputStream); // Return signature with any necessary format conversions return postSignFormat(key, signature.sign()); } catch (SignatureException | IOException ex){ @@ -570,15 +567,12 @@ SHA224withRSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return RSA_SHA224; } - @Override String getJCAAlgorithm() { return "SHA224withRSA"; } - @Override Type getAlgorithmType() { return Type.RSA; } @@ -592,15 +586,12 @@ SHA256withRSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return RSA_SHA256; } - @Override String getJCAAlgorithm() { return "SHA256withRSA"; } - @Override Type getAlgorithmType() { return Type.RSA; } @@ -614,15 +605,12 @@ SHA384withRSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return RSA_SHA384; } - @Override String getJCAAlgorithm() { return "SHA384withRSA"; } - @Override Type getAlgorithmType() { return Type.RSA; } @@ -636,15 +624,12 @@ SHA512withRSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return RSA_SHA512; } - @Override String getJCAAlgorithm() { return "SHA512withRSA"; } - @Override Type getAlgorithmType() { return Type.RSA; } @@ -857,18 +842,15 @@ SHA1withDSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return SignatureMethod.DSA_SHA1; } - @Override String getJCAAlgorithm() { return "SHA1withDSAinP1363Format"; } String getJCAFallbackAlgorithm() { return "SHA1withDSA"; } - @Override Type getAlgorithmType() { return Type.DSA; } @@ -904,18 +886,15 @@ SHA1withECDSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return ECDSA_SHA1; } - @Override String getJCAAlgorithm() { return "SHA1withECDSAinP1363Format"; } String getJCAFallbackAlgorithm() { return "SHA1withECDSA"; } - @Override Type getAlgorithmType() { return Type.ECDSA; } @@ -954,18 +933,15 @@ SHA256withECDSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return ECDSA_SHA256; } - @Override String getJCAAlgorithm() { return "SHA256withECDSAinP1363Format"; } String getJCAFallbackAlgorithm() { return "SHA256withECDSA"; } - @Override Type getAlgorithmType() { return Type.ECDSA; } @@ -979,18 +955,15 @@ SHA384withECDSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return ECDSA_SHA384; } - @Override String getJCAAlgorithm() { return "SHA384withECDSAinP1363Format"; } String getJCAFallbackAlgorithm() { return "SHA384withECDSA"; } - @Override Type getAlgorithmType() { return Type.ECDSA; } @@ -1004,18 +977,15 @@ SHA512withECDSA(Element dmElem) throws MarshalException { super(dmElem); } - @Override public String getAlgorithm() { return ECDSA_SHA512; } - @Override String getJCAAlgorithm() { return "SHA512withECDSAinP1363Format"; } String getJCAFallbackAlgorithm() { return "SHA512withECDSA"; } - @Override Type getAlgorithmType() { return Type.ECDSA; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,10 +29,13 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import java.util.*; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -40,7 +43,7 @@ * DOM-based implementation of SignatureProperties. * */ -public final class DOMSignatureProperties extends BaseStructure +public final class DOMSignatureProperties extends DOMStructure implements SignatureProperties { private final String id; @@ -58,7 +61,7 @@ * @throws IllegalArgumentException if {@code properties} is empty * @throws NullPointerException if {@code properties} */ - public DOMSignatureProperties(List properties, + public DOMSignatureProperties(List properties, String id) { if (properties == null) { @@ -88,7 +91,13 @@ throws MarshalException { // unmarshal attributes - id = DOMUtils.getIdAttributeValue(propsElem, "Id"); + Attr attr = propsElem.getAttributeNodeNS(null, "Id"); + if (attr != null) { + id = attr.getValue(); + propsElem.setIdAttributeNode(attr, true); + } else { + id = null; + } List newProperties = new ArrayList<>(); Node firstChild = propsElem.getFirstChild(); @@ -111,32 +120,34 @@ } } - @Override public List getProperties() { return properties; } - @Override public String getId() { return id; } - public static void marshal(XmlWriter xwriter, SignatureProperties sigProps, String dsPrefix, XMLCryptoContext context) + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "SignatureProperties", XMLSignature.XMLNS); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element propsElem = DOMUtils.createElement(ownerDoc, + "SignatureProperties", + XMLSignature.XMLNS, + dsPrefix); // set attributes - xwriter.writeIdAttribute("", "", "Id", sigProps.getId()); + DOMUtils.setAttributeID(propsElem, "Id", id); // create and append any properties - @SuppressWarnings("unchecked") - List properties = sigProps.getProperties(); for (SignatureProperty property : properties) { - DOMSignatureProperty.marshal(xwriter, property, dsPrefix, context); + ((DOMSignatureProperty)property).marshal(propsElem, dsPrefix, + context); } - xwriter.writeEndElement(); // "SignatureProperties" + parent.appendChild(propsElem); } @Override diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,10 +29,13 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import java.util.*; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -40,7 +43,7 @@ * DOM-based implementation of SignatureProperty. * */ -public final class DOMSignatureProperty extends BaseStructure +public final class DOMSignatureProperty extends DOMStructure implements SignatureProperty { private final String id; @@ -96,7 +99,13 @@ if (target == null) { throw new MarshalException("target cannot be null"); } - id = DOMUtils.getIdAttributeValue(propElem, "Id"); + Attr attr = propElem.getAttributeNodeNS(null, "Id"); + if (attr != null) { + id = attr.getValue(); + propElem.setIdAttributeNode(attr, true); + } else { + id = null; + } List newContent = new ArrayList<>(); Node firstChild = propElem.getFirstChild(); @@ -111,37 +120,37 @@ } } - @Override public List getContent() { return content; } - @Override public String getId() { return id; } - @Override public String getTarget() { return target; } - public static void marshal(XmlWriter xwriter, SignatureProperty sigProp, String dsPrefix, XMLCryptoContext context) + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "SignatureProperty", XMLSignature.XMLNS); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element propElem = DOMUtils.createElement(ownerDoc, "SignatureProperty", + XMLSignature.XMLNS, dsPrefix); // set attributes - xwriter.writeIdAttribute("", "", "Id", sigProp.getId()); - xwriter.writeAttribute("", "", "Target", sigProp.getTarget()); + DOMUtils.setAttributeID(propElem, "Id", id); + DOMUtils.setAttribute(propElem, "Target", target); // create and append any elements and mixed content - List content = getContent(sigProp); for (XMLStructure property : content) { - xwriter.marshalStructure(property, dsPrefix, context); + DOMUtils.appendChild(propElem, + ((javax.xml.crypto.dom.DOMStructure)property).getNode()); } - xwriter.writeEndElement(); // "SignatureProperty" + parent.appendChild(propElem); } @Override @@ -176,10 +185,6 @@ return result; } - @SuppressWarnings("unchecked") - private static List getContent(SignatureProperty prop) { - return prop.getContent(); - } private boolean equalsContent(List otherContent) { int osize = otherContent.size(); if (content.size() != osize) { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,6 +29,7 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import java.io.ByteArrayInputStream; @@ -39,8 +40,11 @@ import java.security.Provider; import java.util.*; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; /** * DOM-based implementation of SignedInfo. @@ -55,6 +59,7 @@ private CanonicalizationMethod canonicalizationMethod; private SignatureMethod signatureMethod; private String id; + private Document ownerDoc; private Element localSiElem; private InputStream canonData; @@ -123,6 +128,7 @@ public DOMSignedInfo(Element siElem, XMLCryptoContext context, Provider provider) throws MarshalException { localSiElem = siElem; + ownerDoc = siElem.getOwnerDocument(); // get Id attribute, if specified id = DOMUtils.getAttributeValue(siElem, "Id"); @@ -175,27 +181,22 @@ references = Collections.unmodifiableList(refList); } - @Override public CanonicalizationMethod getCanonicalizationMethod() { return canonicalizationMethod; } - @Override public SignatureMethod getSignatureMethod() { return signatureMethod; } - @Override public String getId() { return id; } - @Override public List getReferences() { return references; } - @Override public InputStream getCanonicalizedData() { return canonData; } @@ -223,7 +224,7 @@ sb.append((char)signedInfoBytes[i]); } LOG.debug(sb.toString()); - LOG.debug("Data to be signed/verified:" + Base64.getMimeEncoder().encodeToString(signedInfoBytes)); + LOG.debug("Data to be signed/verified:" + XMLUtils.encodeToString(signedInfoBytes)); } this.canonData = new ByteArrayInputStream(signedInfoBytes); @@ -236,32 +237,31 @@ } @Override - public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "SignedInfo", XMLSignature.XMLNS); - XMLStructure siStruct = xwriter.getCurrentNodeAsStructure(); - localSiElem = (Element) ((javax.xml.crypto.dom.DOMStructure) siStruct).getNode(); - - // append Id attribute - xwriter.writeIdAttribute("", "", "Id", id); + ownerDoc = DOMUtils.getOwnerDocument(parent); + Element siElem = DOMUtils.createElement(ownerDoc, "SignedInfo", + XMLSignature.XMLNS, dsPrefix); // create and append CanonicalizationMethod element DOMCanonicalizationMethod dcm = (DOMCanonicalizationMethod)canonicalizationMethod; - dcm.marshal(xwriter, dsPrefix, context); + dcm.marshal(siElem, dsPrefix, context); // create and append SignatureMethod element - ((AbstractDOMSignatureMethod)signatureMethod).marshal(xwriter, dsPrefix); + ((DOMStructure)signatureMethod).marshal(siElem, dsPrefix, context); // create and append Reference elements for (Reference reference : references) { - // TODO - either suppress warning here, or figure out how to get rid of the cast. - DOMReference domRef = (DOMReference)reference; - domRef.marshal(xwriter, dsPrefix, context); + ((DOMReference)reference).marshal(siElem, dsPrefix, context); } - xwriter.writeEndElement(); // "SignedInfo" + // append Id attribute + DOMUtils.setAttributeID(siElem, "Id", id); + + parent.appendChild(siElem); + localSiElem = siElem; } @Override diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,13 +29,24 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.MarshalException; -import javax.xml.crypto.XMLCryptoContext; +import javax.xml.crypto.XMLStructure; +import javax.xml.crypto.dom.DOMCryptoContext; +import org.w3c.dom.Node; /** * DOM-based abstract implementation of XMLStructure. * */ -public abstract class DOMStructure extends BaseStructure { +public abstract class DOMStructure implements XMLStructure { - public abstract void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) throws MarshalException; + public final boolean isFeatureSupported(String feature) { + if (feature == null) { + throw new NullPointerException(); + } else { + return false; + } + } + + public abstract void marshal(Node parent, String dsPrefix, + DOMCryptoContext context) throws MarshalException; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java Sat Mar 09 12:54:20 2019 +0000 @@ -82,7 +82,6 @@ this.withComments = !excludeComments; } - @Override public boolean hasNext() { if (nodeSet == null) { nodeSet = dereferenceSameDocumentURI(root); @@ -91,7 +90,6 @@ return li.hasNext(); } - @Override public Node next() { if (nodeSet == null) { nodeSet = dereferenceSameDocumentURI(root); @@ -104,7 +102,6 @@ } } - @Override public void remove() { throw new UnsupportedOperationException(); } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java Sat Mar 09 12:54:20 2019 +0000 @@ -37,12 +37,14 @@ import javax.xml.crypto.Data; import javax.xml.crypto.MarshalException; import javax.xml.crypto.XMLCryptoContext; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.Transform; import javax.xml.crypto.dsig.TransformException; import javax.xml.crypto.dsig.TransformService; import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.dom.DOMSignContext; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -50,7 +52,7 @@ * DOM-based abstract implementation of Transform. * */ -public class DOMTransform extends BaseStructure implements Transform { +public class DOMTransform extends DOMStructure implements Transform { protected TransformService spi; @@ -74,6 +76,7 @@ throws MarshalException { String algorithm = DOMUtils.getAttributeValue(transElem, "Algorithm"); + if (provider == null) { try { spi = TransformService.getInstance(algorithm, "DOM"); @@ -98,12 +101,10 @@ } } - @Override public final AlgorithmParameterSpec getParameterSpec() { return spi.getParameterSpec(); } - @Override public final String getAlgorithm() { return spi.getAlgorithm(); } @@ -111,18 +112,29 @@ /** * This method marshals any algorithm-specific parameters. */ - public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - String parentLocalName = xwriter.getCurrentLocalName(); - String localName = "Transforms".equals(parentLocalName) ? "Transform" : "CanonicalizationMethod"; - xwriter.writeStartElement(dsPrefix, localName, XMLSignature.XMLNS); - xwriter.writeAttribute("", "", "Algorithm", getAlgorithm()); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); - javax.xml.crypto.XMLStructure xmlStruct = xwriter.getCurrentNodeAsStructure(); - spi.marshalParams(xmlStruct, context); + Element transformElem = null; + if (parent.getLocalName().equals("Transforms")) { + transformElem = DOMUtils.createElement(ownerDoc, "Transform", + XMLSignature.XMLNS, + dsPrefix); + } else { + transformElem = DOMUtils.createElement(ownerDoc, + "CanonicalizationMethod", + XMLSignature.XMLNS, + dsPrefix); + } + DOMUtils.setAttribute(transformElem, "Algorithm", getAlgorithm()); - xwriter.writeEndElement(); // "Transforms" or "CanonicalizationMethod" + spi.marshalParams(new javax.xml.crypto.dom.DOMStructure(transformElem), + context); + + parent.appendChild(transformElem); } /** @@ -136,7 +148,6 @@ * @throws XMLSignatureException if an unexpected error occurs while * executing the transform */ - @Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { @@ -156,7 +167,6 @@ * @throws XMLSignatureException if an unexpected error occurs while * executing the transform */ - @Override public Data transform(Data data, XMLCryptoContext xc, OutputStream os) throws TransformException { @@ -210,9 +220,8 @@ Data transform(Data data, XMLCryptoContext xc, DOMSignContext context) throws MarshalException, TransformException { - Node parent = context.getParent(); - XmlWriter xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), parent); - marshal(xwriter, DOMUtils.getSignaturePrefix(context), context); + marshal(context.getParent(), + DOMUtils.getSignaturePrefix(context), context); return transform(data, xc); } } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java Sat Mar 09 12:54:20 2019 +0000 @@ -54,7 +54,6 @@ Init.init(); } - @Override public Data dereference(URIReference uriRef, XMLCryptoContext context) throws URIReferenceException { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java Sat Mar 09 12:54:20 2019 +0000 @@ -92,7 +92,9 @@ public static Element createElement(Document doc, String tag, String nsURI, String prefix) { - return doc.createElementNS(nsURI, getQNameString(prefix, tag)); + String qName = (prefix == null || prefix.length() == 0) + ? tag : prefix + ":" + tag; + return doc.createElementNS(nsURI, qName); } /** @@ -335,25 +337,20 @@ this.nl = nl; } - @Override public int size() { return nl.getLength(); } - @Override public Iterator iterator() { return new Iterator() { private int index; - @Override public void remove() { throw new UnsupportedOperationException(); } - @Override public Node next() { if (!hasNext()) { throw new NoSuchElementException(); } return nl.item(index++); } - @Override public boolean hasNext() { return index < nl.getLength(); } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java Sat Mar 09 12:54:20 2019 +0000 @@ -34,10 +34,13 @@ import java.util.*; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dsig.keyinfo.X509Data; +import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial; import javax.security.auth.x500.X500Principal; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -48,7 +51,7 @@ * */ //@@@ check for illegal combinations of data violating MUSTs in W3c spec -public final class DOMX509Data extends BaseStructure implements X509Data { +public final class DOMX509Data extends DOMStructure implements X509Data { private final List content; private CertificateFactory cf; @@ -113,7 +116,7 @@ newContent.add(childElem.getFirstChild().getNodeValue()); } else if ("X509SKI".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { String content = XMLUtils.getFullTextChildrenFromElement(childElem); - newContent.add(Base64.getMimeDecoder().decode(content)); + newContent.add(XMLUtils.decode(content)); } else if ("X509CRL".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { newContent.add(unmarshalX509CRL(childElem)); } else { @@ -125,68 +128,89 @@ this.content = Collections.unmodifiableList(newContent); } - @Override public List getContent() { return content; } - public static void marshal(XmlWriter xwriter, X509Data x509Data, String dsPrefix, XMLCryptoContext context) + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "X509Data", XMLSignature.XMLNS); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + Element xdElem = DOMUtils.createElement(ownerDoc, "X509Data", + XMLSignature.XMLNS, dsPrefix); - List content = x509Data.getContent(); // append children and preserve order for (int i = 0, size = content.size(); i < size; i++) { Object object = content.get(i); if (object instanceof X509Certificate) { - marshalCert(xwriter, (X509Certificate) object, dsPrefix); + marshalCert((X509Certificate)object,xdElem,ownerDoc,dsPrefix); } else if (object instanceof XMLStructure) { - xwriter.marshalStructure((XMLStructure) object, dsPrefix, context); + if (object instanceof X509IssuerSerial) { + ((DOMX509IssuerSerial)object).marshal + (xdElem, dsPrefix, context); + } else { + javax.xml.crypto.dom.DOMStructure domContent = + (javax.xml.crypto.dom.DOMStructure)object; + DOMUtils.appendChild(xdElem, domContent.getNode()); + } } else if (object instanceof byte[]) { - marshalSKI(xwriter, (byte[]) object, dsPrefix); + marshalSKI((byte[])object, xdElem, ownerDoc, dsPrefix); } else if (object instanceof String) { - marshalSubjectName(xwriter, (String) object, dsPrefix); + marshalSubjectName((String)object, xdElem, ownerDoc,dsPrefix); } else if (object instanceof X509CRL) { - marshalCRL(xwriter, (X509CRL) object, dsPrefix); + marshalCRL((X509CRL)object, xdElem, ownerDoc, dsPrefix); } } - xwriter.writeEndElement(); // "X509Data" + + parent.appendChild(xdElem); } - private static void marshalSKI(XmlWriter xwriter, byte[] skid, String dsPrefix) + private void marshalSKI(byte[] skid, Node parent, Document doc, + String dsPrefix) { - xwriter.writeTextElement(dsPrefix, "X509SKI", XMLSignature.XMLNS, - Base64.getMimeEncoder().encodeToString(skid)); + Element skidElem = DOMUtils.createElement(doc, "X509SKI", + XMLSignature.XMLNS, dsPrefix); + skidElem.appendChild(doc.createTextNode(XMLUtils.encodeToString(skid))); + parent.appendChild(skidElem); } - private static void marshalSubjectName(XmlWriter xwriter, String name, String dsPrefix) + private void marshalSubjectName(String name, Node parent, Document doc, + String dsPrefix) { - xwriter.writeTextElement(dsPrefix, "X509SubjectName", XMLSignature.XMLNS, name); + Element snElem = DOMUtils.createElement(doc, "X509SubjectName", + XMLSignature.XMLNS, dsPrefix); + snElem.appendChild(doc.createTextNode(name)); + parent.appendChild(snElem); } - private static void marshalCert(XmlWriter xwriter, X509Certificate cert, String dsPrefix) + private void marshalCert(X509Certificate cert, Node parent, Document doc, + String dsPrefix) throws MarshalException { + Element certElem = DOMUtils.createElement(doc, "X509Certificate", + XMLSignature.XMLNS, dsPrefix); try { - byte[] encoded = cert.getEncoded(); - xwriter.writeTextElement(dsPrefix, "X509Certificate", XMLSignature.XMLNS, - Base64.getMimeEncoder().encodeToString(encoded)); + certElem.appendChild(doc.createTextNode + (XMLUtils.encodeToString(cert.getEncoded()))); } catch (CertificateEncodingException e) { throw new MarshalException("Error encoding X509Certificate", e); } + parent.appendChild(certElem); } - private static void marshalCRL(XmlWriter xwriter, X509CRL crl, String dsPrefix) + private void marshalCRL(X509CRL crl, Node parent, Document doc, + String dsPrefix) throws MarshalException { + Element crlElem = DOMUtils.createElement(doc, "X509CRL", + XMLSignature.XMLNS, dsPrefix); try { - byte[] encoded = crl.getEncoded(); - xwriter.writeTextElement(dsPrefix, "X509CRL", XMLSignature.XMLNS, - Base64.getMimeEncoder().encodeToString(encoded)); + crlElem.appendChild(doc.createTextNode + (XMLUtils.encodeToString(crl.getEncoded()))); } catch (CRLException e) { throw new MarshalException("Error encoding X509CRL", e); } + parent.appendChild(crlElem); } private X509Certificate unmarshalX509Certificate(Element elem) @@ -218,7 +242,7 @@ cf = CertificateFactory.getInstance("X.509"); } String content = XMLUtils.getFullTextChildrenFromElement(elem); - return new ByteArrayInputStream(Base64.getMimeDecoder().decode(content)); + return new ByteArrayInputStream(XMLUtils.decode(content)); } catch (CertificateException e) { throw new MarshalException("Cannot create CertificateFactory", e); } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,20 +29,22 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.MarshalException; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial; import java.math.BigInteger; import javax.security.auth.x500.X500Principal; - +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * DOM-based implementation of X509IssuerSerial. * */ -public final class DOMX509IssuerSerial extends BaseStructure +public final class DOMX509IssuerSerial extends DOMStructure implements X509IssuerSerial { private final String issuerName; @@ -89,17 +91,34 @@ serialNumber = new BigInteger(sNElem.getFirstChild().getNodeValue()); } - @Override public String getIssuerName() { return issuerName; } - @Override public BigInteger getSerialNumber() { return serialNumber; } @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) + throws MarshalException + { + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + + Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial", + XMLSignature.XMLNS, dsPrefix); + Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName", + XMLSignature.XMLNS, dsPrefix); + Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber", + XMLSignature.XMLNS, dsPrefix); + inElem.appendChild(ownerDoc.createTextNode(issuerName)); + snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString())); + isElem.appendChild(inElem); + isElem.appendChild(snElem); + parent.appendChild(isElem); + } + + @Override public boolean equals(Object obj) { if (this == obj) { return true; diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,12 +29,14 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import java.security.Provider; import java.util.*; import org.w3c.dom.Attr; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; @@ -43,12 +45,13 @@ * DOM-based implementation of XMLObject. * */ -public final class DOMXMLObject extends BaseStructure implements XMLObject { +public final class DOMXMLObject extends DOMStructure implements XMLObject { private final String id; private final String mimeType; private final String encoding; private final List content; + private Element objectElem; /** * Creates an {@code XMLObject} from the specified parameters. @@ -142,51 +145,56 @@ } else { this.content = Collections.unmodifiableList(newContent); } + this.objectElem = objElem; } - @Override public List getContent() { return content; } - @Override public String getId() { return id; } - @Override public String getMimeType() { return mimeType; } - @Override public String getEncoding() { return encoding; } - public static void marshal(XmlWriter xwriter, XMLObject xmlObj, String dsPrefix, XMLCryptoContext context) + @Override + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { - xwriter.writeStartElement(dsPrefix, "Object", XMLSignature.XMLNS); + Document ownerDoc = DOMUtils.getOwnerDocument(parent); + + Element objElem = objectElem != null ? objectElem : null; + if (objElem == null) { + objElem = DOMUtils.createElement(ownerDoc, "Object", + XMLSignature.XMLNS, dsPrefix); - // set attributes - xwriter.writeIdAttribute("", "", "Id", xmlObj.getId()); - xwriter.writeAttribute("", "", "MimeType", xmlObj.getMimeType()); - xwriter.writeAttribute("", "", "Encoding", xmlObj.getEncoding()); + // set attributes + DOMUtils.setAttributeID(objElem, "Id", id); + DOMUtils.setAttribute(objElem, "MimeType", mimeType); + DOMUtils.setAttribute(objElem, "Encoding", encoding); - // create and append any elements and mixed content, if necessary - @SuppressWarnings("unchecked") - List content = xmlObj.getContent(); - for (XMLStructure object : content) { - xwriter.marshalStructure(object, dsPrefix, context); + // create and append any elements and mixed content, if necessary + for (XMLStructure object : content) { + if (object instanceof DOMStructure) { + ((DOMStructure)object).marshal(objElem, dsPrefix, context); + } else { + javax.xml.crypto.dom.DOMStructure domObject = + (javax.xml.crypto.dom.DOMStructure)object; + DOMUtils.appendChild(objElem, domObject.getNode()); + } + } } - xwriter.writeEndElement(); // "Object" + + parent.appendChild(objElem); } @SuppressWarnings("unchecked") - public static List getXmlObjectContent(XMLObject xo) { - return xo.getContent(); - } - @Override public boolean equals(Object o) { if (this == o) { @@ -208,7 +216,7 @@ : mimeType.equals(oxo.getMimeType()); return idsEqual && encodingsEqual && mimeTypesEqual && - equalsContent(getXmlObjectContent(oxo)); + equalsContent(oxo.getContent()); } @Override diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java Sat Mar 09 12:54:20 2019 +0000 @@ -36,6 +36,7 @@ package org.jcp.xml.dsig.internal.dom; import javax.xml.crypto.*; +import javax.xml.crypto.dom.*; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dsig.dom.DOMSignContext; import javax.xml.crypto.dsig.dom.DOMValidateContext; @@ -46,11 +47,12 @@ import java.security.Provider; import java.util.Collections; import java.util.ArrayList; -import java.util.Base64; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -70,6 +72,9 @@ private KeyInfo ki; private List objects; private SignedInfo si; + private Document ownerDoc = null; + private Element localSigElem = null; + private Element sigElem = null; private boolean validationStatus; private boolean validated = false; private KeySelectorResult ksr; @@ -127,7 +132,8 @@ Provider provider) throws MarshalException { - Element localSigElem = sigElem; + localSigElem = sigElem; + ownerDoc = localSigElem.getOwnerDocument(); // get Id attribute, if specified id = DOMUtils.getAttributeValue(localSigElem, "Id"); @@ -171,69 +177,74 @@ } } - @Override public String getId() { return id; } - @Override public KeyInfo getKeyInfo() { return ki; } - @Override public SignedInfo getSignedInfo() { return si; } - @Override public List getObjects() { return objects; } - @Override public SignatureValue getSignatureValue() { return sv; } - @Override public KeySelectorResult getKeySelectorResult() { return ksr; } @Override - public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) + public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) + throws MarshalException + { + marshal(parent, null, dsPrefix, context); + } + + public void marshal(Node parent, Node nextSibling, String dsPrefix, + DOMCryptoContext context) throws MarshalException { - // rationalize the prefix. - String prefix = dsPrefix; - if (prefix == null) { - prefix = ""; + ownerDoc = DOMUtils.getOwnerDocument(parent); + sigElem = DOMUtils.createElement(ownerDoc, "Signature", + XMLSignature.XMLNS, dsPrefix); + + // append xmlns attribute + if (dsPrefix == null || dsPrefix.length() == 0) { + sigElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", + XMLSignature.XMLNS); + } else { + sigElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + + dsPrefix, XMLSignature.XMLNS); } - xwriter.writeStartElement(prefix, "Signature", XMLSignature.XMLNS); - - xwriter.writeNamespace(prefix, XMLSignature.XMLNS); - - // append Id attribute - xwriter.writeIdAttribute("", "", "Id", id); // create and append SignedInfo element - ((DOMSignedInfo) si).marshal(xwriter, prefix, context); + ((DOMSignedInfo)si).marshal(sigElem, dsPrefix, context); // create and append SignatureValue element - ((DOMSignatureValue) sv).marshal(xwriter, prefix, context); + ((DOMSignatureValue)sv).marshal(sigElem, dsPrefix, context); // create and append KeyInfo element if necessary if (ki != null) { - DOMKeyInfo.marshal(xwriter, ki, prefix, context); + ((DOMKeyInfo)ki).marshal(sigElem, null, dsPrefix, context); } // create and append Object elements if necessary - for (XMLObject xmlObj : objects) { - DOMXMLObject.marshal(xwriter, xmlObj, prefix, context); + for (int i = 0, size = objects.size(); i < size; i++) { + ((DOMXMLObject)objects.get(i)).marshal(sigElem, dsPrefix, context); } - xwriter.writeEndElement(); // "Signature" + // append Id attribute + DOMUtils.setAttributeID(sigElem, "Id", id); + + parent.insertBefore(sigElem, nextSibling); } @Override @@ -262,7 +273,8 @@ } // validate all References - List refs = DOMSignedInfo.getSignedInfoReferences(this.si); + @SuppressWarnings("unchecked") + List refs = this.si.getReferences(); boolean validateRefs = true; for (int i = 0, size = refs.size(); validateRefs && i < size; i++) { Reference ref = refs.get(i); @@ -284,14 +296,16 @@ { for (int i=0, size=objects.size(); validateMans && i < size; i++) { XMLObject xo = objects.get(i); - List content = DOMXMLObject.getXmlObjectContent(xo); + @SuppressWarnings("unchecked") + List content = xo.getContent(); int csize = content.size(); for (int j = 0; validateMans && j < csize; j++) { XMLStructure xs = content.get(j); if (xs instanceof Manifest) { LOG.debug("validating manifest"); Manifest man = (Manifest)xs; - List manRefs = DOMManifest.getManifestReferences(man); + @SuppressWarnings("unchecked") + List manRefs = man.getReferences(); int rsize = manRefs.size(); for (int k = 0; validateMans && k < rsize; k++) { Reference ref = manRefs.get(k); @@ -319,13 +333,8 @@ throw new NullPointerException("signContext cannot be null"); } DOMSignContext context = (DOMSignContext)signContext; - Node nextSibling = context.getNextSibling(); - - XmlWriterToTree xwriter = new XmlWriterToTree(Marshaller.getMarshallers(), context.getParent(), nextSibling); - marshal(xwriter, - DOMUtils.getSignaturePrefix(signContext), signContext); - - Element sigElem = xwriter.getCreatedElement(); + marshal(context.getParent(), context.getNextSibling(), + DOMUtils.getSignaturePrefix(context), context); // generate references and signature value List allReferences = new ArrayList<>(); @@ -335,18 +344,21 @@ signatureIdMap = new HashMap<>(); signatureIdMap.put(id, this); signatureIdMap.put(si.getId(), si); - List refs = DOMSignedInfo.getSignedInfoReferences(si); + @SuppressWarnings("unchecked") + List refs = si.getReferences(); for (Reference ref : refs) { signatureIdMap.put(ref.getId(), ref); } for (XMLObject obj : objects) { signatureIdMap.put(obj.getId(), obj); - List content = DOMXMLObject.getXmlObjectContent(obj); + @SuppressWarnings("unchecked") + List content = obj.getContent(); for (XMLStructure xs : content) { if (xs instanceof Manifest) { Manifest man = (Manifest)xs; signatureIdMap.put(man.getId(), man); - List manRefs = DOMManifest.getManifestReferences(man); + @SuppressWarnings("unchecked") + List manRefs = man.getReferences(); for (Reference ref : manRefs) { allReferences.add(ref); signatureIdMap.put(ref.getId(), ref); @@ -389,14 +401,14 @@ // calculate signature value try { - Element sigValue = (Element) sigElem.getElementsByTagNameNS(XMLSignature.XMLNS, "SignatureValue").item(0); - xwriter.resetToNewParent(sigValue); byte[] val = ((AbstractDOMSignatureMethod) - si.getSignatureMethod()).sign(signingKey, (DOMSignedInfo) si, signContext); - ((DOMSignatureValue)sv).setValue(xwriter, val); + si.getSignatureMethod()).sign(signingKey, si, signContext); + ((DOMSignatureValue)sv).setValue(val); } catch (InvalidKeyException ike) { throw new XMLSignatureException(ike); } + + this.localSigElem = sigElem; } @Override @@ -484,6 +496,7 @@ private String id; private byte[] value; private String valueBase64; + private Element sigValueElem; private boolean validated = false; private boolean validationStatus; @@ -496,17 +509,22 @@ { // base64 decode signatureValue String content = XMLUtils.getFullTextChildrenFromElement(sigValueElem); - value = Base64.getMimeDecoder().decode(content); + value = XMLUtils.decode(content); - id = DOMUtils.getIdAttributeValue(sigValueElem, "Id"); + Attr attr = sigValueElem.getAttributeNodeNS(null, "Id"); + if (attr != null) { + id = attr.getValue(); + sigValueElem.setIdAttributeNode(attr, true); + } else { + id = null; + } + this.sigValueElem = sigValueElem; } - @Override public String getId() { return id; } - @Override public byte[] getValue() { return (value == null) ? null : value.clone(); } @@ -552,7 +570,7 @@ // canonicalize SignedInfo and verify signature try { validationStatus = ((AbstractDOMSignatureMethod)sm).verify - (validationKey, (DOMSignedInfo) si, value, validateContext); + (validationKey, si, value, validateContext); } catch (Exception e) { throw new XMLSignatureException(e); } @@ -590,29 +608,25 @@ return result; } - @Override - public void marshal(XmlWriter xwriter, String dsPrefix, - XMLCryptoContext context) + public void marshal(Node parent, String dsPrefix, + DOMCryptoContext context) throws MarshalException { - // create SignatureValue element - xwriter.writeStartElement(dsPrefix, "SignatureValue", XMLSignature.XMLNS); + sigValueElem = DOMUtils.createElement(ownerDoc, "SignatureValue", + XMLSignature.XMLNS, dsPrefix); + if (valueBase64 != null) { + sigValueElem.appendChild(ownerDoc.createTextNode(valueBase64)); + } // append Id attribute, if specified - xwriter.writeIdAttribute("", "", "Id", id); - if (valueBase64 != null) { - xwriter.writeCharacters(valueBase64); - } - - xwriter.writeEndElement(); // "SignatureValue" + DOMUtils.setAttributeID(sigValueElem, "Id", id); + parent.appendChild(sigValueElem); } - void setValue(XmlWriter xwriter, byte[] value) { + void setValue(byte[] value) { this.value = value; - valueBase64 = Base64.getMimeEncoder().encodeToString(value); - if (xwriter != null) { - xwriter.writeCharacters(valueBase64); - } + valueBase64 = XMLUtils.encodeToString(value); + sigValueElem.appendChild(ownerDoc.createTextNode(valueBase64)); } } } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java Sat Mar 09 12:54:20 2019 +0000 @@ -54,24 +54,20 @@ */ public DOMXMLSignatureFactory() {} - @Override public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki) { return new DOMXMLSignature(si, ki, null, null, null); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, List objects, String id, String signatureValueId) { return new DOMXMLSignature(si, ki, objects, id, signatureValueId); } - @Override public Reference newReference(String uri, DigestMethod dm) { return newReference(uri, dm, null, null, null); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id) { @@ -96,7 +92,6 @@ (uri, type, dm, appliedTransforms, result, transforms, id, getProvider()); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id, byte[] digestValue) { @@ -107,14 +102,12 @@ (uri, type, dm, null, null, transforms, id, digestValue, getProvider()); } - @Override @SuppressWarnings({ "rawtypes" }) public SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references) { return newSignedInfo(cm, sm, references, null); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references, String id) { @@ -122,39 +115,33 @@ } // Object factory methods - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public XMLObject newXMLObject(List content, String id, String mimeType, String encoding) { return new DOMXMLObject(content, id, mimeType, encoding); } - @Override @SuppressWarnings({ "rawtypes" }) public Manifest newManifest(List references) { return newManifest(references, null); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Manifest newManifest(List references, String id) { return new DOMManifest(references, id); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public SignatureProperties newSignatureProperties(List props, String id) { return new DOMSignatureProperties(props, id); } - @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public SignatureProperty newSignatureProperty (List info, String target, String id) { return new DOMSignatureProperty(info, target, id); } - @Override public XMLSignature unmarshalXMLSignature(XMLValidateContext context) throws MarshalException { @@ -164,7 +151,6 @@ return unmarshal(((DOMValidateContext) context).getNode(), context); } - @Override public XMLSignature unmarshalXMLSignature(XMLStructure xmlStructure) throws MarshalException { @@ -212,7 +198,6 @@ } } - @Override public boolean isFeatureSupported(String feature) { if (feature == null) { throw new NullPointerException(); @@ -221,7 +206,6 @@ } } - @Override public DigestMethod newDigestMethod(String algorithm, DigestMethodParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { @@ -255,7 +239,6 @@ } } - @Override public SignatureMethod newSignatureMethod(String algorithm, SignatureMethodParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { @@ -321,7 +304,6 @@ } } - @Override public Transform newTransform(String algorithm, TransformParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { @@ -341,7 +323,6 @@ return new DOMTransform(spi); } - @Override public Transform newTransform(String algorithm, XMLStructure params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { @@ -364,7 +345,6 @@ return new DOMTransform(spi); } - @Override public CanonicalizationMethod newCanonicalizationMethod(String algorithm, C14NMethodParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { @@ -383,7 +363,6 @@ return new DOMCanonicalizationMethod(spi); } - @Override public CanonicalizationMethod newCanonicalizationMethod(String algorithm, XMLStructure params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { @@ -406,7 +385,6 @@ return new DOMCanonicalizationMethod(spi); } - @Override public URIDereferencer getURIDereferencer() { return DOMURIDereferencer.INSTANCE; } diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java Sat Mar 09 12:54:20 2019 +0000 @@ -57,7 +57,6 @@ */ public final class DOMXPathFilter2Transform extends ApacheTransform { - @Override public void init(TransformParameterSpec params) throws InvalidAlgorithmParameterException { @@ -70,7 +69,6 @@ this.params = params; } - @Override public void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException { @@ -126,7 +124,6 @@ this.params = new XPathFilter2ParameterSpec(list); } - @Override public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java Sat Mar 09 12:54:20 2019 +0000 @@ -60,7 +60,6 @@ this.params = params; } - @Override public void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException { @@ -89,7 +88,6 @@ } } - @Override public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException { diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java Sat Mar 09 12:54:20 2019 +0000 @@ -55,7 +55,6 @@ this.params = params; } - @Override public void init(XMLStructure parent, XMLCryptoContext context) throws InvalidAlgorithmParameterException { @@ -68,7 +67,6 @@ (new javax.xml.crypto.dom.DOMStructure(sheet)); } - @Override public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException { super.marshalParams(parent, context); diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Marshaller.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Marshaller.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,353 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jcp.xml.dsig.internal.dom; - -import java.util.ArrayList; -import java.util.Base64; -import java.util.List; - -import javax.xml.XMLConstants; -import javax.xml.crypto.MarshalException; -import javax.xml.crypto.XMLCryptoContext; -import javax.xml.crypto.XMLStructure; -import javax.xml.crypto.dsig.DigestMethod; -import javax.xml.crypto.dsig.Manifest; -import javax.xml.crypto.dsig.SignatureProperties; -import javax.xml.crypto.dsig.SignatureProperty; -import javax.xml.crypto.dsig.XMLSignature; -import javax.xml.crypto.dsig.keyinfo.KeyInfo; -import javax.xml.crypto.dsig.keyinfo.KeyName; -import javax.xml.crypto.dsig.keyinfo.KeyValue; -import javax.xml.crypto.dsig.keyinfo.PGPData; -import javax.xml.crypto.dsig.keyinfo.X509Data; -import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial; - -import org.w3c.dom.Attr; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -/** - * Defines the individual marshallers for each of the different javax.xml.crypto structures. - */ -class Marshaller { - - private Marshaller() { - // complete - } - - public static List> getMarshallers() { - return MARSHALLERS; - } - - /** - * Marshals a {@link KeyName}. - * - * @param xwriter - * @param keyName - * @param dsPrefix - */ - public static void marshalKeyName(XmlWriter xwriter, KeyName keyName, String dsPrefix) { - xwriter.writeTextElement(dsPrefix, "KeyName", XMLSignature.XMLNS, keyName.getName()); - } - - /** - * Marshals a {@link PGPData} - * - * @param xwriter - * @param pgpData - * @param dsPrefix - * @param context - * @throws MarshalException - */ - public static void marshalPGPData(XmlWriter xwriter, PGPData pgpData, String dsPrefix, XMLCryptoContext context) - throws MarshalException { - xwriter.writeStartElement(dsPrefix, "PGPData", XMLSignature.XMLNS); - - // create and append PGPKeyID element - byte[] keyId = pgpData.getKeyId(); - if (keyId != null) { - xwriter.writeTextElement(dsPrefix, "PGPKeyID", XMLSignature.XMLNS, - Base64.getMimeEncoder().encodeToString(keyId)); - } - - // create and append PGPKeyPacket element - byte[] keyPacket = pgpData.getKeyPacket(); - if (keyPacket != null) { - xwriter.writeTextElement(dsPrefix, "XMLSignature.XMLNS", XMLSignature.XMLNS, - Base64.getMimeEncoder().encodeToString(keyPacket)); - } - - // create and append any elements - @SuppressWarnings("unchecked") - List externalElements = pgpData.getExternalElements(); - for (XMLStructure externalItem : externalElements) { - xwriter.marshalStructure(externalItem, dsPrefix, context); - } - - xwriter.writeEndElement(); // "PGPData" - } - - /** - * Marshals an {@link X509IssuerSerial} - * - * @param xwriter - * @param issuerSerial - * @param dsPrefix - */ - public static void marshalX509IssuerSerial(XmlWriter xwriter, X509IssuerSerial issuerSerial, String dsPrefix) { - xwriter.writeStartElement(dsPrefix, "X509IssuerSerial", XMLSignature.XMLNS); - xwriter.writeTextElement(dsPrefix, "X509IssuerName", XMLSignature.XMLNS, - issuerSerial.getIssuerName()); - - xwriter.writeTextElement(dsPrefix, "X509SerialNumber", XMLSignature.XMLNS, - issuerSerial.getSerialNumber().toString()); - - xwriter.writeEndElement(); // "X509IssuerSerial" - } - - private static XmlWriter.ToMarshal Marshal_KeyName = new XmlWriter.ToMarshal(KeyName.class) { - @Override - public void marshalObject(XmlWriter xwriter, KeyName toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - Marshaller.marshalKeyName(xwriter, toMarshal, dsPrefix); - } - }; - - private static XmlWriter.ToMarshal Marshal_KeyInfo = new XmlWriter.ToMarshal(KeyInfo.class) { - @Override - public void marshalObject(XmlWriter xwriter, KeyInfo toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - DOMKeyInfo.marshal(xwriter, toMarshal, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_KeyValue = new XmlWriter.ToMarshal(KeyValue.class) { - @Override - public void marshalObject(XmlWriter xwriter, KeyValue toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - // Since DOMKeyValue allows for deserializing unrecognized keys, and that - // capability isn't available via the KeyValue interface, this must continue - // to cast to DOMKeyValue. - DOMKeyValue dkv = (DOMKeyValue) toMarshal; - dkv.marshal( xwriter, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_X509IssuerSerial = - new XmlWriter.ToMarshal(X509IssuerSerial.class) { - @Override - public void marshalObject(XmlWriter xwriter, X509IssuerSerial toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - Marshaller.marshalX509IssuerSerial( xwriter, toMarshal, dsPrefix); - } - }; - - private static XmlWriter.ToMarshal Marshal_X509Data = - new XmlWriter.ToMarshal(X509Data.class) { - @Override - public void marshalObject(XmlWriter xwriter, X509Data toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - DOMX509Data.marshal( xwriter, toMarshal, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_DigestMethod = - new XmlWriter.ToMarshal(DigestMethod.class) { - @Override - public void marshalObject(XmlWriter xwriter, DigestMethod toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - DOMDigestMethod.marshal( xwriter, toMarshal, dsPrefix); - } - }; - - private static XmlWriter.ToMarshal Marshal_PGPData = - new XmlWriter.ToMarshal(PGPData.class) { - @Override - public void marshalObject(XmlWriter xwriter, PGPData toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - Marshaller.marshalPGPData( xwriter, toMarshal, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_SignatureProperty = - new XmlWriter.ToMarshal(SignatureProperty.class) { - @Override - public void marshalObject(XmlWriter xwriter, SignatureProperty toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - DOMSignatureProperty.marshal(xwriter, toMarshal, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_SignatureProperties = - new XmlWriter.ToMarshal(SignatureProperties.class) { - @Override - public void marshalObject(XmlWriter xwriter, SignatureProperties toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - DOMSignatureProperties.marshal(xwriter, toMarshal, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_DOMSignatureMethod = - new XmlWriter.ToMarshal(DOMSignatureMethod.class) { - @Override - public void marshalObject(XmlWriter xwriter, DOMSignatureMethod toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - toMarshal.marshal(xwriter, dsPrefix); - } - }; - - private static XmlWriter.ToMarshal Marshal_DOMTransform = - new XmlWriter.ToMarshal(DOMTransform.class) { - @Override - public void marshalObject(XmlWriter xwriter, DOMTransform toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - toMarshal.marshal(xwriter, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_Manifest = - new XmlWriter.ToMarshal(Manifest.class) { - @Override - public void marshalObject(XmlWriter xwriter, Manifest toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - DOMManifest.marshal(xwriter, toMarshal, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_DOMStructure = - new XmlWriter.ToMarshal(DOMStructure.class) { - @Override - public void marshalObject(XmlWriter xwriter, DOMStructure toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - toMarshal.marshal(xwriter, dsPrefix, context); - } - }; - - private static XmlWriter.ToMarshal Marshal_JavaXDOMStructure = - new XmlWriter.ToMarshal(javax.xml.crypto.dom.DOMStructure.class) { - @Override - public void marshalObject(XmlWriter xwriter, javax.xml.crypto.dom.DOMStructure toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException { - marshalGenericNode(xwriter, toMarshal); - } - }; - - private static final List> MARSHALLERS = - new ArrayList>(); - - static { - MARSHALLERS.add(Marshal_KeyName); - MARSHALLERS.add(Marshal_KeyInfo); - MARSHALLERS.add(Marshal_KeyValue); - MARSHALLERS.add(Marshal_X509IssuerSerial); - MARSHALLERS.add(Marshal_X509Data); - MARSHALLERS.add(Marshal_DigestMethod); - MARSHALLERS.add(Marshal_PGPData); - MARSHALLERS.add(Marshal_SignatureProperty); - MARSHALLERS.add(Marshal_SignatureProperties); - MARSHALLERS.add(Marshal_DOMSignatureMethod); - MARSHALLERS.add(Marshal_DOMTransform); - MARSHALLERS.add(Marshal_Manifest); - MARSHALLERS.add(Marshal_DOMStructure); - MARSHALLERS.add(Marshal_JavaXDOMStructure); - } - - private static void marshalGenericNode(XmlWriter xwriter, javax.xml.crypto.dom.DOMStructure xmlStruct) { - Node node = xmlStruct.getNode(); - - // if it is a namespace, make a copy. - if (DOMUtils.isNamespace(node)) { - xwriter.writeNamespace(node.getLocalName(), node.getTextContent()); - } - else if (Node.ATTRIBUTE_NODE == node.getNodeType() ) { - sendAttributeToWriter(xwriter, (Attr) node); - } - else { - marshalGenericNode(xwriter, node); - } - } - - private static void marshalGenericNode(XmlWriter xwriter, Node node) { - - short nodeType = node.getNodeType(); - if (DOMUtils.isNamespace(node)) { - xwriter.writeNamespace(node.getLocalName(), node.getTextContent()); - } - else if (nodeType == Node.ATTRIBUTE_NODE) { - // if it is an attribute, make a copy. - sendAttributeToWriter(xwriter, (Attr) node); - } - else { - switch (nodeType) { - case Node.ELEMENT_NODE: - xwriter.writeStartElement(node.getPrefix(), node.getLocalName(), node.getNamespaceURI()); - - // emit all the namespaces and attributes. - NamedNodeMap nnm = node.getAttributes(); - for (int idx = 0 ; idx < nnm.getLength() ; idx++) { - Attr attr = (Attr) nnm.item(idx); - // is this a namespace node? - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(node.getNamespaceURI())) { - xwriter.writeNamespace(attr.getLocalName(), attr.getValue()); - } - else { - // nope - standard attribute. - sendAttributeToWriter(xwriter, attr); - } - } - // now loop through all the children. - for (Node child = node.getFirstChild() ; child != null ; child = child.getNextSibling()) { - marshalGenericNode(xwriter, child); - } - xwriter.writeEndElement(); - break; - case Node.COMMENT_NODE: - xwriter.writeComment(node.getTextContent()); - break; - case Node.TEXT_NODE: - xwriter.writeCharacters(node.getTextContent()); - break; - default: - // unhandled - don't care to deal with processing instructions. - break; - } - } - } - - private static void sendAttributeToWriter(XmlWriter xwriter, Attr attr) { - if (attr.isId()) { - xwriter.writeIdAttribute(attr.getPrefix(), attr.getNamespaceURI(), - attr.getLocalName(), attr.getTextContent()); - } - else { - if (attr.getNamespaceURI() == null && attr.getLocalName() == null) { - // Level 1 DOM attribute - xwriter.writeAttribute(null, null, attr.getName(), attr.getTextContent()); - } else { - xwriter.writeAttribute(attr.getPrefix(), attr.getNamespaceURI(), attr.getLocalName(), - attr.getTextContent()); - } - } - } - -} diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XmlWriter.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XmlWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jcp.xml.dsig.internal.dom; - -import javax.xml.crypto.MarshalException; -import javax.xml.crypto.XMLCryptoContext; -import javax.xml.crypto.XMLStructure; - -import org.w3c.dom.Attr; - -/** - * This interface is used to construct XML via a sequence of API calls. - * - *

    This is written to be similar to javax.xml.stream.XMLStreamWriter, but - * has slightly different requirements. Specifically, we need to be able to create - * an "ID" type attribute, and get the current node. - *

    - */ -public interface XmlWriter { - - /** - * Utility class that brings together the class, and the method for marshaling an - * instance of said class. - * - * @param - */ - abstract static class ToMarshal { //NOPMD - public final Class clazzToMatch; - - public ToMarshal(Class clazzToMatch) { - this.clazzToMatch = clazzToMatch; - } - - public abstract void marshalObject(XmlWriter xwriter, CLZ toMarshal, String dsPrefix, - XMLCryptoContext context) throws MarshalException; - } - - /** - * - * @param prefix What prefix to use? - * @param localName What local name to use? - * @param namespaceURI What namespace URI? - * - * See also {@link javax.xml.stream.XMLStreamWriter#writeStartElement(String, String, String)} - */ - void writeStartElement(String prefix, String localName, String namespaceURI); - - /** - * See also {@link javax.xml.stream.XMLStreamWriter#writeEndElement()} - */ - void writeEndElement(); - - /** - * Convenience method that writes both a start and end tag, with text contents as - * provided. - * - * @param prefix - * @param localName - * @param namespaceURI - * @param value - */ - void writeTextElement(String prefix, String localName, String namespaceURI, String value); - - void writeNamespace(String prefix, String namespaceURI); - - void writeCharacters(String text); - - void writeComment(String text); - - Attr writeAttribute(String prefix, String namespaceURI, String localName, String value); - - void writeIdAttribute(String prefix, String namespaceURI, String localName, String value); - - /** - * Get the local name of the current element. - * @return the local name of the current element. - */ - String getCurrentLocalName(); - - XMLStructure getCurrentNodeAsStructure(); - - /** - * This method marshals a structure, and relies on implementation specific details for how - * an instance of a particular class maps to the method that actually does the marshaling. - * - * @param toMarshal The object to be marshaled. - * @param dsPrefix The digital signature prefix. - * @param context The context for marshaling. - * @throws MarshalException Thrown if something goes wrong during the marshaling. - */ - void marshalStructure(XMLStructure toMarshal, String dsPrefix, XMLCryptoContext context) throws MarshalException; -} diff -r 3e39753ed05b -r b38f280d2114 src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XmlWriterToTree.java --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XmlWriterToTree.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,208 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jcp.xml.dsig.internal.dom; - -import java.util.List; - -import javax.xml.XMLConstants; -import javax.xml.crypto.MarshalException; -import javax.xml.crypto.XMLCryptoContext; -import javax.xml.crypto.XMLStructure; -import javax.xml.crypto.dom.DOMStructure; - -import org.w3c.dom.Attr; -import org.w3c.dom.Comment; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.Text; - -/** - * Manifestation of XmlWriter interface designed to write to a tree. - */ -public class XmlWriterToTree implements XmlWriter { - - private Document factory; - - private Element createdElement; - - private Node nextSibling; - - private Node currentNode; - - private List> m_marshallers; - - public XmlWriterToTree(List> marshallers, Node parent) { - m_marshallers = marshallers; - factory = parent instanceof Document ? (Document)parent : parent.getOwnerDocument(); - currentNode = parent; - } - - /** - * Reset to a new parent so that the writer can be re-used. - * @param newParent - */ - public void resetToNewParent(Node newParent) { - currentNode = newParent; - createdElement = null; - } - - /** - * Get the root element created with this writer. - * @return the root element created with this writer. - */ - public Element getCreatedElement() { - return createdElement; - } - - /** - * In cases where the serialization is supposed to precede a specific - * element, we add an extra parameter to capture that. Only affects the - * first element insertion (obviously?). - * - * @param marshallers - * @param parent - * @param nextSibling The first element created will be created *before* this element. - */ - public XmlWriterToTree(List> marshallers, Node parent, Node nextSibling) { - this(marshallers, parent); - this.nextSibling = nextSibling; - } - - @Override - public void writeStartElement(String prefix, String localName, String namespaceURI) { - if ("".equals(namespaceURI)) { - // Map global namespace from StAX to DOM - namespaceURI = null; - } - - Element newElem = factory.createElementNS(namespaceURI, DOMUtils.getQNameString(prefix, localName)); - if (nextSibling != null) { - newElem = (Element)nextSibling.getParentNode().insertBefore(newElem, nextSibling); - } - else { - newElem = (Element)currentNode.appendChild(newElem); - } - nextSibling = null; - currentNode = newElem; - - if (createdElement == null) { - createdElement = newElem; - } - } - - @Override - public void writeEndElement() { - currentNode = currentNode.getParentNode(); - } - - - @Override - public void writeTextElement(String prefix, String localName, String namespaceURI, String value) { - writeStartElement(prefix, localName, namespaceURI); - writeCharacters(value); - writeEndElement(); - } - - @Override - public void writeNamespace(String prefix, String namespaceURI) { - if ("".equals(prefix) || prefix == null) { - writeAttribute(null, XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns", namespaceURI); - } - else { - writeAttribute("xmlns", XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix, namespaceURI); - } - } - - @Override - public void writeCharacters(String text) { - Text textNode = factory.createTextNode(text); - currentNode.appendChild(textNode); - } - - - @Override - public void writeComment(String text) { - Comment commentNode = factory.createComment(text); - currentNode.appendChild(commentNode); - } - - @Override - public Attr writeAttribute(String prefix, String namespaceURI, String localName, String value) { - - Attr result = null; - if (value != null) { - if ("".equals(namespaceURI)) { - // Map global namespace from StAX to DOM - namespaceURI = null; - } - - result = factory.createAttributeNS(namespaceURI, DOMUtils.getQNameString(prefix, localName)); - result.setTextContent(value); - if (! (currentNode instanceof Element)) { - throw new IllegalStateException( - "Attempting to add an attribute to something other than an element node. Node is " - + currentNode.toString()); - } - ( (Element)currentNode).setAttributeNodeNS(result); - } - return result; - } - - @Override - public void writeIdAttribute(String prefix, String namespaceURI, String localName, String value) { - if (value == null) { - return; - } - Attr newAttr = writeAttribute(prefix, namespaceURI, localName, value); - ( (Element)currentNode).setIdAttributeNode(newAttr, true); - } - - - @Override - public String getCurrentLocalName() { - return currentNode.getLocalName(); - } - - @Override - public XMLStructure getCurrentNodeAsStructure() { - return new DOMStructure(currentNode); - } - - @Override - public void marshalStructure(XMLStructure toMarshal, String dsPrefix, XMLCryptoContext context) throws MarshalException { - - // look for the first isInstance match, and marshal to that. - for (int idx = 0 ; idx < m_marshallers.size() ; idx++) { - @SuppressWarnings("unchecked") - XmlWriter.ToMarshal marshaller = (ToMarshal) m_marshallers.get(idx); - if (marshaller.clazzToMatch.isInstance(toMarshal)) { - marshaller.marshalObject(this, toMarshal, dsPrefix, context); - return; - } - } - throw new IllegalArgumentException("Unable to marshal unexpected object of class " + toMarshal.getClass().toString()); - } - - -} diff -r 3e39753ed05b -r b38f280d2114 src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, 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 @@ -504,12 +504,8 @@ module.completer = sym -> completeModule((ModuleSymbol) sym); } else { Assert.check(rootModules.isEmpty()); - String moduleOverride = singleModuleOverride(trees); - if (moduleOverride != null) { - module = moduleFinder.findModule(names.fromString(moduleOverride)); - } else { - module = defaultModule; - } + Assert.checkNonNull(c); + module = c.packge().modle; rootModules.add(module); } @@ -1796,6 +1792,7 @@ public void newRound() { allModules = null; rootModules = null; + defaultModule = null; warnedMissing.clear(); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Sat Mar 09 12:54:20 2019 +0000 @@ -1174,7 +1174,7 @@ protected void read(Symbol sym, int attrLen) { ClassSymbol c = (ClassSymbol) sym; Name n = readName(nextChar()); - c.sourcefile = new SourceFileObject(n, c.flatname); + c.sourcefile = new SourceFileObject(n); // If the class is a toplevel class, originating from a Java source file, // but the class name does not match the file name, then it is // an auxiliary class. @@ -2950,11 +2950,9 @@ /** The file's name. */ private final Name name; - private final Name flatname; - public SourceFileObject(Name name, Name flatname) { + public SourceFileObject(Name name) { this.name = name; - this.flatname = flatname; } @Override @DefinedBy(Api.COMPILER) diff -r 3e39753ed05b -r b38f280d2114 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,6 +1,6 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, Red Hat Inc. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -223,7 +223,13 @@ } } - setValues(sp, fp, null); + // We found a PC in the frame anchor. Check that it's plausible, and + // if it is, use it. + if (vm.isJavaPCDbg(pc)) { + setValues(sp, fp, pc); + } else { + setValues(sp, fp, null); + } return true; } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,6 +1,6 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, Red Hat Inc. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -136,7 +136,15 @@ this.raw_sp = raw_sp; this.raw_unextendedSP = raw_sp; this.raw_fp = raw_fp; - this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize()); + + // We cannot assume SP[-1] always contains a valid return PC (e.g. if + // the callee is a C/C++ compiled frame). If the PC is not known to + // Java then this.pc is null. + Address savedPC = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize()); + if (VM.getVM().isJavaPCDbg(savedPC)) { + this.pc = savedPC; + } + adjustUnextendedSP(); // Frame must be fully constructed before this call diff -r 3e39753ed05b -r b38f280d2114 src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java --- a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2018, 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 diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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,7 +30,6 @@ import java.util.zip.*; import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ModuleElement; import javax.lang.model.element.PackageElement; @@ -38,7 +37,6 @@ import javax.lang.model.util.SimpleElementVisitor9; import com.sun.source.doctree.DocTree; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -170,7 +168,7 @@ String unicode = uc.toString(); contentTree.addContent(getMarkerAnchorForIndex(unicode)); Content headContent = new StringContent(unicode); - Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false, + Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, false, HtmlStyle.title, headContent); contentTree.addContent(heading); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -40,12 +40,10 @@ import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.Links; -import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter; import jdk.javadoc.internal.doclets.toolkit.Resources; @@ -376,18 +374,6 @@ } /** - * Get the header for the section. - * - * @param member the member being documented. - * @return a header content for the section. - */ - protected Content getHead(Element member) { - Content memberContent = new StringContent(name(member)); - Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent); - return heading; - } - - /** * Return true if the given ProgramElement is inherited * by the class that is being documented. * diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -33,7 +33,6 @@ import javax.lang.model.element.ModuleElement; import javax.lang.model.element.PackageElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -222,7 +221,7 @@ * @param modules the modules to be documented * @param text string which will be used as the heading * @param tableSummary summary for the table - * @param header the document tree to which the navgational links will be added + * @param header the document tree to which the navigational links will be added * @param main the document tree to which the modules list will be added */ protected void addIndexContents(Collection modules, String text, @@ -268,7 +267,7 @@ protected void addConfigurationTitle(Content body) { if (configuration.doctitle.length() > 0) { Content title = new RawHtml(configuration.doctitle); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.title, title); Content div = HtmlTree.DIV(HtmlStyle.header, heading); body.addContent(div); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,7 +29,6 @@ import javax.lang.model.element.PackageElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -180,7 +179,7 @@ protected void addConfigurationTitle(Content body) { if (configuration.doctitle.length() > 0) { Content title = new RawHtml(configuration.doctitle); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.title, title); Content div = HtmlTree.DIV(HtmlStyle.header, heading); body.addContent(div); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -29,7 +29,6 @@ import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -117,7 +116,7 @@ if (!sset.isEmpty()) { TypeElement firstTypeElement = sset.first(); Content headingContent = contents.getContent(heading); - Content sectionHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, + Content sectionHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true, headingContent); HtmlTree htmlTree = HtmlTree.SECTION(sectionHeading); addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null, diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,7 +29,6 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -112,7 +111,7 @@ String label = resources.getText("doclet.All_Classes"); Content body = getBody(false, getWindowTitle(label)); Content htmlTree = HtmlTree.MAIN(); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.bar, contents.allClassesLabel); htmlTree.addContent(heading); Content ul = new HtmlTree(HtmlTag.UL); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -32,7 +32,6 @@ import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -148,7 +147,7 @@ } } Content titleContent = contents.allClassesLabel; - Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, titleContent); Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading); content.addContent(headerDiv); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -27,7 +27,6 @@ import javax.lang.model.element.PackageElement; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -94,7 +93,7 @@ div.setStyle(HtmlStyle.allPackagesContainer); addPackages(div); Content titleContent = contents.allPackagesLabel; - Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, titleContent); Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading); mainTree.addContent(headerDiv); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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,7 +33,6 @@ import javax.lang.model.type.TypeMirror; import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -72,7 +71,7 @@ public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { memberSummaryTree.addContent( - HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY); + MarkerComments.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -96,7 +95,7 @@ * {@inheritDoc} */ public void addAnnotationFieldDetailsMarker(Content memberDetails) { - memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS); + memberDetails.addContent(MarkerComments.START_OF_ANNOTATION_TYPE_FIELD_DETAILS); } /** @@ -107,7 +106,7 @@ if (!writer.printedAnnotationFieldHeading) { memberDetailsTree.addContent(links.createAnchor( SectionName.ANNOTATION_TYPE_FIELD_DETAIL)); - Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, contents.fieldDetailsLabel); memberDetailsTree.addContent(heading); writer.printedAnnotationFieldHeading = true; @@ -121,7 +120,7 @@ Content annotationDetailsTree) { annotationDetailsTree.addContent(links.createAnchor(name(member))); Content annotationDocTree = writer.getMemberTreeHeader(); - Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING); heading.addContent(name(member)); annotationDocTree.addContent(heading); return annotationDocTree; @@ -188,7 +187,7 @@ * {@inheritDoc} */ public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.fieldSummaryLabel); memberTree.addContent(label); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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,9 +33,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.Navigation; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter; import jdk.javadoc.internal.doclets.toolkit.Content; @@ -75,7 +73,7 @@ public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { memberSummaryTree.addContent( - HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY); + MarkerComments.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -112,7 +110,7 @@ */ @Override public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.annotateTypeOptionalMemberSummaryLabel); memberTree.addContent(label); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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,11 +33,9 @@ import javax.lang.model.type.TypeMirror; import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.Navigation; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter; import jdk.javadoc.internal.doclets.toolkit.Content; @@ -75,7 +73,7 @@ public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { memberSummaryTree.addContent( - HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY); + MarkerComments.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -99,7 +97,7 @@ * {@inheritDoc} */ public void addAnnotationDetailsMarker(Content memberDetails) { - memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS); + memberDetails.addContent(MarkerComments.START_OF_ANNOTATION_TYPE_DETAILS); } /** @@ -110,7 +108,7 @@ if (!writer.printedAnnotationHeading) { memberDetailsTree.addContent(links.createAnchor( SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL)); - Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, contents.annotationTypeDetailsLabel); memberDetailsTree.addContent(heading); writer.printedAnnotationHeading = true; @@ -126,7 +124,7 @@ annotationDetailsTree.addContent(links.createAnchor( simpleName + utils.signature((ExecutableElement) member))); Content annotationDocTree = writer.getMemberTreeHeader(); - Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING); heading.addContent(simpleName); annotationDocTree.addContent(heading); return annotationDocTree; @@ -193,7 +191,7 @@ * {@inheritDoc} */ public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.annotateTypeRequiredMemberSummaryLabel); memberTree.addContent(label); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -32,7 +32,6 @@ import javax.lang.model.element.TypeElement; import com.sun.source.doctree.DocTree; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -95,7 +94,7 @@ navBar.setUserHeader(getUserHeaderFooter(true)); htmlTree.addContent(navBar.getContent(true)); bodyTree.addContent(htmlTree); - bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); + bodyTree.addContent(MarkerComments.START_OF_CLASS_DATA); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.header); if (configuration.showModules) { @@ -118,7 +117,7 @@ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_HEADER, annotationType); Content headerContent = new StringContent(header); - Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, headerContent); heading.addContent(getTypeParameterLinks(linkInfo)); div.addContent(heading); @@ -139,7 +138,7 @@ */ @Override public void addFooter(Content contentTree) { - contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA); + contentTree.addContent(MarkerComments.END_OF_CLASS_DATA); Content htmlTree = HtmlTree.FOOTER(); navBar.setUserFooter(getUserHeaderFooter(false)); htmlTree.addContent(navBar.getContent(false)); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -42,7 +42,6 @@ import javax.tools.Diagnostic; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -325,7 +324,7 @@ getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)), getPackageLink(pkg, utils.getPackageName(pkg))); - Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); + Content heading = HtmlTree.HEADING(Headings.TypeUse.SUMMARY_HEADING, link); htmlTree.addContent(heading); addClassUse(pkg, htmlTree); ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); @@ -452,7 +451,7 @@ headContent.addContent(contents.getContent("doclet.ClassUse_Title", cltype)); headContent.addContent(new HtmlTree(HtmlTag.BR)); headContent.addContent(clname); - Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); mainTree.addContent(div); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -36,7 +36,6 @@ import javax.lang.model.util.SimpleElementVisitor8; import com.sun.source.doctree.DocTree; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -116,7 +115,7 @@ navBar.setUserHeader(getUserHeaderFooter(true)); htmlTree.addContent(navBar.getContent(true)); bodyTree.addContent(htmlTree); - bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); + bodyTree.addContent(MarkerComments.START_OF_CLASS_DATA); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.header); if (configuration.showModules) { @@ -143,7 +142,7 @@ //Let's not link to ourselves in the header. linkInfo.linkToSelf = false; Content headerContent = new StringContent(header); - Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, headerContent); heading.addContent(getTypeParameterLinks(linkInfo)); div.addContent(heading); @@ -164,7 +163,7 @@ */ @Override public void addFooter(Content contentTree) { - contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA); + contentTree.addContent(MarkerComments.END_OF_CLASS_DATA); Content htmlTree = HtmlTree.FOOTER(); navBar.setUserFooter(getUserHeaderFooter(false)); htmlTree.addContent(navBar.getContent(false)); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -36,7 +36,6 @@ import javax.lang.model.element.VariableElement; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -152,11 +151,11 @@ @Override public void addContentsList(Content contentTree, Content contentListTree) { Content titleContent = contents.constantsSummaryTitle; - Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content pHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, titleContent); Content div = HtmlTree.DIV(HtmlStyle.header, pHeading); Content headingContent = contents.contentsHeading; - Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true, headingContent); HtmlTree section = HtmlTree.SECTION(heading); section.addContent(contentListTree); @@ -192,7 +191,7 @@ pkgNameContent = getPackageLabel(parsedPackageName); } Content headingContent = new StringContent(".*"); - Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.ConstantsSummary.PACKAGE_HEADING, true, pkgNameContent); heading.addContent(headingContent); summaryTree = HtmlTree.SECTION(heading); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -34,7 +34,6 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -98,7 +97,7 @@ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY); + memberSummaryTree.addContent(MarkerComments.START_OF_CONSTRUCTOR_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -118,11 +117,11 @@ @Override public Content getConstructorDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS); + memberDetailsTree.addContent(MarkerComments.START_OF_CONSTRUCTOR_DETAILS); Content constructorDetailsTree = writer.getMemberTreeHeader(); constructorDetailsTree.addContent(links.createAnchor( SectionName.CONSTRUCTOR_DETAIL)); - Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, contents.constructorDetailsLabel); constructorDetailsTree.addContent(heading); return constructorDetailsTree; @@ -140,7 +139,7 @@ } constructorDetailsTree.addContent(links.createAnchor(writer.getAnchor(constructor))); Content constructorDocTree = writer.getMemberTreeHeader(); - Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING); heading.addContent(name(constructor)); constructorDocTree.addContent(heading); return constructorDocTree; @@ -223,7 +222,7 @@ */ @Override public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.constructorSummaryLabel); memberTree.addContent(label); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -38,7 +38,6 @@ import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -336,11 +335,11 @@ */ public Content getContentsList(DeprecatedAPIListBuilder deprapi) { Content headContent = contents.deprecatedAPI; - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content headingContent = contents.contentsHeading; - div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, + div.addContent(HtmlTree.HEADING(Headings.CONTENT_HEADING, true, headingContent)); Content ul = new HtmlTree(HtmlTag.UL); for (DeprElementKind kind : DeprElementKind.values()) { diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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,11 +33,9 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.Navigation; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter; @@ -71,7 +69,7 @@ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY); + memberSummaryTree.addContent(MarkerComments.START_OF_ENUM_CONSTANT_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -91,11 +89,11 @@ @Override public Content getEnumConstantsDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS); + memberDetailsTree.addContent(MarkerComments.START_OF_ENUM_CONSTANT_DETAILS); Content enumConstantsDetailsTree = writer.getMemberTreeHeader(); enumConstantsDetailsTree.addContent(links.createAnchor( SectionName.ENUM_CONSTANT_DETAIL)); - Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, contents.enumConstantDetailLabel); enumConstantsDetailsTree.addContent(heading); return enumConstantsDetailsTree; @@ -109,7 +107,7 @@ Content enumConstantsDetailsTree) { enumConstantsDetailsTree.addContent(links.createAnchor(name(enumConstant))); Content enumConstantsTree = writer.getMemberTreeHeader(); - Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING); heading.addContent(name(enumConstant)); enumConstantsTree.addContent(heading); return enumConstantsTree; @@ -182,7 +180,7 @@ */ @Override public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.enumConstantSummary); memberTree.addContent(label); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,11 +35,9 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.Navigation; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.FieldWriter; @@ -75,7 +73,7 @@ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY); + memberSummaryTree.addContent(MarkerComments.START_OF_FIELD_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -94,11 +92,11 @@ */ @Override public Content getFieldDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS); + memberDetailsTree.addContent(MarkerComments.START_OF_FIELD_DETAILS); Content fieldDetailsTree = writer.getMemberTreeHeader(); fieldDetailsTree.addContent(links.createAnchor( SectionName.FIELD_DETAIL)); - Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, contents.fieldDetailsLabel); fieldDetailsTree.addContent(heading); return fieldDetailsTree; @@ -111,7 +109,7 @@ public Content getFieldDocTreeHeader(VariableElement field, Content fieldDetailsTree) { fieldDetailsTree.addContent(links.createAnchor(name(field))); Content fieldTree = writer.getMemberTreeHeader(); - Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING); heading.addContent(name(field)); fieldTree.addContent(heading); return fieldTree; @@ -186,7 +184,7 @@ */ @Override public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.fieldSummaryLabel); memberTree.addContent(label); } @@ -247,7 +245,7 @@ ? resources.getText("doclet.Fields_Inherited_From_Class") : resources.getText("doclet.Fields_Inherited_From_Interface")); } - Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, + Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.INHERITED_SUMMARY_HEADING, label); labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -96,6 +96,7 @@ protected void generateFrameFile() throws DocFileIOException { Content frame = getFrameDetails(); HtmlTree body = new HtmlTree(HtmlTag.BODY); + body.addAttr(HtmlAttr.CLASS, "frames"); body.addAttr(HtmlAttr.ONLOAD, "loadFrames()"); String topFilePath = configuration.topFile.getPath(); Script script = new Script( diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Headings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Headings.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 1998, 2019, 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.javadoc.internal.doclets.formats.html; + +import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; + +/** + * Aliases for HTML heading tags (H1..H6) for different kinds of pages. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +class Headings { + /** + * Standard top-level heading for the page title for all pages. + */ + static final HtmlTag PAGE_TITLE_HEADING = HtmlTag.H1; + + /** + * Standard second-level heading for sundry pages that do + * not have their own page group. + */ + static final HtmlTag CONTENT_HEADING = HtmlTag.H2; + + /** + * Headings for the page for a module declaration. + */ + static class ModuleDeclaration { + static final HtmlTag SUMMARY_HEADING = HtmlTag.H2; + } + + /** + * Headings for the page for a type declaration. + * This includes classes, interfaces, enums and annotation types. + */ + static class TypeDeclaration { + /** + * Heading for the different summary lists: + * Field Summary, Constructor Summary, Method Summary, etc. + */ + static final HtmlTag SUMMARY_HEADING = HtmlTag.H2; + + /** + * Subheading within a summary for the inherited elements: + * inherited methods, etc + */ + static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3; + + /** + * Heading for the different detail lists: + * Field Details, Constructor Details, Method Details, etc. + */ + static final HtmlTag DETAILS_HEADING = HtmlTag.H2; + + /** + * Subheading with a Details list for an individual element. + */ + static final HtmlTag MEMBER_HEADING = HtmlTag.H3; + } + + /** + * Headings for the Constants Summary page. + */ + static class ConstantsSummary { + static final HtmlTag PACKAGE_HEADING = HtmlTag.H2; + } + + /** + * Headings for the Serialized Form page. + */ + static class SerializedForm { + /** + * Heading for the package name, preceding a list of types. + */ + static final HtmlTag PACKAGE_HEADING = HtmlTag.H2; + + /** + * Heading for a type name within a package. + */ + static final HtmlTag CLASS_HEADING = HtmlTag.H3; + + /** + * Subheading for info within a type. + */ + static final HtmlTag CLASS_SUBHEADING = HtmlTag.H4; + + /** + * Heading for an individual member element within a type. + */ + static final HtmlTag MEMBER_HEADING = HtmlTag.H5; + } + + /** + * Headings for a type Use page. + */ + static class TypeUse { + static final HtmlTag SUMMARY_HEADING = HtmlTag.H2; + } + + /** + * Headings for index frames pages. + */ + static class IndexFrames { + /** Heading for a list of module names in an index frame. */ + static final HtmlTag MODULE_HEADING = HtmlTag.H2; + /** Heading for a list of package names in an index frame. */ + static final HtmlTag PACKAGE_HEADING = HtmlTag.H2; + } +} diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -113,7 +112,7 @@ */ protected void addHelpFileContents(Content contentTree) { // Heading - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false, HtmlStyle.title, contents.getContent("doclet.help.main_heading")); Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content intro = HtmlTree.DIV(HtmlStyle.subTitle, @@ -126,7 +125,7 @@ // Overview if (configuration.createoverview) { - Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content overviewHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.overviewLabel); htmlTree = HtmlTree.SECTION(overviewHeading); String overviewKey = configuration.showModules @@ -143,7 +142,7 @@ // Module if (configuration.showModules) { - Content moduleHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content moduleHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.moduleLabel); htmlTree = HtmlTree.SECTION(moduleHead); Content moduleIntro = contents.getContent("doclet.help.module.intro"); @@ -158,7 +157,7 @@ } // Package - Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content packageHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.packageLabel); htmlTree = HtmlTree.SECTION(packageHead); Content packageIntro = contents.getContent("doclet.help.package.intro"); @@ -175,7 +174,7 @@ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); // Class/interface - Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content classHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.class_interface.head")); htmlTree = HtmlTree.SECTION(classHead); Content classIntro = contents.getContent("doclet.help.class_interface.intro"); @@ -210,7 +209,7 @@ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); // Annotation Types - Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content aHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.annotationType); htmlTree = HtmlTree.SECTION(aHead); Content aIntro = contents.getContent("doclet.help.annotation_type.intro"); @@ -226,7 +225,7 @@ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); // Enums - Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, contents.enum_); + Content enumHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.enum_); htmlTree = HtmlTree.SECTION(enumHead); Content eIntro = contents.getContent("doclet.help.enum.intro"); Content enumPara = HtmlTree.P(eIntro); @@ -241,7 +240,7 @@ // Class Use if (configuration.classuse) { - Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content useHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.use.head")); htmlTree = HtmlTree.SECTION(useHead); Content useBody = contents.getContent("doclet.help.use.body"); @@ -252,7 +251,7 @@ // Tree if (configuration.createtree) { - Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content treeHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.tree.head")); htmlTree = HtmlTree.SECTION(treeHead); Content treeIntro = contents.getContent("doclet.help.tree.intro", @@ -270,7 +269,7 @@ // Deprecated if (!(configuration.nodeprecatedlist || configuration.nodeprecated)) { - Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content dHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.deprecatedAPI); htmlTree = HtmlTree.SECTION(dHead); Content deprBody = contents.getContent("doclet.help.deprecated.body", @@ -291,7 +290,7 @@ indexlink = links.createLink(DocPaths.INDEX_ALL, resources.getText("doclet.Index")); } - Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content indexHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.index.head")); htmlTree = HtmlTree.SECTION(indexHead); Content indexBody = contents.getContent("doclet.help.index.body", indexlink); @@ -302,7 +301,7 @@ // Frames if (configuration.frames) { - Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content frameHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.frames.head")); htmlTree = HtmlTree.SECTION(frameHead); Content framesBody = contents.getContent("doclet.help.frames.body"); @@ -313,7 +312,7 @@ } // Serialized Form - Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content sHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.serializedForm); htmlTree = HtmlTree.SECTION(sHead); Content serialBody = contents.getContent("doclet.help.serial_form.body"); @@ -322,7 +321,7 @@ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); // Constant Field Values - Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content constHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.constantsSummaryTitle); htmlTree = HtmlTree.SECTION(constHead); Content constantsBody = contents.getContent("doclet.help.constants.body", @@ -333,7 +332,7 @@ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); // Search - Content searchHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content searchHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.search.head")); htmlTree = HtmlTree.SECTION(searchHead); Content searchBody = contents.getContent("doclet.help.search.body"); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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,11 +41,9 @@ import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.DocletEnvironment; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; -import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Resources; @@ -83,6 +81,11 @@ public class HtmlConfiguration extends BaseConfiguration { /** + * Default charset for HTML. + */ + public static final String HTML_DEFAULT_CHARSET = "utf-8"; + + /** * Argument for command line option "-header". */ public String header = ""; @@ -762,7 +765,7 @@ protected boolean finishOptionSettings0() throws DocletException { if (docencoding == null) { if (charset == null) { - docencoding = charset = (encoding == null) ? HtmlConstants.HTML_DEFAULT_CHARSET : encoding; + docencoding = charset = (encoding == null) ? HTML_DEFAULT_CHARSET : encoding; } else { docencoding = charset; } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -26,6 +26,7 @@ package jdk.javadoc.internal.doclets.formats.html; import jdk.javadoc.internal.doclets.formats.html.markup.Head; +import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader; import java.util.*; @@ -2197,6 +2198,8 @@ */ public HtmlTree getBody(boolean includeScript, String title) { HtmlTree body = new HtmlTree(HtmlTag.BODY); + body.addAttr(HtmlAttr.CLASS, getBodyClass()); + // Set window title string which is later printed this.winTitle = title; // Don't print windowtitle script for overview-frame, allclasses-frame @@ -2210,6 +2213,15 @@ return body; } + public String getBodyClass() { + return getClass().getSimpleName() + .replaceAll("(Writer)?(Impl)?$", "") + .replaceAll("AnnotationType", "Class") + .replaceAll("(.)([A-Z])", "$1-$2") + .replaceAll("(?i)^(module|package|class)$", "$1-declaration") + .toLowerCase(Locale.US); + } + Script getMainBodyScript() { return mainBodyScript; } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -34,7 +34,6 @@ import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -108,8 +107,7 @@ li.setStyle(HtmlStyle.blockList); if (serializableFieldsTree.isValid()) { Content headingContent = new StringContent(heading); - Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, - headingContent); + Content serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent); li.addContent(serialHeading); li.addContent(serializableFieldsTree); } @@ -120,7 +118,7 @@ public void addMemberHeader(TypeElement fieldType, String fieldTypeStr, String fieldDimensions, String fieldName, Content contentTree) { Content nameContent = new StringContent(fieldName); - Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent); + Content heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent); contentTree.addContent(heading); Content pre = new HtmlTree(HtmlTag.PRE); if (fieldType == null) { @@ -138,7 +136,7 @@ @Override public void addMemberHeader(TypeMirror fieldType, String fieldName, Content contentTree) { Content nameContent = new StringContent(fieldName); - Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent); + Content heading = HtmlTree.HEADING(HtmlTag.H5, nameContent); contentTree.addContent(heading); Content pre = new HtmlTree(HtmlTag.PRE); Content fieldContent = writer.getLink(new LinkInfoImpl( diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -29,7 +29,6 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -95,8 +94,7 @@ */ public Content getSerializableMethods(String heading, Content serializableMethodContent) { Content headingContent = new StringContent(heading); - Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, - headingContent); + Content serialHeading = HtmlTree.HEADING(Headings.SerializedForm.CLASS_SUBHEADING, headingContent); Content li = HtmlTree.LI(HtmlStyle.blockList, serialHeading); li.addContent(serializableMethodContent); return li; @@ -120,7 +118,9 @@ * @param methodsContentTree the content tree to which the member header will be added */ public void addMemberHeader(ExecutableElement member, Content methodsContentTree) { - methodsContentTree.addContent(getHead(member)); + Content memberContent = new StringContent(name(member)); + Content heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, memberContent); + methodsContentTree.addContent(heading); methodsContentTree.addContent(getSignature(member)); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -107,7 +107,8 @@ bodyContent.addContent(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath)))); - Content body = new HtmlTree(HtmlTag.BODY); + Content body = new HtmlTree(HtmlTag.BODY) + .addAttr(HtmlAttr.CLASS, "index-redirect"); HtmlTree main = HtmlTree.MAIN(bodyContent); body.addContent(main); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MarkerComments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MarkerComments.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2010, 2019, 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.javadoc.internal.doclets.formats.html; + +import jdk.javadoc.internal.doclets.formats.html.markup.Comment; + +/** + * Marker comments to identify regions in the generated files. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + * + * @author Bhavesh Patel + */ +public class MarkerComments { + + /** + * Marker to identify start of top navigation bar. + */ + public static final Comment START_OF_TOP_NAVBAR = + new Comment("========= START OF TOP NAVBAR ======="); + + /** + * Marker to identify start of bottom navigation bar. + */ + public static final Comment START_OF_BOTTOM_NAVBAR = + new Comment("======= START OF BOTTOM NAVBAR ======"); + + /** + * Marker to identify end of top navigation bar. + */ + public static final Comment END_OF_TOP_NAVBAR = + new Comment("========= END OF TOP NAVBAR ========="); + + /** + * Marker to identify end of bottom navigation bar. + */ + public static final Comment END_OF_BOTTOM_NAVBAR = + new Comment("======== END OF BOTTOM NAVBAR ======="); + + /** + * Marker to identify start of module description. + */ + public static final Comment START_OF_MODULE_DESCRIPTION = + new Comment("============ MODULE DESCRIPTION ==========="); + + /** + * Marker to identify start of modules summary. + */ + public static final Comment START_OF_MODULES_SUMMARY = + new Comment("============ MODULES SUMMARY ==========="); + + /** + * Marker to identify start of packages summary. + */ + public static final Comment START_OF_PACKAGES_SUMMARY = + new Comment("============ PACKAGES SUMMARY ==========="); + + /** + * Marker to identify start of services summary. + */ + public static final Comment START_OF_SERVICES_SUMMARY = + new Comment("============ SERVICES SUMMARY ==========="); + + /** + * Marker to identify start of class data. + */ + public static final Comment START_OF_CLASS_DATA = + new Comment("======== START OF CLASS DATA ========"); + + /** + * Marker to identify end of class data. + */ + public static final Comment END_OF_CLASS_DATA = + new Comment("========= END OF CLASS DATA ========="); + + /** + * Marker to identify start of nested class summary. + */ + public static final Comment START_OF_NESTED_CLASS_SUMMARY = + new Comment("======== NESTED CLASS SUMMARY ========"); + + /** + * Marker to identify start of annotation type optional member summary. + */ + public static final Comment START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY = + new Comment("=========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ==========="); + + /** + * Marker to identify start of annotation type required member summary. + */ + public static final Comment START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY = + new Comment("=========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ==========="); + + /** + * Marker to identify start of annotation type required member summary. + */ + public static final Comment START_OF_ANNOTATION_TYPE_FIELD_SUMMARY = + new Comment("=========== ANNOTATION TYPE FIELD SUMMARY ==========="); + + /** + * Marker to identify start of constructor summary. + */ + public static final Comment START_OF_CONSTRUCTOR_SUMMARY = + new Comment("======== CONSTRUCTOR SUMMARY ========"); + + /** + * Marker to identify start of enum constants summary. + */ + public static final Comment START_OF_ENUM_CONSTANT_SUMMARY = + new Comment("=========== ENUM CONSTANT SUMMARY ==========="); + + /** + * Marker to identify start of field summary. + */ + public static final Comment START_OF_FIELD_SUMMARY = + new Comment("=========== FIELD SUMMARY ==========="); + + /** + * Marker to identify start of properties summary. + */ + public static final Comment START_OF_PROPERTY_SUMMARY = + new Comment("=========== PROPERTY SUMMARY ==========="); + + /** + * Marker to identify start of method summary. + */ + public static final Comment START_OF_METHOD_SUMMARY = + new Comment("========== METHOD SUMMARY ==========="); + + /** + * Marker to identify start of annotation type details. + */ + public static final Comment START_OF_ANNOTATION_TYPE_DETAILS = + new Comment("============ ANNOTATION TYPE MEMBER DETAIL ==========="); + + /** + * Marker to identify start of annotation type field details. + */ + public static final Comment START_OF_ANNOTATION_TYPE_FIELD_DETAILS = + new Comment("============ ANNOTATION TYPE FIELD DETAIL ==========="); + + /** + * Marker to identify start of method details. + */ + public static final Comment START_OF_METHOD_DETAILS = + new Comment("============ METHOD DETAIL =========="); + + /** + * Marker to identify start of field details. + */ + public static final Comment START_OF_FIELD_DETAILS = + new Comment("============ FIELD DETAIL ==========="); + + /** + * Marker to identify start of property details. + */ + public static final Comment START_OF_PROPERTY_DETAILS = + new Comment("============ PROPERTY DETAIL ==========="); + + /** + * Marker to identify start of constructor details. + */ + public static final Comment START_OF_CONSTRUCTOR_DETAILS = + new Comment("========= CONSTRUCTOR DETAIL ========"); + + /** + * Marker to identify start of enum constants details. + */ + public static final Comment START_OF_ENUM_CONSTANT_DETAILS = + new Comment("============ ENUM CONSTANT DETAIL ==========="); + +} diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -87,7 +86,7 @@ */ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY); + memberSummaryTree.addContent(MarkerComments.START_OF_METHOD_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -106,10 +105,10 @@ */ @Override public Content getMethodDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS); + memberDetailsTree.addContent(MarkerComments.START_OF_METHOD_DETAILS); Content methodDetailsTree = writer.getMemberTreeHeader(); methodDetailsTree.addContent(links.createAnchor(SectionName.METHOD_DETAIL)); - Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, contents.methodDetailLabel); methodDetailsTree.addContent(heading); return methodDetailsTree; @@ -126,7 +125,7 @@ } methodDetailsTree.addContent(links.createAnchor(writer.getAnchor(method))); Content methodDocTree = writer.getMemberTreeHeader(); - Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING); heading.addContent(name(method)); methodDocTree.addContent(heading); return methodDocTree; @@ -229,7 +228,7 @@ */ @Override public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.methodSummary); memberTree.addContent(label); } @@ -295,7 +294,7 @@ ? resources.getText("doclet.Methods_Inherited_From_Class") : resources.getText("doclet.Methods_Inherited_From_Interface")); } - Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, + Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.INHERITED_SUMMARY_HEADING, label); labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -32,7 +32,6 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.util.ElementFilter; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -101,7 +100,7 @@ DocPath moduleSummary = configuration.useModuleDirectories ? DocPaths.DOT_DOT.resolve(configuration.docPaths.moduleSummary(moduleElement)) : configuration.docPaths.moduleSummary(moduleElement); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.bar, mdlgen.links.createLink(moduleSummary, mdlLabel, "", "classFrame")); htmlTree.addContent(heading); HtmlTree div = new HtmlTree(HtmlTag.DIV); @@ -171,7 +170,7 @@ continue; } if (!printedHeader) { - Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true, labelContent); htmlTree.addContent(heading); printedHeader = true; diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -32,7 +32,6 @@ import javax.lang.model.element.PackageElement; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -57,6 +56,12 @@ * @author Bhavesh Patel */ public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { + /** + * The heading (h1 or h2) to use for the module list, + * set by addNavigationBarHeader depending on whether or not there + * is an additional initial heading. + */ + private HtmlTag moduleListHeading; /** * Construct the ModuleIndexFrameWriter object. @@ -83,8 +88,9 @@ /** * {@inheritDoc} */ + @Override protected void addModulesList(Content main) { - Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true, + Content heading = HtmlTree.HEADING(moduleListHeading, true, contents.modulesLabel); HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading); HtmlTree ul = new HtmlTree(HtmlTag.UL); @@ -125,15 +131,16 @@ * {@inheritDoc} */ protected void addNavigationBarHeader(Content header) { - Content headerContent; - if (configuration.packagesheader.length() > 0) { - headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); + String headerContent = !configuration.packagesheader.isEmpty() ? configuration.packagesheader + : configuration.header; + if (!headerContent.isEmpty()) { + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, + HtmlStyle.bar, new RawHtml(replaceDocRootDir(headerContent))); + header.addContent(heading); + moduleListHeading = Headings.IndexFrames.MODULE_HEADING; } else { - headerContent = new RawHtml(replaceDocRootDir(configuration.header)); + moduleListHeading = Headings.PAGE_TITLE_HEADING; } - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, - HtmlStyle.bar, headerContent); - header.addContent(heading); } /** diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -33,7 +33,6 @@ import javax.lang.model.element.ModuleElement; import javax.lang.model.element.PackageElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -57,6 +56,12 @@ * @author Bhavesh Patel */ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { + /** + * The heading (h1 or h2) to use for the module packages list, + * set by addNavigationBarHeader depending on whether or not there + * is an additional initial heading. + */ + private HtmlTag modulePackagesListHeading; /** * Construct the ModulePackageIndexFrameWriter object. @@ -89,7 +94,7 @@ protected void addModulePackagesList(Map> modules, String text, String tableSummary, Content main, ModuleElement mdle) { Content profNameContent = new StringContent(mdle.getQualifiedName().toString()); - Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, + Content heading = HtmlTree.HEADING(modulePackagesListHeading, true, getTargetModuleLink("classFrame", profNameContent, mdle)); heading.addContent(Contents.SPACE); heading.addContent(contents.packagesLabel); @@ -112,7 +117,7 @@ protected void addModulePackagesList(Set modules, String text, String tableSummary, Content body, ModuleElement mdle) { Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString()); - Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, + Content heading = HtmlTree.HEADING(modulePackagesListHeading, true, getTargetModuleLink("classFrame", moduleNameContent, mdle)); heading.addContent(Contents.SPACE); heading.addContent(contents.packagesLabel); @@ -157,15 +162,16 @@ * {@inheritDoc} */ protected void addNavigationBarHeader(Content header) { - Content headerContent; - if (configuration.packagesheader.length() > 0) { - headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); + String headerContent = !configuration.packagesheader.isEmpty() ? configuration.packagesheader + : configuration.header; + if (!headerContent.isEmpty()) { + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, + HtmlStyle.bar, new RawHtml(replaceDocRootDir(headerContent))); + header.addContent(heading); + modulePackagesListHeading = Headings.IndexFrames.PACKAGE_HEADING; } else { - headerContent = new RawHtml(replaceDocRootDir(configuration.header)); + modulePackagesListHeading = Headings.PAGE_TITLE_HEADING; } - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, - HtmlStyle.bar, headerContent); - header.addContent(heading); } /** @@ -177,6 +183,7 @@ /** * Do nothing as there is no modules list on this page. */ + @Override protected void addModulesList(Content body) { } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -46,7 +46,6 @@ import com.sun.source.doctree.DocTree; import jdk.javadoc.doclet.DocletEnvironment.ModuleMode; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -213,7 +212,7 @@ div.addContent(annotationContent); Content label = mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL) ? contents.openModuleLabel : contents.moduleLabel; - Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content tHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, label); tHeading.addContent(Contents.SPACE); Content moduleHead = new RawHtml(heading); @@ -461,7 +460,7 @@ Content htmltree) { htmltree.addContent(startMarker); htmltree.addContent(links.createAnchor(markerAnchor)); - htmltree.addContent(HtmlTree.HEADING(HtmlTag.H3, heading)); + htmltree.addContent(HtmlTree.HEADING(Headings.ModuleDeclaration.SUMMARY_HEADING, heading)); } /** @@ -509,7 +508,7 @@ contents.descriptionLabel); HtmlTree li = new HtmlTree(HtmlTag.LI); li.setStyle(HtmlStyle.blockList); - addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES, + addSummaryHeader(MarkerComments.START_OF_MODULES_SUMMARY, SectionName.MODULES, contents.navModules, li); if (display(requires)) { String text = resources.getText("doclet.Requires_Summary"); @@ -561,7 +560,7 @@ || display(indirectPackages) || display(indirectOpenPackages)) { HtmlTree li = new HtmlTree(HtmlTag.LI); li.setStyle(HtmlStyle.blockList); - addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, + addSummaryHeader(MarkerComments.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, contents.navPackages, li); if (display(packages)) { addPackageSummary(li); @@ -740,7 +739,7 @@ if (haveProvides || haveUses) { HtmlTree li = new HtmlTree(HtmlTag.LI); li.setStyle(HtmlStyle.blockList); - addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, + addSummaryHeader(MarkerComments.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, contents.navServices, li); TableHeader usesProvidesTableHeader = new TableHeader(contents.typeLabel, contents.descriptionLabel); @@ -869,7 +868,7 @@ if (!utils.getFullBody(mdle).isEmpty()) { Content tree = HtmlTree.SECTION(); addDeprecationInfo(tree); - tree.addContent(HtmlConstants.START_OF_MODULE_DESCRIPTION); + tree.addContent(MarkerComments.START_OF_MODULE_DESCRIPTION); tree.addContent(links.createAnchor(SectionName.MODULE_DESCRIPTION)); addInlineComment(mdle, tree); moduleContentTree.addContent(tree); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -34,10 +34,8 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.Navigation; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter; @@ -72,7 +70,7 @@ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY); + memberSummaryTree.addContent(MarkerComments.START_OF_NESTED_CLASS_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -91,7 +89,7 @@ */ @Override public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.nestedClassSummary); memberTree.addContent(label); } @@ -155,8 +153,7 @@ ? resources.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Interface") : resources.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class")); } - Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, - label); + Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, label); labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); inheritedTree.addContent(labelHeading); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -30,7 +30,6 @@ import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -102,7 +101,7 @@ HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName)); Content pkgNameContent = new StringContent(pkgName); HtmlTree htmlTree = HtmlTree.MAIN(); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.bar, packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent)); htmlTree.addContent(heading); HtmlTree div = new HtmlTree(HtmlTag.DIV); @@ -177,7 +176,7 @@ continue; } if (!printedHeader) { - Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, + Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, true, labelContent); htmlTree.addContent(heading); printedHeader = true; diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -27,7 +27,6 @@ import javax.lang.model.element.PackageElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -52,6 +51,12 @@ * @author Atul M Dambalkar */ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { + /** + * The heading (h1 or h2) to use for the module list, + * set by addNavigationBarHeader depending on whether or not there + * is an additional initial heading. + */ + private HtmlTag packageListHeading; /** * Construct the PackageIndexFrameWriter object. @@ -79,7 +84,7 @@ */ @Override protected void addPackagesList(Content main) { - Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, + Content heading = HtmlTree.HEADING(packageListHeading, true, contents.packagesLabel); HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading); HtmlTree ul = new HtmlTree(HtmlTag.UL); @@ -130,9 +135,14 @@ } else { headerContent = new RawHtml(replaceDocRootDir(configuration.header)); } - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, - HtmlStyle.bar, headerContent); - header.addContent(heading); + if (!headerContent.isEmpty()) { + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, + HtmlStyle.bar, headerContent); + header.addContent(heading); + packageListHeading = Headings.IndexFrames.PACKAGE_HEADING; + } else { + packageListHeading = Headings.PAGE_TITLE_HEADING; + } } /** diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -27,7 +27,6 @@ import javax.lang.model.element.PackageElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -101,7 +100,7 @@ HtmlTree mainTree = HtmlTree.MAIN(); Content headContent = contents.getContent("doclet.Hierarchy_For_Package", utils.getPackageName(packageElement)); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); if (configuration.packages.size() > 1) { diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -34,7 +34,6 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -251,7 +250,7 @@ headContent.addContent(contents.getContent("doclet.ClassUse_Title", packageText)); headContent.addContent(new HtmlTree(HtmlTag.BR)); headContent.addContent(name); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); mainTree.addContent(div); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -36,7 +36,6 @@ import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -129,7 +128,7 @@ Content annotationContent = new HtmlTree(HtmlTag.P); addAnnotationInfo(packageElement, annotationContent); div.addContent(annotationContent); - Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content tHeading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, contents.packageLabel); tHeading.addContent(Contents.SPACE); Content packageHead = new StringContent(heading); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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,7 +33,6 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -68,7 +67,7 @@ */ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY); + memberSummaryTree.addContent(MarkerComments.START_OF_PROPERTY_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -88,10 +87,10 @@ @Override public Content getPropertyDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS); + memberDetailsTree.addContent(MarkerComments.START_OF_PROPERTY_DETAILS); Content propertyDetailsTree = writer.getMemberTreeHeader(); propertyDetailsTree.addContent(links.createAnchor(SectionName.PROPERTY_DETAIL)); - Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, contents.propertyDetailsLabel); propertyDetailsTree.addContent(heading); return propertyDetailsTree; @@ -105,7 +104,7 @@ Content propertyDetailsTree) { propertyDetailsTree.addContent(links.createAnchor(name(property))); Content propertyDocTree = writer.getMemberTreeHeader(); - Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING); heading.addContent(utils.getPropertyLabel(name(property))); propertyDocTree.addContent(heading); return propertyDocTree; @@ -200,7 +199,7 @@ */ @Override public void addSummaryLabel(Content memberTree) { - Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + Content label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, contents.propertySummaryLabel); memberTree.addContent(label); } @@ -261,7 +260,7 @@ ? resources.getText("doclet.Properties_Inherited_From_Class") : resources.getText("doclet.Properties_Inherited_From_Interface")); } - Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, + Content labelHeading = HtmlTree.HEADING(Headings.TypeDeclaration.INHERITED_SUMMARY_HEADING, label); labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,7 +29,6 @@ import javax.lang.model.element.TypeElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -42,7 +41,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; /** - * Generate the Serialized Form Information Page. + * Generates the Serialized Form Information Page, serialized-form.html. * *

    This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. @@ -86,7 +85,7 @@ htmlTree.addContent(navBar.getContent(true)); bodyTree.addContent(htmlTree); Content h1Content = new StringContent(header); - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true, HtmlStyle.title, h1Content); Content div = HtmlTree.DIV(HtmlStyle.header, heading); mainTree.addContent(div); @@ -120,7 +119,7 @@ * @return a content tree for the package header */ public Content getPackageHeader(String packageName) { - Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, + Content heading = HtmlTree.HEADING(Headings.SerializedForm.PACKAGE_HEADING, true, contents.packageLabel); heading.addContent(Contents.SPACE); heading.addContent(packageName); @@ -173,8 +172,7 @@ contents.getContent( "doclet.Class_0_extends_implements_serializable", classLink, superClassLink); - li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, - className)); + li.addContent(HtmlTree.HEADING(Headings.SerializedForm.CLASS_HEADING, className)); return li; } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -93,11 +93,15 @@ protected void generateIndexFile() throws DocFileIOException { String title = resources.getText("doclet.Window_Single_Index"); HtmlTree body = getBody(true, getWindowTitle(title)); - HtmlTree htmlTree = HtmlTree.HEADER(); - addTop(htmlTree); + HtmlTree header = HtmlTree.HEADER(); + addTop(header); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); - body.addContent(htmlTree); + header.addContent(navBar.getContent(true)); + body.addContent(header); + HtmlTree main = HtmlTree.MAIN(); + main.addContent(HtmlTree.DIV(HtmlStyle.header, + HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, + contents.getContent("doclet.Index")))); HtmlTree divTree = new HtmlTree(HtmlTag.DIV); divTree.setStyle(HtmlStyle.contentContainer); elements = new TreeSet<>(indexbuilder.getIndexMap().keySet()); @@ -114,12 +118,13 @@ } } addLinksForIndexes(divTree); - body.addContent(HtmlTree.MAIN(divTree)); - htmlTree = HtmlTree.FOOTER(); + main.addContent(divTree); + body.addContent(main); + HtmlTree footer = HtmlTree.FOOTER(); navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); - addBottom(htmlTree); - body.addContent(htmlTree); + footer.addContent(navBar.getContent(false)); + addBottom(footer); + body.addContent(footer); createSearchIndexFiles(); printHtmlDocument(null, "index", body); } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java Sat Mar 09 12:54:20 2019 +0000 @@ -37,6 +37,7 @@ import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.doclets.formats.html.markup.DocType; +import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; @@ -264,7 +265,7 @@ * @return the header content for the HTML file */ private static Content getHeader() { - return new HtmlTree(HtmlTag.BODY); + return new HtmlTree(HtmlTag.BODY).addAttr(HtmlAttr.CLASS, "source"); } /** diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -126,6 +126,10 @@ navBar.setUserHeader(getUserHeaderFooter(true)); header.addContent(navBar.getContent(true)); body.addContent(header); + HtmlTree main = HtmlTree.MAIN(); + main.addContent(HtmlTree.DIV(HtmlStyle.header, + HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, + contents.getContent("doclet.Index")))); HtmlTree divTree = new HtmlTree(HtmlTag.DIV); divTree.setStyle(HtmlStyle.contentContainer); addLinksForIndexes(divTree); @@ -138,7 +142,8 @@ configuration.tagSearchIndexMap.get(unicode), divTree); } addLinksForIndexes(divTree); - body.addContent(HtmlTree.MAIN(divTree)); + main.addContent(divTree); + body.addContent(main); HtmlTree footer = HtmlTree.FOOTER(); navBar.setUserFooter(getUserHeaderFooter(false)); footer.addContent(navBar.getContent(false)); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java Sat Mar 09 12:54:20 2019 +0000 @@ -29,7 +29,6 @@ import javax.lang.model.element.PackageElement; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; @@ -108,7 +107,7 @@ public void generateTreeFile() throws DocFileIOException { HtmlTree body = getTreeHeader(); Content headContent = contents.hierarchyForAllPackages; - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, + Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, false, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); addPackageTreeLinks(div); diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,252 +0,0 @@ -/* - * 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 - * 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.javadoc.internal.doclets.formats.html.markup; - -import jdk.javadoc.internal.doclets.toolkit.Content; - -/** - * Stores constants for Html Doclet. - * - *

    This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - * - * @author Bhavesh Patel - */ -public class HtmlConstants { - - /** - * Marker to identify start of top navigation bar. - */ - public static final Content START_OF_TOP_NAVBAR = - new Comment("========= START OF TOP NAVBAR ======="); - - /** - * Marker to identify start of bottom navigation bar. - */ - public static final Content START_OF_BOTTOM_NAVBAR = - new Comment("======= START OF BOTTOM NAVBAR ======"); - - /** - * Marker to identify end of top navigation bar. - */ - public static final Content END_OF_TOP_NAVBAR = - new Comment("========= END OF TOP NAVBAR ========="); - - /** - * Marker to identify end of bottom navigation bar. - */ - public static final Content END_OF_BOTTOM_NAVBAR = - new Comment("======== END OF BOTTOM NAVBAR ======="); - - /** - * Marker to identify start of module description. - */ - public static final Content START_OF_MODULE_DESCRIPTION = - new Comment("============ MODULE DESCRIPTION ==========="); - - /** - * Marker to identify start of modules summary. - */ - public static final Content START_OF_MODULES_SUMMARY = - new Comment("============ MODULES SUMMARY ==========="); - - /** - * Marker to identify start of packages summary. - */ - public static final Content START_OF_PACKAGES_SUMMARY = - new Comment("============ PACKAGES SUMMARY ==========="); - - /** - * Marker to identify start of services summary. - */ - public static final Content START_OF_SERVICES_SUMMARY = - new Comment("============ SERVICES SUMMARY ==========="); - - /** - * Marker to identify start of class data. - */ - public static final Content START_OF_CLASS_DATA = - new Comment("======== START OF CLASS DATA ========"); - - /** - * Marker to identify end of class data. - */ - public static final Content END_OF_CLASS_DATA = - new Comment("========= END OF CLASS DATA ========="); - - /** - * Marker to identify start of nested class summary. - */ - public static final Content START_OF_NESTED_CLASS_SUMMARY = - new Comment("======== NESTED CLASS SUMMARY ========"); - - /** - * Marker to identify start of annotation type optional member summary. - */ - public static final Content START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY = - new Comment("=========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ==========="); - - /** - * Marker to identify start of annotation type required member summary. - */ - public static final Content START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY = - new Comment("=========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ==========="); - - /** - * Marker to identify start of annotation type required member summary. - */ - public static final Content START_OF_ANNOTATION_TYPE_FIELD_SUMMARY = - new Comment("=========== ANNOTATION TYPE FIELD SUMMARY ==========="); - - /** - * Marker to identify start of constructor summary. - */ - public static final Content START_OF_CONSTRUCTOR_SUMMARY = - new Comment("======== CONSTRUCTOR SUMMARY ========"); - - /** - * Marker to identify start of enum constants summary. - */ - public static final Content START_OF_ENUM_CONSTANT_SUMMARY = - new Comment("=========== ENUM CONSTANT SUMMARY ==========="); - - /** - * Marker to identify start of field summary. - */ - public static final Content START_OF_FIELD_SUMMARY = - new Comment("=========== FIELD SUMMARY ==========="); - - /** - * Marker to identify start of properties summary. - */ - public static final Content START_OF_PROPERTY_SUMMARY = - new Comment("=========== PROPERTY SUMMARY ==========="); - - /** - * Marker to identify start of method summary. - */ - public static final Content START_OF_METHOD_SUMMARY = - new Comment("========== METHOD SUMMARY ==========="); - - /** - * Marker to identify start of annotation type details. - */ - public static final Content START_OF_ANNOTATION_TYPE_DETAILS = - new Comment("============ ANNOTATION TYPE MEMBER DETAIL ==========="); - - /** - * Marker to identify start of annotation type field details. - */ - public static final Content START_OF_ANNOTATION_TYPE_FIELD_DETAILS = - new Comment("============ ANNOTATION TYPE FIELD DETAIL ==========="); - - /** - * Marker to identify start of method details. - */ - public static final Content START_OF_METHOD_DETAILS = - new Comment("============ METHOD DETAIL =========="); - - /** - * Marker to identify start of field details. - */ - public static final Content START_OF_FIELD_DETAILS = - new Comment("============ FIELD DETAIL ==========="); - - /** - * Marker to identify start of property details. - */ - public static final Content START_OF_PROPERTY_DETAILS = - new Comment("============ PROPERTY DETAIL ==========="); - - /** - * Marker to identify start of constructor details. - */ - public static final Content START_OF_CONSTRUCTOR_DETAILS = - new Comment("========= CONSTRUCTOR DETAIL ========"); - - /** - * Marker to identify start of enum constants details. - */ - public static final Content START_OF_ENUM_CONSTANT_DETAILS = - new Comment("============ ENUM CONSTANT DETAIL ==========="); - - /** - * Html tag for the page title heading. - */ - public static final HtmlTag TITLE_HEADING = HtmlTag.H1; - - /** - * Html tag for the class page title heading. - */ - public static final HtmlTag CLASS_PAGE_HEADING = HtmlTag.H2; - - /** - * Html tag for the content heading. - */ - public static final HtmlTag CONTENT_HEADING = HtmlTag.H2; - - /** - * Html tag for the package name heading. - */ - public static final HtmlTag PACKAGE_HEADING = HtmlTag.H2; - - /** - * Html tag for the module name heading. - */ - public static final HtmlTag MODULE_HEADING = HtmlTag.H2; - - /** - * Html tag for the member summary heading. - */ - public static final HtmlTag SUMMARY_HEADING = HtmlTag.H3; - - /** - * Html tag for the inherited member summary heading. - */ - public static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3; - - /** - * Html tag for the member details heading. - */ - public static final HtmlTag DETAILS_HEADING = HtmlTag.H3; - - /** - * Html tag for the serialized member heading. - */ - public static final HtmlTag SERIALIZED_MEMBER_HEADING = HtmlTag.H3; - - /** - * Html tag for the member heading. - */ - public static final HtmlTag MEMBER_HEADING = HtmlTag.H4; - - /** - * Default charset for HTML. - */ - public static final String HTML_DEFAULT_CHARSET = "utf-8"; -} diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -42,6 +42,7 @@ import jdk.javadoc.internal.doclets.formats.html.AbstractMemberWriter; import jdk.javadoc.internal.doclets.formats.html.Contents; import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; +import jdk.javadoc.internal.doclets.formats.html.MarkerComments; import jdk.javadoc.internal.doclets.formats.html.SectionName; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder; @@ -106,8 +107,8 @@ } enum Position { - BOTTOM(HtmlConstants.START_OF_BOTTOM_NAVBAR, HtmlConstants.END_OF_BOTTOM_NAVBAR), - TOP(HtmlConstants.START_OF_TOP_NAVBAR, HtmlConstants.END_OF_TOP_NAVBAR); + BOTTOM(MarkerComments.START_OF_BOTTOM_NAVBAR, MarkerComments.END_OF_BOTTOM_NAVBAR), + TOP(MarkerComments.START_OF_TOP_NAVBAR, MarkerComments.END_OF_TOP_NAVBAR); final Content startOfNav; final Content endOfNav; diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -304,8 +304,8 @@ Content noCustomizationMsg = methodWriter.getNoCustomizationMsg( resources.getText("doclet.Serializable_no_customization")); classContentTree.addContent(methodWriter.getSerializableMethods( - resources.getText("doclet.Serialized_Form_methods"), - noCustomizationMsg)); + resources.getText("doclet.Serialized_Form_methods"), + noCustomizationMsg)); } } } diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Sat Mar 09 12:54:20 2019 +0000 @@ -296,25 +296,32 @@ /* * Styles for headings. */ -div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { +div.details ul.blockList ul.blockList ul.blockList li.blockList h3, +div.details ul.blockList ul.blockList ul.blockListLast li.blockList h3, +div.serializedFormContainer ul.blockList ul.blockList ul.blockList li.blockList h4 { background-color:#dee3e9; border:1px solid #d0d9e0; margin:0 0 6px -8px; padding:7px 5px; } -ul.blockList ul.blockList ul.blockList li.blockList h3 { +div.details h2, +div.summary h2 { + font-style: italic; +} +div.details h3, +div.summary h3 { + font-style: normal; +} +ul.blockList ul.blockList ul.blockList li.blockList h2 { background-color:#dee3e9; border:1px solid #d0d9e0; margin:0 0 6px -8px; padding:7px 5px; } -ul.blockList ul.blockList li.blockList h3 { +ul.blockList ul.blockList li.blockList h2 { padding:0; margin:15px 0; } -ul.blockList li.blockList h2 { - padding:0px 0 20px 0; -} /* * Styles for page layout containers. */ @@ -597,7 +604,8 @@ .docSummary { padding:0; } -ul.blockList ul.blockList ul.blockList li.blockList h3 { +ul.blockList ul.blockList ul.blockList li.blockList h3, +ul.blockList ul.blockList ul.blockListLast li.blockList h3 { font-style:normal; } div.block { diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java Sat Mar 09 12:54:20 2019 +0000 @@ -197,9 +197,11 @@ } // Parse the files in the packages and subpackages to be documented - ListBuffer packageTrees = new ListBuffer<>(); - parse(etable.getFilesToParse(), packageTrees, false); - modules.enter(packageTrees.toList(), null); + ListBuffer allTrees = new ListBuffer<>(); + allTrees.addAll(classTrees); + parse(etable.getFilesToParse(), allTrees, false); + modules.newRound(); + modules.initModules(allTrees.toList()); if (messager.hasErrors()) { return null; @@ -207,7 +209,7 @@ // Enter symbols for all files toolEnv.notice("main.Building_tree"); - javadocEnter.main(classTrees.toList().appendList(packageTrees)); + javadocEnter.main(allTrees.toList()); if (messager.hasErrors()) { return null; diff -r 3e39753ed05b -r b38f280d2114 src/jdk.javadoc/share/legal/jszip.md --- a/src/jdk.javadoc/share/legal/jszip.md Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.javadoc/share/legal/jszip.md Sat Mar 09 12:54:20 2019 +0000 @@ -23,4 +23,36 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************** + +The JSZip JavaScript Library v3.1.5 also includes pako + +pako includes the following license: + + +(The MIT License) + +Copyright (C) 2014-2017 by Vitaly Puzrin and Andrei Tuputcyn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +****************************************** + diff -r 3e39753ed05b -r b38f280d2114 src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c --- a/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c Sat Mar 09 12:52:30 2019 +0000 +++ b/src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -42,6 +42,12 @@ #define MAXLEN_MESSAGE 256 #define MAXLEN_EXEC (MAXLEN_FILENAME*2+MAXLEN_INTEGER+16) +#define TIMESTAMP_SIZE (MAXLEN_TIMESTAMP+1) +#define MAXLEN_DT 19 // "DD.MM.YYYY HH:MM:SS" +#define MAXLEN_MS 5 // ".mmm " +#define DT_SIZE (MAXLEN_DT+1) +#define TZ_SIZE (TIMESTAMP_SIZE-MAXLEN_DT-MAXLEN_MS) + static MUTEX_T my_mutex = MUTEX_INIT; /* Static variables (should be protected with mutex) */ @@ -52,12 +58,14 @@ static PID_T processPid; static int open_count; -/* Ascii id of current native thread. */ +/* + * "DD.MM.YYYY HH:MM:SS.mmm " + */ static void get_time_stamp(char *tbuf, size_t ltbuf) { - char timestamp_prefix[MAXLEN_TIMESTAMP+1]; - char timestamp_postfix[MAXLEN_TIMESTAMP+1]; + char timestamp_date_time[DT_SIZE]; + char timestamp_timezone[TZ_SIZE]; unsigned millisecs = 0; time_t t = 0; @@ -65,15 +73,14 @@ if ( time(&t) == (time_t)(-1) ) { t = 0; } - /* Break this up so that the format strings are string literals - and we avoid a compiler warning. */ - (void)strftime(timestamp_prefix, sizeof(timestamp_prefix), + + (void)strftime(timestamp_date_time, DT_SIZE, "%d.%m.%Y %T", localtime(&t)); - (void)strftime(timestamp_postfix, sizeof(timestamp_postfix), + (void)strftime(timestamp_timezone, TZ_SIZE, "%Z", localtime(&t)); (void)snprintf(tbuf, ltbuf, - "%s.%.3d %s", timestamp_prefix, - (int)(millisecs), timestamp_postfix); + "%s.%.3d %s", timestamp_date_time, + (int)(millisecs), timestamp_timezone); } /* Get basename of filename */ diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/gtest/memory/test_virtualSpaceNode.cpp --- a/test/hotspot/gtest/memory/test_virtualSpaceNode.cpp Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,277 +0,0 @@ -/* - * Copyright (c) 2018, 2019, 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. - */ - -#include "precompiled.hpp" -#include "memory/metaspace/virtualSpaceList.hpp" -#include "memory/metaspace/chunkManager.hpp" -#include "runtime/mutexLocker.hpp" -#include "utilities/formatBuffer.hpp" -#include "unittest.hpp" - -// include as last, or otherwise we pull in an incompatible "assert" macro -#include - -using namespace metaspace; - -namespace { - static void chunk_up(size_t words_left, size_t& num_medium_chunks, - size_t& num_small_chunks, - size_t& num_specialized_chunks) { - num_medium_chunks = words_left / MediumChunk; - words_left = words_left % MediumChunk; - - num_small_chunks = words_left / SmallChunk; - words_left = words_left % SmallChunk; - // how many specialized chunks can we get? - num_specialized_chunks = words_left / SpecializedChunk; - ASSERT_EQ(0UL, words_left % SpecializedChunk) << "should be nothing left" - << ", words_left = " << words_left - << ", SpecializedChunk = " << SpecializedChunk; - } - static const size_t vsn_test_size_words = MediumChunk * 4; - static const size_t vsn_test_size_bytes = vsn_test_size_words * BytesPerWord; - class MetachunkRemover { - Metachunk* const _m; - ChunkManager* const _c; - public: - MetachunkRemover(Metachunk* m, ChunkManager* c) : _m(m), _c(c) { } - ~MetachunkRemover() { _c->remove_chunk(_m); } - }; -} - -class ChunkManagerTest { - public: - static size_t sum_free_chunks(ChunkManager* cm) { - return cm->sum_free_chunks(); - } - static size_t sum_free_chunks_count(ChunkManager* cm) { - return cm->sum_free_chunks_count(); - } - static ChunkList* free_chunks(ChunkManager* cm, ChunkIndex i) { - return cm->free_chunks(i); - } -}; - -// removes all the chunks added to the ChunkManager since creation of ChunkManagerRestorer -class ChunkManagerRestorer { - metaspace::ChunkManager* const _cm; - std::vector* _free_chunks[metaspace::NumberOfFreeLists]; - int _count_pre_existing; -public: - ChunkManagerRestorer(metaspace::ChunkManager* cm) : _cm(cm), _count_pre_existing(0) { - _cm->locked_verify(); - for (metaspace::ChunkIndex i = metaspace::ZeroIndex; i < metaspace::NumberOfFreeLists; i = next_chunk_index(i)) { - metaspace::ChunkList* l = ChunkManagerTest::free_chunks(_cm, i); - _count_pre_existing += l->count(); - std::vector *v = new std::vector(l->count()); - metaspace::Metachunk* c = l->head(); - while (c) { - v->push_back(c); - c = c->next(); - } - _free_chunks[i] = v; - } - } - ~ChunkManagerRestorer() { - _cm->locked_verify(); - for (metaspace::ChunkIndex i = metaspace::ZeroIndex; i < metaspace::NumberOfFreeLists; i = next_chunk_index(i)) { - metaspace::ChunkList* l = ChunkManagerTest::free_chunks(_cm, i); - std::vector *v = _free_chunks[i]; - ssize_t count = l->count(); - for (ssize_t j = 0; j < count; j++) { - metaspace::Metachunk* c = l->head(); - while (c) { - bool found = false; - for (size_t k = 0; k < v->size() && !found; k++) { - found = (c == v->at(k)); - } - if (found) { - c = c->next(); - } else { - _cm->remove_chunk(c); - break; - } - } - } - delete _free_chunks[i]; - _free_chunks[i] = NULL; - } - int count_after_cleanup = 0; - for (ChunkIndex i = ZeroIndex; i < NumberOfFreeLists; i = next_chunk_index(i)) { - ChunkList* l = ChunkManagerTest::free_chunks(_cm, i); - count_after_cleanup += l->count(); - } - EXPECT_EQ(_count_pre_existing, count_after_cleanup); - _cm->locked_verify(); - } -}; - -TEST_VM(VirtualSpaceNodeTest, sanity) { - // The chunk sizes must be multiples of eachother, or this will fail - STATIC_ASSERT(MediumChunk % SmallChunk == 0); - STATIC_ASSERT(SmallChunk % SpecializedChunk == 0); - - // just in case STATIC_ASSERT doesn't work - EXPECT_EQ(0, MediumChunk % SmallChunk); - EXPECT_EQ(0, SmallChunk % SpecializedChunk); -} - -TEST_VM(VirtualSpaceNodeTest, four_pages_vsn_is_committed_some_is_used_by_chunks) { - const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord; - if (page_chunks >= MediumChunk) { - SUCCEED() << "SKIP: This doesn't work for systems with vm_page_size >= 16K"; - return; - } - MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); - ChunkManager cm(false); - VirtualSpaceNode vsn(false, vsn_test_size_bytes); - ChunkManagerRestorer c(Metaspace::get_chunk_manager(false)); - - vsn.initialize(); - EXPECT_TRUE(vsn.expand_by(page_chunks, page_chunks)); - vsn.get_chunk_vs(SmallChunk); - vsn.get_chunk_vs(SpecializedChunk); - vsn.retire(&cm); - - // committed - used = words left to retire - const size_t words_left = page_chunks - SmallChunk - SpecializedChunk; - size_t num_medium_chunks, num_small_chunks, num_spec_chunks; - chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks); - - EXPECT_EQ(0UL, num_medium_chunks) << "should not get any medium chunks"; - // DISABLED: checks started to fail after 8198423 - // EXPECT_EQ((num_small_chunks + num_spec_chunks), ChunkManagerTest::sum_free_chunks_count(&cm)) << "should be space for 3 chunks"; - // EXPECT_EQ(words_left, ChunkManagerTest::sum_free_chunks(&cm)) << "sizes should add up"; -} - -TEST_VM(VirtualSpaceNodeTest, half_vsn_is_committed_humongous_chunk_is_used) { - MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); - ChunkManager cm(false); - VirtualSpaceNode vsn(false, vsn_test_size_bytes); - ChunkManagerRestorer c(Metaspace::get_chunk_manager(false)); - - vsn.initialize(); - EXPECT_TRUE(vsn.expand_by(MediumChunk * 2, MediumChunk * 2)); - // Humongous chunks will be aligned up to MediumChunk + SpecializedChunk - vsn.get_chunk_vs(MediumChunk + SpecializedChunk); - vsn.retire(&cm); - - const size_t words_left = MediumChunk * 2 - (MediumChunk + SpecializedChunk); - size_t num_medium_chunks, num_small_chunks, num_spec_chunks; - ASSERT_NO_FATAL_FAILURE(chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks)); - - EXPECT_EQ(0UL, num_medium_chunks) << "should not get any medium chunks"; - // DISABLED: checks started to fail after 8198423 - // EXPECT_EQ((num_small_chunks + num_spec_chunks), ChunkManagerTest::sum_free_chunks_count(&cm)) << "should be space for 3 chunks"; - // EXPECT_EQ(words_left, ChunkManagerTest::sum_free_chunks(&cm)) << "sizes should add up"; -} - -TEST_VM(VirtualSpaceNodeTest, all_vsn_is_committed_half_is_used_by_chunks) { - MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); - ChunkManager cm(false); - VirtualSpaceNode vsn(false, vsn_test_size_bytes); - ChunkManagerRestorer c(Metaspace::get_chunk_manager(false)); - - vsn.initialize(); - EXPECT_TRUE(vsn.expand_by(vsn_test_size_words, vsn_test_size_words)); - vsn.get_chunk_vs(MediumChunk); - vsn.get_chunk_vs(MediumChunk); - vsn.retire(&cm); - - // DISABLED: checks started to fail after 8198423 - // EXPECT_EQ(2UL, ChunkManagerTest::sum_free_chunks_count(&cm)) << "should have been memory left for 2 chunks"; - // EXPECT_EQ(2UL * MediumChunk, ChunkManagerTest::sum_free_chunks(&cm)) << "sizes should add up"; -} - -TEST_VM(VirtualSpaceNodeTest, no_committed_memory) { - MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); - ChunkManager cm(false); - VirtualSpaceNode vsn(false, vsn_test_size_bytes); - ChunkManagerRestorer c(Metaspace::get_chunk_manager(false)); - - vsn.initialize(); - vsn.retire(&cm); - - ASSERT_EQ(0UL, ChunkManagerTest::sum_free_chunks_count(&cm)) << "did not commit any memory in the VSN"; -} - -TEST_VM(VirtualSpaceNodeTest, is_available_positive) { - // Reserve some memory. - VirtualSpaceNode vsn(false, os::vm_allocation_granularity()); - ASSERT_TRUE(vsn.initialize()) << "Failed to setup VirtualSpaceNode"; - - // Commit some memory. - size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; - ASSERT_TRUE(vsn.expand_by(commit_word_size, commit_word_size)) - << "Failed to commit, commit_word_size = " << commit_word_size; - - SCOPED_TRACE(err_msg("VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", - p2i(vsn.bottom()), p2i(vsn.end())).buffer()); - - // Check that is_available accepts the committed size. - EXPECT_TRUE(vsn.is_available(commit_word_size)) << " commit_word_size = " << commit_word_size; - - // Check that is_available accepts half the committed size. - size_t expand_word_size = commit_word_size / 2; - EXPECT_TRUE(vsn.is_available(expand_word_size)) << " expand_word_size = " << expand_word_size; -} - -TEST_VM(VirtualSpaceNodeTest, is_available_negative) { - // Reserve some memory. - VirtualSpaceNode vsn(false, os::vm_allocation_granularity()); - ASSERT_TRUE(vsn.initialize()) << "Failed to setup VirtualSpaceNode"; - - // Commit some memory. - size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; - ASSERT_TRUE(vsn.expand_by(commit_word_size, commit_word_size)) - << "Failed to commit, commit_word_size = " << commit_word_size; - - SCOPED_TRACE(err_msg("VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", - p2i(vsn.bottom()), p2i(vsn.end())).buffer()); - - // Check that is_available doesn't accept a too large size. - size_t two_times_commit_word_size = commit_word_size * 2; - EXPECT_FALSE(vsn.is_available(two_times_commit_word_size)) << " two_times_commit_word_size = " << two_times_commit_word_size; -} - -TEST_VM(VirtualSpaceNodeTest, is_available_overflow) { - // Reserve some memory. - VirtualSpaceNode vsn(false, os::vm_allocation_granularity()); - ASSERT_TRUE(vsn.initialize()) << "Failed to setup VirtualSpaceNode"; - - // Commit some memory. - size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord; - ASSERT_TRUE(vsn.expand_by(commit_word_size, commit_word_size)) - << "Failed to commit, commit_word_size = " << commit_word_size; - - SCOPED_TRACE(err_msg("VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", - p2i(vsn.bottom()), p2i(vsn.end())).buffer()); - - // Calculate a size that will overflow the virtual space size. - void* virtual_space_max = (void*)(uintptr_t)-1; - size_t bottom_to_max = pointer_delta(virtual_space_max, vsn.bottom(), 1); - size_t overflow_size = bottom_to_max + BytesPerWord; - size_t overflow_word_size = overflow_size / BytesPerWord; - - EXPECT_FALSE(vsn.is_available(overflow_word_size)) << " overflow_word_size = " << overflow_word_size; -} diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/gtest/runtime/test_os.cpp --- a/test/hotspot/gtest/runtime/test_os.cpp Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/gtest/runtime/test_os.cpp Sat Mar 09 12:54:20 2019 +0000 @@ -153,28 +153,81 @@ } #endif -TEST(os, test_print_hex_dump) { +static void do_test_print_hex_dump(address addr, size_t len, int unitsize, const char* expected) { + char buf[256]; + buf[0] = '\0'; + stringStream ss(buf, sizeof(buf)); + os::print_hex_dump(&ss, addr, addr + len, unitsize); +// tty->print_cr("expected: %s", expected); +// tty->print_cr("result: %s", buf); + ASSERT_NE(strstr(buf, expected), (char*)NULL); +} + +TEST_VM(os, test_print_hex_dump) { + const char* pattern [4] = { +#ifdef VM_LITTLE_ENDIAN + "00 01 02 03 04 05 06 07", + "0100 0302 0504 0706", + "03020100 07060504", + "0706050403020100" +#else + "00 01 02 03 04 05 06 07", + "0001 0203 0405 0607", + "00010203 04050607", + "0001020304050607" +#endif + }; + + const char* pattern_not_readable [4] = { + "?? ?? ?? ?? ?? ?? ?? ??", + "???? ???? ???? ????", + "???????? ????????", + "????????????????" + }; + + // On AIX, zero page is readable. + address unreadable = +#ifdef AIX + (address) 0xFFFFFFFFFFFF0000ULL; +#else + (address) 0 +#endif + ; + ResourceMark rm; - stringStream ss; + char buf[64]; + stringStream ss(buf, sizeof(buf)); outputStream* out = &ss; // outputStream* out = tty; // enable for printout - // Test dumping unreadable memory does not fail - os::print_hex_dump(out, (address)0, (address)100, 1); - os::print_hex_dump(out, (address)0, (address)100, 2); - os::print_hex_dump(out, (address)0, (address)100, 4); - os::print_hex_dump(out, (address)0, (address)100, 8); + // Test dumping unreadable memory + // Exclude test for Windows for now, since it needs SEH handling to work which cannot be + // guaranteed when we call directly into VM code. (see JDK-8220220) +#ifndef _WIN32 + do_test_print_hex_dump(unreadable, 100, 1, pattern_not_readable[0]); + do_test_print_hex_dump(unreadable, 100, 2, pattern_not_readable[1]); + do_test_print_hex_dump(unreadable, 100, 4, pattern_not_readable[2]); + do_test_print_hex_dump(unreadable, 100, 8, pattern_not_readable[3]); +#endif - // Test dumping readable memory does not fail - char arr[100]; + // Test dumping readable memory + address arr = (address)os::malloc(100, mtInternal); for (int c = 0; c < 100; c++) { arr[c] = c; } - address addr = (address)&arr; - os::print_hex_dump(out, addr, addr + 100, 1); - os::print_hex_dump(out, addr, addr + 100, 2); - os::print_hex_dump(out, addr, addr + 100, 4); - os::print_hex_dump(out, addr, addr + 100, 8); + + // properly aligned + do_test_print_hex_dump(arr, 100, 1, pattern[0]); + do_test_print_hex_dump(arr, 100, 2, pattern[1]); + do_test_print_hex_dump(arr, 100, 4, pattern[2]); + do_test_print_hex_dump(arr, 100, 8, pattern[3]); + + // Not properly aligned. Should automatically down-align by unitsize + do_test_print_hex_dump(arr + 1, 100, 2, pattern[1]); + do_test_print_hex_dump(arr + 1, 100, 4, pattern[2]); + do_test_print_hex_dump(arr + 1, 100, 8, pattern[3]); + + os::free(arr); } ////////////////////////////////////////////////////////////////////////////// diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/ProblemList.txt --- a/test/hotspot/jtreg/ProblemList.txt Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/ProblemList.txt Sat Mar 09 12:54:20 2019 +0000 @@ -157,8 +157,6 @@ vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java 8153598 generic-all vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java 8060733 generic-all -vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002/TestDescription.java 4903717 generic-all -vmTestbase/nsk/jdi/ThreadReference/resume/resume001/TestDescription.java 8072701 generic-all vmTestbase/nsk/jdi/ThreadReference/stop/stop001/TestDescription.java 7034630 generic-all vmTestbase/nsk/jdi/BScenarios/hotswap/tc10x001/TestDescription.java 8013728 generic-all vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003/TestDescription.java 8066993 generic-all diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/TEST.groups --- a/test/hotspot/jtreg/TEST.groups Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/TEST.groups Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2019, 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 @@ -265,6 +265,7 @@ -runtime/7158988/FieldMonitor.java \ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \ -runtime/CommandLine/PrintGCApplicationConcurrentTime.java \ + -runtime/CompressedOops/UseCompressedOops.java \ -runtime/ConstantPool/IntfMethod.java \ -runtime/ErrorHandling/CreateCoredumpOnCrash.java \ -runtime/ErrorHandling/ErrorHandler.java \ @@ -346,6 +347,7 @@ runtime/ \ serviceability/ \ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \ + -runtime/CompressedOops/UseCompressedOops.java \ -runtime/Thread/TestThreadDumpMonitorContention.java \ -runtime/containers/ \ -:tier1_runtime \ diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java --- a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java Sat Mar 09 12:54:20 2019 +0000 @@ -294,7 +294,7 @@ try { String cmd = ProcessTools.getCommandLine(ProcessTools.createJavaProcessBuilder(true, args)); return new String[]{"sh", "-c", prefix - + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;") : cmd)}; + + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;").replace("|", "\\|") : cmd)}; } catch(Throwable t) { throw new Error("Can't create process builder: " + t, t); } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019, 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 TestOverloadCompileQueues + * @bug 8163511 + * @summary Test overloading the C1 and C2 compile queues with tasks. + * @run main/othervm -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1 + * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues + * @run main/othervm -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2 + * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues + */ + +package compiler.classUnloading.methodUnloading; + +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +public class TestOverloadCompileQueues { + public static final int ITERS = 500; // Increase for longer stress testing + + // Some methods to fill up the compile queue + public static void test0() { } + public static void test1() { } + public static void test2() { } + public static void test3() { } + public static void test4() { } + public static void test5() { } + public static void test6() { } + public static void test7() { } + public static void test8() { } + public static void test9() { } + public static void test10() { } + public static void test11() { } + public static void test12() { } + public static void test13() { } + public static void test14() { } + public static void test15() { } + public static void test16() { } + public static void test17() { } + public static void test18() { } + public static void test19() { } + + public static void main(String[] args) throws Throwable { + Class thisClass = TestOverloadCompileQueues.class; + ClassLoader defaultLoader = thisClass.getClassLoader(); + URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation(); + + for (int i = 0; i < ITERS; ++i) { + // Load test class with own class loader + URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent()); + Class testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader); + + // Execute all test methods to trigger compilation and fill up compile queue + for (int j = 1; j < 20; ++j) { + Method method = testClass.getDeclaredMethod("test" + j); + method.invoke(null); + method.invoke(null); + } + + // Unload dead classes from ealier iterations + System.gc(); + } + } +} diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java --- a/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java Sat Mar 09 12:54:20 2019 +0000 @@ -25,7 +25,12 @@ * @test * @bug 8209951 * @summary SIGBUS in com.sun.crypto.provider.CipherBlockChaining - * @run main/othervm/timeout=300 -Xbatch + * @library /test/lib / + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -Xbatch + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestCipherBlockChainingEncrypt */ @@ -40,6 +45,10 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; +import compiler.whitebox.CompilerWhiteBoxTest; +import sun.hotspot.code.Compiler; +import jtreg.SkippedException; + public class TestCipherBlockChainingEncrypt { private static String algorithm = "PBEWithHmacSHA1AndAES_256"; private static final String PBEPASS = "Hush, it's supposed to be a secret!"; @@ -53,8 +62,11 @@ private static Cipher ci; public static void main(String[] args) throws Exception { - for(int i=0; i<5_000; i++) { - if (!(new TestCipherBlockChainingEncrypt().test(args))) { + if (!Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.CipherBlockChaining", "implEncrypt", byte[].class, int.class, int.class, byte[].class, int.class)) { + throw new SkippedException("Base64 intrinsic is not available"); + } + for(int i=0; i<2_000; i++) { + if (!(new TestCipherBlockChainingEncrypt().test(args))) { throw new RuntimeException("TestCipherBlockChainingEncrypt test failed"); } } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/compiler/intrinsics/math/TestFpMinMaxIntrinsics.java --- a/test/hotspot/jtreg/compiler/intrinsics/math/TestFpMinMaxIntrinsics.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/compiler/intrinsics/math/TestFpMinMaxIntrinsics.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, Arm Limited. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Arm Limited. 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,20 +27,41 @@ * @bug 8212043 * @summary Test compiler intrinsics of floating-point Math.min/max * - * @run main/othervm -Xint compiler.intrinsics.math.TestFpMinMaxIntrinsics + * @run main/othervm -Xint compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 1 * @run main/othervm -XX:+UnlockDiagnosticVMOptions * -Xcomp -XX:TieredStopAtLevel=1 * -XX:CompileOnly=java/lang/Math - * compiler.intrinsics.math.TestFpMinMaxIntrinsics + * compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 1 * @run main/othervm -XX:+UnlockDiagnosticVMOptions * -Xcomp -XX:-TieredCompilation * -XX:CompileOnly=java/lang/Math - * compiler.intrinsics.math.TestFpMinMaxIntrinsics + * compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 1 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:-TieredCompilation -XX:CompileThresholdScaling=0.1 + * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.*Test* + * compiler.intrinsics.math.TestFpMinMaxIntrinsics sanityTests 10000 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:-TieredCompilation -Xcomp + * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.*Test* + * -XX:CompileCommand=compileonly,compiler/intrinsics/math/TestFpMinMaxIntrinsics.*Test* + * compiler.intrinsics.math.TestFpMinMaxIntrinsics reductionTests 100 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:+TieredCompilation + * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min* + * -XX:CompileCommand=dontinline,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min* + * compiler.intrinsics.math.TestFpMinMaxIntrinsics randomSearchTree 1 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:+TieredCompilation + * -XX:CompileCommand=print,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min* + * -XX:CompileCommand=dontinline,compiler/intrinsics/math/TestFpMinMaxIntrinsics.min* + * compiler.intrinsics.math.TestFpMinMaxIntrinsics sortedSearchTree 1 */ package compiler.intrinsics.math; import java.util.Arrays; +import java.util.Random; +import java.lang.reflect.Method; public class TestFpMinMaxIntrinsics { @@ -63,63 +84,220 @@ private static final float[][] f_cases = { // a b min max { fPos, fPos, fPos, fPos }, + { fNeg, fNeg, fNeg, fNeg }, { fPos, fNeg, fNeg, fPos }, + { fNeg, fPos, fNeg, fPos }, + { fPosZero, fNegZero, fNegZero, fPosZero }, + { fNegZero, fPosZero, fNegZero, fPosZero }, { fNegZero, fNegZero, fNegZero, fNegZero }, + { fPos, fPosInf, fPos, fPosInf }, { fNeg, fNegInf, fNegInf, fNeg }, + { fPos, fNaN, fNaN, fNaN }, + { fNaN, fPos, fNaN, fNaN }, + { fNeg, fNaN, fNaN, fNaN }, + { fNaN, fNeg, fNaN, fNaN }, + + { fPosInf, fNaN, fNaN, fNaN }, + { fNaN, fPosInf, fNaN, fNaN }, { fNegInf, fNaN, fNaN, fNaN }, + { fNaN, fNegInf, fNaN, fNaN } }; private static final double[][] d_cases = { // a b min max { dPos, dPos, dPos, dPos }, + { dNeg, dNeg, dNeg, dNeg }, { dPos, dNeg, dNeg, dPos }, + { dNeg, dPos, dNeg, dPos }, + { dPosZero, dNegZero, dNegZero, dPosZero }, + { dNegZero, dPosZero, dNegZero, dPosZero }, { dNegZero, dNegZero, dNegZero, dNegZero }, + { dPos, dPosInf, dPos, dPosInf }, { dNeg, dNegInf, dNegInf, dNeg }, + { dPos, dNaN, dNaN, dNaN }, + { dNaN, dPos, dNaN, dNaN }, + { dNeg, dNaN, dNaN, dNaN }, + { dNaN, dNeg, dNaN, dNaN }, + + { dPosInf, dNaN, dNaN, dNaN }, + { dNaN, dPosInf, dNaN, dNaN }, { dNegInf, dNaN, dNaN, dNaN }, + { dNaN, dNegInf, dNaN, dNaN } }; private static void fTest(float[] row) { - float min = Math.min(row[0], row[1]); - float max = Math.max(row[0], row[1]); - if (Float.isNaN(min) && Float.isNaN(max) - && Float.isNaN(row[2]) && Float.isNaN(row[3])) { - // Return if all of them are NaN - return; + fCheck(row[0], row[1], Math.min(row[0], row[1]), Math.max(row[0], row[1]), row[2], row[3]); + } + + private static void fReductionTest(float[] row) { + float fmin = row[0], fmax = row[0]; + + for (int i=0; i<100; i++) { + fmin = Math.min(fmin, row[1]); + fmax = Math.max(fmax, row[1]); } - if (min != row[2] || max != row[3]) { + + fCheck(row[0], row[1], fmin, fmax, row[2], row[3]); + } + + private static void fCheck(float a, float b, float fmin, float fmax, float efmin, float efmax) { + int min = Float.floatToRawIntBits(fmin); + int max = Float.floatToRawIntBits(fmax); + int emin = Float.floatToRawIntBits(efmin); + int emax = Float.floatToRawIntBits(efmax); + + if (min != emin || max != emax) { throw new AssertionError("Unexpected result of float min/max: " + - "a = " + row[0] + ", b = " + row[1] + ", " + - "result = (" + min + ", " + max + "), " + - "expected = (" + row[2] + ", " + row[3] + ")"); + "a = " + a + ", b = " + b + ", " + + "result = (" + fmin + ", " + fmax + "), " + + "expected = (" + efmin + ", " + efmax + ")"); } } private static void dTest(double[] row) { - double min = Math.min(row[0], row[1]); - double max = Math.max(row[0], row[1]); - if (Double.isNaN(min) && Double.isNaN(max) - && Double.isNaN(row[2]) && Double.isNaN(row[3])) { - // Return if all of them are NaN - return; + dCheck(row[0], row[1], Math.min(row[0], row[1]), Math.max(row[0], row[1]), row[2], row[3]); + } + + private static void dReductionTest(double[] row) { + double dmin = row[0], dmax = row[0]; + + for (int i=0; i<100; i++) { + dmin = Math.min(dmin, row[1]); + dmax = Math.max(dmax, row[1]); } - if (min != row[2] || max != row[3]) { - throw new AssertionError("Unexpected result of double min/max" + - "a = " + row[0] + ", b = " + row[1] + ", " + - "result = (" + min + ", " + max + "), " + - "expected = (" + row[2] + ", " + row[3] + ")"); + + dCheck(row[0], row[1], dmin, dmax, row[2], row[3]); + } + + private static void dCheck(double a, double b, double dmin, double dmax, double edmin, double edmax) { + double min = Double.doubleToRawLongBits(dmin); + double max = Double.doubleToRawLongBits(dmax); + double emin = Double.doubleToRawLongBits(edmin); + double emax = Double.doubleToRawLongBits(edmax); + + if (min != emin || max != emax) { + throw new AssertionError("Unexpected result of double min/max: " + + "a = " + a + ", b = " + b + ", " + + "result = (" + dmin + ", " + dmax + "), " + + "expected = (" + edmin + ", " + edmax + ")"); } } - public static void main(String[] args) { + public static void sanityTests() { Arrays.stream(f_cases).forEach(TestFpMinMaxIntrinsics::fTest); Arrays.stream(d_cases).forEach(TestFpMinMaxIntrinsics::dTest); - System.out.println("PASS"); + } + + public static void reductionTests() { + Arrays.stream(f_cases).forEach(TestFpMinMaxIntrinsics::fReductionTest); + Arrays.stream(d_cases).forEach(TestFpMinMaxIntrinsics::dReductionTest); + } + + public static void main(String[] args) throws Exception { + Method m = TestFpMinMaxIntrinsics.class.getDeclaredMethod(args[0]); + for (int i = 0 ; i < Integer.parseInt(args[1]) ; i++) + m.invoke(null); + } + + private static final int COUNT = 1000; + private static final int LOOPS = 100; + + private static Random r = new Random(); + + private static Node[] pool = new Node[COUNT]; + + private static long time = 0; + private static long times = 0; + + public static void init() { + for (int i=0; i +#else +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +static volatile int release_critical = 0; + +JNIEXPORT jboolean JNICALL +Java_gc_g1_TestPeriodicCollectionJNI_blockInNative(JNIEnv* env, jobject obj, jintArray dummy) { + void* native_array = (*env)->GetPrimitiveArrayCritical(env, dummy, 0); + + if (native_array == NULL) { + return JNI_FALSE; + } + + while (!release_critical) { +#ifdef WINDOWS + Sleep(1); +#else + usleep(1000); +#endif + } + + (*env)->ReleasePrimitiveArrayCritical(env, dummy, native_array, 0); + + return JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_gc_g1_TestPeriodicCollectionJNI_unblock(JNIEnv *env, jobject obj) +{ + release_critical = 1; +} + +#ifdef __cplusplus +} +#endif diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -203,7 +203,13 @@ allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(origin -> (!(origin.contains("develop") || origin.contains("notproduct")))); /* - * Remove CICompilerCount from testing because currently it can hang system + * Exclude VMThreadStackSize from max range testing, because it will always exit with code 1, + * which technically passes, but really it fails, and worse yet, it produces hs_err_pid file. + */ + excludeTestMaxRange("VMThreadStackSize"); + + /* + * Exclude CICompilerCount from testing because currently it can hang system */ excludeTestMaxRange("CICompilerCount"); diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java --- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java Sat Mar 09 12:54:20 2019 +0000 @@ -45,6 +45,7 @@ {"MinRAMFraction", "2"}, {"InitialRAMFraction", "64"}, {"TLABStats", "false"}, + {"ThreadLocalHandshakes", "true"}, // deprecated alias flags (see also aliased_jvm_flags): {"DefaultMaxRAMFraction", "4"}, diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java --- a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java Sat Mar 09 12:54:20 2019 +0000 @@ -30,7 +30,7 @@ * java.management * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UseCompressedOops + * @run main/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UseCompressedOops */ import java.util.ArrayList; import java.util.Collections; diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java --- a/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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,14 +23,15 @@ /* * @test - * @bug 8151486 + * @bug 8151486 8218266 * @summary Call Class.forName() on the system classloader from a class loaded * from a custom classloader, using the current class's protection domain. * @library /test/lib + * @modules java.base/jdk.internal.misc * @build jdk.test.lib.Utils * jdk.test.lib.util.JarUtils * @build ClassForName ProtectionDomainCacheTest - * @run main/othervm/policy=test.policy -XX:+UnlockDiagnosticVMOptions -XX:VerifySubSet=dictionary -XX:+VerifyAfterGC -Xlog:gc+verify=debug,protectiondomain=trace,class+unload:gc.log -Djava.security.manager ProtectionDomainCacheTest + * @run main/othervm/policy=test.policy -Djava.security.manager ProtectionDomainCacheTest */ import java.net.URL; @@ -42,48 +43,69 @@ import java.util.List; import jdk.test.lib.Utils; import jdk.test.lib.util.JarUtils; +import java.io.File; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* * Create .jar, load ClassForName from .jar using a URLClassLoader */ public class ProtectionDomainCacheTest { - private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR); - private static final String TESTCLASSES = System.getProperty("test.classes", "."); - private static final String CLASSFILENAME = "ClassForName.class"; + static class Test { + private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR); + private static final String TESTCLASSES = System.getProperty("test.classes", "."); + private static final String CLASSFILENAME = "ClassForName.class"; + + // Use a new classloader to load the ClassForName class. + public static void loadAndRun(Path jarFilePath) + throws Exception { + ClassLoader classLoader = new URLClassLoader( + new URL[]{jarFilePath.toUri().toURL()}) { + @Override public String toString() { return "LeakedClassLoader"; } + }; + + Class loadClass = Class.forName("ClassForName", true, classLoader); + loadClass.newInstance(); + + System.out.println("returning : " + classLoader); + } - // Use a new classloader to load the ClassForName class. - public static void loadAndRun(Path jarFilePath) - throws Exception { - ClassLoader classLoader = new URLClassLoader( - new URL[]{jarFilePath.toUri().toURL()}) { - @Override public String toString() { return "LeakedClassLoader"; } - }; + public static void main(final String[] args) throws Exception { + // Create a temporary .jar file containing ClassForName.class + Path testClassesDir = Paths.get(TESTCLASSES); + Path jarFilePath = Files.createTempFile("cfn", ".jar"); + JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME); + jarFilePath.toFile().deleteOnExit(); - Class loadClass = Class.forName("ClassForName", true, classLoader); - loadClass.newInstance(); + // Remove the ClassForName.class file that jtreg built, to make sure + // we're loading from the tmp .jar + Path classFile = FileSystems.getDefault().getPath(TESTCLASSES, + CLASSFILENAME); + Files.delete(classFile); - System.out.println("returning : " + classLoader); + loadAndRun(jarFilePath); + + // Give the GC a chance to unload protection domains + for (int i = 0; i < 100; i++) { + System.gc(); + } + System.out.println("All Classloaders and protection domain cache entries successfully unloaded"); + } } - public static void main(final String[] args) throws Exception { - // Create a temporary .jar file containing ClassForName.class - Path testClassesDir = Paths.get(TESTCLASSES); - Path jarFilePath = Files.createTempFile("cfn", ".jar"); - JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME); - jarFilePath.toFile().deleteOnExit(); - - // Remove the ClassForName.class file that jtreg built, to make sure - // we're loading from the tmp .jar - Path classFile = FileSystems.getDefault().getPath(TESTCLASSES, - CLASSFILENAME); - Files.delete(classFile); - - loadAndRun(jarFilePath); - - // Give the GC a chance to unload protection domains - for (int i = 0; i < 100; i++) { - System.gc(); - } - System.out.println("All Classloaders and protection domain cache entries successfully unloaded"); + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Djava.security.policy==" + System.getProperty("test.src") + File.separator + "test.policy", + "-Dtest.classes=" + System.getProperty("test.classes", "."), + "-XX:+UnlockDiagnosticVMOptions", + "-XX:VerifySubSet=dictionary", + "-XX:+VerifyAfterGC", + "-Xlog:gc+verify,protectiondomain=debug", + "-Djava.security.manager", + Test.class.getName()); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("PD in set is not alive"); + output.shouldHaveExitValue(0); } } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/Dictionary/test.policy --- a/test/hotspot/jtreg/runtime/Dictionary/test.policy Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/runtime/Dictionary/test.policy Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ grant { - permission java.io.FilePermission "<>", "read, write, delete"; + permission java.io.FilePermission "<>", "read, write, delete, execute"; permission java.lang.RuntimePermission "createClassLoader"; permission java.lang.RuntimePermission "getClassLoader"; permission java.util.PropertyPermission "*", "read"; /* for Utils */ diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2019, SAP SE. 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.*; +import jdk.test.lib.process.*; + +/* + * @test TestAbortVMOnSafepointTimeout + * @summary Check if VM can kill thread which doesn't reach safepoint. + * @bug 8219584 + * @requires vm.compiler2.enabled + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + */ + +public class TestAbortVMOnSafepointTimeout { + + public static void main(String[] args) throws Exception { + if (args.length > 0) { + int result = test_loop(3); + System.out.println("This message would occur after some time with result " + result); + return; + } + + testWith(500, 500); + } + + static int test_loop(int x) { + int sum = 0; + if (x != 0) { + // Long running loop without safepoint. + for (int y = 1; y < Integer.MAX_VALUE; ++y) { + if (y % x == 0) ++sum; + } + } + return sum; + } + + public static void testWith(int sfpt_interval, int timeout_delay) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+SafepointTimeout", + "-XX:+SafepointALot", + "-XX:+AbortVMOnSafepointTimeout", + "-XX:SafepointTimeoutDelay=" + timeout_delay, + "-XX:GuaranteedSafepointInterval=" + sfpt_interval, + "-XX:-TieredCompilation", + "-XX:-UseCountedLoopSafepoints", + "-XX:LoopStripMiningIter=0", + "-XX:LoopUnrollLimit=0", + "-XX:CompileCommand=compileonly,TestAbortVMOnSafepointTimeout::test_loop", + "-Xcomp", + "-XX:-CreateCoredumpOnCrash", + "-Xms64m", + "TestAbortVMOnSafepointTimeout", + "runTestLoop" + ); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + if (Platform.isWindows()) { + output.shouldMatch("Safepoint sync time longer than"); + } else { + output.shouldMatch("SIGILL"); + if (Platform.isLinux()) { + output.shouldMatch("(sent by kill)"); + } + output.shouldMatch("TestAbortVMOnSafepointTimeout.test_loop"); + } + output.shouldNotHaveExitValue(0); + } +} diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest --- a/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest Sat Mar 09 12:54:20 2019 +0000 @@ -1,4 +1,4 @@ -FROM oraclelinux:7.2 +FROM oraclelinux:7.6 MAINTAINER mikhailo.seledtsov@oracle.com COPY /jdk /jdk diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/containers/docker/JfrReporter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/containers/docker/JfrReporter.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019, 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 java.nio.file.Paths; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; + + +// This class is intended to run inside a container +public class JfrReporter { + public static final String TEST_REPORTED_CORES="TEST_REPORTED_CORES"; + public static final String TEST_REPORTED_MEMORY="TEST_REPORTED_MEMORY"; + public static final String TEST_REPORTED_PID="TEST_REPORTED_PID"; + public static final String TESTCASE_CPU="cpu"; + public static final String TESTCASE_MEMORY="memory"; + public static final String TESTCASE_PROCESS="process"; + + public static void main(String[] args) throws Exception { + String testCase = args[0]; + System.out.println("Testcase: " + testCase); + switch (testCase) { + case TESTCASE_CPU: + RecordedEvent event = testEvent("jdk.CPUInformation", "cpu.jfr"); + System.out.println(TEST_REPORTED_CORES + "=" + event.getInt("cores")); + break; + case TESTCASE_MEMORY: + event = testEvent("jdk.PhysicalMemory", "memory.jfr"); + System.out.println(TEST_REPORTED_MEMORY + "=" + event.getLong("totalSize")); + break; + case TESTCASE_PROCESS: + event = testEvent("jdk.SystemProcess", "process.jfr"); + System.out.println(TEST_REPORTED_PID + "=" + event.getString("pid")); + break; + default: + throw new IllegalArgumentException("Invalid test case"); + } + } + + private static RecordedEvent testEvent(String event, String recordingPath) throws Exception { + System.out.println("========= Testing event: " + event); + Recording r = new Recording(); + r.enable(event); + r.setDestination(Paths.get("tmp", recordingPath)); + r.start(); + r.stop(); + + RecordedEvent recordedEvent = RecordingFile.readAllEvents(r.getDestination()).get(0); + System.out.println("RecordedEvent: " + recordedEvent); + return recordedEvent; + } +} diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/runtime/containers/docker/TestJFREvents.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/containers/docker/TestJFREvents.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2019, 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 Ensure that certain JFR events return correct results for resource values + * when run inside Docker container, such as available CPU and memory. + * Also make sure that PIDs are based on value provided by container, + * not by the host system. + * @requires (docker.support & os.maxMemory >= 2g) + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * jdk.jartool/sun.tools.jar + * @build JfrReporter + * @run driver TestJFREvents + */ +import jdk.test.lib.containers.docker.Common; +import jdk.test.lib.containers.docker.DockerRunOptions; +import jdk.test.lib.containers.docker.DockerTestUtils; +import jdk.test.lib.Utils; + + +public class TestJFREvents { + private static final String imageName = Common.imageName("jfr-events"); + private static final int availableCPUs = Runtime.getRuntime().availableProcessors(); + + public static void main(String[] args) throws Exception { + System.out.println("Test Environment: detected availableCPUs = " + availableCPUs); + if (!DockerTestUtils.canTestDocker()) { + return; + } + + DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker"); + + try { + // leave one CPU for system and tools, otherwise this test may be unstable + int maxNrOfAvailableCpus = availableCPUs - 1; + for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) { + testCPUInfo(i, i); + } + + long MB = 1024*1024; + testMemory("200m", "" + 200*MB); + testMemory("500m", "" + 500*MB); + testMemory("1g", "" + 1024*MB); + + testProcessInfo(); + + } finally { + DockerTestUtils.removeDockerImage(imageName); + } + } + + + private static void testCPUInfo(int valueToSet, int expectedValue) throws Exception { + Common.logNewTestCase("CPUInfo: --cpus = " + valueToSet); + DockerTestUtils.dockerRunJava( + commonDockerOpts() + .addDockerOpts("--cpus=" + valueToSet) + .addClassOptions(JfrReporter.TESTCASE_CPU)) + .shouldHaveExitValue(0) + .shouldContain(JfrReporter.TEST_REPORTED_CORES); + + // The following assertion is currently disabled due to JFR reporting incorrect values. + // JFR reports values for the host system as opposed to values for the container. + // @ignore 8219999 + // .shouldContain(JfrReporter.TEST_REPORTED_CORES + "=" + expectedValue); + } + + + private static void testMemory(String valueToSet, String expectedValue) throws Exception { + Common.logNewTestCase("Memory: --memory = " + valueToSet); + DockerTestUtils.dockerRunJava( + commonDockerOpts() + .addDockerOpts("--memory=" + valueToSet) + .addClassOptions(JfrReporter.TESTCASE_MEMORY)) + .shouldHaveExitValue(0) + .shouldContain(JfrReporter.TEST_REPORTED_MEMORY + "=" + expectedValue); + } + + + private static void testProcessInfo() throws Exception { + Common.logNewTestCase("ProcessInfo"); + DockerTestUtils.dockerRunJava( + commonDockerOpts() + .addClassOptions(JfrReporter.TESTCASE_PROCESS)) + .shouldHaveExitValue(0) + .shouldContain(JfrReporter.TEST_REPORTED_PID + "=1"); + + } + + + private static DockerRunOptions commonDockerOpts() { + return new DockerRunOptions(imageName, "/jdk/bin/java", "JfrReporter") + .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/") + .addJavaOpts("-cp", "/test-classes/"); + } +} diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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,14 +23,15 @@ package nsk.jdi.ClassUnloadRequest.addClassExclusionFilter; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; + import java.io.*; -import java.util.*; /** * Debugger requests ClassUnloadEvent and sets class filter by calling @@ -64,7 +65,7 @@ private static int exitStatus; private static Log log; private static Debugee debugee; - private static int eventWaitTime; + private static long waitTime; String[] patterns = { prefix + "Sub*", @@ -88,7 +89,7 @@ exclfilter001 tstObj = new exclfilter001(); ArgumentHandler argHandler = new ArgumentHandler(argv); - eventWaitTime = argHandler.getWaitTime() * 60000; + waitTime = argHandler.getWaitTime(); log = new Log(out, argHandler); debugee = Debugee.prepareDebugee(argHandler, log, debugeeName); @@ -121,7 +122,7 @@ debugee.sendSignal(SGNL_UNLOAD); debugee.receiveExpectedSignal(SGNL_READY); - receiveEvents(eventWaitTime, patterns[i]); + receiveEvents(patterns[i]); display(""); debugee.getEventRequestManager().deleteEventRequest(request); @@ -146,19 +147,20 @@ return request; } - private void receiveEvents(int waitTime, String pattern) { + private void receiveEvents(String pattern) { EventSet eventSet = null; Event event; - int totalTime = waitTime; + long totalWaitTime = Utils.adjustTimeout(waitTime * 10000); + long waitTimeout = Utils.adjustTimeout(waitTime * 1000); long begin, delta; int count = 0; boolean exit = false; try { begin = System.currentTimeMillis(); - eventSet = debugee.VM().eventQueue().remove(totalTime); + eventSet = debugee.VM().eventQueue().remove(waitTimeout); delta = System.currentTimeMillis() - begin; - totalTime -= delta; + totalWaitTime -= delta; while (eventSet != null) { EventIterator eventIterator = eventSet.eventIterator(); while (eventIterator.hasNext()) { @@ -174,14 +176,14 @@ throw new Failure("Unexpected VMDisconnectEvent received"); } } - if (totalTime <= 0 || exit) { + if (totalWaitTime <= 0 || exit) { break; } debugee.resume(); - begin = System.currentTimeMillis(); - eventSet = debugee.VM().eventQueue().remove(totalTime); + begin = System.currentTimeMillis(); + eventSet = debugee.VM().eventQueue().remove(waitTimeout); delta = System.currentTimeMillis() - begin; - totalTime -= delta; + totalWaitTime -= delta; } } catch(InterruptedException e) { throw new Failure(e); diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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,6 +23,7 @@ package nsk.jdi.ClassUnloadRequest.addClassFilter; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jdi.*; @@ -63,7 +64,7 @@ private static int exitStatus; private static Log log; private static Debugee debugee; - private static int eventWaitTime; + private static long waitTime; String[] patterns = { prefix + "Sub*", @@ -87,7 +88,8 @@ filter001 tstObj = new filter001(); ArgumentHandler argHandler = new ArgumentHandler(argv); - eventWaitTime = argHandler.getWaitTime() * 60000; + waitTime = argHandler.getWaitTime(); + log = new Log(out, argHandler); debugee = Debugee.prepareDebugee(argHandler, log, debugeeName); @@ -120,7 +122,7 @@ debugee.sendSignal(SGNL_UNLOAD); debugee.receiveExpectedSignal(SGNL_READY); - receiveEvents(eventWaitTime, patterns[i]); + receiveEvents(patterns[i]); display(""); debugee.getEventRequestManager().deleteEventRequest(request); @@ -145,19 +147,20 @@ return request; } - private void receiveEvents(int waitTime, String pattern) { + private void receiveEvents(String pattern) { EventSet eventSet = null; Event event; - int totalTime = waitTime; + long totalWaitTime = Utils.adjustTimeout(waitTime * 10000); + long waitTimeout = Utils.adjustTimeout(waitTime * 1000); long begin, delta; int count = 0; boolean exit = false; try { begin = System.currentTimeMillis(); - eventSet = debugee.VM().eventQueue().remove(totalTime); + eventSet = debugee.VM().eventQueue().remove(waitTimeout); delta = System.currentTimeMillis() - begin; - totalTime -= delta; + totalWaitTime -= delta; while (eventSet != null) { EventIterator eventIterator = eventSet.eventIterator(); while (eventIterator.hasNext()) { @@ -173,14 +176,14 @@ throw new Failure("Unexpected VMDisconnectEvent received"); } } - if (totalTime <= 0 || exit) { + if (totalWaitTime <= 0 || exit) { break; } debugee.resume(); - begin = System.currentTimeMillis(); - eventSet = debugee.VM().eventQueue().remove(totalTime); + begin = System.currentTimeMillis(); + eventSet = debugee.VM().eventQueue().remove(waitTimeout); delta = System.currentTimeMillis() - begin; - totalTime -= delta; + totalWaitTime -= delta; } } catch(InterruptedException e) { throw new Failure(e); diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import java.util.List; import java.io.*; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -234,7 +235,7 @@ // wait for a requested event try { - gotEvent.wait(argHandler.getWaitTime()*60000); + gotEvent.wait(Utils.adjustTimeout(argHandler.getWaitTime()*1000)); } catch (InterruptedException e) { log.complain("TEST FAILURE: waiting for a requested AccessWatchpointEvent #" + i + ": caught " + e); diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,6 +23,7 @@ package nsk.jdi.EventQueue.remove; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -67,7 +68,7 @@ *
    * The check includes two steps.
    * In first one, second thread waits for any incoming event from the
    - * debugger which is sleeping for "WAITTIME*90 seconds"; hence,
    + * debugger which is sleeping for some time; hence,
    * no events are expected to be received at the debugger end.
    * In second, second thread is interrupted, and the debugger waits for
    * a breakpoint event after the debuggee finishes sleeping.
    @@ -130,7 +131,7 @@ static Debugee debuggee; static ArgumentHandler argsHandler; - static int waitTime; + static long waitTime; static VirtualMachine vm = null; static EventRequestManager eventRManager = null; @@ -140,6 +141,8 @@ static ReferenceType debuggeeClass = null; + static Value trueValue; + static int testExitCode = PASSED; class JDITestRuntimeException extends RuntimeException { @@ -156,7 +159,7 @@ logHandler = new Log(out, argsHandler); Binder binder = new Binder(argsHandler, logHandler); - waitTime = argsHandler.getWaitTime() * 60000; + waitTime = Utils.adjustTimeout(argsHandler.getWaitTime() * 1000); try { log2("launching a debuggee :"); @@ -285,6 +288,8 @@ if (!debuggeeClass.name().equals(debuggeeName)) throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **"); + trueValue = debuggeeClass.getValue(debuggeeClass.fieldByName("BOOLEAN_TRUE_VALUE")); + log2(" received: ClassPrepareEvent for debuggeeClass"); String bPointMethod = "methodForCommunication"; @@ -356,11 +361,11 @@ thread2.interrupt(); for (int i2 = 0; i2 < waitTime; ) { - waitObj.wait(10000); + waitObj.wait(1000); if (!thread2.isAlive()) { break; } - i2 += 10000; + i2 += 1000; } if (thread2.isAlive()) { log3("ERROR: thread2 is still alive"); @@ -508,9 +513,17 @@ log2("-----t2: eventSet = eventQueue.remove(); expects: InterruptedException"); eventSet = eventQueue.remove(); throw new JDITestRuntimeException("** return from eventQueue.remove(); **"); - } catch ( InterruptedException e1) { + } catch (InterruptedException e1) { log2("-----t2: InterruptedException"); - } catch ( Exception e ) { + // Signal to debuggee to stop sleeping + try { + ((ClassType) debuggeeClass).setValue(debuggeeClass.fieldByName("stopSleeping"), + trueValue); + } catch (InvalidTypeException | ClassNotLoadedException e) { + log3("ERROR: -----t2: Exception : " + e); + testExitCode = FAILED; + } + } catch (Exception e) { log3("ERROR: -----t2: Exception : " + e); testExitCode = FAILED; } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,6 +23,7 @@ package nsk.jdi.EventQueue.remove; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -63,6 +64,12 @@ static int lineForComm = 2; + // Used for communication between debugger and debuggee + static volatile boolean stopSleeping = false; + + // Used by debugger to set stopSleeping flag to true + static final boolean BOOLEAN_TRUE_VALUE = true; + private static void methodForCommunication() { int i1 = instruction; int i2 = i1; @@ -97,10 +104,12 @@ log1("before: methodForCommunication();"); methodForCommunication(); log1("before: Thread.sleep"); - try { - Thread.sleep(argHandler.getWaitTime()*90000); - } catch (InterruptedException e) { - } + Utils.waitForCondition( + () -> { + return stopSleeping; + }, + Utils.adjustTimeout(argHandler.getWaitTime() * 10000), + 100); log1("after: Thread.sleep"); break ; diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,6 +23,7 @@ package nsk.jdi.EventQueue.remove_l; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -30,7 +31,6 @@ import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; - import java.util.*; import java.io.*; @@ -63,8 +63,8 @@ * to be suspended and to inform the debugger with the event.
    * The case for testing consists of of two steps.
    * In the first one the first assertion is checked up on as follows:
    - * the debugger sleeps for "WAITTIME * 90 sec";
    - * hence, no event is expected in the debugger within WAITTINE, and
    + * the debugger sleeps for some time;
    + * hence, no event is expected in the debugger within WAITTIME, and
    * debugger's method breakpointForCommunication() should get null.
    * After WAITTIME, the debugger just expects to get normal breakpoint event.
    */ @@ -126,7 +126,7 @@ static Debugee debuggee; static ArgumentHandler argsHandler; - static int waitTime; + static long waitTime; static VirtualMachine vm = null; static EventRequestManager eventRManager = null; @@ -136,6 +136,8 @@ static ReferenceType debuggeeClass = null; + static Value trueValue; + static int testExitCode = PASSED; class JDITestRuntimeException extends RuntimeException { @@ -152,7 +154,7 @@ logHandler = new Log(out, argsHandler); Binder binder = new Binder(argsHandler, logHandler); - waitTime = argsHandler.getWaitTime() * 60000; + waitTime = Utils.adjustTimeout(argsHandler.getWaitTime() * 1000); try { log2("launching a debuggee :"); @@ -281,6 +283,8 @@ if (!debuggeeClass.name().equals(debuggeeName)) throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **"); + trueValue = debuggeeClass.getValue(debuggeeClass.fieldByName("BOOLEAN_TRUE_VALUE")); + log2(" received: ClassPrepareEvent for debuggeeClass"); String bPointMethod = "methodForCommunication"; @@ -326,6 +330,11 @@ testExitCode = FAILED; throw new JDITestRuntimeException("** unexpected Exception **"); } + + // Signal to debuggee to stop sleeping + ((ClassType) debuggeeClass).setValue(debuggeeClass.fieldByName("stopSleeping"), + trueValue); + } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,6 +23,7 @@ package nsk.jdi.EventQueue.remove_l; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -63,6 +64,12 @@ static int lineForComm = 2; + // Used for communication between debugger and debuggee + static volatile boolean stopSleeping = false; + + // Used by debugger to set stopSleeping flag to true + static final boolean BOOLEAN_TRUE_VALUE = true; + private static void methodForCommunication() { int i1 = instruction; int i2 = i1; @@ -97,10 +104,12 @@ log1("before: methodForCommunication();"); methodForCommunication(); log1("before: Thread.sleep"); - try { - Thread.sleep(argHandler.getWaitTime()*90000); - } catch (InterruptedException e) { - } + Utils.waitForCondition( + () -> { + return stopSleeping; + }, + Utils.adjustTimeout(argHandler.getWaitTime() * 10000), + 100); log1("after: Thread.sleep"); break ; diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002a.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/isSuspended/issuspended002a.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -63,8 +63,8 @@ public static void main (String argv[]) { - for (int i=0; icom.sun.jdi.VirtualMachine.allThreads()
    * complies with the its spec.
    *
    - * The test checks up the reasults of the method when
    + * The test checks up the results of the method when
    * it is invoked two times in raw immediately after
    * new thread has been started in the debuggee VM.
    *
    @@ -192,11 +192,15 @@ String threadName = "testedThread"; + // Suspend VM to ensure no new background thread (e.g. JVMCI + // compiler thread) is started between two allThreads() calls. + vm.suspend(); List allThreads1 = vm.allThreads(); log2("allThreads1.size() = " + allThreads1.size()); List allThreads2 = vm.allThreads(); log2("allThreads2.size() = " + allThreads2.size()); + vm.resume(); if ( allThreads1.size() != allThreads2.size() ) { log3("ERROR: allThreads1.size() != allThreads2.size()"); diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java Sat Mar 09 12:54:20 2019 +0000 @@ -23,6 +23,7 @@ package nsk.jdi.VirtualMachine.dispose; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -272,29 +273,29 @@ if (expresult != returnCode0) break label1; - log2(" Thread.sleep(waitTime*60000);"); - try { - Thread.sleep(waitTime*60000); - } catch ( InterruptedException e ) { - log3("ERROR: InterruptedException"); - expresult = returnCode1; - break label1; - } + log2(" Waiting for thread2 is not alive"); - log2("......sending to the debuggee: 'check_alive'"); - log2(" expected reply: 'not_alive'"); - pipe.println("check_alive"); - line = pipe.readln(); - if (line.equals("alive")) { - log3("ERROR: thread2 is alive"); - expresult = returnCode1; - } else if (line.equals("not_alive")) { - log2(" thread2 is not alive"); - } else { - log3("ERROR: unexpected reply: " + line); - expresult = returnCode4; - } + Utils.waitForCondition( + () -> { + log2("......sending to the debuggee: 'check_alive'"); + log2(" expected reply: 'not_alive'"); + pipe.println("check_alive"); + String reply = pipe.readln(); + if (reply.equals("alive")) { + log3("ERROR: thread2 is alive"); + return false; + } else if (reply.equals("not_alive")) { + log2(" thread2 is not alive"); + return true; + } else { + log3("ERROR: unexpected reply: " + reply); + throw new RuntimeException("ERROR: unexpected reply: " + reply); + } + }, + Utils.adjustTimeout(waitTime * 60000), + 1000); + pipe.println("check_done"); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,18 +125,26 @@ } } log1("mainThread is out of: synchronized (lockingObject)"); - - instruction = pipe.readln(); - if (!instruction.equals("check_alive")) { - logErr("ERROR: unexpected instruction: " + instruction); - exitCode = FAILED; - } else { - log1("checking on: thread2.isAlive"); - if (test_thread.isAlive()) { - pipe.println("alive"); - test_thread.interrupt(); + while (true) { + instruction = pipe.readln(); + if (instruction.equals("check_done")) { + if (test_thread.isAlive()) { + logErr("ERROR: thread thread2 is still alive"); + exitCode = FAILED; + } + break; + } else if (instruction.equals("check_alive")) { + log1("checking on: thread2.isAlive"); + if (test_thread.isAlive()) { + pipe.println("alive"); + test_thread.interrupt(); + } else { + pipe.println("not_alive"); + } } else { - pipe.println("not_alive"); + logErr("ERROR: unexpected instruction: " + instruction); + exitCode = FAILED; + break; } } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java Sat Mar 09 12:54:20 2019 +0000 @@ -23,6 +23,7 @@ package nsk.jdi.VirtualMachine.dispose; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -179,6 +180,7 @@ int expresult = returnCode0; + String threadName = "testedThread"; List allThreads = null; @@ -236,28 +238,28 @@ if (expresult != returnCode0) break label1; - log2(" Thread.sleep(waitTime*60000);"); - try { - Thread.sleep(waitTime*60000); - } catch ( InterruptedException e ) { - log3("ERROR: InterruptedException"); - expresult = returnCode1; - break label1; - } + log2(" Waiting for thread2 is not alive"); - log2("......sending to the debuggee: 'check_alive'"); - log2(" expected reply: 'not_alive'"); - pipe.println("check_alive"); - line = pipe.readln(); - if (line.equals("alive")) { - log3("ERROR: thread2 is alive"); - expresult = returnCode1; - } else if (line.equals("not_alive")) { - log2(" thread2 is not alive"); - } else { - log3("ERROR: unexpected reply: " + line); - expresult = returnCode4; - } + Utils.waitForCondition( + () -> { + log2("......sending to the debuggee: 'check_alive'"); + log2(" expected reply: 'not_alive'"); + pipe.println("check_alive"); + String reply = pipe.readln(); + if (reply.equals("alive")) { + log3("ERROR: thread2 is alive"); + return false; + } else if (reply.equals("not_alive")) { + log2(" thread2 is not alive"); + return true; + } else { + log3("ERROR: unexpected reply: " + reply); + throw new RuntimeException("ERROR: unexpected reply: " + reply); + } + }, + Utils.adjustTimeout(waitTime * 60000), + 1000); + pipe.println("check_done"); } @@ -287,4 +289,6 @@ } return testExitCode; } + + } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -126,17 +126,26 @@ } log1("mainThread is out of: synchronized (lockingObject)"); - instruction = pipe.readln(); - if (!instruction.equals("check_alive")) { - logErr("ERROR: unexpected instruction: " + instruction); - exitCode = FAILED; - } else { - log1("checking on: thread2.isAlive"); - if (test_thread.isAlive()) { - test_thread.resume(); - pipe.println("alive"); + while (true) { + instruction = pipe.readln(); + if (instruction.equals("check_done")) { + if (test_thread.isAlive()) { + logErr("ERROR: thread2 thread is still alive"); + exitCode = FAILED; + } + break; + } else if (instruction.equals("check_alive")) { + log1("checking on: thread2.isAlive"); + if (test_thread.isAlive()) { + test_thread.resume(); + pipe.println("alive"); + } else { + pipe.println("not_alive"); + } } else { - pipe.println("not_alive"); + logErr("ERROR: unexpected instruction: " + instruction); + exitCode = FAILED; + break; } } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java Sat Mar 09 12:54:20 2019 +0000 @@ -23,6 +23,7 @@ package nsk.jdi.VirtualMachine.dispose; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -261,29 +262,30 @@ if (expresult != returnCode0) break label1; - log2(" Thread.sleep(waitTime*60000);"); - try { - Thread.sleep(waitTime*60000); - } catch ( InterruptedException e ) { - log3("ERROR: InterruptedException"); - expresult = returnCode1; - break label1; - } + log2(" Waiting for thread2 is not alive"); - log2("......sending to the debuggee: 'check_alive'"); - log2(" expected reply: 'not_alive'"); - pipe.println("check_alive"); - line = pipe.readln(); - if (line.equals("alive")) { - log3("ERROR: thread2 is alive"); - expresult = returnCode1; - } else if (line.equals("not_alive")) { - log2(" thread2 is not alive"); - } else { - log3("ERROR: unexpected reply: " + line); - expresult = returnCode4; - } + Utils.waitForCondition( + () -> { + log2("......sending to the debuggee: 'check_alive'"); + log2(" expected reply: 'not_alive'"); + pipe.println("check_alive"); + String reply = pipe.readln(); + if (reply.equals("alive")) { + log3("ERROR: thread2 is alive"); + return false; + } else if (reply.equals("not_alive")) { + log2(" thread2 is not alive"); + return true; + } else { + log3("ERROR: unexpected reply: " + reply); + throw new RuntimeException("ERROR: unexpected reply: " + reply); + } + }, + Utils.adjustTimeout(waitTime * 60000), + 1000); + + pipe.println("check_done"); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -127,18 +127,26 @@ } } log1("mainThread is out of: synchronized (lockingObject)"); - - instruction = pipe.readln(); - if (!instruction.equals("check_alive")) { - logErr("ERROR: unexpected instruction: " + instruction); - exitCode = FAILED; - } else { - log1("checking on: thread2.isAlive"); - if (test_thread.isAlive()) { - test_thread.resume(); - pipe.println("alive"); + while (true) { + instruction = pipe.readln(); + if (instruction.equals("check_done")) { + if (test_thread.isAlive()) { + logErr("thread thread2 is still alive"); + exitCode = FAILED; + } + break; + } else if (instruction.equals("check_alive")) { + log1("checking on: thread2.isAlive"); + if (test_thread.isAlive()) { + test_thread.resume(); + pipe.println("alive"); + } else { + pipe.println("not_alive"); + } } else { - pipe.println("not_alive"); + logErr("ERROR: unexpected instruction: " + instruction); + exitCode = FAILED; + break; } } diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java Sat Mar 09 12:54:20 2019 +0000 @@ -23,6 +23,7 @@ package nsk.jdi.VirtualMachine.suspend; +import jdk.test.lib.Utils; import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -318,9 +319,10 @@ eventSet1.resume(); eventSet.resume(); - log2(" before: Thread.sleep(waitTime*60000);"); + log2(" before: Thread.sleep(waitTime*1000);"); + try { - Thread.sleep(waitTime*60000); + Thread.sleep(Utils.adjustTimeout(waitTime*1000)); } catch ( InterruptedException e ) { log3("ERROR: InterruptedException"); expresult = returnCode1; diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -275,7 +275,6 @@ jint frameCount = 0; jint frameStackSize = 0; jvmtiFrameInfo frameStack[MAX_STACK_SIZE]; - int commonDepth = 0; int found = 0; int j; @@ -296,12 +295,8 @@ } NSK_DISPLAY1(" stack depth: %d\n", (int)frameStackSize); - commonDepth = (frameCount < frameStackSize ? frameCount : frameStackSize); - NSK_DISPLAY1(" common: %d\n", (int)commonDepth); - - /* check first commonDepth frames and find expected method there */ found = 0; - for (j = 0; j < commonDepth; j++) { + for (j = 0; j < frameStackSize; j++) { jmethodID qMethod = (jmethodID)NULL; jlocation qLocation = NSK_JVMTI_INVALID_JLOCATION; diff -r 3e39753ed05b -r b38f280d2114 test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp Sat Mar 09 12:52:30 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -295,7 +295,6 @@ jint frameCount = 0; jint frameStackSize = 0; jvmtiFrameInfo frameStack[MAX_STACK_SIZE]; - int commonDepth = 0; int found = 0; int j; @@ -319,12 +318,8 @@ } NSK_DISPLAY1(" stack depth: %d\n", (int)frameStackSize); - commonDepth = (frameCount < frameStackSize ? frameCount : frameStackSize); - NSK_DISPLAY1(" common: %d\n", (int)commonDepth); - - /* check first commonDepth frames and find expected method there */ found = 0; - for (j = 0; j < commonDepth; j++) { + for (j = 0; j < frameStackSize; j++) { jmethodID qMethod = (jmethodID)NULL; jlocation qLocation = NSK_JVMTI_INVALID_JLOCATION; diff -r 3e39753ed05b -r b38f280d2114 test/jdk/TEST.groups --- a/test/jdk/TEST.groups Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/TEST.groups Sat Mar 09 12:54:20 2019 +0000 @@ -1,4 +1,4 @@ -# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2019, 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 @@ -214,8 +214,7 @@ sun/security \ -sun/security/krb5 \ -sun/security/jgss \ - javax/net \ - com/sun/net/ssl + javax/net jdk_security4 = \ com/sun/security/jgss \ diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMLargeDataKAT.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMLargeDataKAT.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2019, 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 javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.GCMParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.security.MessageDigest; +import java.util.HashMap; + +/* + * @test + * @bug 8220165 + * @summary Verify correctness of large data sizes for GCM. + */ + +/** + * This test stores the MD5 hash of correctly encrypted AES/GCM data for + * particular data lengths. Those lengths are run on SunJCE to verify returns + * the same MD5 hash of the encrypted data. These are not NIST data sets or + * provided by any other organization. The data sets are known good values, + * verified with two different JCE providers (solaris-sparcv9 ucrypto and + * linux SunJCE). + * + * Lengths around 64k are chosen because 64k is the point where + * com.sun.crypto.provider.GaloisCounterMode#doLastBlock() starts it's + * intrinsic warmup + * + * Plaintext is all zeros. Preset key and IV. + * + * The choice of MD5 is for speed. Shortcoming of the algorithm are + * not relevant for this test. + */ + +public class GCMLargeDataKAT { + + // Hash of encrypted results of AES/GCM for particular lengths. + // + static final HashMap results = new HashMap<>() {{ + put(65534, "1397b91c31ce793895edace4e175bfee"); //64k-2 + put(65535, "4ad101c9f450e686668b3f8f05db96f0"); //64k-1 + put(65536, "fbfaee3451acd3f603200d6be0f39b24"); //64k + put(65537, "e7dfca4a71495c65d20982c3c9b9813f"); //64k+1 + put(67583, "c8ebdcb3532ec6c165de961341af7635"); //66k-1 + put(67584, "36559d108dfd25dd29da3fec3455b9e5"); //66k + put(67585, "1d21b42d80ea179810744fc23dc228b6"); //66k+1 + put(102400, "0d1544fcab20bbd4c8103b9d273f2c82"); //100k + put(102401, "f2d53ef65fd12d0a861368659b23ea2e"); //100k+1 + put(102402, "97f0f524cf63d2d9d23d81e64d416ee0"); //100k+2 + put(102403, "4a6b4af55b7d9016b64114d6813d639c"); //100k+3 + put(102404, "ba63cc131fcde2f12ddf2ac634201be8"); //100k+4 + put(102405, "673d05c7fe5e283e42e5c0d049fdcea6"); //100k+5 + put(102406, "76cc99a7850ce857eb3cb43049cf9877"); //100k+6 + put(102407, "65863f99072cf2eb7fce18bd78b33f4e"); //100k+7 + put(102408, "b9184f0f272682cc1f791fa7070eddd4"); //100k+8 + put(102409, "45fe36afef43cc665bf22a9ca200c3c2"); //100k+9 + put(102410, "67249e41646edcb37a78a61b0743cf11"); //100k+0 + put(102411, "ffdc611e29c8849842e81ec78f32c415"); //100k+11 + put(102412, "b7fde7fd52221057dccc1c181a140125"); //100k+12 + put(102413, "4b1d6c64d56448105e5613157e69c0ae"); //100k+13 + put(102414, "6d2c0b26c0c8785c8eec3298a5f0080c"); //100k+14 + put(102415, "1df2061b114fbe56bdf3717e3ee61ef9"); //100k+15 + put(102416, "a691742692c683ac9d1254df5fc5f768"); //100k+16 + }}; + static final int HIGHLEN = 102416; + + static final int GCM_TAG_LENGTH = 16; + static final byte[] iv = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + static final byte[] key_code = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + }; + static final GCMParameterSpec spec = + new GCMParameterSpec(GCM_TAG_LENGTH * 8, iv); + static final SecretKey key = new SecretKeySpec(key_code, "AES"); + static boolean testresult = true; + static byte[] plaintext = new byte[HIGHLEN]; + static MessageDigest md5; + Cipher cipher; + + GCMLargeDataKAT() { + } + + byte[] encrypt(int inLen) { + try { + cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + cipher.init(Cipher.ENCRYPT_MODE, key, spec); + return cipher.doFinal(plaintext, 0, inLen); + } catch (Exception e) { + System.err.println("Encrypt Failure (length = " + inLen + ") : " + + e.getMessage()); + e.printStackTrace(); + } + return new byte[0]; + } + + static byte[] hash(byte[] data) { + return md5.digest(data); + } + + // Decrypt the data and return a boolean if the plaintext is all 0's. + boolean decrypt(byte[] data) { + byte[] result = null; + int len = data.length - GCM_TAG_LENGTH; + if (data.length == 0) { + return false; + } + try { + cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + cipher.init(Cipher.DECRYPT_MODE, key, spec); + result = cipher.doFinal(data); + } catch (Exception e) { + System.err.println("Decrypt Failure (length = " + len + ") : " + + e.getMessage()); + e.printStackTrace(); + return false; + } + + if (result.length != len) { + System.err.println("Decrypt Failure (length = " + len + + ") : plaintext length invalid = " + result.length); + } + // Return false if we find a non zero. + int i = 0; + while (result.length > i) { + if (result[i++] != 0) { + System.err.println("Decrypt Failure (length = " + len + + ") : plaintext invalid, char index " + i); + return false; + } + } + return true; + } + + void test() throws Exception { + + // results order is not important + for (int l : results.keySet()) { + byte[] enc = new GCMLargeDataKAT().encrypt(l); + + // verify hash with stored hash of that length + String hashstr = toHex(hash(enc)); + boolean r = (hashstr.compareTo(results.get(l)) == 0); + + System.out.println("---------------------------------------------"); + + // Encrypted test & results + System.out.println("Encrypt data size " + l + " \tResult: " + + (r ? "Pass" : "Fail")); + if (!r) { + if (enc.length != 0) { + System.out.println("\tExpected: " + results.get(l)); + System.out.println("\tReturned: " + hashstr); + } + testresult = false; + continue; + } + + // Decrypted test & results + r = decrypt(enc); + System.out.println("Decrypt data size " + l + " \tResult: " + + (r ? "Pass" : "Fail")); + if (!r) { + testresult = false; + } + } + + // After test complete, throw an error if there was a failure + if (!testresult) { + throw new Exception("Tests failed"); + } + } + + /** + * With no argument, the test will run the predefined data lengths + * + * With an integer argument, this test will print the hash of the encrypted + * data of that integer length. + * + */ + public static void main(String args[]) throws Exception { + md5 = MessageDigest.getInstance("MD5"); + + if (args.length > 0) { + int len = Integer.parseInt(args[0]); + byte[] e = new GCMLargeDataKAT().encrypt(len); + System.out.println(toHex(hash(e))); + return; + } + + new GCMLargeDataKAT().test(); + } + + // bytes to hex string + static String toHex(byte[] bytes) { + StringBuffer hexStringBuffer = new StringBuffer(32); + for (int i = 0; i < bytes.length; i++) { + hexStringBuffer.append(byteToHex(bytes[i])); + } + return hexStringBuffer.toString(); + } + // byte to hex + static String byteToHex(byte num) { + char[] hexDigits = new char[2]; + hexDigits[0] = Character.forDigit((num >> 4) & 0xF, 16); + hexDigits[1] = Character.forDigit((num & 0xF), 16); + return new String(hexDigits); + } +} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/jdi/JdbStopThreadidTest.java --- a/test/jdk/com/sun/jdi/JdbStopThreadidTest.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/com/sun/jdi/JdbStopThreadidTest.java Sat Mar 09 12:54:20 2019 +0000 @@ -32,6 +32,7 @@ * @run main/othervm JdbStopThreadidTest */ +import jdk.test.lib.process.OutputAnalyzer; import lib.jdb.Jdb; import lib.jdb.JdbCommand; import lib.jdb.JdbTest; @@ -138,6 +139,7 @@ jdb.command(JdbCommand.cont().waitForPrompt("Breakpoint hit: \"thread=MYTHREAD-2\", \\S+MyThread.brkMethod", true)); // Continue until the application exits. Once again, hitting a breakpoint will cause // a failure because we are not suppose to hit one. - jdb.command(JdbCommand.cont().waitForPrompt(Jdb.APPLICATION_EXIT, true)); + jdb.contToExit(1); + new OutputAnalyzer(getJdbOutput()).shouldContain(Jdb.APPLICATION_EXIT); } } diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java --- a/test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -212,6 +212,8 @@ protected void startUp(String targetName) { List argList = new ArrayList<>(Arrays.asList(args)); argList.add(0, targetName); // pre-pend so it becomes the first "app" arg + // We need the class path that contains the path to jdk.test.lib.Asserts. + argList.add(0, " -cp " + System.getProperty("test.class.path")); println("run args: " + argList); connect((String[]) argList.toArray(args)); waitForVMStart(); diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/ComKeyManagerFactoryImpl.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/ComKeyManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2002, 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.security.*; -import com.sun.net.ssl.*; - -public class ComKeyManagerFactoryImpl extends KeyManagerFactorySpi { - - public ComKeyManagerFactoryImpl() { - System.out.println("ComKeyManagerFactoryImpl initialized"); - } - - protected void engineInit(KeyStore ks, char [] password) - throws KeyStoreException { - System.out.println("ComKeyManagerFactoryImpl init'd"); - } - - protected KeyManager[] engineGetKeyManagers() { - return null; - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/ComSSLContextImpl.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/ComSSLContextImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2002, 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.security.*; -import com.sun.net.ssl.*; - -public class ComSSLContextImpl extends SSLContextSpi { - - public ComSSLContextImpl() { - System.out.println("ComSSLContextImpl initialized"); - } - - protected void engineInit(KeyManager[] km, - TrustManager[] tm, SecureRandom sr) throws KeyManagementException { - System.out.println("ComSSLContextImpl init'd"); - } - - protected javax.net.ssl.SSLSocketFactory engineGetSocketFactory() { - return null; - } - - protected javax.net.ssl.SSLServerSocketFactory - engineGetServerSocketFactory() { - return null; - } - -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/ComTrustManagerFactoryImpl.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/ComTrustManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2002, 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.security.*; -import com.sun.net.ssl.*; - -public class ComTrustManagerFactoryImpl extends TrustManagerFactorySpi { - - public ComTrustManagerFactoryImpl() { - System.out.println("ComTrustManagerFactoryImpl initialized"); - } - - protected void engineInit(KeyStore ks) throws KeyStoreException { - System.out.println("ComTrustManagerFactoryImpl init'd"); - } - - protected TrustManager[] engineGetTrustManagers() { - return null; - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/JavaxKeyManagerFactoryImpl.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/JavaxKeyManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2002, 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.security.*; -import javax.net.ssl.*; - -public class JavaxKeyManagerFactoryImpl extends KeyManagerFactorySpi { - - public JavaxKeyManagerFactoryImpl () { - System.out.println("JavaxKeyManagerFactoryImpl initialized"); - } - - protected void engineInit(KeyStore ks, char[] passwd) - throws KeyStoreException { - System.out.println("JavaxKeyManagerFactoryImpl init'd"); - } - - protected void engineInit(ManagerFactoryParameters spec) - throws InvalidAlgorithmParameterException { - } - - protected KeyManager[] engineGetKeyManagers() { - return null; - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/JavaxSSLContextImpl.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/JavaxSSLContextImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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.security.*; -import javax.net.ssl.*; - -public class JavaxSSLContextImpl extends SSLContextSpi { - - public JavaxSSLContextImpl() { - System.out.println("JavaxSSLContextImpl initialized"); - } - - protected void engineInit(KeyManager[] km, - TrustManager[] tm, SecureRandom sr) throws KeyManagementException { - System.out.println("JavaxSSLContextImpl init'd"); - } - - protected SSLEngine engineCreateSSLEngine() { - return null; - } - - protected SSLEngine engineCreateSSLEngine(String host, int port) { - return null; - } - - protected SSLSocketFactory engineGetSocketFactory() { - return null; - } - - protected SSLServerSocketFactory engineGetServerSocketFactory() { - return null; - } - - protected SSLSessionContext engineGetServerSessionContext() { - return null; - } - - protected SSLSessionContext engineGetClientSessionContext() { - return null; - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/JavaxTrustManagerFactoryImpl.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/JavaxTrustManagerFactoryImpl.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002, 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.security.*; -import javax.net.ssl.*; - -public class JavaxTrustManagerFactoryImpl extends TrustManagerFactorySpi { - - public JavaxTrustManagerFactoryImpl () { - System.out.println("JavaxTrustManagerFactoryImpl initialized"); - } - - protected void engineInit(KeyStore ks) throws KeyStoreException { - System.out.println("JavaxTrustManagerFactoryImpl init'd"); - } - - protected void engineInit(ManagerFactoryParameters spec) - throws InvalidAlgorithmParameterException { - } - - protected TrustManager[] engineGetTrustManagers() { - return null; - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/ProviderTest.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/ProviderTest.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * 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 - * 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 4667976 8130181 - * @modules java.base/com.sun.net.ssl - * @compile JavaxSSLContextImpl.java ComSSLContextImpl.java - * JavaxTrustManagerFactoryImpl.java ComTrustManagerFactoryImpl.java - * JavaxKeyManagerFactoryImpl.java ComKeyManagerFactoryImpl.java - * @run main/othervm ProviderTest - * @summary brokenness in the com.sun.net.ssl.SSLSecurity wrappers - */ - -import java.security.*; -import com.sun.net.ssl.*; - -public class ProviderTest { - - public static void main(String args[]) throws Exception { - SSLContext sslc; - TrustManagerFactory tmf; - KeyManagerFactory kmf; - - Provider extraProvider = new MyProvider(); - Security.addProvider(extraProvider); - try { - System.out.println("getting a javax SSLContext"); - sslc = SSLContext.getInstance("javax"); - sslc.init(null, null, null); - System.out.println("\ngetting a com SSLContext"); - sslc = SSLContext.getInstance("com"); - sslc.init(null, null, null); - - System.out.println("\ngetting a javax TrustManagerFactory"); - tmf = TrustManagerFactory.getInstance("javax"); - tmf.init((KeyStore) null); - System.out.println("\ngetting a com TrustManagerFactory"); - tmf = TrustManagerFactory.getInstance("com"); - tmf.init((KeyStore) null); - - System.out.println("\ngetting a javax KeyManagerFactory"); - kmf = KeyManagerFactory.getInstance("javax"); - kmf.init((KeyStore) null, null); - System.out.println("\ngetting a com KeyManagerFactory"); - kmf = KeyManagerFactory.getInstance("com"); - kmf.init((KeyStore) null, null); - } finally { - Security.removeProvider(extraProvider.getName()); - } - } -} - -class MyProvider extends Provider { - - private static String info = "Brad's provider"; - - /** - * Installs the JSSE provider. - */ - public static synchronized void install() - { - /* nop. Remove this method in the future. */ - } - - public MyProvider() - { - super("BRAD", "1.0", info); - - AccessController.doPrivileged(new java.security.PrivilegedAction() { - public Object run() { - - put("SSLContext.javax", "JavaxSSLContextImpl"); - put("SSLContext.com", "ComSSLContextImpl"); - put("TrustManagerFactory.javax", - "JavaxTrustManagerFactoryImpl"); - put("TrustManagerFactory.com", - "ComTrustManagerFactoryImpl"); - put("KeyManagerFactory.javax", - "JavaxKeyManagerFactoryImpl"); - put("KeyManagerFactory.com", - "ComKeyManagerFactoryImpl"); - - return null; - } - }); - - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/com/sun/net/ssl/SSLSecurity/TruncateArray.java --- a/test/jdk/com/sun/net/ssl/SSLSecurity/TruncateArray.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2002, 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 4665824 - * @summary JSSE - ClassCastException with 1.4 - * @modules java.base/com.sun.net.ssl - */ - -import com.sun.net.ssl.*; - -public class TruncateArray { - - public static void main(String args[]) throws Exception { - try { - - TrustManager tms [] = new TrustManager [] { - new MyTM(), new MyTM(), new MyTM() }; - - KeyManager kms [] = new KeyManager [] { - new MyKM(), new MyKM(), new MyKM() }; - - SSLContext ctx = SSLContext.getInstance("TLS"); - ctx.init(kms, tms, null); - - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SUNX509"); - KeyManager[] km = kmf.getKeyManagers(); - - TrustManagerFactory tmf = - TrustManagerFactory.getInstance("SUNX509"); - TrustManager[] tm = tmf.getTrustManagers(); - - } catch (ClassCastException e) { - throw e; - } catch (Throwable e) { - /* - * swallow anything else, we only are interested - * in class casting errors here. For example, we soon - * may be catching methods called on uninitialized factories. - */ - System.out.println("Caught something else"); - e.printStackTrace(); - } - } - - static class MyTM implements TrustManager { - } - - static class MyKM implements KeyManager { - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java --- a/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/lang/SecurityManager/CheckSecurityProvider.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ expected.add("sun.security.rsa.SunRsaSign"); layer.findModule("jdk.crypto.ec") .ifPresent(m -> expected.add("sun.security.ec.SunEC")); - expected.add("com.sun.net.ssl.internal.ssl.Provider"); + expected.add("sun.security.ssl.SunJSSE"); expected.add("com.sun.crypto.provider.SunJCE"); layer.findModule("jdk.security.jgss") .ifPresent(m -> expected.add("sun.security.jgss.SunProvider")); diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/lang/StringBuffer/AppendCharSequence.java --- a/test/jdk/java/lang/StringBuffer/AppendCharSequence.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/lang/StringBuffer/AppendCharSequence.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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,7 +22,7 @@ */ /* @test - * @bug 4812591 4705328 5019111 + * @bug 4812591 4705328 5019111 8218228 * @summary Test append and insert methods with CharSequence params * @key randomness */ @@ -230,6 +230,35 @@ throw new RuntimeException("CharSequence constructor failure"); } } + checkNegativeLenCharSeq(-1); + checkNegativeLenCharSeq(-16); + checkNegativeLenCharSeq(-17); + checkNegativeLenCharSeq(Integer.MIN_VALUE); } + // Test constructing from CharSequence of negative length + private static void checkNegativeLenCharSeq(int len) { + try { + CharSequence seq = new MyNegativeLenCharSeq(len); + StringBuffer sb = new StringBuffer(seq); + } catch (NegativeArraySizeException expected) { + } catch (Throwable exc) { + throw new RuntimeException("Unexpected: " + exc, exc); + } + } + + private static class MyNegativeLenCharSeq implements CharSequence { + int length; + MyNegativeLenCharSeq(int length) { + this.length = length; + } + public char charAt(int i) { + throw new UnsupportedOperationException(); + } + public int length() { return length; } + public CharSequence subSequence(int st, int e) { + throw new UnsupportedOperationException(); + } + public String toString() { return ""; } + } } diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/Basic-X.java.template --- a/test/jdk/java/nio/Buffer/Basic-X.java.template Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/Basic-X.java.template Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, ($type$[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + $Type$Buffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + $Type$Buffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + #if[byte] // Views diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/Basic.java --- a/test/jdk/java/nio/Buffer/Basic.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/Basic.java Sat Mar 09 12:54:20 2019 +0000 @@ -25,8 +25,8 @@ * @summary Unit test for buffers * @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725 * 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 5029431 - * 6231529 6221101 6234263 6535542 6591971 6593946 6795561 7190219 7199551 - * 8065556 8149469 + * 5071718 6231529 6221101 6234263 6535542 6591971 6593946 6795561 7190219 + * 7199551 8065556 8149469 * @modules java.base/java.nio:open * java.base/jdk.internal.misc * @author Mark Reinhold diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/BasicByte.java --- a/test/jdk/java/nio/Buffer/BasicByte.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/BasicByte.java Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, (byte[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + ByteBuffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + ByteBuffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + // Views diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/BasicChar.java --- a/test/jdk/java/nio/Buffer/BasicChar.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/BasicChar.java Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, (char[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + CharBuffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + CharBuffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/BasicDouble.java --- a/test/jdk/java/nio/Buffer/BasicDouble.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/BasicDouble.java Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, (double[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + DoubleBuffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + DoubleBuffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/BasicFloat.java --- a/test/jdk/java/nio/Buffer/BasicFloat.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/BasicFloat.java Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, (float[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + FloatBuffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + FloatBuffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/BasicInt.java --- a/test/jdk/java/nio/Buffer/BasicInt.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/BasicInt.java Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, (int[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + IntBuffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + IntBuffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/BasicLong.java --- a/test/jdk/java/nio/Buffer/BasicLong.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/BasicLong.java Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, (long[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + LongBuffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + LongBuffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/BasicShort.java --- a/test/jdk/java/nio/Buffer/BasicShort.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/BasicShort.java Sat Mar 09 12:54:20 2019 +0000 @@ -648,7 +648,7 @@ } } - // Exceptions in absolute bulk operations + // Exceptions in absolute bulk and slice operations catchNullArgument(b, () -> b.get(7, null, 0, 42)); catchNullArgument(b, () -> b.put(7, (short[])null, 0, 42)); @@ -668,6 +668,11 @@ catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1)); catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42)); + catchIndexOutOfBounds(b, () -> b.slice(-1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(b.limit() + 1, 7)); + catchIndexOutOfBounds(b, () -> b.slice(0, -1)); + catchIndexOutOfBounds(b, () -> b.slice(7, b.limit() - 7 + 1)); + // Values b.clear(); @@ -832,6 +837,20 @@ + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2); } + int bPos = b.position(); + int bLim = b.limit(); + + b.position(7); + b.limit(42); + ShortBuffer rsb = b.slice(); + b.position(0); + b.limit(b.capacity()); + ShortBuffer asb = b.slice(7, 35); + checkSlice(rsb, asb); + + b.position(bPos); + b.limit(bLim); + diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/ByteBufferViews.java --- a/test/jdk/java/nio/Buffer/ByteBufferViews.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/ByteBufferViews.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -64,6 +64,8 @@ size -> ByteBuffer.allocate(size).position(8).slice()), Map.entry("ByteBuffer.allocate(size).position(8).slice().duplicate()", size -> ByteBuffer.allocate(size).position(8).slice().duplicate()), + Map.entry("ByteBuffer.allocate(size).slice(8,size-8)", + size -> ByteBuffer.allocate(size).slice(8,size-8)), // Unaligned Map.entry("ByteBuffer.allocate(size).position(1)", size -> ByteBuffer.allocate(size).position(1)), @@ -71,6 +73,8 @@ size -> ByteBuffer.allocate(size).position(1).slice()), Map.entry("ByteBuffer.allocate(size).position(1).slice().duplicate()", size -> ByteBuffer.allocate(size).position(1).slice().duplicate()), + Map.entry("ByteBuffer.allocate(size).slice(1,size-1)", + size -> ByteBuffer.allocate(size).slice(1,size-1)), // Off-heap Map.entry("ByteBuffer.allocateDirect(size)", @@ -82,13 +86,17 @@ size -> ByteBuffer.allocateDirect(size).position(8).slice()), Map.entry("ByteBuffer.allocateDirect(size).position(8).slice().duplicate()", size -> ByteBuffer.allocateDirect(size).position(8).slice().duplicate()), + Map.entry("ByteBuffer.allocateDirect(size).slice(8,size-8)", + size -> ByteBuffer.allocateDirect(size).slice(8,size-8)), // Unaligned Map.entry("ByteBuffer.allocateDirect(size).position(1)", size -> ByteBuffer.allocateDirect(size).position(1)), Map.entry("ByteBuffer.allocateDirect(size).position(1).slice()", size -> ByteBuffer.allocateDirect(size).position(1).slice()), Map.entry("ByteBuffer.allocateDirect(size).position(1).slice().duplicate()", - size -> ByteBuffer.allocateDirect(size).position(1).slice().duplicate()) + size -> ByteBuffer.allocateDirect(size).position(1).slice().duplicate()), + Map.entry("ByteBuffer.allocateDirect(size).slice(1,size-1)", + size -> ByteBuffer.allocateDirect(size).slice(1,size-1)) ); // List of buffer byte order functions diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/nio/Buffer/StringCharBufferSliceTest.java --- a/test/jdk/java/nio/Buffer/StringCharBufferSliceTest.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/nio/Buffer/StringCharBufferSliceTest.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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,11 +22,14 @@ */ /* @test - * @bug 4997655 7000913 + * @bug 4997655 5071718 7000913 * @summary (bf) CharBuffer.slice() on wrapped CharSequence results in wrong position */ -import java.nio.*; +import java.nio.CharBuffer; +import java.nio.InvalidMarkException; +import java.util.function.BiConsumer; +import java.util.function.Consumer; public class StringCharBufferSliceTest { public static void main( String[] args) throws Exception { @@ -40,85 +43,114 @@ CharBuffer buff = CharBuffer.wrap(in); test(buff, buff.slice()); + test(buff, buff.slice(0, buff.remaining())); System.out.println( ">>> StringCharBufferSliceTest-main: testing with new position."); buff.position(2); test(buff, buff.slice()); + test(buff, buff.slice(2, buff.remaining())); System.out.println( ">>> StringCharBufferSliceTest-main: testing with non zero initial position."); buff = CharBuffer.wrap(in, 3, in.length()); test(buff, buff.slice()); + test(buff, buff.slice(0, buff.remaining())); System.out.println( ">>> StringCharBufferSliceTest-main: testing slice result with get()"); buff.position(4); buff.limit(7); - CharBuffer slice = buff.slice(); - for (int i = 0; i < 3; i++) { - if (slice.get() != buff.get()) { - throw new RuntimeException("Wrong characters in slice result."); + BiConsumer bitest = (b, s) -> { + for (int i = 0; i < 3; i++) { + if (s.get() != b.get()) { + throw new RuntimeException + ("Wrong characters in slice result."); + } } - } + }; + bitest.accept(buff, buff.slice()); + buff.position(4); + bitest.accept(buff, buff.slice(4, 3)); System.out.println( ">>> StringCharBufferSliceTest-main: testing slice result with get(int)"); buff.position(4); buff.limit(7); - slice = buff.slice(); - for (int i = 0; i < 3; i++) { - if (slice.get(i) != buff.get(4 + i)) { - throw new RuntimeException("Wrong characters in slice result."); + bitest = (b, s) -> { + for (int i = 0; i < 3; i++) { + if (s.get(i) != b.get(4 + i)) { + throw new RuntimeException + ("Wrong characters in slice result."); + } } - } + }; + bitest.accept(buff, buff.slice()); + buff.position(4); + bitest.accept(buff, buff.slice(4, 3)); System.out.println( ">>> StringCharBufferSliceTest-main: testing slice with result of slice"); buff.position(0); buff.limit(buff.capacity()); - slice = buff.slice(); - for (int i=0; i<4; i++) { - slice.position(i); - CharBuffer nextSlice = slice.slice(); - if (nextSlice.position() != 0) - throw new RuntimeException("New buffer's position should be zero"); - if (!nextSlice.equals(slice)) - throw new RuntimeException("New buffer should be equal"); - slice = nextSlice; - } + Consumer test = (s) -> { + for (int i=0; i<4; i++) { + s.position(i); + CharBuffer nextSlice = s.slice(); + if (nextSlice.position() != 0) + throw new RuntimeException + ("New buffer's position should be zero"); + if (!nextSlice.equals(s)) + throw new RuntimeException("New buffer should be equal"); + s = nextSlice; + } + }; + test.accept(buff.slice()); + test.accept(buff.slice(0, buff.capacity())); System.out.println( ">>> StringCharBufferSliceTest-main: testing toString."); buff.position(4); buff.limit(7); - slice = buff.slice(); - if (!slice.toString().equals("tes")) { - throw new RuntimeException("bad toString() after slice(): " + slice.toString()); - } + test = (s) -> { + if (!s.toString().equals("tes")) { + throw new RuntimeException + ("bad toString() after slice(): " + s.toString()); + } + }; + test.accept(buff.slice()); + test.accept(buff.slice(4, 3)); System.out.println( ">>> StringCharBufferSliceTest-main: testing subSequence."); buff.position(4); buff.limit(8); - slice = buff.slice(); - CharSequence subSeq = slice.subSequence(1, 3); - if (subSeq.charAt(0) != 'e' || subSeq.charAt(1) != 's') { - throw new RuntimeException("bad subSequence() after slice(): '" + subSeq + "'"); - } + test = (s) -> { + CharSequence subSeq = s.subSequence(1, 3); + if (subSeq.charAt(0) != 'e' || subSeq.charAt(1) != 's') { + throw new RuntimeException + ("bad subSequence() after slice(): '" + subSeq + "'"); + } + }; + test.accept(buff.slice()); + test.accept(buff.slice(4, 4)); System.out.println( ">>> StringCharBufferSliceTest-main: testing duplicate."); buff.position(4); buff.limit(8); - slice = buff.slice(); - CharBuffer dupe = slice.duplicate(); - if (dupe.charAt(0) != 't' || dupe.charAt(1) != 'e' - || dupe.charAt(2) != 's' || dupe.charAt(3) != 't') { - throw new RuntimeException("bad duplicate() after slice(): '" + dupe + "'"); - } + test = (s) -> { + CharBuffer dupe = s.duplicate(); + if (dupe.charAt(0) != 't' || dupe.charAt(1) != 'e' + || dupe.charAt(2) != 's' || dupe.charAt(3) != 't') { + throw new RuntimeException + ("bad duplicate() after slice(): '" + dupe + "'"); + } + }; + test.accept(buff.slice()); + test.accept(buff.slice(4, 4)); System.out.println(">>> StringCharBufferSliceTest-main: done!"); } diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/security/BasicPermission/Wildcard.java --- a/test/jdk/java/security/BasicPermission/Wildcard.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/security/BasicPermission/Wildcard.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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,8 +33,7 @@ * @summary Check that BasicPermission subclasses don't throw exception if name * contains wildcard character ("*") but does not signify a * wildcard match - * @modules java.base/com.sun.net.ssl - * java.sql + * @modules java.sql */ public class Wildcard { @@ -51,6 +50,5 @@ new SQLPermission(wildcard); new PropertyPermission(wildcard, "read"); new SSLPermission(wildcard); - new com.sun.net.ssl.SSLPermission(wildcard); } } diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,368 @@ +/* + * Copyright (c) 2019, 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 8218948 + * @summary TCK tests that check the time zone names between DFS.getZoneStrings() + * and SDF.format("z*") + * @run main SDFTCKZoneNamesTest + */ +import java.text.*; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +public class SDFTCKZoneNamesTest { + + StringBuffer myFormat(Date date, SimpleDateFormat sdf) { + String pattern = sdf.toPattern(); + StringBuffer toAppendTo = new StringBuffer(""); + boolean inQuote = false; + char prevCh = 0; + char ch; + int count = 0; + for (int i = 0; i < pattern.length(); i++) { + ch = pattern.charAt(i); + if (inQuote) { + if (ch == '\'') { + inQuote = false; + if (count == 0) toAppendTo.append(ch); + else count = 0; + } else { + toAppendTo.append(ch); + count++; + } + } else { // not inQuote + if (ch == '\'') { + inQuote = true; + if (count > 0) { + toAppendTo.append(subFormat(prevCh, count, date, sdf)); + count = 0; + prevCh = 0; + } + } else if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') { + if (ch != prevCh && count > 0) { + toAppendTo.append(subFormat(prevCh, count, date, sdf)); + prevCh = ch; + count = 1; + } else { + if (ch != prevCh) prevCh = ch; + count++; + } + } else if (count > 0) { + toAppendTo.append(subFormat(prevCh, count, date, sdf)); + toAppendTo.append(ch); + prevCh = 0; + count = 0; + } else toAppendTo.append(ch); + } + } + if (count > 0) { + toAppendTo.append(subFormat(prevCh, count, date, sdf)); + } + return toAppendTo; + } + + private String subFormat(char ch, int count, Date date, SimpleDateFormat sdf) + throws IllegalArgumentException { + int value = 0; + int patternCharIndex = -1; + int maxIntCount = 10; + String current = ""; + DateFormatSymbols formatData = sdf.getDateFormatSymbols(); + Calendar calendar = sdf.getCalendar(); + calendar.setTime(date); + NumberFormat nf = sdf.getNumberFormat(); + nf.setGroupingUsed(false); + + if ((patternCharIndex = "GyMdkHmsSEDFwWahKz".indexOf(ch)) == -1) + throw new IllegalArgumentException("Illegal pattern character " + + "'" + ch + "'"); + switch (patternCharIndex) { + case 0: // 'G' - ERA + value = calendar.get(Calendar.ERA); + current = formatData.getEras()[value]; + break; + case 1: // 'y' - YEAR + value = calendar.get(Calendar.YEAR); + + if (count == 2) { + // For formatting, if the number of pattern letters is 2, + // the year is truncated to 2 digits; + current = zeroPaddingNumber(value, 2, 2, nf); + } else { + // otherwise it is interpreted as a number. + current = zeroPaddingNumber(value, count, maxIntCount, nf); + } + + break; + case 2: // 'M' - MONTH + value = calendar.get(Calendar.MONTH); + if (count >= 4) + // DateFormatSymbols::getMonths spec: "If the language requires different forms for formatting + // and stand-alone usages, this method returns month names in the formatting form." + // Because of that only formatting cases patterns may be tested. Like, "MMMM yyyy". Wrong + // pattern: "MMMM". + current = formatData.getMonths()[value]; + else if (count == 3) + // DateFormatSymbols::getShortMonths spec: "If the language requires different forms for formatting + // and stand-alone usages, This method returns short month names in the formatting form." + // Because of that only formatting cases patterns may be tested. Like, "MMM yyyy". Wrong pattern: + // "MMM". + current = formatData.getShortMonths()[value]; + else + current = zeroPaddingNumber(value + 1, count, maxIntCount, nf); + break; + case 3: // 'd' - DATE + value = calendar.get(Calendar.DATE); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 4: // 'k' - HOUR_OF_DAY: 1-based. eg, 23:59 + 1 hour =>> 24:59 + if ((value = calendar.get(Calendar.HOUR_OF_DAY)) == 0) + current = zeroPaddingNumber( + calendar.getMaximum(Calendar.HOUR_OF_DAY) + 1, + count, maxIntCount, nf); + else + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 5: // 'H' - HOUR_OF_DAY:0-based. eg, 23:59 + 1 hour =>> 00:59 + value = calendar.get(Calendar.HOUR_OF_DAY); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 6: // 'm' - MINUTE + value = calendar.get(Calendar.MINUTE); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 7: // 's' - SECOND + value = calendar.get(Calendar.SECOND); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 8: // 'S' - MILLISECOND + value = calendar.get(Calendar.MILLISECOND); + /* + if (count > 3) + value = value * (int) Math.pow(10, count - 3); + else if (count == 2) + value = (value + 5) / 10; + else if (count == 1) + value = (value + 50) / 100; + */ + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 9: // 'E' - DAY_OF_WEEK + value = calendar.get(Calendar.DAY_OF_WEEK); + if (count >= 4) + current = formatData.getWeekdays()[value]; + else // count < 4, use abbreviated form if exists + current = formatData.getShortWeekdays()[value]; + break; + case 10: // 'D' - DAY_OF_YEAR + value = calendar.get(Calendar.DAY_OF_YEAR); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 11: // 'F' - DAY_OF_WEEK_IN_MONTH + value = calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 12: // 'w' - WEEK_OF_YEAR + value = calendar.get(Calendar.WEEK_OF_YEAR); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 13: // 'W' - WEEK_OF_MONTH + value = calendar.get(Calendar.WEEK_OF_MONTH); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 14: // 'a' - AM_PM + value = calendar.get(Calendar.AM_PM); + current = formatData.getAmPmStrings()[value]; + break; + case 15: // 'h' - HOUR:1-based. eg, 11PM + 1 hour =>> 12 AM + if ((value = calendar.get(Calendar.HOUR)) == 0) + current = zeroPaddingNumber( + calendar.getLeastMaximum(Calendar.HOUR) + 1, + count, maxIntCount, nf); + else + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 16: // 'K' - HOUR: 0-based. eg, 11PM + 1 hour =>> 0 AM + value = calendar.get(Calendar.HOUR); + current = zeroPaddingNumber(value, count, maxIntCount, nf); + break; + case 17: // 'z' - ZONE_OFFSET + int zoneIndex = getZoneIndex(calendar.getTimeZone().getID(), formatData); + if (zoneIndex == -1) { + StringBuffer zoneString = new StringBuffer(); + value = calendar.get(Calendar.ZONE_OFFSET) + + calendar.get(Calendar.DST_OFFSET); + if (value < 0) { + zoneString.append("GMT-"); + value = -value; // suppress the '-' sign for text display. + } else + zoneString.append("GMT+"); + zoneString.append( + zeroPaddingNumber((int) (value / (60 * 60 * 1000)), 2, 2, nf)); + zoneString.append(':'); + zoneString.append( + zeroPaddingNumber( + (int) ((value % (60 * 60 * 1000)) / (60 * 1000)), 2, 2, nf)); + current = zoneString.toString(); + } else if (calendar.get(Calendar.DST_OFFSET) != 0) { + if (count >= 4) + current = formatData.getZoneStrings()[zoneIndex][3]; + else + // count < 4, use abbreviated form if exists + current = formatData.getZoneStrings()[zoneIndex][4]; + } else { + if (count >= 4) + current = formatData.getZoneStrings()[zoneIndex][1]; + else + current = formatData.getZoneStrings()[zoneIndex][2]; + } + break; + } + + return current; + } + + + String zeroPaddingNumber(long value, int minDigits, int maxDigits, + NumberFormat nf) { + nf.setMinimumIntegerDigits(minDigits); + nf.setMaximumIntegerDigits(maxDigits); + return nf.format(value); + } + + + int getZoneIndex(String ID, DateFormatSymbols dfs) { + String[][] zoneStrings = dfs.getZoneStrings(); + + for (int index = 0; index < zoneStrings.length; index++) { + if (ID.equalsIgnoreCase(zoneStrings[index][0])) return index; + } + return -1; + } + + + final int second = 1000; + final int minute = 60 * second; + final int hour = 60 * minute; + final int day = 24 * hour; + final int month = 30 * day; + final int year = 365 * day; + final int someday = 30 * year + 3 * month + 19 * day + 5 * hour; + + + /* standalone interface */ + public static void main(String argv[]) { + Locale defaultLocale = Locale.getDefault(); + SDFTCKZoneNamesTest test = new SDFTCKZoneNamesTest(); + + try { + List.of(Locale.ROOT, + Locale.CHINA, + Locale.forLanguageTag("es-419"), + Locale.GERMANY, + Locale.forLanguageTag("hi-IN"), + Locale.JAPAN, + Locale.TAIWAN, + Locale.UK, + Locale.US, + Locale.forLanguageTag("uz-Cyrl-UZ"), + Locale.forLanguageTag("zh-SG"), + Locale.forLanguageTag("zh-HK"), + Locale.forLanguageTag("zh-MO")).stream() + .forEach(l -> { + System.out.printf("Testing locale: %s%n", l); + Locale.setDefault(l); + test.SimpleDateFormat0062(); + }); + } finally { + Locale.setDefault(defaultLocale); + } + } + + + /** + * Equivalence class partitioning + * with state, input and output values orientation + * for public StringBuffer format(Date date, StringBuffer result, FieldPosition fp), + *
    pre-conditions: patterns: { "'s0mething'z mm::hh,yyyy zz", + * "zzzz", + * "z"} (each pattern contains letter for TIMEZONE_FIELD), + *
    date: a Date object + *
    result: a string + *
    fp: a FieldPosition object with TIMEZONE_FIELD field + *
    output: formatted date as expected. + */ + public void SimpleDateFormat0062() { + boolean passed = true; + String patterns[] = {"'s0mething'z mm::hh,yyyy zz", + "zzzz", + "z"}; + SimpleDateFormat sdf = new SimpleDateFormat(); + Date date = new Date(1234567890); + for (String[] tz : sdf.getDateFormatSymbols().getZoneStrings()) { + sdf.setTimeZone(TimeZone.getTimeZone(tz[0])); + for (int i = 0; i < patterns.length && passed; i++) { + StringBuffer result = new StringBuffer("qwerty"); + FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD); + sdf.applyPattern(patterns[i]); + String expected = new + StringBuffer("qwerty").append(myFormat(date, + sdf)).toString(); + String formatted = sdf.format(date, result, fp).toString(); + + if (!expected.equals(formatted)) { + System.out.println( + "method format(date, StringBuffer, FieldPosition) formats wrong"); + System.out.println(" pattern: " + patterns[i]); + System.out.println(" time zone ID: " + tz[0]); + System.out.println(" expected result: " + expected); + System.out.println(" formatted result: " + formatted); + passed = false; + } + + if (passed && !expected.equals(result.toString())) { + System.out.println( + "method format(Date date, StringBuffer toAppendTo, FieldPosition fp) toAppendTo is not " + + "equal to output"); + System.out.println(" pattern: " + patterns[i]); + System.out.println(" time zone ID: " + tz[0]); + System.out.println(" toAppendTo : " + result); + System.out.println(" formatted date: " + formatted); + passed = false; + } + } + } + if(passed) + { + System.out.println("PASSED : OKAY"); + }else + { + throw new RuntimeException("FAILED"); + } + } +} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/java/util/Calendar/JapaneseEraNameTest.java --- a/test/jdk/java/util/Calendar/JapaneseEraNameTest.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/java/util/Calendar/JapaneseEraNameTest.java Sat Mar 09 12:54:20 2019 +0000 @@ -23,7 +23,7 @@ /* * @test - * @bug 8202088 8207152 8217609 + * @bug 8202088 8207152 8217609 8219890 * @summary Test the localized Japanese new era name (May 1st. 2019-) * is retrieved no matter CLDR provider contains the name or not. * @modules jdk.localedata @@ -53,8 +53,10 @@ // type, locale, name { LONG, JAPAN, "\u5143\u53f7" }, // NewEra { LONG, US, "NewEra" }, + { LONG, CHINA, "NewEra" }, { SHORT, JAPAN, "\u5143\u53f7" }, { SHORT, US, "NewEra" }, + { SHORT, CHINA, "N" }, }; } diff -r 3e39753ed05b -r b38f280d2114 test/jdk/javax/net/ssl/FixingJavadocs/ComURLNulls.java --- a/test/jdk/javax/net/ssl/FixingJavadocs/ComURLNulls.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 4387882 4451038 - * @summary Need to revisit the javadocs for JSSE, especially the - * promoted classes, and HttpsURLConnection.getCipherSuite throws - * NullPointerException - * @modules java.base/com.sun.net.ssl - * java.base/com.sun.net.ssl.internal.www.protocol.https - * @run main/othervm ComURLNulls - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * @author Brad Wetmore - */ - -import java.net.*; -import java.io.*; -import javax.net.ssl.*; -import com.sun.net.ssl.HttpsURLConnection; -import com.sun.net.ssl.HostnameVerifier; - -/* - * Tests that the com null argument changes made it in ok. - */ - -public class ComURLNulls { - - private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory { - private static String SUPPORTED_PROTOCOL = "https"; - - public URLStreamHandler createURLStreamHandler(String protocol) { - if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL)) - return null; - - return new com.sun.net.ssl.internal.www.protocol.https.Handler(); - } - } - - public static void main(String[] args) throws Exception { - HostnameVerifier reservedHV = - HttpsURLConnection.getDefaultHostnameVerifier(); - try { - URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory()); - - /** - * This test does not establish any connection to the specified - * URL, hence a dummy URL is used. - */ - URL foobar = new URL("https://example.com/"); - - HttpsURLConnection urlc = - (HttpsURLConnection) foobar.openConnection(); - - try { - urlc.getCipherSuite(); - } catch (IllegalStateException e) { - System.out.print("Caught proper exception: "); - System.out.println(e.getMessage()); - } - - try { - urlc.getServerCertificates(); - } catch (IllegalStateException e) { - System.out.print("Caught proper exception: "); - System.out.println(e.getMessage()); - } - - try { - urlc.setDefaultHostnameVerifier(null); - } catch (IllegalArgumentException e) { - System.out.print("Caught proper exception: "); - System.out.println(e.getMessage()); - } - - try { - urlc.setHostnameVerifier(null); - } catch (IllegalArgumentException e) { - System.out.print("Caught proper exception: "); - System.out.println(e.getMessage()); - } - - try { - urlc.setDefaultSSLSocketFactory(null); - } catch (IllegalArgumentException e) { - System.out.print("Caught proper exception: "); - System.out.println(e.getMessage()); - } - - try { - urlc.setSSLSocketFactory(null); - } catch (IllegalArgumentException e) { - System.out.print("Caught proper exception"); - System.out.println(e.getMessage()); - } - System.out.println("TESTS PASSED"); - } finally { - HttpsURLConnection.setDefaultHostnameVerifier(reservedHV); - } - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/javax/net/ssl/GetInstance.java --- a/test/jdk/javax/net/ssl/GetInstance.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/javax/net/ssl/GetInstance.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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,7 +27,6 @@ * @summary verify getInstance() works using Provider.getService() * Export "PKIX" as the standard algorithm name of KeyManagerFactory * @author Andreas Sterbenz - * @modules java.base/com.sun.net.ssl */ import java.security.*; @@ -113,38 +112,7 @@ tmf = TrustManagerFactory.getInstance("X.509", p); same(p, tmf.getProvider()); - testComSun(); - long stop = System.currentTimeMillis(); System.out.println("Done (" + (stop - start) + " ms)."); } - - private static void testComSun() throws Exception { - Provider p = Security.getProvider("SunJSSE"); - - com.sun.net.ssl.SSLContext context; - context = com.sun.net.ssl.SSLContext.getInstance("SSL"); - same(p, context.getProvider()); - context = com.sun.net.ssl.SSLContext.getInstance("SSL", "SunJSSE"); - same(p, context.getProvider()); - context = com.sun.net.ssl.SSLContext.getInstance("SSL", p); - same(p, context.getProvider()); - - com.sun.net.ssl.KeyManagerFactory kmf; - kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509"); - same(p, kmf.getProvider()); - kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509", "SunJSSE"); - same(p, kmf.getProvider()); - kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509", p); - same(p, kmf.getProvider()); - - com.sun.net.ssl.TrustManagerFactory tmf; - tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509"); - same(p, tmf.getProvider()); - tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509", "SunJSSE"); - same(p, tmf.getProvider()); - tmf = com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509", p); - same(p, tmf.getProvider()); - } - } diff -r 3e39753ed05b -r b38f280d2114 test/jdk/javax/net/ssl/SSLSession/CheckMyTrustedKeystore.java --- a/test/jdk/javax/net/ssl/SSLSession/CheckMyTrustedKeystore.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,407 +0,0 @@ -/* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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. - */ - -// SunJSSE does not support dynamic system properties, no way to re-use -// system properties in samevm/agentvm mode. - -/* - * @test - * @bug 4329114 - * @summary Need better way of reflecting the reason when a chain is - * rejected as untrusted. - * @modules java.base/com.sun.net.ssl - * @ignore JSSE supports algorithm constraints with CR 6916074, - * need to update this test case in JDK 7 soon - * @run main/othervm CheckMyTrustedKeystore - * - * @author Brad Wetmore - */ - -// This is a serious hack job! - -import java.io.*; -import java.net.*; -import java.security.*; -import javax.net.ssl.*; -import java.security.cert.*; - -public class CheckMyTrustedKeystore { - - /* - * ============================================================= - * Set the various variables needed for the tests, then - * specify what tests to run on each side. - */ - - /* - * Should we run the client or server in a separate thread? - * Both sides can throw exceptions, but do you have a preference - * as to which side should be the main thread. - */ - static boolean separateServerThread = true; - - /* - * Where do we find the keystores? - */ - final static String pathToStores = "../etc"; - final static String keyStoreFile = "keystore"; - final static String trustStoreFile = "truststore"; - final static String unknownStoreFile = "unknown_keystore"; - final static String passwd = "passphrase"; - final static char[] cpasswd = "passphrase".toCharArray(); - - /* - * Is the server ready to serve? - */ - volatile static boolean serverReady = false; - - /* - * Turn on SSL debugging? - */ - final static boolean debug = false; - - /* - * If the client or server is doing some kind of object creation - * that the other side depends on, and that thread prematurely - * exits, you may experience a hang. The test harness will - * terminate all hung threads after its timeout has expired, - * currently 3 minutes by default, but you might try to be - * smart about it.... - */ - - /* - * Define the server side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doServerSide() throws Exception { - KeyStore ks = KeyStore.getInstance("JKS"); - com.sun.net.ssl.SSLContext ctx = - com.sun.net.ssl.SSLContext.getInstance("TLS"); - com.sun.net.ssl.KeyManagerFactory kmf = - com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509"); - - ks.load(new FileInputStream(keyFilename), cpasswd); - kmf.init(ks, cpasswd); - - com.sun.net.ssl.TrustManager [] tms = - new com.sun.net.ssl.TrustManager [] - { new MyComX509TrustManager() }; - - ctx.init(kmf.getKeyManagers(), tms, null); - - SSLServerSocketFactory sslssf = - (SSLServerSocketFactory) ctx.getServerSocketFactory(); - - SSLServerSocket sslServerSocket = - (SSLServerSocket) sslssf.createServerSocket(serverPort); - serverPort = sslServerSocket.getLocalPort(); - - sslServerSocket.setNeedClientAuth(true); - - /* - * Create using the other type. - */ - SSLContext ctx1 = - SSLContext.getInstance("TLS"); - KeyManagerFactory kmf1 = - KeyManagerFactory.getInstance("SunX509"); - - TrustManager [] tms1 = - new TrustManager [] - { new MyJavaxX509TrustManager() }; - - kmf1.init(ks, cpasswd); - - ctx1.init(kmf1.getKeyManagers(), tms1, null); - - sslssf = (SSLServerSocketFactory) ctx1.getServerSocketFactory(); - - SSLServerSocket sslServerSocket1 = - (SSLServerSocket) sslssf.createServerSocket(serverPort1); - serverPort1 = sslServerSocket1.getLocalPort(); - sslServerSocket1.setNeedClientAuth(true); - - /* - * Signal Client, we're ready for his connect. - */ - serverReady = true; - - SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); - sslServerSocket.close(); - serverReady = false; - - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream(); - - sslIS.read(); - sslOS.write(85); - sslOS.flush(); - sslSocket.close(); - - sslSocket = (SSLSocket) sslServerSocket1.accept(); - sslIS = sslSocket.getInputStream(); - sslOS = sslSocket.getOutputStream(); - - sslIS.read(); - sslOS.write(85); - sslOS.flush(); - sslSocket.close(); - - System.out.println("Server exiting!"); - System.out.flush(); - } - - void doTest(SSLSocket sslSocket) throws Exception { - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream(); - - System.out.println(" Writing"); - sslOS.write(280); - sslOS.flush(); - System.out.println(" Reading"); - sslIS.read(); - - sslSocket.close(); - } - - /* - * Define the client side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doClientSide() throws Exception { - - /* - * Wait for server to get started. - */ - while (!serverReady) { - Thread.sleep(50); - } - - /* - * See if an unknown keystore actually gets checked ok. - */ - System.out.println("=============="); - System.out.println("Starting test0"); - KeyStore uks = KeyStore.getInstance("JKS"); - SSLContext ctx = - SSLContext.getInstance("TLS"); - KeyManagerFactory kmf = - KeyManagerFactory.getInstance("SunX509"); - - uks.load(new FileInputStream(unknownFilename), cpasswd); - kmf.init(uks, cpasswd); - - TrustManager [] tms = new TrustManager [] - { new MyJavaxX509TrustManager() }; - - ctx.init(kmf.getKeyManagers(), tms, null); - - SSLSocketFactory sslsf = - (SSLSocketFactory) ctx.getSocketFactory(); - - System.out.println("Trying first socket " + serverPort); - SSLSocket sslSocket = (SSLSocket) - sslsf.createSocket("localhost", serverPort); - - doTest(sslSocket); - - /* - * Now try the other way. - */ - com.sun.net.ssl.SSLContext ctx1 = - com.sun.net.ssl.SSLContext.getInstance("TLS"); - com.sun.net.ssl.KeyManagerFactory kmf1 = - com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509"); - kmf1.init(uks, cpasswd); - - com.sun.net.ssl.TrustManager [] tms1 = - new com.sun.net.ssl.TrustManager [] - { new MyComX509TrustManager() }; - - ctx1.init(kmf1.getKeyManagers(), tms1, null); - - sslsf = (SSLSocketFactory) ctx1.getSocketFactory(); - - System.out.println("Trying second socket " + serverPort1); - sslSocket = (SSLSocket) sslsf.createSocket("localhost", - serverPort1); - - doTest(sslSocket); - System.out.println("Completed test1"); - } - - /* - * ============================================================= - * The remainder is just support stuff - */ - - int serverPort = 0; - int serverPort1 = 0; - - volatile Exception serverException = null; - volatile Exception clientException = null; - - final static String keyFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + keyStoreFile; - final static String unknownFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + unknownStoreFile; - - public static void main(String[] args) throws Exception { - - if (debug) - System.setProperty("javax.net.debug", "all"); - - /* - * Start the tests. - */ - new CheckMyTrustedKeystore(); - } - - Thread clientThread = null; - Thread serverThread = null; - - /* - * Primary constructor, used to drive remainder of the test. - * - * Fork off the other side, then do your work. - */ - CheckMyTrustedKeystore() throws Exception { - if (separateServerThread) { - startServer(true); - startClient(false); - } else { - startClient(true); - startServer(false); - } - - /* - * Wait for other side to close down. - */ - if (separateServerThread) { - serverThread.join(); - } else { - clientThread.join(); - } - - /* - * When we get here, the test is pretty much over. - * - * If the main thread excepted, that propagates back - * immediately. If the other thread threw an exception, we - * should report back. - */ - if (serverException != null) { - System.out.print("Server Exception:"); - throw serverException; - } - if (clientException != null) { - System.out.print("Client Exception:"); - throw clientException; - } - } - - void startServer(boolean newThread) throws Exception { - if (newThread) { - serverThread = new Thread() { - public void run() { - try { - doServerSide(); - } catch (Exception e) { - /* - * Our server thread just died. - * - * Release the client, if not active already... - */ - System.err.println("Server died..."); - serverReady = true; - serverException = e; - } - } - }; - serverThread.start(); - } else { - doServerSide(); - } - } - - void startClient(boolean newThread) throws Exception { - if (newThread) { - clientThread = new Thread() { - public void run() { - try { - doClientSide(); - } catch (Exception e) { - /* - * Our client thread just died. - */ - System.err.println("Client died..."); - clientException = e; - } - } - }; - clientThread.start(); - } else { - doClientSide(); - } - } -} - -class MyComX509TrustManager implements com.sun.net.ssl.X509TrustManager { - - public X509Certificate[] getAcceptedIssuers() { - return (new X509Certificate[0]); - } - - public boolean isClientTrusted(X509Certificate[] chain) { - System.out.println(" IsClientTrusted?"); - return true; - } - - public boolean isServerTrusted(X509Certificate[] chain) { - System.out.println(" IsServerTrusted?"); - return true; - } -} - -class MyJavaxX509TrustManager implements X509TrustManager { - - public X509Certificate[] getAcceptedIssuers() { - return (new X509Certificate[0]); - } - - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - System.out.println(" CheckClientTrusted(" + authType + ")?"); - } - - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - System.out.println(" CheckServerTrusted(" + authType + ")?"); - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/javax/xml/crypto/dsig/GenerationTests.java --- a/test/jdk/javax/xml/crypto/dsig/GenerationTests.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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,7 +24,7 @@ /** * @test * @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349 8046949 - * 8046724 8079693 8177334 8205507 8210736 + * 8046724 8079693 8177334 8205507 8210736 8217878 * @summary Basic unit tests for generating XML Signatures with JSR 105 * @modules java.base/sun.security.util * java.base/sun.security.x509 @@ -126,8 +126,12 @@ private final static String CRL = DATA_DIR + System.getProperty("file.separator") + "certs" + System.getProperty("file.separator") + "crl"; + // XML Document with a DOCTYPE declaration private final static String ENVELOPE = DATA_DIR + System.getProperty("file.separator") + "envelope.xml"; + // XML Document without a DOCTYPE declaration + private final static String ENVELOPE2 = + DATA_DIR + System.getProperty("file.separator") + "envelope2.xml"; private static URIDereferencer httpUd = null; private final static String STYLESHEET = "http://www.w3.org/TR/xml-stylesheet"; @@ -328,6 +332,10 @@ test_create_signature_reference_dependency(); test_create_signature_with_attr_in_no_namespace(); test_create_signature_with_empty_id(); + test_create_signature_enveloping_over_doc(ENVELOPE, true); + test_create_signature_enveloping_over_doc(ENVELOPE2, true); + test_create_signature_enveloping_over_doc(ENVELOPE, false); + test_create_signature_enveloping_dom_level1(); // run tests for detached signatures with local http server try (Http server = Http.startServer()) { @@ -1038,6 +1046,109 @@ "signature", null); DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 512), doc); sig.sign(dsc); + + System.out.println(); + } + + static void test_create_signature_enveloping_over_doc(String filename, + boolean pass) throws Exception + { + System.out.println("* Generating signature-enveloping-over-doc.xml"); + + // create reference + Reference ref = fac.newReference("#object", sha256); + + // create SignedInfo + SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha256, + Collections.singletonList(ref)); + + // create object + Document doc = null; + try (FileInputStream fis = new FileInputStream(filename)) { + doc = db.parse(fis); + } + DOMStructure ds = pass ? new DOMStructure(doc.getDocumentElement()) + : new DOMStructure(doc); + XMLObject obj = fac.newXMLObject(Collections.singletonList(ds), + "object", null, "UTF-8"); + + // This creates an enveloping signature over the entire XML Document + XMLSignature sig = fac.newXMLSignature(si, rsa, + Collections.singletonList(obj), + "signature", null); + DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 1024), doc); + try { + sig.sign(dsc); + if (!pass) { + // A Document node can only exist at the root of the doc so this + // should fail + throw new Exception("Test unexpectedly passed"); + } + } catch (Exception e) { + if (!pass) { + System.out.println("Test failed as expected: " + e); + } else { + throw e; + } + } + + if (pass) { + DOMValidateContext dvc = new DOMValidateContext + (getPublicKey("RSA", 1024), doc.getDocumentElement()); + XMLSignature sig2 = fac.unmarshalXMLSignature(dvc); + + if (sig.equals(sig2) == false) { + throw new Exception + ("Unmarshalled signature is not equal to generated signature"); + } + if (sig2.validate(dvc) == false) { + throw new Exception("Validation of generated signature failed"); + } + } + + System.out.println(); + } + + static void test_create_signature_enveloping_dom_level1() throws Exception { + System.out.println("* Generating signature-enveloping-dom-level1.xml"); + + // create reference + Reference ref = fac.newReference("#object", sha256); + + // create SignedInfo + SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha256, + Collections.singletonList(ref)); + + // create object using DOM Level 1 methods + Document doc = db.newDocument(); + Element child = doc.createElement("Child"); + child.setAttribute("Version", "1.0"); + child.setAttribute("Id", "child"); + child.setIdAttribute("Id", true); + child.appendChild(doc.createComment("Comment")); + XMLObject obj = fac.newXMLObject( + Collections.singletonList(new DOMStructure(child)), + "object", null, "UTF-8"); + + XMLSignature sig = fac.newXMLSignature(si, rsa, + Collections.singletonList(obj), + "signature", null); + DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 1024), doc); + sig.sign(dsc); + + DOMValidateContext dvc = new DOMValidateContext + (getPublicKey("RSA", 1024), doc.getDocumentElement()); + XMLSignature sig2 = fac.unmarshalXMLSignature(dvc); + + if (sig.equals(sig2) == false) { + throw new Exception + ("Unmarshalled signature is not equal to generated signature"); + } + if (sig2.validate(dvc) == false) { + throw new Exception("Validation of generated signature failed"); + } + + System.out.println(); } static void test_create_signature() throws Exception { diff -r 3e39753ed05b -r b38f280d2114 test/jdk/javax/xml/crypto/dsig/data/envelope2.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/javax/xml/crypto/dsig/data/envelope2.xml Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,15 @@ + + + + foo + bar + + + bar + + + + + + + diff -r 3e39753ed05b -r b38f280d2114 test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest --- a/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest Sat Mar 09 12:54:20 2019 +0000 @@ -1,4 +1,4 @@ -FROM oraclelinux:7.2 +FROM oraclelinux:7.6 MAINTAINER mikhailo.seledtsov@oracle.com COPY /jdk /jdk diff -r 3e39753ed05b -r b38f280d2114 test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java --- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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,6 +24,7 @@ */ package jdk.jfr.jvm; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -54,48 +55,66 @@ private static final CharSequence LOG_FILE_EXTENSION = ".log"; private static final CharSequence JFR_FILE_EXTENSION = ".jfr"; - static class Crasher { + static class CrasherIllegalAccess { public static void main(String[] args) { Unsafe.getUnsafe().putInt(0L, 0); } } - public static void main(String[] args) throws Exception { - processOutput(runProcess()); + static class CrasherHalt { + public static void main(String[] args) { + System.out.println("Running Runtime.getRuntime.halt"); + Runtime.getRuntime().halt(17); + } + } + + static class CrasherSig { + public static void main(String[] args) throws Exception { + String signalName = args[0]; + System.out.println("Sending SIG" + signalName + " to process " + ProcessHandle.current().pid()); + Runtime.getRuntime().exec("kill -" + signalName + " " + ProcessHandle.current().pid()).waitFor(); + } } - private static OutputAnalyzer runProcess() throws Exception { - return new OutputAnalyzer( - ProcessTools.createJavaProcessBuilder(true, + public static void main(String[] args) throws Exception { + verify(runProcess(CrasherIllegalAccess.class.getName(), "")); + verify(runProcess(CrasherHalt.class.getName(), "")); + + // Verification is excluded for the test case below until 8219680 is fixed + long pid = runProcess(CrasherSig.class.getName(), "FPE"); + // @ignore 8219680 + // verify(pid); + } + + private static long runProcess(String crasher, String signal) throws Exception { + System.out.println("Test case for crasher " + crasher); + Process p = ProcessTools.createJavaProcessBuilder(true, "-Xmx64m", - "-Xint", "-XX:-CreateCoredumpOnCrash", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - "-XX:StartFlightRecording=dumponexit=true", - Crasher.class.getName()).start()); + "-XX:StartFlightRecording", + crasher, + signal) + .start(); + + OutputAnalyzer output = new OutputAnalyzer(p); + System.out.println("========== Crasher process output:"); + System.out.println(output.getOutput()); + System.out.println("=================================="); + + return p.pid(); } - private static void processOutput(OutputAnalyzer output) throws Exception { - output.shouldContain("CreateCoredumpOnCrash turned off, no core file dumped"); + private static void verify(long pid) throws IOException { + String fileName = "hs_err_pid" + pid + ".jfr"; + Path file = Paths.get(fileName).toAbsolutePath().normalize(); - final Path jfrEmergencyFilePath = getHsErrJfrPath(output); - Asserts.assertTrue(Files.exists(jfrEmergencyFilePath), "No emergency jfr recording file " + jfrEmergencyFilePath + " exists"); - Asserts.assertNotEquals(Files.size(jfrEmergencyFilePath), 0L, "File length 0. Should at least be some bytes"); - System.out.printf("File size=%d%n", Files.size(jfrEmergencyFilePath)); + Asserts.assertTrue(Files.exists(file), "No emergency jfr recording file " + file + " exists"); + Asserts.assertNotEquals(Files.size(file), 0L, "File length 0. Should at least be some bytes"); + System.out.printf("File size=%d%n", Files.size(file)); - List events = RecordingFile.readAllEvents(jfrEmergencyFilePath); + List events = RecordingFile.readAllEvents(file); Asserts.assertFalse(events.isEmpty(), "No event found"); System.out.printf("Found event %s%n", events.get(0).getEventType().getName()); } - - private static Path getHsErrJfrPath(OutputAnalyzer output) throws Exception { - // extract to find hs-err_pid log file location - final String hs_err_pid_log_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); - if (hs_err_pid_log_file == null) { - throw new RuntimeException("Did not find hs_err_pid.log file in output.\n"); - } - // the dumped out jfr file should have the same name and location but with a .jfr extension - final String hs_err_pid_jfr_file = hs_err_pid_log_file.replace(LOG_FILE_EXTENSION, JFR_FILE_EXTENSION); - return Paths.get(hs_err_pid_jfr_file); - } } diff -r 3e39753ed05b -r b38f280d2114 test/jdk/sun/net/www/protocol/https/HttpsURLConnection/CheckMethods.java --- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/CheckMethods.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/CheckMethods.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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,13 +26,12 @@ * @bug 4423074 * @summary Need to rebase all the duplicated classes from Merlin. * This test will check out http POST - * @modules java.base/sun.net.www.protocol.https java.base/com.sun.net.ssl.internal.www.protocol.https + * @modules java.base/sun.net.www.protocol.https */ import java.net.*; import java.util.*; import java.lang.reflect.*; import sun.net.www.protocol.https.HttpsURLConnectionImpl; -import com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl; public class CheckMethods { static boolean debug = false; @@ -85,9 +84,8 @@ } } - // check HttpsURLConnectionImpl and HttpsURLConnectionOldImpl - // contain all public and protected methods defined in - // HttpURLConnection and URLConnection + // check HttpsURLConnectionImpl contain all public and protected methods + // defined in HttpURLConnection and URLConnection public static void main(String[] args) { ArrayList allMethods = new ArrayList( Arrays.asList(HttpURLConnection.class.getDeclaredMethods())); @@ -121,24 +119,6 @@ throw new RuntimeException("Method definition test failed on HttpsURLConnectionImpl"); } - // testing HttpsURLConnectionOldImpl - List httpsOldMethods = - Arrays.asList(HttpsURLConnectionOldImpl.class.getDeclaredMethods()); - - ArrayList httpsOldMethodSignatures = new ArrayList(); - for (Iterator itr = httpsOldMethods.iterator(); itr.hasNext(); ) { - Method m = (Method)itr.next(); - if (!Modifier.isStatic(m.getModifiers())) { - httpsOldMethodSignatures.add( - new MethodSignature(m.getName(), m.getParameterTypes())); - } - } - - if (!httpsOldMethodSignatures.containsAll(allMethodSignatures)) { - throw new RuntimeException("Method definition test failed" + - " on HttpsURLConnectionOldImpl"); - } - // testing for non static public field ArrayList allFields = new ArrayList( Arrays.asList(URLConnection.class.getFields())); diff -r 3e39753ed05b -r b38f280d2114 test/jdk/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java --- a/test/jdk/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,393 +0,0 @@ -/* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 4474255 - * @summary Can no longer obtain a com.sun.net.ssl.HttpsURLConnection - * @modules java.base/com.sun.net.ssl - * java.base/com.sun.net.ssl.internal.www.protocol.https - * @run main/othervm ComHTTPSConnection - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * @author Brad Wetmore - */ - -import java.io.*; -import java.net.*; -import java.security.cert.Certificate; -import javax.net.ssl.*; -import com.sun.net.ssl.HostnameVerifier; -import com.sun.net.ssl.HttpsURLConnection; - -/** - * See if we can obtain a com.sun.net.ssl.HttpsURLConnection, - * and then play with it a bit. - */ -public class ComHTTPSConnection { - - /* - * ============================================================= - * Set the various variables needed for the tests, then - * specify what tests to run on each side. - */ - - /* - * Should we run the client or server in a separate thread? - * Both sides can throw exceptions, but do you have a preference - * as to which side should be the main thread. - */ - static boolean separateServerThread = true; - - /* - * Where do we find the keystores? - */ - static String pathToStores = "../../../../../../javax/net/ssl/etc"; - static String keyStoreFile = "keystore"; - static String trustStoreFile = "truststore"; - static String passwd = "passphrase"; - - /* - * Is the server ready to serve? - */ - volatile static boolean serverReady = false; - - /* - * Turn on SSL debugging? - */ - static boolean debug = false; - - /* - * If the client or server is doing some kind of object creation - * that the other side depends on, and that thread prematurely - * exits, you may experience a hang. The test harness will - * terminate all hung threads after its timeout has expired, - * currently 3 minutes by default, but you might try to be - * smart about it.... - */ - - /** - * Returns the path to the file obtained from - * parsing the HTML header. - */ - private static String getPath(DataInputStream in) - throws IOException - { - String line = in.readLine(); - String path = ""; - // extract class from GET line - if (line.startsWith("GET /")) { - line = line.substring(5, line.length()-1).trim(); - int index = line.indexOf(' '); - if (index != -1) { - path = line.substring(0, index); - } - } - - // eat the rest of header - do { - line = in.readLine(); - } while ((line.length() != 0) && - (line.charAt(0) != '\r') && (line.charAt(0) != '\n')); - - if (path.length() != 0) { - return path; - } else { - throw new IOException("Malformed Header"); - } - } - - /** - * Returns an array of bytes containing the bytes for - * the file represented by the argument path. - * - * In our case, we just pretend to send something back. - * - * @return the bytes for the file - * @exception FileNotFoundException if the file corresponding - * to path could not be loaded. - */ - private byte[] getBytes(String path) - throws IOException - { - return "Hello world, I am here".getBytes(); - } - - /* - * Define the server side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doServerSide() throws Exception { - - SSLServerSocketFactory sslssf = - (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); - SSLServerSocket sslServerSocket = - (SSLServerSocket) sslssf.createServerSocket(serverPort); - serverPort = sslServerSocket.getLocalPort(); - - /* - * Signal Client, we're ready for his connect. - */ - serverReady = true; - - SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); - DataOutputStream out = - new DataOutputStream(sslSocket.getOutputStream()); - - try { - // get path to class file from header - DataInputStream in = - new DataInputStream(sslSocket.getInputStream()); - String path = getPath(in); - // retrieve bytecodes - byte[] bytecodes = getBytes(path); - // send bytecodes in response (assumes HTTP/1.0 or later) - try { - out.writeBytes("HTTP/1.0 200 OK\r\n"); - out.writeBytes("Content-Length: " + bytecodes.length + "\r\n"); - out.writeBytes("Content-Type: text/html\r\n\r\n"); - out.write(bytecodes); - out.flush(); - } catch (IOException ie) { - ie.printStackTrace(); - return; - } - - } catch (Exception e) { - e.printStackTrace(); - // write out error response - out.writeBytes("HTTP/1.0 400 " + e.getMessage() + "\r\n"); - out.writeBytes("Content-Type: text/html\r\n\r\n"); - out.flush(); - } finally { - // close the socket - System.out.println("Server closing socket"); - sslSocket.close(); - serverReady = false; - } - } - - private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory { - private static String SUPPORTED_PROTOCOL = "https"; - - public URLStreamHandler createURLStreamHandler(String protocol) { - if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL)) - return null; - - return new com.sun.net.ssl.internal.www.protocol.https.Handler(); - } - } - - /* - * Define the client side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doClientSide() throws Exception { - /* - * Wait for server to get started. - */ - while (!serverReady) { - Thread.sleep(50); - } - - HostnameVerifier reservedHV = - HttpsURLConnection.getDefaultHostnameVerifier(); - try { - URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory()); - HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier()); - - URL url = new URL("https://" + "localhost:" + serverPort + - "/etc/hosts"); - URLConnection urlc = url.openConnection(); - - if (!(urlc instanceof com.sun.net.ssl.HttpsURLConnection)) { - throw new Exception( - "URLConnection ! instanceof " + - "com.sun.net.ssl.HttpsURLConnection"); - } - - BufferedReader in = null; - try { - in = new BufferedReader(new InputStreamReader( - urlc.getInputStream())); - String inputLine; - System.out.print("Client reading... "); - while ((inputLine = in.readLine()) != null) - System.out.println(inputLine); - - System.out.println("Cipher Suite: " + - ((HttpsURLConnection)urlc).getCipherSuite()); - Certificate[] certs = - ((HttpsURLConnection)urlc).getServerCertificates(); - for (int i = 0; i < certs.length; i++) { - System.out.println(certs[0]); - } - - in.close(); - } catch (SSLException e) { - if (in != null) - in.close(); - throw e; - } - System.out.println("Client reports: SUCCESS"); - } finally { - HttpsURLConnection.setDefaultHostnameVerifier(reservedHV); - } - } - - static class NameVerifier implements HostnameVerifier { - public boolean verify(String urlHostname, - String certHostname) { - System.out.println( - "CertificateHostnameVerifier: " + urlHostname + " == " - + certHostname + " returning true"); - return true; - } - } - - /* - * ============================================================= - * The remainder is just support stuff - */ - - // use any free port by default - volatile int serverPort = 0; - - volatile Exception serverException = null; - volatile Exception clientException = null; - - public static void main(String[] args) throws Exception { - String keyFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + keyStoreFile; - String trustFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + trustStoreFile; - - System.setProperty("javax.net.ssl.keyStore", keyFilename); - System.setProperty("javax.net.ssl.keyStorePassword", passwd); - System.setProperty("javax.net.ssl.trustStore", trustFilename); - System.setProperty("javax.net.ssl.trustStorePassword", passwd); - - if (debug) - System.setProperty("javax.net.debug", "all"); - - /* - * Start the tests. - */ - new ComHTTPSConnection(); - } - - Thread clientThread = null; - Thread serverThread = null; - - /* - * Primary constructor, used to drive remainder of the test. - * - * Fork off the other side, then do your work. - */ - ComHTTPSConnection() throws Exception { - if (separateServerThread) { - startServer(true); - startClient(false); - } else { - startClient(true); - startServer(false); - } - - /* - * Wait for other side to close down. - */ - if (separateServerThread) { - serverThread.join(); - } else { - clientThread.join(); - } - - /* - * When we get here, the test is pretty much over. - * - * If the main thread excepted, that propagates back - * immediately. If the other thread threw an exception, we - * should report back. - */ - if (serverException != null) { - System.out.print("Server Exception:"); - throw serverException; - } - if (clientException != null) { - System.out.print("Client Exception:"); - throw clientException; - } - } - - void startServer(boolean newThread) throws Exception { - if (newThread) { - serverThread = new Thread() { - public void run() { - try { - doServerSide(); - } catch (Exception e) { - /* - * Our server thread just died. - * - * Release the client, if not active already... - */ - System.err.println("Server died..."); - serverReady = true; - serverException = e; - } - } - }; - serverThread.start(); - } else { - doServerSide(); - } - } - - void startClient(boolean newThread) throws Exception { - if (newThread) { - clientThread = new Thread() { - public void run() { - try { - doClientSide(); - } catch (Exception e) { - /* - * Our client thread just died. - */ - System.err.println("Client died..."); - clientException = e; - } - } - }; - clientThread.start(); - } else { - doClientSide(); - } - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java --- a/test/jdk/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,362 +0,0 @@ -/* - * Copyright (c) 2001, 2018, 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. - */ - -// SunJSSE does not support dynamic system properties, no way to re-use -// system properties in samevm/agentvm mode. - -/* - * @test - * @bug 4474255 4484246 - * @summary When an application enables anonymous SSL cipher suite, - * Hostname verification is not required - * @modules java.base/com.sun.net.ssl - * java.base/com.sun.net.ssl.internal.www.protocol.https - * @run main/othervm ComHostnameVerifier - */ - -import java.io.*; -import java.net.*; -import java.security.Security; -import javax.net.ssl.*; -import javax.security.cert.*; -import com.sun.net.ssl.HostnameVerifier; -import com.sun.net.ssl.HttpsURLConnection; - -/** - * Use com.net.net.ssl.HostnameVerifier - */ -public class ComHostnameVerifier { - - /* - * ============================================================= - * Set the various variables needed for the tests, then - * specify what tests to run on each side. - */ - - /* - * Should we run the client or server in a separate thread? - * Both sides can throw exceptions, but do you have a preference - * as to which side should be the main thread. - */ - static boolean separateServerThread = true; - - /* - * Is the server ready to serve? - */ - volatile static boolean serverReady = false; - - /* - * Turn on SSL debugging? - */ - static boolean debug = false; - - /* - * If the client or server is doing some kind of object creation - * that the other side depends on, and that thread prematurely - * exits, you may experience a hang. The test harness will - * terminate all hung threads after its timeout has expired, - * currently 3 minutes by default, but you might try to be - * smart about it.... - */ - - /** - * Returns the path to the file obtained from - * parsing the HTML header. - */ - private static String getPath(DataInputStream in) - throws IOException - { - String line = in.readLine(); - if (line == null) - return null; - String path = ""; - // extract class from GET line - if (line.startsWith("GET /")) { - line = line.substring(5, line.length()-1).trim(); - int index = line.indexOf(' '); - if (index != -1) { - path = line.substring(0, index); - } - } - - // eat the rest of header - do { - line = in.readLine(); - } while ((line.length() != 0) && - (line.charAt(0) != '\r') && (line.charAt(0) != '\n')); - - if (path.length() != 0) { - return path; - } else { - throw new IOException("Malformed Header"); - } - } - - /** - * Returns an array of bytes containing the bytes for - * the file represented by the argument path. - * - * In our case, we just pretend to send something back. - * - * @return the bytes for the file - * @exception FileNotFoundException if the file corresponding - * to path could not be loaded. - */ - private byte[] getBytes(String path) - throws IOException - { - return "Hello world, I am here".getBytes(); - } - - /* - * Define the server side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doServerSide() throws Exception { - - SSLServerSocketFactory sslssf = - (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); - SSLServerSocket sslServerSocket = - (SSLServerSocket) sslssf.createServerSocket(serverPort); - serverPort = sslServerSocket.getLocalPort(); - - String ciphers[]= { "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" }; - sslServerSocket.setEnabledCipherSuites(ciphers); - - /* - * Signal Client, we're ready for his connect. - */ - serverReady = true; - - SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); - DataOutputStream out = - new DataOutputStream(sslSocket.getOutputStream()); - - try { - // get path to class file from header - DataInputStream in = - new DataInputStream(sslSocket.getInputStream()); - String path = getPath(in); - // retrieve bytecodes - byte[] bytecodes = getBytes(path); - // send bytecodes in response (assumes HTTP/1.0 or later) - try { - out.writeBytes("HTTP/1.0 200 OK\r\n"); - out.writeBytes("Content-Length: " + bytecodes.length + "\r\n"); - out.writeBytes("Content-Type: text/html\r\n\r\n"); - out.write(bytecodes); - out.flush(); - } catch (IOException ie) { - ie.printStackTrace(); - return; - } - - } catch (Exception e) { - e.printStackTrace(); - // write out error response - out.writeBytes("HTTP/1.0 400 " + e.getMessage() + "\r\n"); - out.writeBytes("Content-Type: text/html\r\n\r\n"); - out.flush(); - } finally { - // close the socket - System.out.println("Server closing socket"); - sslSocket.close(); - serverReady = false; - } - } - - private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory { - private static String SUPPORTED_PROTOCOL = "https"; - - public URLStreamHandler createURLStreamHandler(String protocol) { - if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL)) - return null; - - return new com.sun.net.ssl.internal.www.protocol.https.Handler(); - } - } - - /* - * Define the client side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doClientSide() throws Exception { - /* - * Wait for server to get started. - */ - while (!serverReady) { - Thread.sleep(50); - } - - URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory()); - - System.setProperty("https.cipherSuites", - "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"); - - // use the default hostname verifier - - URL url = new URL("https://" + "localhost:" + serverPort + - "/etc/hosts"); - URLConnection urlc = url.openConnection(); - - if (!(urlc instanceof com.sun.net.ssl.HttpsURLConnection)) { - throw new Exception( - "URLConnection ! instanceof " + - "com.sun.net.ssl.HttpsURLConnection"); - } - - BufferedReader in = null; - try { - in = new BufferedReader(new InputStreamReader( - urlc.getInputStream())); - String inputLine; - System.out.print("Client reading... "); - while ((inputLine = in.readLine()) != null) - System.out.println(inputLine); - System.out.println("Cipher Suite: " + - ((HttpsURLConnection)urlc).getCipherSuite()); - in.close(); - } catch (SSLException e) { - if (in != null) - in.close(); - throw e; - } - System.out.println("Client reports: SUCCESS"); - } - - /* - * ============================================================= - * The remainder is just support stuff - */ - - // use any free port by default - volatile int serverPort = 0; - - volatile Exception serverException = null; - volatile Exception clientException = null; - - public static void main(String[] args) throws Exception { - // re-enable 3DES - Security.setProperty("jdk.tls.disabledAlgorithms", ""); - - if (debug) - System.setProperty("javax.net.debug", "all"); - - /* - * Start the tests. - */ - new ComHostnameVerifier(); - } - - Thread clientThread = null; - Thread serverThread = null; - - /* - * Primary constructor, used to drive remainder of the test. - * - * Fork off the other side, then do your work. - */ - ComHostnameVerifier() throws Exception { - if (separateServerThread) { - startServer(true); - startClient(false); - } else { - startClient(true); - startServer(false); - } - - /* - * Wait for other side to close down. - */ - if (separateServerThread) { - serverThread.join(); - } else { - clientThread.join(); - } - - /* - * When we get here, the test is pretty much over. - * - * If the main thread excepted, that propagates back - * immediately. If the other thread threw an exception, we - * should report back. - */ - if (serverException != null) { - System.out.print("Server Exception:"); - throw serverException; - } - if (clientException != null) { - System.out.print("Client Exception:"); - throw clientException; - } - } - - void startServer(boolean newThread) throws Exception { - if (newThread) { - serverThread = new Thread() { - public void run() { - try { - doServerSide(); - } catch (Exception e) { - /* - * Our server thread just died. - * - * Release the client, if not active already... - */ - System.err.println("Server died..."); - serverReady = true; - serverException = e; - } - } - }; - serverThread.start(); - } else { - doServerSide(); - } - } - - void startClient(boolean newThread) throws Exception { - if (newThread) { - clientThread = new Thread() { - public void run() { - try { - doClientSide(); - } catch (Exception e) { - /* - * Our client thread just died. - */ - System.err.println("Client died..."); - clientException = e; - } - } - }; - clientThread.start(); - } else { - doClientSide(); - } - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/sun/security/ssl/X509TrustManagerImpl/CheckNullEntity.java --- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/CheckNullEntity.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/CheckNullEntity.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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,7 +27,6 @@ * @summary unspecified exceptions in X509TrustManager.checkClient[Server]Truste d * @author Xuelei Fan - * @modules java.base/com.sun.net.ssl.internal.ssl */ import java.io.*; @@ -37,8 +36,6 @@ import java.security.*; import java.util.Enumeration; -import com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager; - public class CheckNullEntity { /* @@ -157,7 +154,7 @@ if (trustManager instanceof X509ExtendedTrustManager) { try { ((X509ExtendedTrustManager)trustManager).checkClientTrusted( - certChain, (String)null, "localhost", null); + certChain, (String)null, (Socket)null); } catch (IllegalArgumentException iae) { // get the right exception extFailed >>= 1; @@ -165,7 +162,7 @@ try { ((X509ExtendedTrustManager)trustManager).checkServerTrusted( - certChain, (String)null, "localhost", null); + certChain, (String)null, (Socket)null); } catch (IllegalArgumentException iae) { // get the right exception extFailed >>= 1; @@ -173,7 +170,7 @@ try { ((X509ExtendedTrustManager)trustManager).checkClientTrusted( - certChain, "", "localhost", null); + certChain, "", (Socket)null); } catch (IllegalArgumentException iae) { // get the right exception extFailed >>= 1; @@ -181,7 +178,7 @@ try { ((X509ExtendedTrustManager)trustManager).checkServerTrusted( - certChain, "", "localhost", null); + certChain, "", (Socket)null); } catch (IllegalArgumentException iae) { // get the right exception extFailed >>= 1; @@ -189,7 +186,7 @@ try { ((X509ExtendedTrustManager)trustManager).checkClientTrusted( - null, authType, "localhost", null); + null, authType, (Socket)null); } catch (IllegalArgumentException iae) { // get the right exception extFailed >>= 1; @@ -197,7 +194,7 @@ try { ((X509ExtendedTrustManager)trustManager).checkServerTrusted( - null, authType, "localhost", null); + null, authType, (Socket)null); } catch (IllegalArgumentException iae) { // get the right exception extFailed >>= 1; diff -r 3e39753ed05b -r b38f280d2114 test/jdk/sun/security/ssl/X509TrustManagerImpl/ClientServer.java --- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/ClientServer.java Sat Mar 09 12:52:30 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,365 +0,0 @@ -/* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 4717766 - * @author Brad Wetmore - * @summary 1.0.3 JsseX509TrustManager erroneously calls isClientTrusted() - * @modules java.base/com.sun.net.ssl - * @run main/manual ClientServer - */ - -/* - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * - * JSSE supports algorithm constraints with CR 6916074, need to update - * this test case in JDK 7 soon. - * - * This problem didn't exist in JSSE 1.4, only JSSE 1.0.3. However, - * this is a useful test, so I decided to include it in 1.4.2. - */ - -import java.io.*; -import java.net.*; -import javax.net.ssl.*; -import java.security.cert.*; -import java.security.*; -import com.sun.net.ssl.*; - -public class ClientServer { - - /* - * ============================================================= - * Set the various variables needed for the tests, then - * specify what tests to run on each side. - */ - - /* - * Should we run the client or server in a separate thread? - * Both sides can throw exceptions, but do you have a preference - * as to which side should be the main thread. - */ - static boolean separateServerThread = true; - - /* - * Where do we find the keystores? - */ - static String pathToStores = "../../../../javax/net/ssl/etc"; - static String keyStoreFile = "keystore"; - static String trustStoreFile = "truststore"; - static String passwd = "passphrase"; - - /* - * Is the server ready to serve? - */ - volatile static boolean serverReady = false; - - /* - * Turn on SSL debugging? - */ - static boolean debug = false; - - /* - * If the client or server is doing some kind of object creation - * that the other side depends on, and that thread prematurely - * exits, you may experience a hang. The test harness will - * terminate all hung threads after its timeout has expired, - * currently 3 minutes by default, but you might try to be - * smart about it.... - */ - - /* - * Define the server side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doServerSide() throws Exception { - SSLServerSocketFactory sslssf = getDefaultServer(); - SSLServerSocket sslServerSocket = - (SSLServerSocket) sslssf.createServerSocket(serverPort); - serverPort = sslServerSocket.getLocalPort(); - - /* - * Signal Client, we're ready for his connect. - */ - serverReady = true; - - SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); - sslSocket.setNeedClientAuth(true); - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream(); - - sslIS.read(); - sslOS.write(85); - sslOS.flush(); - - sslSocket.close(); - - if (!serverTM.wasServerChecked() && serverTM.wasClientChecked()) { - System.out.println("SERVER TEST PASSED!"); - } else { - throw new Exception("SERVER TEST FAILED! " + - !serverTM.wasServerChecked() + " " + - serverTM.wasClientChecked()); - } - } - - /* - * Define the client side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doClientSide() throws Exception { - - /* - * Wait for server to get started. - */ - while (!serverReady) { - Thread.sleep(50); - } - - SSLSocketFactory sslsf = getDefaultClient(); - SSLSocket sslSocket = (SSLSocket) - sslsf.createSocket("localhost", serverPort); - - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream(); - - sslOS.write(280); - sslOS.flush(); - sslIS.read(); - - sslSocket.close(); - - if (clientTM.wasServerChecked() && !clientTM.wasClientChecked()) { - System.out.println("CLIENT TEST PASSED!"); - } else { - throw new Exception("CLIENT TEST FAILED! " + - clientTM.wasServerChecked() + " " + - !clientTM.wasClientChecked()); - } - } - - private com.sun.net.ssl.SSLContext getDefault(MyX509TM tm) - throws Exception { - - String keyFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + keyStoreFile; - String trustFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + trustStoreFile; - - char[] passphrase = "passphrase".toCharArray(); - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(new FileInputStream(keyFilename), passphrase); - - com.sun.net.ssl.KeyManagerFactory kmf = - com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, passphrase); - - ks = KeyStore.getInstance("JKS"); - ks.load(new FileInputStream(trustFilename), passphrase); - - com.sun.net.ssl.TrustManagerFactory tmf = - com.sun.net.ssl.TrustManagerFactory.getInstance("SunX509"); - tmf.init(ks); - - com.sun.net.ssl.TrustManager [] tms = tmf.getTrustManagers(); - - int i; - for (i = 0; i < tms.length; i++) { - if (tms[i] instanceof com.sun.net.ssl.X509TrustManager) { - break; - } - } - - if (i >= tms.length) { - throw new Exception("Couldn't find X509TM"); - } - - tm.init((com.sun.net.ssl.X509TrustManager)tms[i]); - tms = new MyX509TM [] { tm }; - - com.sun.net.ssl.SSLContext ctx = - com.sun.net.ssl.SSLContext.getInstance("TLS"); - ctx.init(kmf.getKeyManagers(), tms, null); - return ctx; - } - - MyX509TM serverTM; - MyX509TM clientTM; - - private SSLServerSocketFactory getDefaultServer() throws Exception { - serverTM = new MyX509TM(); - return getDefault(serverTM).getServerSocketFactory(); - } - - private SSLSocketFactory getDefaultClient() throws Exception { - clientTM = new MyX509TM(); - return getDefault(clientTM).getSocketFactory(); - } - - static class MyX509TM implements com.sun.net.ssl.X509TrustManager { - - com.sun.net.ssl.X509TrustManager tm; - boolean clientChecked; - boolean serverChecked; - - void init(com.sun.net.ssl.X509TrustManager x509TM) { - tm = x509TM; - } - - public boolean wasClientChecked() { - return clientChecked; - } - - public boolean wasServerChecked() { - return serverChecked; - } - - public boolean isClientTrusted(X509Certificate[] chain) { - clientChecked = true; - return true; - } - - public boolean isServerTrusted(X509Certificate[] chain) { - serverChecked = true; - return true; - } - - public X509Certificate[] getAcceptedIssuers() { - return tm.getAcceptedIssuers(); - } - } - - /* - * ============================================================= - * The remainder is just support stuff - */ - - // use any free port by default - volatile int serverPort = 0; - - volatile Exception serverException = null; - volatile Exception clientException = null; - - public static void main(String[] args) throws Exception { - - if (debug) - System.setProperty("javax.net.debug", "all"); - - /* - * Start the tests. - */ - new ClientServer(); - } - - Thread clientThread = null; - Thread serverThread = null; - - /* - * Primary constructor, used to drive remainder of the test. - * - * Fork off the other side, then do your work. - */ - ClientServer() throws Exception { - if (separateServerThread) { - startServer(true); - startClient(false); - } else { - startClient(true); - startServer(false); - } - - /* - * Wait for other side to close down. - */ - if (separateServerThread) { - serverThread.join(); - } else { - clientThread.join(); - } - - /* - * When we get here, the test is pretty much over. - * - * If the main thread excepted, that propagates back - * immediately. If the other thread threw an exception, we - * should report back. - */ - if (serverException != null) - throw serverException; - if (clientException != null) - throw clientException; - } - - void startServer(boolean newThread) throws Exception { - if (newThread) { - serverThread = new Thread() { - public void run() { - try { - doServerSide(); - } catch (Exception e) { - /* - * Our server thread just died. - * - * Release the client, if not active already... - */ - System.err.println("Server died..."); - serverReady = true; - serverException = e; - } - } - }; - serverThread.start(); - } else { - doServerSide(); - } - } - - void startClient(boolean newThread) throws Exception { - if (newThread) { - clientThread = new Thread() { - public void run() { - try { - doClientSide(); - } catch (Exception e) { - /* - * Our client thread just died. - */ - System.err.println("Client died..."); - clientException = e; - } - } - }; - clientThread.start(); - } else { - doClientSide(); - } - } -} diff -r 3e39753ed05b -r b38f280d2114 test/jdk/tools/launcher/Test7029048.java --- a/test/jdk/tools/launcher/Test7029048.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/jdk/tools/launcher/Test7029048.java Sat Mar 09 12:54:20 2019 +0000 @@ -23,7 +23,7 @@ /** * @test - * @bug 7029048 8217340 + * @bug 7029048 8217340 8217216 * @summary Ensure that the launcher defends against user settings of the * LD_LIBRARY_PATH environment variable on Unixes * @library /test/lib @@ -89,6 +89,29 @@ } static void analyze(TestResult tr, int nLLPComponents, String caseID) { + if (isSolaris) { + String envValue = getValue("LD_LIBRARY_PATH_64", tr.testOutput); + /* + * the envValue can never be null, since the test code should always + * print a "null" string. + */ + if (envValue == null) { + throw new RuntimeException("NPE, likely a program crash ??"); + } + boolean noLLP64 = envValue.equals("null"); + if (nLLPComponents == 0 && noLLP64) { + System.out.println("FAIL: test7029048, " + caseID); + System.out.println(" Missing LD_LIBRARY_PATH_64"); + errors++; + return; + } else if (nLLPComponents > 3 && !noLLP64) { + System.out.println("FAIL: test7029048, " + caseID); + System.out.println(" Unexpected LD_LIBRARY_PATH_64: " + envValue); + errors++; + return; + } + } + String envValue = getValue(LD_LIBRARY_PATH, tr.testOutput); /* * the envValue can never be null, since the test code should always @@ -202,8 +225,8 @@ env.clear(); env.put(LD_LIBRARY_PATH_64, dstServerDir.getAbsolutePath()); run(env, - v.value, // Do not add one, since we didn't set - // LD_LIBRARY_PATH here + // LD_LIBRARY_PATH_64 is copied into LD_LIBRARY_PATH for LIBJVM case + v.value == 0 ? 0 : v.value + 1, "Case 3: " + desc); } } diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java --- a/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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 @@ -56,13 +56,13 @@ checkExit(Exit.OK); checkOutput("overview-summary.html", true, ""); checkOutput("index.html", true, - " allBodyClassesFound = new HashSet<>(); final Set allGeneratorsFound = new HashSet<>(); public void runTests() throws Exception { @@ -93,6 +94,7 @@ } javadoc(args.toArray(new String[args.size()])); checkExit(Exit.OK); + checkBodyClasses(); checkMetadata(); // spot check the descriptions for declarations @@ -126,10 +128,91 @@ failed("not found: " + notFound); } + checking ("all body classes"); + if (allBodyClassesFound.equals(allBodyClasses)) { + passed("all gbody classes found"); + } else { + Set notFound = new TreeSet<>(allBodyClasses); + notFound.removeAll(allBodyClassesFound); + failed("not found: " + notFound); + } + printSummary(); } final Pattern nl = Pattern.compile("[\\r\\n]+"); + final Pattern bodyPattern = Pattern.compile("]*class=\"([^\"]+)\""); + final Set allBodyClasses = Set.of( + "all-classes-frame", + "all-classes-index", + "all-packages-index", + "class-declaration", + "class-use", + "constants-summary", + "deprecated-list", + "doc-file", + "frames", + "help", + "index-redirect", + "module-declaration", + "module-frame", + "module-index", + "module-index-frame", + "module-package-index-frame", + "package-declaration", + "package-frame", + "package-index", + "package-index-frame", + "package-tree", + "package-use", + "serialized-form", + "single-index", + "source", + "split-index", + "tree" + ); + + void checkBodyClasses() throws IOException { + Path outputDirPath = outputDir.toPath(); + for (Path p : tb.findFiles(".html", outputDirPath)) { + checkBodyClass(outputDirPath.relativize(p)); + } + } + + void checkBodyClass(Path p) { + checking("Check body: " + p); + + List bodyLines = nl.splitAsStream(readOutputFile(p.toString())) + .filter(s -> s.contains(""); final Pattern generatorPattern = Pattern.compile("content=\"javadoc/([^\"]+)\">"); final Set allGenerators = Set.of( diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Sat Mar 09 12:54:20 2019 +0000 @@ -173,7 +173,7 @@ checkExit(Exit.OK); checkOutput("m/module-summary.html", false, - "

    Services

    "); + "

    Services

    "); } @Test @@ -194,7 +194,7 @@ checkExit(Exit.OK); checkOutput("m/module-summary.html", true, - "

    Services

    "); + "

    Services

    "); checkOutput("m/module-summary.html", true, "
    \n\n" + @@ -235,7 +235,7 @@ checkExit(Exit.OK); checkOutput("m/module-summary.html", true, - "

    Services

    "); + "

    Services

    "); checkOutput("m/module-summary.html", true, "
    \n
    \n" + @@ -276,7 +276,7 @@ checkExit(Exit.OK); checkOutput("m/module-summary.html", false, - "

    Services

    "); + "

    Services

    "); } @Test @@ -302,7 +302,7 @@ checkExit(Exit.OK); checkOutput("m/module-summary.html", true, - "

    Services

    "); + "

    Services

    "); checkOutput("m/module-summary.html", true, "
    \n
    \n" + @@ -346,7 +346,7 @@ checkExit(Exit.OK); checkOutput("m/module-summary.html", true, - "

    Services

    "); + "

    Services

    "); checkOutput("m/module-summary.html", true, "
    \n
    \n" + @@ -389,7 +389,7 @@ checkExit(Exit.OK); checkOutput("m/module-summary.html", true, - "

    Services

    "); + "

    Services

    "); checkOutput("m/module-summary.html", true, "
    \n
    \n" + diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testModules/TestModules.java --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java Sat Mar 09 12:54:20 2019 +0000 @@ -1261,7 +1261,7 @@ + "
    This is a test description for the test.moduleFullName.
    \n" + ""); checkOutput("module-overview-frame.html", found, - "

    Modules

    \n" + "

    Modules

    \n" + "
      \n" + "
    • moduleB
    • \n" + "
    • test.moduleFullName
    • \n" diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java --- a/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java Sat Mar 09 12:54:20 2019 +0000 @@ -24,7 +24,7 @@ /* * @test * @bug 4789689 4905985 4927164 4827184 4993906 5004549 7025314 7010344 8025633 8026567 8162363 - * 8175200 8186332 8182765 8196202 8187288 8173730 + * 8175200 8186332 8182765 8196202 8187288 8173730 8215307 * @summary Run Javadoc on a set of source files that demonstrate new * language features. Check the output to ensure that the new * language features are properly documented. @@ -66,7 +66,7 @@ void checkEnums() { checkOutput("pkg/Coin.html", true, // Make sure enum header is correct. - "Enum Coin", + "Enum Coin", // Make sure enum signature is correct. "
      public enum "
                       + "Coin\n"
      @@ -110,7 +110,7 @@
           void checkTypeParameters() {
               checkOutput("pkg/TypeParameters.html", true,
                       // Make sure the header is correct.
      -                "Class TypeParameters<E>",
      +                "Class TypeParameters<E>",
                       // Check class type parameters section.
                       "
      Type Parameters:
      \n" + "
      E - " diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java --- a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java Sat Mar 09 12:54:20 2019 +0000 @@ -193,10 +193,10 @@ "
      @Documented\npublic @interface "
                       + "AnnotationTypeField
      ", - "

      DEFAULT_NAME

      \n
      static final java.lang.String "
      +                "

      DEFAULT_NAME

      \n
      static final java.lang.String "
                       + ""
                       + "DEFAULT_NAME
      ", - "

      name

      \n
      java.lang.String name\n
      java.lang.String name
      "); checkOutput("src-html/linksource/AnnotationTypeField.html", true, diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java --- a/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java Sat Mar 09 12:54:20 2019 +0000 @@ -551,107 +551,107 @@ checkExit(Exit.OK); checkOrder("pkg5/AnnoFieldTest.html", - "

      Field Detail

      ", + "

      Field Detail

      ", "
      static final int one
      ", "
      static final int two
      ", "
      static final int three
      ", "
      static final int four
      "); checkOrder("pkg5/AnnoOptionalTest.html", - "

      Optional Element Summary

      ", + "

      Optional Element Summary

      ", "four", "one", "three", "two", - "

      Element Detail

      ", - "

      one

      ", - "

      two

      ", - "

      three

      ", - "

      four

      "); + "

      Element Detail

      ", + "

      one

      ", + "

      two

      ", + "

      three

      ", + "

      four

      "); checkOrder("pkg5/AnnoRequiredTest.html", - "

      Required Element Summary

      ", + "

      Required Element Summary

      ", "four", "one", "three", "two", - "

      Element Detail

      ", - "

      one

      ", - "

      two

      ", - "

      three

      ", - "

      four

      "); + "

      Element Detail

      ", + "

      one

      ", + "

      two

      ", + "

      three

      ", + "

      four

      "); checkOrder("pkg5/CtorTest.html", - "

      Constructor Summary

      ", + "

      Constructor Summary

      ", "Constructor Detail", + "

      Constructor Detail

      ", "
      ", "", "", ""); checkOrder("pkg5/EnumTest.html", - "

      Enum Constant Summary

      ", + "

      Enum Constant Summary

      ", "
      FOUR", "ONE", "THREE", "TWO", - "

      Enum Constant Detail

      ", - "

      ONE

      ", - "

      TWO

      ", - "

      THREE

      ", - "

      FOUR

      "); + "

      Enum Constant Detail

      ", + "

      ONE

      ", + "

      TWO

      ", + "

      THREE

      ", + "

      FOUR

      "); checkOrder("pkg5/FieldTest.html", - "

      Field Summary

      ", + "

      Field Summary

      ", "four", "one", "three", "two", - "

      Field Detail

      ", - "

      one

      ", - "

      two

      ", - "

      three

      ", - "

      four

      "); + "

      Field Detail

      ", + "

      one

      ", + "

      two

      ", + "

      three

      ", + "

      four

      "); checkOrder("pkg5/IntfTest.html", - "

      Method Summary

      ", + "

      Method Summary

      ", "four", "one", "three", "two", - "

      Method Detail

      ", - "

      one

      ", - "

      two

      ", - "

      three

      ", - "

      four

      "); + "

      Method Detail

      ", + "

      one

      ", + "

      two

      ", + "

      three

      ", + "

      four

      "); checkOrder("pkg5/MethodTest.html", - "

      Method Summary

      ", + "

      Method Summary

      ", "four", "one", "three", "two", - "

      Method Detail

      ", - "

      one

      ", - "

      two

      ", - "

      three

      ", - "

      four

      "); + "

      Method Detail

      ", + "

      one

      ", + "

      two

      ", + "

      three

      ", + "

      four

      "); checkOrder("pkg5/PropertyTest.html", - "

      Property Summary

      ", + "

      Property Summary

      ", "four", "one", "three", "two", - "

      Property Detail

      ", - "

      oneProperty

      ", - "

      twoProperty

      ", - "

      threeProperty

      ", - "

      fourProperty

      "); + "

      Property Detail

      ", + "

      oneProperty

      ", + "

      twoProperty

      ", + "

      threeProperty

      ", + "

      fourProperty

      "); } } diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java --- a/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestBadOverride.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -53,7 +53,7 @@ checkOutput("pkg4/Foo.html", true, "
    • \n" - + "

      toString

      \n" + + "

      toString

      \n" + "
      public void toString()
      \n" + "
      Why can't I do this ?
      \n" + "
    • "); diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java --- a/test/langtools/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 4341304 4485668 4966728 8032066 8071982 8192933 + * @bug 4341304 4485668 4966728 8032066 8071982 8192933 8215307 * @summary Test that methods readResolve and writeReplace show * up in serialized-form.html the same way that readObject and writeObject do. * If the doclet includes readResolve and writeReplace in the serialized-form @@ -109,6 +109,8 @@ testSrc("SerializedForm.java"), testSrc("ExternalizedForm.java"), "pkg1"); checkExit(Exit.OK); + showHeadings("serialized-form.html"); + checkOutput("serialized-form.html", true, "

      Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " @@ -130,15 +132,15 @@ + "extends java.lang.Object implements Serializable

      "); checkOutput("serialized-form.html", true, - "

      Serialized Fields

      \n" + + "

      Serialized Fields

      \n" + "
        \n" + "
      • \n" + - "

        longs

        \n" + + "
        longs
        \n" + "
        Long[] longs
        \n" + "
        the longs
        \n" + "
      • \n" + "
      • \n" + - "

        name

        \n" + + "
        name
        \n" + "
        java.lang.String name
        \n" + "
        a test
        "); } diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testSummaryHeading/TestSummaryHeading.java --- a/test/langtools/jdk/javadoc/doclet/testSummaryHeading/TestSummaryHeading.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testSummaryHeading/TestSummaryHeading.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -51,6 +51,6 @@ checkExit(Exit.OK); checkOutput("C.html", true, - "

        Method Summary

        "); + "

        Method Summary

        "); } } diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java --- a/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java Sat Mar 09 12:54:20 2019 +0000 @@ -86,7 +86,7 @@ // make sure the second @summary's content is displayed correctly checkOutput("p1/A.html", true, "
      • \n" - + "

        m3

        \n" + + "

        m3

        \n" + "
        public void m3()
        \n" + "
        First sentence some text maybe second sentence.
        \n" + "
      • \n" diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java --- a/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -76,9 +76,9 @@ checkExit(Exit.OK); checkOrder("pkg/A.html", - "

        Class A

        ", + "

        Class A

        ", "test with user.name", - "

        Method Detail

        ", + "

        Method Detail

        ", "test with java.version"); checkOrder("index-all.html", diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/lib/javadoc/tester/A11yChecker.java --- a/test/langtools/jdk/javadoc/lib/javadoc/tester/A11yChecker.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/A11yChecker.java Sat Mar 09 12:54:20 2019 +0000 @@ -36,7 +36,7 @@ private boolean html5; - private int currLevel; + private int currRank; private int headingErrors; private boolean inBody; @@ -86,6 +86,7 @@ switch (name) { case "body": inBody = true; + currRank = 0; break; case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": @@ -126,18 +127,18 @@ } private void checkHeading(String h) { - int level = Character.digit(h.charAt(1), 10); - if (level > currLevel + 1) { + int rank = Character.digit(h.charAt(1), 10); + if (rank > currRank + 1) { headingErrors++; StringBuilder sb = new StringBuilder(); String sep = ""; - for (int i = currLevel + 1; i < level; i++) { + for (int i = currRank + 1; i < rank; i++) { sb.append(sep).append("h").append(i); sep = ", "; } error(currFile, getLineNumber(), "missing headings: " + sb); } - currLevel = level; + currRank = rank; } @Override diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/lib/javadoc/tester/JavadocTester.java --- a/test/langtools/jdk/javadoc/lib/javadoc/tester/JavadocTester.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/JavadocTester.java Sat Mar 09 12:54:20 2019 +0000 @@ -232,7 +232,7 @@ private DirectoryCheck outputDirectoryCheck = DirectoryCheck.EMPTY; - private boolean automaticCheckAccessibility = false; + private boolean automaticCheckAccessibility = true; private boolean automaticCheckLinks = true; /** The current subtest number. Incremented when checking(...) is called. */ @@ -261,7 +261,7 @@ } /** - * Run all methods annotated with @Test, followed by printSummary. + * Runs all methods annotated with @Test, followed by printSummary. * Typically called on a tester object in main() * @param f a function which will be used to provide arguments to each * invoked method @@ -285,7 +285,7 @@ } /** - * Run javadoc. + * Runs javadoc. * The output directory used by this call and the final exit code * will be saved for later use. * To aid the reader, it is recommended that calls to this method @@ -391,7 +391,7 @@ } /** - * Set the kind of check for the initial contents of the output directory + * Sets the kind of check for the initial contents of the output directory * before javadoc is run. * The filter should return true for files that should not appear. * @param c the kind of check to perform @@ -401,7 +401,14 @@ } /** - * Set whether or not to perform an automatic call of checkLinks. + * Sets whether or not to perform an automatic call of checkAccessibility. + */ + public void setAutomaticCheckAccessibility(boolean b) { + automaticCheckAccessibility = b; + } + + /** + * Sets whether or not to perform an automatic call of checkLinks. */ public void setAutomaticCheckLinks(boolean b) { automaticCheckLinks = b; @@ -431,7 +438,7 @@ } /** - * Check the exit code of the most recent call of javadoc. + * Checks the exit code of the most recent call of javadoc. * * @param expected the exit code that is required for the test * to pass. @@ -446,7 +453,7 @@ } /** - * Check for content in (or not in) the generated output. + * Checks for content in (or not in) the generated output. * Within the search strings, the newline character \n * will be translated to the platform newline character sequence. * @param path a path within the most recent output directory @@ -465,7 +472,7 @@ } /** - * Check for content in (or not in) the generated output. + * Checks for content in (or not in) the generated output. * Within the search strings, the newline character \n * will be translated to the platform newline character sequence. * @param path a path within the most recent output directory, identifying @@ -487,7 +494,7 @@ } /** - * Check for content in (or not in) the one of the output streams written by + * Checks for content in (or not in) the one of the output streams written by * javadoc. Within the search strings, the newline character \n * will be translated to the platform newline character sequence. * @param output the output stream to check @@ -519,6 +526,11 @@ } } + /** + * Performs some structural accessibility checks on the files generated by the most + * recent run of javadoc. + * The checks can be run automatically by calling {@link #setAutomaticCheckAccessibility}. + */ public void checkAccessibility() { checking("Check accessibility"); A11yChecker c = new A11yChecker(out, this::readFile); @@ -536,6 +548,11 @@ } } + /** + * Checks all the links within the files generated by the most + * recent run of javadoc. + * The checks can be run automatically by calling {@link #setAutomaticCheckLinks}. + */ public void checkLinks() { checking("Check links"); LinkChecker c = new LinkChecker(out, this::readFile); @@ -554,7 +571,27 @@ } /** - * Get the content of the one of the output streams written by javadoc. + * Shows the heading structure for each of the specified files. + * The structure is is printed in plain text to the main output stream. + * No errors are reported (unless there is a problem reading a file) + * but missing headings are noted within the output. + * @params the files + */ + public void showHeadings(String... paths) { + ShowHeadings s = new ShowHeadings(out, this::readFile); + for (String p : paths) { + try { + File f = new File(outputDir, p); + s.checkFiles(List.of(f.toPath()), false, Collections.emptySet()); + } catch (IOException e) { + checking("Read file"); + failed("Error reading file: " + e); + } + } + } + + /** + * Gets the content of the one of the output streams written by javadoc. * @param output the name of the output stream * @return the content of the output stream */ @@ -563,7 +600,7 @@ } /** - * Get the content of the one of the output streams written by javadoc. + * Gets the content of the one of the output streams written by javadoc. * @param output the name of the output stream * @return the content of the output stream, as a line of lines */ @@ -573,7 +610,7 @@ } /** - * Check for files in (or not in) the generated output. + * Checks for files in (or not in) the generated output. * @param expectedFound true if all of the files are expected * to be found, or false if all of the files are expected to be * not found @@ -584,7 +621,7 @@ } /** - * Check for files in (or not in) the generated output. + * Checks for files in (or not in) the generated output. * @param expectedFound true if all of the files are expected * to be found, or false if all of the files are expected to be * not found @@ -605,7 +642,7 @@ } /** - * Check that a series of strings are found in order in a file in + * Checks that a series of strings are found in order in a file in * the generated output. * @param path the file to check * @param strings the strings whose order to check @@ -658,7 +695,7 @@ } /** - * Compare a set of files in each of two directories. + * Compares a set of files in each of two directories. * * @param baseDir1 the directory containing the first set of files * @param baseDir2 the directory containing the second set of files @@ -673,7 +710,7 @@ } /** - * A utility to copy a directory from one place to another. + * Copies a directory from one place to another. * * @param targetDir the directory to copy. * @param destDir the destination to copy the directory to. @@ -707,7 +744,7 @@ } /** - * Copy source file to destination file. + * Copies a file. * * @param destfile the destination file * @param srcfile the source file @@ -749,7 +786,7 @@ } /** - * Read the file and return it as a string. + * Reads the file and return it as a string. * * @param baseDir the directory in which to locate the file * @param fileName the name of the file to read @@ -825,7 +862,7 @@ } /** - * Print a summary of the test results. + * Prints a summary of the test results. */ protected void printSummary() { String javadocRuns = (javadocRunNum <= 1) ? "" @@ -845,7 +882,7 @@ } /** - * Search for the string in the given file and return true + * Searches for the string in the given file and return true * if the string was found. * * @param fileString the contents of the file to search through @@ -861,7 +898,7 @@ } /** - * Compare the two given files. + * Compares the two given files. * * @param baseDir1 the directory in which to locate the first file * @param baseDir2 the directory in which to locate the second file diff -r 3e39753ed05b -r b38f280d2114 test/langtools/jdk/javadoc/lib/javadoc/tester/ShowHeadings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/ShowHeadings.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2019, 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 javadoc.tester; + +import java.io.PrintStream; +import java.nio.file.Path; +import java.util.Map; +import java.util.function.Function; + +public class ShowHeadings extends HtmlChecker { + + private int currLevel; + + private boolean copyContent; + + ShowHeadings(PrintStream out, Function fileReader) { + super(out, fileReader); + } + + @Override + public void report() { + } + + @Override + public void startFile(Path path) { + out.println("Headings: " + path); + currLevel = 0; + } + + @Override + public void endFile() { + } + + @Override + public void docType(String doctype) { + } + + @Override + public void startElement(String name, Map attrs, boolean selfClosing) { + switch (name) { + case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": + startHeading(name); + break; + } + } + + @Override + public void endElement(String name) { + switch (name) { + case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": + out.println(); + copyContent = false; + break; + } + + } + + private void startHeading(String h) { + int level = Character.digit(h.charAt(1), 10); + while (level > currLevel + 1) { + currLevel++; + out.println("* ".repeat(currLevel - 1) + "H" + currLevel + ": *** MISSING ***"); + } + currLevel = level; + out.print("* ".repeat(currLevel - 1) + "H" + currLevel + ": "); + copyContent = true; + } + + @Override + public void content(String s) { + if (copyContent) { + out.print(s.replace(" ", " ") + .replace("<", "<") + .replace(">", ">") + .replace("&", "&") + .replaceAll("\\s+", " ") + ); + } + } +} + diff -r 3e39753ed05b -r b38f280d2114 test/langtools/tools/javac/modules/PatchModulesTest.java --- a/test/langtools/tools/javac/modules/PatchModulesTest.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/tools/javac/modules/PatchModulesTest.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 8160489 + * @bug 8160489 8217868 * @summary tests for --patch-modules * @library /tools/lib * @modules @@ -192,5 +192,23 @@ throw new AssertionError(); } } + + @Test + public void testPatchModuleSourcePathClash(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module m { uses test.Test; }", + "package test; public class Test { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new toolbox.JavacTask(tb) + .options("--patch-module", "other=" + src.toString(), + "-sourcepath", src.toString()) + .outdir(classes) + .files(findJavaFiles(src.resolve("module-info.java"))) + .run() + .writeAll(); + } } diff -r 3e39753ed05b -r b38f280d2114 test/langtools/tools/javac/processing/model/completionfailure/SymbolsDontCumulate.java --- a/test/langtools/tools/javac/processing/model/completionfailure/SymbolsDontCumulate.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/langtools/tools/javac/processing/model/completionfailure/SymbolsDontCumulate.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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,25 +24,31 @@ /* * @test * @bug 8209055 - * @summary Verify that speculative symbols are not unnecesarily retained in + * @summary Verify that speculative symbols are not unnecessarily retained in * the DeferredCompletionFailureHandler * @library /tools/javac/lib /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.code:+open + * jdk.compiler/com.sun.tools.javac.main * @run main SymbolsDontCumulate */ import java.lang.reflect.Field; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; import javax.tools.JavaCompiler; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; -import toolbox.*; import com.sun.tools.javac.api.JavacTaskImpl; import com.sun.tools.javac.code.DeferredCompletionFailureHandler; +import toolbox.ToolBox; + public class SymbolsDontCumulate { ToolBox tb = new ToolBox(); @@ -65,7 +71,7 @@ DeferredCompletionFailureHandler h = DeferredCompletionFailureHandler.instance(((JavacTaskImpl) task).getContext()); Field class2Flip = h.userCodeHandler.getClass().getDeclaredField("class2Flip"); class2Flip.setAccessible(true); - int size = ((Map) class2Flip.get(h.userCodeHandler)).size(); + int size = ((Map) class2Flip.get(h.userCodeHandler)).size(); assertEquals(0, size); } } diff -r 3e39753ed05b -r b38f280d2114 test/micro/org/openjdk/bench/java/lang/StringIndexOf.java --- a/test/micro/org/openjdk/bench/java/lang/StringIndexOf.java Sat Mar 09 12:52:30 2019 +0000 +++ b/test/micro/org/openjdk/bench/java/lang/StringIndexOf.java Sat Mar 09 12:54:20 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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,6 +46,12 @@ private String shortSub1; private String data2; private String shortSub2; + private String string16Short; + private String string16Medium; + private String string16Long; + private char searchChar; + private char searchChar16; + private String searchString16; @Setup public void setup() { @@ -58,9 +64,122 @@ shortSub1 = "1"; data2 = "00001001010100a10110101010010101110101001110110101010010101010010000010111010101010101010a100010010101110111010101101010100010010a100a0010101111111000010101010010101000010101010010101010101110a10010101010101010101010101010"; shortSub2 = "a"; + searchChar = 's'; + + string16Short = "scar\u01fe1"; + string16Medium = "capaapapapasdkajdlkajskldjaslkjdlkasjdsalksca1r\u01fescar"; + string16Long = "2937489745890797905764956790452976742965790437698498409583479067ngdcapaapapapasdkajdlkajskldjaslkjdlkasjdsalkja1sscar\u01fescar"; + searchChar16 = 0x1fe; + searchString16 = "\u01fe"; + } + + + /** IndexOf Micros Chars */ + @Benchmark + public int searchCharLongSuccess() { + return dataStringBig.indexOf(searchChar); + } + + @Benchmark + public int searchCharMediumSuccess() { + return searchStringBig.indexOf(searchChar); + } + + @Benchmark + public int searchCharShortSuccess() { + return searchString.indexOf(searchChar); + } + + @Benchmark + public int searchChar16LongSuccess() { + return string16Long.indexOf(searchChar16); + } + + @Benchmark + public int searchChar16MediumSuccess() { + return string16Medium.indexOf(searchChar16); + } + + @Benchmark + public int searchChar16ShortSuccess() { + return string16Short.indexOf(searchChar16); + } + + @Benchmark + public int searchChar16LongWithOffsetSuccess() { + return string16Long.indexOf(searchChar16, 3); + } + + @Benchmark + public int searchChar16MediumWithOffsetSuccess() { + return string16Medium.indexOf(searchChar16, 3); + } + + @Benchmark + public int searchChar16ShortWithOffsetSuccess() { + return string16Short.indexOf(searchChar16, 2); } /** IndexOf Micros Strings */ + @Benchmark + public int searchString16LongLatinSuccess() { + return string16Long.indexOf(shortSub1); + } + + @Benchmark + public int searchString16MediumLatinSuccess() { + return string16Medium.indexOf(shortSub1); + } + + @Benchmark + public int searchString16ShortLatinSuccess() { + return string16Long.indexOf(shortSub2); + } + + @Benchmark + public int searchString16LongWithOffsetLatinSuccess() { + return string16Long.indexOf(shortSub1, 3); + } + + @Benchmark + public int searchString16MediumWithOffsetLatinSuccess() { + return string16Medium.indexOf(shortSub1, 3); + } + + @Benchmark + public int searchString16ShortWithOffsetLatinSuccess() { + return string16Short.indexOf(shortSub2, 1); + } + + @Benchmark + public int searchString16LongWithOffsetSuccess() { + return string16Long.indexOf(searchString16, 3); + } + + @Benchmark + public int searchString16MediumWithOffsetSuccess() { + return string16Medium.indexOf(searchString16, 3); + } + + @Benchmark + public int searchString16ShortWithOffsetSuccess() { + return string16Short.indexOf(searchString16, 2); + } + + @Benchmark + public int searchString16LongSuccess() { + return string16Long.indexOf(searchString16); + } + + @Benchmark + public int searchString16MediumSuccess() { + return string16Medium.indexOf(searchString16); + } + + @Benchmark + public int searchString16ShortSuccess() { + return string16Short.indexOf(searchString16); + } /** * Benchmarks String.indexOf with a rather small String to search and a rather small String to search for. The diff -r 3e39753ed05b -r b38f280d2114 test/micro/org/openjdk/bench/vm/compiler/FpMinMaxIntrinsics.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/micro/org/openjdk/bench/vm/compiler/FpMinMaxIntrinsics.java Sat Mar 09 12:54:20 2019 +0000 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2019, 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 org.openjdk.bench.vm.compiler; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.*; + +import java.util.concurrent.TimeUnit; +import java.util.Random; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +public class FpMinMaxIntrinsics { + private static final int COUNT = 1000; + + private double[] doubles = new double[COUNT]; + private float[] floats = new float[COUNT]; + + private int c1, c2, s1, s2; + + private Random r = new Random(); + + @Setup + public void init() { + c1 = s1 = step(); + c2 = COUNT - (s2 = step()); + + for (int i=0; i 0 ? c2 - s2 : COUNT - (s2 = step()); + } + + @Benchmark + public float fMinReduce() { + float result = Float.MAX_VALUE; + + for (int i=0; i