From 24961812899d088e94d5cabd46e1af98db9253b1 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Sat, 11 Jul 2015 14:54:07 +0300 Subject: [PATCH 001/109] 8081297: SSL Problem with Tomcat Reviewed-by: xuelei, jnimeh, ahgross --- .../TlsRsaPremasterSecretGenerator.java | 11 +-- .../TlsRsaPremasterSecretParameterSpec.java | 38 +++++++++++ .../security/ssl/RSAClientKeyExchange.java | 68 +++++++++++++++++-- .../classes/sun/security/util/KeyUtil.java | 9 +-- 4 files changed, 112 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/TlsRsaPremasterSecretGenerator.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/TlsRsaPremasterSecretGenerator.java index ef2d6351dde..8aa652255de 100644 --- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/TlsRsaPremasterSecretGenerator.java +++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/TlsRsaPremasterSecretGenerator.java @@ -76,11 +76,14 @@ public final class TlsRsaPremasterSecretGenerator extends KeyGeneratorSpi { "TlsRsaPremasterSecretGenerator must be initialized"); } - if (random == null) { - random = new SecureRandom(); + byte[] b = spec.getEncodedSecret(); + if (b == null) { + if (random == null) { + random = new SecureRandom(); + } + b = new byte[48]; + random.nextBytes(b); } - byte[] b = new byte[48]; - random.nextBytes(b); b[0] = (byte)spec.getMajorVersion(); b[1] = (byte)spec.getMinorVersion(); diff --git a/jdk/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java b/jdk/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java index ad44d4a5452..6a0fe12ed1c 100644 --- a/jdk/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java +++ b/jdk/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java @@ -43,6 +43,8 @@ import java.security.PrivilegedAction; public class TlsRsaPremasterSecretParameterSpec implements AlgorithmParameterSpec { + private final byte[] encodedSecret; + /* * The TLS spec says that the version in the RSA premaster secret must * be the maximum version supported by the client (i.e. the version it @@ -89,6 +91,33 @@ public class TlsRsaPremasterSecretParameterSpec this.clientVersion = checkVersion(clientVersion); this.serverVersion = checkVersion(serverVersion); + this.encodedSecret = null; + } + + /** + * Constructs a new TlsRsaPremasterSecretParameterSpec. + * + * @param clientVersion the version of the TLS protocol by which the + * client wishes to communicate during this session + * @param serverVersion the negotiated version of the TLS protocol which + * contains the lower of that suggested by the client in the client + * hello and the highest supported by the server. + * @param encodedSecret the encoded secret key + * + * @throws IllegalArgumentException if clientVersion or serverVersion are + * negative or larger than (2^16 - 1) or if encodedSecret is not + * exactly 48 bytes + */ + public TlsRsaPremasterSecretParameterSpec( + int clientVersion, int serverVersion, byte[] encodedSecret) { + + this.clientVersion = checkVersion(clientVersion); + this.serverVersion = checkVersion(serverVersion); + if (encodedSecret == null || encodedSecret.length != 48) { + throw new IllegalArgumentException( + "Encoded secret is not exactly 48 bytes"); + } + this.encodedSecret = encodedSecret.clone(); } /** @@ -147,4 +176,13 @@ public class TlsRsaPremasterSecretParameterSpec } return version; } + + /** + * Returns the encoded secret. + * + * @return the encoded secret, may be null if no encoded secret. + */ + public byte[] getEncodedSecret() { + return encodedSecret == null ? null : encodedSecret.clone(); + } } diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java b/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java index f56401e1dbf..9d403db3dae 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java @@ -113,14 +113,41 @@ final class RSAClientKeyExchange extends HandshakeMessage { } } + boolean needFailover = false; + byte[] encoded = null; try { Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1); - cipher.init(Cipher.UNWRAP_MODE, privateKey, - new TlsRsaPremasterSecretParameterSpec( - maxVersion.v, currentVersion.v), - generator); - preMaster = (SecretKey)cipher.unwrap(encrypted, - "TlsRsaPremasterSecret", Cipher.SECRET_KEY); + needFailover = !KeyUtil.isOracleJCEProvider( + cipher.getProvider().getName()); + if (needFailover) { + cipher.init(Cipher.DECRYPT_MODE, privateKey); + encoded = cipher.doFinal(encrypted); + encoded = KeyUtil.checkTlsPreMasterSecretKey( + maxVersion.v, currentVersion.v, + generator, encoded, false); + preMaster = generatePreMasterSecret( + maxVersion.v, currentVersion.v, + encoded, generator); + } else { + cipher.init(Cipher.UNWRAP_MODE, privateKey, + new TlsRsaPremasterSecretParameterSpec( + maxVersion.v, currentVersion.v), + generator); + preMaster = (SecretKey)cipher.unwrap(encrypted, + "TlsRsaPremasterSecret", Cipher.SECRET_KEY); + } + } catch (BadPaddingException bpe) { + if (needFailover) { + encoded = KeyUtil.checkTlsPreMasterSecretKey( + maxVersion.v, currentVersion.v, + generator, null, false); + preMaster = generatePreMasterSecret( + maxVersion.v, currentVersion.v, + encoded, generator); + } else { + // Otherwise, unlikely to happen + throw new RuntimeException("Unexpected exception", bpe); + } } catch (InvalidKeyException ibk) { // the message is too big to process with RSA throw new SSLProtocolException( @@ -135,6 +162,35 @@ final class RSAClientKeyExchange extends HandshakeMessage { } } + // generate a premaster secret with the specified version number + @SuppressWarnings("deprecation") + private static SecretKey generatePreMasterSecret( + int clientVersion, int serverVersion, + byte[] encodedSecret, SecureRandom generator) { + + if (debug != null && Debug.isOn("handshake")) { + System.out.println("Generating a premaster secret"); + } + + try { + String s = ((clientVersion >= ProtocolVersion.TLS12.v) ? + "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret"); + KeyGenerator kg = JsseJce.getKeyGenerator(s); + kg.init(new TlsRsaPremasterSecretParameterSpec( + clientVersion, serverVersion, encodedSecret), + generator); + return kg.generateKey(); + } catch (InvalidAlgorithmParameterException | + NoSuchAlgorithmException iae) { + // unlikely to happen, otherwise, must be a provider exception + if (debug != null && Debug.isOn("handshake")) { + System.out.println("RSA premaster secret generation error:"); + iae.printStackTrace(System.out); + } + throw new RuntimeException("Could not generate premaster secret", iae); + } + } + @Override int messageType() { return ht_client_key_exchange; diff --git a/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java b/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java index 5e0f58ca2be..1397f3b05e9 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java +++ b/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java @@ -143,8 +143,6 @@ public final class KeyUtil { /** * Returns whether the specified provider is Oracle provider or not. - *

- * Note that this method is only apply to SunJCE and SunPKCS11 at present. * * @param providerName * the provider name @@ -152,8 +150,11 @@ public final class KeyUtil { * {@code providerName} is Oracle provider */ public static final boolean isOracleJCEProvider(String providerName) { - return providerName != null && (providerName.equals("SunJCE") || - providerName.startsWith("SunPKCS11")); + return providerName != null && + (providerName.equals("SunJCE") || + providerName.equals("SunMSCAPI") || + providerName.equals("OracleUcrypto") || + providerName.startsWith("SunPKCS11")); } /** From 72e0832da6dc5aa297503c869e986a74f0a6589d Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Wed, 29 Jul 2015 13:42:56 +0100 Subject: [PATCH 002/109] 8059054: Better URL processing Reviewed-by: chegar, rriggs, ahgross, coffeys, igerasim --- .../java.base/share/classes/java/net/URL.java | 241 +++++++++++++++++- 1 file changed, 232 insertions(+), 9 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/URL.java b/jdk/src/java.base/share/classes/java/net/URL.java index e8a694116fd..2235a4edd2a 100644 --- a/jdk/src/java.base/share/classes/java/net/URL.java +++ b/jdk/src/java.base/share/classes/java/net/URL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -31,6 +31,10 @@ import java.net.spi.URLStreamHandlerProvider; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Hashtable; +import java.io.InvalidObjectException; +import java.io.ObjectStreamException; +import java.io.ObjectStreamField; +import java.io.ObjectInputStream.GetField; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.ServiceConfigurationError; @@ -142,6 +146,7 @@ import sun.security.util.SecurityConstants; */ public final class URL implements java.io.Serializable { + static final String BUILTIN_HANDLERS_PREFIX = "sun.net.www.protocol"; static final long serialVersionUID = -7627629688361524110L; /** @@ -226,6 +231,8 @@ public final class URL implements java.io.Serializable { */ private int hashCode = -1; + private transient UrlDeserializedState tempState; + /** * Creates a {@code URL} object from the specified * {@code protocol}, {@code host}, {@code port} @@ -1353,6 +1360,31 @@ public final class URL implements java.io.Serializable { return handler; } + /** + * @serialField protocol String + * + * @serialField host String + * + * @serialField port int + * + * @serialField authority String + * + * @serialField file String + * + * @serialField ref String + * + * @serialField hashCode int + * + */ + private static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField("protocol", String.class), + new ObjectStreamField("host", String.class), + new ObjectStreamField("port", int.class), + new ObjectStreamField("authority", String.class), + new ObjectStreamField("file", String.class), + new ObjectStreamField("ref", String.class), + new ObjectStreamField("hashCode", int.class), }; + /** * WriteObject is called to save the state of the URL to an * ObjectOutputStream. The handler is not saved since it is @@ -1375,16 +1407,67 @@ public final class URL implements java.io.Serializable { * stream handler. */ private synchronized void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException - { - s.defaultReadObject(); // read the fields - if ((handler = getURLStreamHandler(protocol)) == null) { + throws IOException, ClassNotFoundException { + GetField gf = s.readFields(); + String protocol = (String)gf.get("protocol", null); + if (getURLStreamHandler(protocol) == null) { throw new IOException("unknown protocol: " + protocol); } + String host = (String)gf.get("host", null); + int port = gf.get("port", -1); + String authority = (String)gf.get("authority", null); + String file = (String)gf.get("file", null); + String ref = (String)gf.get("ref", null); + int hashCode = gf.get("hashCode", -1); + if (authority == null + && ((host != null && host.length() > 0) || port != -1)) { + if (host == null) + host = ""; + authority = (port == -1) ? host : host + ":" + port; + } + tempState = new UrlDeserializedState(protocol, host, port, authority, + file, ref, hashCode); + } + + /** + * Replaces the de-serialized object with an URL object. + * + * @return a newly created object from deserialized data + * + * @throws ObjectStreamException if a new object replacing this + * object could not be created + */ + + private Object readResolve() throws ObjectStreamException { + + URLStreamHandler handler = null; + // already been checked in readObject + handler = getURLStreamHandler(tempState.getProtocol()); + + URL replacementURL = null; + if (isBuiltinStreamHandler(handler.getClass().getName())) { + replacementURL = fabricateNewURL(); + } else { + replacementURL = setDeserializedFields(handler); + } + return replacementURL; + } + + private URL setDeserializedFields(URLStreamHandler handler) { + URL replacementURL; + String userInfo = null; + String protocol = tempState.getProtocol(); + String host = tempState.getHost(); + int port = tempState.getPort(); + String authority = tempState.getAuthority(); + String file = tempState.getFile(); + String ref = tempState.getRef(); + int hashCode = tempState.getHashCode(); + // Construct authority part - if (authority == null && - ((host != null && host.length() > 0) || port != -1)) { + if (authority == null + && ((host != null && host.length() > 0) || port != -1)) { if (host == null) host = ""; authority = (port == -1) ? host : host + ":" + port; @@ -1403,8 +1486,8 @@ public final class URL implements java.io.Serializable { } // Construct path and query part - path = null; - query = null; + String path = null; + String query = null; if (file != null) { // Fix: only do this if hierarchical? int q = file.lastIndexOf('?'); @@ -1414,6 +1497,67 @@ public final class URL implements java.io.Serializable { } else path = file; } + + if (port == -1) { + port = 0; + } + // Set the object fields. + this.protocol = protocol; + this.host = host; + this.port = port; + this.file = file; + this.authority = authority; + this.ref = ref; + this.hashCode = hashCode; + this.handler = handler; + this.query = query; + this.path = path; + this.userInfo = userInfo; + replacementURL = this; + return replacementURL; + } + + private URL fabricateNewURL() + throws InvalidObjectException { + // create URL string from deserialized object + URL replacementURL = null; + String urlString = tempState.reconstituteUrlString(); + + try { + replacementURL = new URL(urlString); + } catch (MalformedURLException mEx) { + resetState(); + InvalidObjectException invoEx = new InvalidObjectException( + "Malformed URL: " + urlString); + invoEx.initCause(mEx); + throw invoEx; + } + replacementURL.setSerializedHashCode(tempState.getHashCode()); + resetState(); + return replacementURL; + } + + private boolean isBuiltinStreamHandler(String handlerClassName) { + return (handlerClassName.startsWith(BUILTIN_HANDLERS_PREFIX)); + } + + private void resetState() { + this.protocol = null; + this.host = null; + this.port = -1; + this.file = null; + this.authority = null; + this.ref = null; + this.hashCode = -1; + this.handler = null; + this.query = null; + this.path = null; + this.userInfo = null; + this.tempState = null; + } + + private void setSerializedHashCode(int hc) { + this.hashCode = hc; } } @@ -1445,3 +1589,82 @@ class Parts { return ref; } } + +final class UrlDeserializedState { + private final String protocol; + private final String host; + private final int port; + private final String authority; + private final String file; + private final String ref; + private final int hashCode; + + public UrlDeserializedState(String protocol, + String host, int port, + String authority, String file, + String ref, int hashCode) { + this.protocol = protocol; + this.host = host; + this.port = port; + this.authority = authority; + this.file = file; + this.ref = ref; + this.hashCode = hashCode; + } + + String getProtocol() { + return protocol; + } + + String getHost() { + return host; + } + + String getAuthority () { + return authority; + } + + int getPort() { + return port; + } + + String getFile () { + return file; + } + + String getRef () { + return ref; + } + + int getHashCode () { + return hashCode; + } + + String reconstituteUrlString() { + + // pre-compute length of StringBuffer + int len = protocol.length() + 1; + if (authority != null && authority.length() > 0) + len += 2 + authority.length(); + if (file != null) { + len += file.length(); + } + if (ref != null) + len += 1 + ref.length(); + StringBuilder result = new StringBuilder(len); + result.append(protocol); + result.append(":"); + if (authority != null && authority.length() > 0) { + result.append("//"); + result.append(authority); + } + if (file != null) { + result.append(file); + } + if (ref != null) { + result.append("#"); + result.append(ref); + } + return result.toString(); + } +} From 3b45c076803b4a718dae6fe9b58c5dc18682677e Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Mon, 3 Aug 2015 12:18:10 +0300 Subject: [PATCH 003/109] 8132209: DiagnosticCommandImpl.getNotificationInfo() may expose internal representation DiagnosticCommandImpl.getNotificationInfo() may expose internal representation Reviewed-by: skoivu, fparain, jbachorik --- .../com/sun/management/internal/DiagnosticCommandImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java b/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java index a0718a3c2f3..5e149633dcd 100644 --- a/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java +++ b/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java @@ -343,7 +343,7 @@ public class DiagnosticCommandImpl extends NotificationEmitterSupport "Diagnostic Framework Notification"); } } - return notifInfo; + return notifInfo.clone(); } private static long seqNumber = 0; From be335f3af5dabdc0d7d01b551f8704e1f975442b Mon Sep 17 00:00:00 2001 From: Shanliang Jiang Date: Thu, 3 Sep 2015 09:33:04 +0200 Subject: [PATCH 004/109] 8130710: Better attributes processing Reviewed-by: jbachorik, dfuchs, ahgross --- .../remote/rmi/RMIConnectionImpl.java | 7 ++--- .../management/remote/rmi/RMIConnector.java | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java index dd050e4ef9c..c37e3e9af12 100644 --- a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java +++ b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java @@ -359,7 +359,6 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { "connectionId=" + connectionId +", className=" + className +", name=" + name - +", params=" + objects(values) +", signature=" + strings(signature)); return (ObjectInstance) @@ -425,7 +424,6 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { +", className=" + className +", name=" + name +", loaderName=" + loaderName - +", params=" + objects(values) +", signature=" + strings(signature)); return (ObjectInstance) @@ -717,7 +715,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { if (debug) logger.debug("setAttribute", "connectionId=" + connectionId +", name="+name - +", attribute="+attr); + +", attribute name="+attr.getName()); doPrivilegedOperation( SET_ATTRIBUTE, @@ -768,7 +766,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { if (debug) logger.debug("setAttributes", "connectionId=" + connectionId +", name="+name - +", attributes="+attrlist); + +", attribute names="+RMIConnector.getAttributesNames(attrlist)); return (AttributeList) doPrivilegedOperation( @@ -823,7 +821,6 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { "connectionId=" + connectionId +", name="+name +", operationName="+operationName - +", params="+objects(values) +", signature="+strings(signature)); return diff --git a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java index 4bd796e3e7a..bb4057db54a 100644 --- a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java +++ b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java @@ -65,6 +65,7 @@ import java.util.Hashtable; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; +import java.util.stream.Collectors; import javax.management.Attribute; import javax.management.AttributeList; import javax.management.AttributeNotFoundException; @@ -689,9 +690,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable if (logger.debugOn()) logger.debug("createMBean(String,ObjectName,Object[],String[])", "className=" + className + ", name=" - + name + ", params=" - + objects(params) + ", signature=" - + strings(signature)); + + name + ", signature=" + strings(signature)); final MarshalledObject sParams = new MarshalledObject(params); @@ -730,8 +729,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable if (logger.debugOn()) logger.debug( "createMBean(String,ObjectName,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", loaderName=" - + loaderName + ", params=" + objects(params) - + ", signature=" + strings(signature)); + + loaderName + ", signature=" + strings(signature)); final MarshalledObject sParams = new MarshalledObject(params); @@ -931,8 +929,8 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable IOException { if (logger.debugOn()) logger.debug("setAttribute", - "name=" + name + ", attribute=" - + attribute); + "name=" + name + ", attribute name=" + + attribute.getName()); final MarshalledObject sAttribute = new MarshalledObject(attribute); @@ -954,9 +952,11 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable ReflectionException, IOException { - if (logger.debugOn()) logger.debug("setAttributes", - "name=" + name + ", attributes=" - + attributes); + if (logger.debugOn()) { + logger.debug("setAttributes", + "name=" + name + ", attribute names=" + + getAttributesNames(attributes)); + } final MarshalledObject sAttributes = new MarshalledObject(attributes); @@ -989,7 +989,6 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable if (logger.debugOn()) logger.debug("invoke", "name=" + name + ", operationName=" + operationName - + ", params=" + objects(params) + ", signature=" + strings(signature)); final MarshalledObject sParams = @@ -2246,4 +2245,12 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable private static String strings(final String[] strs) { return objects(strs); } + + static String getAttributesNames(AttributeList attributes) { + return attributes != null ? + attributes.asList().stream() + .map(Attribute::getName) + .collect(Collectors.joining("[", ", ", "]")) + : "[]"; + } } From 3febcc8b758771cd37151fa4b7137d70c731536b Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Mon, 7 Sep 2015 18:58:41 +0300 Subject: [PATCH 005/109] 8074068: Cleanup in java.base/share/classes/sun/security/x509/ Reviewed-by: mullan, ahgross, coffeys --- .../sun/security/x509/AlgorithmId.java | 2 +- .../x509/CRLDistributionPointsExtension.java | 8 +++-- .../sun/security/x509/CRLNumberExtension.java | 7 ++-- .../classes/sun/security/x509/DNSName.java | 12 +++---- .../sun/security/x509/EDIPartyName.java | 2 +- .../sun/security/x509/GeneralSubtrees.java | 2 +- .../sun/security/x509/IPAddressName.java | 20 ++++++----- .../IssuingDistributionPointExtension.java | 2 +- .../sun/security/x509/KeyIdentifier.java | 4 +-- .../x509/PolicyMappingsExtension.java | 2 +- .../x509/PrivateKeyUsageExtension.java | 6 ++-- .../share/classes/sun/security/x509/RDN.java | 34 +++++++------------ .../x509/SubjectInfoAccessExtension.java | 4 ++- .../classes/sun/security/x509/URIName.java | 2 +- .../classes/sun/security/x509/X500Name.java | 13 +++---- .../sun/security/x509/X509AttributeName.java | 2 +- .../sun/security/x509/X509CRLImpl.java | 8 ++--- .../sun/security/x509/X509CertImpl.java | 4 +-- 18 files changed, 60 insertions(+), 74 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java b/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java index f84371da80e..60b0b922190 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/AlgorithmId.java @@ -588,7 +588,7 @@ public class AlgorithmId implements Serializable, DerEncoder { } if (oidTable == null) { - oidTable = new HashMap<>(1); + oidTable = Collections.emptyMap(); } initOidTable = true; } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/CRLDistributionPointsExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/CRLDistributionPointsExtension.java index d60f7f13079..cb7f106e685 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/CRLDistributionPointsExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/CRLDistributionPointsExtension.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.*; +import java.util.Collections; import sun.security.util.DerOutputStream; import sun.security.util.DerValue; @@ -255,11 +256,12 @@ public class CRLDistributionPointsExtension extends Extension */ public void delete(String name) throws IOException { if (name.equalsIgnoreCase(POINTS)) { - distributionPoints = new ArrayList(); + distributionPoints = + Collections.emptyList(); } else { throw new IOException("Attribute name [" + name + - "] not recognized by " + - "CertAttrSet:" + extensionName + "."); + "] not recognized by " + + "CertAttrSet:" + extensionName + '.'); } encodeThis(); } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/CRLNumberExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/CRLNumberExtension.java index 7a66f0b935f..9434e613441 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/CRLNumberExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/CRLNumberExtension.java @@ -157,11 +157,10 @@ implements CertAttrSet { */ public BigInteger get(String name) throws IOException { if (name.equalsIgnoreCase(NUMBER)) { - if (crlNumber == null) return null; - else return crlNumber; + return crlNumber; } else { - throw new IOException("Attribute name not recognized by" - + " CertAttrSet:" + extensionName + "."); + throw new IOException("Attribute name not recognized by" + + " CertAttrSet:" + extensionName + '.'); } } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/DNSName.java b/jdk/src/java.base/share/classes/sun/security/x509/DNSName.java index 449d7550043..c9aa54aa73e 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/DNSName.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/DNSName.java @@ -232,15 +232,15 @@ public class DNSName implements GeneralNameInterface { * @throws UnsupportedOperationException if not supported for this name type */ public int subtreeDepth() throws UnsupportedOperationException { - String subtree=name; - int i=1; + // subtree depth is always at least 1 + int sum = 1; - /* count dots */ - for (; subtree.lastIndexOf('.') >= 0; i++) { - subtree=subtree.substring(0,subtree.lastIndexOf('.')); + // count dots + for (int i = name.indexOf('.'); i >= 0; i = name.indexOf('.', i + 1)) { + ++sum; } - return i; + return sum; } } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/EDIPartyName.java b/jdk/src/java.base/share/classes/sun/security/x509/EDIPartyName.java index 74c0e4df7d4..2ba0b56ad6f 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/EDIPartyName.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/EDIPartyName.java @@ -197,7 +197,7 @@ public class EDIPartyName implements GeneralNameInterface { */ public int hashCode() { if (myhash == -1) { - myhash = 37 + party.hashCode(); + myhash = 37 + (party == null ? 1 : party.hashCode()); if (assigner != null) { myhash = 37 * myhash + assigner.hashCode(); } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/GeneralSubtrees.java b/jdk/src/java.base/share/classes/sun/security/x509/GeneralSubtrees.java index 5a1f8c7de65..847f56aba86 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/GeneralSubtrees.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/GeneralSubtrees.java @@ -189,7 +189,7 @@ public class GeneralSubtrees implements Cloneable { // the list: if any subsequent entry matches or widens entry n, // remove entry n. If any subsequent entries narrow entry n, remove // the subsequent entries. - for (int i = 0; i < size(); i++) { + for (int i = 0; i < (size() - 1); i++) { GeneralNameInterface current = getGeneralNameInterface(i); boolean remove1 = false; diff --git a/jdk/src/java.base/share/classes/sun/security/x509/IPAddressName.java b/jdk/src/java.base/share/classes/sun/security/x509/IPAddressName.java index c94df301bcb..50f045758be 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/IPAddressName.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/IPAddressName.java @@ -197,8 +197,10 @@ public class IPAddressName implements GeneralNameInterface { // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); - if (prefixLen > 128) - throw new IOException("IPv6Address prefix is longer than 128"); + if (prefixLen < 0 || prefixLen > 128) { + throw new IOException("IPv6Address prefix length (" + + prefixLen + ") in out of valid range [0,128]"); + } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); @@ -317,7 +319,8 @@ public class IPAddressName implements GeneralNameInterface { if (!(obj instanceof IPAddressName)) return false; - byte[] other = ((IPAddressName)obj).getBytes(); + IPAddressName otherName = (IPAddressName)obj; + byte[] other = otherName.address; if (other.length != address.length) return false; @@ -326,12 +329,10 @@ public class IPAddressName implements GeneralNameInterface { // Two subnet addresses // Mask each and compare masked values int maskLen = address.length/2; - byte[] maskedThis = new byte[maskLen]; - byte[] maskedOther = new byte[maskLen]; for (int i=0; i < maskLen; i++) { - maskedThis[i] = (byte)(address[i] & address[i+maskLen]); - maskedOther[i] = (byte)(other[i] & other[i+maskLen]); - if (maskedThis[i] != maskedOther[i]) { + byte maskedThis = (byte)(address[i] & address[i+maskLen]); + byte maskedOther = (byte)(other[i] & other[i+maskLen]); + if (maskedThis != maskedOther) { return false; } } @@ -400,7 +401,8 @@ public class IPAddressName implements GeneralNameInterface { else if (((IPAddressName)inputName).equals(this)) constraintType = NAME_MATCH; else { - byte[] otherAddress = ((IPAddressName)inputName).getBytes(); + IPAddressName otherName = (IPAddressName)inputName; + byte[] otherAddress = otherName.address; if (otherAddress.length == 4 && address.length == 4) // Two host addresses constraintType = NAME_SAME_TYPE; diff --git a/jdk/src/java.base/share/classes/sun/security/x509/IssuingDistributionPointExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/IssuingDistributionPointExtension.java index 26dd18a352b..580225859b9 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/IssuingDistributionPointExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/IssuingDistributionPointExtension.java @@ -261,6 +261,7 @@ public class IssuingDistributionPointExtension extends Extension throw new IOException( "Attribute value should be of type ReasonFlags."); } + revocationReasons = (ReasonFlags)obj; } else if (name.equalsIgnoreCase(INDIRECT_CRL)) { if (!(obj instanceof Boolean)) { @@ -290,7 +291,6 @@ public class IssuingDistributionPointExtension extends Extension } hasOnlyAttributeCerts = ((Boolean)obj).booleanValue(); - } else { throw new IOException("Attribute name [" + name + "] not recognized by " + diff --git a/jdk/src/java.base/share/classes/sun/security/x509/KeyIdentifier.java b/jdk/src/java.base/share/classes/sun/security/x509/KeyIdentifier.java index 74139a4f6b5..97036e2ea88 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/KeyIdentifier.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/KeyIdentifier.java @@ -148,7 +148,7 @@ public class KeyIdentifier { return true; if (!(other instanceof KeyIdentifier)) return false; - return java.util.Arrays.equals(octetString, - ((KeyIdentifier)other).getIdentifier()); + byte[] otherString = ((KeyIdentifier)other).octetString; + return java.util.Arrays.equals(octetString, otherString); } } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/PolicyMappingsExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/PolicyMappingsExtension.java index 175201c732b..ed931a2119b 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/PolicyMappingsExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/PolicyMappingsExtension.java @@ -102,7 +102,7 @@ implements CertAttrSet { public PolicyMappingsExtension() { extensionId = PKIXExtensions.PolicyMappings_Id; critical = true; - maps = new ArrayList(); + maps = Collections.emptyList(); } /** diff --git a/jdk/src/java.base/share/classes/sun/security/x509/PrivateKeyUsageExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/PrivateKeyUsageExtension.java index 0cb40155025..afb08b1a68e 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/PrivateKeyUsageExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/PrivateKeyUsageExtension.java @@ -33,6 +33,7 @@ import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateNotYetValidException; import java.util.Date; import java.util.Enumeration; +import java.util.Objects; import sun.security.util.*; @@ -217,16 +218,17 @@ implements CertAttrSet { */ public void valid(Date now) throws CertificateNotYetValidException, CertificateExpiredException { + Objects.requireNonNull(now); /* * we use the internal Dates rather than the passed in Date * because someone could override the Date methods after() * and before() to do something entirely different. */ - if (notBefore.after(now)) { + if (notBefore != null && notBefore.after(now)) { throw new CertificateNotYetValidException("NotBefore: " + notBefore.toString()); } - if (notAfter.before(now)) { + if (notAfter != null && notAfter.before(now)) { throw new CertificateExpiredException("NotAfter: " + notAfter.toString()); } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/RDN.java b/jdk/src/java.base/share/classes/sun/security/x509/RDN.java index 6e927c4a340..2ee060930db 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/RDN.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/RDN.java @@ -27,6 +27,8 @@ package sun.security.x509; import java.io.IOException; import java.io.StringReader; +import java.util.Arrays; +import java.util.StringJoiner; import java.util.*; import sun.security.util.*; @@ -436,31 +438,19 @@ public class RDN { assertion[0].toRFC2253String(oidMap); } - StringBuilder relname = new StringBuilder(); - if (!canonical) { - for (int i = 0; i < assertion.length; i++) { - if (i > 0) { - relname.append('+'); - } - relname.append(assertion[i].toRFC2253String(oidMap)); - } - } else { + AVA[] toOutput = assertion; + if (canonical) { // order the string type AVA's alphabetically, // followed by the oid type AVA's numerically - List avaList = new ArrayList<>(assertion.length); - for (int i = 0; i < assertion.length; i++) { - avaList.add(assertion[i]); - } - java.util.Collections.sort(avaList, AVAComparator.getInstance()); - - for (int i = 0; i < avaList.size(); i++) { - if (i > 0) { - relname.append('+'); - } - relname.append(avaList.get(i).toRFC2253CanonicalString()); - } + toOutput = assertion.clone(); + Arrays.sort(toOutput, AVAComparator.getInstance()); } - return relname.toString(); + StringJoiner sj = new StringJoiner("+"); + for (AVA ava : toOutput) { + sj.add(canonical ? ava.toRFC2253CanonicalString() + : ava.toRFC2253String(oidMap)); + } + return sj.toString(); } } diff --git a/jdk/src/java.base/share/classes/sun/security/x509/SubjectInfoAccessExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/SubjectInfoAccessExtension.java index 8daa0b319b4..0acdf96057f 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/SubjectInfoAccessExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/SubjectInfoAccessExtension.java @@ -28,6 +28,7 @@ package sun.security.x509; import java.io.IOException; import java.io.OutputStream; +import java.util.Collections; import java.util.*; import sun.security.util.DerOutputStream; @@ -200,7 +201,8 @@ public class SubjectInfoAccessExtension extends Extension */ public void delete(String name) throws IOException { if (name.equalsIgnoreCase(DESCRIPTIONS)) { - accessDescriptions = new ArrayList(); + accessDescriptions = + Collections.emptyList(); } else { throw new IOException("Attribute name [" + name + "] not recognized by " + diff --git a/jdk/src/java.base/share/classes/sun/security/x509/URIName.java b/jdk/src/java.base/share/classes/sun/security/x509/URIName.java index 2f3e107ef0b..878d745a881 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/URIName.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/URIName.java @@ -165,7 +165,7 @@ public class URIName implements GeneralNameInterface { String host = uri.getSchemeSpecificPart(); try { DNSName hostDNS; - if (host.charAt(0) == '.') { + if (host.startsWith(".")) { hostDNS = new DNSName(host.substring(1)); } else { hostDNS = new DNSName(host); diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java b/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java index 740b7fed538..07f0aedf8e8 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/X500Name.java @@ -347,6 +347,8 @@ public class X500Name implements GeneralNameInterface, Principal { for (int i = 0; i < names.length; i++) { list.addAll(names[i].avas()); } + list = Collections.unmodifiableList(list); + allAvaList = list; } return list; } @@ -365,9 +367,6 @@ public class X500Name implements GeneralNameInterface, Principal { */ public boolean isEmpty() { int n = names.length; - if (n == 0) { - return true; - } for (int i = 0; i < n; i++) { if (names[i].assertion.length != 0) { return false; @@ -1103,12 +1102,8 @@ public class X500Name implements GeneralNameInterface, Principal { * and speed recognition of common X.500 attributes. */ static ObjectIdentifier intern(ObjectIdentifier oid) { - ObjectIdentifier interned = internedOIDs.get(oid); - if (interned != null) { - return interned; - } - internedOIDs.put(oid, oid); - return oid; + ObjectIdentifier interned = internedOIDs.putIfAbsent(oid, oid); + return (interned == null) ? oid : interned; } private static final Map internedOIDs diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509AttributeName.java b/jdk/src/java.base/share/classes/sun/security/x509/X509AttributeName.java index 090792aa2e9..c60b6f46010 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/X509AttributeName.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/X509AttributeName.java @@ -47,7 +47,7 @@ public class X509AttributeName { */ public X509AttributeName(String name) { int i = name.indexOf(SEPARATOR); - if (i == (-1)) { + if (i < 0) { prefix = name; } else { prefix = name.substring(0, i); diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java index 812778c02c0..1fc5bed4c83 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java @@ -762,9 +762,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { public byte[] getTBSCertList() throws CRLException { if (tbsCertList == null) throw new CRLException("Uninitialized CRL"); - byte[] dup = new byte[tbsCertList.length]; - System.arraycopy(tbsCertList, 0, dup, 0, dup.length); - return dup; + return tbsCertList.clone(); } /** @@ -775,9 +773,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { public byte[] getSignature() { if (signature == null) return null; - byte[] dup = new byte[signature.length]; - System.arraycopy(signature, 0, dup, 0, dup.length); - return dup; + return signature.clone(); } /** diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java index cc15fb23414..0e4da831a83 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java @@ -1001,9 +1001,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { public byte[] getSignature() { if (signature == null) return null; - byte[] dup = new byte[signature.length]; - System.arraycopy(signature, 0, dup, 0, dup.length); - return dup; + return signature.clone(); } /** From c05fa375933253976ca5586022250f01019034ee Mon Sep 17 00:00:00 2001 From: Shanliang Jiang Date: Tue, 8 Sep 2015 08:34:35 +0200 Subject: [PATCH 006/109] 8132210: Reinforce JMX collector internals Reviewed-by: jbachorik, ahgross --- .../internal/GarbageCollectorExtImpl.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/jdk/src/jdk.management/share/classes/com/sun/management/internal/GarbageCollectorExtImpl.java b/jdk/src/jdk.management/share/classes/com/sun/management/internal/GarbageCollectorExtImpl.java index 8e0512dde5f..fde7a0070df 100644 --- a/jdk/src/jdk.management/share/classes/com/sun/management/internal/GarbageCollectorExtImpl.java +++ b/jdk/src/jdk.management/share/classes/com/sun/management/internal/GarbageCollectorExtImpl.java @@ -81,17 +81,12 @@ public class GarbageCollectorExtImpl extends GarbageCollectorImpl GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION }; - private MBeanNotificationInfo[] notifInfo = null; public MBeanNotificationInfo[] getNotificationInfo() { - synchronized (this) { - if (notifInfo == null) { - notifInfo = new MBeanNotificationInfo[1]; - notifInfo[0] = new MBeanNotificationInfo(gcNotifTypes, - notifName, - "GC Notification"); - } - } - return notifInfo; + return new MBeanNotificationInfo[]{ + new MBeanNotificationInfo(gcNotifTypes, + notifName, + "GC Notification") + }; } private static long seqNumber = 0; From 0ab643787434613472d1290c09aa57c154af3e2c Mon Sep 17 00:00:00 2001 From: Vinnie Ryan Date: Wed, 7 Oct 2015 18:04:06 +0100 Subject: [PATCH 007/109] 8138589: Correct limits on unlimited cryptography Reviewed-by: mullan --- .../share/classes/com/sun/crypto/provider/PBES2Core.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java index 51c49b500ab..37873666eba 100644 --- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java +++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -263,7 +263,7 @@ abstract class PBES2Core extends CipherSpi { passwdChars[i] = (char) (passwdBytes[i] & 0x7f); PBEKeySpec pbeSpec = - new PBEKeySpec(passwdChars, salt, iCount, blkSize * 8); + new PBEKeySpec(passwdChars, salt, iCount, keyLength); // password char[] was cloned in PBEKeySpec constructor, // so we can zero it out here java.util.Arrays.fill(passwdChars, ' '); From 31abfb24a90dcb2112245b328682185da9a339d5 Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Tue, 13 Oct 2015 20:59:19 +0300 Subject: [PATCH 008/109] 8132988: Better printing dialogues Reviewed-by: prr, serb, mschoene --- .../macosx/classes/sun/lwawt/macosx/CPrinterJob.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java index a7b200981ed..c28e83bfbf2 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java @@ -235,6 +235,11 @@ public final class CPrinterJob extends RasterPrinterJob { // this will not work if the user clicks on the "Preview" button // However if the printer is a StreamPrintService, its the right path. PrintService psvc = getPrintService(); + + if (psvc == null) { + throw new PrinterException("No print service found."); + } + if (psvc instanceof StreamPrintService) { spoolToService(psvc, attributes); return; From 57e9de313667e5e4e5e116b379c2fb847b32e420 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Fri, 2 Oct 2015 11:50:20 +0300 Subject: [PATCH 009/109] 8134605: Partial rework of the fix for 8081297 Reviewed-by: xuelei, coffeys, valeriep --- .../classes/sun/security/jca/JCAUtil.java | 29 ++--- .../security/ssl/RSAClientKeyExchange.java | 29 ++--- .../classes/sun/security/util/KeyUtil.java | 6 +- .../sun/security/pkcs11/P11Cipher.java | 5 +- .../sun/security/pkcs11/P11RSACipher.java | 115 ++++++++---------- .../oracle/security/ucrypto/NativeCipher.java | 7 +- .../security/ucrypto/NativeGCMCipher.java | 7 +- .../security/ucrypto/NativeRSACipher.java | 4 + 8 files changed, 95 insertions(+), 107 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/jca/JCAUtil.java b/jdk/src/java.base/share/classes/sun/security/jca/JCAUtil.java index 7515a22b40e..59375cc220b 100644 --- a/jdk/src/java.base/share/classes/sun/security/jca/JCAUtil.java +++ b/jdk/src/java.base/share/classes/sun/security/jca/JCAUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -41,12 +41,6 @@ public final class JCAUtil { // no instantiation } - // lock to use for synchronization - private static final Object LOCK = JCAUtil.class; - - // cached SecureRandom instance - private static volatile SecureRandom secureRandom; - // size of the temporary arrays we use. Should fit into the CPU's 1st // level cache and could be adjusted based on the platform private static final int ARRAY_SIZE = 4096; @@ -60,26 +54,19 @@ public final class JCAUtil { return Math.min(ARRAY_SIZE, totalSize); } + // cached SecureRandom instance + private static class CachedSecureRandomHolder { + public static SecureRandom instance = new SecureRandom(); + } + /** - * Get a SecureRandom instance. This method should me used by JDK + * Get a SecureRandom instance. This method should be used by JDK * internal code in favor of calling "new SecureRandom()". That needs to * iterate through the provider table to find the default SecureRandom * implementation, which is fairly inefficient. */ public static SecureRandom getSecureRandom() { - // we use double checked locking to minimize synchronization - // works because we use a volatile reference - SecureRandom r = secureRandom; - if (r == null) { - synchronized (LOCK) { - r = secureRandom; - if (r == null) { - r = new SecureRandom(); - secureRandom = r; - } - } - } - return r; + return CachedSecureRandomHolder.instance; } } diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java b/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java index 9d403db3dae..b374b8c42d7 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,18 +113,23 @@ final class RSAClientKeyExchange extends HandshakeMessage { } } - boolean needFailover = false; byte[] encoded = null; try { Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1); - needFailover = !KeyUtil.isOracleJCEProvider( - cipher.getProvider().getName()); + boolean needFailover = !KeyUtil.isOracleJCEProvider( + cipher.getProvider().getName()); if (needFailover) { cipher.init(Cipher.DECRYPT_MODE, privateKey); - encoded = cipher.doFinal(encrypted); + boolean failed = false; + try { + encoded = cipher.doFinal(encrypted); + } catch (BadPaddingException bpe) { + // Note: encoded == null + failed = true; + } encoded = KeyUtil.checkTlsPreMasterSecretKey( maxVersion.v, currentVersion.v, - generator, encoded, false); + generator, encoded, failed); preMaster = generatePreMasterSecret( maxVersion.v, currentVersion.v, encoded, generator); @@ -136,18 +141,6 @@ final class RSAClientKeyExchange extends HandshakeMessage { preMaster = (SecretKey)cipher.unwrap(encrypted, "TlsRsaPremasterSecret", Cipher.SECRET_KEY); } - } catch (BadPaddingException bpe) { - if (needFailover) { - encoded = KeyUtil.checkTlsPreMasterSecretKey( - maxVersion.v, currentVersion.v, - generator, null, false); - preMaster = generatePreMasterSecret( - maxVersion.v, currentVersion.v, - encoded, generator); - } else { - // Otherwise, unlikely to happen - throw new RuntimeException("Unexpected exception", bpe); - } } catch (InvalidKeyException ibk) { // the message is too big to process with RSA throw new SSLProtocolException( diff --git a/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java b/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java index 1397f3b05e9..70f5952b077 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java +++ b/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -41,6 +41,8 @@ import javax.crypto.spec.DHParameterSpec; import javax.crypto.spec.DHPublicKeySpec; import java.math.BigInteger; +import sun.security.jca.JCAUtil; + /** * A utility class to get key length, valiate keys, etc. */ @@ -201,7 +203,7 @@ public final class KeyUtil { byte[] encoded, boolean isFailOver) { if (random == null) { - random = new SecureRandom(); + random = JCAUtil.getSecureRandom(); } byte[] replacer = new byte[48]; random.nextBytes(replacer); diff --git a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Cipher.java b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Cipher.java index 690d865167e..022dc3be72a 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Cipher.java +++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11Cipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -35,6 +35,7 @@ import javax.crypto.*; import javax.crypto.spec.*; import sun.nio.ch.DirectBuffer; +import sun.security.jca.JCAUtil; import sun.security.pkcs11.wrapper.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; @@ -379,7 +380,7 @@ final class P11Cipher extends CipherSpi { } // generate random IV if (random == null) { - random = new SecureRandom(); + random = JCAUtil.getSecureRandom(); } iv = new byte[blockSize]; random.nextBytes(iv); diff --git a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11RSACipher.java b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11RSACipher.java index bc65e2f2424..58a4e2f545d 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11RSACipher.java +++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11RSACipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -470,49 +470,49 @@ final class P11RSACipher extends CipherSpi { algorithm.equals("TlsRsaPremasterSecret"); Exception failover = null; - SecureRandom secureRandom = random; - if (secureRandom == null && isTlsRsaPremasterSecret) { - secureRandom = new SecureRandom(); - } - // Should C_Unwrap be preferred for non-TLS RSA premaster secret? if (token.supportsRawSecretKeyImport()) { // XXX implement unwrap using C_Unwrap() for all keys implInit(Cipher.DECRYPT_MODE, p11Key); - if (wrappedKey.length > maxInputSize) { - throw new InvalidKeyException("Key is too long for unwrapping"); - } - - byte[] encoded = null; - implUpdate(wrappedKey, 0, wrappedKey.length); try { - encoded = doFinal(); - } catch (BadPaddingException e) { - if (isTlsRsaPremasterSecret) { - failover = e; - } else { + if (wrappedKey.length > maxInputSize) { + throw new InvalidKeyException("Key is too long for unwrapping"); + } + + byte[] encoded = null; + implUpdate(wrappedKey, 0, wrappedKey.length); + try { + encoded = doFinal(); + } catch (BadPaddingException e) { + if (isTlsRsaPremasterSecret) { + failover = e; + } else { + throw new InvalidKeyException("Unwrapping failed", e); + } + } catch (IllegalBlockSizeException e) { + // should not occur, handled with length check above throw new InvalidKeyException("Unwrapping failed", e); } - } catch (IllegalBlockSizeException e) { - // should not occur, handled with length check above - throw new InvalidKeyException("Unwrapping failed", e); - } - if (isTlsRsaPremasterSecret) { - if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) { - throw new IllegalStateException( - "No TlsRsaPremasterSecretParameterSpec specified"); + if (isTlsRsaPremasterSecret) { + if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) { + throw new IllegalStateException( + "No TlsRsaPremasterSecretParameterSpec specified"); + } + + // polish the TLS premaster secret + TlsRsaPremasterSecretParameterSpec psps = + (TlsRsaPremasterSecretParameterSpec)spec; + encoded = KeyUtil.checkTlsPreMasterSecretKey( + psps.getClientVersion(), psps.getServerVersion(), + random, encoded, (failover != null)); } - // polish the TLS premaster secret - TlsRsaPremasterSecretParameterSpec psps = - (TlsRsaPremasterSecretParameterSpec)spec; - encoded = KeyUtil.checkTlsPreMasterSecretKey( - psps.getClientVersion(), psps.getServerVersion(), - secureRandom, encoded, (failover != null)); + return ConstructKeys.constructKey(encoded, algorithm, type); + } finally { + // Restore original mode + implInit(Cipher.UNWRAP_MODE, p11Key); } - - return ConstructKeys.constructKey(encoded, algorithm, type); } else { Session s = null; SecretKey secretKey = null; @@ -540,20 +540,13 @@ final class P11RSACipher extends CipherSpi { } if (isTlsRsaPremasterSecret) { - byte[] replacer = new byte[48]; - if (failover == null) { - // Does smart compiler dispose this operation? - secureRandom.nextBytes(replacer); - } - TlsRsaPremasterSecretParameterSpec psps = (TlsRsaPremasterSecretParameterSpec)spec; - // Please use the tricky failover and replacer byte array - // as the parameters so that smart compiler won't dispose - // the unused variable . + // Please use the tricky failover as the parameter so that + // smart compiler won't dispose the unused variable. secretKey = polishPreMasterSecretKey(token, s, - failover, replacer, secretKey, + failover, secretKey, psps.getClientVersion(), psps.getServerVersion()); } @@ -572,29 +565,27 @@ final class P11RSACipher extends CipherSpi { private static SecretKey polishPreMasterSecretKey( Token token, Session session, - Exception failover, byte[] replacer, SecretKey secretKey, + Exception failover, SecretKey unwrappedKey, int clientVersion, int serverVersion) { - if (failover != null) { - CK_VERSION version = new CK_VERSION( - (clientVersion >>> 8) & 0xFF, clientVersion & 0xFF); - try { - CK_ATTRIBUTE[] attributes = token.getAttributes( - O_GENERATE, CKO_SECRET_KEY, - CKK_GENERIC_SECRET, new CK_ATTRIBUTE[0]); - long keyID = token.p11.C_GenerateKey(session.id(), - // new CK_MECHANISM(CKM_TLS_PRE_MASTER_KEY_GEN, version), - new CK_MECHANISM(CKM_SSL3_PRE_MASTER_KEY_GEN, version), - attributes); - return P11Key.secretKey(session, - keyID, "TlsRsaPremasterSecret", 48 << 3, attributes); - } catch (PKCS11Exception e) { - throw new ProviderException( - "Could not generate premaster secret", e); - } + SecretKey newKey; + CK_VERSION version = new CK_VERSION( + (clientVersion >>> 8) & 0xFF, clientVersion & 0xFF); + try { + CK_ATTRIBUTE[] attributes = token.getAttributes( + O_GENERATE, CKO_SECRET_KEY, + CKK_GENERIC_SECRET, new CK_ATTRIBUTE[0]); + long keyID = token.p11.C_GenerateKey(session.id(), + new CK_MECHANISM(CKM_SSL3_PRE_MASTER_KEY_GEN, version), + attributes); + newKey = P11Key.secretKey(session, + keyID, "TlsRsaPremasterSecret", 48 << 3, attributes); + } catch (PKCS11Exception e) { + throw new ProviderException( + "Could not generate premaster secret", e); } - return secretKey; + return (failover == null) ? unwrappedKey : newKey; } } diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java index 392ade324d3..af7767924a3 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java @@ -38,6 +38,8 @@ import javax.crypto.*; import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.IvParameterSpec; +import sun.security.jca.JCAUtil; + /** * Cipher wrapper class utilizing ucrypto APIs. This class currently supports * - AES/ECB/NOPADDING @@ -288,7 +290,10 @@ class NativeCipher extends CipherSpi { if (encrypt) { // generate IV if none supplied for encryption ivBytes = new byte[blockSize]; - new SecureRandom().nextBytes(ivBytes); + if (random == null) { + random = JCAUtil.getSecureRandom(); + } + random.nextBytes(ivBytes); } else { throw new InvalidAlgorithmParameterException ("Parameters required for decryption"); diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java index 2f9880cd792..10913cb3c06 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java @@ -36,6 +36,8 @@ import javax.crypto.*; import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.GCMParameterSpec; +import sun.security.jca.JCAUtil; + /** * Cipher wrapper class utilizing ucrypto APIs. This class currently supports * - AES/GCM/NoPADDING @@ -200,7 +202,10 @@ class NativeGCMCipher extends NativeCipher { // generate IV if none supplied for encryption ivBytes = new byte[blockSize]; - new SecureRandom().nextBytes(ivBytes); + if (random == null) { + random = JCAUtil.getSecureRandom(); + } + random.nextBytes(ivBytes); } else { throw new InvalidAlgorithmParameterException("Parameters required for decryption"); } diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java index 183c4d0a17a..4b4e408e42d 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java @@ -63,6 +63,7 @@ import javax.crypto.ShortBufferException; import javax.crypto.spec.SecretKeySpec; import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; +import sun.security.jca.JCAUtil; import sun.security.util.KeyUtil; /** @@ -201,6 +202,9 @@ public class NativeRSACipher extends CipherSpi { "No Parameters can be specified"); } spec = params; + if (random == null) { + random = JCAUtil.getSecureRandom(); + } this.random = random; // for TLS RSA premaster secret } boolean doEncrypt = (opmode == Cipher.ENCRYPT_MODE || opmode == Cipher.WRAP_MODE); From 683bd2b8b384f40885194557b5f743204b59de42 Mon Sep 17 00:00:00 2001 From: Shanliang Jiang Date: Tue, 6 Oct 2015 09:20:12 +0200 Subject: [PATCH 010/109] 8137060: JMX memory management improvements Reviewed-by: dfuchs, ahgross --- .../share/classes/sun/management/MemoryImpl.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/jdk/src/java.management/share/classes/sun/management/MemoryImpl.java b/jdk/src/java.management/share/classes/sun/management/MemoryImpl.java index 00d68d4a022..c707c4fba73 100644 --- a/jdk/src/java.management/share/classes/sun/management/MemoryImpl.java +++ b/jdk/src/java.management/share/classes/sun/management/MemoryImpl.java @@ -115,17 +115,10 @@ class MemoryImpl extends NotificationEmitterSupport "Memory usage exceeds collection usage threshold" }; - private MBeanNotificationInfo[] notifInfo = null; public MBeanNotificationInfo[] getNotificationInfo() { - synchronized (this) { - if (notifInfo == null) { - notifInfo = new MBeanNotificationInfo[1]; - notifInfo[0] = new MBeanNotificationInfo(notifTypes, - notifName, - "Memory Notification"); - } - } - return notifInfo; + return new MBeanNotificationInfo[] { + new MBeanNotificationInfo(notifTypes, notifName, "Memory Notification") + }; } private static String getNotifMsg(String notifType) { From c464a9de39631ca47524b78fe9274cc0892d21ef Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 3 Dec 2015 11:17:31 +0100 Subject: [PATCH 011/109] 8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package Reviewed-by: jrose, vlivanov, mchung, roland --- .../java/lang/invoke/BoundMethodHandle.java | 26 +++++++------- .../java/lang/invoke/DirectMethodHandle.java | 24 +++++++------ .../lang/invoke/InvokerBytecodeGenerator.java | 8 ++--- .../classes/java/lang/invoke/Invokers.java | 4 +++ .../classes/java/lang/invoke/LambdaForm.java | 20 +++++++---- .../java/lang/invoke/MethodHandleImpl.java | 4 +-- .../classes/java/lang/invoke/MethodType.java | 1 + .../java/lang/invoke/MethodTypeForm.java | 1 + .../internal/vm/annotation}/DontInline.java | 21 ++++++++--- .../internal/vm/annotation}/ForceInline.java | 22 +++++++++--- .../internal/vm/annotation}/Stable.java | 35 ++++++++++++++----- 11 files changed, 113 insertions(+), 53 deletions(-) rename jdk/src/java.base/share/classes/{java/lang/invoke => jdk/internal/vm/annotation}/DontInline.java (59%) rename jdk/src/java.base/share/classes/{java/lang/invoke => jdk/internal/vm/annotation}/ForceInline.java (58%) rename jdk/src/java.base/share/classes/{java/lang/invoke => jdk/internal/vm/annotation}/Stable.java (65%) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java index f385d95c4c9..90d0d590697 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -25,25 +25,25 @@ package java.lang.invoke; -import static jdk.internal.org.objectweb.asm.Opcodes.*; -import static java.lang.invoke.LambdaForm.*; -import static java.lang.invoke.LambdaForm.BasicType.*; -import static java.lang.invoke.MethodHandleStatics.*; +import jdk.internal.vm.annotation.Stable; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.FieldVisitor; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import sun.invoke.util.ValueConversions; +import sun.invoke.util.Wrapper; import java.lang.invoke.LambdaForm.NamedFunction; import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Field; import java.util.Arrays; -import java.util.function.Function; -import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.function.Function; -import jdk.internal.org.objectweb.asm.FieldVisitor; -import sun.invoke.util.ValueConversions; -import sun.invoke.util.Wrapper; - -import jdk.internal.org.objectweb.asm.ClassWriter; -import jdk.internal.org.objectweb.asm.MethodVisitor; +import static java.lang.invoke.LambdaForm.BasicType; +import static java.lang.invoke.LambdaForm.BasicType.*; +import static java.lang.invoke.MethodHandleStatics.*; +import static jdk.internal.org.objectweb.asm.Opcodes.*; /** * The flavor of method handle which emulates an invoke instruction @@ -459,7 +459,7 @@ import jdk.internal.org.objectweb.asm.MethodVisitor; static final String BMH_SIG = "L"+BMH+";"; static final String SPECIES_DATA = "java/lang/invoke/BoundMethodHandle$SpeciesData"; static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";"; - static final String STABLE_SIG = "Ljava/lang/invoke/Stable;"; + static final String STABLE_SIG = "Ljdk/internal/vm/annotation/Stable;"; static final String SPECIES_PREFIX_NAME = "Species_"; static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java index 54cbb4b3038..21e45d85663 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -26,20 +26,24 @@ package java.lang.invoke; import jdk.internal.misc.Unsafe; -import java.lang.reflect.Method; -import java.util.Arrays; -import sun.invoke.util.VerifyAccess; -import static java.lang.invoke.MethodHandleNatives.Constants.*; -import static java.lang.invoke.LambdaForm.*; -import static java.lang.invoke.MethodTypeForm.*; -import static java.lang.invoke.MethodHandleStatics.*; -import java.lang.ref.WeakReference; -import java.lang.reflect.Field; -import java.util.Objects; +import jdk.internal.vm.annotation.ForceInline; import sun.invoke.util.ValueConversions; +import sun.invoke.util.VerifyAccess; import sun.invoke.util.VerifyType; import sun.invoke.util.Wrapper; +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Objects; + +import static java.lang.invoke.LambdaForm.*; +import static java.lang.invoke.MethodHandleNatives.Constants.*; +import static java.lang.invoke.MethodHandleStatics.UNSAFE; +import static java.lang.invoke.MethodHandleStatics.newInternalError; +import static java.lang.invoke.MethodTypeForm.*; + /** * The flavor of method handle which implements a constant reference * to a class member. diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 83d66d52299..802589d727f 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -608,9 +608,9 @@ class InvokerBytecodeGenerator { if (lambdaForm.forceInline) { // Force inlining of this invoker method. - mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true); + mv.visitAnnotation("Ljdk/internal/vm/annotation/ForceInline;", true); } else { - mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true); + mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true); } if (lambdaForm.customized != null) { @@ -1292,7 +1292,7 @@ class InvokerBytecodeGenerator { mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true); // Don't inline the interpreter entry. - mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true); + mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true); // create parameter array emitIconstInsn(invokerType.parameterCount()); @@ -1351,7 +1351,7 @@ class InvokerBytecodeGenerator { mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true); // Force inlining of this invoker method. - mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true); + mv.visitAnnotation("Ljdk/internal/vm/annotation/ForceInline;", true); // Load receiver emitAloadInsn(0); diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java index add42889bac..32a96ebea7e 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java @@ -25,6 +25,10 @@ package java.lang.invoke; +import jdk.internal.vm.annotation.DontInline; +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.annotation.Stable; + import java.lang.reflect.Array; import java.util.Arrays; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java index 438b4256c09..45818bbf24a 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java @@ -25,18 +25,24 @@ package java.lang.invoke; -import java.lang.annotation.*; +import jdk.internal.vm.annotation.DontInline; +import jdk.internal.vm.annotation.Stable; +import sun.invoke.util.Wrapper; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.List; import java.util.Arrays; import java.util.HashMap; - -import sun.invoke.util.Wrapper; -import java.lang.reflect.Field; +import java.util.List; import static java.lang.invoke.LambdaForm.BasicType.*; -import static java.lang.invoke.MethodHandleStatics.*; -import static java.lang.invoke.MethodHandleNatives.Constants.*; +import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic; +import static java.lang.invoke.MethodHandleStatics.debugEnabled; +import static java.lang.invoke.MethodHandleStatics.newInternalError; /** * The symbolic, non-executable form of a method handle's invocation semantics. diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 7ad49cd38aa..c522b03486d 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -32,8 +32,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; +import jdk.internal.vm.annotation.Stable; import sun.invoke.empty.Empty; import sun.invoke.util.ValueConversions; import sun.invoke.util.VerifyType; @@ -1483,7 +1483,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; } private static final int LEFT_ARGS = FILL_ARRAYS_COUNT - 1; - private static final @Stable MethodHandle[] FILL_ARRAY_TO_RIGHT = new MethodHandle[MAX_ARITY+1]; + private static final @Stable MethodHandle[] FILL_ARRAY_TO_RIGHT = new MethodHandle[MAX_ARITY + 1]; /** fill_array_to_right(N).invoke(a, argL..arg[N-1]) * fills a[L]..a[N-1] with corresponding arguments, * and then returns a. The value L is a global constant (LEFT_ARGS). diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java index d75bad58a36..71690e5c439 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java @@ -25,6 +25,7 @@ package java.lang.invoke; +import jdk.internal.vm.annotation.Stable; import sun.invoke.util.Wrapper; import java.lang.ref.WeakReference; import java.lang.ref.Reference; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java index 0c4cf9bd4e1..e988252c8bc 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java @@ -25,6 +25,7 @@ package java.lang.invoke; +import jdk.internal.vm.annotation.Stable; import sun.invoke.util.Wrapper; import java.lang.ref.SoftReference; import static java.lang.invoke.MethodHandleStatics.*; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DontInline.java b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/DontInline.java similarity index 59% rename from jdk/src/java.base/share/classes/java/lang/invoke/DontInline.java rename to jdk/src/java.base/share/classes/jdk/internal/vm/annotation/DontInline.java index 1bd969efb8a..d39dccffbad 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/DontInline.java +++ b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/DontInline.java @@ -23,15 +23,28 @@ * questions. */ -package java.lang.invoke; +package jdk.internal.vm.annotation; import java.lang.annotation.*; /** - * Internal marker for some methods in the JSR 292 implementation. + * A method or constructor may be annotated as "don't inline" if the inlining of + * this method should not be performed by the HotSpot VM. + *

+ * This annotation must be used sparingly. It is useful when the only + * reasonable alternative is to bind the name of a specific method or + * constructor into the HotSpot VM for special handling by the inlining policy. + * This annotation must not be relied on as an alternative to avoid tuning the + * VM's inlining policy. In a few cases, it may act as a temporary workaround + * until the profiling and inlining performed by the HotSpot VM is sufficiently + * improved. + * + * @implNote + * This annotation only takes effect for methods or constructors of classes + * loaded by the boot loader. Annotations on methods or constructors of classes + * loaded outside of the boot loader are ignored. */ -/*non-public*/ @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) @Retention(RetentionPolicy.RUNTIME) -@interface DontInline { +public @interface DontInline { } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/ForceInline.java b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/ForceInline.java similarity index 58% rename from jdk/src/java.base/share/classes/java/lang/invoke/ForceInline.java rename to jdk/src/java.base/share/classes/jdk/internal/vm/annotation/ForceInline.java index bbac427efb7..e8253db04a1 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/ForceInline.java +++ b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/ForceInline.java @@ -23,15 +23,29 @@ * questions. */ -package java.lang.invoke; +package jdk.internal.vm.annotation; import java.lang.annotation.*; /** - * Internal marker for some methods in the JSR 292 implementation. + * A method or constructor may be annotated as "force inline" if the standard + * inlining metrics are to be ignored when the HotSpot VM inlines the method + * or constructor. + *

+ * This annotation must be used sparingly. It is useful when the only + * reasonable alternative is to bind the name of a specific method or + * constructor into the HotSpot VM for special handling by the inlining policy. + * This annotation must not be relied on as an alternative to avoid tuning the + * VM's inlining policy. In a few cases, it may act as a temporary workaround + * until the profiling and inlining performed by the HotSpot VM is sufficiently + * improved. + * + * @implNote + * This annotation only takes effect for methods or constructors of classes + * loaded by the boot loader. Annotations on methods or constructors of classes + * loaded outside of the boot loader are ignored. */ -/*non-public*/ @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) @Retention(RetentionPolicy.RUNTIME) -@interface ForceInline { +public @interface ForceInline { } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Stable.java b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java similarity index 65% rename from jdk/src/java.base/share/classes/java/lang/invoke/Stable.java rename to jdk/src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java index a0a413e2a79..2ba6e992adf 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/Stable.java +++ b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java @@ -23,7 +23,7 @@ * questions. */ -package java.lang.invoke; +package jdk.internal.vm.annotation; import java.lang.annotation.*; @@ -57,17 +57,34 @@ import java.lang.annotation.*; *

* Fields which are declared {@code final} may also be annotated as stable. * Since final fields already behave as stable values, such an annotation - * indicates no additional information, unless the type of the field is - * an array type. + * conveys no additional information regarding change of the field's value, but + * still conveys information regarding change of additional components values if + * the type of the field is an array type (as described above). + *

+ * The HotSpot VM relies on this annotation to promote a non-null (resp., + * non-zero) component value to a constant, thereby enabling superior + * optimizations of code depending on such a value (such as constant folding). + * More specifically, the HotSpot VM will process non-null stable fields (final + * or otherwise) in a similar manner to static final fields with respect to + * promoting the field's value to a constant. Thus, placing aside the + * differences for null/non-null values and arrays, a final stable field is + * treated as if it is really final from both the Java language and the HotSpot + * VM. *

* It is (currently) undefined what happens if a field annotated as stable - * is given a third value. In practice, if the JVM relies on this annotation - * to promote a field reference to a constant, it may be that the Java memory - * model would appear to be broken, if such a constant (the second value of the field) - * is used as the value of the field even after the field value has changed. + * is given a third value (by explicitly updating a stable field, a component of + * a stable array, or a final stable field via reflection or other means). + * Since the HotSpot VM promotes a non-null component value to constant, it may + * be that the Java memory model would appear to be broken, if such a constant + * (the second value of the field) is used as the value of the field even after + * the field value has changed (to a third value). + * + * @implNote + * This annotation only takes effect for fields of classes loaded by the boot + * loader. Annoations on fields of classes loaded outside of the boot loader + * are ignored. */ -/* package-private */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) -@interface Stable { +public @interface Stable { } From be2ad289543a3f1ce74ab6fa1734ae70064c04a1 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Wed, 9 Dec 2015 15:26:52 +0100 Subject: [PATCH 012/109] 8143628: Fork sun.misc.Unsafe and jdk.internal.misc.Unsafe native method tables Reviewed-by: shade, dholmes, alanb, chegar, mchung --- jdk/make/src/classes/build/tools/spp/Spp.java | 45 ++++++++++--------- .../share/classes/sun/misc/Unsafe.java | 12 ++--- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/jdk/make/src/classes/build/tools/spp/Spp.java b/jdk/make/src/classes/build/tools/spp/Spp.java index 0e3ca8da0b9..9bbebe6f34e 100644 --- a/jdk/make/src/classes/build/tools/spp/Spp.java +++ b/jdk/make/src/classes/build/tools/spp/Spp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -32,9 +32,10 @@ import java.util.regex.*; * Spp: A simple regex-based stream preprocessor based on Mark Reinhold's * sed-based spp.sh * - * Usage: java build.tools.spp.Spp [-be] [-Kkey] -Dvar=value ... out + * Usage: java build.tools.spp.Spp [-be] [-nel] [-Kkey] -Dvar=value ... out * - * Source-file constructs + * If -nel is declared then empty lines will not be substituted for lines of + * text in the template that do not appear in the output. * * Meaningful only at beginning of line, works with any number of keys: * @@ -64,9 +65,10 @@ import java.util.regex.*; public class Spp { public static void main(String args[]) throws Exception { - Map vars = new HashMap(); - Set keys = new HashSet(); + Map vars = new HashMap<>(); + Set keys = new HashSet<>(); boolean be = false; + boolean el = true; for (String arg:args) { if (arg.startsWith("-D")) { @@ -76,8 +78,10 @@ public class Spp { keys.add(arg.substring(2)); } else if ("-be".equals(arg)) { be = true; + } else if ("-nel".equals(arg)) { + el = false; } else { - System.err.println("Usage: java build.tools.spp.Spp [-be] [-Kkey] -Dvar=value ... out"); + System.err.println("Usage: java build.tools.spp.Spp [-be] [-nel] [-Kkey] -Dvar=value ... out"); System.exit(-1); } } @@ -85,7 +89,7 @@ public class Spp { StringBuffer out = new StringBuffer(); new Spp().spp(new Scanner(System.in), out, "", - keys, vars, be, + keys, vars, be, el, false); System.out.print(out.toString()); } @@ -93,7 +97,7 @@ public class Spp { static final String LNSEP = System.getProperty("line.separator"); static final String KEY = "([a-zA-Z0-9]+)"; static final String VAR = "([a-zA-Z0-9_\\-]+)"; - static final String TEXT = "([a-zA-Z0-9&;,.<>/#() \\$]+)"; // $ -- hack embedded $var$ + static final String TEXT = "([a-zA-Z0-9&;,.<>/#() \\?\\[\\]\\$]+)"; // $ -- hack embedded $var$ static final int GN_NOT = 1; static final int GN_KEY = 2; @@ -101,11 +105,11 @@ public class Spp { static final int GN_NO = 5; static final int GN_VAR = 6; - Matcher ifkey = Pattern.compile("^#if\\[(!)?" + KEY + "\\]").matcher(""); - Matcher elsekey = Pattern.compile("^#else\\[(!)?" + KEY + "\\]").matcher(""); - Matcher endkey = Pattern.compile("^#end\\[(!)?" + KEY + "\\]").matcher(""); - Matcher vardef = Pattern.compile("\\{#if\\[(!)?" + KEY + "\\]\\?" + TEXT + "(:"+ TEXT + ")?\\}|\\$" + VAR + "\\$").matcher(""); - Matcher vardef2 = Pattern.compile("\\$" + VAR + "\\$").matcher(""); + final Matcher ifkey = Pattern.compile("^#if\\[(!)?" + KEY + "\\]").matcher(""); + final Matcher elsekey = Pattern.compile("^#else\\[(!)?" + KEY + "\\]").matcher(""); + final Matcher endkey = Pattern.compile("^#end\\[(!)?" + KEY + "\\]").matcher(""); + final Matcher vardef = Pattern.compile("\\{#if\\[(!)?" + KEY + "\\]\\?" + TEXT + "(:"+ TEXT + ")?\\}|\\$" + VAR + "\\$").matcher(""); + final Matcher vardef2 = Pattern.compile("\\$" + VAR + "\\$").matcher(""); void append(StringBuffer buf, String ln, Set keys, Map vars) { @@ -135,7 +139,7 @@ public class Spp { // return true if #end[key], #end or EOF reached boolean spp(Scanner in, StringBuffer buf, String key, Set keys, Map vars, - boolean be, boolean skip) { + boolean be, boolean el, boolean skip) { while (in.hasNextLine()) { String ln = in.nextLine(); if (be) { @@ -154,9 +158,9 @@ public class Spp { boolean test = keys.contains(k); if (ifkey.group(GN_NOT) != null) test = !test; - buf.append(LNSEP); - if (!spp(in, buf, k, keys, vars, be, skip || !test)) { - spp(in, buf, k, keys, vars, be, skip || test); + if (el) buf.append(LNSEP); + if (!spp(in, buf, k, keys, vars, be, el, skip || !test)) { + spp(in, buf, k, keys, vars, be, el, skip || test); } continue; } @@ -164,14 +168,14 @@ public class Spp { if (!key.equals(elsekey.group(GN_KEY))) { throw new Error("Mis-matched #if-else-end at line <" + ln + ">"); } - buf.append(LNSEP); + if (el) buf.append(LNSEP); return false; } if (endkey.reset(ln).find()) { if (!key.equals(endkey.group(GN_KEY))) { throw new Error("Mis-matched #if-else-end at line <" + ln + ">"); } - buf.append(LNSEP); + if (el) buf.append(LNSEP); return true; } if (ln.startsWith("#warn")) { @@ -181,8 +185,9 @@ public class Spp { } if (!skip) { append(buf, ln, keys, vars); + if (!el) buf.append(LNSEP); } - buf.append(LNSEP); + if (el) buf.append(LNSEP); } return true; } diff --git a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java index 6a4775a4c3a..f100c8649e3 100644 --- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java @@ -25,13 +25,12 @@ package sun.misc; -import java.lang.reflect.Field; -import java.security.ProtectionDomain; - +import jdk.internal.HotSpotIntrinsicCandidate; import sun.reflect.CallerSensitive; import sun.reflect.Reflection; -import jdk.internal.HotSpotIntrinsicCandidate; +import java.lang.reflect.Field; +import java.security.ProtectionDomain; /** @@ -1035,9 +1034,4 @@ public final class Unsafe { private static void throwIllegalAccessError() { throw new IllegalAccessError(); } - - // JVM interface methods - private native boolean unalignedAccess0(); - private native boolean isBigEndian0(); - } From 5ba6e8e4394d04fce3c0b41efacce6f52c4c98a7 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Tue, 6 Oct 2015 18:42:06 +0200 Subject: [PATCH 013/109] 8133348: Reference.reachabilityFence Co-authored-by: Doug Lea Co-authored-by: Aleksey Shipilev Reviewed-by: plevart, mr, chegar, mchung --- .../classes/java/lang/ref/Reference.java | 117 ++++++++++++++ .../java/lang/ref/ReachabilityFenceTest.java | 143 ++++++++++++++++++ 2 files changed, 260 insertions(+) create mode 100644 jdk/test/java/lang/ref/ReachabilityFenceTest.java diff --git a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java index d18f059308f..eeb771903af 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java @@ -25,6 +25,7 @@ package java.lang.ref; +import jdk.internal.vm.annotation.DontInline; import sun.misc.Cleaner; import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.misc.JavaLangRefAccess; @@ -311,4 +312,120 @@ public abstract class Reference { this.queue = (queue == null) ? ReferenceQueue.NULL : queue; } + /** + * Ensures that the object referenced by the given reference remains + * strongly reachable, + * regardless of any prior actions of the program that might otherwise cause + * the object to become unreachable; thus, the referenced object is not + * reclaimable by garbage collection at least until after the invocation of + * this method. Invocation of this method does not itself initiate garbage + * collection or finalization. + * + *

This method establishes an ordering for + * strong reachability + * with respect to garbage collection. It controls relations that are + * otherwise only implicit in a program -- the reachability conditions + * triggering garbage collection. This method is designed for use in + * uncommon situations of premature finalization where using + * {@code synchronized} blocks or methods, or using other synchronization + * facilities are not possible or do not provide the desired control. This + * method is applicable only when reclamation may have visible effects, + * which is possible for objects with finalizers (See + * + * Section 12.6 17 of The Java™ Language Specification) + * that are implemented in ways that rely on ordering control for correctness. + * + * @apiNote + * Finalization may occur whenever the virtual machine detects that no + * reference to an object will ever be stored in the heap: The garbage + * collector may reclaim an object even if the fields of that object are + * still in use, so long as the object has otherwise become unreachable. + * This may have surprising and undesirable effects in cases such as the + * following example in which the bookkeeping associated with a class is + * managed through array indices. Here, method {@code action} uses a + * {@code reachabilityFence} to ensure that the {@code Resource} object is + * not reclaimed before bookkeeping on an associated + * {@code ExternalResource} has been performed; in particular here, to + * ensure that the array slot holding the {@code ExternalResource} is not + * nulled out in method {@link Object#finalize}, which may otherwise run + * concurrently. + * + *

 {@code
+     * class Resource {
+     *   private static ExternalResource[] externalResourceArray = ...
+     *
+     *   int myIndex;
+     *   Resource(...) {
+     *     myIndex = ...
+     *     externalResourceArray[myIndex] = ...;
+     *     ...
+     *   }
+     *   protected void finalize() {
+     *     externalResourceArray[myIndex] = null;
+     *     ...
+     *   }
+     *   public void action() {
+     *     try {
+     *       // ...
+     *       int i = myIndex;
+     *       Resource.update(externalResourceArray[i]);
+     *     } finally {
+     *       Reference.reachabilityFence(this);
+     *     }
+     *   }
+     *   private static void update(ExternalResource ext) {
+     *     ext.status = ...;
+     *   }
+     * }}
+ * + * Here, the invocation of {@code reachabilityFence} is nonintuitively + * placed after the call to {@code update}, to ensure that the + * array slot is not nulled out by {@link Object#finalize} before the + * update, even if the call to {@code action} was the last use of this + * object. This might be the case if, for example a usage in a user program + * had the form {@code new Resource().action();} which retains no other + * reference to this {@code Resource}. While probably overkill here, + * {@code reachabilityFence} is placed in a {@code finally} block to ensure + * that it is invoked across all paths in the method. In a method with more + * complex control paths, you might need further precautions to ensure that + * {@code reachabilityFence} is encountered along all of them. + * + *

It is sometimes possible to better encapsulate use of + * {@code reachabilityFence}. Continuing the above example, if it were + * acceptable for the call to method {@code update} to proceed even if the + * finalizer had already executed (nulling out slot), then you could + * localize use of {@code reachabilityFence}: + * + *

 {@code
+     * public void action2() {
+     *   // ...
+     *   Resource.update(getExternalResource());
+     * }
+     * private ExternalResource getExternalResource() {
+     *   ExternalResource ext = externalResourceArray[myIndex];
+     *   Reference.reachabilityFence(this);
+     *   return ext;
+     * }}
+ * + *

Method {@code reachabilityFence} is not required in constructions + * that themselves ensure reachability. For example, because objects that + * are locked cannot, in general, be reclaimed, it would suffice if all + * accesses of the object, in all methods of class {@code Resource} + * (including {@code finalize}) were enclosed in {@code synchronized (this)} + * blocks. (Further, such blocks must not include infinite loops, or + * themselves be unreachable, which fall into the corner case exceptions to + * the "in general" disclaimer.) However, method {@code reachabilityFence} + * remains a better option in cases where this approach is not as efficient, + * desirable, or possible; for example because it would encounter deadlock. + * + * @param ref the reference. If {@code null}, this method has no effect. + * @since 9 + */ + @DontInline + public static void reachabilityFence(Object ref) { + // Does nothing, because this method is annotated with @DontInline + // HotSpot needs to retain the ref and not GC it before a call to this + // method + } + } diff --git a/jdk/test/java/lang/ref/ReachabilityFenceTest.java b/jdk/test/java/lang/ref/ReachabilityFenceTest.java new file mode 100644 index 00000000000..461c6b200f1 --- /dev/null +++ b/jdk/test/java/lang/ref/ReachabilityFenceTest.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8133348 + * @summary Tests if reachabilityFence is working + * + * @run main/othervm -Xint -Dpremature=false ReachabilityFenceTest + * @run main/othervm -XX:TieredStopAtLevel=1 -Dpremature=true ReachabilityFenceTest + * @run main/othervm -XX:TieredStopAtLevel=2 -Dpremature=true ReachabilityFenceTest + * @run main/othervm -XX:TieredStopAtLevel=3 -Dpremature=true ReachabilityFenceTest + * @run main/othervm -XX:TieredStopAtLevel=4 -Dpremature=true ReachabilityFenceTest + */ + +import java.lang.ref.Reference; +import java.util.concurrent.atomic.AtomicBoolean; + +public class ReachabilityFenceTest { + + /* + * Implementation notes: + * + * This test has positive and negative parts. + * + * Negative test is "nonFenced", and it tests that absent of reachabilityFence, the object can + * be prematurely finalized -- this validates the test itself. Not every VM mode is expected to + * prematurely finalize the objects, and -Dpremature option communicates that to test. If a VM mode + * passes the negative test, then our understanding of what could happen is correct, and we can + * go forward. + * + * Positive test is "fenced", and it checks that given the reachabilityFence at the end of the block, + * the object cannot be finalized. There is no sense running a positive test when premature finalization + * is not expected. It is a job for negative test to verify that invariant. + * + * The test methods should be appropriately compiled, therefore we do several iterations. + */ + + // Enough to OSR and compile + static final int LOOP_ITERS = Integer.getInteger("LOOP_ITERS", 50000); + + // Enough after which to start triggering GC and finalization + static final int WARMUP_LOOP_ITERS = LOOP_ITERS - Integer.getInteger("GC_ITERS", 100); + + // Enough to switch from an OSR'ed method to compiled method + static final int MAIN_ITERS = 3; + + static final boolean PREMATURE_FINALIZATION = Boolean.getBoolean("premature"); + + public static void main(String... args) { + // Negative test + boolean finalized = false; + for (int c = 0; !finalized && c < MAIN_ITERS; c++) { + finalized |= nonFenced(); + } + + if (PREMATURE_FINALIZATION && !finalized) { + throw new IllegalStateException("The object had never been finalized before timeout reached."); + } + + if (!PREMATURE_FINALIZATION && finalized) { + throw new IllegalStateException("The object had been finalized without a fence, even though we don't expect it."); + } + + if (!PREMATURE_FINALIZATION) + return; + + // Positive test + finalized = false; + for (int c = 0; !finalized && c < MAIN_ITERS; c++) { + finalized |= fenced(); + } + + if (finalized) { + throw new IllegalStateException("The object had been prematurely finalized."); + } + } + + public static boolean nonFenced() { + AtomicBoolean finalized = new AtomicBoolean(); + MyFinalizeable o = new MyFinalizeable(finalized); + + for (int i = 0; i < LOOP_ITERS; i++) { + if (finalized.get()) break; + if (i > WARMUP_LOOP_ITERS) { + System.gc(); + System.runFinalization(); + } + } + + return finalized.get(); + } + + public static boolean fenced() { + AtomicBoolean finalized = new AtomicBoolean(); + MyFinalizeable o = new MyFinalizeable(finalized); + + for (int i = 0; i < LOOP_ITERS; i++) { + if (finalized.get()) break; + if (i > WARMUP_LOOP_ITERS) { + System.gc(); + System.runFinalization(); + } + } + + Reference.reachabilityFence(o); + + return finalized.get(); + } + + private static class MyFinalizeable { + private final AtomicBoolean finalized; + + public MyFinalizeable(AtomicBoolean b) { + this.finalized = b; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + finalized.set(true); + } + } +} \ No newline at end of file From 64190ac6295d2efc1daf5fa173d6ed9487c1ba60 Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Fri, 16 Oct 2015 14:12:35 +0300 Subject: [PATCH 014/109] 8139017: More stable image decoding Reviewed-by: prr, serb, mschoene --- .../share/native/libjavajpeg/jpegdecoder.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c b/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c index 65ef089a06a..06d0e2ba539 100644 --- a/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c +++ b/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c @@ -180,6 +180,7 @@ struct sun_jpeg_source_mgr { int *ip; unsigned char *bp; } outbuf; + size_t outbufSize; jobject hOutputBuffer; }; @@ -235,6 +236,7 @@ static int GET_ARRAYS(JNIEnv *env, sun_jpeg_source_ptr src) assert(src->outbuf.ip == 0); src->outbuf.ip = (int *)(*env)->GetPrimitiveArrayCritical (env, src->hOutputBuffer, 0); + src->outbufSize = (*env)->GetArrayLength(env, src->hOutputBuffer); if (src->outbuf.ip == 0) { RELEASE_ARRAYS(env, src); return 0; @@ -677,8 +679,8 @@ Java_sun_awt_image_JPEGImageDecoder_readImage(JNIEnv *env, cinfo.output_scanline - 1); } else { if (hasalpha) { - ip = jsrc.outbuf.ip + cinfo.image_width; - bp = jsrc.outbuf.bp + cinfo.image_width * 4; + ip = jsrc.outbuf.ip + jsrc.outbufSize; + bp = jsrc.outbuf.bp + jsrc.outbufSize * 4; while (ip > jsrc.outbuf.ip) { pixel = (*--bp) << 24; pixel |= (*--bp); @@ -687,8 +689,8 @@ Java_sun_awt_image_JPEGImageDecoder_readImage(JNIEnv *env, *--ip = pixel; } } else { - ip = jsrc.outbuf.ip + cinfo.image_width; - bp = jsrc.outbuf.bp + cinfo.image_width * 3; + ip = jsrc.outbuf.ip + jsrc.outbufSize; + bp = jsrc.outbuf.bp + jsrc.outbufSize * 3; while (ip > jsrc.outbuf.ip) { pixel = (*--bp); pixel |= (*--bp) << 8; From 11af905b181504da95f793d5172af0728d16ba4b Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Wed, 21 Oct 2015 14:55:18 +0300 Subject: [PATCH 015/109] 8139012: Better font substitutions Reviewed-by: prr, srl, mschoene --- .../layout/ContextualSubstSubtables.cpp | 38 ++++++++++--------- .../layout/CursiveAttachmentSubtables.cpp | 2 +- .../native/libfontmanager/layout/Features.cpp | 2 +- .../layout/MarkToBasePosnSubtables.cpp | 2 +- .../layout/MarkToLigaturePosnSubtables.cpp | 6 ++- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualSubstSubtables.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualSubstSubtables.cpp index 8b676683fa8..8beae2730aa 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualSubstSubtables.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualSubstSubtables.cpp @@ -243,14 +243,14 @@ le_uint32 ContextualSubstitutionFormat1Subtable::process(const LETableReference le_uint16 srSetCount = SWAPW(subRuleSetCount); if (coverageIndex < srSetCount) { - LEReferenceToArrayOf subRuleSetTableOffsetArrayRef(base, success, - &subRuleSetTableOffsetArray[coverageIndex], 1); + LEReferenceToArrayOf + subRuleSetTableOffsetArrayRef(base, success, subRuleSetTableOffsetArray, srSetCount); if (LE_FAILURE(success)) { return 0; } Offset subRuleSetTableOffset = SWAPW(subRuleSetTableOffsetArray[coverageIndex]); - LEReferenceTo - subRuleSetTable(base, success, (const SubRuleSetTable *) ((char *) this + subRuleSetTableOffset)); + LEReferenceTo subRuleSetTable(base, success, subRuleSetTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 subRuleCount = SWAPW(subRuleSetTable->subRuleCount); le_int32 position = glyphIterator->getCurrStreamPosition(); @@ -264,6 +264,7 @@ le_uint32 ContextualSubstitutionFormat1Subtable::process(const LETableReference SWAPW(subRuleSetTable->subRuleTableOffsetArray[subRule]); LEReferenceTo subRuleTable(subRuleSetTable, success, subRuleTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 matchCount = SWAPW(subRuleTable->glyphCount) - 1; le_uint16 substCount = SWAPW(subRuleTable->substCount); LEReferenceToArrayOf inputGlyphArray(base, success, subRuleTable->inputGlyphArray, matchCount+2); @@ -304,8 +305,8 @@ le_uint32 ContextualSubstitutionFormat2Subtable::process(const LETableReference } if (coverageIndex >= 0) { - LEReferenceTo classDefinitionTable(base, success, - (const ClassDefinitionTable *) ((char *) this + SWAPW(classDefTableOffset))); + LEReferenceTo classDefinitionTable(base, success, SWAPW(classDefTableOffset)); + if (LE_FAILURE(success)) { return 0; } le_uint16 scSetCount = SWAPW(subClassSetCount); le_int32 setClass = classDefinitionTable->getGlyphClass(classDefinitionTable, glyphIterator->getCurrGlyphID(), @@ -313,13 +314,13 @@ le_uint32 ContextualSubstitutionFormat2Subtable::process(const LETableReference if (setClass < scSetCount) { LEReferenceToArrayOf - subClassSetTableOffsetArrayRef(base, success, subClassSetTableOffsetArray, setClass); + subClassSetTableOffsetArrayRef(base, success, subClassSetTableOffsetArray, scSetCount); if (LE_FAILURE(success)) { return 0; } if (subClassSetTableOffsetArray[setClass] != 0) { Offset subClassSetTableOffset = SWAPW(subClassSetTableOffsetArray[setClass]); - LEReferenceTo - subClassSetTable(base, success, (const SubClassSetTable *) ((char *) this + subClassSetTableOffset)); + LEReferenceTo subClassSetTable(base, success, subClassSetTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 subClassRuleCount = SWAPW(subClassSetTable->subClassRuleCount); le_int32 position = glyphIterator->getCurrStreamPosition(); LEReferenceToArrayOf @@ -332,6 +333,7 @@ le_uint32 ContextualSubstitutionFormat2Subtable::process(const LETableReference SWAPW(subClassSetTable->subClassRuleTableOffsetArray[scRule]); LEReferenceTo subClassRuleTable(subClassSetTable, success, subClassRuleTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 matchCount = SWAPW(subClassRuleTable->glyphCount) - 1; le_uint16 substCount = SWAPW(subClassRuleTable->substCount); @@ -463,13 +465,13 @@ le_uint32 ChainingContextualSubstitutionFormat1Subtable::process(const LETableRe if (coverageIndex < srSetCount) { LEReferenceToArrayOf - chainSubRuleSetTableOffsetArrayRef(base, success, chainSubRuleSetTableOffsetArray, coverageIndex); + chainSubRuleSetTableOffsetArrayRef(base, success, chainSubRuleSetTableOffsetArray, srSetCount); if (LE_FAILURE(success)) { return 0; } Offset chainSubRuleSetTableOffset = SWAPW(chainSubRuleSetTableOffsetArray[coverageIndex]); - LEReferenceTo - chainSubRuleSetTable(base, success, (const ChainSubRuleSetTable *) ((char *) this + chainSubRuleSetTableOffset)); + LEReferenceTo chainSubRuleSetTable(base, success, chainSubRuleSetTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 chainSubRuleCount = SWAPW(chainSubRuleSetTable->chainSubRuleCount); le_int32 position = glyphIterator->getCurrStreamPosition(); GlyphIterator tempIterator(*glyphIterator, emptyFeatureList); @@ -550,17 +552,17 @@ le_uint32 ChainingContextualSubstitutionFormat2Subtable::process(const LETableRe if (coverageIndex >= 0) { LEReferenceTo - backtrackClassDefinitionTable(base, success, (const ClassDefinitionTable *) ((char *) this + SWAPW(backtrackClassDefTableOffset))); + backtrackClassDefinitionTable(base, success, SWAPW(backtrackClassDefTableOffset)); LEReferenceTo - inputClassDefinitionTable(base, success, (const ClassDefinitionTable *) ((char *) this + SWAPW(inputClassDefTableOffset))); + inputClassDefinitionTable(base, success, SWAPW(inputClassDefTableOffset)); LEReferenceTo - lookaheadClassDefinitionTable(base, success, (const ClassDefinitionTable *) ((char *) this + SWAPW(lookaheadClassDefTableOffset))); + lookaheadClassDefinitionTable(base, success, SWAPW(lookaheadClassDefTableOffset)); le_uint16 scSetCount = SWAPW(chainSubClassSetCount); le_int32 setClass = inputClassDefinitionTable->getGlyphClass(inputClassDefinitionTable, glyphIterator->getCurrGlyphID(), success); LEReferenceToArrayOf - chainSubClassSetTableOffsetArrayRef(base, success, chainSubClassSetTableOffsetArray, setClass); + chainSubClassSetTableOffsetArrayRef(base, success, chainSubClassSetTableOffsetArray, scSetCount); if (LE_FAILURE(success)) { return 0; } @@ -568,7 +570,8 @@ le_uint32 ChainingContextualSubstitutionFormat2Subtable::process(const LETableRe if (setClass < scSetCount && chainSubClassSetTableOffsetArray[setClass] != 0) { Offset chainSubClassSetTableOffset = SWAPW(chainSubClassSetTableOffsetArray[setClass]); LEReferenceTo - chainSubClassSetTable(base, success, (const ChainSubClassSetTable *) ((char *) this + chainSubClassSetTableOffset)); + chainSubClassSetTable(base, success, chainSubClassSetTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 chainSubClassRuleCount = SWAPW(chainSubClassSetTable->chainSubClassRuleCount); le_int32 position = glyphIterator->getCurrStreamPosition(); GlyphIterator tempIterator(*glyphIterator, emptyFeatureList); @@ -582,6 +585,7 @@ le_uint32 ChainingContextualSubstitutionFormat2Subtable::process(const LETableRe SWAPW(chainSubClassSetTable->chainSubClassRuleTableOffsetArray[scRule]); LEReferenceTo chainSubClassRuleTable(chainSubClassSetTable, success, chainSubClassRuleTableOffset); + if (LE_FAILURE(success)) { return 0; } le_uint16 backtrackGlyphCount = SWAPW(chainSubClassRuleTable->backtrackGlyphCount); LEReferenceToArrayOf backtrackClassArray(base, success, chainSubClassRuleTable->backtrackClassArray, backtrackGlyphCount); if( LE_FAILURE(success) ) { return 0; } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/CursiveAttachmentSubtables.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/CursiveAttachmentSubtables.cpp index f2c9f95ac70..0f230f12e7d 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/CursiveAttachmentSubtables.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/CursiveAttachmentSubtables.cpp @@ -46,7 +46,7 @@ le_uint32 CursiveAttachmentSubtable::process(const LEReferenceTo - entryExitRecordsArrayRef(base, success, entryExitRecords, coverageIndex); + entryExitRecordsArrayRef(base, success, entryExitRecords, eeCount); if (coverageIndex < 0 || coverageIndex >= eeCount || LE_FAILURE(success)) { glyphIterator->setCursiveGlyph(); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp index 02bb838d52f..0621888504d 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp @@ -41,7 +41,7 @@ U_NAMESPACE_BEGIN LEReferenceTo FeatureListTable::getFeatureTable(const LETableReference &base, le_uint16 featureIndex, LETag *featureTag, LEErrorCode &success) const { LEReferenceToArrayOf - featureRecordArrayRef(base, success, featureRecordArray, featureIndex+1); + featureRecordArrayRef(base, success, featureRecordArray, SWAPW(featureCount)); if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) { return LEReferenceTo(); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToBasePosnSubtables.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToBasePosnSubtables.cpp index ed1d11d4044..086da91629e 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToBasePosnSubtables.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToBasePosnSubtables.cpp @@ -93,7 +93,7 @@ le_int32 MarkToBasePositioningSubtable::process(const LETableReference &base, Gl } LEReferenceTo baseRecord(base, success, &baseArray->baseRecordArray[baseCoverage * mcCount]); if( LE_FAILURE(success) ) { return 0; } - LEReferenceToArrayOf baseAnchorTableOffsetArray(base, success, &(baseRecord->baseAnchorTableOffsetArray[0]), markClass+1); + LEReferenceToArrayOf baseAnchorTableOffsetArray(base, success, &(baseRecord->baseAnchorTableOffsetArray[0]), mcCount); if( LE_FAILURE(success) ) { return 0; } Offset anchorTableOffset = SWAPW(baseRecord->baseAnchorTableOffsetArray[markClass]); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToLigaturePosnSubtables.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToLigaturePosnSubtables.cpp index 55fadf3b5f0..2515b8afb5a 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToLigaturePosnSubtables.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/MarkToLigaturePosnSubtables.cpp @@ -83,6 +83,7 @@ le_int32 MarkToLigaturePositioningSubtable::process(const LETableReference &base LEGlyphID ligatureGlyph = findLigatureGlyph(&ligatureIterator); le_int32 ligatureCoverage = getBaseCoverage(base, (LEGlyphID) ligatureGlyph, success); LEReferenceTo ligatureArray(base, success, SWAPW(baseArrayOffset)); + if (LE_FAILURE(success)) { return 0; } le_uint16 ligatureCount = SWAPW(ligatureArray->ligatureCount); if (ligatureCoverage < 0 || ligatureCoverage >= ligatureCount) { @@ -95,6 +96,7 @@ le_int32 MarkToLigaturePositioningSubtable::process(const LETableReference &base le_int32 markPosition = glyphIterator->getCurrStreamPosition(); Offset ligatureAttachOffset = SWAPW(ligatureArray->ligatureAttachTableOffsetArray[ligatureCoverage]); LEReferenceTo ligatureAttachTable(ligatureArray, success, ligatureAttachOffset); + if (LE_FAILURE(success)) { return 0; } le_int32 componentCount = SWAPW(ligatureAttachTable->componentCount); le_int32 component = ligatureIterator.getMarkComponent(markPosition); @@ -104,10 +106,12 @@ le_int32 MarkToLigaturePositioningSubtable::process(const LETableReference &base } LEReferenceTo componentRecord(base, success, &ligatureAttachTable->componentRecordArray[component * mcCount]); - LEReferenceToArrayOf ligatureAnchorTableOffsetArray(base, success, &(componentRecord->ligatureAnchorTableOffsetArray[0]), markClass+1); + if (LE_FAILURE(success)) { return 0; } + LEReferenceToArrayOf ligatureAnchorTableOffsetArray(base, success, &(componentRecord->ligatureAnchorTableOffsetArray[0]), mcCount); if( LE_FAILURE(success) ) { return 0; } Offset anchorTableOffset = SWAPW(componentRecord->ligatureAnchorTableOffsetArray[markClass]); LEReferenceTo anchorTable(ligatureAttachTable, success, anchorTableOffset); + if (LE_FAILURE(success)) { return 0; } LEPoint ligatureAnchor, markAdvance, pixels; anchorTable->getAnchor(anchorTable, ligatureGlyph, fontInstance, ligatureAnchor, success); From f03a55be9ea9565ccf2a64c6b5aea1a1716db629 Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Mon, 26 Oct 2015 23:41:41 +0300 Subject: [PATCH 016/109] 8140543: Arrange font actions Reviewed-by: prr, srl, mschoene --- .../libfontmanager/layout/IndicRearrangementProcessor.cpp | 6 +++--- .../libfontmanager/layout/IndicRearrangementProcessor.h | 4 ++-- .../libfontmanager/layout/IndicRearrangementProcessor2.cpp | 6 +++--- .../libfontmanager/layout/IndicRearrangementProcessor2.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp index 15bca3800b2..5598349131a 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp @@ -76,11 +76,11 @@ ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphS } if (flags & irfMarkFirst) { - firstGlyph = (le_uint32)currGlyph; + firstGlyph = currGlyph; } if (flags & irfMarkLast) { - lastGlyph = (le_uint32)currGlyph; + lastGlyph = currGlyph; } doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success); @@ -118,7 +118,7 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto if (firstGlyph == lastGlyph) break; if (firstGlyph + 1 < firstGlyph) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; - break; + break; } a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h index 36af0ff1254..42d7a249aa1 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h @@ -76,8 +76,8 @@ public: static UClassID getStaticClassID(); protected: - le_uint32 firstGlyph; - le_uint32 lastGlyph; + le_int32 firstGlyph; + le_int32 lastGlyph; LEReferenceTo indicRearrangementSubtableHeader; LEReferenceToArrayOf entryTable; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.cpp index 2a94c101f2a..8692312ecd4 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.cpp @@ -74,11 +74,11 @@ le_uint16 IndicRearrangementProcessor2::processStateEntry(LEGlyphStorage &glyphS } if (flags & irfMarkFirst) { - firstGlyph = (le_uint32)currGlyph; + firstGlyph = currGlyph; } if (flags & irfMarkLast) { - lastGlyph = (le_uint32)currGlyph; + lastGlyph = currGlyph; } doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask), success); @@ -115,7 +115,7 @@ void IndicRearrangementProcessor2::doRearrangementAction(LEGlyphStorage &glyphSt if (firstGlyph == lastGlyph) break; if (firstGlyph + 1 < firstGlyph) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; - break; + break; } a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.h b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.h index b68abe1695c..691274c6da0 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor2.h @@ -76,8 +76,8 @@ public: static UClassID getStaticClassID(); protected: - le_uint32 firstGlyph; - le_uint32 lastGlyph; + le_int32 firstGlyph; + le_int32 lastGlyph; LEReferenceToArrayOf entryTable; LEReferenceTo indicRearrangementSubtableHeader; From 69c0fd73d38b4a38ff0c1ffa0abf7315a1de9b6d Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Tue, 3 Nov 2015 14:44:10 +0300 Subject: [PATCH 017/109] 8141213: [Parfait]Potentially blocking function GetArrayLength called in JNI critical region at line 239 of jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c in function GET_ARRAYS Reviewed-by: prr, serb --- jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c b/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c index 06d0e2ba539..1cd05ab09c2 100644 --- a/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c +++ b/jdk/src/java.desktop/share/native/libjavajpeg/jpegdecoder.c @@ -234,9 +234,9 @@ static int GET_ARRAYS(JNIEnv *env, sun_jpeg_source_ptr src) } if (src->hOutputBuffer) { assert(src->outbuf.ip == 0); + src->outbufSize = (*env)->GetArrayLength(env, src->hOutputBuffer); src->outbuf.ip = (int *)(*env)->GetPrimitiveArrayCritical (env, src->hOutputBuffer, 0); - src->outbufSize = (*env)->GetArrayLength(env, src->hOutputBuffer); if (src->outbuf.ip == 0) { RELEASE_ARRAYS(env, src); return 0; From c6b9bd52d8ed92ad5c3028f8992a827cf79d2109 Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Wed, 18 Nov 2015 11:35:23 +0300 Subject: [PATCH 018/109] 8141229: [Parfait] Null pointer dereference in cmsstrcasecmp of cmserr.c Reviewed-by: prr, serb --- jdk/src/java.desktop/share/native/liblcms/cmscgats.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/src/java.desktop/share/native/liblcms/cmscgats.c b/jdk/src/java.desktop/share/native/liblcms/cmscgats.c index 0dedc277718..664a3c9eca7 100644 --- a/jdk/src/java.desktop/share/native/liblcms/cmscgats.c +++ b/jdk/src/java.desktop/share/native/liblcms/cmscgats.c @@ -2545,9 +2545,11 @@ int LocateSample(cmsIT8* it8, const char* cSample) for (i=0; i < t->nSamples; i++) { fld = GetDataFormat(it8, i); + if (fld != NULL) { if (cmsstrcasecmp(fld, cSample) == 0) return i; } + } return -1; From 1d4561775d54cded26d08d8ed0444653789a2e23 Mon Sep 17 00:00:00 2001 From: Michael Haupt Date: Wed, 9 Dec 2015 11:02:54 +0000 Subject: [PATCH 019/109] 8081512: Remove sun.invoke.anon classes, or move / co-locate them with tests Reviewed-by: mchung, sundar --- .../sun/invoke/anon/AnonymousClassLoader.java | 234 -------- .../sun/invoke/anon/ConstantPoolParser.java | 368 ------------- .../sun/invoke/anon/ConstantPoolPatch.java | 503 ------------------ .../sun/invoke/anon/ConstantPoolVisitor.java | 192 ------- .../InvalidConstantPoolFormatException.java | 45 -- .../ConstantPoolPatch/OptimalMapSize.java | 41 -- 6 files changed, 1383 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java delete mode 100644 jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolParser.java delete mode 100644 jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolPatch.java delete mode 100644 jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolVisitor.java delete mode 100644 jdk/src/java.base/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java delete mode 100644 jdk/test/sun/invoke/anon/ConstantPoolPatch/OptimalMapSize.java diff --git a/jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java b/jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java deleted file mode 100644 index 6c5cb3f5563..00000000000 --- a/jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.invoke.anon; - -import java.io.EOFException; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * Anonymous class loader. Will load any valid classfile, producing - * a {@link Class} metaobject, without installing that class in the - * system dictionary. Therefore, {@link Class#forName(String)} will never - * produce a reference to an anonymous class. - *

- * The access permissions of the anonymous class are borrowed from - * a host class. The new class behaves as if it were an - * inner class of the host class. It can access the host's private - * members, if the creator of the class loader has permission to - * do so (or to create accessible reflective objects). - *

- * When the anonymous class is loaded, elements of its constant pool - * can be patched to new values. This provides a hook to pre-resolve - * named classes in the constant pool to other classes, including - * anonymous ones. Also, string constants can be pre-resolved to - * any reference. (The verifier treats non-string, non-class reference - * constants as plain objects.) - *

- * Why include the patching function? It makes some use cases much easier. - * Second, the constant pool needed some internal patching anyway, - * to anonymize the loaded class itself. Finally, if you are going - * to use this seriously, you'll want to build anonymous classes - * on top of pre-existing anonymous classes, and that requires patching. - * - *

%%% TO-DO: - *

- * - * @author jrose - * @author Remi Forax - * @see - * http://blogs.sun.com/jrose/entry/anonymous_classes_in_the_vm - */ - -public class AnonymousClassLoader { - final Class hostClass; - - // Privileged constructor. - private AnonymousClassLoader(Class hostClass) { - this.hostClass = hostClass; - } - - public static AnonymousClassLoader make(jdk.internal.misc.Unsafe unsafe, Class hostClass) { - if (unsafe == null) throw new NullPointerException(); - return new AnonymousClassLoader(hostClass); - } - - public Class loadClass(byte[] classFile) { - if (defineAnonymousClass == null) { - // no JVM support; try to fake an approximation - try { - return fakeLoadClass(new ConstantPoolParser(classFile).createPatch()); - } catch (InvalidConstantPoolFormatException ee) { - throw new IllegalArgumentException(ee); - } - } - return loadClass(classFile, null); - } - - public Class loadClass(ConstantPoolPatch classPatch) { - if (defineAnonymousClass == null) { - // no JVM support; try to fake an approximation - return fakeLoadClass(classPatch); - } - Object[] patches = classPatch.patchArray; - // Convert class names (this late in the game) - // to use slash '/' instead of dot '.'. - // Java likes dots, but the JVM likes slashes. - for (int i = 0; i < patches.length; i++) { - Object value = patches[i]; - if (value != null) { - byte tag = classPatch.getTag(i); - switch (tag) { - case ConstantPoolVisitor.CONSTANT_Class: - if (value instanceof String) { - if (patches == classPatch.patchArray) - patches = patches.clone(); - patches[i] = ((String)value).replace('.', '/'); - } - break; - case ConstantPoolVisitor.CONSTANT_Fieldref: - case ConstantPoolVisitor.CONSTANT_Methodref: - case ConstantPoolVisitor.CONSTANT_InterfaceMethodref: - case ConstantPoolVisitor.CONSTANT_NameAndType: - // When/if the JVM supports these patches, - // we'll probably need to reformat them also. - // Meanwhile, let the class loader create the error. - break; - } - } - } - return loadClass(classPatch.outer.classFile, classPatch.patchArray); - } - - private Class loadClass(byte[] classFile, Object[] patchArray) { - try { - return (Class) - defineAnonymousClass.invoke(unsafe, - hostClass, classFile, patchArray); - } catch (Exception ex) { - throwReflectedException(ex); - throw new RuntimeException("error loading into "+hostClass, ex); - } - } - - private static void throwReflectedException(Exception ex) { - if (ex instanceof InvocationTargetException) { - Throwable tex = ((InvocationTargetException)ex).getTargetException(); - if (tex instanceof Error) - throw (Error) tex; - ex = (Exception) tex; - } - if (ex instanceof RuntimeException) { - throw (RuntimeException) ex; - } - } - - private Class fakeLoadClass(ConstantPoolPatch classPatch) { - // Implementation: - // 1. Make up a new name nobody has used yet. - // 2. Inspect the tail-header of the class to find the this_class index. - // 3. Patch the CONSTANT_Class for this_class to the new name. - // 4. Add other CP entries required by (e.g.) string patches. - // 5. Flatten Class constants down to their names, making sure that - // the host class loader can pick them up again accurately. - // 6. Generate the edited class file bytes. - // - // Potential limitations: - // * The class won't be truly anonymous, and may interfere with others. - // * Flattened class constants might not work, because of loader issues. - // * Pseudo-string constants will not flatten down to real strings. - // * Method handles will (of course) fail to flatten to linkage strings. - if (true) throw new UnsupportedOperationException("NYI"); - Object[] cpArray; - try { - cpArray = classPatch.getOriginalCP(); - } catch (InvalidConstantPoolFormatException ex) { - throw new RuntimeException(ex); - } - int thisClassIndex = classPatch.getParser().getThisClassIndex(); - String thisClassName = (String) cpArray[thisClassIndex]; - synchronized (AnonymousClassLoader.class) { - thisClassName = thisClassName+"\\|"+(++fakeNameCounter); - } - classPatch.putUTF8(thisClassIndex, thisClassName); - byte[] classFile = null; - return unsafe.defineClass(null, classFile, 0, classFile.length, - hostClass.getClassLoader(), - hostClass.getProtectionDomain()); - } - private static int fakeNameCounter = 99999; - - // ignore two warnings on this line: - private static jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); - // preceding line requires that this class be on the boot class path - - private static final Method defineAnonymousClass; - static { - Method dac = null; - Class unsafeClass = unsafe.getClass(); - try { - dac = unsafeClass.getMethod("defineAnonymousClass", - Class.class, - byte[].class, - Object[].class); - } catch (Exception ee) { - dac = null; - } - defineAnonymousClass = dac; - } - - private static void noJVMSupport() { - throw new UnsupportedOperationException("no JVM support for anonymous classes"); - } - - - private static native Class loadClassInternal(Class hostClass, - byte[] classFile, - Object[] patchArray); - - public static byte[] readClassFile(Class templateClass) throws IOException { - String templateName = templateClass.getName(); - int lastDot = templateName.lastIndexOf('.'); - java.net.URL url = templateClass.getResource(templateName.substring(lastDot+1)+".class"); - java.net.URLConnection connection = url.openConnection(); - int contentLength = connection.getContentLength(); - if (contentLength < 0) - throw new IOException("invalid content length "+contentLength); - - byte[] b = connection.getInputStream().readAllBytes(); - if (b.length != contentLength) - throw new EOFException("Expected:" + contentLength + ", read:" + b.length); - - return b; - } -} diff --git a/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolParser.java b/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolParser.java deleted file mode 100644 index 441ba957336..00000000000 --- a/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolParser.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.invoke.anon; - -import java.io.IOException; -import java.io.OutputStream; -import java.nio.BufferUnderflowException; -import java.nio.ByteBuffer; - -import static sun.invoke.anon.ConstantPoolVisitor.*; - -/** A constant pool parser. - */ -public class ConstantPoolParser { - final byte[] classFile; - final byte[] tags; - final char[] firstHeader; // maghi, maglo, minor, major, cplen - - // these are filled in on first parse: - int endOffset; - char[] secondHeader; // flags, this_class, super_class, intlen - - // used to decode UTF8 array - private char[] charArray = new char[80]; - - /** Creates a constant pool parser. - * @param classFile an array of bytes containing a class. - * @throws InvalidConstantPoolFormatException if the header of the class has errors. - */ - public ConstantPoolParser(byte[] classFile) throws InvalidConstantPoolFormatException { - this.classFile = classFile; - this.firstHeader = parseHeader(classFile); - this.tags = new byte[firstHeader[4]]; - } - - /** Create a constant pool parser by loading the bytecodes of the - * class taken as argument. - * - * @param templateClass the class to parse. - * - * @throws IOException raised if an I/O occurs when loading - * the bytecode of the template class. - * @throws InvalidConstantPoolFormatException if the header of the class has errors. - * - * @see #ConstantPoolParser(byte[]) - * @see AnonymousClassLoader#readClassFile(Class) - */ - public ConstantPoolParser(Class templateClass) throws IOException, InvalidConstantPoolFormatException { - this(AnonymousClassLoader.readClassFile(templateClass)); - } - - /** Creates an empty patch to patch the class file - * used by the current parser. - * @return a new class patch. - */ - public ConstantPoolPatch createPatch() { - return new ConstantPoolPatch(this); - } - - /** Report the tag of the indicated CP entry. - * @param index - * @return one of {@link ConstantPoolVisitor#CONSTANT_Utf8}, etc. - */ - public byte getTag(int index) { - getEndOffset(); // trigger an exception if we haven't parsed yet - return tags[index]; - } - - /** Report the length of the constant pool. */ - public int getLength() { - return firstHeader[4]; - } - - /** Report the offset, within the class file, of the start of the constant pool. */ - public int getStartOffset() { - return firstHeader.length * 2; - } - - /** Report the offset, within the class file, of the end of the constant pool. */ - public int getEndOffset() { - if (endOffset == 0) - throw new IllegalStateException("class file has not yet been parsed"); - return endOffset; - } - - /** Report the CP index of this class's own name. */ - public int getThisClassIndex() { - getEndOffset(); // provoke exception if not yet parsed - return secondHeader[1]; - } - - /** Report the total size of the class file. */ - public int getTailLength() { - return classFile.length - getEndOffset(); - } - - /** Write the head (header plus constant pool) - * of the class file to the indicated stream. - */ - public void writeHead(OutputStream out) throws IOException { - out.write(classFile, 0, getEndOffset()); - } - - /** Write the head (header plus constant pool) - * of the class file to the indicated stream, - * incorporating the non-null entries of the given array - * as patches. - */ - void writePatchedHead(OutputStream out, Object[] patchArray) { - // this will be useful to partially emulate the class loader on old JVMs - throw new UnsupportedOperationException("Not yet implemented"); - } - - /** Write the tail (everything after the constant pool) - * of the class file to the indicated stream. - */ - public void writeTail(OutputStream out) throws IOException { - out.write(classFile, getEndOffset(), getTailLength()); - } - - private static char[] parseHeader(byte[] classFile) throws InvalidConstantPoolFormatException { - char[] result = new char[5]; - ByteBuffer buffer = ByteBuffer.wrap(classFile); - for (int i = 0; i < result.length; i++) - result[i] = (char) getUnsignedShort(buffer); - int magic = result[0] << 16 | result[1] << 0; - if (magic != 0xCAFEBABE) - throw new InvalidConstantPoolFormatException("invalid magic number "+magic); - // skip major, minor version - int len = result[4]; - if (len < 1) - throw new InvalidConstantPoolFormatException("constant pool length < 1"); - return result; - } - - /** Parse the constant pool of the class - * calling a method visit* each time a constant pool entry is parsed. - * - * The order of the calls to visit* is not guaranteed to be the same - * than the order of the constant pool entry in the bytecode array. - * - * @param visitor - * @throws InvalidConstantPoolFormatException - */ - public void parse(ConstantPoolVisitor visitor) throws InvalidConstantPoolFormatException { - ByteBuffer buffer = ByteBuffer.wrap(classFile); - buffer.position(getStartOffset()); //skip header - - Object[] values = new Object[getLength()]; - try { - parseConstantPool(buffer, values, visitor); - } catch(BufferUnderflowException e) { - throw new InvalidConstantPoolFormatException(e); - } - if (endOffset == 0) { - endOffset = buffer.position(); - secondHeader = new char[4]; - for (int i = 0; i < secondHeader.length; i++) { - secondHeader[i] = (char) getUnsignedShort(buffer); - } - } - resolveConstantPool(values, visitor); - } - - private char[] getCharArray(int utfLength) { - if (utfLength <= charArray.length) - return charArray; - return charArray = new char[utfLength]; - } - - private void parseConstantPool(ByteBuffer buffer, Object[] values, ConstantPoolVisitor visitor) throws InvalidConstantPoolFormatException { - for (int i = 1; i < tags.length; ) { - byte tag = (byte) getUnsignedByte(buffer); - assert(tags[i] == 0 || tags[i] == tag); - tags[i] = tag; - switch (tag) { - case CONSTANT_Utf8: - int utfLen = getUnsignedShort(buffer); - String value = getUTF8(buffer, utfLen, getCharArray(utfLen)); - visitor.visitUTF8(i, CONSTANT_Utf8, value); - tags[i] = tag; - values[i++] = value; - break; - case CONSTANT_Integer: - visitor.visitConstantValue(i, tag, buffer.getInt()); - i++; - break; - case CONSTANT_Float: - visitor.visitConstantValue(i, tag, buffer.getFloat()); - i++; - break; - case CONSTANT_Long: - visitor.visitConstantValue(i, tag, buffer.getLong()); - i+=2; - break; - case CONSTANT_Double: - visitor.visitConstantValue(i, tag, buffer.getDouble()); - i+=2; - break; - - case CONSTANT_Class: // fall through: - case CONSTANT_String: - tags[i] = tag; - values[i++] = new int[] { getUnsignedShort(buffer) }; - break; - - case CONSTANT_Fieldref: // fall through: - case CONSTANT_Methodref: // fall through: - case CONSTANT_InterfaceMethodref: // fall through: - case CONSTANT_NameAndType: - tags[i] = tag; - values[i++] = new int[] { getUnsignedShort(buffer), getUnsignedShort(buffer) }; - break; - default: - throw new AssertionError("invalid constant "+tag); - } - } - } - - private void resolveConstantPool(Object[] values, ConstantPoolVisitor visitor) { - // clean out the int[] values, which are temporary - for (int beg = 1, end = values.length-1, beg2, end2; - beg <= end; - beg = beg2, end = end2) { - beg2 = end; end2 = beg-1; - //System.out.println("CP resolve pass: "+beg+".."+end); - for (int i = beg; i <= end; i++) { - Object value = values[i]; - if (!(value instanceof int[])) - continue; - int[] array = (int[]) value; - byte tag = tags[i]; - switch (tag) { - case CONSTANT_String: - String stringBody = (String) values[array[0]]; - visitor.visitConstantString(i, tag, stringBody, array[0]); - values[i] = null; - break; - case CONSTANT_Class: { - String className = (String) values[array[0]]; - // use the external form favored by Class.forName: - className = className.replace('/', '.'); - visitor.visitConstantString(i, tag, className, array[0]); - values[i] = className; - break; - } - case CONSTANT_NameAndType: { - String memberName = (String) values[array[0]]; - String signature = (String) values[array[1]]; - visitor.visitDescriptor(i, tag, memberName, signature, - array[0], array[1]); - values[i] = new String[] {memberName, signature}; - break; - } - case CONSTANT_Fieldref: // fall through: - case CONSTANT_Methodref: // fall through: - case CONSTANT_InterfaceMethodref: { - Object className = values[array[0]]; - Object nameAndType = values[array[1]]; - if (!(className instanceof String) || - !(nameAndType instanceof String[])) { - // one more pass is needed - if (beg2 > i) beg2 = i; - if (end2 < i) end2 = i; - continue; - } - String[] nameAndTypeArray = (String[]) nameAndType; - visitor.visitMemberRef(i, tag, - (String)className, - nameAndTypeArray[0], - nameAndTypeArray[1], - array[0], array[1]); - values[i] = null; - } - break; - default: - continue; - } - } - } - } - - private static int getUnsignedByte(ByteBuffer buffer) { - return buffer.get() & 0xFF; - } - - private static int getUnsignedShort(ByteBuffer buffer) { - int b1 = getUnsignedByte(buffer); - int b2 = getUnsignedByte(buffer); - return (b1 << 8) + (b2 << 0); - } - - private static String getUTF8(ByteBuffer buffer, int utfLen, char[] charArray) throws InvalidConstantPoolFormatException { - int utfLimit = buffer.position() + utfLen; - int index = 0; - while (buffer.position() < utfLimit) { - int c = buffer.get() & 0xff; - if (c > 127) { - buffer.position(buffer.position() - 1); - return getUTF8Extended(buffer, utfLimit, charArray, index); - } - charArray[index++] = (char)c; - } - return new String(charArray, 0, index); - } - - private static String getUTF8Extended(ByteBuffer buffer, int utfLimit, char[] charArray, int index) throws InvalidConstantPoolFormatException { - int c, c2, c3; - while (buffer.position() < utfLimit) { - c = buffer.get() & 0xff; - switch (c >> 4) { - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: - /* 0xxxxxxx*/ - charArray[index++] = (char)c; - break; - case 12: case 13: - /* 110x xxxx 10xx xxxx*/ - c2 = buffer.get(); - if ((c2 & 0xC0) != 0x80) - throw new InvalidConstantPoolFormatException( - "malformed input around byte " + buffer.position()); - charArray[index++] = (char)(((c & 0x1F) << 6) | - (c2 & 0x3F)); - break; - case 14: - /* 1110 xxxx 10xx xxxx 10xx xxxx */ - c2 = buffer.get(); - c3 = buffer.get(); - if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80)) - throw new InvalidConstantPoolFormatException( - "malformed input around byte " + (buffer.position())); - charArray[index++] = (char)(((c & 0x0F) << 12) | - ((c2 & 0x3F) << 6) | - ((c3 & 0x3F) << 0)); - break; - default: - /* 10xx xxxx, 1111 xxxx */ - throw new InvalidConstantPoolFormatException( - "malformed input around byte " + buffer.position()); - } - } - // The number of chars produced may be less than utflen - return new String(charArray, 0, index); - } -} diff --git a/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolPatch.java b/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolPatch.java deleted file mode 100644 index 416a918ba8d..00000000000 --- a/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolPatch.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.invoke.anon; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.Map; - -import static sun.invoke.anon.ConstantPoolVisitor.*; - -/** A class and its patched constant pool. - * - * This class allow to modify (patch) a constant pool - * by changing the value of its entry. - * Entry are referenced using index that can be get - * by parsing the constant pool using - * {@link ConstantPoolParser#parse(ConstantPoolVisitor)}. - * - * @see ConstantPoolVisitor - * @see ConstantPoolParser#createPatch() - */ -public class ConstantPoolPatch { - final ConstantPoolParser outer; - final Object[] patchArray; - - ConstantPoolPatch(ConstantPoolParser outer) { - this.outer = outer; - this.patchArray = new Object[outer.getLength()]; - } - - /** Create a {@link ConstantPoolParser} and - * a {@link ConstantPoolPatch} in one step. - * Equivalent to {@code new ConstantPoolParser(classFile).createPatch()}. - * - * @param classFile an array of bytes containing a class. - * @see #ConstantPoolParser(Class) - */ - public ConstantPoolPatch(byte[] classFile) throws InvalidConstantPoolFormatException { - this(new ConstantPoolParser(classFile)); - } - - /** Create a {@link ConstantPoolParser} and - * a {@link ConstantPoolPatch} in one step. - * Equivalent to {@code new ConstantPoolParser(templateClass).createPatch()}. - * - * @param templateClass the class to parse. - * @see #ConstantPoolParser(Class) - */ - public ConstantPoolPatch(Class templateClass) throws IOException, InvalidConstantPoolFormatException { - this(new ConstantPoolParser(templateClass)); - } - - - /** Creates a patch from an existing patch. - * All changes are copied from that patch. - * @param patch a patch - * - * @see ConstantPoolParser#createPatch() - */ - public ConstantPoolPatch(ConstantPoolPatch patch) { - outer = patch.outer; - patchArray = patch.patchArray.clone(); - } - - /** Which parser built this patch? */ - public ConstantPoolParser getParser() { - return outer; - } - - /** Report the tag at the given index in the constant pool. */ - public byte getTag(int index) { - return outer.getTag(index); - } - - /** Report the current patch at the given index of the constant pool. - * Null means no patch will be made. - * To observe the unpatched entry at the given index, use - * {@link #getParser()}{@code .}@link ConstantPoolParser#parse(ConstantPoolVisitor)} - */ - public Object getPatch(int index) { - Object value = patchArray[index]; - if (value == null) return null; - switch (getTag(index)) { - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - if (value instanceof String) - value = stripSemis(2, (String) value); - break; - case CONSTANT_NameAndType: - if (value instanceof String) - value = stripSemis(1, (String) value); - break; - } - return value; - } - - /** Clear all patches. */ - public void clear() { - Arrays.fill(patchArray, null); - } - - /** Clear one patch. */ - public void clear(int index) { - patchArray[index] = null; - } - - /** Produce the patches as an array. */ - public Object[] getPatches() { - return patchArray.clone(); - } - - /** Produce the original constant pool as an array. */ - public Object[] getOriginalCP() throws InvalidConstantPoolFormatException { - return getOriginalCP(0, patchArray.length, -1); - } - - /** Walk the constant pool, applying patches using the given map. - * - * @param utf8Map Utf8 strings to modify, if encountered - * @param classMap Classes (or their names) to modify, if encountered - * @param valueMap Constant values to modify, if encountered - * @param deleteUsedEntries if true, delete map entries that are used - */ - public void putPatches(final Map utf8Map, - final Map classMap, - final Map valueMap, - boolean deleteUsedEntries) throws InvalidConstantPoolFormatException { - final HashSet usedUtf8Keys; - final HashSet usedClassKeys; - final HashSet usedValueKeys; - if (deleteUsedEntries) { - usedUtf8Keys = (utf8Map == null) ? null : new HashSet(); - usedClassKeys = (classMap == null) ? null : new HashSet(); - usedValueKeys = (valueMap == null) ? null : new HashSet(); - } else { - usedUtf8Keys = null; - usedClassKeys = null; - usedValueKeys = null; - } - - outer.parse(new ConstantPoolVisitor() { - - @Override - public void visitUTF8(int index, byte tag, String utf8) { - putUTF8(index, utf8Map.get(utf8)); - if (usedUtf8Keys != null) usedUtf8Keys.add(utf8); - } - - @Override - public void visitConstantValue(int index, byte tag, Object value) { - putConstantValue(index, tag, valueMap.get(value)); - if (usedValueKeys != null) usedValueKeys.add(value); - } - - @Override - public void visitConstantString(int index, byte tag, String name, int nameIndex) { - if (tag == CONSTANT_Class) { - putConstantValue(index, tag, classMap.get(name)); - if (usedClassKeys != null) usedClassKeys.add(name); - } else { - assert(tag == CONSTANT_String); - visitConstantValue(index, tag, name); - } - } - }); - if (usedUtf8Keys != null) utf8Map.keySet().removeAll(usedUtf8Keys); - if (usedClassKeys != null) classMap.keySet().removeAll(usedClassKeys); - if (usedValueKeys != null) valueMap.keySet().removeAll(usedValueKeys); - } - - Object[] getOriginalCP(final int startIndex, - final int endIndex, - final int tagMask) throws InvalidConstantPoolFormatException { - final Object[] cpArray = new Object[endIndex - startIndex]; - outer.parse(new ConstantPoolVisitor() { - - void show(int index, byte tag, Object value) { - if (index < startIndex || index >= endIndex) return; - if (((1 << tag) & tagMask) == 0) return; - cpArray[index - startIndex] = value; - } - - @Override - public void visitUTF8(int index, byte tag, String utf8) { - show(index, tag, utf8); - } - - @Override - public void visitConstantValue(int index, byte tag, Object value) { - assert(tag != CONSTANT_String); - show(index, tag, value); - } - - @Override - public void visitConstantString(int index, byte tag, - String value, int j) { - show(index, tag, value); - } - - @Override - public void visitMemberRef(int index, byte tag, - String className, String memberName, - String signature, - int j, int k) { - show(index, tag, new String[]{ className, memberName, signature }); - } - - @Override - public void visitDescriptor(int index, byte tag, - String memberName, String signature, - int j, int k) { - show(index, tag, new String[]{ memberName, signature }); - } - }); - return cpArray; - } - - /** Write the head (header plus constant pool) - * of the patched class file to the indicated stream. - */ - void writeHead(OutputStream out) throws IOException { - outer.writePatchedHead(out, patchArray); - } - - /** Write the tail (everything after the constant pool) - * of the patched class file to the indicated stream. - */ - void writeTail(OutputStream out) throws IOException { - outer.writeTail(out); - } - - private void checkConstantTag(byte tag, Object value) { - if (value == null) - throw new IllegalArgumentException( - "invalid null constant value"); - if (classForTag(tag) != value.getClass()) - throw new IllegalArgumentException( - "invalid constant value" - + (tag == CONSTANT_None ? "" - : " for tag "+tagName(tag)) - + " of class "+value.getClass()); - } - - private void checkTag(int index, byte putTag) { - byte tag = outer.tags[index]; - if (tag != putTag) - throw new IllegalArgumentException( - "invalid put operation" - + " for " + tagName(putTag) - + " at index " + index + " found " + tagName(tag)); - } - - private void checkTagMask(int index, int tagBitMask) { - byte tag = outer.tags[index]; - int tagBit = ((tag & 0x1F) == tag) ? (1 << tag) : 0; - if ((tagBit & tagBitMask) == 0) - throw new IllegalArgumentException( - "invalid put operation" - + " at index " + index + " found " + tagName(tag)); - } - - private static void checkMemberName(String memberName) { - if (memberName.indexOf(';') >= 0) - throw new IllegalArgumentException("memberName " + memberName + " contains a ';'"); - } - - /** Set the entry of the constant pool indexed by index to - * a new string. - * - * @param index an index to a constant pool entry containing a - * {@link ConstantPoolVisitor#CONSTANT_Utf8} value. - * @param utf8 a string - * - * @see ConstantPoolVisitor#visitUTF8(int, byte, String) - */ - public void putUTF8(int index, String utf8) { - if (utf8 == null) { clear(index); return; } - checkTag(index, CONSTANT_Utf8); - patchArray[index] = utf8; - } - - /** Set the entry of the constant pool indexed by index to - * a new value, depending on its dynamic type. - * - * @param index an index to a constant pool entry containing a - * one of the following structures: - * {@link ConstantPoolVisitor#CONSTANT_Integer}, - * {@link ConstantPoolVisitor#CONSTANT_Float}, - * {@link ConstantPoolVisitor#CONSTANT_Long}, - * {@link ConstantPoolVisitor#CONSTANT_Double}, - * {@link ConstantPoolVisitor#CONSTANT_String}, or - * {@link ConstantPoolVisitor#CONSTANT_Class} - * @param value a boxed int, float, long or double; or a string or class object - * @throws IllegalArgumentException if the type of the constant does not - * match the constant pool entry type, - * as reported by {@link #getTag(int)} - * - * @see #putConstantValue(int, byte, Object) - * @see ConstantPoolVisitor#visitConstantValue(int, byte, Object) - * @see ConstantPoolVisitor#visitConstantString(int, byte, String, int) - */ - public void putConstantValue(int index, Object value) { - if (value == null) { clear(index); return; } - byte tag = tagForConstant(value.getClass()); - checkConstantTag(tag, value); - checkTag(index, tag); - patchArray[index] = value; - } - - /** Set the entry of the constant pool indexed by index to - * a new value. - * - * @param index an index to a constant pool entry matching the given tag - * @param tag one of the following values: - * {@link ConstantPoolVisitor#CONSTANT_Integer}, - * {@link ConstantPoolVisitor#CONSTANT_Float}, - * {@link ConstantPoolVisitor#CONSTANT_Long}, - * {@link ConstantPoolVisitor#CONSTANT_Double}, - * {@link ConstantPoolVisitor#CONSTANT_String}, or - * {@link ConstantPoolVisitor#CONSTANT_Class} - * @param value a boxed number, string, or class object - * @throws IllegalArgumentException if the type of the constant does not - * match the constant pool entry type, or if a class name contains - * '/' or ';' - * - * @see #putConstantValue(int, Object) - * @see ConstantPoolVisitor#visitConstantValue(int, byte, Object) - * @see ConstantPoolVisitor#visitConstantString(int, byte, String, int) - */ - public void putConstantValue(int index, byte tag, Object value) { - if (value == null) { clear(index); return; } - checkTag(index, tag); - if (tag == CONSTANT_Class && value instanceof String) { - checkClassName((String) value); - } else if (tag == CONSTANT_String) { - // the JVM accepts any object as a patch for a string - } else { - // make sure the incoming value is the right type - checkConstantTag(tag, value); - } - checkTag(index, tag); - patchArray[index] = value; - } - - /** Set the entry of the constant pool indexed by index to - * a new {@link ConstantPoolVisitor#CONSTANT_NameAndType} value. - * - * @param index an index to a constant pool entry containing a - * {@link ConstantPoolVisitor#CONSTANT_NameAndType} value. - * @param memberName a memberName - * @param signature a signature - * @throws IllegalArgumentException if memberName contains the character ';' - * - * @see ConstantPoolVisitor#visitDescriptor(int, byte, String, String, int, int) - */ - public void putDescriptor(int index, String memberName, String signature) { - checkTag(index, CONSTANT_NameAndType); - checkMemberName(memberName); - patchArray[index] = addSemis(memberName, signature); - } - - /** Set the entry of the constant pool indexed by index to - * a new {@link ConstantPoolVisitor#CONSTANT_Fieldref}, - * {@link ConstantPoolVisitor#CONSTANT_Methodref}, or - * {@link ConstantPoolVisitor#CONSTANT_InterfaceMethodref} value. - * - * @param index an index to a constant pool entry containing a member reference - * @param className a class name - * @param memberName a field or method name - * @param signature a field or method signature - * @throws IllegalArgumentException if memberName contains the character ';' - * or signature is not a correct signature - * - * @see ConstantPoolVisitor#visitMemberRef(int, byte, String, String, String, int, int) - */ - public void putMemberRef(int index, byte tag, - String className, String memberName, String signature) { - checkTagMask(tag, CONSTANT_MemberRef_MASK); - checkTag(index, tag); - checkClassName(className); - checkMemberName(memberName); - if (signature.startsWith("(") == (tag == CONSTANT_Fieldref)) - throw new IllegalArgumentException("bad signature: "+signature); - patchArray[index] = addSemis(className, memberName, signature); - } - - private static final int CONSTANT_MemberRef_MASK = - CONSTANT_Fieldref - | CONSTANT_Methodref - | CONSTANT_InterfaceMethodref; - - private static final Map, Byte> CONSTANT_VALUE_CLASS_TAG - = new IdentityHashMap, Byte>(6); - private static final Class[] CONSTANT_VALUE_CLASS = new Class[16]; - static { - Object[][] values = { - {Integer.class, CONSTANT_Integer}, - {Long.class, CONSTANT_Long}, - {Float.class, CONSTANT_Float}, - {Double.class, CONSTANT_Double}, - {String.class, CONSTANT_String}, - {Class.class, CONSTANT_Class} - }; - for (Object[] value : values) { - Class cls = (Class)value[0]; - Byte tag = (Byte) value[1]; - CONSTANT_VALUE_CLASS_TAG.put(cls, tag); - CONSTANT_VALUE_CLASS[(byte)tag] = cls; - } - } - - static Class classForTag(byte tag) { - if ((tag & 0xFF) >= CONSTANT_VALUE_CLASS.length) - return null; - return CONSTANT_VALUE_CLASS[tag]; - } - - static byte tagForConstant(Class cls) { - Byte tag = CONSTANT_VALUE_CLASS_TAG.get(cls); - return (tag == null) ? CONSTANT_None : (byte)tag; - } - - private static void checkClassName(String className) { - if (className.indexOf('/') >= 0 || className.indexOf(';') >= 0) - throw new IllegalArgumentException("invalid class name " + className); - } - - static String addSemis(String name, String... names) { - StringBuilder buf = new StringBuilder(name.length() * 5); - buf.append(name); - for (String name2 : names) { - buf.append(';').append(name2); - } - String res = buf.toString(); - assert(stripSemis(names.length, res)[0].equals(name)); - assert(stripSemis(names.length, res)[1].equals(names[0])); - assert(names.length == 1 || - stripSemis(names.length, res)[2].equals(names[1])); - return res; - } - - static String[] stripSemis(int count, String string) { - String[] res = new String[count+1]; - int pos = 0; - for (int i = 0; i < count; i++) { - int pos2 = string.indexOf(';', pos); - if (pos2 < 0) pos2 = string.length(); // yuck - res[i] = string.substring(pos, pos2); - pos = pos2; - } - res[count] = string.substring(pos); - return res; - } - - public String toString() { - StringBuilder buf = new StringBuilder(this.getClass().getName()); - buf.append("{"); - Object[] origCP = null; - for (int i = 0; i < patchArray.length; i++) { - if (patchArray[i] == null) continue; - if (origCP != null) { - buf.append(", "); - } else { - try { - origCP = getOriginalCP(); - } catch (InvalidConstantPoolFormatException ee) { - origCP = new Object[0]; - } - } - Object orig = (i < origCP.length) ? origCP[i] : "?"; - buf.append(orig).append("=").append(patchArray[i]); - } - buf.append("}"); - return buf.toString(); - } -} diff --git a/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolVisitor.java b/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolVisitor.java deleted file mode 100644 index dfec8b41151..00000000000 --- a/jdk/src/java.base/share/classes/sun/invoke/anon/ConstantPoolVisitor.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.invoke.anon; - -/** - * A visitor called by {@link ConstantPoolParser#parse(ConstantPoolVisitor)} - * when a constant pool entry is parsed. - *

- * A visit* method is called when a constant pool entry is parsed. - * The first argument is always the constant pool index. - * The second argument is always the constant pool tag, - * even for methods like {@link #visitUTF8(int, byte, String)} which only apply to one tag. - * String arguments refer to Utf8 or NameAndType entries declared elsewhere, - * and are always accompanied by the indexes of those entries. - *

- * The order of the calls to the visit* methods is not necessarily related - * to the order of the entries in the constant pool. - * If one entry has a reference to another entry, the latter (lower-level) - * entry will be visited first. - *

- * The following table shows the relation between constant pool entry - * types and the corresponding visit* methods: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Tag(s)Method
{@link #CONSTANT_Utf8}{@link #visitUTF8(int, byte, String)}
{@link #CONSTANT_Integer}, {@link #CONSTANT_Float}, - * {@link #CONSTANT_Long}, {@link #CONSTANT_Double}{@link #visitConstantValue(int, byte, Object)}
{@link #CONSTANT_String}, {@link #CONSTANT_Class}{@link #visitConstantString(int, byte, String, int)}
{@link #CONSTANT_NameAndType}{@link #visitDescriptor(int, byte, String, String, int, int)}
{@link #CONSTANT_Fieldref}, - * {@link #CONSTANT_Methodref}, - * {@link #CONSTANT_InterfaceMethodref}{@link #visitMemberRef(int, byte, String, String, String, int, int)}
- * - * @see ConstantPoolPatch - * @author Remi Forax - * @author jrose - */ -public class ConstantPoolVisitor { - /** Called each time an UTF8 constant pool entry is found. - * @param index the constant pool index - * @param tag always {@link #CONSTANT_Utf8} - * @param utf8 string encoded in modified UTF-8 format passed as a {@code String} - * - * @see ConstantPoolPatch#putUTF8(int, String) - */ - public void visitUTF8(int index, byte tag, String utf8) { - // do nothing - } - - /** Called for each constant pool entry that encodes an integer, - * a float, a long, or a double. - * Constant strings and classes are not managed by this method but - * by {@link #visitConstantString(int, byte, String, int)}. - * - * @param index the constant pool index - * @param tag one of {@link #CONSTANT_Integer}, - * {@link #CONSTANT_Float}, - * {@link #CONSTANT_Long}, - * or {@link #CONSTANT_Double} - * @param value encoded value - * - * @see ConstantPoolPatch#putConstantValue(int, Object) - */ - public void visitConstantValue(int index, byte tag, Object value) { - // do nothing - } - - /** Called for each constant pool entry that encodes a string or a class. - * @param index the constant pool index - * @param tag one of {@link #CONSTANT_String}, - * {@link #CONSTANT_Class}, - * @param name string body or class name (using dot separator) - * @param nameIndex the index of the Utf8 string for the name - * - * @see ConstantPoolPatch#putConstantValue(int, byte, Object) - */ - public void visitConstantString(int index, byte tag, - String name, int nameIndex) { - // do nothing - } - - /** Called for each constant pool entry that encodes a name and type. - * @param index the constant pool index - * @param tag always {@link #CONSTANT_NameAndType} - * @param memberName a field or method name - * @param signature the member signature - * @param memberNameIndex index of the Utf8 string for the member name - * @param signatureIndex index of the Utf8 string for the signature - * - * @see ConstantPoolPatch#putDescriptor(int, String, String) - */ - public void visitDescriptor(int index, byte tag, - String memberName, String signature, - int memberNameIndex, int signatureIndex) { - // do nothing - } - - /** Called for each constant pool entry that encodes a field or method. - * @param index the constant pool index - * @param tag one of {@link #CONSTANT_Fieldref}, - * or {@link #CONSTANT_Methodref}, - * or {@link #CONSTANT_InterfaceMethodref} - * @param className the class name (using dot separator) - * @param memberName name of the field or method - * @param signature the field or method signature - * @param classNameIndex index of the Utf8 string for the class name - * @param descriptorIndex index of the NameAndType descriptor constant - * - * @see ConstantPoolPatch#putMemberRef(int, byte, String, String, String) - */ - public void visitMemberRef(int index, byte tag, - String className, String memberName, String signature, - int classNameIndex, int descriptorIndex) { - // do nothing - } - - public static final byte - CONSTANT_None = 0, - CONSTANT_Utf8 = 1, - //CONSTANT_Unicode = 2, /* unused */ - CONSTANT_Integer = 3, - CONSTANT_Float = 4, - CONSTANT_Long = 5, - CONSTANT_Double = 6, - CONSTANT_Class = 7, - CONSTANT_String = 8, - CONSTANT_Fieldref = 9, - CONSTANT_Methodref = 10, - CONSTANT_InterfaceMethodref = 11, - CONSTANT_NameAndType = 12; - - private static String[] TAG_NAMES = { - "Empty", - "Utf8", - null, //"Unicode", - "Integer", - "Float", - "Long", - "Double", - "Class", - "String", - "Fieldref", - "Methodref", - "InterfaceMethodref", - "NameAndType" - }; - - public static String tagName(byte tag) { - String name = null; - if ((tag & 0xFF) < TAG_NAMES.length) - name = TAG_NAMES[tag]; - if (name == null) - name = "Unknown#"+(tag&0xFF); - return name; - } -} diff --git a/jdk/src/java.base/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java b/jdk/src/java.base/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java deleted file mode 100644 index d420d34b0d6..00000000000 --- a/jdk/src/java.base/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.invoke.anon; - -/** Exception used when there is an error in the constant pool - * format. - */ -public class InvalidConstantPoolFormatException extends Exception { - private static final long serialVersionUID=-6103888330523770949L; - - public InvalidConstantPoolFormatException(String message,Throwable cause) { - super(message,cause); - } - - public InvalidConstantPoolFormatException(String message) { - super(message); - } - - public InvalidConstantPoolFormatException(Throwable cause) { - super(cause); - } -} diff --git a/jdk/test/sun/invoke/anon/ConstantPoolPatch/OptimalMapSize.java b/jdk/test/sun/invoke/anon/ConstantPoolPatch/OptimalMapSize.java deleted file mode 100644 index d3895dd9255..00000000000 --- a/jdk/test/sun/invoke/anon/ConstantPoolPatch/OptimalMapSize.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8080535 - * @summary Static storages should be initialized with optimal capacity - * @library /lib/testlibrary - * @build jdk.testlibrary.OptimalCapacity - * @run main OptimalMapSize - */ - -import jdk.testlibrary.OptimalCapacity; - -public class OptimalMapSize { - public static void main(String[] args) throws Throwable { - OptimalCapacity.ofIdentityHashMap( - Class.forName("sun.invoke.anon.ConstantPoolPatch"), - "CONSTANT_VALUE_CLASS_TAG", 6); - } -} From ac45dea45ef65d7b0d950242d2afdc82cab9c87f Mon Sep 17 00:00:00 2001 From: David Lindholm Date: Wed, 18 Nov 2015 14:51:10 +0100 Subject: [PATCH 020/109] 8145092: Use Unified Logging for the GC logging JEP-271 Reviewed-by: sjohanss, brutisso --- .../HotSpotDiagnosticMXBean/CheckOrigin.java | 4 ++-- .../HotSpotDiagnosticMXBean/GetVMOption.java | 6 ++--- .../HotSpotDiagnosticMXBean/SetVMOption.java | 20 ++++++++-------- .../MemoryMXBean/LowMemoryTest.java | 2 +- .../lang/management/MemoryMXBean/RunUtil.java | 2 +- .../RuntimeMXBean/TestInputArgument.sh | 4 ++-- .../DecimalFormat/FormatMicroBenchmark.java | 8 +++---- .../jdk/testlibrary/JDKToolLauncher.java | 3 +-- .../jinfo/JInfoRunningProcessFlagTest.java | 24 +++++++++---------- jdk/test/sun/tools/jps/JpsHelper.java | 2 +- 10 files changed, 37 insertions(+), 38 deletions(-) diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java index 6f3ac9feec5..9b8afea79e9 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -62,7 +62,7 @@ public class CheckOrigin { ProcessBuilder pb = ProcessTools. createJavaProcessBuilder( "-XX:+UseConcMarkSweepGC", // this will cause UseParNewGC to be FLAG_SET_ERGO - "-XX:+PrintGCDetails", + "-XX:+UseCodeAging", "-XX:+UseCerealGC", // Should be ignored. "-XX:Flags=" + flagsFile.getAbsolutePath(), "-cp", System.getProperty("test.class.path"), @@ -97,7 +97,7 @@ public class CheckOrigin { // Not set, so should be default checkOrigin("ManagementServer", Origin.DEFAULT); // Set on the command line - checkOrigin("PrintGCDetails", Origin.VM_CREATION); + checkOrigin("UseCodeAging", Origin.VM_CREATION); // Set in _JAVA_OPTIONS checkOrigin("TraceExceptions", Origin.ENVIRON_VAR); // Set in JAVA_TOOL_OPTIONS diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java index 16589749648..49edcc14415 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetVMOption.java @@ -28,7 +28,7 @@ * @author Mandy Chung * * @modules jdk.management - * @run main/othervm -XX:+PrintGCDetails GetVMOption + * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError GetVMOption */ import com.sun.management.HotSpotDiagnosticMXBean; @@ -38,7 +38,7 @@ import java.util.List; import javax.management.MBeanServer; public class GetVMOption { - private static final String PRINT_GC_DETAILS = "PrintGCDetails"; + private static final String HEAP_DUMP_ON_OOM = "HeapDumpOnOutOfMemoryError"; private static final String EXPECTED_VALUE = "true"; private static final String BAD_OPTION = "BadOption"; private static final String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME = @@ -58,7 +58,7 @@ public class GetVMOption { } private static void checkVMOption(HotSpotDiagnosticMXBean mbean) { - VMOption option = mbean.getVMOption(PRINT_GC_DETAILS); + VMOption option = mbean.getVMOption(HEAP_DUMP_ON_OOM); if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) { throw new RuntimeException("Unexpected value: " + option.getValue() + " expected: " + EXPECTED_VALUE); diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java index 1c7117d91d0..d11ec33fa7c 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java @@ -30,7 +30,7 @@ * @author Jaroslav Bachorik * * @modules jdk.management - * @run main/othervm -XX:+PrintGCDetails SetVMOption + * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError SetVMOption */ import java.lang.management.ManagementFactory; @@ -40,7 +40,7 @@ import com.sun.management.VMOption; import com.sun.management.VMOption.Origin; public class SetVMOption { - private static final String PRINT_GC_DETAILS = "PrintGCDetails"; + private static final String HEAP_DUMP_ON_OOM = "HeapDumpOnOutOfMemoryError"; private static final String EXPECTED_VALUE = "true"; private static final String BAD_VALUE = "yes"; private static final String NEW_VALUE = "false"; @@ -51,7 +51,7 @@ public class SetVMOption { mbean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); - VMOption option = findPrintGCDetailsOption(); + VMOption option = findHeapDumpOnOomOption(); if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) { throw new RuntimeException("Unexpected value: " + option.getValue() + " expected: " + EXPECTED_VALUE); @@ -61,14 +61,14 @@ public class SetVMOption { option.getOrigin() + " expected: VM_CREATION"); } if (!option.isWriteable()) { - throw new RuntimeException("Expected " + PRINT_GC_DETAILS + + throw new RuntimeException("Expected " + HEAP_DUMP_ON_OOM + " to be writeable"); } // set VM option to a new value - mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE); + mbean.setVMOption(HEAP_DUMP_ON_OOM, NEW_VALUE); - option = findPrintGCDetailsOption(); + option = findHeapDumpOnOomOption(); if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) { throw new RuntimeException("Unexpected value: " + option.getValue() + " expected: " + NEW_VALUE); @@ -77,7 +77,7 @@ public class SetVMOption { throw new RuntimeException("Unexpected origin: " + option.getOrigin() + " expected: MANAGEMENT"); } - VMOption o = mbean.getVMOption(PRINT_GC_DETAILS); + VMOption o = mbean.getVMOption(HEAP_DUMP_ON_OOM); if (!option.getValue().equals(o.getValue())) { throw new RuntimeException("Unmatched value: " + option.getValue() + " expected: " + o.getValue()); @@ -123,17 +123,17 @@ public class SetVMOption { } } - public static VMOption findPrintGCDetailsOption() { + public static VMOption findHeapDumpOnOomOption() { List options = mbean.getDiagnosticOptions(); VMOption gcDetails = null; for (VMOption o : options) { - if (o.getName().equals(PRINT_GC_DETAILS)) { + if (o.getName().equals(HEAP_DUMP_ON_OOM)) { gcDetails = o; break; } } if (gcDetails == null) { - throw new RuntimeException("VM option " + PRINT_GC_DETAILS + + throw new RuntimeException("VM option " + HEAP_DUMP_ON_OOM + " not found"); } return gcDetails; diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java index 5e8bda4cd86..8e3c2e55a3f 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java @@ -100,7 +100,7 @@ public class LowMemoryTest { opts.addAll(Arrays.asList(Utils.getTestJavaOpts())); opts.add("-cp"); opts.add(System.getProperty("test.class.path", "test.class.path")); - opts.add("-XX:+PrintGCDetails"); + opts.add("-Xlog:gc*=debug"); opts.addAll(Arrays.asList(testOpts)); opts.add(classMain); diff --git a/jdk/test/java/lang/management/MemoryMXBean/RunUtil.java b/jdk/test/java/lang/management/MemoryMXBean/RunUtil.java index 5f9d07c1a00..24761131484 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/RunUtil.java +++ b/jdk/test/java/lang/management/MemoryMXBean/RunUtil.java @@ -66,7 +66,7 @@ public class RunUtil { opts.addAll(Arrays.asList(Utils.getTestJavaOpts())); opts.add("-cp"); opts.add(System.getProperty("test.class.path", "test.class.path")); - opts.add("-XX:+PrintGCDetails"); + opts.add("-Xlog:gc*=debug"); if (clearGcOpts) { opts = Utils.removeGcOpts(opts); diff --git a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh index f92fac42db0..d76b2bd2c34 100644 --- a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh +++ b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh @@ -48,8 +48,8 @@ runOne() runOne InputArgument -runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails -runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+UseFastJNIAccessors +runOne -XX:+UseFastJNIAccessors -Xlog:gc*=debug InputArgument +runOne -XX:+UseFastJNIAccessors -Xlog:gc*=debug InputArgument -XX:+UseFastJNIAccessors runOne "-Dprops=one two three" InputArgument "-Dprops=one two three" exit 0 diff --git a/jdk/test/java/text/Format/DecimalFormat/FormatMicroBenchmark.java b/jdk/test/java/text/Format/DecimalFormat/FormatMicroBenchmark.java index cd8648a70ce..372d3e0ce98 100644 --- a/jdk/test/java/text/Format/DecimalFormat/FormatMicroBenchmark.java +++ b/jdk/test/java/text/Format/DecimalFormat/FormatMicroBenchmark.java @@ -51,7 +51,7 @@ * getting reliable numbers. Otherwise GC activity may corrupt results. * As of jdk80b48 using "-Xms500m -Xmx500m -XX:NewSize=400m" covers * all cases. - * - Optionally using "-XX:+printGC" option provides information that + * - Optionally using "-Xlog:gc" option provides information that * helps checking any GC activity while benches are run. * * Vm Options: @@ -60,7 +60,7 @@ * non fast-path case: -Xms500m -Xmx500m -XX:NewSize=400m * or use worst case (non fast-path above) with both types of algorithm. * - * - use -XX:+PrintGC to verify memory consumption of the benchmarks. + * - use -Xlog:gc to verify memory consumption of the benchmarks. * (See "Checking Memory Consumption" below). * * Description: @@ -166,7 +166,7 @@ * but is not enough, since any unexpected incremental GC may lower * artificially the estimation of the memory consumption. * - * Options to set are -Xms, -Xmx, -XX:NewSize, plus -XX:+PrintGC to evaluate + * Options to set are -Xms, -Xmx, -XX:NewSize, plus -Xlog:gc to evaluate * correctly the values of these options. When running "-verbose", varying * numbers reported for memory consumption may indicate bad choices for these * options. @@ -217,7 +217,7 @@ public class FormatMicroBenchmark { " getting reliable numbers. Otherwise GC activity may corrupt results.\n" + " As of jdk80b48 using \"-Xms500m -Xmx500m -XX:NewSize=400m\" covers \n" + " all cases.\n" + - " - Optionally using \"-XX:+printGC\" option provides information that \n" + + " - Optionally using \"-Xlog:gc\" option provides information that \n" + " helps checking any GC activity while benches are run.\n\n" + "Look at the heading comments and description in source code for " + "detailed information.\n"); diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java index 43f1ddb97d6..777e8cf5336 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java @@ -38,8 +38,7 @@ import java.util.List; *

  * {@code
  * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
- *                                       .addVMArg("-XX:+PrintGC");
- *                                       .addVMArg("-XX:+PrintGCDetails")
+ *                                       .addVMArg("-Xlog:gc*=debug")
  *                                       .addToolArg("-heap")
  *                                       .addToolArg(pid);
  * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
diff --git a/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java b/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java
index 35dd7526e20..cb28cc7a49f 100644
--- a/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java
+++ b/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java
@@ -60,30 +60,30 @@ public class JInfoRunningProcessFlagTest {
     }
 
     private static void testFlagPlus() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+PrintGC");
+        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+HeapDumpOnOutOfMemoryError");
         output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "PrintGC");
+        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
         output.shouldHaveExitValue(0);
-        output.shouldContain("+PrintGC");
-        verifyIsEnabled("PrintGC");
+        output.shouldContain("+HeapDumpOnOutOfMemoryError");
+        verifyIsEnabled("HeapDumpOnOutOfMemoryError");
     }
 
     private static void testFlagMinus() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-PrintGC");
+        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-HeapDumpOnOutOfMemoryError");
         output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "PrintGC");
+        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
         output.shouldHaveExitValue(0);
-        output.shouldContain("-PrintGC");
-        verifyIsDisabled("PrintGC");
+        output.shouldContain("-HeapDumpOnOutOfMemoryError");
+        verifyIsDisabled("HeapDumpOnOutOfMemoryError");
     }
 
     private static void testFlagEqual() throws Exception {
-        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "PrintGC=1");
+        OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError=1");
         output.shouldHaveExitValue(0);
-        output = JInfoHelper.jinfo("-flag", "PrintGC");
+        output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
         output.shouldHaveExitValue(0);
-        output.shouldContain("+PrintGC");
-        verifyIsEnabled("PrintGC");
+        output.shouldContain("+HeapDumpOnOutOfMemoryError");
+        verifyIsEnabled("HeapDumpOnOutOfMemoryError");
     }
 
     private static void testInvalidFlag() throws Exception {
diff --git a/jdk/test/sun/tools/jps/JpsHelper.java b/jdk/test/sun/tools/jps/JpsHelper.java
index 6f32ff4f67a..3078ea5a336 100644
--- a/jdk/test/sun/tools/jps/JpsHelper.java
+++ b/jdk/test/sun/tools/jps/JpsHelper.java
@@ -98,7 +98,7 @@ public final class JpsHelper {
      * -XX:+UsePerfData is required for running the tests on embedded platforms.
      */
     public static final String[] VM_ARGS = {
-        "-XX:+UsePerfData", "-Xmx512m", "-XX:+PrintGCDetails",
+        "-XX:+UsePerfData", "-Xmx512m", "-Xlog:gc",
         "-Dmultiline.prop=value1\nvalue2\r\nvalue3"
     };
     /**

From 343b6c32534ff4b150268c436b16c775895a85f3 Mon Sep 17 00:00:00 2001
From: Weijun Wang 
Date: Thu, 26 Nov 2015 16:25:48 -0800
Subject: [PATCH 021/109] 8143959: Certificates requiring blacklisting

Reviewed-by: mullan
---
 .../blacklisted.certs.pem                     | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem b/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem
index db1c077ccb0..191e94e12a5 100644
--- a/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem
+++ b/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem
@@ -725,3 +725,26 @@ v9qpeC45ZA/jelxV11HKbQnVF194gDb7D2H9OsAsRUy8HVKbXEcc/8dKvwOqb+BC
 DBabJH1vJ9Gd+KwxMCmBZ6pQPl28JDimhJhI2LNqU349uADQVV0HJosddN/ARyyI
 LSIQO7BnNVKVG9Iujf33bvPNeg0qNz5qw+rKKq97Pqeum+L5oKU=
 -----END CERTIFICATE-----
+
+// Subject: CN=eDellRoot
+// Issuer: CN=eDellRoot
+// Serial Number:
+//     6b:c5:7b:95:18:93:aa:97:4b:62:4a:c0:88:fc:3b:b6
+-----BEGIN CERTIFICATE-----
+MIIC8zCCAd+gAwIBAgIQa8V7lRiTqpdLYkrAiPw7tjAJBgUrDgMCHQUAMBQxEjAQ
+BgNVBAMTCWVEZWxsUm9vdDAeFw0xNTA0MDcxMDIzMjdaFw0zOTEyMzEyMzU5NTla
+MBQxEjAQBgNVBAMTCWVEZWxsUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
+AQoCggEBAL3RJg1uzVuEX0Hw4XWGzs6oI9W+o7HZdVdBMMVb4Gzb4uZjCTNjbPx4
+b8LNFL1uArUt+5VVMQDsOTY3Lg/Xe/UNukY2b+0llUOzzBYYpbsFcco4n6SsTvDh
+Ni5t+kPo7c23ZrYBPmOu82eEJ6cavs/t39u+wFOkXXwvRCiHA/lWyNWNEPh17+bC
+EP3q5N+JrV+6Ho3zQPEv5QUJYdmXsMmD2CMQojeQUj68J91P5w5BKjurG0xjivzh
+Soie9ym7VRwLFjWScRuw/9XV6CLqTyL5xrqiiDp1uTOuqNj3uxyts9ocbsoJXuxj
+5iEYkSM1nvLupEv+lgy9WqzIEFMm1l8CAwEAAaNJMEcwRQYDVR0BBD4wPIAQYA/f
+EzPwmaRcZuSaa/VZ1KEWMBQxEjAQBgNVBAMTCWVEZWxsUm9vdIIQa8V7lRiTqpdL
+YkrAiPw7tjAJBgUrDgMCHQUAA4IBAQArfdcScsezj8ooJ92UwwnPgg36noOgiUs5
+XzPLP4h0JpUYQVKB9hY1WTDwRUfTKGh7oNOowd027a/rVSb/TNeoiJIvMKn4gbvV
+CWAiHhO8u2u0RkHCDVsa7e0i4ncpueWsihjn6jBrY8T+7eDYwiFT/F03A8NJ7mK5
+lZA8SFd5CTDy3EBUU5UwzXUc5HoIRUxXSPycu3aIBWawg3sCdKiAoikScPAWj0bM
+0vmsP/8QSlTOBqO+QFQ6R82BtTvBNU3qbVICV4QObsxib++FAFL56NApPqskg7Vz
+LfNIAjKabHUcjbuZkmg6jr4BfYW7+oQDHCsYgADjjKGdKz/8U/fP
+-----END CERTIFICATE-----

From 78853b0d4679356e3060b3caba60828451be6379 Mon Sep 17 00:00:00 2001
From: Chris Hegarty 
Date: Tue, 1 Dec 2015 12:38:28 +0000
Subject: [PATCH 022/109] 8143185: Cleanup for handling proxies

Reviewed-by: alanb, darcy, robm, rriggs, skoivu, rriggs
---
 .../AnnotationInvocationHandler.java          | 52 ++++++++++++++++---
 1 file changed, 45 insertions(+), 7 deletions(-)

diff --git a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
index 2f6bdee2f93..a69b32f2be4 100644
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
@@ -25,6 +25,7 @@
 
 package sun.reflect.annotation;
 
+import java.io.ObjectInputStream;
 import java.lang.annotation.*;
 import java.lang.reflect.*;
 import java.io.Serializable;
@@ -431,35 +432,72 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
 
     private void readObject(java.io.ObjectInputStream s)
         throws java.io.IOException, ClassNotFoundException {
-        s.defaultReadObject();
+        ObjectInputStream.GetField fields = s.readFields();
+
+        @SuppressWarnings("unchecked")
+        Class t = (Class)fields.get("type", null);
+        @SuppressWarnings("unchecked")
+        Map streamVals = (Map)fields.get("memberValues", null);
 
         // Check to make sure that types have not evolved incompatibly
 
         AnnotationType annotationType = null;
         try {
-            annotationType = AnnotationType.getInstance(type);
+            annotationType = AnnotationType.getInstance(t);
         } catch(IllegalArgumentException e) {
             // Class is no longer an annotation type; time to punch out
             throw new java.io.InvalidObjectException("Non-annotation type in annotation serial stream");
         }
 
         Map> memberTypes = annotationType.memberTypes();
+        // consistent with runtime Map type
+        Map mv = new LinkedHashMap<>();
 
         // If there are annotation members without values, that
         // situation is handled by the invoke method.
-        for (Map.Entry memberValue : memberValues.entrySet()) {
+        for (Map.Entry memberValue : streamVals.entrySet()) {
             String name = memberValue.getKey();
+            Object value = null;
             Class memberType = memberTypes.get(name);
             if (memberType != null) {  // i.e. member still exists
-                Object value = memberValue.getValue();
+                value = memberValue.getValue();
                 if (!(memberType.isInstance(value) ||
                       value instanceof ExceptionProxy)) {
-                    memberValue.setValue(
-                        new AnnotationTypeMismatchExceptionProxy(
+                    value = new AnnotationTypeMismatchExceptionProxy(
                             value.getClass() + "[" + value + "]").setMember(
-                                annotationType.members().get(name)));
+                                annotationType.members().get(name));
                 }
             }
+            mv.put(name, value);
+        }
+
+        UnsafeAccessor.setType(this, t);
+        UnsafeAccessor.setMemberValues(this, mv);
+    }
+
+    private static class UnsafeAccessor {
+        private static final jdk.internal.misc.Unsafe unsafe;
+        private static final long typeOffset;
+        private static final long memberValuesOffset;
+        static {
+            try {
+                unsafe = jdk.internal.misc.Unsafe.getUnsafe();
+                typeOffset = unsafe.objectFieldOffset
+                        (AnnotationInvocationHandler.class.getDeclaredField("type"));
+                memberValuesOffset = unsafe.objectFieldOffset
+                        (AnnotationInvocationHandler.class.getDeclaredField("memberValues"));
+            } catch (Exception ex) {
+                throw new ExceptionInInitializerError(ex);
+            }
+        }
+        static void setType(AnnotationInvocationHandler o,
+                            Class type) {
+            unsafe.putObject(o, typeOffset, type);
+        }
+
+        static void setMemberValues(AnnotationInvocationHandler o,
+                                    Map memberValues) {
+            unsafe.putObject(o, memberValuesOffset, memberValues);
         }
     }
 }

From 24e53a99d3a90413334202d5c0a34cea134302a4 Mon Sep 17 00:00:00 2001
From: Alexander Zvegintsev 
Date: Tue, 8 Dec 2015 19:01:33 +0300
Subject: [PATCH 023/109] 8143941: Update splashscreen displays

Reviewed-by: ahgross, prr, serb
---
 .../native/libsplashscreen/libpng/CHANGES     | 411 +++++++-
 .../native/libsplashscreen/libpng/LICENSE     |  55 +-
 .../native/libsplashscreen/libpng/README      |   4 +-
 .../share/native/libsplashscreen/libpng/png.c | 345 +++----
 .../share/native/libsplashscreen/libpng/png.h | 602 +++++-------
 .../native/libsplashscreen/libpng/pngconf.h   |  50 +-
 .../native/libsplashscreen/libpng/pngdebug.h  |   3 +-
 .../native/libsplashscreen/libpng/pngget.c    |  36 +-
 .../native/libsplashscreen/libpng/pnginfo.h   |   3 +-
 .../libsplashscreen/libpng/pnglibconf.h       |  12 +-
 .../native/libsplashscreen/libpng/pngmem.c    |   5 +-
 .../native/libsplashscreen/libpng/pngpread.c  | 125 +--
 .../native/libsplashscreen/libpng/pngpriv.h   | 123 ++-
 .../native/libsplashscreen/libpng/pngread.c   |  59 +-
 .../native/libsplashscreen/libpng/pngrio.c    |   6 +-
 .../native/libsplashscreen/libpng/pngrtran.c  |  85 +-
 .../native/libsplashscreen/libpng/pngrutil.c  | 429 +++++----
 .../native/libsplashscreen/libpng/pngset.c    | 100 +-
 .../native/libsplashscreen/libpng/pngstruct.h |  38 +-
 .../native/libsplashscreen/libpng/pngtest.c   | 196 ++--
 .../native/libsplashscreen/libpng/pngtrans.c  |  10 +-
 .../native/libsplashscreen/libpng/pngwio.c    |   2 +-
 .../native/libsplashscreen/libpng/pngwrite.c  | 637 ++++---------
 .../native/libsplashscreen/libpng/pngwtran.c  |  16 +-
 .../native/libsplashscreen/libpng/pngwutil.c  | 902 ++++++------------
 .../native/libsplashscreen/splashscreen_png.c |   1 +
 26 files changed, 1971 insertions(+), 2284 deletions(-)

diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
index 443187481ba..8d9d53ee4e2 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES
@@ -23,13 +23,17 @@
  * questions.
  */
 
+#if 0
 CHANGES - changes for libpng
 
-Version 0.2
+version 0.1 [March 29, 1995]
+  initial work-in-progress release
+
+version 0.2 [April 1, 1995]
   added reader into png.h
   fixed small problems in stub file
 
-Version 0.3
+version 0.3 [April 8, 1995]
   added pull reader
   split up pngwrite.c to several files
   added pnglib.txt
@@ -38,9 +42,9 @@ Version 0.3
   fixed some bugs in writer
   interfaced with zlib 0.5
   added K&R support
-  added check for 64 KB blocks for 16-bit machines
+  added check for 64 KB blocks for 16 bit machines
 
-Version 0.4
+version 0.4 [April 26, 1995]
   cleaned up code and commented code
   simplified time handling into png_time
   created png_color_16 and png_color_8 to handle color needs
@@ -51,28 +55,29 @@ Version 0.4
   cleaned up zTXt reader and writer (using zlib's Reset functions)
   split transformations into pngrtran.c and pngwtran.c
 
-Version 0.5
+version 0.5 [April 30, 1995]
   interfaced with zlib 0.8
   fixed many reading and writing bugs
   saved using 3 spaces instead of tabs
 
-Version 0.6
+version 0.6 [May 1, 1995]
+  first beta release
   added png_large_malloc() and png_large_free()
   added png_size_t
   cleaned up some compiler warnings
   added png_start_read_image()
 
-Version 0.7
+version 0.7 [June 24, 1995]
   cleaned up lots of bugs
   finished dithering and other stuff
   added test program
   changed name from pnglib to libpng
 
-Version 0.71 [June, 1995]
+version 0.71 [June 26, 1995]
   changed pngtest.png for zlib 0.93
   fixed error in libpng.txt and example.c
 
-Version 0.8
+version 0.8 [August 20, 1995]
   cleaned up some bugs
   added png_set_filler()
   split up pngstub.c into pngmem.c, pngio.c, and pngerror.c
@@ -115,7 +120,7 @@ Version 0.88 [January, 1996]
   cleaned up documentation
   added callbacks for read/write and warning/error functions
 
-Version 0.89 [July, 1996]
+Version 0.89 [June 5, 1996]
   Added new initialization API to make libpng work better with shared libs
     we now have png_create_read_struct(), png_create_write_struct(),
     png_create_info_struct(), png_destroy_read_struct(), and
@@ -142,6 +147,9 @@ Version 0.89 [July, 1996]
   New pngtest image also has interlacing and zTXt
   Updated documentation to reflect new API
 
+Version 0.89c [June 17, 1996]
+  Bug fixes.
+
 Version 0.90 [January, 1997]
   Made CRC errors/warnings on critical and ancillary chunks configurable
   libpng will use the zlib CRC routines by (compile-time) default
@@ -182,7 +190,7 @@ Version 0.95 [March, 1997]
   Added new pCAL chunk read/write support
   Added experimental filter selection weighting (Greg Roelofs)
   Removed old png_set_rgbx() and png_set_xrgb() functions that have been
-     obsolete for about 2 years now (use png_set_filler() instead)
+    obsolete for about 2 years now (use png_set_filler() instead)
   Added macros to read 16- and 32-bit ints directly from buffer, to be
     used only on those systems that support it (namely PowerPC and 680x0)
     With some testing, this may become the default for MACOS/PPC systems.
@@ -464,7 +472,7 @@ Version 1.0.3 [January 14, 1999]
 
 Version 1.0.3a [August 12, 1999]
   Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
-     if an attempt is made to read an interlaced image when it's not supported.
+    if an attempt is made to read an interlaced image when it's not supported.
   Added check if png_ptr->trans is defined before freeing it in pngread.c
   Modified the Y2K statement to include versions back to version 0.71
   Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
@@ -472,7 +480,7 @@ Version 1.0.3a [August 12, 1999]
   Replaced leading blanks with tab characters in makefile.hux
   Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
   Changed (float)red and (float)green to (double)red, (double)green
-     in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
+    in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
   Fixed a bug in pngconf.h that omitted  when PNG_DEBUG==0 (K Bracey).
   Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt).
   Updated documentation to refer to the PNG-1.2 specification.
@@ -515,7 +523,7 @@ Version 1.0.3d [September 4, 1999]
   Added new png_expand functions to scripts/pngdef.pas and pngos2.def
   Added a demo read_user_transform_fn that examines the row filters in pngtest.c
 
-Version 1.0.4 [September 24, 1999]
+Version 1.0.4 [September 24, 1999, not distributed publicly]
   Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
   Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h
   Made several minor corrections to pngtest.c
@@ -542,6 +550,7 @@ Version 1.0.4c [October 1, 1999]
   Added a "png_check_version" function in png.c and pngtest.c that will generate
     a helpful compiler error if an old png.h is found in the search path.
   Changed type of png_user_transform_depth|channels from int to png_byte.
+  Added "Libpng is OSI Certified Open Source Software" statement to png.h
 
 Version 1.0.4d [October 6, 1999]
   Changed 0.45 to 0.45455 in png_set_sRGB()
@@ -928,7 +937,7 @@ Version 1.0.7 [July 1, 2000]
 Version 1.0.8beta1 [July 8, 2000]
   Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks.
   Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and
-     pngwutil.c.
+    pngwutil.c.
   Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h.
   Removed unused "#include " from png.c
   Added WindowsCE support.
@@ -936,12 +945,12 @@ Version 1.0.8beta1 [July 8, 2000]
 
 Version 1.0.8beta2 [July 10, 2000]
   Added project files to the wince directory and made further revisions
-     of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE.
+    of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE.
 
 Version 1.0.8beta3 [July 11, 2000]
   Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS()
-     for indexed-color input files to avoid potential double-freeing trans array
-     under some unusual conditions; problem was introduced in version 1.0.6f.
+    for indexed-color input files to avoid potential double-freeing trans array
+    under some unusual conditions; problem was introduced in version 1.0.6f.
   Further revisions to pngtest.c and files in the wince subdirectory.
 
 Version 1.0.8beta4 [July 14, 2000]
@@ -1113,16 +1122,16 @@ Version 1.2.0beta3 [May 17, 2001]
 
 Version 1.2.0beta4 [June 23, 2001]
   Check for missing profile length field in iCCP chunk and free chunk_data
-     in case of truncated iCCP chunk.
+    in case of truncated iCCP chunk.
   Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc
   Bumped dll-number from 2 to 3 in makefile.cygwin
   Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly
-     if user attempts to run it on an 8-bit display.
+    if user attempts to run it on an 8-bit display.
   Updated contrib/gregbook
   Use png_malloc instead of png_zalloc to allocate palette in pngset.c
   Updated makefile.ibmc
   Added some typecasts to eliminate gcc 3.0 warnings.  Changed prototypes
-     of png_write_oFFS width and height from png_uint_32 to png_int_32.
+    of png_write_oFFS width and height from png_uint_32 to png_int_32.
   Updated example.c
   Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c
 
@@ -1130,9 +1139,9 @@ Version 1.2.0beta5 [August 8, 2001]
   Revised contrib/gregbook
   Revised makefile.gcmmx
   Revised pnggccrd.c to conditionally compile some thread-unsafe code only
-     when PNG_THREAD_UNSAFE_OK is defined.
+    when PNG_THREAD_UNSAFE_OK is defined.
   Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with
-     value exceeding 2^bit_depth-1
+    value exceeding 2^bit_depth-1
   Revised makefile.sgi and makefile.sggcc
   Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c
   Removed restriction that do_invert_mono only operate on 1-bit opaque files
@@ -1473,8 +1482,9 @@ Version 1.2.6beta4 [July 28, 2004]
   Use png_malloc instead of png_zalloc to allocate the pallete.
 
 Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004]
-  Fixed buffer overflow vulnerability in png_handle_tRNS()
-  Fixed integer arithmetic overflow vulnerability in png_read_png().
+  Fixed buffer overflow vulnerability (CVE-2004-0597) in png_handle_tRNS().
+  Fixed NULL dereference vulnerability (CVE-2004-0598) in png_handle_iCCP().
+  Fixed integer overflow vulnerability (CVE-2004-0599) in png_read_png().
   Fixed some harmless bugs in png_handle_sBIT, etc, that would cause
     duplicate chunk types to go undetected.
   Fixed some timestamps in the -config version
@@ -1517,7 +1527,7 @@ Version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004]
 
 Version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004]
   Moved  "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED
-     section of png.h where they were inadvertently placed in version rc3.
+    section of png.h where they were inadvertently placed in version rc3.
 
 Version 1.2.6 and 1.0.16 [August 15, 2004]
   Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1.
@@ -2126,7 +2136,7 @@ Version 1.4.0beta24 [July 25, 2008]
     png_decompress_chunk(), and remove "chunkdata" from parameter list.
   Put a call to png_check_chunk_name() in png_read_chunk_header().
   Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte.
-  Removed two calls to png_check_chunk_name() occuring later in the process.
+  Removed two calls to png_check_chunk_name() occurring later in the process.
   Define PNG_NO_ERROR_NUMBERS by default in pngconf.h
 
 Version 1.4.0beta25 [July 30, 2008]
@@ -2349,7 +2359,7 @@ Version 1.4.0beta63 [June 15, 2009]
 Version 1.4.0beta64 [June 24, 2009]
   Eliminated PNG_LEGACY_SUPPORTED code.
   Moved the various unknown chunk macro definitions outside of the
-     PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks.
+    PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks.
 
 Version 1.4.0beta65 [June 26, 2009]
   Added a reference to the libpng license in each file.
@@ -3771,8 +3781,9 @@ Version 1.5.7beta04 [November 17, 2011]
 
 Version 1.5.7beta05 [November 25, 2011]
   Removed "zTXt" from warning in generic chunk decompression function.
-  Validate time settings passed to pngset() and png_convert_to_rfc1123()
-    (Frank Busse).
+  Validate time settings passed to png_set_tIME() and png_convert_to_rfc1123()
+    (Frank Busse). Note: This prevented CVE-2015-7981 from affecting
+    libpng-1.5.7 and later.
   Added MINGW support to CMakeLists.txt
   Reject invalid compression flag or method when reading the iTXt chunk.
   Backed out 'simplified' API changes. The API seems too complex and there
@@ -3818,12 +3829,13 @@ Version 1.6.0beta01 [December 15, 2011]
     (the other two required headers aren't used).  Non-ANSI systems that don't
     have stddef.h or limits.h will have to provide an appropriate fake
     containing the relevant types and #defines.
-  The use of FAR/far has been eliminated and the definition of png_alloc_size_t
-    is now controlled by a flag so that 'small size_t' systems can select it
-    if necessary.  Libpng 1.6 may not currently work on such systems -- it
-    seems likely that it will ask 'malloc' for more than 65535 bytes with any
-    image that has a sufficiently large row size (rather than simply failing
-    to read such images).
+  Dropped support for 16-bit platforms. The use of FAR/far has been eliminated
+    and the definition of png_alloc_size_t is now controlled by a flag so
+    that 'small size_t' systems can select it if necessary.  Libpng 1.6 may
+    not currently work on such systems -- it seems likely that it will
+    ask 'malloc' for more than 65535 bytes with any image that has a
+    sufficiently large row size (rather than simply failing to read such
+    images).
   New tools directory containing tools used to generate libpng code.
   Fixed race conditions in parallel make builds. With higher degrees of
     parallelism during 'make' the use of the same temporary file names such
@@ -4435,7 +4447,7 @@ Version 1.6.1beta02 [February 19, 2013]
 
 Version 1.6.1beta03 [February 22, 2013]
   Fixed ALIGNED_MEMORY support.
-  Allow run-time ARM NEON checking to be disabled. A new configure option:
+  Added a new configure option:
     --enable-arm-neon=always will stop the run-time checks. New checks
     within arm/arm_init.c will cause the code not to be compiled unless
     __ARM_NEON__ is set. This should make it fail safe (if someone asks
@@ -4454,10 +4466,10 @@ Version 1.6.1beta05 [March 1, 2013]
 Version 1.6.1beta06 [March 4, 2013]
   Better documentation of unknown handling API interactions.
   Corrected Android builds and corrected libpng.vers with symbol
-    prefixing. This adds an API to set optimization options externally,
+    prefixing.  It also makes those tests compile and link on Android.
+  Added an API png_set_option() to set optimization options externally,
     providing an alternative and general solution for the non-portable
-    run-time tests used by the ARM Neon code.  It also makes those tests
-    compile and link on Android.
+    run-time tests used by the ARM Neon code, using the PNG_ARM_NEON option.
   The order of settings vs options in pnglibconf.h is reversed to allow
     settings to depend on options and options can now set (or override) the
     defaults for settings.
@@ -4549,13 +4561,14 @@ Version 1.6.3beta03 [April 30, 2013]
   Expanded manual paragraph about writing private chunks, particularly
     the need to call png_set_keep_unknown_chunks() when writing them.
   Avoid dereferencing NULL pointer possibly returned from
-     png_create_write_struct() (Andrew Church).
+    png_create_write_struct() (Andrew Church).
 
 Version 1.6.3beta05 [May 9, 2013]
   Calculate our own zlib windowBits when decoding rather than trusting the
     CMF bytes in the PNG datastream.
   Added an option to force maximum window size for inflating, which was
-    the behavior of libpng15 and earlier.
+    the behavior of libpng15 and earlier, via a new PNG_MAXIMUM_INFLATE_WINDOW
+    option for png_set_options().
   Added png-fix-itxt and png-fix-too-far-back to the built programs and
     removed warnings from the source code and timepng that are revealed as
     a result.
@@ -5138,17 +5151,326 @@ Version 1.6.16beta03 [December 21, 2014]
 
 Version 1.6.16rc01 [December 21, 2014]
   Restored a test on width that was removed from png.c at libpng-1.6.9
-    (Bug report by Alex Eubanks).
+    (Bug report by Alex Eubanks, CVE-2015-0973).
 
 Version 1.6.16rc02 [December 21, 2014]
   Undid the update to pngrutil.c in 1.6.16rc01.
 
 Version 1.6.16rc03 [December 21, 2014]
-  Fixed an overflow in png_combine_row with very wide interlaced images.
+  Fixed an overflow in png_combine_row() with very wide interlaced images
+    (Bug report and fix by John Bowler, CVE-2014-9495).
 
 Version 1.6.16 [December 22, 2014]
   No changes.
 
+Version 1.6.17beta01 [January 29, 2015]
+  Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h
+  Corrected the width limit calculation in png_check_IHDR().
+  Removed user limits from pngfix. Also pass NULL pointers to
+    png_read_row to skip the unnecessary row de-interlace stuff.
+  Added testing of png_set_packing() to pngvalid.c
+  Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
+  Implement previously untested cases of libpng transforms in pngvalid.c
+  Fixed byte order in png_do_read_filler() with 16-bit input. Previously
+    the high and low bytes of the filler, from png_set_filler() or from
+    png_set_add_alpha(), were read in the wrong order.
+  Made the check for out-of-range values in png_set_tRNS() detect
+    values that are exactly 2^bit_depth, and work on 16-bit platforms.
+  Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
+  Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
+    pngset.c to avoid warnings about dead code.
+  Added "& 0xff" to many instances of expressions that are typecast
+    to (png_byte), to avoid Coverity warnings.
+
+Version 1.6.17beta02 [February 7, 2015]
+  Work around one more Coverity-scan dead-code warning.
+  Do not build png_product2() when it is unused.
+
+Version 1.6.17beta03 [February 17, 2015]
+  Display user limits in the output from pngtest.
+  Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column
+    and 1-million-row default limits in pnglibconf.dfa, that can be reset
+    by the user at build time or run time.  This provides a more robust
+    defense against DOS and as-yet undiscovered overflows.
+
+Version 1.6.17beta04 [February 21, 2015]
+  Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default.
+  Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins).
+  Rebuilt configure scripts with automake-1.15 and libtool-2.4.6
+
+Version 1.6.17beta05 [February 25, 2015]
+  Restored compiling of png_reciprocal2 with PNG_NO_16BIT.
+
+Version 1.6.17beta06 [February 27, 2015]
+  Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block
+    of png.h.
+  Avoid runtime checks when converting integer to png_byte with
+    Visual Studio (Sergey Kosarevsky)
+
+Version 1.6.17rc01 [March 4, 2015]
+  No changes.
+
+Version 1.6.17rc02 [March 9, 2015]
+  Removed some comments that the configure script did not handle
+    properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
+  Free the unknown_chunks structure even when it contains no data.
+
+Version 1.6.17rc03 [March 12, 2015]
+  Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
+    for consistency, and remove some useless tests (Alexey Petruchik).
+
+Version 1.6.17rc04 [March 16, 2015]
+  Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of
+    pnglibconf.* in "make clean" (Cosmin).
+  Fix bug in calculation of maxbits, in png_write_sBIT, introduced
+    in libpng-1.6.17beta01 (John Bowler).
+
+Version 1.6.17rc05 [March 21, 2015]
+  Define PNG_FILTER_* and PNG_FILTER_VALUE_* in png.h even when WRITE
+    is not supported (John Bowler).  This fixes an error introduced in
+    libpng-1.6.17beta06.
+  Reverted "& 0xff" additions of version 1.6.17beta01. Libpng passes
+    the Coverity scan without them.
+
+Version 1.6.17rc06 [March 23, 2015]
+  Remove pnglibconf.dfn and pnglibconf.pre with "make clean".
+  Reformatted some "&0xff" instances to "& 0xff".
+  Fixed simplified 8-bit-linear to sRGB alpha. The calculated alpha
+    value was wrong.  It's not clear if this affected the final stored
+    value; in the obvious code path the upper and lower 8-bits of the
+    alpha value were identical and the alpha was truncated to 8-bits
+    rather than dividing by 257 (John Bowler).
+
+Version 1.6.17 [March 26, 2015]
+  No changes.
+
+Version 1.6.18beta01 [April 1, 2015]
+  Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros.  They
+    have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves
+    bug report by Andrew Church).
+  Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c.  This
+    fixes some arithmetic errors that caused some tests to fail on
+    some 32-bit platforms (Bug reports by Peter Breitenlohner [i686]
+    and Petr Gajdos [i586]).
+
+Version 1.6.18beta02 [April 26, 2015]
+  Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
+    (Bug report by Viktor Szakats).
+
+Version 1.6.18beta03 [May 6, 2015]
+  Replaced "unexpected" with an integer (0xabadca11) in pngset.c
+    where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1.
+  Added contrib/examples/simpleover.c, to demonstrate how to handle
+    alpha compositing of multiple images, using the "simplified API"
+    and an example PNG generation tool, contrib/examples/genpng.c
+    (John Bowler).
+
+Version 1.6.18beta04 [May 20, 2015]
+  PNG_RELEASE_BUILD replaces tests where the code depended on the build base
+    type and can be defined on the command line, allowing testing in beta
+    builds (John Bowler).
+  Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds.
+  Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug
+    report from Christopher Ferris).
+
+Version 1.6.18beta05 [May 31, 2015]
+  Backport filter selection code from libpng-1.7.0beta51, to combine
+    sub_row, up_row, avg_row, and paeth_row into try_row and tst_row.
+  Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c
+    to avoid confusion with the libpng private macros.
+  Fixed old cut&paste bug in the weighted filter selection code in
+    pngwutil.c, introduced in libpng-0.95, March 1997.
+
+Version 1.6.18beta06 [June 1, 2015]
+  Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the
+    compiled library size. It never worked properly and as far as we can
+    tell, no one uses it. The png_set_filter_heuristics() and
+    png_set_filter_heuristics_fixed() APIs are retained but deprecated
+    and do nothing.
+
+Version 1.6.18beta07 [June 6, 2015]
+  Removed non-working progressive reader 'skip' function. This
+    function has apparently never been used. It was implemented
+    to support back-door modification of png_struct in libpng-1.4.x
+    but (because it does nothing and cannot do anything) was apparently
+    never tested (John Bowler).
+  Fixed cexcept.h in which GCC 5 now reports that one of the auto
+    variables in the Try macro needs to be volatile to prevent value
+    being lost over the setjmp (John Bowler).
+  Fixed NO_WRITE_FILTER and -Wconversion build breaks (John Bowler).
+  Fix g++ build breaks (John Bowler).
+  Quieted some Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,
+    pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
+    would only work with iTXt chunks with length 255 or less.
+  Added #ifdef's to contrib/examples programs so people don't try
+    to compile them without the minimum required support enabled
+    (suggested by Flavio Medeiros).
+
+Version 1.6.18beta08 [June 30, 2015]
+  Eliminated the final two Coverity defects (insecure temporary file
+    handling in contrib/libtests/pngstest.c; possible overflow of
+    unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure"
+    file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will
+    be used.
+  Removed some unused WEIGHTED_FILTER macros from png.h and pngstruct.h
+
+Version 1.6.18beta09 [July 5, 2015]
+  Removed some useless typecasts from contrib/tools/png-fix-itxt.c
+  Fixed a new signed-unsigned comparison in pngrtran.c (Max Stepin).
+  Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*.  To
+    preserve API compatibility, the new defines all default to "extern"
+    (requested by Jan Nijtmans).
+
+Version 1.6.18rc01 [July 9, 2015]
+  Belatedly added Mans Rullgard and James Yu to the list of Contributing
+    Authors.
+
+Version 1.6.18rc02 [July 12, 2015]
+  Restored unused FILTER_HEURISTIC macros removed at libpng-1.6.18beta08
+    to png.h to avoid compatibility warnings.
+
+Version 1.6.18rc03 [July 15, 2015]
+  Minor changes to the man page
+
+Version 1.6.18 [July 23, 2015]
+  No changes.
+
+Version 1.6.19beta01 [July 30, 2015]
+  Updated obsolete information about the simplified API macros in the
+    manual pages (Bug report by Arc Riley).
+  Avoid potentially dereferencing NULL info_ptr in png_info_init_3().
+  Rearranged png.h to put the major sections in the same order as
+    in libpng17.
+  Eliminated unused PNG_COST_SHIFT, PNG_WEIGHT_SHIFT, PNG_COST_FACTOR, and
+    PNG_WEIGHT_FACTOR macros.
+  Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
+    (Bug report by Viktor Szakats).  Several warnings remain and are
+    unavoidable, where we test for overflow.
+  Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c
+  Fixed uninitialized variable in contrib/gregbook/rpng2-x.c
+
+Version 1.6.19beta02 [August 19, 2015]
+  Moved config.h.in~ from the "libpng_autotools_files" list to the
+    "libpng_autotools_extra" list in autogen.sh because it was causing a
+    false positive for missing files (bug report by Robert C. Seacord).
+  Removed unreachable "break" statements in png.c, pngread.c, and pngrtran.c
+    to suppress clang warnings (Bug report by Viktor Szakats).
+  Fixed some bad links in the man page.
+  Changed "n bit" to "n-bit" in comments.
+  Added signed/unsigned 16-bit safety net. This removes the dubious
+    0x8000 flag definitions on 16-bit systems. They aren't supported
+    yet the defs *probably* work, however it seems much safer to do this
+    and be advised if anyone, contrary to advice, is building libpng 1.6
+    on a 16-bit system. It also adds back various switch default clauses
+    for GCC; GCC errors out if they are not present (with an appropriately
+    high level of warnings).
+  Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert
+    Seacord).
+  Fixed the recently reported 1's complement security issue by replacing
+    the value that is illegal in the PNG spec, in both signed and unsigned
+    values, with 0. Illegal unsigned values (anything greater than or equal
+    to  0x80000000) can still pass through, but since these are not illegal
+    in ANSI-C (unlike 0x80000000 in the signed case) the checking that
+    occurs later can catch them (John Bowler).
+
+Version 1.6.19beta03 [September 26, 2015]
+  Fixed png_save_int_32 when int is not 2's complement (John Bowler).
+  Updated libpng16 with all the recent test changes from libpng17,
+    including changes to pngvalid.c to ensure that the original,
+    distributed, version of contrib/visupng/cexcept.h can be used
+    (John Bowler).
+  pngvalid contains the correction to the use of SAVE/STORE_
+    UNKNOWN_CHUNKS; a bug revealed by changes in libpng 1.7. More
+    tests contain the --strict option to detect warnings and the
+    pngvalid-standard test has been corrected so that it does not
+    turn on progressive-read. There is a separate test which does
+    that. (John Bowler)
+  Also made some signed/unsigned fixes.
+  Make pngstest error limits version specific. Splitting the machine
+    generated error structs out to a file allows the values to be updated
+    without changing pngstest.c itself. Since libpng 1.6 and 1.7 have
+    slightly different error limits this simplifies maintenance. The
+    makepngs.sh script has also been updated to more accurately reflect
+    current problems in libpng 1.7 (John Bowler).
+  Incorporated new test PNG files into make check.  tests/pngstest-*
+    are changed so that the new test files are divided into 8 groups by
+    gamma and alpha channel.  These tests have considerably better code
+    and pixel-value coverage than contrib/pngsuite; however,coverage is
+    still incomplete (John Bowler).
+  Removed the '--strict' in 1.6 because of the double-gamma-correction
+    warning, updated pngstest-errors.h for the errors detected with the
+    new contrib/testspngs PNG test files (John Bowler).
+
+Version 1.6.19beta04 [October 15, 2015]
+  Worked around rgb-to-gray issues in libpng 1.6.  The previous
+    attempts to ignore the errors in the code aren't quite enough to
+    deal with the 'channel selection' encoding added to libpng 1.7; abort.
+    pngvalid.c is changed to drop this encoding in prior versions.
+  Fixed 'pow' macros in pngvalid.c. It is legal for 'pow' to be a
+    macro, therefore the argument list cannot contain preprocessing
+    directives.  Make sure pow is a function where this happens. This is
+    a minimal safe fix, the issue only arises in non-performance-critical
+    code (bug report by Curtis Leach, fix by John Bowler).
+  Added sPLT support to pngtest.c
+
+Version 1.6.19rc01 [October 23, 2015]
+  No changes.
+
+Version 1.6.19rc02 [October 31, 2015]
+  Prevent setting or writing over-length PLTE chunk (Cosmin Truta).
+  Silently truncate over-length PLTE chunk while reading.
+  Libpng incorrectly calculated the output rowbytes when the application
+    decreased either the number of channels or the bit depth (or both) in
+    a user transform.  This was safe; libpng overallocated buffer space
+   (potentially by quite a lot; up to 4 times the amount required) but,
+   from 1.5.4 on, resulted in a png_error (John Bowler).
+
+Version 1.6.19rc03 [November 3, 2015]
+  Fixed some inconsequential cut-and-paste typos in png_set_cHRM_XYZ_fixed().
+  Clarified COPYRIGHT information to state explicitly that versions
+    are derived from previous versions.
+  Removed much of the long list of previous versions from png.h and
+    libpng.3.
+
+Version 1.6.19rc04 [November 5, 2015]
+  Fixed new bug with CRC error after reading an over-length palette
+    (bug report by Cosmin Truta) (CVE-2015-8126).
+
+Version 1.6.19 [November 12, 2015]
+  Cleaned up coding style in png_handle_PLTE().
+
+Version 1.6.20beta01 [November 20, 2015]
+  Avoid potential pointer overflow/underflow in png_handle_sPLT() and
+    png_handle_pCAL() (Bug report by John Regehr).
+
+Version 1.6.20beta02 [November 23, 2015]
+  Fixed incorrect implementation of png_set_PLTE() that uses png_ptr
+    not info_ptr, that left png_set_PLTE() open to the CVE-2015-8126
+    vulnerability.
+
+Version 1.6.20beta03 [November 24, 2015]
+  Backported tests from libpng-1.7.0beta69.
+
+Version 1.6.20rc01 [November 26, 2015]
+  Fixed an error in handling of bad zlib CMINFO field in pngfix, found by
+    American Fuzzy Lop, reported by Brian Carpenter.  inflate() doesn't
+    immediately fault a bad CMINFO field; instead a 'too far back' error
+    happens later (at least some times).  pngfix failed to limit CMINFO to
+    the allowed values but then assumed that window_bits was in range,
+    triggering an assert. The bug is mostly harmless; the PNG file cannot
+    be fixed.
+
+Version 1.6.20rc02 [November 29, 2015]
+  In libpng 1.6 zlib initialization was changed to use the window size
+    in the zlib stream, not a fixed value. This causes some invalid images,
+    where CINFO is too large, to display 'correctly' if the rest of the
+    data is valid.  This provides a workaround for zlib versions where the
+    error arises (ones that support the API change to use the window size
+    in the stream).
+
+Version 1.6.20 [December 3, 2015]
+  No changes.
+
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
@@ -5156,3 +5478,4 @@ to subscribe)
 or to glennrp at users.sourceforge.net
 
 Glenn R-P
+#endif
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE
index f912f6a6d9b..82dbe117f6d 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE
@@ -10,21 +10,18 @@ this sentence.
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are
-Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
-distributed according to the same disclaimer and license as libpng-1.2.5
-with the following individual added to the list of Contributing Authors
-
-   Cosmin Truta
-
-libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
-Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
-distributed according to the same disclaimer and license as libpng-1.0.6
-with the following individuals added to the list of Contributing Authors
+libpng versions 1.0.7, July 1, 2000, through 1.6.20, December 3, 2015, are
+Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
+derived from libpng-1.0.6, and are distributed according to the same
+disclaimer and license as libpng-1.0.6 with the following individuals
+added to the list of Contributing Authors:
 
    Simon-Pierre Cadieux
    Eric S. Raymond
+   Mans Rullgard
+   Cosmin Truta
    Gilles Vollant
+   James Yu
 
 and with the following additions to the disclaimer:
 
@@ -36,18 +33,20 @@ and with the following additions to the disclaimer:
    the user.
 
 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
-Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
-distributed according to the same disclaimer and license as libpng-0.96,
-with the following individuals added to the list of Contributing Authors:
+Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
+libpng-0.96, and are distributed according to the same disclaimer and
+license as libpng-0.96, with the following individuals added to the list
+of Contributing Authors:
 
    Tom Lane
    Glenn Randers-Pehrson
    Willem van Schaik
 
 libpng versions 0.89, June 1996, through 0.96, May 1997, are
-Copyright (c) 1996, 1997 Andreas Dilger
-Distributed according to the same disclaimer and license as libpng-0.88,
-with the following individuals added to the list of Contributing Authors:
+Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
+and are distributed according to the same disclaimer and license as
+libpng-0.88, with the following individuals added to the list of
+Contributing Authors:
 
    John Bowler
    Kevin Bracey
@@ -57,7 +56,7 @@ with the following individuals added to the list of Contributing Authors:
    Tom Tanner
 
 libpng versions 0.5, May 1995, through 0.88, January 1996, are
-Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
+Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
@@ -80,13 +79,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
 source code, or portions hereof, for any purpose, without fee, subject
 to the following restrictions:
 
-1. The origin of this source code must not be misrepresented.
+  1. The origin of this source code must not be misrepresented.
 
-2. Altered versions must be plainly marked as such and must not
-   be misrepresented as being the original source.
+  2. Altered versions must be plainly marked as such and must not
+     be misrepresented as being the original source.
 
-3. This Copyright notice may not be removed or altered from any
-   source or altered source distribution.
+  3. This Copyright notice may not be removed or altered from any
+     source or altered source distribution.
 
 The Contributing Authors and Group 42, Inc. specifically permit, without
 fee, and encourage the use of this source code as a component to
@@ -94,18 +93,20 @@ supporting the PNG file format in commercial products.  If you use this
 source code in a product, acknowledgment is not required but would be
 appreciated.
 
+END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
 
 A "png_get_copyright" function is available, for convenient use in "about"
 boxes and the like:
 
-   printf("%s",png_get_copyright(NULL));
+   printf("%s", png_get_copyright(NULL));
 
 Also, the PNG logo (in PNG format, of course) is supplied in the
 files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
 
-Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is a
-certification mark of the Open Source Initiative.
+Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
+a certification mark of the Open Source Initiative. OSI has not addressed
+the additional disclaimers inserted at version 1.0.7.
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-December 22, 2014
+December 3, 2015
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/README b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/README
index 8c5b0b2f153..59f1f918ae2 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/README
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/README
@@ -1,4 +1,4 @@
-README for libpng version 1.6.16 - December 22, 2014 (shared library 16.0)
+README for libpng version 1.6.20 - December 3, 2015 (shared library 16.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -134,7 +134,7 @@ and ...".  If in doubt, send questions to me.  I'll bounce them
 to others, if necessary.
 
 Please do not send suggestions on how to change PNG.  We have
-been discussing PNG for nineteen years now, and it is official and
+been discussing PNG for twenty years now, and it is official and
 finished.  If you have suggestions for libpng, however, I'll
 gladly listen.  Even if your suggestion is not used immediately,
 it may be used later.
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.c
index d7682a1c4fd..38aa05942c9 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.16 [December 22, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.19 [November 12, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -42,7 +42,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_16 Your_png_h_is_not_version_1_6_16;
+typedef png_libpng_version_1_6_20 Your_png_h_is_not_version_1_6_20;
 
 /* Tells libpng that we have already handled the first "num_bytes" bytes
  * of the PNG file signature.  If the PNG data is embedded into another
@@ -54,15 +54,20 @@ typedef png_libpng_version_1_6_16 Your_png_h_is_not_version_1_6_16;
 void PNGAPI
 png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
 {
+   unsigned int nb = (unsigned int)num_bytes;
+
    png_debug(1, "in png_set_sig_bytes");
 
    if (png_ptr == NULL)
       return;
 
-   if (num_bytes > 8)
+   if (num_bytes < 0)
+      nb = 0;
+
+   if (nb > 8)
       png_error(png_ptr, "Too many bytes for PNG signature");
 
-   png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
+   png_ptr->sig_bytes = (png_byte)nb;
 }
 
 /* Checks whether the supplied bytes match the PNG signature.  We allow
@@ -129,7 +134,7 @@ png_zfree(voidpf png_ptr, voidpf ptr)
 void /* PRIVATE */
 png_reset_crc(png_structrp png_ptr)
 {
-   /* The cast is safe because the crc is a 32 bit value. */
+   /* The cast is safe because the crc is a 32-bit value. */
    png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);
 }
 
@@ -157,7 +162,7 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
    }
 
    /* 'uLong' is defined in zlib.h as unsigned long; this means that on some
-    * systems it is a 64 bit value.  crc32, however, returns 32 bits so the
+    * systems it is a 64-bit value.  crc32, however, returns 32 bits so the
     * following cast is safe.  'uInt' may be no more than 16 bits, so it is
     * necessary to perform a loop here.
     */
@@ -168,8 +173,10 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
       do
       {
          uInt safe_length = (uInt)length;
+#ifndef __COVERITY__
          if (safe_length == 0)
             safe_length = (uInt)-1; /* evil, but safe */
+#endif
 
          crc = crc32(crc, ptr, safe_length);
 
@@ -269,15 +276,15 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
       create_struct.user_height_max = PNG_USER_HEIGHT_MAX;
 
 #     ifdef PNG_USER_CHUNK_CACHE_MAX
-         /* Added at libpng-1.2.43 and 1.4.0 */
-         create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
+      /* Added at libpng-1.2.43 and 1.4.0 */
+      create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
 #     endif
 
 #     ifdef PNG_USER_CHUNK_MALLOC_MAX
-         /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists
-          * in png_struct regardless.
-          */
-         create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
+      /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists
+       * in png_struct regardless.
+       */
+      create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
 #     endif
 #  endif
 
@@ -301,7 +308,9 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
 
 #  ifdef PNG_SETJMP_SUPPORTED
       if (!setjmp(create_jmp_buf))
+#  endif
       {
+#  ifdef PNG_SETJMP_SUPPORTED
          /* Temporarily fake out the longjmp information until we have
           * successfully completed this function.  This only works if we have
           * setjmp() support compiled in, but it is safe - this stuff should
@@ -310,8 +319,6 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
          create_struct.jmp_buf_ptr = &create_jmp_buf;
          create_struct.jmp_buf_size = 0; /*stack allocation*/
          create_struct.longjmp_fn = longjmp;
-#  else
-      {
 #  endif
          /* Call the general version checker (shared with read and write code):
           */
@@ -330,10 +337,10 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
                create_struct.zstream.opaque = png_ptr;
 
 #              ifdef PNG_SETJMP_SUPPORTED
-                  /* Eliminate the local error handling: */
-                  create_struct.jmp_buf_ptr = NULL;
-                  create_struct.jmp_buf_size = 0;
-                  create_struct.longjmp_fn = 0;
+               /* Eliminate the local error handling: */
+               create_struct.jmp_buf_ptr = NULL;
+               create_struct.jmp_buf_size = 0;
+               create_struct.longjmp_fn = 0;
 #              endif
 
                *png_ptr = create_struct;
@@ -439,6 +446,8 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),
       free(info_ptr);
       info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
          (sizeof *info_ptr)));
+      if (info_ptr == NULL)
+         return;
       *ptr_ptr = info_ptr;
    }
 
@@ -504,9 +513,10 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
    /* Free any tRNS entry */
    if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0)
    {
+      info_ptr->valid &= ~PNG_INFO_tRNS;
       png_free(png_ptr, info_ptr->trans_alpha);
       info_ptr->trans_alpha = NULL;
-      info_ptr->valid &= ~PNG_INFO_tRNS;
+      info_ptr->num_trans = 0;
    }
 #endif
 
@@ -572,20 +582,17 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
 
       else
       {
-         if (info_ptr->splt_palettes_num != 0)
+         int i;
+
+         for (i = 0; i < info_ptr->splt_palettes_num; i++)
          {
-            int i;
-
-            for (i = 0; i < info_ptr->splt_palettes_num; i++)
-            {
-               png_free(png_ptr, info_ptr->splt_palettes[i].name);
-               png_free(png_ptr, info_ptr->splt_palettes[i].entries);
-            }
-
-            png_free(png_ptr, info_ptr->splt_palettes);
-            info_ptr->splt_palettes = NULL;
-            info_ptr->splt_palettes_num = 0;
+            png_free(png_ptr, info_ptr->splt_palettes[i].name);
+            png_free(png_ptr, info_ptr->splt_palettes[i].entries);
          }
+
+         png_free(png_ptr, info_ptr->splt_palettes);
+         info_ptr->splt_palettes = NULL;
+         info_ptr->splt_palettes_num = 0;
          info_ptr->valid &= ~PNG_INFO_sPLT;
       }
    }
@@ -605,15 +612,12 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
       {
          int i;
 
-         if (info_ptr->unknown_chunks_num != 0)
-         {
-            for (i = 0; i < info_ptr->unknown_chunks_num; i++)
-               png_free(png_ptr, info_ptr->unknown_chunks[i].data);
+         for (i = 0; i < info_ptr->unknown_chunks_num; i++)
+            png_free(png_ptr, info_ptr->unknown_chunks[i].data);
 
-            png_free(png_ptr, info_ptr->unknown_chunks);
-            info_ptr->unknown_chunks = NULL;
-            info_ptr->unknown_chunks_num = 0;
-         }
+         png_free(png_ptr, info_ptr->unknown_chunks);
+         info_ptr->unknown_chunks = NULL;
+         info_ptr->unknown_chunks_num = 0;
       }
    }
 #endif
@@ -694,22 +698,23 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
 }
 #  endif
 
-#ifdef PNG_SAVE_INT_32_SUPPORTED
-/* The png_save_int_32 function assumes integers are stored in two's
- * complement format.  If this isn't the case, then this routine needs to
- * be modified to write data in two's complement format.  Note that,
- * the following works correctly even if png_int_32 has more than 32 bits
- * (compare the more complex code required on read for sign extension.)
+#  ifdef PNG_SAVE_INT_32_SUPPORTED
+/* PNG signed integers are saved in 32-bit 2's complement format.  ANSI C-90
+ * defines a cast of a signed integer to an unsigned integer either to preserve
+ * the value, if it is positive, or to calculate:
+ *
+ *     (UNSIGNED_MAX+1) + integer
+ *
+ * Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
+ * negative integral value is added the result will be an unsigned value
+ * correspnding to the 2's complement representation.
  */
 void PNGAPI
 png_save_int_32(png_bytep buf, png_int_32 i)
 {
-   buf[0] = (png_byte)((i >> 24) & 0xff);
-   buf[1] = (png_byte)((i >> 16) & 0xff);
-   buf[2] = (png_byte)((i >> 8) & 0xff);
-   buf[3] = (png_byte)(i & 0xff);
+   png_save_uint_32(buf, i);
 }
-#endif
+#  endif
 
 #  ifdef PNG_TIME_RFC1123_SUPPORTED
 /* Convert the supplied time into an RFC 1123 string suitable for use in
@@ -753,6 +758,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
       APPEND(':');
       APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);
       APPEND_STRING(" +0000"); /* This reliably terminates the buffer */
+      PNG_UNUSED (pos)
 
 #     undef APPEND
 #     undef APPEND_NUMBER
@@ -762,7 +768,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
    return 1;
 }
 
-#     if PNG_LIBPNG_VER < 10700
+#    if PNG_LIBPNG_VER < 10700
 /* To do: remove the following from libpng-1.7 */
 /* Original API that uses a private buffer in png_struct.
  * Deprecated because it causes png_struct to carry a spurious temporary
@@ -783,7 +789,7 @@ png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)
 
    return NULL;
 }
-#     endif
+#    endif /* LIBPNG_VER < 10700 */
 #  endif /* TIME_RFC1123 */
 
 #endif /* READ || WRITE */
@@ -797,14 +803,14 @@ png_get_copyright(png_const_structrp png_ptr)
 #else
 #  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-     "libpng version 1.6.16 - December 22, 2014" PNG_STRING_NEWLINE \
-     "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
-     "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
-     "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
-     PNG_STRING_NEWLINE;
+      "libpng version 1.6.20 - December 3, 2015" PNG_STRING_NEWLINE \
+      "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
+      "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
+      "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
+      PNG_STRING_NEWLINE;
 #  else
-      return "libpng version 1.6.16 - December 22, 2014\
-      Copyright (c) 1998-2014 Glenn Randers-Pehrson\
+   return "libpng version 1.6.20 - December 3, 2015\
+      Copyright (c) 1998-2015 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
 #  endif
@@ -842,9 +848,9 @@ png_get_header_version(png_const_structrp png_ptr)
 #ifdef __STDC__
    return PNG_HEADER_VERSION_STRING
 #  ifndef PNG_READ_SUPPORTED
-   "     (NO READ SUPPORT)"
+      " (NO READ SUPPORT)"
 #  endif
-   PNG_STRING_NEWLINE;
+      PNG_STRING_NEWLINE;
 #else
    return PNG_HEADER_VERSION_STRING;
 #endif
@@ -900,9 +906,9 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
 
    for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
    {
-      palette[i].red = (png_byte)v;
-      palette[i].green = (png_byte)v;
-      palette[i].blue = (png_byte)v;
+      palette[i].red = (png_byte)(v & 0xff);
+      palette[i].green = (png_byte)(v & 0xff);
+      palette[i].blue = (png_byte)(v & 0xff);
    }
 }
 #endif
@@ -975,8 +981,6 @@ png_access_version_number(void)
    return((png_uint_32)PNG_LIBPNG_VER);
 }
 
-
-
 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
 /* Ensure that png_ptr->zstream.msg holds some appropriate error message string.
  * If it doesn't 'ret' is used to set it to something appropriate, even in cases
@@ -1119,10 +1123,10 @@ png_colorspace_set_gamma(png_const_structrp png_ptr,
       errmsg = "gamma value out of range";
 
 #  ifdef PNG_READ_gAMA_SUPPORTED
-      /* Allow the application to set the gamma value more than once */
-      else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
-         (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0)
-         errmsg = "duplicate";
+   /* Allow the application to set the gamma value more than once */
+   else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
+      (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0)
+      errmsg = "duplicate";
 #  endif
 
    /* Do nothing if the colorspace is already invalid */
@@ -1163,31 +1167,31 @@ png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
          PNG_INFO_iCCP);
 
 #     ifdef PNG_COLORSPACE_SUPPORTED
-         /* Clean up the iCCP profile now if it won't be used. */
-         png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/);
+      /* Clean up the iCCP profile now if it won't be used. */
+      png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/);
 #     else
-         PNG_UNUSED(png_ptr)
+      PNG_UNUSED(png_ptr)
 #     endif
    }
 
    else
    {
 #     ifdef PNG_COLORSPACE_SUPPORTED
-         /* Leave the INFO_iCCP flag set if the pngset.c code has already set
-          * it; this allows a PNG to contain a profile which matches sRGB and
-          * yet still have that profile retrievable by the application.
-          */
-         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0)
-            info_ptr->valid |= PNG_INFO_sRGB;
+      /* Leave the INFO_iCCP flag set if the pngset.c code has already set
+       * it; this allows a PNG to contain a profile which matches sRGB and
+       * yet still have that profile retrievable by the application.
+       */
+      if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0)
+         info_ptr->valid |= PNG_INFO_sRGB;
 
-         else
-            info_ptr->valid &= ~PNG_INFO_sRGB;
+      else
+         info_ptr->valid &= ~PNG_INFO_sRGB;
 
-         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
-            info_ptr->valid |= PNG_INFO_cHRM;
+      if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
+         info_ptr->valid |= PNG_INFO_cHRM;
 
-         else
-            info_ptr->valid &= ~PNG_INFO_cHRM;
+      else
+         info_ptr->valid &= ~PNG_INFO_cHRM;
 #     endif
 
       if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0)
@@ -1209,7 +1213,7 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
    png_colorspace_sync_info(png_ptr, info_ptr);
 }
 #endif
-#endif
+#endif /* GAMMA */
 
 #ifdef PNG_COLORSPACE_SUPPORTED
 /* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
@@ -1268,16 +1272,17 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
 
    /* Check xy and, implicitly, z.  Note that wide gamut color spaces typically
     * have end points with 0 tristimulus values (these are impossible end
-    * points, but they are used to cover the possible colors.)
+    * points, but they are used to cover the possible colors).  We check
+    * xy->whitey against 5, not 0, to avoid a possible integer overflow.
     */
-   if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1;
-   if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
+   if (xy->redx   < 0 || xy->redx > PNG_FP_1) return 1;
+   if (xy->redy   < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
    if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1;
    if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1;
-   if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;
-   if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;
+   if (xy->bluex  < 0 || xy->bluex > PNG_FP_1) return 1;
+   if (xy->bluey  < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;
    if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1;
-   if (xy->whitey < 0 || xy->whitey > PNG_FP_1-xy->whitex) return 1;
+   if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1;
 
    /* The reverse calculation is more difficult because the original tristimulus
     * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
@@ -1735,7 +1740,6 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr,
           */
          colorspace->flags |= PNG_COLORSPACE_INVALID;
          png_error(png_ptr, "internal error checking chromaticities");
-         break;
    }
 
    return 0; /* failed */
@@ -1763,7 +1767,6 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr,
       default:
          colorspace->flags |= PNG_COLORSPACE_INVALID;
          png_error(png_ptr, "internal error checking chromaticities");
-         break;
    }
 
    return 0; /* failed */
@@ -2089,8 +2092,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
    temp = png_get_uint_32(profile+12); /* profile/device class */
    switch (temp)
    {
-      case 0x73636E72: /* 'scnr' */
-      case 0x6D6E7472: /* 'mntr' */
+      case 0x73636e72: /* 'scnr' */
+      case 0x6d6e7472: /* 'mntr' */
       case 0x70727472: /* 'prtr' */
       case 0x73706163: /* 'spac' */
          /* All supported */
@@ -2101,7 +2104,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
          return png_icc_profile_error(png_ptr, colorspace, name, temp,
             "invalid embedded Abstract ICC profile");
 
-      case 0x6C696E6B: /* 'link' */
+      case 0x6c696e6b: /* 'link' */
          /* DeviceLink profiles cannot be interpreted in a non-device specific
           * fashion, if an app uses the AToB0Tag in the profile the results are
           * undefined unless the result is sent to the intended device,
@@ -2111,7 +2114,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
          return png_icc_profile_error(png_ptr, colorspace, name, temp,
             "unexpected DeviceLink ICC profile class");
 
-      case 0x6E6D636C: /* 'nmcl' */
+      case 0x6e6d636c: /* 'nmcl' */
          /* A NamedColor profile is also device specific, however it doesn't
           * contain an AToB0 tag that is open to misinterpretation.  Almost
           * certainly it will fail the tests below.
@@ -2137,8 +2140,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
    temp = png_get_uint_32(profile+20);
    switch (temp)
    {
-      case 0x58595A20: /* 'XYZ ' */
-      case 0x4C616220: /* 'Lab ' */
+      case 0x58595a20: /* 'XYZ ' */
+      case 0x4c616220: /* 'Lab ' */
          break;
 
       default:
@@ -2194,7 +2197,8 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
    return 1; /* success, maybe with warnings */
 }
 
-#if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
+#ifdef PNG_sRGB_SUPPORTED
+#if PNG_sRGB_PROFILE_CHECKS >= 0
 /* Information about the known ICC sRGB profiles */
 static const struct
 {
@@ -2307,8 +2311,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
          }
 
          /* Length *and* intent must match */
-         if (length == png_sRGB_checks[i].length &&
-            intent == png_sRGB_checks[i].intent)
+         if (length == (png_uint_32) png_sRGB_checks[i].length &&
+            intent == (png_uint_32) png_sRGB_checks[i].intent)
          {
             /* Now calculate the adler32 if not done already. */
             if (adler == 0)
@@ -2352,8 +2356,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
                    */
                   else if (png_sRGB_checks[i].have_md5 == 0)
                   {
-                     png_chunk_report(png_ptr, "out-of-date sRGB profile with"
-                        " no signature",
+                     png_chunk_report(png_ptr,
+                        "out-of-date sRGB profile with no signature",
                         PNG_CHUNK_WARNING);
                   }
 
@@ -2366,8 +2370,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
           * way.  This probably indicates a data error or uninformed hacking.
           * Fall through to "no match".
           */
-         png_chunk_report(png_ptr, "Not recognizing known sRGB profile that"
-             " has been edited",
+         png_chunk_report(png_ptr,
+             "Not recognizing known sRGB profile that has been edited",
              PNG_CHUNK_WARNING);
          break;
 # endif
@@ -2377,9 +2381,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
 
    return 0; /* no match */
 }
-#endif
+#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
 
-#ifdef PNG_sRGB_SUPPORTED
 void /* PRIVATE */
 png_icc_set_sRGB(png_const_structrp png_ptr,
    png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
@@ -2393,7 +2396,7 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
       (void)png_colorspace_set_sRGB(png_ptr, colorspace,
          (int)/*already checked*/png_get_uint_32(profile+64));
 }
-#endif /* READ_sRGB */
+#endif /* sRGB */
 
 int /* PRIVATE */
 png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
@@ -2485,7 +2488,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
          png_error(png_ptr, "internal error handling cHRM->XYZ");
    }
 }
-#endif
+#endif /* READ_RGB_TO_GRAY */
 
 #endif /* COLORSPACE */
 
@@ -2514,18 +2517,19 @@ png_check_IHDR(png_const_structrp png_ptr,
       png_warning(png_ptr, "Image width is zero in IHDR");
       error = 1;
    }
-   else if (width > PNG_UINT_31_MAX)
+
+   if (width > PNG_UINT_31_MAX)
    {
       png_warning(png_ptr, "Invalid image width in IHDR");
       error = 1;
    }
 
-   else if (png_gt(width,
-                   (PNG_SIZE_MAX >> 3) /* 8-byte RGBA pixels */
-                   - 48                /* big_row_buf hack */
-                   - 1                 /* filter byte */
-                   - 7*8               /* rounding width to multiple of 8 pix */
-                   - 8))               /* extra max_pixel_depth pad */
+   if (png_gt(((width + 7) & (~7)),
+       ((PNG_SIZE_MAX
+           - 48        /* big_row_buf hack */
+           - 1)        /* filter byte */
+           / 8)        /* 8-byte RGBA pixels */
+           - 1))       /* extra max_pixel_depth pad */
    {
       /* The size of the row must be within the limits of this architecture.
        * Because the read code can perform arbitrary transformations the
@@ -2541,17 +2545,15 @@ png_check_IHDR(png_const_structrp png_ptr,
       png_warning(png_ptr, "Image width is too large for this architecture");
       error = 1;
    }
-   else
+
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   if (width > png_ptr->user_width_max)
+#else
+   if (width > PNG_USER_WIDTH_MAX)
+#endif
    {
-#     ifdef PNG_SET_USER_LIMITS_SUPPORTED
-      if (width > png_ptr->user_width_max)
-#     else
-      if (width > PNG_USER_WIDTH_MAX)
-#     endif
-      {
-         png_warning(png_ptr, "Image width exceeds user limit in IHDR");
-         error = 1;
-      }
+      png_warning(png_ptr, "Image width exceeds user limit in IHDR");
+      error = 1;
    }
 
    if (height == 0)
@@ -2559,22 +2561,21 @@ png_check_IHDR(png_const_structrp png_ptr,
       png_warning(png_ptr, "Image height is zero in IHDR");
       error = 1;
    }
-   else if (height > PNG_UINT_31_MAX)
+
+   if (height > PNG_UINT_31_MAX)
    {
       png_warning(png_ptr, "Invalid image height in IHDR");
       error = 1;
    }
-   else
+
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   if (height > png_ptr->user_height_max)
+#else
+   if (height > PNG_USER_HEIGHT_MAX)
+#endif
    {
-#     ifdef PNG_SET_USER_LIMITS_SUPPORTED
-      if (height > png_ptr->user_height_max)
-#     else
-      if (height > PNG_USER_HEIGHT_MAX)
-#     endif
-      {
-         png_warning(png_ptr, "Image height exceeds user limit in IHDR");
-         error = 1;
-      }
+      png_warning(png_ptr, "Image height exceeds user limit in IHDR");
+      error = 1;
    }
 
    /* Check other values */
@@ -2613,7 +2614,7 @@ png_check_IHDR(png_const_structrp png_ptr,
       error = 1;
    }
 
-#  ifdef PNG_MNG_FEATURES_SUPPORTED
+#ifdef PNG_MNG_FEATURES_SUPPORTED
    /* Accept filter_method 64 (intrapixel differencing) only if
     * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
     * 2. Libpng did not read a PNG signature (this filter_method is only
@@ -2646,13 +2647,13 @@ png_check_IHDR(png_const_structrp png_ptr,
       }
    }
 
-#  else
+#else
    if (filter_type != PNG_FILTER_TYPE_BASE)
    {
       png_warning(png_ptr, "Unknown filter method in IHDR");
       error = 1;
    }
-#  endif
+#endif
 
    if (error == 1)
       png_error(png_ptr, "Invalid IHDR data");
@@ -2878,7 +2879,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
 
       if (fp >= DBL_MIN && fp <= DBL_MAX)
       {
-         int exp_b10;       /* A base 10 exponent */
+         int exp_b10;   /* A base 10 exponent */
          double base;   /* 10^exp_b10 */
 
          /* First extract a base 10 exponent of the number,
@@ -2926,7 +2927,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
           */
 
          {
-            int czero, clead, cdigits;
+            unsigned int czero, clead, cdigits;
             char exponent[10];
 
             /* Allow up to two leading zeros - this will not lengthen
@@ -2956,7 +2957,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
                 * of the loop don't break the number into parts so
                 * that the final digit is rounded.
                 */
-               if (cdigits+czero-clead+1 < (int)precision)
+               if (cdigits+czero+1 < precision+clead)
                   fp = modf(fp, &d);
 
                else
@@ -3062,14 +3063,14 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
                   *ascii++ = (char)(48 + (int)d), ++cdigits;
                }
             }
-            while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);
+            while (cdigits+czero < precision+clead && fp > DBL_MIN);
 
             /* The total output count (max) is now 4+precision */
 
             /* Check for an exponent, if we don't need one we are
              * done and just need to terminate the string.  At
              * this point exp_b10==(-1) is effectively if flag - it got
-             * to '-1' because of the decrement after outputing
+             * to '-1' because of the decrement after outputting
              * the decimal point above (the exponent required is
              * *not* -1!)
              */
@@ -3077,7 +3078,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
             {
                /* The following only happens if we didn't output the
                 * leading zeros above for negative exponent, so this
-                * doest add to the digit requirement.  Note that the
+                * doesn't add to the digit requirement.  Note that the
                 * two zeros here can only be output if the two leading
                 * zeros were *not* output, so this doesn't increase
                 * the output count.
@@ -3130,7 +3131,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
             /* Need another size check here for the exponent digits, so
              * this need not be considered above.
              */
-            if ((int)size > cdigits)
+            if (size > cdigits)
             {
                while (cdigits > 0) *ascii++ = exponent[--cdigits];
 
@@ -3178,7 +3179,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
 
       /* Avoid overflow here on the minimum integer. */
       if (fp < 0)
-         *ascii++ = 45, --size, num = -fp;
+         *ascii++ = 45, num = -fp;
       else
          num = fp;
 
@@ -3234,7 +3235,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
    png_error(png_ptr, "ASCII conversion buffer too small");
 }
 #   endif /* FIXED_POINT */
-#endif /* READ_SCAL */
+#endif /* SCAL */
 
 #if defined(PNG_FLOATING_POINT_SUPPORTED) && \
    !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
@@ -3252,7 +3253,7 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
       png_fixed_error(png_ptr, text);
 
 #  ifndef PNG_ERROR_TEXT_SUPPORTED
-      PNG_UNUSED(text)
+   PNG_UNUSED(text)
 #  endif
 
    return (png_fixed_point)r;
@@ -3433,29 +3434,29 @@ png_gamma_significant(png_fixed_point gamma_val)
 #endif
 
 #ifdef PNG_READ_GAMMA_SUPPORTED
-#if defined(PNG_16BIT_SUPPORTED) || !defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
+#ifdef PNG_16BIT_SUPPORTED
 /* A local convenience routine. */
 static png_fixed_point
 png_product2(png_fixed_point a, png_fixed_point b)
 {
    /* The required result is 1/a * 1/b; the following preserves accuracy. */
-#    ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
+#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
    double r = a * 1E-5;
    r *= b;
    r = floor(r+.5);
 
    if (r <= 2147483647. && r >= -2147483648.)
       return (png_fixed_point)r;
-#    else
+#else
    png_fixed_point res;
 
    if (png_muldiv(&res, a, b, 100000) != 0)
       return res;
-#    endif
+#endif
 
    return 0; /* overflow */
 }
-#endif /* 16BIT || !FLOATING_ARITHMETIC */
+#endif /* 16BIT */
 
 /* The inverse of the above. */
 png_fixed_point
@@ -3463,12 +3464,15 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
 {
    /* The required result is 1/a * 1/b; the following preserves accuracy. */
 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
-   double r = 1E15/a;
-   r /= b;
-   r = floor(r+.5);
+   if (a != 0 && b != 0)
+   {
+      double r = 1E15/a;
+      r /= b;
+      r = floor(r+.5);
 
-   if (r <= 2147483647. && r >= -2147483648.)
-      return (png_fixed_point)r;
+      if (r <= 2147483647. && r >= -2147483648.)
+         return (png_fixed_point)r;
+   }
 #else
    /* This may overflow because the range of png_fixed_point isn't symmetric,
     * but this API is only used for the product of file and screen gamma so it
@@ -3706,7 +3710,7 @@ png_exp(png_fixed_point x)
    if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */
    {
       /* Obtain a 4-bit approximation */
-      png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf];
+      png_uint_32 e = png_32bit_exp[(x >> 12) & 0x0f];
 
       /* Incorporate the low 12 bits - these decrease the returned value by
        * multiplying by a number less than 1 if the bit is set.  The multiplier
@@ -3759,7 +3763,7 @@ png_exp8bit(png_fixed_point lg2)
     * step.
     */
    x -= x >> 8;
-   return (png_byte)((x + 0x7fffffU) >> 24);
+   return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff);
 }
 
 #ifdef PNG_16BIT_SUPPORTED
@@ -3820,7 +3824,7 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
 #     endif
    }
 
-   return (png_byte)value;
+   return (png_byte)(value & 0xff);
 }
 
 #ifdef PNG_16BIT_SUPPORTED
@@ -4042,7 +4046,7 @@ png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
 
    else
       for (i=0; i<256; ++i)
-         table[i] = (png_byte)i;
+         table[i] = (png_byte)(i & 0xff);
 }
 
 /* Used from png_read_destroy and below to release the memory used by the gamma
@@ -4182,7 +4186,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
       *
       */
      if (sig_bit > 0 && sig_bit < 16U)
-        shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */
+        /* shift == insignificant bits */
+        shift = (png_byte)((16U - sig_bit) & 0xff);
 
      else
         shift = 0; /* keep all 16 bits */
@@ -4251,7 +4256,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
       int setting = (2 + (onoff != 0)) << option;
       int current = png_ptr->options;
 
-      png_ptr->options = (png_byte)((current & ~mask) | setting);
+      png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff);
 
       return (current & mask) >> option;
    }
@@ -4267,7 +4272,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
  * contrib/tools/makesRGB.c.  The actual sRGB transfer curve defined in the
  * specification (see the article at http://en.wikipedia.org/wiki/SRGB)
  * is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
- * The sRGB to linear table is exact (to the nearest 16 bit linear fraction).
+ * The sRGB to linear table is exact (to the nearest 16-bit linear fraction).
  * The inverse (linear to sRGB) table has accuracies as follows:
  *
  * For all possible (255*65535+1) input values:
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.h b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.h
index de99418e773..c90a90f29cb 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.h
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.h
@@ -29,8 +29,9 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * libpng version 1.6.16, December 22, 2014
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * libpng version 1.6.20, December 3, 2015
+ *
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -38,17 +39,137 @@
  *
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
- *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.6.16, December 22, 2014: Glenn
+ *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
+ *   libpng versions 0.97, January 1998, through 1.6.20, December 3, 2015:
+ *     Glenn Randers-Pehrson.
  *   See also "Contributing Authors", below.
+ */
+
+/*
+ * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
  *
- * Note about libpng version numbers:
+ * If you modify libpng you may insert additional notices immediately following
+ * this sentence.
  *
- *   Due to various miscommunications, unforeseen code incompatibilities
- *   and occasional factors outside the authors' control, version numbering
- *   on the library has not always been consistent and straightforward.
- *   The following table summarizes matters since version 0.89c, which was
- *   the first widely used release:
+ * This code is released under the libpng license.
+ *
+ * libpng versions 1.0.7, July 1, 2000, through 1.6.20, December 3, 2015, are
+ * Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
+ * derived from libpng-1.0.6, and are distributed according to the same
+ * disclaimer and license as libpng-1.0.6 with the following individuals
+ * added to the list of Contributing Authors:
+ *
+ *    Simon-Pierre Cadieux
+ *    Eric S. Raymond
+ *    Mans Rullgard
+ *    Cosmin Truta
+ *    Gilles Vollant
+ *    James Yu
+ *
+ * and with the following additions to the disclaimer:
+ *
+ *    There is no warranty against interference with your enjoyment of the
+ *    library or against infringement.  There is no warranty that our
+ *    efforts or the library will fulfill any of your particular purposes
+ *    or needs.  This library is provided with all faults, and the entire
+ *    risk of satisfactory quality, performance, accuracy, and effort is with
+ *    the user.
+ *
+ * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
+ * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
+ * libpng-0.96, and are distributed according to the same disclaimer and
+ * license as libpng-0.96, with the following individuals added to the list
+ * of Contributing Authors:
+ *
+ *    Tom Lane
+ *    Glenn Randers-Pehrson
+ *    Willem van Schaik
+ *
+ * libpng versions 0.89, June 1996, through 0.96, May 1997, are
+ * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
+ * and are distributed according to the same disclaimer and license as
+ * libpng-0.88, with the following individuals added to the list of
+ * Contributing Authors:
+ *
+ *    John Bowler
+ *    Kevin Bracey
+ *    Sam Bushell
+ *    Magnus Holmgren
+ *    Greg Roelofs
+ *    Tom Tanner
+ *
+ * libpng versions 0.5, May 1995, through 0.88, January 1996, are
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+ *
+ * For the purposes of this copyright and license, "Contributing Authors"
+ * is defined as the following set of individuals:
+ *
+ *    Andreas Dilger
+ *    Dave Martindale
+ *    Guy Eric Schalnat
+ *    Paul Schmidt
+ *    Tim Wegner
+ *
+ * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
+ * and Group 42, Inc. disclaim all warranties, expressed or implied,
+ * including, without limitation, the warranties of merchantability and of
+ * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
+ * assume no liability for direct, indirect, incidental, special, exemplary,
+ * or consequential damages, which may result from the use of the PNG
+ * Reference Library, even if advised of the possibility of such damage.
+ *
+ * Permission is hereby granted to use, copy, modify, and distribute this
+ * source code, or portions hereof, for any purpose, without fee, subject
+ * to the following restrictions:
+ *
+ *   1. The origin of this source code must not be misrepresented.
+ *
+ *   2. Altered versions must be plainly marked as such and must not
+ *      be misrepresented as being the original source.
+ *
+ *   3. This Copyright notice may not be removed or altered from any
+ *      source or altered source distribution.
+ *
+ * The Contributing Authors and Group 42, Inc. specifically permit, without
+ * fee, and encourage the use of this source code as a component to
+ * supporting the PNG file format in commercial products.  If you use this
+ * source code in a product, acknowledgment is not required but would be
+ * appreciated.
+ *
+ * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
+ */
+
+/*
+ * A "png_get_copyright" function is available, for convenient use in "about"
+ * boxes and the like:
+ *
+ *    printf("%s", png_get_copyright(NULL));
+ *
+ * Also, the PNG logo (in PNG format, of course) is supplied in the
+ * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
+ */
+
+/*
+ * Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
+ * a certification mark of the Open Source Initiative. OSI has not addressed
+ * the additional disclaimers inserted at version 1.0.7.
+ */
+
+/*
+ * The contributing authors would like to thank all those who helped
+ * with testing, bug fixes, and patience.  This wouldn't have been
+ * possible without all of you.
+ *
+ * Thanks to Frank J. T. Wojcik for helping with the documentation.
+ */
+
+/* Note about libpng version numbers:
+ *
+ *    Due to various miscommunications, unforeseen code incompatibilities
+ *    and occasional factors outside the authors' control, version numbering
+ *    on the library has not always been consistent and straightforward.
+ *    The following table summarizes matters since version 0.89c, which was
+ *    the first widely used release:
  *
  *    source                 png.h  png.h  shared-lib
  *    version                string   int  version
@@ -86,310 +207,48 @@
  *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)
  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
  *    1.0.7                    1    10007  (still compatible)
- *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4
- *    1.0.8rc1                 1    10008  2.1.0.8rc1
- *    1.0.8                    1    10008  2.1.0.8
- *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6
- *    1.0.9rc1                 1    10009  2.1.0.9rc1
- *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10
- *    1.0.9rc2                 1    10009  2.1.0.9rc2
- *    1.0.9                    1    10009  2.1.0.9
- *    1.0.10beta1              1    10010  2.1.0.10beta1
- *    1.0.10rc1                1    10010  2.1.0.10rc1
- *    1.0.10                   1    10010  2.1.0.10
- *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3
- *    1.0.11rc1                1    10011  2.1.0.11rc1
- *    1.0.11                   1    10011  2.1.0.11
- *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2
- *    1.0.12rc1                2    10012  2.1.0.12rc1
- *    1.0.12                   2    10012  2.1.0.12
- *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)
- *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2
- *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5
- *    1.2.0rc1                 3    10200  3.1.2.0rc1
- *    1.2.0                    3    10200  3.1.2.0
- *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4
- *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2
- *    1.2.1                    3    10201  3.1.2.1
- *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6
- *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1
- *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1
- *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1
- *    1.0.13                  10    10013  10.so.0.1.0.13
- *    1.2.2                   12    10202  12.so.0.1.2.2
- *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6
- *    1.2.3                   12    10203  12.so.0.1.2.3
- *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3
- *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1
- *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1
- *    1.0.14                  10    10014  10.so.0.1.0.14
- *    1.2.4                   13    10204  12.so.0.1.2.4
- *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2
- *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3
- *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3
- *    1.0.15                  10    10015  10.so.0.1.0.15
- *    1.2.5                   13    10205  12.so.0.1.2.5
- *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4
- *    1.0.16                  10    10016  10.so.0.1.0.16
- *    1.2.6                   13    10206  12.so.0.1.2.6
- *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2
- *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1
- *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1
- *    1.0.17                  10    10017  12.so.0.1.0.17
- *    1.2.7                   13    10207  12.so.0.1.2.7
- *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5
- *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5
- *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5
- *    1.0.18                  10    10018  12.so.0.1.0.18
- *    1.2.8                   13    10208  12.so.0.1.2.8
- *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3
- *    1.2.9beta4-11           13    10209  12.so.0.9[.0]
- *    1.2.9rc1                13    10209  12.so.0.9[.0]
- *    1.2.9                   13    10209  12.so.0.9[.0]
- *    1.2.10beta1-7           13    10210  12.so.0.10[.0]
- *    1.2.10rc1-2             13    10210  12.so.0.10[.0]
- *    1.2.10                  13    10210  12.so.0.10[.0]
- *    1.4.0beta1-5            14    10400  14.so.0.0[.0]
- *    1.2.11beta1-4           13    10211  12.so.0.11[.0]
- *    1.4.0beta7-8            14    10400  14.so.0.0[.0]
- *    1.2.11                  13    10211  12.so.0.11[.0]
- *    1.2.12                  13    10212  12.so.0.12[.0]
- *    1.4.0beta9-14           14    10400  14.so.0.0[.0]
- *    1.2.13                  13    10213  12.so.0.13[.0]
- *    1.4.0beta15-36          14    10400  14.so.0.0[.0]
- *    1.4.0beta37-87          14    10400  14.so.14.0[.0]
- *    1.4.0rc01               14    10400  14.so.14.0[.0]
- *    1.4.0beta88-109         14    10400  14.so.14.0[.0]
- *    1.4.0rc02-08            14    10400  14.so.14.0[.0]
- *    1.4.0                   14    10400  14.so.14.0[.0]
- *    1.4.1beta01-03          14    10401  14.so.14.1[.0]
- *    1.4.1rc01               14    10401  14.so.14.1[.0]
- *    1.4.1beta04-12          14    10401  14.so.14.1[.0]
- *    1.4.1                   14    10401  14.so.14.1[.0]
- *    1.4.2                   14    10402  14.so.14.2[.0]
- *    1.4.3                   14    10403  14.so.14.3[.0]
- *    1.4.4                   14    10404  14.so.14.4[.0]
- *    1.5.0beta01-58          15    10500  15.so.15.0[.0]
- *    1.5.0rc01-07            15    10500  15.so.15.0[.0]
- *    1.5.0                   15    10500  15.so.15.0[.0]
- *    1.5.1beta01-11          15    10501  15.so.15.1[.0]
- *    1.5.1rc01-02            15    10501  15.so.15.1[.0]
- *    1.5.1                   15    10501  15.so.15.1[.0]
- *    1.5.2beta01-03          15    10502  15.so.15.2[.0]
- *    1.5.2rc01-03            15    10502  15.so.15.2[.0]
- *    1.5.2                   15    10502  15.so.15.2[.0]
- *    1.5.3beta01-10          15    10503  15.so.15.3[.0]
- *    1.5.3rc01-02            15    10503  15.so.15.3[.0]
- *    1.5.3beta11             15    10503  15.so.15.3[.0]
- *    1.5.3 [omitted]
- *    1.5.4beta01-08          15    10504  15.so.15.4[.0]
- *    1.5.4rc01               15    10504  15.so.15.4[.0]
- *    1.5.4                   15    10504  15.so.15.4[.0]
- *    1.5.5beta01-08          15    10505  15.so.15.5[.0]
- *    1.5.5rc01               15    10505  15.so.15.5[.0]
- *    1.5.5                   15    10505  15.so.15.5[.0]
- *    1.5.6beta01-07          15    10506  15.so.15.6[.0]
- *    1.5.6rc01-03            15    10506  15.so.15.6[.0]
- *    1.5.6                   15    10506  15.so.15.6[.0]
- *    1.5.7beta01-05          15    10507  15.so.15.7[.0]
- *    1.5.7rc01-03            15    10507  15.so.15.7[.0]
- *    1.5.7                   15    10507  15.so.15.7[.0]
- *    1.6.0beta01-40          16    10600  16.so.16.0[.0]
- *    1.6.0rc01-08            16    10600  16.so.16.0[.0]
- *    1.6.0                   16    10600  16.so.16.0[.0]
- *    1.6.1beta01-09          16    10601  16.so.16.1[.0]
- *    1.6.1rc01               16    10601  16.so.16.1[.0]
- *    1.6.1                   16    10601  16.so.16.1[.0]
- *    1.6.2beta01             16    10602  16.so.16.2[.0]
- *    1.6.2rc01-06            16    10602  16.so.16.2[.0]
- *    1.6.2                   16    10602  16.so.16.2[.0]
- *    1.6.3beta01-11          16    10603  16.so.16.3[.0]
- *    1.6.3rc01               16    10603  16.so.16.3[.0]
- *    1.6.3                   16    10603  16.so.16.3[.0]
- *    1.6.4beta01-02          16    10604  16.so.16.4[.0]
- *    1.6.4rc01               16    10604  16.so.16.4[.0]
- *    1.6.4                   16    10604  16.so.16.4[.0]
- *    1.6.5                   16    10605  16.so.16.5[.0]
- *    1.6.6                   16    10606  16.so.16.6[.0]
- *    1.6.7beta01-04          16    10607  16.so.16.7[.0]
- *    1.6.7rc01-03            16    10607  16.so.16.7[.0]
- *    1.6.7                   16    10607  16.so.16.7[.0]
- *    1.6.8beta01-02          16    10608  16.so.16.8[.0]
- *    1.6.8rc01-02            16    10608  16.so.16.8[.0]
- *    1.6.8                   16    10608  16.so.16.8[.0]
- *    1.6.9beta01-04          16    10609  16.so.16.9[.0]
- *    1.6.9rc01-02            16    10609  16.so.16.9[.0]
- *    1.6.9                   16    10609  16.so.16.9[.0]
- *    1.6.10beta01-03         16    10610  16.so.16.10[.0]
- *    1.6.10rc01-03           16    10610  16.so.16.10[.0]
- *    1.6.10                  16    10610  16.so.16.10[.0]
- *    1.6.11beta01-06         16    10611  16.so.16.11[.0]
- *    1.6.11rc01-02           16    10611  16.so.16.11[.0]
- *    1.6.11                  16    10611  16.so.16.11[.0]
- *    1.6.12rc01-03           16    10612  16.so.16.12[.0]
- *    1.6.12                  16    10612  16.so.16.12[.0]
- *    1.6.13beta01-04         16    10613  16.so.16.13[.0]
- *    1.6.13rc01-02           16    10613  16.so.16.13[.0]
- *    1.6.13                  16    10613  16.so.16.13[.0]
- *    1.6.14beta01-07         16    10614  16.so.16.14[.0]
- *    1.6.14rc01-02           16    10614  16.so.16.14[.0]
- *    1.6.14                  16    10614  16.so.16.14[.0]
- *    1.6.15beta01-08         16    10615  16.so.16.15[.0]
- *    1.6.15rc01-03           16    10615  16.so.16.15[.0]
- *    1.6.15                  16    10615  16.so.16.15[.0]
- *    1.6.16beta01-03         16    10616  16.so.16.16[.0]
- *    1.6.16rc01-02           16    10616  16.so.16.16[.0]
- *    1.6.16                  16    10616  16.so.16.16[.0]
+ *    ...
+ *    1.0.19                  10    10019  10.so.0.19[.0]
+ *    ...
+ *    1.2.53                  13    10253  12.so.0.53[.0]
+ *    ...
+ *    1.5.23                  15    10523  15.so.15.23[.0]
+ *    ...
+ *    1.6.20                  16    10620  16.so.16.20[.0]
  *
- *   Henceforth the source version will match the shared-library major
- *   and minor numbers; the shared-library major version number will be
- *   used for changes in backward compatibility, as it is intended.  The
- *   PNG_LIBPNG_VER macro, which is not used within libpng but is available
- *   for applications, is an unsigned integer of the form xyyzz corresponding
- *   to the source version x.y.z (leading zeros in y and z).  Beta versions
- *   were given the previous public release number plus a letter, until
- *   version 1.0.6j; from then on they were given the upcoming public
- *   release number plus "betaNN" or "rcNN".
+ *    Henceforth the source version will match the shared-library major
+ *    and minor numbers; the shared-library major version number will be
+ *    used for changes in backward compatibility, as it is intended.  The
+ *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
+ *    for applications, is an unsigned integer of the form xyyzz corresponding
+ *    to the source version x.y.z (leading zeros in y and z).  Beta versions
+ *    were given the previous public release number plus a letter, until
+ *    version 1.0.6j; from then on they were given the upcoming public
+ *    release number plus "betaNN" or "rcNN".
  *
- *   Binary incompatibility exists only when applications make direct access
- *   to the info_ptr or png_ptr members through png.h, and the compiled
- *   application is loaded with a different version of the library.
+ *    Binary incompatibility exists only when applications make direct access
+ *    to the info_ptr or png_ptr members through png.h, and the compiled
+ *    application is loaded with a different version of the library.
  *
- *   DLLNUM will change each time there are forward or backward changes
- *   in binary compatibility (e.g., when a new feature is added).
+ *    DLLNUM will change each time there are forward or backward changes
+ *    in binary compatibility (e.g., when a new feature is added).
  *
- * See libpng-manual.txt or libpng.3 for more information.  The PNG
- * specification is available as a W3C Recommendation and as an ISO
- * Specification, = 0x8000 /* else this might break */
 #define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */
+#endif
 
 /* This is used for the transformation routines, as some of them
  * change these values for the row.  It also should enable using
@@ -1017,7 +883,9 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
 #define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */
 /* Added to libpng-1.5.4 */
 #define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */
+#if INT_MAX >= 0x8000 /* else this might break */
 #define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */
+#endif
 
 /* Flags for MNG supported features */
 #define PNG_FLAG_MNG_EMPTY_PLTE     0x01
@@ -1034,7 +902,7 @@ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
     png_alloc_size_t));
 typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
 
-/* Section 3: exported functions
+/* Section 4: exported functions
  * Here are the function definitions most commonly used.  This is not
  * the place to find out how to use libpng.  See libpng-manual.txt for the
  * full explanation, see example.c for the summary.  This just provides
@@ -1407,13 +1275,13 @@ PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));
 #endif
 
 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
-/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
+/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
 PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
     int flags));
 /* The values of the PNG_FILLER_ defines should NOT be changed */
 #  define PNG_FILLER_BEFORE 0
 #  define PNG_FILLER_AFTER 1
-/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
+/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
 PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
     png_uint_32 filler, int flags));
 #endif /* READ_FILLER || WRITE_FILLER */
@@ -1606,6 +1474,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
 #define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */
 #define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */
 
+#ifdef PNG_WRITE_SUPPORTED
 /* These functions give the user control over the scan-line filtering in
  * libpng and the compression methods used by zlib.  These functions are
  * mainly useful for testing, as the defaults should work with most users.
@@ -1619,6 +1488,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
  */
 PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
     int filters));
+#endif /* WRITE */
 
 /* Flags for png_set_filter() to say which filters to use.  The flags
  * are chosen so that they don't conflict with real filter types
@@ -1644,35 +1514,8 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
 #define PNG_FILTER_VALUE_PAETH 4
 #define PNG_FILTER_VALUE_LAST  5
 
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
-/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
- * defines, either the default (minimum-sum-of-absolute-differences), or
- * the experimental method (weighted-minimum-sum-of-absolute-differences).
- *
- * Weights are factors >= 1.0, indicating how important it is to keep the
- * filter type consistent between rows.  Larger numbers mean the current
- * filter is that many times as likely to be the same as the "num_weights"
- * previous filters.  This is cumulative for each previous row with a weight.
- * There needs to be "num_weights" values in "filter_weights", or it can be
- * NULL if the weights aren't being specified.  Weights have no influence on
- * the selection of the first row filter.  Well chosen weights can (in theory)
- * improve the compression for a given image.
- *
- * Costs are factors >= 1.0 indicating the relative decoding costs of a
- * filter type.  Higher costs indicate more decoding expense, and are
- * therefore less likely to be selected over a filter with lower computational
- * costs.  There needs to be a value in "filter_costs" for each valid filter
- * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
- * setting the costs.  Costs try to improve the speed of decompression without
- * unduly increasing the compressed image size.
- *
- * A negative weight or cost indicates the default value is to be used, and
- * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
- * The default values for both weights and costs are currently 1.0, but may
- * change if good general weighting/cost heuristics can be found.  If both
- * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
- * to the UNWEIGHTED method, but with added encoding time/computation.
- */
+#ifdef PNG_WRITE_SUPPORTED
+#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
 PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
     int heuristic_method, int num_weights, png_const_doublep filter_weights,
     png_const_doublep filter_costs))
@@ -1682,15 +1525,12 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
     png_const_fixed_point_p filter_costs))
 #endif /* WRITE_WEIGHTED_FILTER */
 
-/* Heuristic used for row filter selection.  These defines should NOT be
- * changed.
- */
+/* The following are no longer used and will be removed from libpng-1.7: */
 #define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
 #define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
 #define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
 
-#ifdef PNG_WRITE_SUPPORTED
 /* Set the library compression level.  Currently, valid values range from
  * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
  * (0 - no compression, 9 - "maximal" compression).  Note that tests have
@@ -1698,6 +1538,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
  * for PNG images, and do considerably fewer caclulations.  In the future,
  * these values may not correspond directly to the zlib compression levels.
  */
+#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
 PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,
     int level));
 
@@ -1715,7 +1556,7 @@ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,
 
 PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,
     int method));
-#endif
+#endif /* WRITE_CUSTOMIZE_COMPRESSION */
 
 #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
 /* Also set zlib parameters for compressing non-IDAT chunks */
@@ -1737,6 +1578,7 @@ PNG_EXPORT(225, void, png_set_text_compression_window_bits,
 PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
     int method));
 #endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
+#endif /* WRITE */
 
 /* These next functions are called for input/output, memory, and error
  * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
@@ -1847,7 +1689,7 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
  *
  * The integer return from the callback function is interpreted thus:
  *
- * negative: An error occured, png_chunk_error will be called.
+ * negative: An error occurred; png_chunk_error will be called.
  *     zero: The chunk was not handled, the chunk will be saved. A critical
  *           chunk will cause an error at this point unless it is to be saved.
  * positive: The chunk was handled, libpng will ignore/discard it.
@@ -2692,26 +2534,28 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
            * (png_uint_16)(alpha)                         \
            + (png_uint_16)(bg)*(png_uint_16)(255          \
            - (png_uint_16)(alpha)) + 128);                \
-       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
+       (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
 
 #  define png_composite_16(composite, fg, alpha, bg)       \
      { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \
            * (png_uint_32)(alpha)                          \
            + (png_uint_32)(bg)*(65535                      \
            - (png_uint_32)(alpha)) + 32768);               \
-       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
+       (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
 
 #else  /* Standard method using integer division */
 
-#  define png_composite(composite, fg, alpha, bg)                          \
-     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
-     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
-     127) / 255)
+#  define png_composite(composite, fg, alpha, bg)                        \
+     (composite) =                                                       \
+         (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
+         (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
+         127) / 255))
 
 #  define png_composite_16(composite, fg, alpha, bg)                         \
-     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
-     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \
-     32767) / 65535)
+     (composite) =                                                           \
+         (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
+         (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +     \
+         32767) / 65535))
 #endif /* READ_COMPOSITE_NODIV */
 
 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
@@ -2762,7 +2606,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
 
 #  define PNG_get_int_32(buf) \
      ((png_int_32)((*(buf) & 0x80) \
-      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
+      ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
       : (png_int_32)png_get_uint_32(buf)))
 
    /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
@@ -2782,10 +2626,17 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
 #  endif
 #endif
 
-#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
-    defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
+#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
+PNG_EXPORT(242, void, png_set_check_for_invalid_index,
+    (png_structrp png_ptr, int allowed));
+#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED
+PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
+    png_const_infop info_ptr));
+#  endif
+#endif /* CHECK_FOR_INVALID_INDEX */
+
 /*******************************************************************************
- *  SIMPLIFIED API
+ * Section 5: SIMPLIFIED API
  *******************************************************************************
  *
  * Please read the documentation in libpng-manual.txt (TODO: write said
@@ -2801,8 +2652,9 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
  *
  * To read a PNG file using the simplified API:
  *
- * 1) Declare a 'png_image' structure (see below) on the stack and set the
- *    version field to PNG_IMAGE_VERSION.
+ * 1) Declare a 'png_image' structure (see below) on the stack, set the
+ *    version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL
+ *    (this is REQUIRED, your program may crash if you don't do it.)
  * 2) Call the appropriate png_image_begin_read... function.
  * 3) Set the png_image 'format' member to the required sample format.
  * 4) Allocate a buffer for the image and, if required, the color-map.
@@ -2829,6 +2681,9 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
  * when it is being read or defines the in-memory format of an image that you
  * need to write:
  */
+#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
+    defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
+
 #define PNG_IMAGE_VERSION 1
 
 typedef struct png_control *png_controlp;
@@ -2928,7 +2783,7 @@ typedef struct
  * called to read or write the color-map and set the format correctly for the
  * image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!
  *
- * NOTE: libpng can be built with particular features disabled, if you see
+ * NOTE: libpng can be built with particular features disabled. If you see
  * compiler errors because the definition of one of the following flags has been
  * compiled out it is because libpng does not have the required support.  It is
  * possible, however, for the libpng configuration to enable the format on just
@@ -2940,7 +2795,7 @@ typedef struct
  */
 #define PNG_FORMAT_FLAG_ALPHA    0x01U /* format with an alpha channel */
 #define PNG_FORMAT_FLAG_COLOR    0x02U /* color format: otherwise grayscale */
-#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */
+#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2-byte channels else 1-byte */
 #define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */
 
 #ifdef PNG_FORMAT_BGR_SUPPORTED
@@ -3227,9 +3082,11 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
  *
  * With all APIs row_stride is handled as in the read APIs - it is the spacing
  * from one row to the next in component sized units (1 or 2 bytes) and if
- * negative indicates a bottom-up row layout in the buffer.
+ * negative indicates a bottom-up row layout in the buffer.  If row_stride is zero,
+ * libpng will calculate it for you from the image width and number of channels.
  *
- * Note that the write API does not support interlacing or sub-8-bit pixels.
+ * Note that the write API does not support interlacing, sub-8-bit pixels, indexed
+ * PNG (color_type 3) or most ancillary chunks.
  */
 #endif /* STDIO */
 #endif /* SIMPLIFIED_WRITE */
@@ -3238,17 +3095,8 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
  ******************************************************************************/
 #endif /* SIMPLIFIED_{READ|WRITE} */
 
-#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
-PNG_EXPORT(242, void, png_set_check_for_invalid_index,
-    (png_structrp png_ptr, int allowed));
-#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED
-PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
-    png_const_infop info_ptr));
-#  endif
-#endif /* CHECK_FOR_INVALID_INDEX */
-
 /*******************************************************************************
- *  IMPLEMENTATION OPTIONS
+ * Section 6: IMPLEMENTATION OPTIONS
  *******************************************************************************
  *
  * Support for arbitrary implementation-specific optimizations.  The API allows
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
index 2059235d374..482dcf7daef 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h
@@ -29,9 +29,9 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * libpng version 1.6.16,December 22, 2014
+ * libpng version 1.6.20, December 3, 2015
  *
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -39,9 +39,7 @@
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  *
- */
-
-/* Any machine specific code is near the front of this file, so if you
+ * Any machine specific code is near the front of this file, so if you
  * are configuring libpng for a machine, you may want to read the section
  * starting here down to where it starts to typedef png_color, png_text,
  * and png_info.
@@ -50,26 +48,6 @@
 #ifndef PNGCONF_H
 #define PNGCONF_H
 
-/* To do: Do all of this in scripts/pnglibconf.dfa */
-#ifdef PNG_SAFE_LIMITS_SUPPORTED
-#  ifdef PNG_USER_WIDTH_MAX
-#    undef PNG_USER_WIDTH_MAX
-#    define PNG_USER_WIDTH_MAX 1000000L
-#  endif
-#  ifdef PNG_USER_HEIGHT_MAX
-#    undef PNG_USER_HEIGHT_MAX
-#    define PNG_USER_HEIGHT_MAX 1000000L
-#  endif
-#  ifdef PNG_USER_CHUNK_MALLOC_MAX
-#    undef PNG_USER_CHUNK_MALLOC_MAX
-#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L
-#  endif
-#  ifdef PNG_USER_CHUNK_CACHE_MAX
-#    undef PNG_USER_CHUNK_CACHE_MAX
-#    define PNG_USER_CHUNK_CACHE_MAX 128
-#  endif
-#endif
-
 #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
 
 /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
@@ -113,7 +91,7 @@
  */
 #define PNG_CONST const /* backward compatibility only */
 
-/* This controls optimization of the reading of 16 and 32 bit values
+/* This controls optimization of the reading of 16-bit and 32-bit values
  * from PNG files.  It can be set on a per-app-file basis - it
  * just changes whether a macro is used when the function is called.
  * The library builder sets the default; if read functions are not
@@ -345,11 +323,11 @@
     * table entries, so we discard it here.  See the .dfn files in the
     * scripts directory.
     */
-#ifndef PNG_EXPORTA
 
-#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\
-      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
-        extern attributes)
+#ifndef PNG_EXPORTA
+#  define PNG_EXPORTA(ordinal, type, name, args, attributes) \
+      PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
+      PNG_LINKAGE_API attributes)
 #endif
 
 /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
@@ -357,7 +335,7 @@
  */
 #define PNG_EMPTY /*empty list*/
 
-#define PNG_EXPORT(ordinal, type, name, args)\
+#define PNG_EXPORT(ordinal, type, name, args) \
    PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
 
 /* Use PNG_REMOVED to comment out a removed interface. */
@@ -530,7 +508,7 @@
 #if CHAR_BIT == 8 && UCHAR_MAX == 255
    typedef unsigned char png_byte;
 #else
-#  error "libpng requires 8 bit bytes"
+#  error "libpng requires 8-bit bytes"
 #endif
 
 #if INT_MIN == -32768 && INT_MAX == 32767
@@ -538,7 +516,7 @@
 #elif SHRT_MIN == -32768 && SHRT_MAX == 32767
    typedef short png_int_16;
 #else
-#  error "libpng requires a signed 16 bit type"
+#  error "libpng requires a signed 16-bit type"
 #endif
 
 #if UINT_MAX == 65535
@@ -546,7 +524,7 @@
 #elif USHRT_MAX == 65535
    typedef unsigned short png_uint_16;
 #else
-#  error "libpng requires an unsigned 16 bit type"
+#  error "libpng requires an unsigned 16-bit type"
 #endif
 
 #if INT_MIN < -2147483646 && INT_MAX > 2147483646
@@ -554,7 +532,7 @@
 #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
    typedef long int png_int_32;
 #else
-#  error "libpng requires a signed 32 bit (or more) type"
+#  error "libpng requires a signed 32-bit (or more) type"
 #endif
 
 #if UINT_MAX > 4294967294
@@ -562,7 +540,7 @@
 #elif ULONG_MAX > 4294967294
    typedef unsigned long int png_uint_32;
 #else
-#  error "libpng requires an unsigned 32 bit (or more) type"
+#  error "libpng requires an unsigned 32-bit (or more) type"
 #endif
 
 /* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h
index d4af91dcd5c..d30815032c7 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h
@@ -29,12 +29,11 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
+ * Last changed in libpng 1.6.8 [December 19, 2013]
  * Copyright (c) 1998-2013 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.6.8 [December 19, 2013]
- *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c
index c87fc907797..a2c9d3a8a4c 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.17 [March 26, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -827,14 +827,20 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
 {
    png_debug1(1, "in %s retrieval function", "IHDR");
 
-   if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
-       height == NULL || bit_depth == NULL || color_type == NULL)
+   if (png_ptr == NULL || info_ptr == NULL)
       return (0);
 
-   *width = info_ptr->width;
-   *height = info_ptr->height;
-   *bit_depth = info_ptr->bit_depth;
-   *color_type = info_ptr->color_type;
+   if (width != NULL)
+       *width = info_ptr->width;
+
+   if (height != NULL)
+       *height = info_ptr->height;
+
+   if (bit_depth != NULL)
+       *bit_depth = info_ptr->bit_depth;
+
+   if (color_type != NULL)
+       *color_type = info_ptr->color_type;
 
    if (compression_type != NULL)
       *compression_type = info_ptr->compression_type;
@@ -1163,21 +1169,21 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
    if (png_ptr == NULL)
       return 0;
 
-#  ifdef PNG_WRITE_SUPPORTED
+#ifdef PNG_WRITE_SUPPORTED
       if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
-#  endif
+#endif
    {
-#     ifdef PNG_SEQUENTIAL_READ_SUPPORTED
+#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
          return png_ptr->IDAT_read_size;
-#     else
+#else
          return PNG_IDAT_READ_SIZE;
-#     endif
+#endif
    }
 
-#  ifdef PNG_WRITE_SUPPORTED
+#ifdef PNG_WRITE_SUPPORTED
       else
          return png_ptr->zbuffer_size;
-#  endif
+#endif
 }
 
 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h
index 0b885a5ee7b..ff350824430 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h
@@ -29,12 +29,11 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
+ * Last changed in libpng 1.6.1 [March 28, 2013]
  * Copyright (c) 1998-2013 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.6.1 [March 28, 2013]
- *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
index f5fdbae317c..bcb167e7aa7 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h
@@ -34,7 +34,7 @@
  * file and, per its terms, should not be removed:
  */
 
-/* libpng version 1.6.16,December 22, 2014 */
+/* libpng version 1.6.20, December 3, 2015 */
 
 /* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
 
@@ -129,13 +129,10 @@
 #define PNG_READ_tIME_SUPPORTED
 #define PNG_READ_tRNS_SUPPORTED
 #define PNG_READ_zTXt_SUPPORTED
-/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
 /*#undef PNG_SAVE_INT_32_SUPPORTED*/
 #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
 #define PNG_SEQUENTIAL_READ_SUPPORTED
 #define PNG_SETJMP_SUPPORTED
-#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
-#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
 #define PNG_SET_OPTION_SUPPORTED
 #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
 #define PNG_SET_USER_LIMITS_SUPPORTED
@@ -161,6 +158,7 @@
 /*#undef PNG_WRITE_BGR_SUPPORTED*/
 /*#undef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED*/
 /*#undef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED*/
+/*#undef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED*/
 /*#undef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED*/
 /*#undef PNG_WRITE_FILLER_SUPPORTED*/
 /*#undef PNG_WRITE_FILTER_SUPPORTED*/
@@ -219,11 +217,14 @@
 /* end of options */
 /* settings */
 #define PNG_API_RULE 0
-#define PNG_COST_SHIFT 3
 #define PNG_DEFAULT_READ_MACROS 1
 #define PNG_GAMMA_THRESHOLD_FIXED 5000
 #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
 #define PNG_INFLATE_BUF_SIZE 1024
+#define PNG_LINKAGE_API extern
+#define PNG_LINKAGE_CALLBACK extern
+#define PNG_LINKAGE_DATA extern
+#define PNG_LINKAGE_FUNCTION extern
 #define PNG_MAX_GAMMA_8 11
 #define PNG_QUANTIZE_BLUE_BITS 5
 #define PNG_QUANTIZE_GREEN_BITS 5
@@ -234,7 +235,6 @@
 #define PNG_USER_CHUNK_MALLOC_MAX 0
 #define PNG_USER_HEIGHT_MAX 1000000
 #define PNG_USER_WIDTH_MAX 1000000
-#define PNG_WEIGHT_SHIFT 8
 #define PNG_ZBUF_SIZE 8192
 #define PNG_ZLIB_VERNUM 0
 #define PNG_Z_DEFAULT_COMPRESSION (-1)
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c
index c24098ffb73..71c6956b79f 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c
@@ -69,7 +69,7 @@ png_destroy_png_struct(png_structrp png_ptr)
 }
 
 /* Allocate memory.  For reasonable files, size should never exceed
- * 64K.  However, zlib may allocate more then 64K if you don't tell
+ * 64K.  However, zlib may allocate more than 64K if you don't tell
  * it not to.  See zconf.h and png.h for more information.  zlib does
  * need to allocate exactly 64K, so whatever you call here must
  * have the ability to do that.
@@ -105,6 +105,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
    PNG_UNUSED(png_ptr)
 #endif
 
+   /* Some compilers complain that this is always true.  However, it
+    * can be false when integer overflow happens.
+    */
    if (size > 0 && size <= PNG_SIZE_MAX
 #     ifdef PNG_MAX_MALLOC_64K
          && size <= 65536U
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c
index a0a92bb7faf..e17c993a2ff 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.18 [July 23, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -47,7 +47,6 @@
 #define PNG_READ_SIG_MODE   0
 #define PNG_READ_CHUNK_MODE 1
 #define PNG_READ_IDAT_MODE  2
-#define PNG_SKIP_MODE       3
 #define PNG_READ_tEXt_MODE  4
 #define PNG_READ_zTXt_MODE  5
 #define PNG_READ_DONE_MODE  6
@@ -106,32 +105,14 @@ png_process_data_pause(png_structrp png_ptr, int save)
 png_uint_32 PNGAPI
 png_process_data_skip(png_structrp png_ptr)
 {
-   png_uint_32 remaining = 0;
-
-   if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&
-      png_ptr->skip_length > 0)
-   {
-      /* At the end of png_process_data the buffer size must be 0 (see the loop
-       * above) so we can detect a broken call here:
-       */
-      if (png_ptr->buffer_size != 0)
-         png_error(png_ptr,
-            "png_process_data_skip called inside png_process_data");
-
-      /* If is impossible for there to be a saved buffer at this point -
-       * otherwise we could not be in SKIP mode.  This will also happen if
-       * png_process_skip is called inside png_process_data (but only very
-       * rarely.)
-       */
-      if (png_ptr->save_buffer_size != 0)
-         png_error(png_ptr, "png_process_data_skip called with saved data");
-
-      remaining = png_ptr->skip_length;
-      png_ptr->skip_length = 0;
-      png_ptr->process_mode = PNG_READ_CHUNK_MODE;
-   }
-
-   return remaining;
+  /* TODO: Deprecate and remove this API.
+   * Somewhere the implementation of this seems to have been lost,
+   * or abandoned.  It was only to support some internal back-door access
+   * to png_struct) in libpng-1.4.x.
+   */
+   png_app_warning(png_ptr,
+"png_process_data_skip is not implemented in any current version of libpng");
+   return 0;
 }
 
 /* What we do with the incoming data depends on what we were previously
@@ -163,12 +144,6 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
          break;
       }
 
-      case PNG_SKIP_MODE:
-      {
-         png_push_crc_finish(png_ptr);
-         break;
-      }
-
       default:
       {
          png_ptr->buffer_size = 0;
@@ -187,7 +162,7 @@ void /* PRIVATE */
 png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
 {
    png_size_t num_checked = png_ptr->sig_bytes, /* SAFE, does not exceed 8 */
-             num_to_check = 8 - num_checked;
+       num_to_check = 8 - num_checked;
 
    if (png_ptr->buffer_size < num_to_check)
    {
@@ -467,69 +442,6 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
    png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
 }
 
-void /* PRIVATE */
-png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
-{
-   png_ptr->process_mode = PNG_SKIP_MODE;
-   png_ptr->skip_length = skip;
-}
-
-void /* PRIVATE */
-png_push_crc_finish(png_structrp png_ptr)
-{
-   if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)
-   {
-      png_size_t save_size = png_ptr->save_buffer_size;
-      png_uint_32 skip_length = png_ptr->skip_length;
-
-      /* We want the smaller of 'skip_length' and 'save_buffer_size', but
-       * they are of different types and we don't know which variable has the
-       * fewest bits.  Carefully select the smaller and cast it to the type of
-       * the larger - this cannot overflow.  Do not cast in the following test
-       * - it will break on either 16 or 64 bit platforms.
-       */
-      if (skip_length < save_size)
-         save_size = (png_size_t)skip_length;
-
-      else
-         skip_length = (png_uint_32)save_size;
-
-      png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
-
-      png_ptr->skip_length -= skip_length;
-      png_ptr->buffer_size -= save_size;
-      png_ptr->save_buffer_size -= save_size;
-      png_ptr->save_buffer_ptr += save_size;
-   }
-   if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)
-   {
-      png_size_t save_size = png_ptr->current_buffer_size;
-      png_uint_32 skip_length = png_ptr->skip_length;
-
-      /* We want the smaller of 'skip_length' and 'current_buffer_size', here,
-       * the same problem exists as above and the same solution.
-       */
-      if (skip_length < save_size)
-         save_size = (png_size_t)skip_length;
-
-      else
-         skip_length = (png_uint_32)save_size;
-
-      png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);
-
-      png_ptr->skip_length -= skip_length;
-      png_ptr->buffer_size -= save_size;
-      png_ptr->current_buffer_size -= save_size;
-      png_ptr->current_buffer_ptr += save_size;
-   }
-   if (png_ptr->skip_length == 0)
-   {
-      PNG_PUSH_SAVE_BUFFER_IF_LT(4)
-      png_crc_finish(png_ptr, 0);
-      png_ptr->process_mode = PNG_READ_CHUNK_MODE;
-   }
-}
-
 void PNGCBAPI
 png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
 {
@@ -612,13 +524,11 @@ png_push_save_buffer(png_structrp png_ptr)
       if (png_ptr->save_buffer == NULL)
       {
          png_free(png_ptr, old_buffer);
-         old_buffer = NULL;
          png_error(png_ptr, "Insufficient memory for save_buffer");
       }
 
       memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
       png_free(png_ptr, old_buffer);
-      old_buffer = NULL;
       png_ptr->save_buffer_max = new_max;
    }
    if (png_ptr->current_buffer_size)
@@ -681,7 +591,7 @@ png_push_read_IDAT(png_structrp png_ptr)
        * are of different types and we don't know which variable has the fewest
        * bits.  Carefully select the smaller and cast it to the type of the
        * larger - this cannot overflow.  Do not cast in the following test - it
-       * will break on either 16 or 64 bit platforms.
+       * will break on either 16-bit or 64-bit platforms.
        */
       if (idat_size < save_size)
          save_size = (png_size_t)idat_size;
@@ -724,6 +634,7 @@ png_push_read_IDAT(png_structrp png_ptr)
       png_ptr->current_buffer_size -= save_size;
       png_ptr->current_buffer_ptr += save_size;
    }
+
    if (png_ptr->idat_size == 0)
    {
       PNG_PUSH_SAVE_BUFFER_IF_LT(4)
@@ -754,7 +665,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
     * or the stream marked as finished.
     */
    while (png_ptr->zstream.avail_in > 0 &&
-      !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
+      (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
    {
       int ret;
 
@@ -779,7 +690,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
        * change the current behavior (see comments in inflate.c
        * for why this doesn't happen at present with zlib 1.2.5).
        */
-      ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH);
+      ret = PNG_INFLATE(png_ptr, Z_SYNC_FLUSH);
 
       /* Check for any failure before proceeding. */
       if (ret != Z_OK && ret != Z_STREAM_END)
@@ -1064,6 +975,7 @@ png_push_process_row(png_structrp png_ptr)
       }
    }
    else
+#endif
    {
       png_push_have_row(png_ptr, png_ptr->row_buf + 1);
       png_read_push_finish_row(png_ptr);
@@ -1073,6 +985,7 @@ png_push_process_row(png_structrp png_ptr)
 void /* PRIVATE */
 png_read_push_finish_row(png_structrp png_ptr)
 {
+#ifdef PNG_READ_INTERLACING_SUPPORTED
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
@@ -1097,6 +1010,7 @@ png_read_push_finish_row(png_structrp png_ptr)
    if (png_ptr->row_number < png_ptr->num_rows)
       return;
 
+#ifdef PNG_READ_INTERLACING_SUPPORTED
    if (png_ptr->interlaced != 0)
    {
       png_ptr->row_number = 0;
@@ -1131,6 +1045,7 @@ png_read_push_finish_row(png_structrp png_ptr)
 
       } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
    }
+#endif /* READ_INTERLACING */
 }
 
 void /* PRIVATE */
@@ -1155,6 +1070,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row)
          (int)png_ptr->pass);
 }
 
+#ifdef PNG_READ_INTERLACING_SUPPORTED
 void PNGAPI
 png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
     png_const_bytep new_row)
@@ -1169,6 +1085,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
    if (new_row != NULL)
       png_combine_row(png_ptr, old_row, 1/*blocky display*/);
 }
+#endif /* READ_INTERLACING */
 
 void PNGAPI
 png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h
index 8f79edf59a7..f5c1532af51 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h
@@ -29,13 +29,11 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.18 [July 23, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.6.10 [March 6, 1014]]
- *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
@@ -148,8 +146,12 @@
     * to compile with an appropriate #error if ALIGNED_MEMORY has been turned
     * off.
     *
-    * Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we
-    * check both variants.
+    * Note that gcc-4.9 defines __ARM_NEON instead of the deprecated
+    * __ARM_NEON__, so we check both variants.
+    *
+    * To disable ARM_NEON optimizations entirely, and skip compiling the
+    * associated assembler code, pass --enable-arm-neon=no to configure
+    * or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
     */
 #  if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
    defined(PNG_ALIGNED_MEMORY_SUPPORTED)
@@ -278,17 +280,18 @@
  * always be used to declare an extern data or function object in this file.
  */
 #ifndef PNG_INTERNAL_DATA
-#  define PNG_INTERNAL_DATA(type, name, array) extern type name array
+#  define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array
 #endif
 
 #ifndef PNG_INTERNAL_FUNCTION
 #  define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
-      extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
+      PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
 #endif
 
 #ifndef PNG_INTERNAL_CALLBACK
 #  define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
-      extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)
+      PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\
+         PNG_EMPTY attributes)
 #endif
 
 /* If floating or fixed point APIs are disabled they may still be compiled
@@ -326,48 +329,27 @@
 #  define PNG_DLL_EXPORT
 #endif
 
-/* SECURITY and SAFETY:
+/* This is a global switch to set the compilation for an installed system
+ * (a release build).  It can be set for testing debug builds to ensure that
+ * they will compile when the build type is switched to RC or STABLE, the
+ * default is just to use PNG_LIBPNG_BUILD_BASE_TYPE.  Set this in CPPFLAGS
+ * with either:
  *
- * By default libpng is built without any internal limits on image size,
- * individual heap (png_malloc) allocations or the total amount of memory used.
- * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used
- * (unless individually overridden).  These limits are believed to be fairly
- * safe, but builders of secure systems should verify the values against the
- * real system capabilities.
+ *   -DPNG_RELEASE_BUILD Turns on the release compile path
+ *   -DPNG_RELEASE_BUILD=0 Turns it off
+ * or in your pngusr.h with
+ *   #define PNG_RELEASE_BUILD=1 Turns on the release compile path
+ *   #define PNG_RELEASE_BUILD=0 Turns it off
  */
-#ifdef PNG_SAFE_LIMITS_SUPPORTED
-   /* 'safe' limits */
-#  ifndef PNG_USER_WIDTH_MAX
-#     define PNG_USER_WIDTH_MAX 1000000
-#  endif
-#  ifndef PNG_USER_HEIGHT_MAX
-#     define PNG_USER_HEIGHT_MAX 1000000
-#  endif
-#  ifndef PNG_USER_CHUNK_CACHE_MAX
-#     define PNG_USER_CHUNK_CACHE_MAX 128
-#  endif
-#  ifndef PNG_USER_CHUNK_MALLOC_MAX
-#     define PNG_USER_CHUNK_MALLOC_MAX 8000000
-#  endif
-#else
-   /* values for no limits */
-#  ifndef PNG_USER_WIDTH_MAX
-#     define PNG_USER_WIDTH_MAX 0x7fffffff
-#  endif
-#  ifndef PNG_USER_HEIGHT_MAX
-#     define PNG_USER_HEIGHT_MAX 0x7fffffff
-#  endif
-#  ifndef PNG_USER_CHUNK_CACHE_MAX
-#     define PNG_USER_CHUNK_CACHE_MAX 0
-#  endif
-#  ifndef PNG_USER_CHUNK_MALLOC_MAX
-#     define PNG_USER_CHUNK_MALLOC_MAX 0
-#  endif
+#ifndef PNG_RELEASE_BUILD
+#  define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
 #endif
 
-/* Moved to pngpriv.h at libpng-1.5.0 */
-/* NOTE: some of these may have been used in external applications as
- * these definitions were exposed in pngconf.h prior to 1.5.
+/* SECURITY and SAFETY:
+ *
+ * libpng is built with support for internal limits on image dimensions and
+ * memory usage.  These are documented in scripts/pnglibconf.dfa of the
+ * source and recorded in the machine generated header file pnglibconf.h.
  */
 
 /* If you are running on a machine where you cannot allocate more
@@ -610,21 +592,17 @@
 #define PNG_RGB_TO_GRAY_WARN  0x400000
 #define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
 #define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */
-#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */
-#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */
-#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */
-                       /*   0x8000000 unused */
-                       /*  0x10000000 unused */
-                       /*  0x20000000 unused */
-                       /*  0x40000000 unused */
+#define PNG_ADD_ALPHA        0x1000000 /* Added to libpng-1.2.7 */
+#define PNG_EXPAND_tRNS      0x2000000 /* Added to libpng-1.2.9 */
+#define PNG_SCALE_16_TO_8    0x4000000 /* Added to libpng-1.5.4 */
+                       /*    0x8000000 unused */
+                       /*   0x10000000 unused */
+                       /*   0x20000000 unused */
+                       /*   0x40000000 unused */
 /* Flags for png_create_struct */
 #define PNG_STRUCT_PNG   0x0001
 #define PNG_STRUCT_INFO  0x0002
 
-/* Scaling factor for filter heuristic weighting calculations */
-#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
-#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
-
 /* Flags for the png_ptr->flags rather than declaring a byte for each one */
 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
 #define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002 /* Added to libpng-1.6.0 */
@@ -715,7 +693,7 @@
 /* The fixed point conversion performs range checking and evaluates
  * its argument multiple times, so must be used with care.  The
  * range checking uses the PNG specification values for a signed
- * 32 bit fixed point value except that the values are deliberately
+ * 32-bit fixed point value except that the values are deliberately
  * rounded-to-zero to an integral value - 21474 (21474.83 is roughly
  * (2^31-1) * 100000). 's' is a string that describes the value being
  * converted.
@@ -808,15 +786,17 @@
  * macro will fail on top-bit-set values because of the sign extension.
  */
 #define PNG_CHUNK_FROM_STRING(s)\
-   PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
+   PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3])
 
 /* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
  * signed and the argument is a (char[])  This macro will fail miserably on
  * systems where (char) is more than 8 bits.
  */
 #define PNG_STRING_FROM_CHUNK(s,c)\
-   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
-   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
+   (void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \
+   ((char*)(s))[1]=(char)(((c)>>16) & 0xff),\
+   ((char*)(s))[2]=(char)(((c)>>8) & 0xff), \
+   ((char*)(s))[3]=(char)((c & 0xff)))
 
 /* Do the same but terminate with a null character. */
 #define PNG_CSTRING_FROM_CHUNK(s,c)\
@@ -860,7 +840,7 @@
     */
 #endif
 
-/* This is used for 16 bit gamma tables -- only the top level pointers are
+/* This is used for 16-bit gamma tables -- only the top level pointers are
  * const; this could be changed:
  */
 typedef const png_uint_16p * png_const_uint_16pp;
@@ -878,8 +858,9 @@ PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
 PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
 PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
 
-#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
-   ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
+#define PNG_sRGB_FROM_LINEAR(linear) \
+  ((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \
+   + ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)))
    /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
     * encoded value with maximum error 0.646365.  Note that the input is not a
     * 16-bit value; it has been multiplied by 255! */
@@ -1262,6 +1243,14 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
 /* Initialize the row buffers, etc. */
 PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
 
+#if PNG_ZLIB_VERNUM >= 0x1240
+PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
+      PNG_EMPTY);
+#  define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
+#else /* Zlib < 1.2.4 */
+#  define PNG_INFLATE(pp, flush) inflate(&(pp)->zstream, flush)
+#endif /* Zlib < 1.2.4 */
+
 #ifdef PNG_READ_TRANSFORMS_SUPPORTED
 /* Optional call to update the users info structure */
 PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,
@@ -1436,10 +1425,6 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,
 PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,
     png_inforp info_ptr),PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,
-    png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),
-    PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),
     PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c
index 71d5f9269aa..69d5be24367 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.17 [March 26, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -91,7 +91,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
          /* In stable builds only warn if an application error can be completely
           * handled.
           */
-#        if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+#        if PNG_RELEASE_BUILD
             png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
 #        endif
 #     endif
@@ -842,8 +842,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
          /* Zero length IDATs are legal after the last IDAT has been
           * read, but not after other chunks have been read.
           */
-         if ((length > 0) ||
-             (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
+         if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
             png_benign_error(png_ptr, "Too many IDATs found");
 
          png_crc_finish(png_ptr, length);
@@ -1072,9 +1071,9 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
    /* Tell libpng to strip 16-bit/color files down to 8 bits per color.
     */
    if ((transforms & PNG_TRANSFORM_SCALE_16) != 0)
-     /* Added at libpng-1.5.4. "strip_16" produces the same result that it
-      * did in earlier versions, while "scale_16" is now more accurate.
-      */
+      /* Added at libpng-1.5.4. "strip_16" produces the same result that it
+       * did in earlier versions, while "scale_16" is now more accurate.
+       */
 #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
       png_set_scale_16(png_ptr);
 #else
@@ -1238,7 +1237,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
 
       for (iptr = 0; iptr < info_ptr->height; iptr++)
          info_ptr->row_pointers[iptr] = png_voidcast(png_bytep,
-            png_malloc(png_ptr, info_ptr->rowbytes));
+             png_malloc(png_ptr, info_ptr->rowbytes));
    }
 
    png_read_image(png_ptr, info_ptr->row_pointers);
@@ -1712,10 +1711,11 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)
          value *= 257;
          break;
 
+#ifdef __GNUC__
       default:
          png_error(display->image->opaque->png_ptr,
             "unexpected encoding (internal error)");
-         break;
+#endif
    }
 
    return value;
@@ -1852,6 +1852,7 @@ png_create_colormap_entry(png_image_read_control *display,
             y = (y + 128) >> 8;
             y *= 255;
             y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7);
+            alpha = PNG_DIV257(alpha);
             encoding = P_sRGB;
          }
 
@@ -2314,8 +2315,14 @@ png_image_read_colormap(png_voidp argument)
                      output_processing = PNG_CMAP_NONE;
                      break;
                   }
-
+#ifdef __COVERITY__
+                 /* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
+                  * here.
+                  */
+                  back_alpha = 255;
+#else
                   back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
+#endif
                }
 
                /* output_processing means that the libpng-processed row will be
@@ -2440,7 +2447,14 @@ png_image_read_colormap(png_voidp argument)
                 */
                background_index = i;
                png_create_colormap_entry(display, i++, back_r, back_g, back_b,
-                  output_encoding == P_LINEAR ? 65535U : 255U, output_encoding);
+#ifdef __COVERITY__
+                 /* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
+                  * here.
+                  */ 255U,
+#else
+                  output_encoding == P_LINEAR ? 65535U : 255U,
+#endif
+                  output_encoding);
 
                /* For non-opaque input composite on the sRGB background - this
                 * requires inverting the encoding for each component.  The input
@@ -2852,7 +2866,6 @@ png_image_read_colormap(png_voidp argument)
       default:
          png_error(png_ptr, "invalid PNG color type");
          /*NOT REACHED*/
-         break;
    }
 
    /* Now deal with the output processing */
@@ -2862,10 +2875,6 @@ png_image_read_colormap(png_voidp argument)
 
    switch (data_encoding)
    {
-      default:
-         png_error(png_ptr, "bad data option (internal error)");
-         break;
-
       case P_sRGB:
          /* Change to 8-bit sRGB */
          png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
@@ -2875,6 +2884,11 @@ png_image_read_colormap(png_voidp argument)
          if (png_ptr->bit_depth > 8)
             png_set_scale_16(png_ptr);
          break;
+
+#ifdef __GNUC__
+      default:
+         png_error(png_ptr, "bad data option (internal error)");
+#endif
    }
 
    if (cmap_entries > 256 || cmap_entries > image->colormap_entries)
@@ -3274,7 +3288,7 @@ png_image_read_composite(png_voidp argument)
       png_uint_32  width = image->width;
       ptrdiff_t    step_row = display->row_bytes;
       unsigned int channels =
-         (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
+          (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
       int pass;
 
       for (pass = 0; pass < passes; ++pass)
@@ -3425,10 +3439,6 @@ png_image_read_background(png_voidp argument)
     */
    switch (info_ptr->bit_depth)
    {
-      default:
-         png_error(png_ptr, "unexpected bit depth");
-         break;
-
       case 8:
          /* 8-bit sRGB gray values with an alpha channel; the alpha channel is
           * to be removed by composing on a background: either the row if
@@ -3646,6 +3656,11 @@ png_image_read_background(png_voidp argument)
             }
          }
          break;
+
+#ifdef __GNUC__
+      default:
+         png_error(png_ptr, "unexpected bit depth");
+#endif
    }
 
    return 1;
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c
index debf6458ae1..b72cafd328a 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.17 [March 26, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -54,7 +54,7 @@
  * reads from a file pointer.  Note that this routine sometimes gets called
  * with very small lengths, so you should implement some kind of simple
  * buffering if you are using unbuffered reads.  This should never be asked
- * to read more then 64K on a 16 bit machine.
+ * to read more than 64K on a 16-bit machine.
  */
 void /* PRIVATE */
 png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
index dc38d78d14d..b6b731d0176 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.19 [November 12, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -422,7 +422,7 @@ png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
 /* Dither file to 8-bit.  Supply a palette, the current number
  * of elements in the palette, the maximum number of elements
  * allowed, and a histogram if possible.  If the current number
- * of colors is greater then the maximum number, the palette will be
+ * of colors is greater than the maximum number, the palette will be
  * modified to fit in the maximum number.  "full_quantize" indicates
  * whether we need a quantizing cube set up for RGB images, or if we
  * simply are reducing the number of colors in a paletted image.
@@ -1004,7 +1004,6 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
 
       default:
          png_error(png_ptr, "invalid error action to rgb_to_gray");
-         break;
    }
 
    if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
@@ -2025,7 +2024,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
 #     endif
 
 #  else
-      /* No 16 bit support: force chopping 16-bit input down to 8, in this case
+      /* No 16-bit support: force chopping 16-bit input down to 8, in this case
        * the app program can chose if both APIs are available by setting the
        * correct scaling to use.
        */
@@ -2126,10 +2125,10 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
 defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
    {
-      if (info_ptr->bit_depth < png_ptr->user_transform_depth)
+      if (png_ptr->user_transform_depth != 0)
          info_ptr->bit_depth = png_ptr->user_transform_depth;
 
-      if (info_ptr->channels < png_ptr->user_transform_channels)
+      if (png_ptr->user_transform_channels != 0)
          info_ptr->channels = png_ptr->user_transform_channels;
    }
 #endif
@@ -2385,7 +2384,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
                if (++channel >= channels)
                   channel = 0;
                *bp++ = (png_byte)(value >> 8);
-               *bp++ = (png_byte)(value & 0xff);
+               *bp++ = (png_byte)value;
             }
             break;
          }
@@ -2410,8 +2409,8 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
 
       while (sp < ep)
       {
-         /* The input is an array of 16 bit components, these must be scaled to
-          * 8 bits each.  For a 16 bit value V the required value (from the PNG
+         /* The input is an array of 16-bit components, these must be scaled to
+          * 8 bits each.  For a 16-bit value V the required value (from the PNG
           * specification) is:
           *
           *    (V * 255) / 65535
@@ -2432,7 +2431,7 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
           *
           * The approximate differs from the exact answer only when (vlo-vhi) is
           * 128; it then gives a correction of +1 when the exact correction is
-          * 0.  This gives 128 errors.  The exact answer (correct for all 16 bit
+          * 0.  This gives 128 errors.  The exact answer (correct for all 16-bit
           * input values) is:
           *
           *    error = (vlo-vhi+128)*65535 >> 24;
@@ -2690,9 +2689,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
    png_uint_32 row_width = row_info->width;
 
 #ifdef PNG_READ_16BIT_SUPPORTED
-   png_byte hi_filler = (png_byte)((filler>>8) & 0xff);
+   png_byte hi_filler = (png_byte)(filler>>8);
 #endif
-   png_byte lo_filler = (png_byte)(filler & 0xff);
+   png_byte lo_filler = (png_byte)filler;
 
    png_debug(1, "in png_do_read_filler");
 
@@ -2743,13 +2742,13 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
             png_bytep dp = sp  + (png_size_t)row_width * 2;
             for (i = 1; i < row_width; i++)
             {
-               *(--dp) = hi_filler;
                *(--dp) = lo_filler;
+               *(--dp) = hi_filler;
                *(--dp) = *(--sp);
                *(--dp) = *(--sp);
             }
-            *(--dp) = hi_filler;
             *(--dp) = lo_filler;
+            *(--dp) = hi_filler;
             row_info->channels = 2;
             row_info->pixel_depth = 32;
             row_info->rowbytes = row_width * 4;
@@ -2764,8 +2763,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
             {
                *(--dp) = *(--sp);
                *(--dp) = *(--sp);
-               *(--dp) = hi_filler;
                *(--dp) = lo_filler;
+               *(--dp) = hi_filler;
             }
             row_info->channels = 2;
             row_info->pixel_depth = 32;
@@ -2824,8 +2823,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
             png_bytep dp = sp  + (png_size_t)row_width * 2;
             for (i = 1; i < row_width; i++)
             {
-               *(--dp) = hi_filler;
                *(--dp) = lo_filler;
+               *(--dp) = hi_filler;
                *(--dp) = *(--sp);
                *(--dp) = *(--sp);
                *(--dp) = *(--sp);
@@ -2833,8 +2832,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
                *(--dp) = *(--sp);
                *(--dp) = *(--sp);
             }
-            *(--dp) = hi_filler;
             *(--dp) = lo_filler;
+            *(--dp) = hi_filler;
             row_info->channels = 4;
             row_info->pixel_depth = 64;
             row_info->rowbytes = row_width * 8;
@@ -2853,8 +2852,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
                *(--dp) = *(--sp);
                *(--dp) = *(--sp);
                *(--dp) = *(--sp);
-               *(--dp) = hi_filler;
                *(--dp) = lo_filler;
+               *(--dp) = hi_filler;
             }
 
             row_info->channels = 4;
@@ -3115,10 +3114,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
             for (i = 0; i < row_width; i++)
             {
                png_uint_16 red, green, blue, w;
+               png_byte hi,lo;
 
-               red   = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
-               green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
-               blue  = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
+               hi=*(sp)++; lo=*(sp)++; red   = (png_uint_16)((hi << 8) | (lo));
+               hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
+               hi=*(sp)++; lo=*(sp)++; blue  = (png_uint_16)((hi << 8) | (lo));
 
                if (red == green && red == blue)
                {
@@ -3132,16 +3132,16 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
 
                else
                {
-                  png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red&0xff)
+                  png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red & 0xff)
                       >> png_ptr->gamma_shift][red>>8];
                   png_uint_16 green_1 =
-                      png_ptr->gamma_16_to_1[(green&0xff) >>
+                      png_ptr->gamma_16_to_1[(green & 0xff) >>
                       png_ptr->gamma_shift][green>>8];
-                  png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff)
+                  png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue & 0xff)
                       >> png_ptr->gamma_shift][blue>>8];
                   png_uint_16 gray16  = (png_uint_16)((rc*red_1 + gc*green_1
                       + bc*blue_1 + 16384)>>15);
-                  w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
+                  w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >>
                       png_ptr->gamma_shift][gray16 >> 8];
                   rgb_error |= 1;
                }
@@ -3166,17 +3166,18 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
             for (i = 0; i < row_width; i++)
             {
                png_uint_16 red, green, blue, gray16;
+               png_byte hi,lo;
 
-               red   = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
-               green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
-               blue  = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
+               hi=*(sp)++; lo=*(sp)++; red   = (png_uint_16)((hi << 8) | (lo));
+               hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
+               hi=*(sp)++; lo=*(sp)++; blue  = (png_uint_16)((hi << 8) | (lo));
 
                if (red != green || red != blue)
                   rgb_error |= 1;
 
-               /* From 1.5.5 in the 16 bit case do the accurate conversion even
+               /* From 1.5.5 in the 16-bit case do the accurate conversion even
                 * in the 'fast' case - this is because this is where the code
-                * ends up when handling linear 16 bit data.
+                * ends up when handling linear 16-bit data.
                 */
                gray16  = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
                   15);
@@ -3341,7 +3342,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
                         if ((png_uint_16)((*sp >> shift) & 0x0f)
                             == png_ptr->trans_color.gray)
                         {
-                           unsigned int tmp = *sp & (0xf0f >> (4 - shift));
+                           unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
                            tmp |= png_ptr->background.gray << shift;
                            *sp = (png_byte)(tmp & 0xff);
                         }
@@ -3351,7 +3352,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
                            unsigned int p = (*sp >> shift) & 0x0f;
                            unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
                               0x0f;
-                           unsigned int tmp = *sp & (0xf0f >> (4 - shift));
+                           unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
                            tmp |= g << shift;
                            *sp = (png_byte)(tmp & 0xff);
                         }
@@ -3377,7 +3378,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
                         if ((png_uint_16)((*sp >> shift) & 0x0f)
                             == png_ptr->trans_color.gray)
                         {
-                           unsigned int tmp = *sp & (0xf0f >> (4 - shift));
+                           unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
                            tmp |= png_ptr->background.gray << shift;
                            *sp = (png_byte)(tmp & 0xff);
                         }
@@ -3695,7 +3696,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
                         if (optimize != 0)
                            w = v;
                         else
-                           w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
+                           w = gamma_16_from_1[(v & 0xff) >>
+                               gamma_shift][v >> 8];
                         *sp = (png_byte)((w >> 8) & 0xff);
                         *(sp + 1) = (png_byte)(w & 0xff);
                      }
@@ -3859,7 +3861,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
                         v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
                         png_composite_16(w, v, a, png_ptr->background_1.red);
                         if (optimize == 0)
-                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
+                           w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
                                 8];
                         *sp = (png_byte)((w >> 8) & 0xff);
                         *(sp + 1) = (png_byte)(w & 0xff);
@@ -3867,7 +3869,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
                         v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
                         png_composite_16(w, v, a, png_ptr->background_1.green);
                         if (optimize == 0)
-                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
+                           w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
                                 8];
 
                         *(sp + 2) = (png_byte)((w >> 8) & 0xff);
@@ -3876,7 +3878,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
                         v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
                         png_composite_16(w, v, a, png_ptr->background_1.blue);
                         if (optimize == 0)
-                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
+                           w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
                                 8];
 
                         *(sp + 4) = (png_byte)((w >> 8) & 0xff);
@@ -4485,7 +4487,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
 
                for (i = 0; i < row_width; i++)
                {
-                  if (*sp == gray)
+                  if ((*sp & 0xffU) == gray)
                      *dp-- = 0;
 
                   else
@@ -4503,7 +4505,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
                dp = row + (row_info->rowbytes << 1) - 1;
                for (i = 0; i < row_width; i++)
                {
-                  if (*(sp - 1) == gray_high && *(sp) == gray_low)
+                  if ((*(sp - 1) & 0xffU) == gray_high &&
+                      (*(sp) & 0xffU) == gray_low)
                   {
                      *dp-- = 0;
                      *dp-- = 0;
@@ -4865,7 +4868,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
       /* Because PNG_COMPOSE does the gamma transform if there is something to
        * do (if there is an alpha channel or transparency.)
        */
-       !((png_ptr->transformations & PNG_COMPOSE) &&
+       !((png_ptr->transformations & PNG_COMPOSE) != 0 &&
        ((png_ptr->num_trans != 0) ||
        (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
 #endif
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c
index 68e5caff89c..a2e58468a68 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.20 [December 3, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -117,7 +117,13 @@ png_get_int_32)(png_const_bytep buf)
       return uval;
 
    uval = (uval ^ 0xffffffff) + 1;  /* 2's complement: -x = ~x+1 */
-   return -(png_int_32)uval;
+   if ((uval & 0x80000000) == 0) /* no overflow */
+       return -(png_int_32)uval;
+   /* The following has to be safe; this function only gets called on PNG data
+    * and if we get here that data is invalid.  0 is the most safe value and
+    * if not then an attacker would surely just generate a PNG with 0 instead.
+    */
+   return 0;
 }
 
 /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
@@ -126,7 +132,7 @@ png_get_uint_16)(png_const_bytep buf)
 {
    /* ANSI-C requires an int value to accomodate at least 16 bits so this
     * works and allows the compiler not to worry about possible narrowing
-    * on 32 bit systems.  (Pre-ANSI systems did not make integers smaller
+    * on 32-bit systems.  (Pre-ANSI systems did not make integers smaller
     * than 16 bits either.)
     */
    unsigned int val =
@@ -369,7 +375,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
        * are minimal.
        */
       (void)png_safecat(msg, (sizeof msg), 4, " using zstream");
-#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+#if PNG_RELEASE_BUILD
       png_chunk_warning(png_ptr, msg);
       png_ptr->zowner = 0;
 #else
@@ -399,10 +405,16 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
 
       if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
           PNG_OPTION_ON)
+      {
          window_bits = 15;
+         png_ptr->zstream_start = 0; /* fixed window size */
+      }
 
       else
+      {
          window_bits = 0;
+         png_ptr->zstream_start = 1;
+      }
 # else
 #   define window_bits 0
 # endif
@@ -451,6 +463,31 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
 #endif
 }
 
+#if PNG_ZLIB_VERNUM >= 0x1240
+/* Handle the start of the inflate stream if we called inflateInit2(strm,0);
+ * in this case some zlib versions skip validation of the CINFO field and, in
+ * certain circumstances, libpng may end up displaying an invalid image, in
+ * contrast to implementations that call zlib in the normal way (e.g. libpng
+ * 1.5).
+ */
+int /* PRIVATE */
+png_zlib_inflate(png_structrp png_ptr, int flush)
+{
+   if (png_ptr->zstream_start && png_ptr->zstream.avail_in > 0)
+   {
+      if ((*png_ptr->zstream.next_in >> 4) > 7)
+      {
+         png_ptr->zstream.msg = "invalid window size (libpng)";
+         return Z_DATA_ERROR;
+      }
+
+      png_ptr->zstream_start = 0;
+   }
+
+   return inflate(&png_ptr->zstream, flush);
+}
+#endif /* Zlib >= 1.2.4 */
+
 #ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
 /* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to
  * allow the caller to do multiple calls if required.  If the 'finish' flag is
@@ -544,7 +581,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
           * the previous chunk of input data.  Tell zlib if we have reached the
           * end of the output buffer.
           */
-         ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH :
+         ret = PNG_INFLATE(png_ptr, avail_out > 0 ? Z_NO_FLUSH :
              (finish ? Z_FINISH : Z_SYNC_FLUSH));
       } while (ret == Z_OK);
 
@@ -603,7 +640,7 @@ png_decompress_chunk(png_structrp png_ptr,
     */
    png_alloc_size_t limit = PNG_SIZE_MAX;
 
-# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
+# ifdef PNG_SET_USER_LIMITS_SUPPORTED
    if (png_ptr->user_chunk_malloc_max > 0 &&
        png_ptr->user_chunk_malloc_max < limit)
       limit = png_ptr->user_chunk_malloc_max;
@@ -698,7 +735,6 @@ png_decompress_chunk(png_structrp png_ptr,
                    * success)
                    */
                   png_free(png_ptr, text);
-                  text = NULL;
 
                   /* This really is very benign, but it's still an error because
                    * the extra space may otherwise be used as a Trojan Horse.
@@ -794,7 +830,7 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
           * the available output is produced; this allows reading of truncated
           * streams.
           */
-         ret = inflate(&png_ptr->zstream,
+         ret = PNG_INFLATE(png_ptr,
             *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
       }
       while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
@@ -895,7 +931,7 @@ void /* PRIVATE */
 png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 {
    png_color palette[PNG_MAX_PALETTE_LENGTH];
-   int num, i;
+   int max_palette_length, num, i;
 #ifdef PNG_POINTER_INDEXING_SUPPORTED
    png_colorp pal_ptr;
 #endif
@@ -956,6 +992,19 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
    /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */
    num = (int)length / 3;
 
+   /* If the palette has 256 or fewer entries but is too large for the bit
+    * depth, we don't issue an error, to preserve the behavior of previous
+    * libpng versions. We silently truncate the unused extra palette entries
+    * here.
+    */
+   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+      max_palette_length = (1 << png_ptr->bit_depth);
+   else
+      max_palette_length = PNG_MAX_PALETTE_LENGTH;
+
+   if (num > max_palette_length)
+      num = max_palette_length;
+
 #ifdef PNG_POINTER_INDEXING_SUPPORTED
    for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
    {
@@ -988,7 +1037,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
    if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
 #endif
    {
-      png_crc_finish(png_ptr, 0);
+      png_crc_finish(png_ptr, (int) length - num * 3);
    }
 
 #ifndef PNG_READ_OPT_PLTE_SUPPORTED
@@ -1175,11 +1224,13 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
       return;
 
    for (i=0; i sample_depth)
       {
          png_chunk_benign_error(png_ptr, "invalid");
          return;
       }
+   }
 
    if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
    {
@@ -1490,10 +1541,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
                                     finished = 1;
 
 #                                   ifdef PNG_sRGB_SUPPORTED
-                                       /* Check for a match against sRGB */
-                                       png_icc_set_sRGB(png_ptr,
-                                          &png_ptr->colorspace, profile,
-                                          png_ptr->zstream.adler);
+                                    /* Check for a match against sRGB */
+                                    png_icc_set_sRGB(png_ptr,
+                                       &png_ptr->colorspace, profile,
+                                       png_ptr->zstream.adler);
 #                                   endif
 
                                     /* Steal the profile for info_ptr. */
@@ -1543,8 +1594,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
                                  else if (size > 0)
                                     errmsg = "truncated";
 
+#ifndef __COVERITY__
                                  else
                                     errmsg = png_ptr->zstream.msg;
+#endif
                               }
 
                               /* else png_icc_check_tag_table output an error */
@@ -1676,7 +1729,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
    ++entry_start;
 
    /* A sample depth should follow the separator, and we should be on it  */
-   if (entry_start > buffer + length - 2)
+   if (length < 2U || entry_start > buffer + (length - 2U))
    {
       png_warning(png_ptr, "malformed sPLT chunk");
       return;
@@ -1701,8 +1754,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
    if (dl > max_dl)
    {
-       png_warning(png_ptr, "sPLT chunk too long");
-       return;
+      png_warning(png_ptr, "sPLT chunk too long");
+      return;
    }
 
    new_palette.nentries = (png_int_32)(data_length / entry_size);
@@ -1712,8 +1765,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
    if (new_palette.entries == NULL)
    {
-       png_warning(png_ptr, "sPLT chunk requires too much memory");
-       return;
+      png_warning(png_ptr, "sPLT chunk requires too much memory");
+      return;
    }
 
 #ifdef PNG_POINTER_INDEXING_SUPPORTED
@@ -1843,7 +1896,8 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
          return;
       }
 
-      if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH ||
+      if (length > (unsigned int) png_ptr->num_palette ||
+         length > (unsigned int) PNG_MAX_PALETTE_LENGTH ||
          length == 0)
       {
          png_crc_finish(png_ptr, length);
@@ -2006,7 +2060,8 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
 
    num = length / 2 ;
 
-   if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH)
+   if (num != (unsigned int) png_ptr->num_palette ||
+       num > (unsigned int) PNG_MAX_PALETTE_LENGTH)
    {
       png_crc_finish(png_ptr, length);
       png_chunk_benign_error(png_ptr, "invalid");
@@ -2178,7 +2233,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
    /* We need to have at least 12 bytes after the purpose string
     * in order to get the parameter information.
     */
-   if (endptr <= buf + 12)
+   if (endptr - buf <= 12)
    {
       png_chunk_benign_error(png_ptr, "invalid");
       return;
@@ -2741,14 +2796,14 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
       png_ptr->unknown_chunk.data = NULL;
    }
 
-#  ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
-      if (png_ptr->user_chunk_malloc_max > 0 &&
-          png_ptr->user_chunk_malloc_max < limit)
-         limit = png_ptr->user_chunk_malloc_max;
+#  ifdef PNG_SET_USER_LIMITS_SUPPORTED
+   if (png_ptr->user_chunk_malloc_max > 0 &&
+       png_ptr->user_chunk_malloc_max < limit)
+      limit = png_ptr->user_chunk_malloc_max;
 
 #  elif PNG_USER_CHUNK_MALLOC_MAX > 0
-      if (PNG_USER_CHUNK_MALLOC_MAX < limit)
-         limit = PNG_USER_CHUNK_MALLOC_MAX;
+   if (PNG_USER_CHUNK_MALLOC_MAX < limit)
+      limit = PNG_USER_CHUNK_MALLOC_MAX;
 #  endif
 
    if (length <= limit)
@@ -2811,7 +2866,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
     */
 #  ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
 #     ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-         keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name);
+   keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name);
 #     endif
 #  endif
 
@@ -2820,153 +2875,153 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
     * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
     */
 #  ifdef PNG_READ_USER_CHUNKS_SUPPORTED
-      /* The user callback takes precedence over the chunk keep value, but the
-       * keep value is still required to validate a save of a critical chunk.
-       */
-      if (png_ptr->read_user_chunk_fn != NULL)
+   /* The user callback takes precedence over the chunk keep value, but the
+    * keep value is still required to validate a save of a critical chunk.
+    */
+   if (png_ptr->read_user_chunk_fn != NULL)
+   {
+      if (png_cache_unknown_chunk(png_ptr, length) != 0)
       {
-         if (png_cache_unknown_chunk(png_ptr, length) != 0)
+         /* Callback to user unknown chunk handler */
+         int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr,
+            &png_ptr->unknown_chunk);
+
+         /* ret is:
+          * negative: An error occurred; png_chunk_error will be called.
+          *     zero: The chunk was not handled, the chunk will be discarded
+          *           unless png_set_keep_unknown_chunks has been used to set
+          *           a 'keep' behavior for this particular chunk, in which
+          *           case that will be used.  A critical chunk will cause an
+          *           error at this point unless it is to be saved.
+          * positive: The chunk was handled, libpng will ignore/discard it.
+          */
+         if (ret < 0)
+            png_chunk_error(png_ptr, "error in user chunk");
+
+         else if (ret == 0)
          {
-            /* Callback to user unknown chunk handler */
-            int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr,
-               &png_ptr->unknown_chunk);
-
-            /* ret is:
-             * negative: An error occured, png_chunk_error will be called.
-             *     zero: The chunk was not handled, the chunk will be discarded
-             *           unless png_set_keep_unknown_chunks has been used to set
-             *           a 'keep' behavior for this particular chunk, in which
-             *           case that will be used.  A critical chunk will cause an
-             *           error at this point unless it is to be saved.
-             * positive: The chunk was handled, libpng will ignore/discard it.
+            /* If the keep value is 'default' or 'never' override it, but
+             * still error out on critical chunks unless the keep value is
+             * 'always'  While this is weird it is the behavior in 1.4.12.
+             * A possible improvement would be to obey the value set for the
+             * chunk, but this would be an API change that would probably
+             * damage some applications.
+             *
+             * The png_app_warning below catches the case that matters, where
+             * the application has not set specific save or ignore for this
+             * chunk or global save or ignore.
              */
-            if (ret < 0)
-               png_chunk_error(png_ptr, "error in user chunk");
-
-            else if (ret == 0)
+            if (keep < PNG_HANDLE_CHUNK_IF_SAFE)
             {
-               /* If the keep value is 'default' or 'never' override it, but
-                * still error out on critical chunks unless the keep value is
-                * 'always'  While this is weird it is the behavior in 1.4.12.
-                * A possible improvement would be to obey the value set for the
-                * chunk, but this would be an API change that would probably
-                * damage some applications.
-                *
-                * The png_app_warning below catches the case that matters, where
-                * the application has not set specific save or ignore for this
-                * chunk or global save or ignore.
-                */
-               if (keep < PNG_HANDLE_CHUNK_IF_SAFE)
+#              ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
+               if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)
                {
-#                 ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-                     if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)
-                     {
-                        png_chunk_warning(png_ptr, "Saving unknown chunk:");
-                        png_app_warning(png_ptr,
-                           "forcing save of an unhandled chunk;"
-                           " please call png_set_keep_unknown_chunks");
-                           /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */
-                     }
-#                 endif
-                  keep = PNG_HANDLE_CHUNK_IF_SAFE;
+                  png_chunk_warning(png_ptr, "Saving unknown chunk:");
+                  png_app_warning(png_ptr,
+                     "forcing save of an unhandled chunk;"
+                     " please call png_set_keep_unknown_chunks");
+                     /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */
                }
-            }
-
-            else /* chunk was handled */
-            {
-               handled = 1;
-               /* Critical chunks can be safely discarded at this point. */
-               keep = PNG_HANDLE_CHUNK_NEVER;
+#              endif
+               keep = PNG_HANDLE_CHUNK_IF_SAFE;
             }
          }
 
-         else
-            keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */
+         else /* chunk was handled */
+         {
+            handled = 1;
+            /* Critical chunks can be safely discarded at this point. */
+            keep = PNG_HANDLE_CHUNK_NEVER;
+         }
       }
 
       else
-         /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */
+         keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */
+   }
+
+   else
+   /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */
 #  endif /* READ_USER_CHUNKS */
 
 #  ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
+   {
+      /* keep is currently just the per-chunk setting, if there was no
+       * setting change it to the global default now (not that this may
+       * still be AS_DEFAULT) then obtain the cache of the chunk if required,
+       * if not simply skip the chunk.
+       */
+      if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
+         keep = png_ptr->unknown_default;
+
+      if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
+         (keep == PNG_HANDLE_CHUNK_IF_SAFE &&
+          PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
       {
-         /* keep is currently just the per-chunk setting, if there was no
-          * setting change it to the global default now (not that this may
-          * still be AS_DEFAULT) then obtain the cache of the chunk if required,
-          * if not simply skip the chunk.
-          */
-         if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
-            keep = png_ptr->unknown_default;
-
-         if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
-            (keep == PNG_HANDLE_CHUNK_IF_SAFE &&
-             PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
-         {
-            if (png_cache_unknown_chunk(png_ptr, length) == 0)
-               keep = PNG_HANDLE_CHUNK_NEVER;
-         }
-
-         else
-            png_crc_finish(png_ptr, length);
+         if (png_cache_unknown_chunk(png_ptr, length) == 0)
+            keep = PNG_HANDLE_CHUNK_NEVER;
       }
+
+      else
+         png_crc_finish(png_ptr, length);
+   }
 #  else
 #     ifndef PNG_READ_USER_CHUNKS_SUPPORTED
 #        error no method to support READ_UNKNOWN_CHUNKS
 #     endif
 
-      {
-         /* If here there is no read callback pointer set and no support is
-          * compiled in to just save the unknown chunks, so simply skip this
-          * chunk.  If 'keep' is something other than AS_DEFAULT or NEVER then
-          * the app has erroneously asked for unknown chunk saving when there
-          * is no support.
-          */
-         if (keep > PNG_HANDLE_CHUNK_NEVER)
-            png_app_error(png_ptr, "no unknown chunk support available");
+   {
+      /* If here there is no read callback pointer set and no support is
+       * compiled in to just save the unknown chunks, so simply skip this
+       * chunk.  If 'keep' is something other than AS_DEFAULT or NEVER then
+       * the app has erroneously asked for unknown chunk saving when there
+       * is no support.
+       */
+      if (keep > PNG_HANDLE_CHUNK_NEVER)
+         png_app_error(png_ptr, "no unknown chunk support available");
 
-         png_crc_finish(png_ptr, length);
-      }
+      png_crc_finish(png_ptr, length);
+   }
 #  endif
 
 #  ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-      /* Now store the chunk in the chunk list if appropriate, and if the limits
-       * permit it.
-       */
-      if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
-         (keep == PNG_HANDLE_CHUNK_IF_SAFE &&
-          PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
+   /* Now store the chunk in the chunk list if appropriate, and if the limits
+    * permit it.
+    */
+   if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
+      (keep == PNG_HANDLE_CHUNK_IF_SAFE &&
+       PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
+   {
+#     ifdef PNG_USER_LIMITS_SUPPORTED
+      switch (png_ptr->user_chunk_cache_max)
       {
-#     ifdef PNG_USER_LIMITS_SUPPORTED
-         switch (png_ptr->user_chunk_cache_max)
-         {
-            case 2:
-               png_ptr->user_chunk_cache_max = 1;
-               png_chunk_benign_error(png_ptr, "no space in chunk cache");
-               /* FALL THROUGH */
-            case 1:
-               /* NOTE: prior to 1.6.0 this case resulted in an unknown critical
-                * chunk being skipped, now there will be a hard error below.
-                */
-               break;
+         case 2:
+            png_ptr->user_chunk_cache_max = 1;
+            png_chunk_benign_error(png_ptr, "no space in chunk cache");
+            /* FALL THROUGH */
+         case 1:
+            /* NOTE: prior to 1.6.0 this case resulted in an unknown critical
+             * chunk being skipped, now there will be a hard error below.
+             */
+            break;
 
-            default: /* not at limit */
-               --(png_ptr->user_chunk_cache_max);
-               /* FALL THROUGH */
-            case 0: /* no limit */
-#     endif /* USER_LIMITS */
-               /* Here when the limit isn't reached or when limits are compiled
-                * out; store the chunk.
-                */
-               png_set_unknown_chunks(png_ptr, info_ptr,
-                  &png_ptr->unknown_chunk, 1);
-               handled = 1;
-#     ifdef PNG_USER_LIMITS_SUPPORTED
-               break;
-         }
-#     endif
+         default: /* not at limit */
+            --(png_ptr->user_chunk_cache_max);
+            /* FALL THROUGH */
+         case 0: /* no limit */
+#  endif /* USER_LIMITS */
+            /* Here when the limit isn't reached or when limits are compiled
+             * out; store the chunk.
+             */
+            png_set_unknown_chunks(png_ptr, info_ptr,
+               &png_ptr->unknown_chunk, 1);
+            handled = 1;
+#  ifdef PNG_USER_LIMITS_SUPPORTED
+            break;
       }
+#  endif
+   }
 #  else /* no store support: the chunk must be handled by the user callback */
-      PNG_UNUSED(info_ptr)
+   PNG_UNUSED(info_ptr)
 #  endif
 
    /* Regardless of the error handling below the cached data (if any) can be
@@ -3068,13 +3123,13 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
       end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1;
       end_byte = *end_ptr;
 #     ifdef PNG_READ_PACKSWAP_SUPPORTED
-         if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
-            /* little-endian byte */
-            end_mask = 0xff << end_mask;
+      if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
+         /* little-endian byte */
+         end_mask = 0xff << end_mask;
 
-         else /* big-endian byte */
+      else /* big-endian byte */
 #     endif
-         end_mask = 0xff >> end_mask;
+      end_mask = 0xff >> end_mask;
       /* end_mask is now the bits to *keep* from the destination row */
    }
 
@@ -3232,12 +3287,12 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
          png_uint_32 mask;
 
 #        ifdef PNG_READ_PACKSWAP_SUPPORTED
-            if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
-               mask = MASK(pass, pixel_depth, display, 0);
+         if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
+            mask = MASK(pass, pixel_depth, display, 0);
 
-            else
+         else
 #        endif
-            mask = MASK(pass, pixel_depth, display, 1);
+         mask = MASK(pass, pixel_depth, display, 1);
 
          for (;;)
          {
@@ -3838,15 +3893,15 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
       p = b - c;
       pc = a - c;
 
-#     ifdef PNG_USE_ABS
-         pa = abs(p);
-         pb = abs(pc);
-         pc = abs(p + pc);
-#     else
-         pa = p < 0 ? -p : p;
-         pb = pc < 0 ? -pc : pc;
-         pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#     endif
+#ifdef PNG_USE_ABS
+      pa = abs(p);
+      pb = abs(pc);
+      pc = abs(p + pc);
+#else
+      pa = p < 0 ? -p : p;
+      pb = pc < 0 ? -pc : pc;
+      pc = (p + pc) < 0 ? -(p + pc) : p + pc;
+#endif
 
       /* Find the best predictor, the least of pa, pb, pc favoring the earlier
        * ones in the case of a tie.
@@ -3893,15 +3948,15 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
       p = b - c;
       pc = a - c;
 
-#     ifdef PNG_USE_ABS
-         pa = abs(p);
-         pb = abs(pc);
-         pc = abs(p + pc);
-#     else
-         pa = p < 0 ? -p : p;
-         pb = pc < 0 ? -pc : pc;
-         pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#     endif
+#ifdef PNG_USE_ABS
+      pa = abs(p);
+      pb = abs(pc);
+      pc = abs(p + pc);
+#else
+      pa = p < 0 ? -p : p;
+      pb = pc < 0 ? -pc : pc;
+      pc = (p + pc) < 0 ? -(p + pc) : p + pc;
+#endif
 
       if (pb < pa) pa = pb, a = b;
       if (pc < pa) a = c;
@@ -4043,7 +4098,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
        *
        * TODO: deal more elegantly with truncated IDAT lists.
        */
-      ret = inflate(&png_ptr->zstream, Z_NO_FLUSH);
+      ret = PNG_INFLATE(png_ptr, Z_NO_FLUSH);
 
       /* Take the unconsumed output back. */
       if (output != NULL)
@@ -4306,18 +4361,18 @@ png_read_start_row(png_structrp png_ptr)
 #ifdef PNG_READ_EXPAND_16_SUPPORTED
    if ((png_ptr->transformations & PNG_EXPAND_16) != 0)
    {
-#     ifdef PNG_READ_EXPAND_SUPPORTED
-         /* In fact it is an error if it isn't supported, but checking is
-          * the safe way.
-          */
-         if ((png_ptr->transformations & PNG_EXPAND) != 0)
-         {
-            if (png_ptr->bit_depth < 16)
-               max_pixel_depth *= 2;
-         }
-         else
-#     endif
-         png_ptr->transformations &= ~PNG_EXPAND_16;
+#  ifdef PNG_READ_EXPAND_SUPPORTED
+      /* In fact it is an error if it isn't supported, but checking is
+       * the safe way.
+       */
+      if ((png_ptr->transformations & PNG_EXPAND) != 0)
+      {
+         if (png_ptr->bit_depth < 16)
+            max_pixel_depth *= 2;
+      }
+      else
+#  endif
+      png_ptr->transformations &= ~PNG_EXPAND_16;
    }
 #endif
 
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c
index d2c89b2a55f..748008eb70b 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.19 [November 12, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -151,12 +151,12 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
       png_fixed(png_ptr, red_X, "cHRM Red X"),
       png_fixed(png_ptr, red_Y, "cHRM Red Y"),
       png_fixed(png_ptr, red_Z, "cHRM Red Z"),
-      png_fixed(png_ptr, green_X, "cHRM Red X"),
-      png_fixed(png_ptr, green_Y, "cHRM Red Y"),
-      png_fixed(png_ptr, green_Z, "cHRM Red Z"),
-      png_fixed(png_ptr, blue_X, "cHRM Red X"),
-      png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
-      png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
+      png_fixed(png_ptr, green_X, "cHRM Green X"),
+      png_fixed(png_ptr, green_Y, "cHRM Green Y"),
+      png_fixed(png_ptr, green_Z, "cHRM Green Z"),
+      png_fixed(png_ptr, blue_X, "cHRM Blue X"),
+      png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
+      png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
 }
 #  endif /* FLOATING_POINT */
 
@@ -218,6 +218,7 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
    if (info_ptr->hist == NULL)
    {
       png_warning(png_ptr, "Insufficient memory for hIST chunk data");
+
       return;
    }
 
@@ -299,7 +300,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
    png_debug1(1, "in %s storage function", "pCAL");
 
    if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL
-      || (nparams > 0 && params == NULL))
+       || (nparams > 0 && params == NULL))
       return;
 
    length = strlen(purpose) + 1;
@@ -329,6 +330,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
    if (info_ptr->pcal_purpose == NULL)
    {
       png_warning(png_ptr, "Insufficient memory for pCAL purpose");
+
       return;
    }
 
@@ -350,6 +352,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
    if (info_ptr->pcal_units == NULL)
    {
       png_warning(png_ptr, "Insufficient memory for pCAL units");
+
       return;
    }
 
@@ -361,6 +364,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
    if (info_ptr->pcal_params == NULL)
    {
       png_warning(png_ptr, "Insufficient memory for pCAL params");
+
       return;
    }
 
@@ -377,6 +381,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
       if (info_ptr->pcal_params[i] == NULL)
       {
          png_warning(png_ptr, "Insufficient memory for pCAL parameter");
+
          return;
       }
 
@@ -426,6 +431,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
    if (info_ptr->scal_s_width == NULL)
    {
       png_warning(png_ptr, "Memory allocation failed while processing sCAL");
+
       return;
    }
 
@@ -444,6 +450,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
       info_ptr->scal_s_width = NULL;
 
       png_warning(png_ptr, "Memory allocation failed while processing sCAL");
+
       return;
    }
 
@@ -534,12 +541,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
     png_const_colorp palette, int num_palette)
 {
 
+   png_uint_32 max_palette_length;
+
    png_debug1(1, "in %s storage function", "PLTE");
 
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
-   if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
+   max_palette_length = (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
+      (1 << info_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
+
+   if (num_palette < 0 || num_palette > (int) max_palette_length)
    {
       if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
          png_error(png_ptr, "Invalid palette length");
@@ -547,6 +559,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
       else
       {
          png_warning(png_ptr, "Invalid palette length");
+
          return;
       }
    }
@@ -559,7 +572,6 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
       ))
    {
       png_error(png_ptr, "Invalid palette");
-      return;
    }
 
    /* It may not actually be necessary to set png_ptr->palette here;
@@ -572,8 +584,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
    png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
 
    /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
-    * of num_palette entries, in case of an invalid PNG file that has
-    * too-large sample values.
+    * of num_palette entries, in case of an invalid PNG file or incorrect
+    * call to png_set_PLTE() with too-large sample values.
     */
    png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
        PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
@@ -683,6 +695,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
    if (new_iccp_name == NULL)
    {
       png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
+
       return;
    }
 
@@ -693,9 +706,9 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
    if (new_iccp_profile == NULL)
    {
       png_free(png_ptr, new_iccp_name);
-      new_iccp_name = NULL;
       png_benign_error(png_ptr,
           "Insufficient memory to process iCCP profile");
+
       return;
    }
 
@@ -729,7 +742,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
 {
    int i;
 
-   png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
+   png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U :
       (unsigned long)png_ptr->chunk_name);
 
    if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
@@ -771,6 +784,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
       {
          png_chunk_report(png_ptr, "too many text chunks",
             PNG_CHUNK_WRITE_ERROR);
+
          return 1;
       }
 
@@ -826,7 +840,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
          else
             lang_key_len = 0;
       }
-#  else /* PNG_iTXt_SUPPORTED */
+#  else /* iTXt */
       {
          png_chunk_report(png_ptr, "iTXt chunk not supported",
             PNG_CHUNK_WRITE_ERROR);
@@ -859,6 +873,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
       {
          png_chunk_report(png_ptr, "text chunk: out of memory",
                PNG_CHUNK_WRITE_ERROR);
+
          return 1;
       }
 
@@ -932,6 +947,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
        mod_time->second > 60)
    {
       png_warning(png_ptr, "Ignoring invalid time value");
+
       return;
    }
 
@@ -948,6 +964,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
    png_debug1(1, "in %s storage function", "tRNS");
 
    if (png_ptr == NULL || info_ptr == NULL)
+
       return;
 
    if (trans_alpha != NULL)
@@ -973,16 +990,21 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
 
    if (trans_color != NULL)
    {
-      int sample_max = (1 << info_ptr->bit_depth);
+#ifdef PNG_WARNINGS_SUPPORTED
+      if (info_ptr->bit_depth < 16)
+      {
+         int sample_max = (1 << info_ptr->bit_depth) - 1;
 
-      if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
-          trans_color->gray > sample_max) ||
-          (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
-          (trans_color->red > sample_max ||
-          trans_color->green > sample_max ||
-          trans_color->blue > sample_max)))
-         png_warning(png_ptr,
-            "tRNS chunk has out-of-range samples for bit_depth");
+         if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
+             trans_color->gray > sample_max) ||
+             (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
+             (trans_color->red > sample_max ||
+             trans_color->green > sample_max ||
+             trans_color->blue > sample_max)))
+            png_warning(png_ptr,
+               "tRNS chunk has out-of-range samples for bit_depth");
+      }
+#endif
 
       info_ptr->trans_color = *trans_color;
 
@@ -1029,6 +1051,7 @@ png_set_sPLT(png_const_structrp png_ptr,
    {
       /* Out of memory or too many chunks */
       png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
+
       return;
    }
 
@@ -1144,7 +1167,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
    png_unknown_chunkp np;
 
    if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
-      unknowns == NULL)
+       unknowns == NULL)
       return;
 
    /* Check for the failure cases where support has been disabled at compile
@@ -1158,6 +1181,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
       if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
       {
          png_app_error(png_ptr, "no unknown chunk support on read");
+
          return;
       }
 #  endif
@@ -1166,6 +1190,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
       if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
       {
          png_app_error(png_ptr, "no unknown chunk support on write");
+
          return;
       }
 #  endif
@@ -1183,6 +1208,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
    {
       png_chunk_report(png_ptr, "too many unknown chunks",
          PNG_CHUNK_WRITE_ERROR);
+
       return;
    }
 
@@ -1260,8 +1286,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
          check_location(png_ptr, location);
    }
 }
-#endif
-
+#endif /* STORE_UNKNOWN_CHUNKS */
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
 png_uint_32 PNGAPI
@@ -1292,6 +1317,7 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
       if (memcmp(list, add, 4) == 0)
       {
          list[4] = (png_byte)keep;
+
          return count;
       }
    }
@@ -1319,6 +1345,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
    if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
    {
       png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
+
       return;
    }
 
@@ -1368,6 +1395,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
           * which can be switched off.
           */
          png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
+
          return;
       }
 
@@ -1383,6 +1411,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
    if (num_chunks + old_num_chunks > UINT_MAX/5)
    {
       png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
+
       return;
    }
 
@@ -1520,23 +1549,30 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
          {
             png_warning(png_ptr,
               "Compression buffer size cannot be changed because it is in use");
+
             return;
          }
 
+#ifndef __COVERITY__
+         /* Some compilers complain that this is always false.  However, it
+          * can be true when integer overflow happens.
+          */
          if (size > ZLIB_IO_MAX)
          {
             png_warning(png_ptr,
                "Compression buffer size limited to system maximum");
             size = ZLIB_IO_MAX; /* must fit */
          }
+#endif
 
-         else if (size < 6)
+         if (size < 6)
          {
             /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
              * if this is permitted.
              */
             png_warning(png_ptr,
                "Compression buffer size cannot be reduced below 6");
+
             return;
          }
 
@@ -1565,7 +1601,7 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
 {
    /* Images with dimensions larger than these limits will be
     * rejected by png_set_IHDR().  To accept any PNG datastream
-    * regardless of dimensions, set both limits to 0x7ffffffL.
+    * regardless of dimensions, set both limits to 0x7fffffff.
     */
    if (png_ptr == NULL)
       return;
@@ -1578,8 +1614,8 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
 void PNGAPI
 png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
 {
-    if (png_ptr != NULL)
-       png_ptr->user_chunk_cache_max = user_chunk_cache_max;
+   if (png_ptr != NULL)
+      png_ptr->user_chunk_cache_max = user_chunk_cache_max;
 }
 
 /* This function was added to libpng 1.4.1 */
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h
index 8670a5a4e8d..e47c02d6fa6 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h
@@ -29,12 +29,11 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Copyright (c) 1998-2013 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.18 [July 23, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.6.1 [March 28, 2013]
- *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
@@ -129,7 +128,7 @@ typedef struct png_XYZ
 #endif /* COLORSPACE */
 
 #if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
-/* A colorspace is all the above plus, potentially, profile information,
+/* A colorspace is all the above plus, potentially, profile information;
  * however at present libpng does not use the profile internally so it is only
  * stored in the png_info struct (if iCCP is supported.)  The rendering intent
  * is retained here and is checked.
@@ -248,16 +247,18 @@ struct png_struct_def
    png_uint_32 row_number;    /* current row in interlace pass */
    png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */
    png_bytep prev_row;        /* buffer to save previous (unfiltered) row.
-                               * This is a pointer into big_prev_row
+                               * While reading this is a pointer into
+                               * big_prev_row; while writing it is separately
+                               * allocated if needed.
                                */
    png_bytep row_buf;         /* buffer to save current (unfiltered) row.
-                               * This is a pointer into big_row_buf
+                               * While reading, this is a pointer into
+                               * big_row_buf; while writing it is separately
+                               * allocated.
                                */
-#ifdef PNG_WRITE_SUPPORTED
-   png_bytep sub_row;         /* buffer to save "sub" row when filtering */
-   png_bytep up_row;          /* buffer to save "up" row when filtering */
-   png_bytep avg_row;         /* buffer to save "avg" row when filtering */
-   png_bytep paeth_row;       /* buffer to save "Paeth" row when filtering */
+#ifdef PNG_WRITE_FILTER_SUPPORTED
+   png_bytep try_row;    /* buffer to save trial row when filtering */
+   png_bytep tst_row;    /* buffer to save best trial row when filtering */
 #endif
    png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */
 
@@ -290,6 +291,9 @@ struct png_struct_def
                               /* pixel depth used for the row buffers */
    png_byte transformed_pixel_depth;
                               /* pixel depth after read/write transforms */
+#if PNG_ZLIB_VERNUM >= 0x1240
+   png_byte zstream_start;    /* at start of an input zlib stream */
+#endif /* Zlib >= 1.2.4 */
 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
    png_uint_16 filler;           /* filler bytes for pixel expansion */
 #endif
@@ -375,17 +379,7 @@ struct png_struct_def
    png_bytep quantize_index; /* index translation for palette files */
 #endif
 
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-   png_byte heuristic_method;        /* heuristic for row filter selection */
-   png_byte num_prev_filters;        /* number of weights for previous rows */
-   png_bytep prev_filters;           /* filter type(s) of previous row(s) */
-   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */
-   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */
-   png_uint_16p filter_costs;        /* relative filter calculation cost */
-   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */
-#endif
-
-   /* Options */
+/* Options */
 #ifdef PNG_SET_OPTION_SUPPORTED
    png_byte options;           /* On/off state (up to 4 options) */
 #endif
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtest.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtest.c
index fdd51acd04d..ef3a4ab0e50 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtest.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtest.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.25 [December 3, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -89,10 +89,11 @@
    defined PNG_READ_sBIT_SUPPORTED &&\
    defined PNG_READ_sCAL_SUPPORTED &&\
    defined PNG_READ_sRGB_SUPPORTED &&\
+   defined PNG_READ_sPLT_SUPPORTED &&\
    defined PNG_READ_tEXt_SUPPORTED &&\
    defined PNG_READ_tIME_SUPPORTED &&\
    defined PNG_READ_zTXt_SUPPORTED &&\
-   defined PNG_WRITE_INTERLACING_SUPPORTED
+   (defined PNG_WRITE_INTERLACING_SUPPORTED || PNG_LIBPNG_VER >= 10700)
 
 #ifdef PNG_ZLIB_HEADER
 #  include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */
@@ -129,6 +130,10 @@ typedef FILE                * png_FILE_p;
 #  define SINGLE_ROWBUF_ALLOC  /* Makes buffer overruns easier to nail */
 #endif
 
+#ifndef PNG_UNUSED
+#  define PNG_UNUSED(param) (void)param;
+#endif
+
 /* Turn on CPU timing
 #define PNGTEST_TIMING
 */
@@ -146,6 +151,22 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
 #define PNG_tIME_STRING_LENGTH 29
 static int tIME_chunk_present = 0;
 static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
+
+#if PNG_LIBPNG_VER < 10619
+#define png_convert_to_rfc1123_buffer(ts, t) tIME_to_str(read_ptr, ts, t)
+
+static int
+tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t)
+{
+    png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
+
+    if (str == NULL)
+        return 0;
+
+    strcpy(ts, str);
+    return 1;
+}
+#endif /* older libpng */
 #endif
 
 static int verbose = 0;
@@ -213,16 +234,14 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 
 
 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-/* Example of using user transform callback (we don't transform anything,
- * but merely examine the row filters.  We set this to 256 rather than
- * 5 in case illegal filter values are present.)
+/* Example of using a user transform callback (doesn't do anything at present).
  */
-static png_uint_32 filters_used[256];
 static void PNGCBAPI
-count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
+read_user_callback(png_structp png_ptr, png_row_infop row_info, png_bytep data)
 {
-   if (png_ptr != NULL && row_info != NULL)
-      ++filters_used[*(data - 1)];
+   PNG_UNUSED(png_ptr)
+   PNG_UNUSED(row_info)
+   PNG_UNUSED(data)
 }
 #endif
 
@@ -497,7 +516,7 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
 
 /* Allocate memory.  For reasonable files, size should never exceed
- * 64K.  However, zlib may allocate more then 64K if you don't tell
+ * 64K.  However, zlib may allocate more than 64K if you don't tell
  * it not to.  See zconf.h and png.h for more information.  zlib does
  * need to allocate exactly 64K, so whatever you call here must
  * have the ability to do that.
@@ -593,6 +612,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
    }
 
    /* Unlink the element from the list. */
+   if (pinformation != NULL)
    {
       memory_infop *ppinfo = &pinformation;
 
@@ -609,8 +629,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
             /* We must free the list element too, but first kill
                the memory that is to be freed. */
             memset(ptr, 0x55, pinfo->size);
-            if (pinfo != NULL)
-               free(pinfo);
+            free(pinfo);
             pinfo = NULL;
             break;
          }
@@ -820,7 +839,7 @@ write_chunks(png_structp write_ptr, int location)
  */
 #ifdef PNG_TEXT_SUPPORTED
 static void
-pngtest_check_text_support(png_const_structp png_ptr, png_textp text_ptr,
+pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
    int num_text)
 {
    while (num_text > 0)
@@ -833,6 +852,8 @@ pngtest_check_text_support(png_const_structp png_ptr, png_textp text_ptr,
          case PNG_TEXT_COMPRESSION_zTXt:
 #           ifndef PNG_WRITE_zTXt_SUPPORTED
                ++unsupported_chunks;
+               /* In libpng 1.7 this now does an app-error, so stop it: */
+               text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE;
 #           endif
             break;
 
@@ -840,6 +861,7 @@ pngtest_check_text_support(png_const_structp png_ptr, png_textp text_ptr,
          case PNG_ITXT_COMPRESSION_zTXt:
 #           ifndef PNG_WRITE_iTXt_SUPPORTED
                ++unsupported_chunks;
+               text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE;
 #           endif
             break;
 
@@ -866,16 +888,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
    png_structp write_ptr;
    png_infop write_info_ptr;
    png_infop write_end_info_ptr;
+#ifdef PNG_WRITE_FILTER_SUPPORTED
    int interlace_preserved = 1;
-#else
+#endif /* WRITE_FILTER */
+#else /* !WRITE */
    png_structp write_ptr = NULL;
    png_infop write_info_ptr = NULL;
    png_infop write_end_info_ptr = NULL;
-#endif
+#endif /* !WRITE */
    png_bytep row_buf;
    png_uint_32 y;
    png_uint_32 width, height;
-   int num_pass = 1, pass;
+   volatile int num_passes;
+   int pass;
    int bit_depth, color_type;
 
    row_buf = NULL;
@@ -1028,14 +1053,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
    }
 
 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-   {
-      int i;
-
-      for (i = 0; i<256; i++)
-         filters_used[i] = 0;
-
-      png_set_read_user_transform_fn(read_ptr, count_filters);
-   }
+   png_set_read_user_transform_fn(read_ptr, read_user_callback);
 #endif
 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
    zero_samples = 0;
@@ -1082,27 +1100,27 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
       {
          png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
             color_type, interlace_type, compression_type, filter_type);
-#ifndef PNG_READ_INTERLACING_SUPPORTED
-         /* num_pass will not be set below, set it here if the image is
-          * interlaced: what happens is that write interlacing is *not* turned
-          * on an the partial interlaced rows are written directly.
+         /* num_passes may not be available below if interlace support is not
+          * provided by libpng for both read and write.
           */
          switch (interlace_type)
          {
             case PNG_INTERLACE_NONE:
-               num_pass = 1;
+               num_passes = 1;
                break;
 
             case PNG_INTERLACE_ADAM7:
-               num_pass = 7;
-                break;
+               num_passes = 7;
+               break;
 
             default:
-                png_error(read_ptr, "invalid interlace type");
-                /*NOT REACHED*/
+               png_error(read_ptr, "invalid interlace type");
+               /*NOT REACHED*/
          }
-#endif
       }
+
+      else
+         png_error(read_ptr, "png_get_IHDR failed");
    }
 #ifdef PNG_FIXED_POINT_SUPPORTED
 #ifdef PNG_cHRM_SUPPORTED
@@ -1273,6 +1291,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
 #endif
 #endif
 #endif
+
+#ifdef PNG_sPLT_SUPPORTED
+   {
+       png_sPLT_tp entries;
+
+       int num_entries = (int) png_get_sPLT(read_ptr, read_info_ptr, &entries);
+       if (num_entries)
+       {
+           png_set_sPLT(write_ptr, write_info_ptr, entries, num_entries);
+       }
+   }
+#endif
+
 #ifdef PNG_TEXT_SUPPORTED
    {
       png_textp text_ptr;
@@ -1394,21 +1425,49 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
 #endif /* SINGLE_ROWBUF_ALLOC */
    pngtest_debug("Writing row data");
 
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-   num_pass = png_set_interlace_handling(read_ptr);
-   if (png_set_interlace_handling(write_ptr) != num_pass)
-      png_error(write_ptr, "png_set_interlace_handling: inconsistent num_pass");
-#endif
+#if defined(PNG_READ_INTERLACING_SUPPORTED) &&\
+   defined(PNG_WRITE_INTERLACING_SUPPORTED)
+   /* Both must be defined for libpng to be able to handle the interlace,
+    * otherwise it gets handled below by simply reading and writing the passes
+    * directly.
+    */
+   if (png_set_interlace_handling(read_ptr) != num_passes)
+      png_error(write_ptr,
+            "png_set_interlace_handling(read): wrong pass count ");
+   if (png_set_interlace_handling(write_ptr) != num_passes)
+      png_error(write_ptr,
+            "png_set_interlace_handling(write): wrong pass count ");
+#else /* png_set_interlace_handling not called on either read or write */
+#  define calc_pass_height
+#endif /* not using libpng interlace handling */
 
 #ifdef PNGTEST_TIMING
    t_stop = (float)clock();
    t_misc += (t_stop - t_start);
    t_start = t_stop;
 #endif
-   for (pass = 0; pass < num_pass; pass++)
+   for (pass = 0; pass < num_passes; pass++)
    {
+#     ifdef calc_pass_height
+         png_uint_32 pass_height;
+
+         if (num_passes == 7) /* interlaced */
+         {
+            if (PNG_PASS_COLS(width, pass) > 0)
+               pass_height = PNG_PASS_ROWS(height, pass);
+
+            else
+               pass_height = 0;
+         }
+
+         else /* not interlaced */
+            pass_height = height;
+#     else
+#        define pass_height height
+#     endif
+
       pngtest_debug1("Writing row data for pass %d", pass);
-      for (y = 0; y < height; y++)
+      for (y = 0; y < pass_height; y++)
       {
 #ifndef SINGLE_ROWBUF_ALLOC
          pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
@@ -1598,7 +1657,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
    }
 
 #  ifdef PNG_WRITE_SUPPORTED
-      /* If there we no write support nothing was written! */
+      /* If there is no write support nothing was written! */
       else if (unsupported_chunks > 0)
       {
          fprintf(STDERR, "\n  %s: unsupported chunks (%d)%s",
@@ -1629,7 +1688,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
       return (1);
    }
 
-#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */
+#if defined (PNG_WRITE_SUPPORTED) /* else nothing was written */ &&\
+    defined (PNG_WRITE_FILTER_SUPPORTED)
    if (interlace_preserved != 0) /* else the files will be changed */
    {
       for (;;)
@@ -1706,7 +1766,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
          }
       }
    }
-#endif /* WRITE */
+#endif /* WRITE && WRITE_FILTER */
 
    FCLOSE(fpin);
    FCLOSE(fpout);
@@ -1729,6 +1789,8 @@ main(int argc, char *argv[])
    int multiple = 0;
    int ierror = 0;
 
+   png_structp dummy_ptr;
+
    fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
    fprintf(STDERR, "   with zlib   version %s\n", ZLIB_VERSION);
    fprintf(STDERR, "%s", png_get_copyright(NULL));
@@ -1843,26 +1905,17 @@ main(int argc, char *argv[])
          kerror = test_one_file(argv[i], outname);
          if (kerror == 0)
          {
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-            int k;
-#endif
 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
             fprintf(STDERR, "\n PASS (%lu zero samples)\n",
                (unsigned long)zero_samples);
 #else
             fprintf(STDERR, " PASS\n");
 #endif
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-            for (k = 0; k<256; k++)
-               if (filters_used[k] != 0)
-                  fprintf(STDERR, " Filter %d was used %lu times\n",
-                     k, (unsigned long)filters_used[k]);
-#endif
 #ifdef PNG_TIME_RFC1123_SUPPORTED
-         if (tIME_chunk_present != 0)
-            fprintf(STDERR, " tIME = %s\n", tIME_string);
+            if (tIME_chunk_present != 0)
+               fprintf(STDERR, " tIME = %s\n", tIME_string);
 
-         tIME_chunk_present = 0;
+            tIME_chunk_present = 0;
 #endif /* TIME_RFC1123 */
          }
 
@@ -1934,21 +1987,12 @@ main(int argc, char *argv[])
          {
             if (verbose == 1 || i == 2)
             {
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-                int k;
-#endif
 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
                 fprintf(STDERR, "\n PASS (%lu zero samples)\n",
                    (unsigned long)zero_samples);
 #else
                 fprintf(STDERR, " PASS\n");
 #endif
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-                for (k = 0; k<256; k++)
-                   if (filters_used[k] != 0)
-                      fprintf(STDERR, " Filter %d was used %lu times\n",
-                         k, (unsigned long)filters_used[k]);
-#endif
 #ifdef PNG_TIME_RFC1123_SUPPORTED
              if (tIME_chunk_present != 0)
                 fprintf(STDERR, " tIME = %s\n", tIME_string);
@@ -2022,6 +2066,24 @@ main(int argc, char *argv[])
    else
       fprintf(STDERR, " libpng FAILS test\n");
 
+   dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+   fprintf(STDERR, " Default limits:\n");
+   fprintf(STDERR, "  width_max  = %lu\n",
+      (unsigned long) png_get_user_width_max(dummy_ptr));
+   fprintf(STDERR, "  height_max = %lu\n",
+      (unsigned long) png_get_user_height_max(dummy_ptr));
+   if (png_get_chunk_cache_max(dummy_ptr) == 0)
+      fprintf(STDERR, "  cache_max  = unlimited\n");
+   else
+      fprintf(STDERR, "  cache_max  = %lu\n",
+         (unsigned long) png_get_chunk_cache_max(dummy_ptr));
+   if (png_get_chunk_malloc_max(dummy_ptr) == 0)
+      fprintf(STDERR, "  malloc_max = unlimited\n");
+   else
+      fprintf(STDERR, "  malloc_max = %lu\n",
+         (unsigned long) png_get_chunk_malloc_max(dummy_ptr));
+   png_destroy_read_struct(&dummy_ptr, NULL, NULL);
+
    return (int)(ierror != 0);
 }
 #else
@@ -2036,4 +2098,4 @@ main(void)
 #endif
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_16 Your_png_h_is_not_version_1_6_16;
+typedef png_libpng_version_1_6_20 Your_png_h_is_not_version_1_6_20;
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c
index 5b95db8c66b..d6016df53ec 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.18 [July 23, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -58,7 +58,7 @@ png_set_bgr(png_structrp png_ptr)
 #endif
 
 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* Turn on 16 bit byte swapping */
+/* Turn on 16-bit byte swapping */
 void PNGAPI
 png_set_swap(png_structrp png_ptr)
 {
@@ -341,7 +341,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
 
 #ifdef PNG_16BIT_SUPPORTED
 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* Swaps byte order on 16 bit depth images */
+/* Swaps byte order on 16-bit depth images */
 void /* PRIVATE */
 png_do_swap(png_row_infop row_info, png_bytep row)
 {
@@ -732,7 +732,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
              */
             for (; rp > png_ptr->row_buf; rp--)
             {
-              if (*rp >> padding != 0)
+              if ((*rp >> padding) != 0)
                  png_ptr->num_palette_max = 1;
               padding = 0;
             }
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwio.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwio.c
index 017a9d7b31b..7268523c3f9 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwio.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwio.c
@@ -54,7 +54,7 @@
  * writes to a file pointer.  Note that this routine sometimes gets called
  * with very small lengths, so you should implement some kind of simple
  * buffering if you are using unbuffered writes.  This should never be asked
- * to write more than 64K on a 16 bit machine.
+ * to write more than 64K on a 16-bit machine.
  */
 
 void /* PRIVATE */
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwrite.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwrite.c
index 1d39e7490f7..d7d751d36fe 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwrite.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwrite.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.19 [November 12, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -118,43 +118,44 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
 
    if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
    {
-   /* Write PNG signature */
-   png_write_sig(png_ptr);
+      /* Write PNG signature */
+      png_write_sig(png_ptr);
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
-   if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
-       png_ptr->mng_features_permitted != 0)
-   {
-      png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
-      png_ptr->mng_features_permitted = 0;
-   }
+      if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
+          png_ptr->mng_features_permitted != 0)
+      {
+         png_warning(png_ptr,
+             "MNG features are not allowed in a PNG datastream");
+         png_ptr->mng_features_permitted = 0;
+      }
 #endif
 
-   /* Write IHDR information. */
-   png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
-       info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
-       info_ptr->filter_type,
+      /* Write IHDR information. */
+      png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
+          info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
+          info_ptr->filter_type,
 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
-       info_ptr->interlace_type
+          info_ptr->interlace_type
 #else
-       0
+          0
 #endif
-      );
+         );
 
-   /* The rest of these check to see if the valid field has the appropriate
-    * flag set, and if it does, writes the chunk.
-    *
-    * 1.6.0: COLORSPACE support controls the writing of these chunks too, and
-    * the chunks will be written if the WRITE routine is there and information
-    * is available in the COLORSPACE.  (See png_colorspace_sync_info in png.c
-    * for where the valid flags get set.)
-    *
-    * Under certain circumstances the colorspace can be invalidated without
-    * syncing the info_struct 'valid' flags; this happens if libpng detects and
-    * error and calls png_error while the color space is being set, yet the
-    * application continues writing the PNG.  So check the 'invalid' flag here
-    * too.
-    */
+      /* The rest of these check to see if the valid field has the appropriate
+       * flag set, and if it does, writes the chunk.
+       *
+       * 1.6.0: COLORSPACE support controls the writing of these chunks too, and
+       * the chunks will be written if the WRITE routine is there and
+       * information * is available in the COLORSPACE. (See
+       * png_colorspace_sync_info in png.c for where the valid flags get set.)
+       *
+       * Under certain circumstances the colorspace can be invalidated without
+       * syncing the info_struct 'valid' flags; this happens if libpng detects
+       * an error and calls png_error while the color space is being set, yet
+       * the application continues writing the PNG.  So check the 'invalid'
+       * flag here too.
+       */
 #ifdef PNG_GAMMA_SUPPORTED
 #  ifdef PNG_WRITE_gAMA_SUPPORTED
       if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
@@ -165,50 +166,50 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
 #endif
 
 #ifdef PNG_COLORSPACE_SUPPORTED
-   /* Write only one of sRGB or an ICC profile.  If a profile was supplied
-    * and it matches one of the known sRGB ones issue a warning.
-    */
+      /* Write only one of sRGB or an ICC profile.  If a profile was supplied
+       * and it matches one of the known sRGB ones issue a warning.
+       */
 #  ifdef PNG_WRITE_iCCP_SUPPORTED
-      if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
-          (info_ptr->valid & PNG_INFO_iCCP) != 0)
-      {
-#        ifdef PNG_WRITE_sRGB_SUPPORTED
-            if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
-               png_app_warning(png_ptr,
-                  "profile matches sRGB but writing iCCP instead");
-#        endif
+         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
+             (info_ptr->valid & PNG_INFO_iCCP) != 0)
+         {
+#    ifdef PNG_WRITE_sRGB_SUPPORTED
+               if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
+                  png_app_warning(png_ptr,
+                     "profile matches sRGB but writing iCCP instead");
+#     endif
 
-         png_write_iCCP(png_ptr, info_ptr->iccp_name,
-            info_ptr->iccp_profile);
-      }
+            png_write_iCCP(png_ptr, info_ptr->iccp_name,
+               info_ptr->iccp_profile);
+         }
 #     ifdef PNG_WRITE_sRGB_SUPPORTED
          else
 #     endif
 #  endif
 
 #  ifdef PNG_WRITE_sRGB_SUPPORTED
-      if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
-          (info_ptr->valid & PNG_INFO_sRGB) != 0)
-         png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
+         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
+             (info_ptr->valid & PNG_INFO_sRGB) != 0)
+            png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
 #  endif /* WRITE_sRGB */
 #endif /* COLORSPACE */
 
 #ifdef PNG_WRITE_sBIT_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
-      png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
+         if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
+            png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
 #endif
 
 #ifdef PNG_COLORSPACE_SUPPORTED
 #  ifdef PNG_WRITE_cHRM_SUPPORTED
-      if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
-         (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
-         (info_ptr->valid & PNG_INFO_cHRM) != 0)
-         png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
+         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
+             (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
+             (info_ptr->valid & PNG_INFO_cHRM) != 0)
+            png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
 #  endif
 #endif
 
 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-      write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
+         write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
 #endif
 
       png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
@@ -233,7 +234,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
       png_write_PLTE(png_ptr, info_ptr->palette,
           (png_uint_32)info_ptr->num_palette);
 
-   else if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) !=0)
+   else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
       png_error(png_ptr, "Valid palette required for paletted images");
 
 #ifdef PNG_WRITE_tRNS_SUPPORTED
@@ -244,8 +245,13 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
       if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
           info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
       {
-         int j;
-         for (j = 0; j<(int)info_ptr->num_trans; j++)
+         int j, jend;
+
+         jend = info_ptr->num_trans;
+         if (jend > PNG_MAX_PALETTE_LENGTH)
+            jend = PNG_MAX_PALETTE_LENGTH;
+
+         for (j = 0; jtrans_alpha[j] =
                (png_byte)(255 - info_ptr->trans_alpha[j]);
       }
@@ -566,7 +572,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
       /* App warnings are warnings in release (or release candidate) builds but
        * are errors during development.
        */
-#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+#if PNG_RELEASE_BUILD
       png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
 #endif
 
@@ -666,8 +672,8 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
 
          for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
          {
-            *(rp)     = (png_byte)((*rp       - *(rp + 1)) & 0xff);
-            *(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
+            *(rp)     = (png_byte)(*rp       - *(rp + 1));
+            *(rp + 2) = (png_byte)(*(rp + 2) - *(rp + 1));
          }
       }
 
@@ -693,10 +699,10 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
             png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);
             png_uint_32 red  = (png_uint_32)((s0 - s1) & 0xffffL);
             png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
-            *(rp    ) = (png_byte)((red >> 8) & 0xff);
-            *(rp + 1) = (png_byte)(red & 0xff);
-            *(rp + 4) = (png_byte)((blue >> 8) & 0xff);
-            *(rp + 5) = (png_byte)(blue & 0xff);
+            *(rp    ) = (png_byte)(red >> 8);
+            *(rp + 1) = (png_byte)red;
+            *(rp + 4) = (png_byte)(blue >> 8);
+            *(rp + 5) = (png_byte)blue;
          }
       }
 #endif /* WRITE_16BIT */
@@ -877,7 +883,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
     * which is also the output depth.
     */
    if (row_info.pixel_depth != png_ptr->pixel_depth ||
-      row_info.pixel_depth != png_ptr->transformed_pixel_depth)
+       row_info.pixel_depth != png_ptr->transformed_pixel_depth)
       png_error(png_ptr, "internal write transform logic error");
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
@@ -945,10 +951,6 @@ png_write_flush(png_structrp png_ptr)
 }
 #endif /* WRITE_FLUSH */
 
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
-#endif
-
 /* Free any memory used in png_ptr struct without freeing the struct itself. */
 static void
 png_write_destroy(png_structrp png_ptr)
@@ -965,24 +967,11 @@ png_write_destroy(png_structrp png_ptr)
    png_ptr->row_buf = NULL;
 #ifdef PNG_WRITE_FILTER_SUPPORTED
    png_free(png_ptr, png_ptr->prev_row);
-   png_free(png_ptr, png_ptr->sub_row);
-   png_free(png_ptr, png_ptr->up_row);
-   png_free(png_ptr, png_ptr->avg_row);
-   png_free(png_ptr, png_ptr->paeth_row);
+   png_free(png_ptr, png_ptr->try_row);
+   png_free(png_ptr, png_ptr->tst_row);
    png_ptr->prev_row = NULL;
-   png_ptr->sub_row = NULL;
-   png_ptr->up_row = NULL;
-   png_ptr->avg_row = NULL;
-   png_ptr->paeth_row = NULL;
-#endif
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-   /* Use this to save a little code space, it doesn't free the filter_costs */
-   png_reset_filter_heuristics(png_ptr);
-   png_free(png_ptr, png_ptr->filter_costs);
-   png_free(png_ptr, png_ptr->inv_filter_costs);
-   png_ptr->filter_costs = NULL;
-   png_ptr->inv_filter_costs = NULL;
+   png_ptr->try_row = NULL;
+   png_ptr->tst_row = NULL;
 #endif
 
 #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
@@ -1072,211 +1061,85 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
 #endif /* WRITE_FILTER */
       }
 
+#ifdef PNG_WRITE_FILTER_SUPPORTED
       /* If we have allocated the row_buf, this means we have already started
        * with the image and we should have allocated all of the filter buffers
        * that have been selected.  If prev_row isn't already allocated, then
        * it is too late to start using the filters that need it, since we
        * will be missing the data in the previous row.  If an application
        * wants to start and stop using particular filters during compression,
-       * it should start out with all of the filters, and then add and
-       * remove them after the start of compression.
+       * it should start out with all of the filters, and then remove them
+       * or add them back after the start of compression.
+       *
+       * NOTE: this is a nasty constraint on the code, because it means that the
+       * prev_row buffer must be maintained even if there are currently no
+       * 'prev_row' requiring filters active.
        */
       if (png_ptr->row_buf != NULL)
       {
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-         if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 &&
-             png_ptr->sub_row == NULL)
+         int num_filters;
+         png_alloc_size_t buf_size;
+
+         /* Repeat the checks in png_write_start_row; 1 pixel high or wide
+          * images cannot benefit from certain filters.  If this isn't done here
+          * the check below will fire on 1 pixel high images.
+          */
+         if (png_ptr->height == 1)
+            filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
+
+         if (png_ptr->width == 1)
+            filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
+
+         if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
+            && png_ptr->prev_row == NULL)
          {
-            png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
-                (png_ptr->rowbytes + 1));
-            png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
+            /* This is the error case, however it is benign - the previous row
+             * is not available so the filter can't be used.  Just warn here.
+             */
+            png_app_warning(png_ptr,
+               "png_set_filter: UP/AVG/PAETH cannot be added after start");
+            filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
          }
 
-         if ((png_ptr->do_filter & PNG_FILTER_UP) != 0 &&
-              png_ptr->up_row == NULL)
+         num_filters = 0;
+
+         if (filters & PNG_FILTER_SUB)
+            num_filters++;
+
+         if (filters & PNG_FILTER_UP)
+            num_filters++;
+
+         if (filters & PNG_FILTER_AVG)
+            num_filters++;
+
+         if (filters & PNG_FILTER_PAETH)
+            num_filters++;
+
+         /* Allocate needed row buffers if they have not already been
+          * allocated.
+          */
+         buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth,
+             png_ptr->width) + 1;
+
+         if (png_ptr->try_row == NULL)
+            png_ptr->try_row = png_voidcast(png_bytep,
+               png_malloc(png_ptr, buf_size));
+
+         if (num_filters > 1)
          {
-            if (png_ptr->prev_row == NULL)
-            {
-               png_warning(png_ptr, "Can't add Up filter after starting");
-               png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
-                   ~PNG_FILTER_UP);
-            }
-
-            else
-            {
-               png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
-                   (png_ptr->rowbytes + 1));
-               png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
-            }
+            if (png_ptr->tst_row == NULL)
+               png_ptr->tst_row = png_voidcast(png_bytep,
+                  png_malloc(png_ptr, buf_size));
          }
-
-         if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 &&
-              png_ptr->avg_row == NULL)
-         {
-            if (png_ptr->prev_row == NULL)
-            {
-               png_warning(png_ptr, "Can't add Average filter after starting");
-               png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
-                   ~PNG_FILTER_AVG);
-            }
-
-            else
-            {
-               png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
-                   (png_ptr->rowbytes + 1));
-               png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
-            }
-         }
-
-         if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 &&
-             png_ptr->paeth_row == NULL)
-         {
-            if (png_ptr->prev_row == NULL)
-            {
-               png_warning(png_ptr, "Can't add Paeth filter after starting");
-               png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
-            }
-
-            else
-            {
-               png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
-                   (png_ptr->rowbytes + 1));
-               png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
-            }
-         }
-
-         if (png_ptr->do_filter == PNG_NO_FILTERS)
-#endif /* WRITE_FILTER */
-            png_ptr->do_filter = PNG_FILTER_NONE;
       }
+      png_ptr->do_filter = (png_byte)filters;
+#endif
    }
    else
       png_error(png_ptr, "Unknown custom filter method");
 }
 
-/* This allows us to influence the way in which libpng chooses the "best"
- * filter for the current scanline.  While the "minimum-sum-of-absolute-
- * differences metric is relatively fast and effective, there is some
- * question as to whether it can be improved upon by trying to keep the
- * filtered data going to zlib more consistent, hopefully resulting in
- * better compression.
- */
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED      /* GRR 970116 */
-/* Convenience reset API. */
-static void
-png_reset_filter_heuristics(png_structrp png_ptr)
-{
-   /* Clear out any old values in the 'weights' - this must be done because if
-    * the app calls set_filter_heuristics multiple times with different
-    * 'num_weights' values we would otherwise potentially have wrong sized
-    * arrays.
-    */
-   png_ptr->num_prev_filters = 0;
-   png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED;
-   if (png_ptr->prev_filters != NULL)
-   {
-      png_bytep old = png_ptr->prev_filters;
-      png_ptr->prev_filters = NULL;
-      png_free(png_ptr, old);
-   }
-   if (png_ptr->filter_weights != NULL)
-   {
-      png_uint_16p old = png_ptr->filter_weights;
-      png_ptr->filter_weights = NULL;
-      png_free(png_ptr, old);
-   }
-
-   if (png_ptr->inv_filter_weights != NULL)
-   {
-      png_uint_16p old = png_ptr->inv_filter_weights;
-      png_ptr->inv_filter_weights = NULL;
-      png_free(png_ptr, old);
-   }
-
-   /* Leave the filter_costs - this array is fixed size. */
-}
-
-static int
-png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
-   int num_weights)
-{
-   if (png_ptr == NULL)
-      return 0;
-
-   /* Clear out the arrays */
-   png_reset_filter_heuristics(png_ptr);
-
-   /* Check arguments; the 'reset' function makes the correct settings for the
-    * unweighted case, but we must handle the weight case by initializing the
-    * arrays for the caller.
-    */
-   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-   {
-      int i;
-
-      if (num_weights > 0)
-      {
-         png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
-             (png_uint_32)((sizeof (png_byte)) * num_weights));
-
-         /* To make sure that the weighting starts out fairly */
-         for (i = 0; i < num_weights; i++)
-         {
-            png_ptr->prev_filters[i] = 255;
-         }
-
-         png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
-             (png_uint_32)((sizeof (png_uint_16)) * num_weights));
-
-         png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
-             (png_uint_32)((sizeof (png_uint_16)) * num_weights));
-
-         for (i = 0; i < num_weights; i++)
-         {
-            png_ptr->inv_filter_weights[i] =
-            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
-         }
-
-         /* Safe to set this now */
-         png_ptr->num_prev_filters = (png_byte)num_weights;
-      }
-
-      /* If, in the future, there are other filter methods, this would
-       * need to be based on png_ptr->filter.
-       */
-      if (png_ptr->filter_costs == NULL)
-      {
-         png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
-             (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
-
-         png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
-             (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
-      }
-
-      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
-      {
-         png_ptr->inv_filter_costs[i] =
-         png_ptr->filter_costs[i] = PNG_COST_FACTOR;
-      }
-
-      /* All the arrays are inited, safe to set this: */
-      png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED;
-
-      /* Return the 'ok' code. */
-      return 1;
-   }
-   else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT ||
-      heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED)
-   {
-      return 1;
-   }
-   else
-   {
-      png_warning(png_ptr, "Unknown filter heuristic method");
-      return 0;
-   }
-}
-
+#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
 /* Provide floating and fixed point APIs */
 #ifdef PNG_FLOATING_POINT_SUPPORTED
 void PNGAPI
@@ -1284,52 +1147,11 @@ png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
     int num_weights, png_const_doublep filter_weights,
     png_const_doublep filter_costs)
 {
-   png_debug(1, "in png_set_filter_heuristics");
-
-   /* The internal API allocates all the arrays and ensures that the elements of
-    * those arrays are set to the default value.
-    */
-   if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
-      return;
-
-   /* If using the weighted method copy in the weights. */
-   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-   {
-      int i;
-      for (i = 0; i < num_weights; i++)
-      {
-         if (filter_weights[i] <= 0.0)
-         {
-            png_ptr->inv_filter_weights[i] =
-            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
-         }
-
-         else
-         {
-            png_ptr->inv_filter_weights[i] =
-                (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5);
-
-            png_ptr->filter_weights[i] =
-                (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5);
-         }
-      }
-
-      /* Here is where we set the relative costs of the different filters.  We
-       * should take the desired compression level into account when setting
-       * the costs, so that Paeth, for instance, has a high relative cost at low
-       * compression levels, while it has a lower relative cost at higher
-       * compression settings.  The filter types are in order of increasing
-       * relative cost, so it would be possible to do this with an algorithm.
-       */
-      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0)
-      {
-         png_ptr->inv_filter_costs[i] =
-             (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5);
-
-         png_ptr->filter_costs[i] =
-             (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5);
-      }
-   }
+   PNG_UNUSED(png_ptr)
+   PNG_UNUSED(heuristic_method)
+   PNG_UNUSED(num_weights)
+   PNG_UNUSED(filter_weights)
+   PNG_UNUSED(filter_costs)
 }
 #endif /* FLOATING_POINT */
 
@@ -1339,67 +1161,16 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
     int num_weights, png_const_fixed_point_p filter_weights,
     png_const_fixed_point_p filter_costs)
 {
-   png_debug(1, "in png_set_filter_heuristics_fixed");
-
-   /* The internal API allocates all the arrays and ensures that the elements of
-    * those arrays are set to the default value.
-    */
-   if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
-      return;
-
-   /* If using the weighted method copy in the weights. */
-   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-   {
-      int i;
-      for (i = 0; i < num_weights; i++)
-      {
-         if (filter_weights[i] <= 0)
-         {
-            png_ptr->inv_filter_weights[i] =
-            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
-         }
-
-         else
-         {
-            png_ptr->inv_filter_weights[i] = (png_uint_16)
-               ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1);
-
-            png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR*
-               PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]);
-         }
-      }
-
-      /* Here is where we set the relative costs of the different filters.  We
-       * should take the desired compression level into account when setting
-       * the costs, so that Paeth, for instance, has a high relative cost at low
-       * compression levels, while it has a lower relative cost at higher
-       * compression settings.  The filter types are in order of increasing
-       * relative cost, so it would be possible to do this with an algorithm.
-       */
-      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
-         if (filter_costs[i] >= PNG_FP_1)
-      {
-         png_uint_32 tmp;
-
-         /* Use a 32 bit unsigned temporary here because otherwise the
-          * intermediate value will be a 32 bit *signed* integer (ANSI rules)
-          * and this will get the wrong answer on division.
-          */
-         tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2);
-         tmp /= filter_costs[i];
-
-         png_ptr->inv_filter_costs[i] = (png_uint_16)tmp;
-
-         tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF;
-         tmp /= PNG_FP_1;
-
-         png_ptr->filter_costs[i] = (png_uint_16)tmp;
-      }
-   }
+   PNG_UNUSED(png_ptr)
+   PNG_UNUSED(heuristic_method)
+   PNG_UNUSED(num_weights)
+   PNG_UNUSED(filter_weights)
+   PNG_UNUSED(filter_costs)
 }
 #endif /* FIXED_POINT */
 #endif /* WRITE_WEIGHTED_FILTER */
 
+#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
 void PNGAPI
 png_set_compression_level(png_structrp png_ptr, int level)
 {
@@ -1445,8 +1216,8 @@ png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
    if (png_ptr == NULL)
       return;
 
-   /* Prior to 1.6.0 this would warn but then set the window_bits value, this
-    * meant that negative window bits values could be selected which would cause
+   /* Prior to 1.6.0 this would warn but then set the window_bits value. This
+    * meant that negative window bits values could be selected that would cause
     * libpng to write a non-standard PNG file with raw deflate or gzip
     * compressed IDAT or ancillary chunks.  Such files can be read and there is
     * no warning on read, so this seems like a very bad idea.
@@ -1482,6 +1253,7 @@ png_set_compression_method(png_structrp png_ptr, int method)
 
    png_ptr->zlib_method = method;
 }
+#endif /* WRITE_CUSTOMIZE_COMPRESSION */
 
 /* The following were added to libpng-1.5.4 */
 #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
@@ -1642,14 +1414,14 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
     * alpha channel.
     */
    if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER|
-      PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0)
+       PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0)
    {
 #ifdef PNG_WRITE_FILLER_SUPPORTED
       if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0)
       {
          if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
             png_app_error(png_ptr,
-               "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
+                "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
 
          /* Continue if ignored - this is the pre-1.6.10 behavior */
          png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
@@ -1678,7 +1450,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
       png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
 #endif
 
-   /* Swap bits of 1, 2, 4 bit packed pixel formats */
+   /* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */
    if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
 #ifdef PNG_WRITE_PACKSWAP_SUPPORTED
       png_set_packswap(png_ptr);
@@ -1708,13 +1480,13 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
 
 
 #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
-#ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */
+# ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */
 /* Initialize the write structure - general purpose utility. */
 static int
 png_image_write_init(png_imagep image)
 {
    png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image,
-          png_safe_error, png_safe_warning);
+       png_safe_error, png_safe_warning);
 
    if (png_ptr != NULL)
    {
@@ -1723,7 +1495,7 @@ png_image_write_init(png_imagep image)
       if (info_ptr != NULL)
       {
          png_controlp control = png_voidcast(png_controlp,
-            png_malloc_warn(png_ptr, (sizeof *control)));
+             png_malloc_warn(png_ptr, (sizeof *control)));
 
          if (control != NULL)
          {
@@ -1770,12 +1542,12 @@ static int
 png_write_image_16bit(png_voidp argument)
 {
    png_image_write_control *display = png_voidcast(png_image_write_control*,
-      argument);
+       argument);
    png_imagep image = display->image;
    png_structrp png_ptr = image->opaque->png_ptr;
 
    png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
-      display->first_row);
+       display->first_row);
    png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
    png_uint_16p row_end;
    const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
@@ -1784,17 +1556,18 @@ png_write_image_16bit(png_voidp argument)
 
    if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
    {
-#     ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
-         if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
-         {
-            aindex = -1;
-            ++input_row; /* To point to the first component */
-            ++output_row;
-         }
-
+#   ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
+      if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
+      {
+         aindex = -1;
+         ++input_row; /* To point to the first component */
+         ++output_row;
+      }
          else
-#     endif
+            aindex = channels;
+#     else
          aindex = channels;
+#     endif
    }
 
    else
@@ -1876,7 +1649,7 @@ png_write_image_16bit(png_voidp argument)
  * calculation can be done to 15 bits of accuracy; however, the output needs to
  * be scaled in the range 0..255*65535, so include that scaling here.
  */
-#define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha)
+#   define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha)
 
 static png_byte
 png_unpremultiply(png_uint_32 component, png_uint_32 alpha,
@@ -1927,12 +1700,12 @@ static int
 png_write_image_8bit(png_voidp argument)
 {
    png_image_write_control *display = png_voidcast(png_image_write_control*,
-      argument);
+       argument);
    png_imagep image = display->image;
    png_structrp png_ptr = image->opaque->png_ptr;
 
    png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
-      display->first_row);
+       display->first_row);
    png_bytep output_row = png_voidcast(png_bytep, display->local_row);
    png_uint_32 y = image->height;
    const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
@@ -1942,17 +1715,17 @@ png_write_image_8bit(png_voidp argument)
       png_bytep row_end;
       int aindex;
 
-#     ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
-         if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
-         {
-            aindex = -1;
-            ++input_row; /* To point to the first component */
-            ++output_row;
-         }
+#   ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
+      if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
+      {
+         aindex = -1;
+         ++input_row; /* To point to the first component */
+         ++output_row;
+      }
 
-         else
-#     endif
-         aindex = channels;
+      else
+#   endif
+      aindex = channels;
 
       /* Use row_end in place of a loop counter: */
       row_end = output_row + image->width * (channels+1);
@@ -1986,7 +1759,7 @@ png_write_image_8bit(png_voidp argument)
          } /* while out_ptr < row_end */
 
          png_write_row(png_ptr, png_voidcast(png_const_bytep,
-            display->local_row));
+             display->local_row));
          input_row += display->row_bytes/(sizeof (png_uint_16));
       } /* while y */
    }
@@ -2025,25 +1798,25 @@ png_image_set_PLTE(png_image_write_control *display)
    const png_imagep image = display->image;
    const void *cmap = display->colormap;
    const int entries = image->colormap_entries > 256 ? 256 :
-      (int)image->colormap_entries;
+       (int)image->colormap_entries;
 
    /* NOTE: the caller must check for cmap != NULL and entries != 0 */
    const png_uint_32 format = image->format;
    const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
 
-#  if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
+#   if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
       defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
       const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
-         (format & PNG_FORMAT_FLAG_ALPHA) != 0;
-#  else
+          (format & PNG_FORMAT_FLAG_ALPHA) != 0;
+#   else
 #     define afirst 0
-#  endif
+#   endif
 
-#  ifdef PNG_FORMAT_BGR_SUPPORTED
+#   ifdef PNG_FORMAT_BGR_SUPPORTED
       const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
-#  else
+#   else
 #     define bgr 0
-#  endif
+#   endif
 
    int i, num_trans;
    png_color palette[256];
@@ -2068,11 +1841,11 @@ png_image_set_PLTE(png_image_write_control *display)
             if (channels >= 3) /* RGB */
             {
                palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
-                  entry[(2 ^ bgr)]);
+                   entry[(2 ^ bgr)]);
                palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
-                  entry[1]);
+                   entry[1]);
                palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
-                  entry[bgr]);
+                   entry[bgr]);
             }
 
             else /* Gray */
@@ -2148,12 +1921,12 @@ png_image_set_PLTE(png_image_write_control *display)
       }
    }
 
-#  ifdef afirst
+#   ifdef afirst
 #     undef afirst
-#  endif
-#  ifdef bgr
+#   endif
+#   ifdef bgr
 #     undef bgr
-#  endif
+#   endif
 
    png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette,
       entries);
@@ -2181,10 +1954,10 @@ png_image_write_main(png_voidp argument)
    int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
    int write_16bit = linear && !colormap && (display->convert_to_8bit == 0);
 
-#  ifdef PNG_BENIGN_ERRORS_SUPPORTED
+#   ifdef PNG_BENIGN_ERRORS_SUPPORTED
       /* Make sure we error out on any bad situation */
       png_set_benign_errors(png_ptr, 0/*error*/);
-#  endif
+#   endif
 
    /* Default the 'row_stride' parameter if required. */
    if (display->row_stride == 0)
@@ -2253,7 +2026,7 @@ png_image_write_main(png_voidp argument)
    /* Now set up the data transformations (*after* the header is written),
     * remove the handled transformations from the 'format' flags for checking.
     *
-    * First check for a little endian system if writing 16 bit files.
+    * First check for a little endian system if writing 16-bit files.
     */
    if (write_16bit != 0)
    {
@@ -2263,23 +2036,23 @@ png_image_write_main(png_voidp argument)
          png_set_swap(png_ptr);
    }
 
-#  ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
+#   ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
       if ((format & PNG_FORMAT_FLAG_BGR) != 0)
       {
          if (colormap == 0 && (format & PNG_FORMAT_FLAG_COLOR) != 0)
             png_set_bgr(png_ptr);
          format &= ~PNG_FORMAT_FLAG_BGR;
       }
-#  endif
+#   endif
 
-#  ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
+#   ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
       if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
       {
          if (colormap == 0 && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
             png_set_swap_alpha(png_ptr);
          format &= ~PNG_FORMAT_FLAG_AFIRST;
       }
-#  endif
+#   endif
 
    /* If there are 16 or fewer color-map entries we wrote a lower bit depth
     * above, but the application data is still byte packed.
@@ -2315,7 +2088,9 @@ png_image_write_main(png_voidp argument)
        * it about 50 times.  The speed-up in pngstest was about 10-20% of the
        * total (user) time on a heavily loaded system.
        */
+#   ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
       png_set_compression_level(png_ptr, 3);
+#   endif
    }
 
    /* Check for the cases that currently require a pre-transform on the row
@@ -2478,6 +2253,6 @@ png_image_write_to_file(png_imagep image, const char *file_name,
    else
       return 0;
 }
-#endif /* STDIO */
+# endif /* STDIO */
 #endif /* SIMPLIFIED_WRITE */
 #endif /* WRITE */
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwtran.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwtran.c
index ef015aeb7b9..44e7daf5614 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwtran.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwtran.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.18 [July 23, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -99,7 +99,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
          case 2:
          {
             png_bytep sp, dp;
-            int shift, v;
+            unsigned int shift;
+            int v;
             png_uint_32 i;
             png_uint_32 row_width = row_info->width;
 
@@ -138,7 +139,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
          case 4:
          {
             png_bytep sp, dp;
-            int shift, v;
+            unsigned int shift;
+            int v;
             png_uint_32 i;
             png_uint_32 row_width = row_info->width;
 
@@ -450,7 +452,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
                *(dp++) = *(sp++);
                */
                sp+=3; dp = sp;
-               *(dp++) = (png_byte)(255 - *(sp++));
+               *dp = (png_byte)(255 - *(sp++));
             }
          }
 
@@ -474,7 +476,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
                */
                sp+=6; dp = sp;
                *(dp++) = (png_byte)(255 - *(sp++));
-               *(dp++) = (png_byte)(255 - *(sp++));
+               *dp     = (png_byte)(255 - *(sp++));
             }
          }
 #endif /* WRITE_16BIT */
@@ -512,7 +514,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
                */
                sp+=2; dp = sp;
                *(dp++) = (png_byte)(255 - *(sp++));
-               *(dp++) = (png_byte)(255 - *(sp++));
+               *dp     = (png_byte)(255 - *(sp++));
             }
          }
 #endif /* WRITE_16BIT */
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwutil.c b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwutil.c
index 66a8812d790..a51f24b94c4 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwutil.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwutil.c
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.19 [November 12, 2015]
+ * Copyright (c) 1998-2015 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -51,10 +51,10 @@
 void PNGAPI
 png_save_uint_32(png_bytep buf, png_uint_32 i)
 {
-   buf[0] = (png_byte)((i >> 24) & 0xff);
-   buf[1] = (png_byte)((i >> 16) & 0xff);
-   buf[2] = (png_byte)((i >> 8) & 0xff);
-   buf[3] = (png_byte)(i & 0xff);
+   buf[0] = (png_byte)(i >> 24);
+   buf[1] = (png_byte)(i >> 16);
+   buf[2] = (png_byte)(i >> 8);
+   buf[3] = (png_byte)(i     );
 }
 
 /* Place a 16-bit number into a buffer in PNG byte order.
@@ -64,8 +64,8 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
 void PNGAPI
 png_save_uint_16(png_bytep buf, unsigned int i)
 {
-   buf[0] = (png_byte)((i >> 8) & 0xff);
-   buf[1] = (png_byte)(i & 0xff);
+   buf[0] = (png_byte)(i >> 8);
+   buf[1] = (png_byte)(i     );
 }
 #endif
 
@@ -207,7 +207,7 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
    if (png_ptr == NULL)
       return;
 
-   /* On 64 bit architectures 'length' may not fit in a png_uint_32. */
+   /* On 64-bit architectures 'length' may not fit in a png_uint_32. */
    if (length > PNG_UINT_31_MAX)
       png_error(png_ptr, "length exceeds PNG maximum");
 
@@ -336,7 +336,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
        */
       (void)png_safecat(msg, (sizeof msg), 10, " using zstream");
 #endif
-#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+#if PNG_RELEASE_BUILD
          png_warning(png_ptr, msg);
 
          /* Attempt sane error recovery */
@@ -723,7 +723,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
 
    while (*key && key_len < 79)
    {
-      png_byte ch = (png_byte)(0xff & *key++);
+      png_byte ch = (png_byte)*key++;
 
       if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
          *new_key++ = ch, ++key_len, space = 0;
@@ -899,7 +899,7 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
    interlace_type=PNG_INTERLACE_NONE;
 #endif
 
-   /* Save the relevent information */
+   /* Save the relevant information */
    png_ptr->bit_depth = (png_byte)bit_depth;
    png_ptr->color_type = (png_byte)color_type;
    png_ptr->interlaced = (png_byte)interlace_type;
@@ -950,17 +950,20 @@ void /* PRIVATE */
 png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
     png_uint_32 num_pal)
 {
-   png_uint_32 i;
+   png_uint_32 max_palette_length, i;
    png_const_colorp pal_ptr;
    png_byte buf[3];
 
    png_debug(1, "in png_write_PLTE");
 
+   max_palette_length = (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
+      (1 << png_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
+
    if ((
 #ifdef PNG_MNG_FEATURES_SUPPORTED
        (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 &&
 #endif
-       num_pal == 0) || num_pal > 256)
+       num_pal == 0) || num_pal > max_palette_length)
    {
       if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
       {
@@ -1472,7 +1475,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
 
    else if (color_type == PNG_COLOR_TYPE_GRAY)
    {
-      /* One 16 bit value */
+      /* One 16-bit value */
       if (tran->gray >= (1 << png_ptr->bit_depth))
       {
          png_app_warning(png_ptr,
@@ -1487,7 +1490,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
 
    else if (color_type == PNG_COLOR_TYPE_RGB)
    {
-      /* Three 16 bit values */
+      /* Three 16-bit values */
       png_save_uint_16(buf, tran->red);
       png_save_uint_16(buf + 2, tran->green);
       png_save_uint_16(buf + 4, tran->blue);
@@ -1793,7 +1796,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
       png_write_compressed_data_out(png_ptr, &comp);
 
    else
-      png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len);
+      png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len);
 
    png_write_chunk_end(png_ptr);
 }
@@ -1989,6 +1992,10 @@ png_write_start_row(png_structrp png_ptr)
    png_alloc_size_t buf_size;
    int usr_pixel_depth;
 
+#ifdef PNG_WRITE_FILTER_SUPPORTED
+   png_byte filters;
+#endif
+
    png_debug(1, "in png_write_start_row");
 
    usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;
@@ -1999,50 +2006,54 @@ png_write_start_row(png_structrp png_ptr)
    png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
 
    /* Set up row buffer */
-   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
+   png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
 
    png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
 
 #ifdef PNG_WRITE_FILTER_SUPPORTED
-   /* Set up filtering buffer, if using this filter */
-   if (png_ptr->do_filter & PNG_FILTER_SUB)
-   {
-      png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
+   filters = png_ptr->do_filter;
 
-      png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
+   if (png_ptr->height == 1)
+      filters &= 0xff & ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
+
+   if (png_ptr->width == 1)
+      filters &= 0xff & ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
+
+   if (filters == 0)
+      filters = PNG_FILTER_NONE;
+
+   png_ptr->do_filter = filters;
+
+   if (((filters & (PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG |
+       PNG_FILTER_PAETH)) != 0) && png_ptr->try_row == NULL)
+   {
+      int num_filters = 0;
+
+      png_ptr->try_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
+
+      if (filters & PNG_FILTER_SUB)
+         num_filters++;
+
+      if (filters & PNG_FILTER_UP)
+         num_filters++;
+
+      if (filters & PNG_FILTER_AVG)
+         num_filters++;
+
+      if (filters & PNG_FILTER_PAETH)
+         num_filters++;
+
+      if (num_filters > 1)
+         png_ptr->tst_row = png_voidcast(png_bytep, png_malloc(png_ptr,
+             buf_size));
    }
 
-   /* We only need to keep the previous row if we are using one of these. */
-   if ((png_ptr->do_filter &
-      (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0)
-   {
-      /* Set up previous row buffer */
-      png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);
-
-      if ((png_ptr->do_filter & PNG_FILTER_UP) != 0)
-      {
-         png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
-            png_ptr->rowbytes + 1);
-
-         png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
-      }
-
-      if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0)
-      {
-         png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
-             png_ptr->rowbytes + 1);
-
-         png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
-      }
-
-      if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0)
-      {
-         png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
-             png_ptr->rowbytes + 1);
-
-         png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
-      }
-   }
+   /* We only need to keep the previous row if we are using one of the following
+    * filters.
+    */
+   if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0)
+      png_ptr->prev_row = png_voidcast(png_bytep,
+         png_calloc(png_ptr, buf_size));
 #endif /* WRITE_FILTER */
 
 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
@@ -2188,7 +2199,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
          {
             png_bytep sp;
             png_bytep dp;
-            int shift;
+            unsigned int shift;
             int d;
             int value;
             png_uint_32 i;
@@ -2226,7 +2237,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
          {
             png_bytep sp;
             png_bytep dp;
-            int shift;
+            unsigned int shift;
             int d;
             int value;
             png_uint_32 i;
@@ -2263,7 +2274,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
          {
             png_bytep sp;
             png_bytep dp;
-            int shift;
+            unsigned int shift;
             int d;
             int value;
             png_uint_32 i;
@@ -2338,50 +2349,181 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
 }
 #endif
 
+
 /* This filters the row, chooses which filter to use, if it has not already
  * been specified by the application, and then writes the row out with the
  * chosen filter.
  */
-static void
+static void /* PRIVATE */
 png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
    png_size_t row_bytes);
 
-#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)
-#define PNG_HISHIFT 10
-#define PNG_LOMASK ((png_uint_32)0xffffL)
-#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))
+#ifdef PNG_WRITE_FILTER_SUPPORTED
+static png_size_t /* PRIVATE */
+png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
+    const png_size_t row_bytes, const png_size_t lmins)
+{
+   png_bytep rp, dp, lp;
+   png_size_t i;
+   png_size_t sum = 0;
+   int v;
+
+   png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
+
+   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp;
+        i++, rp++, dp++)
+   {
+      v = *dp = *rp;
+      sum += (v < 128) ? v : 256 - v;
+   }
+
+   for (lp = png_ptr->row_buf + 1; i < row_bytes;
+      i++, rp++, lp++, dp++)
+   {
+      v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
+      sum += (v < 128) ? v : 256 - v;
+
+      if (sum > lmins)  /* We are already worse, don't continue. */
+        break;
+   }
+
+   return (sum);
+}
+
+static png_size_t /* PRIVATE */
+png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
+    const png_size_t lmins)
+{
+   png_bytep rp, dp, pp;
+   png_size_t i;
+   png_size_t sum = 0;
+   int v;
+
+   png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
+
+   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
+       pp = png_ptr->prev_row + 1; i < row_bytes;
+       i++, rp++, pp++, dp++)
+   {
+      v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
+      sum += (v < 128) ? v : 256 - v;
+
+      if (sum > lmins)  /* We are already worse, don't continue. */
+        break;
+   }
+
+   return (sum);
+}
+
+static png_size_t /* PRIVATE */
+png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
+      const png_size_t row_bytes, const png_size_t lmins)
+{
+   png_bytep rp, dp, pp, lp;
+   png_uint_32 i;
+   png_size_t sum = 0;
+   int v;
+
+   png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
+
+   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
+        pp = png_ptr->prev_row + 1; i < bpp; i++)
+   {
+      v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
+
+      sum += (v < 128) ? v : 256 - v;
+   }
+
+   for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
+   {
+      v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
+          & 0xff);
+
+      sum += (v < 128) ? v : 256 - v;
+
+      if (sum > lmins)  /* We are already worse, don't continue. */
+        break;
+   }
+
+   return (sum);
+}
+
+static png_size_t /* PRIVATE */
+png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
+    const png_size_t row_bytes, const png_size_t lmins)
+{
+   png_bytep rp, dp, pp, cp, lp;
+   png_size_t i;
+   png_size_t sum = 0;
+   int v;
+
+   png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
+
+   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
+       pp = png_ptr->prev_row + 1; i < bpp; i++)
+   {
+      v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
+
+      sum += (v < 128) ? v : 256 - v;
+   }
+
+   for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
+        i++)
+   {
+      int a, b, c, pa, pb, pc, p;
+
+      b = *pp++;
+      c = *cp++;
+      a = *lp++;
+
+      p = b - c;
+      pc = a - c;
+
+#ifdef PNG_USE_ABS
+      pa = abs(p);
+      pb = abs(pc);
+      pc = abs(p + pc);
+#else
+      pa = p < 0 ? -p : p;
+      pb = pc < 0 ? -pc : pc;
+      pc = (p + pc) < 0 ? -(p + pc) : p + pc;
+#endif
+
+      p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
+
+      v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
+
+      sum += (v < 128) ? v : 256 - v;
+
+      if (sum > lmins)  /* We are already worse, don't continue. */
+        break;
+   }
+
+   return (sum);
+}
+#endif /* WRITE_FILTER */
+
 void /* PRIVATE */
 png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
 {
-   png_bytep best_row;
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-   png_bytep prev_row, row_buf;
-   png_uint_32 mins, bpp;
+#ifndef PNG_WRITE_FILTER_SUPPORTED
+   png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1);
+#else
    png_byte filter_to_do = png_ptr->do_filter;
+   png_bytep row_buf;
+   png_bytep best_row;
+   png_uint_32 bpp;
+   png_size_t mins;
    png_size_t row_bytes = row_info->rowbytes;
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-   int num_p_filters = png_ptr->num_prev_filters;
-#endif
 
    png_debug(1, "in png_write_find_filter");
 
-#ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-  if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS)
-  {
-     /* These will never be selected so we need not test them. */
-     filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH);
-  }
-#endif
-
    /* Find out how many bytes offset each pixel is */
    bpp = (row_info->pixel_depth + 7) >> 3;
 
-   prev_row = png_ptr->prev_row;
-#endif
-   best_row = png_ptr->row_buf;
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-   row_buf = best_row;
-   mins = PNG_MAXSUM;
+   row_buf = png_ptr->row_buf;
+   mins = PNG_SIZE_MAX - 256/* so we can detect potential overflow of the
+                               running sum */;
 
    /* The prediction method we use is to find which method provides the
     * smallest value when summing the absolute values of the distances
@@ -2411,57 +2553,37 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
    /* We don't need to test the 'no filter' case if this is the only filter
     * that has been chosen, as it doesn't actually do anything to the data.
     */
+   best_row = png_ptr->row_buf;
+
+
    if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE)
    {
       png_bytep rp;
-      png_uint_32 sum = 0;
+      png_size_t sum = 0;
       png_size_t i;
       int v;
 
-      for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
+      if (PNG_SIZE_MAX/128 <= row_bytes)
       {
-         v = *rp;
-         sum += (v < 128) ? v : 256 - v;
-      }
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         png_uint_32 sumhi, sumlo;
-         int j;
-         sumlo = sum & PNG_LOMASK;
-         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */
-
-         /* Reduce the sum if we match any of the previous rows */
-         for (j = 0; j < num_p_filters; j++)
+         for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
          {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
-            {
-               sumlo = (sumlo * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
+            /* Check for overflow */
+            if (sum > PNG_SIZE_MAX/128 - 256)
+               break;
 
-               sumhi = (sumhi * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
+            v = *rp;
+            sum += (v < 128) ? v : 256 - v;
          }
-
-         /* Factor in the cost of this filter (this is here for completeness,
-          * but it makes no sense to have a "cost" for the NONE filter, as
-          * it has the minimum possible computational cost - none).
-          */
-         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>
-             PNG_COST_SHIFT;
-
-         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>
-             PNG_COST_SHIFT;
-
-         if (sumhi > PNG_HIMASK)
-            sum = PNG_MAXSUM;
-
-         else
-            sum = (sumhi << PNG_HISHIFT) + sumlo;
       }
-#endif
+      else /* Overflow is not possible */
+      {
+         for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
+         {
+            v = *rp;
+            sum += (v < 128) ? v : 256 - v;
+         }
+      }
+
       mins = sum;
    }
 
@@ -2469,553 +2591,109 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
    if (filter_to_do == PNG_FILTER_SUB)
    /* It's the only filter so no testing is needed */
    {
-      png_bytep rp, lp, dp;
-      png_size_t i;
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
-           i++, rp++, dp++)
-      {
-         *dp = *rp;
-      }
-
-      for (lp = row_buf + 1; i < row_bytes;
-         i++, rp++, lp++, dp++)
-      {
-         *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
-      }
-
-      best_row = png_ptr->sub_row;
+      (void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins);
+      best_row = png_ptr->try_row;
    }
 
    else if ((filter_to_do & PNG_FILTER_SUB) != 0)
    {
-      png_bytep rp, dp, lp;
-      png_uint_32 sum = 0, lmins = mins;
-      png_size_t i;
-      int v;
+      png_size_t sum;
+      png_size_t lmins = mins;
 
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      /* We temporarily increase the "minimum sum" by the factor we
-       * would reduce the sum of this filter, so that we can do the
-       * early exit comparison without scaling the sum each time.
-       */
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 lmhi, lmlo;
-         lmlo = lmins & PNG_LOMASK;
-         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
-            {
-               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
-             PNG_COST_SHIFT;
-
-         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
-             PNG_COST_SHIFT;
-
-         if (lmhi > PNG_HIMASK)
-            lmins = PNG_MAXSUM;
-
-         else
-            lmins = (lmhi << PNG_HISHIFT) + lmlo;
-      }
-#endif
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
-           i++, rp++, dp++)
-      {
-         v = *dp = *rp;
-
-         sum += (v < 128) ? v : 256 - v;
-      }
-
-      for (lp = row_buf + 1; i < row_bytes;
-         i++, rp++, lp++, dp++)
-      {
-         v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
-
-         sum += (v < 128) ? v : 256 - v;
-
-         if (sum > lmins)  /* We are already worse, don't continue. */
-            break;
-      }
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 sumhi, sumlo;
-         sumlo = sum & PNG_LOMASK;
-         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
-            {
-               sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
-             PNG_COST_SHIFT;
-
-         sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>
-             PNG_COST_SHIFT;
-
-         if (sumhi > PNG_HIMASK)
-            sum = PNG_MAXSUM;
-
-         else
-            sum = (sumhi << PNG_HISHIFT) + sumlo;
-      }
-#endif
+      sum = png_setup_sub_row(png_ptr, bpp, row_bytes, lmins);
 
       if (sum < mins)
       {
          mins = sum;
-         best_row = png_ptr->sub_row;
+         best_row = png_ptr->try_row;
+         if (png_ptr->tst_row != NULL)
+         {
+            png_ptr->try_row = png_ptr->tst_row;
+            png_ptr->tst_row = best_row;
+         }
       }
    }
 
    /* Up filter */
    if (filter_to_do == PNG_FILTER_UP)
    {
-      png_bytep rp, dp, pp;
-      png_size_t i;
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
-          pp = prev_row + 1; i < row_bytes;
-          i++, rp++, pp++, dp++)
-      {
-         *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
-      }
-
-      best_row = png_ptr->up_row;
+      (void) png_setup_up_row(png_ptr, row_bytes, mins);
+      best_row = png_ptr->try_row;
    }
 
    else if ((filter_to_do & PNG_FILTER_UP) != 0)
    {
-      png_bytep rp, dp, pp;
-      png_uint_32 sum = 0, lmins = mins;
-      png_size_t i;
-      int v;
+      png_size_t sum;
+      png_size_t lmins = mins;
 
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 lmhi, lmlo;
-         lmlo = lmins & PNG_LOMASK;
-         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
-            {
-               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>
-             PNG_COST_SHIFT;
-
-         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>
-             PNG_COST_SHIFT;
-
-         if (lmhi > PNG_HIMASK)
-            lmins = PNG_MAXSUM;
-
-         else
-            lmins = (lmhi << PNG_HISHIFT) + lmlo;
-      }
-#endif
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
-          pp = prev_row + 1; i < row_bytes; i++)
-      {
-         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
-
-         sum += (v < 128) ? v : 256 - v;
-
-         if (sum > lmins)  /* We are already worse, don't continue. */
-            break;
-      }
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 sumhi, sumlo;
-         sumlo = sum & PNG_LOMASK;
-         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
-            {
-               sumlo = (sumlo * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               sumhi = (sumhi * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>
-             PNG_COST_SHIFT;
-
-         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>
-             PNG_COST_SHIFT;
-
-         if (sumhi > PNG_HIMASK)
-            sum = PNG_MAXSUM;
-
-         else
-            sum = (sumhi << PNG_HISHIFT) + sumlo;
-      }
-#endif
+      sum = png_setup_up_row(png_ptr, row_bytes, lmins);
 
       if (sum < mins)
       {
          mins = sum;
-         best_row = png_ptr->up_row;
+         best_row = png_ptr->try_row;
+         if (png_ptr->tst_row != NULL)
+         {
+            png_ptr->try_row = png_ptr->tst_row;
+            png_ptr->tst_row = best_row;
+         }
       }
    }
 
    /* Avg filter */
    if (filter_to_do == PNG_FILTER_AVG)
    {
-      png_bytep rp, dp, pp, lp;
-      png_uint_32 i;
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
-           pp = prev_row + 1; i < bpp; i++)
-      {
-         *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
-      }
-
-      for (lp = row_buf + 1; i < row_bytes; i++)
-      {
-         *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
-                 & 0xff);
-      }
-      best_row = png_ptr->avg_row;
+      (void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins);
+      best_row = png_ptr->try_row;
    }
 
    else if ((filter_to_do & PNG_FILTER_AVG) != 0)
    {
-      png_bytep rp, dp, pp, lp;
-      png_uint_32 sum = 0, lmins = mins;
-      png_size_t i;
-      int v;
+      png_size_t sum;
+      png_size_t lmins = mins;
 
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 lmhi, lmlo;
-         lmlo = lmins & PNG_LOMASK;
-         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG)
-            {
-               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>
-             PNG_COST_SHIFT;
-
-         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>
-             PNG_COST_SHIFT;
-
-         if (lmhi > PNG_HIMASK)
-            lmins = PNG_MAXSUM;
-
-         else
-            lmins = (lmhi << PNG_HISHIFT) + lmlo;
-      }
-#endif
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
-           pp = prev_row + 1; i < bpp; i++)
-      {
-         v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
-
-         sum += (v < 128) ? v : 256 - v;
-      }
-
-      for (lp = row_buf + 1; i < row_bytes; i++)
-      {
-         v = *dp++ =
-             (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);
-
-         sum += (v < 128) ? v : 256 - v;
-
-         if (sum > lmins)  /* We are already worse, don't continue. */
-            break;
-      }
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 sumhi, sumlo;
-         sumlo = sum & PNG_LOMASK;
-         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
-            {
-               sumlo = (sumlo * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               sumhi = (sumhi * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>
-             PNG_COST_SHIFT;
-
-         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>
-             PNG_COST_SHIFT;
-
-         if (sumhi > PNG_HIMASK)
-            sum = PNG_MAXSUM;
-
-         else
-            sum = (sumhi << PNG_HISHIFT) + sumlo;
-      }
-#endif
+      sum= png_setup_avg_row(png_ptr, bpp, row_bytes, lmins);
 
       if (sum < mins)
       {
          mins = sum;
-         best_row = png_ptr->avg_row;
+         best_row = png_ptr->try_row;
+         if (png_ptr->tst_row != NULL)
+         {
+            png_ptr->try_row = png_ptr->tst_row;
+            png_ptr->tst_row = best_row;
+         }
       }
    }
 
    /* Paeth filter */
    if ((filter_to_do == PNG_FILTER_PAETH) != 0)
    {
-      png_bytep rp, dp, pp, cp, lp;
-      png_size_t i;
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
-          pp = prev_row + 1; i < bpp; i++)
-      {
-         *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
-      }
-
-      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
-      {
-         int a, b, c, pa, pb, pc, p;
-
-         b = *pp++;
-         c = *cp++;
-         a = *lp++;
-
-         p = b - c;
-         pc = a - c;
-
-#ifdef PNG_USE_ABS
-         pa = abs(p);
-         pb = abs(pc);
-         pc = abs(p + pc);
-#else
-         pa = p < 0 ? -p : p;
-         pb = pc < 0 ? -pc : pc;
-         pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-
-         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
-
-         *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
-      }
-      best_row = png_ptr->paeth_row;
+      (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins);
+      best_row = png_ptr->try_row;
    }
 
    else if ((filter_to_do & PNG_FILTER_PAETH) != 0)
    {
-      png_bytep rp, dp, pp, cp, lp;
-      png_uint_32 sum = 0, lmins = mins;
-      png_size_t i;
-      int v;
+      png_size_t sum;
+      png_size_t lmins = mins;
 
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 lmhi, lmlo;
-         lmlo = lmins & PNG_LOMASK;
-         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
-            {
-               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>
-             PNG_COST_SHIFT;
-
-         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>
-             PNG_COST_SHIFT;
-
-         if (lmhi > PNG_HIMASK)
-            lmins = PNG_MAXSUM;
-
-         else
-            lmins = (lmhi << PNG_HISHIFT) + lmlo;
-      }
-#endif
-
-      for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
-          pp = prev_row + 1; i < bpp; i++)
-      {
-         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
-
-         sum += (v < 128) ? v : 256 - v;
-      }
-
-      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
-      {
-         int a, b, c, pa, pb, pc, p;
-
-         b = *pp++;
-         c = *cp++;
-         a = *lp++;
-
-#ifndef PNG_SLOW_PAETH
-         p = b - c;
-         pc = a - c;
-#ifdef PNG_USE_ABS
-         pa = abs(p);
-         pb = abs(pc);
-         pc = abs(p + pc);
-#else
-         pa = p < 0 ? -p : p;
-         pb = pc < 0 ? -pc : pc;
-         pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
-#else /* SLOW_PAETH */
-         p = a + b - c;
-         pa = abs(p - a);
-         pb = abs(p - b);
-         pc = abs(p - c);
-
-         if (pa <= pb && pa <= pc)
-            p = a;
-
-         else if (pb <= pc)
-            p = b;
-
-         else
-            p = c;
-#endif /* SLOW_PAETH */
-
-         v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
-
-         sum += (v < 128) ? v : 256 - v;
-
-         if (sum > lmins)  /* We are already worse, don't continue. */
-            break;
-      }
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
-      {
-         int j;
-         png_uint_32 sumhi, sumlo;
-         sumlo = sum & PNG_LOMASK;
-         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
-
-         for (j = 0; j < num_p_filters; j++)
-         {
-            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
-            {
-               sumlo = (sumlo * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-
-               sumhi = (sumhi * png_ptr->filter_weights[j]) >>
-                   PNG_WEIGHT_SHIFT;
-            }
-         }
-
-         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>
-             PNG_COST_SHIFT;
-
-         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>
-             PNG_COST_SHIFT;
-
-         if (sumhi > PNG_HIMASK)
-            sum = PNG_MAXSUM;
-
-         else
-            sum = (sumhi << PNG_HISHIFT) + sumlo;
-      }
-#endif
+      sum = png_setup_paeth_row(png_ptr, bpp, row_bytes, lmins);
 
       if (sum < mins)
       {
-         best_row = png_ptr->paeth_row;
+         best_row = png_ptr->try_row;
+         if (png_ptr->tst_row != NULL)
+         {
+            png_ptr->try_row = png_ptr->tst_row;
+            png_ptr->tst_row = best_row;
+         }
       }
    }
-#endif /* WRITE_FILTER */
 
    /* Do the actual writing of the filtered row data from the chosen filter. */
    png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
 
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-   /* Save the type of filter we picked this time for future calculations */
-   if (png_ptr->num_prev_filters > 0)
-   {
-      int j;
-
-      for (j = 1; j < num_p_filters; j++)
-      {
-         png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];
-      }
-
-      png_ptr->prev_filters[j] = best_row[0];
-   }
-#endif
 #endif /* WRITE_FILTER */
 }
 
@@ -3031,6 +2709,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
 
    png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
 
+#ifdef PNG_WRITE_FILTER_SUPPORTED
    /* Swap the current and previous rows */
    if (png_ptr->prev_row != NULL)
    {
@@ -3040,6 +2719,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
       png_ptr->prev_row = png_ptr->row_buf;
       png_ptr->row_buf = tptr;
    }
+#endif /* WRITE_FILTER */
 
    /* Finish row - updates counters and flushes zlib if last row */
    png_write_finish_row(png_ptr);
diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/splashscreen_png.c b/jdk/src/java.desktop/share/native/libsplashscreen/splashscreen_png.c
index 3f77ea6d6d0..0ad3d448372 100644
--- a/jdk/src/java.desktop/share/native/libsplashscreen/splashscreen_png.c
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/splashscreen_png.c
@@ -103,6 +103,7 @@ SplashDecodePng(Splash * splash, png_rw_ptr read_func, void *io_ptr)
     if (png_get_gAMA(png_ptr, info_ptr, &gamma))
         png_set_gamma(png_ptr, 2.2, gamma);
 
+    png_set_interlace_handling(png_ptr);
     png_read_update_info(png_ptr, info_ptr);
 
     rowbytes = png_get_rowbytes(png_ptr, info_ptr);

From 730f05c91c2ff7b43428a87b581d25343b58a58a Mon Sep 17 00:00:00 2001
From: Vadim Pakhnushev 
Date: Thu, 10 Dec 2015 12:13:12 +0300
Subject: [PATCH 024/109] 8143002: [Parfait] JNI exception pending in
 fontpath.c:1300

Reviewed-by: prr, serb
---
 .../unix/native/common/awt/fontpath.c         | 22 ++++++++++++++-----
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/jdk/src/java.desktop/unix/native/common/awt/fontpath.c b/jdk/src/java.desktop/unix/native/common/awt/fontpath.c
index 6355e273a58..c0d99e5eb98 100644
--- a/jdk/src/java.desktop/unix/native/common/awt/fontpath.c
+++ b/jdk/src/java.desktop/unix/native/common/awt/fontpath.c
@@ -1156,8 +1156,8 @@ Java_sun_font_FontConfigManager_getFontConfig
             continue;
         }
         pattern = (*FcNameParse)((FcChar8 *)fcName);
+        (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
         if (pattern == NULL) {
-            (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
             closeFontConfig(libfontconfig, JNI_FALSE);
             return;
         }
@@ -1175,7 +1175,6 @@ Java_sun_font_FontConfigManager_getFontConfig
         fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result);
         if (fontset == NULL) {
             (*FcPatternDestroy)(pattern);
-            (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
             closeFontConfig(libfontconfig, JNI_FALSE);
             return;
         }
@@ -1207,7 +1206,6 @@ Java_sun_font_FontConfigManager_getFontConfig
             }
             (*FcPatternDestroy)(pattern);
             (*FcFontSetDestroy)(fontset);
-            (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
             closeFontConfig(libfontconfig, JNI_FALSE);
             return;
         }
@@ -1249,8 +1247,6 @@ Java_sun_font_FontConfigManager_getFontConfig
                 free(file);
                 (*FcPatternDestroy)(pattern);
                 (*FcFontSetDestroy)(fontset);
-                (*env)->ReleaseStringUTFChars(env,
-                                              fcNameStr, (const char*)fcName);
                 closeFontConfig(libfontconfig, JNI_FALSE);
                 return;
             }
@@ -1298,6 +1294,16 @@ Java_sun_font_FontConfigManager_getFontConfig
         if (includeFallbacks) {
             fcFontArr =
                 (*env)->NewObjectArray(env, fontCount, fcFontClass, NULL);
+            if (IS_NULL(fcFontArr)) {
+                free(family);
+                free(fullname);
+                free(styleStr);
+                free(file);
+                (*FcPatternDestroy)(pattern);
+                (*FcFontSetDestroy)(fontset);
+                closeFontConfig(libfontconfig, JNI_FALSE);
+                return;
+            }
             (*env)->SetObjectField(env,fcCompFontObj, fcAllFontsID, fcFontArr);
         }
         fn=0;
@@ -1306,18 +1312,23 @@ Java_sun_font_FontConfigManager_getFontConfig
             if (family[j] != NULL) {
                 jobject fcFont =
                     (*env)->NewObject(env, fcFontClass, fcFontCons);
+                if (IS_NULL(fcFont)) break;
                 jstr = (*env)->NewStringUTF(env, (const char*)family[j]);
+                if (IS_NULL(jstr)) break;
                 (*env)->SetObjectField(env, fcFont, familyNameID, jstr);
                 if (file[j] != NULL) {
                     jstr = (*env)->NewStringUTF(env, (const char*)file[j]);
+                    if (IS_NULL(jstr)) break;
                     (*env)->SetObjectField(env, fcFont, fontFileID, jstr);
                 }
                 if (styleStr[j] != NULL) {
                     jstr = (*env)->NewStringUTF(env, (const char*)styleStr[j]);
+                    if (IS_NULL(jstr)) break;
                     (*env)->SetObjectField(env, fcFont, styleNameID, jstr);
                 }
                 if (fullname[j] != NULL) {
                     jstr = (*env)->NewStringUTF(env, (const char*)fullname[j]);
+                    if (IS_NULL(jstr)) break;
                     (*env)->SetObjectField(env, fcFont, fullNameID, jstr);
                 }
                 if (fn==0) {
@@ -1331,7 +1342,6 @@ Java_sun_font_FontConfigManager_getFontConfig
                 }
             }
         }
-        (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName);
         (*FcFontSetDestroy)(fontset);
         (*FcPatternDestroy)(pattern);
         free(family);

From c19bf5ef498a66ba52e3796bf202612fedcfb2ad Mon Sep 17 00:00:00 2001
From: Volker Simonis 
Date: Mon, 14 Dec 2015 15:32:03 +0100
Subject: [PATCH 025/109] 8145212: ISO-8859-1 isn't properly handled as
 'fastEncoding' in jni_util.c

Reviewed-by: martin, rriggs
---
 jdk/src/java.base/share/native/libjava/jni_util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/jdk/src/java.base/share/native/libjava/jni_util.c b/jdk/src/java.base/share/native/libjava/jni_util.c
index 7308b08b192..89f6edb7c03 100644
--- a/jdk/src/java.base/share/native/libjava/jni_util.c
+++ b/jdk/src/java.base/share/native/libjava/jni_util.c
@@ -660,7 +660,8 @@ initializeEncoding(JNIEnv *env)
             */
                     if ((strcmp(encname, "8859_1") == 0) ||
                         (strcmp(encname, "ISO8859-1") == 0) ||
-                        (strcmp(encname, "ISO8859_1") == 0))
+                        (strcmp(encname, "ISO8859_1") == 0) ||
+                        (strcmp(encname, "ISO-8859-1") == 0))
                         fastEncoding = FAST_8859_1;
                     else if (strcmp(encname, "ISO646-US") == 0)
                         fastEncoding = FAST_646_US;

From c0cbd031f0c0edf1984f4bcbf6456989e8e85200 Mon Sep 17 00:00:00 2001
From: Alexander Kulyakhtin 
Date: Wed, 16 Dec 2015 19:59:23 +0300
Subject: [PATCH 026/109] 8145408: com/sun/jdi/BreakpointWithFullGC.sh Required
 output "Full GC" not found

Modified the test so it correctly parses the new debug output

Reviewed-by: jbachorik
---
 jdk/test/com/sun/jdi/BreakpointWithFullGC.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/jdk/test/com/sun/jdi/BreakpointWithFullGC.sh b/jdk/test/com/sun/jdi/BreakpointWithFullGC.sh
index f7bcb89e715..81baff826e4 100644
--- a/jdk/test/com/sun/jdi/BreakpointWithFullGC.sh
+++ b/jdk/test/com/sun/jdi/BreakpointWithFullGC.sh
@@ -121,7 +121,8 @@ jdbFailIfNotPresent 'System\..*bottom of loop'
 jdbFailIfNotPresent 'System\..*end of test'
 
 # make sure we had at least one full GC
-debuggeeFailIfNotPresent 'Full GC'
+# Prior to JDK9-B95, the pattern was 'Full GC'
+debuggeeMatchRegexp '^.*?\bPause Full\b\(System.gc\(\)\)\b.*?$'
 
 # check for error message due to thread ID change
 debuggeeFailIfPresent \

From fbce4be2e6fdb120a30290894364acab7cba8008 Mon Sep 17 00:00:00 2001
From: Jaroslav Bachorik 
Date: Fri, 11 Dec 2015 14:02:41 +0100
Subject: [PATCH 027/109] 8138677: IllegalAccessException Class
 sun.usagetracker.UsageTrackerClient$4 (module java.base) can not access a
 member of class java.lang.management.ManagementFactory (module
 java.management)

Reviewed-by: alanb, mchung, dholmes, erikj, ihse
---
 jdk/make/lib/CoreLibraries.gmk                           | 9 ++++++++-
 jdk/make/lib/LibCommon.gmk                               | 7 ++++++-
 jdk/src/java.base/share/native/include/jvm.h             | 3 +++
 jdk/src/java.management/share/native/include/jmm.h       | 6 ------
 .../share/native/libmanagement/VMManagementImpl.c        | 2 +-
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk
index ace022c0d87..926ebc7ce38 100644
--- a/jdk/make/lib/CoreLibraries.gmk
+++ b/jdk/make/lib/CoreLibraries.gmk
@@ -25,6 +25,10 @@
 
 WIN_VERIFY_LIB := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libverify/verify.lib
 
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, jdk, lib/CoreLibraries.gmk))
+
+
 ##########################################################################################
 # libfdlibm is statically linked with libjava below and not delivered into the
 # product on its own.
@@ -119,6 +123,9 @@ LIBJAVA_CFLAGS := $(addprefix -I, $(LIBJAVA_SRC_DIRS)) \
     -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
     -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'
 
+# Make it possible to override this variable
+LIBJAVA_MAPFILE ?= $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers
+
 ifeq ($(OPENJDK_TARGET_OS), macosx)
   BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c
   BUILD_LIBJAVA_java_props_macosx.c_CFLAGS := -x objective-c
@@ -146,7 +153,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
     System.c_CFLAGS := $(VERSION_CFLAGS), \
     jdk_util.c_CFLAGS := $(VERSION_CFLAGS), \
     DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \
-    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers, \
+    MAPFILE := $(LIBJAVA_MAPFILE), \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \
diff --git a/jdk/make/lib/LibCommon.gmk b/jdk/make/lib/LibCommon.gmk
index d1bfc4ed3a5..85d00c42073 100644
--- a/jdk/make/lib/LibCommon.gmk
+++ b/jdk/make/lib/LibCommon.gmk
@@ -27,6 +27,11 @@ include $(SPEC)
 include MakeBase.gmk
 include NativeCompilation.gmk
 
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, jdk, lib/LibCommon.gmk))
+
+################################################################################
+
 GLOBAL_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/common/version.rc
 
 # Absolute paths to lib files on windows for use in LDFLAGS. Should figure out a more
@@ -50,7 +55,7 @@ endif
 # Find the default set of src dirs for a native library.
 # Param 1 - module name
 # Param 2 - library name
-FindSrcDirsForLib = \
+FindSrcDirsForLib += \
   $(call uniq, $(wildcard \
       $(JDK_TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/lib$(strip $2) \
       $(JDK_TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/lib$(strip $2) \
diff --git a/jdk/src/java.base/share/native/include/jvm.h b/jdk/src/java.base/share/native/include/jvm.h
index d99148a28cc..2f65c1a2e97 100644
--- a/jdk/src/java.base/share/native/include/jvm.h
+++ b/jdk/src/java.base/share/native/include/jvm.h
@@ -208,6 +208,9 @@ JVM_FillStackFrames(JNIEnv* env, jclass cls,
 JNIEXPORT void JNICALL
 JVM_SetMethodInfo(JNIEnv* env, jobject frame);
 
+JNIEXPORT jobjectArray JNICALL
+JVM_GetVmArguments(JNIEnv *env);
+
 /*
  * java.lang.Thread
  */
diff --git a/jdk/src/java.management/share/native/include/jmm.h b/jdk/src/java.management/share/native/include/jmm.h
index 1730541d076..6c3894ad8dc 100644
--- a/jdk/src/java.management/share/native/include/jmm.h
+++ b/jdk/src/java.management/share/native/include/jmm.h
@@ -227,16 +227,10 @@ typedef struct jmmInterface_1_ {
   jint         (JNICALL *GetOptionalSupport)     (JNIEnv *env,
                                                   jmmOptionalSupport* support_ptr);
 
-  /* This is used by JDK 6 and earlier.
-   * For JDK 7 and after, use GetInputArgumentArray.
-   */
-  jobject      (JNICALL *GetInputArguments)      (JNIEnv *env);
-
   jint         (JNICALL *GetThreadInfo)          (JNIEnv *env,
                                                   jlongArray ids,
                                                   jint maxDepth,
                                                   jobjectArray infoArray);
-  jobjectArray (JNICALL *GetInputArgumentArray)  (JNIEnv *env);
 
   jobjectArray (JNICALL *GetMemoryPools)         (JNIEnv* env, jobject mgr);
 
diff --git a/jdk/src/java.management/share/native/libmanagement/VMManagementImpl.c b/jdk/src/java.management/share/native/libmanagement/VMManagementImpl.c
index 1aa09d2c41e..7743c359764 100644
--- a/jdk/src/java.management/share/native/libmanagement/VMManagementImpl.c
+++ b/jdk/src/java.management/share/native/libmanagement/VMManagementImpl.c
@@ -112,7 +112,7 @@ JNIEXPORT jobjectArray JNICALL
 Java_sun_management_VMManagementImpl_getVmArguments0
   (JNIEnv *env, jobject dummy)
 {
-    return jmm_interface->GetInputArgumentArray(env);
+    return JVM_GetVmArguments(env);
 }
 
 JNIEXPORT jlong JNICALL

From 441b190d5c827543dab88cddba3a6d39f1a5d3de Mon Sep 17 00:00:00 2001
From: Frederic Parain 
Date: Fri, 11 Dec 2015 09:08:12 -0800
Subject: [PATCH 028/109] 8046936: JEP 270: Reserved Stack Areas for Critical
 Sections

Reviewed-by: acorn, dcubed
---
 .../locks/AbstractQueuedSynchronizer.java     |  5 ++
 .../util/concurrent/locks/ReentrantLock.java  |  5 ++
 .../vm/annotation/ReservedStackAccess.java    | 52 +++++++++++++++++++
 3 files changed, 62 insertions(+)
 create mode 100644 jdk/src/java.base/share/classes/jdk/internal/vm/annotation/ReservedStackAccess.java

diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
index 5a79376d340..a90e4fdd629 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
@@ -39,6 +39,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.concurrent.TimeUnit;
+import jdk.internal.vm.annotation.ReservedStackAccess;
 
 /**
  * Provides a framework for implementing blocking locks and related
@@ -886,6 +887,7 @@ public abstract class AbstractQueuedSynchronizer
      * @param arg the acquire argument
      * @return {@code true} if interrupted while waiting
      */
+    @ReservedStackAccess
     final boolean acquireQueued(final Node node, int arg) {
         try {
             boolean interrupted = false;
@@ -1218,6 +1220,7 @@ public abstract class AbstractQueuedSynchronizer
      *        {@link #tryAcquire} but is otherwise uninterpreted and
      *        can represent anything you like.
      */
+    @ReservedStackAccess
     public final void acquire(int arg) {
         if (!tryAcquire(arg) &&
             acquireQueued(addWaiter(Node.EXCLUSIVE), arg))
@@ -1281,6 +1284,7 @@ public abstract class AbstractQueuedSynchronizer
      *        can represent anything you like.
      * @return the value returned from {@link #tryRelease}
      */
+    @ReservedStackAccess
     public final boolean release(int arg) {
         if (tryRelease(arg)) {
             Node h = head;
@@ -1361,6 +1365,7 @@ public abstract class AbstractQueuedSynchronizer
      *        and can represent anything you like.
      * @return the value returned from {@link #tryReleaseShared}
      */
+    @ReservedStackAccess
     public final boolean releaseShared(int arg) {
         if (tryReleaseShared(arg)) {
             doReleaseShared();
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java
index 9df25057041..c39c94724e7 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java
@@ -37,6 +37,7 @@ package java.util.concurrent.locks;
 
 import java.util.Collection;
 import java.util.concurrent.TimeUnit;
+import jdk.internal.vm.annotation.ReservedStackAccess;
 
 /**
  * A reentrant mutual exclusion {@link Lock} with the same basic
@@ -127,6 +128,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
          * Performs non-fair tryLock.  tryAcquire is implemented in
          * subclasses, but both need nonfair try for trylock method.
          */
+        @ReservedStackAccess
         final boolean nonfairTryAcquire(int acquires) {
             final Thread current = Thread.currentThread();
             int c = getState();
@@ -146,6 +148,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
             return false;
         }
 
+        @ReservedStackAccess
         protected final boolean tryRelease(int releases) {
             int c = getState() - releases;
             if (Thread.currentThread() != getExclusiveOwnerThread())
@@ -203,6 +206,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
          * Performs lock.  Try immediate barge, backing up to normal
          * acquire on failure.
          */
+        @ReservedStackAccess
         final void lock() {
             if (compareAndSetState(0, 1))
                 setExclusiveOwnerThread(Thread.currentThread());
@@ -229,6 +233,7 @@ public class ReentrantLock implements Lock, java.io.Serializable {
          * Fair version of tryAcquire.  Don't grant access unless
          * recursive call or no waiters or is first.
          */
+        @ReservedStackAccess
         protected final boolean tryAcquire(int acquires) {
             final Thread current = Thread.currentThread();
             int c = getState();
diff --git a/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/ReservedStackAccess.java b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/ReservedStackAccess.java
new file mode 100644
index 00000000000..72ddc4c30f6
--- /dev/null
+++ b/jdk/src/java.base/share/classes/jdk/internal/vm/annotation/ReservedStackAccess.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.vm.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 

An annotation expressing that a method is especially sensitive + * to stack overflows. This is a hint the JVM can use to grant access to + * extra stack space when executing this code if such feature is supported + * by the JVM. The JVM is free to ignore this annotation. + * + * A possible way for the JVM to improve the execution context for methods + * with this annotation is to reserve part of the thread's execution stack + * for them. Access to this section of the stack would be denied by default + * but could be granted if the JVM detects a possible stack overflow and + * the thread's call stack includes at least one annotated method. Even if + * access to this reserved area has been granted, the JVM might decide to + * throw a delayed StackOverflowError when the thread exits the annotated + * method. + * + * @since 1.9 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface ReservedStackAccess { } From 4cebcd8b2d4f5e56a8fdbffd99e2a61d07c04175 Mon Sep 17 00:00:00 2001 From: Alexander Smundak Date: Fri, 11 Dec 2015 10:45:58 -0800 Subject: [PATCH 029/109] 8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling Add ppc64le/jvm.cfg, check for the ppc64le in addition to ppc64 in tests Co-authored-by: Andrew Hughes Reviewed-by: dholmes, ihse --- jdk/src/java.base/unix/conf/ppc64le/jvm.cfg | 34 ++++++++++++++++++++ jdk/test/sun/security/pkcs11/PKCS11Test.java | 1 + jdk/test/tools/launcher/Settings.java | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 jdk/src/java.base/unix/conf/ppc64le/jvm.cfg diff --git a/jdk/src/java.base/unix/conf/ppc64le/jvm.cfg b/jdk/src/java.base/unix/conf/ppc64le/jvm.cfg new file mode 100644 index 00000000000..6c024af438f --- /dev/null +++ b/jdk/src/java.base/unix/conf/ppc64le/jvm.cfg @@ -0,0 +1,34 @@ +# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# +# List of JVMs that can be used as an option to java, javac, etc. +# Order is important -- first in this list is the default JVM. +# NOTE that this both this file and its format are UNSUPPORTED and +# WILL GO AWAY in a future release. +# +# You may also select a JVM in an arbitrary location with the +# "-XXaltjvm=" option, but that too is unsupported +# and may not be available in a future release. +# +-server KNOWN +-client IGNORE diff --git a/jdk/test/sun/security/pkcs11/PKCS11Test.java b/jdk/test/sun/security/pkcs11/PKCS11Test.java index 1e738601104..e0a17eaa87e 100644 --- a/jdk/test/sun/security/pkcs11/PKCS11Test.java +++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java @@ -540,6 +540,7 @@ public abstract class PKCS11Test { "/usr/lib/x86_64-linux-gnu/", "/usr/lib/x86_64-linux-gnu/nss/", "/usr/lib64/"}); osMap.put("Linux-ppc64-64", new String[]{"/usr/lib64/"}); + osMap.put("Linux-ppc64le-64", new String[]{"/usr/lib64/"}); osMap.put("Windows-x86-32", new String[]{ PKCS11_BASE + "/nss/lib/windows-i586/".replace('/', SEP)}); osMap.put("Windows-amd64-64", new String[]{ diff --git a/jdk/test/tools/launcher/Settings.java b/jdk/test/tools/launcher/Settings.java index 16fd29b0b16..8d45c8288b6 100644 --- a/jdk/test/tools/launcher/Settings.java +++ b/jdk/test/tools/launcher/Settings.java @@ -74,7 +74,7 @@ public class Settings extends TestHelper { static void runTestOptionDefault() throws IOException { String stackSize = "256"; // in kb - if (getArch().equals("ppc64")) { + if (getArch().equals("ppc64") || getArch().equals("ppc64le")) { stackSize = "800"; } TestResult tr = null; From 2f861a922589f25de922140bbf108a3fd3f95d06 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Tue, 15 Dec 2015 12:59:00 +0000 Subject: [PATCH 030/109] 8144773: Further reduce use of MD5 Reviewed-by: mullan, wetmore, jnimeh, ahgross --- .../sun/security/ssl/ClientHandshaker.java | 10 +-- .../sun/security/ssl/HandshakeMessage.java | 4 +- .../classes/sun/security/ssl/Handshaker.java | 2 +- .../sun/security/ssl/ServerHandshaker.java | 37 ++++++++-- .../ssl/SignatureAndHashAlgorithm.java | 69 +++++++++---------- .../share/conf/security/java.security | 2 +- .../CriticalSubjectAltName.java | 8 ++- .../ssl/ServerName/SSLSocketSNISensitive.java | 8 ++- .../TLSv11/EmptyCertificateAuthorities.java | 8 ++- .../javax/net/ssl/TLSv12/ShortRSAKey512.java | 4 +- .../javax/net/ssl/TLSv12/ShortRSAKeyGCM.java | 4 +- .../HttpsURLConnection/DNSIdentities.java | 8 ++- .../IPAddressIPIdentities.java | 8 ++- .../HttpsURLConnection/IPIdentities.java | 8 ++- .../https/HttpsURLConnection/Identities.java | 8 ++- .../ssl/SSLContextImpl/MD2InTrustAnchor.java | 8 ++- .../ssl/SSLContextImpl/TrustTrustedCert.java | 8 ++- .../ssl/X509KeyManager/PreferredKey.java | 8 ++- .../BasicConstraints.java | 8 ++- .../X509TrustManagerImpl/PKIXExtendedTM.java | 8 ++- .../X509TrustManagerImpl/SelfIssuedCert.java | 8 ++- .../SunX509ExtendedTM.java | 8 ++- 22 files changed, 150 insertions(+), 94 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java index 172baa870e0..05d5e2f7906 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java @@ -333,7 +333,7 @@ final class ClientHandshaker extends Handshaker { input, serverKey, clnt_random.random_bytes, svr_random.random_bytes, messageLen, - localSupportedSignAlgs, protocolVersion); + getLocalSupportedSignAlgs(), protocolVersion); handshakeState.update(dhSrvKeyExchange, resumingSession); this.serverKeyExchange(dhSrvKeyExchange); } catch (GeneralSecurityException e) { @@ -348,7 +348,7 @@ final class ClientHandshaker extends Handshaker { new ECDH_ServerKeyExchange (input, serverKey, clnt_random.random_bytes, svr_random.random_bytes, - localSupportedSignAlgs, protocolVersion); + getLocalSupportedSignAlgs(), protocolVersion); handshakeState.update(ecdhSrvKeyExchange, resumingSession); this.serverKeyExchange(ecdhSrvKeyExchange); } catch (GeneralSecurityException e) { @@ -398,7 +398,7 @@ final class ClientHandshaker extends Handshaker { Collection supportedPeerSignAlgs = SignatureAndHashAlgorithm.getSupportedAlgorithms( - peerSignAlgs); + algorithmConstraints, peerSignAlgs); if (supportedPeerSignAlgs.isEmpty()) { throw new SSLHandshakeException( "No supported signature and hash algorithm in common"); @@ -1211,8 +1211,8 @@ final class ClientHandshaker extends Handshaker { if (protocolVersion.useTLS12PlusSpec()) { preferableSignatureAlgorithm = SignatureAndHashAlgorithm.getPreferableAlgorithm( - peerSupportedSignAlgs, signingKey.getAlgorithm(), - signingKey); + getPeerSupportedSignAlgs(), + signingKey.getAlgorithm(), signingKey); if (preferableSignatureAlgorithm == null) { throw new SSLHandshakeException( diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java index d0097cea3a5..86c72bac38a 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java @@ -1943,7 +1943,7 @@ static final class CertificateVerify extends HandshakeMessage { // the signature bytes private byte[] signature; - // protocol version being established using this ServerKeyExchange message + // protocol version being established using this CertificateVerify message ProtocolVersion protocolVersion; // the preferable signature algorithm used by this CertificateVerify message @@ -1996,7 +1996,7 @@ static final class CertificateVerify extends HandshakeMessage { preferableSignatureAlgorithm)) { throw new SSLHandshakeException( "Unsupported SignatureAndHashAlgorithm in " + - "ServerKeyExchange message"); + "CertificateVerify message"); } } diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java index a77967dfa66..d9441526400 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java @@ -90,7 +90,7 @@ abstract class Handshaker { AlgorithmConstraints algorithmConstraints = null; // Local supported signature and algorithms - Collection localSupportedSignAlgs; + private Collection localSupportedSignAlgs; // Peer supported signature and algorithms Collection peerSupportedSignAlgs; diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java index a69c2c61fb2..0b8072ff679 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java @@ -320,7 +320,7 @@ final class ServerHandshaker extends Handshaker { case HandshakeMessage.ht_certificate_verify: CertificateVerify cvm = new CertificateVerify(input, - localSupportedSignAlgs, protocolVersion); + getLocalSupportedSignAlgs(), protocolVersion); handshakeState.update(cvm, resumingSession); this.clientCertificateVerify(cvm); @@ -772,11 +772,10 @@ final class ServerHandshaker extends Handshaker { Collection supportedPeerSignAlgs = SignatureAndHashAlgorithm.getSupportedAlgorithms( - peerSignAlgs); + algorithmConstraints, peerSignAlgs); if (supportedPeerSignAlgs.isEmpty()) { throw new SSLHandshakeException( - "No supported signature and hash algorithm " + - "in common"); + "No signature and hash algorithm in common"); } setPeerSupportedSignAlgs(supportedPeerSignAlgs); @@ -1351,6 +1350,13 @@ final class ServerHandshaker extends Handshaker { supportedSignAlgs = new ArrayList(1); supportedSignAlgs.add(algorithm); + + supportedSignAlgs = + SignatureAndHashAlgorithm.getSupportedAlgorithms( + algorithmConstraints, supportedSignAlgs); + + // May be no default activated signature algorithm, but + // let the following process make the final decision. } // Sets the peer supported signature algorithm to use in KM @@ -1395,6 +1401,11 @@ final class ServerHandshaker extends Handshaker { SignatureAndHashAlgorithm.getPreferableAlgorithm( supportedSignAlgs, "RSA", privateKey); if (preferableSignatureAlgorithm == null) { + if ((debug != null) && Debug.isOn("handshake")) { + System.out.println( + "No signature and hash algorithm for cipher " + + suite); + } return false; } } @@ -1413,6 +1424,11 @@ final class ServerHandshaker extends Handshaker { SignatureAndHashAlgorithm.getPreferableAlgorithm( supportedSignAlgs, "RSA", privateKey); if (preferableSignatureAlgorithm == null) { + if ((debug != null) && Debug.isOn("handshake")) { + System.out.println( + "No signature and hash algorithm for cipher " + + suite); + } return false; } } @@ -1428,6 +1444,11 @@ final class ServerHandshaker extends Handshaker { SignatureAndHashAlgorithm.getPreferableAlgorithm( supportedSignAlgs, "DSA"); if (preferableSignatureAlgorithm == null) { + if ((debug != null) && Debug.isOn("handshake")) { + System.out.println( + "No signature and hash algorithm for cipher " + + suite); + } return false; } } @@ -1446,6 +1467,11 @@ final class ServerHandshaker extends Handshaker { SignatureAndHashAlgorithm.getPreferableAlgorithm( supportedSignAlgs, "ECDSA"); if (preferableSignatureAlgorithm == null) { + if ((debug != null) && Debug.isOn("handshake")) { + System.out.println( + "No signature and hash algorithm for cipher " + + suite); + } return false; } } @@ -1487,7 +1513,8 @@ final class ServerHandshaker extends Handshaker { ClientKeyExchangeService.find(keyExchange.name); if (p == null) { // internal error, unknown key exchange - throw new RuntimeException("Unrecognized cipherSuite: " + suite); + throw new RuntimeException( + "Unrecognized cipherSuite: " + suite); } // need service creds if (serviceCreds == null) { diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java index 6eb36e8ca84..59568562a3c 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java @@ -166,10 +166,13 @@ final class SignatureAndHashAlgorithm { // Get supported algorithm collection from an untrusted collection static Collection getSupportedAlgorithms( + AlgorithmConstraints constraints, Collection algorithms ) { Collection supported = new ArrayList<>(); for (SignatureAndHashAlgorithm sigAlg : algorithms) { - if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { + if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && + constraints.permits(SIGNATURE_PRIMITIVE_SET, + sigAlg.algorithm, null)) { supported.add(sigAlg); } } @@ -233,30 +236,42 @@ final class SignatureAndHashAlgorithm { } static SignatureAndHashAlgorithm getPreferableAlgorithm( - Collection algorithms, - String expected, PrivateKey signingKey) { + Collection algorithms, + String expected, PrivateKey signingKey) { - if (expected == null && !algorithms.isEmpty()) { - for (SignatureAndHashAlgorithm sigAlg : algorithms) { - if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { - return sigAlg; + int maxDigestLength = getMaxDigestLength(signingKey); + for (SignatureAndHashAlgorithm algorithm : algorithms) { + int signValue = algorithm.id & 0xFF; + if ((expected == null) || + (expected.equalsIgnoreCase("rsa") && + signValue == SignatureAlgorithm.RSA.value) || + (expected.equalsIgnoreCase("dsa") && + signValue == SignatureAlgorithm.DSA.value) || + (expected.equalsIgnoreCase("ecdsa") && + signValue == SignatureAlgorithm.ECDSA.value) || + (expected.equalsIgnoreCase("ec") && + signValue == SignatureAlgorithm.ECDSA.value)) { + + if (algorithm.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && + algorithm.hash.length <= maxDigestLength) { + + return algorithm; } } - - return null; // no supported algorithm } - if (expected == null ) { - return null; // no expected algorithm, no supported algorithm - } + return null; + } - /* - * Need to check RSA key length to match the length of hash value - */ + /* + * Need to check key length to match the length of hash value + */ + private static int getMaxDigestLength(PrivateKey signingKey) { int maxDigestLength = Integer.MAX_VALUE; + + // only need to check RSA algorithm at present. if (signingKey != null && - "rsa".equalsIgnoreCase(signingKey.getAlgorithm()) && - expected.equalsIgnoreCase("rsa")) { + "rsa".equalsIgnoreCase(signingKey.getAlgorithm())) { /* * RSA keys of 512 bits have been shown to be practically * breakable, it does not make much sense to use the strong @@ -284,25 +299,7 @@ final class SignatureAndHashAlgorithm { // preferable hash algorithm. } - for (SignatureAndHashAlgorithm algorithm : algorithms) { - int signValue = algorithm.id & 0xFF; - if (expected.equalsIgnoreCase("rsa") && - signValue == SignatureAlgorithm.RSA.value) { - if (algorithm.hash.length <= maxDigestLength) { - return algorithm; - } - } else if ( - (expected.equalsIgnoreCase("dsa") && - signValue == SignatureAlgorithm.DSA.value) || - (expected.equalsIgnoreCase("ecdsa") && - signValue == SignatureAlgorithm.ECDSA.value) || - (expected.equalsIgnoreCase("ec") && - signValue == SignatureAlgorithm.ECDSA.value)) { - return algorithm; - } - } - - return null; + return maxDigestLength; } static enum HashAlgorithm { diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index b0982712a46..be48902f550 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -576,7 +576,7 @@ jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 # # Example: # jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048 -jdk.tls.disabledAlgorithms=SSLv3, RC4, DH keySize < 768 +jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 768 # Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS) # processing in JSSE implementation. diff --git a/jdk/test/javax/net/ssl/HttpsURLConnection/CriticalSubjectAltName.java b/jdk/test/javax/net/ssl/HttpsURLConnection/CriticalSubjectAltName.java index f9abcd670b2..d4eca8b5776 100644 --- a/jdk/test/javax/net/ssl/HttpsURLConnection/CriticalSubjectAltName.java +++ b/jdk/test/javax/net/ssl/HttpsURLConnection/CriticalSubjectAltName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -159,8 +159,10 @@ public class CriticalSubjectAltName implements HostnameVerifier { public static void main(String[] args) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); String keyFilename = System.getProperty("test.src", "./") + "/" + pathToStores + diff --git a/jdk/test/javax/net/ssl/ServerName/SSLSocketSNISensitive.java b/jdk/test/javax/net/ssl/ServerName/SSLSocketSNISensitive.java index ac4f8a11ab1..031da1fdda9 100644 --- a/jdk/test/javax/net/ssl/ServerName/SSLSocketSNISensitive.java +++ b/jdk/test/javax/net/ssl/ServerName/SSLSocketSNISensitive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -433,8 +433,10 @@ public class SSLSocketSNISensitive { public static void main(String[] args) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java b/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java index 572ac2cce8c..97383271dae 100644 --- a/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java +++ b/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -230,8 +230,10 @@ public class EmptyCertificateAuthorities { public static void main(String[] args) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); String keyFilename = System.getProperty("test.src", ".") + "/" + pathToStores + diff --git a/jdk/test/javax/net/ssl/TLSv12/ShortRSAKey512.java b/jdk/test/javax/net/ssl/TLSv12/ShortRSAKey512.java index c3bf12260ec..0c26c5f0ff0 100644 --- a/jdk/test/javax/net/ssl/TLSv12/ShortRSAKey512.java +++ b/jdk/test/javax/net/ssl/TLSv12/ShortRSAKey512.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -282,6 +282,8 @@ public class ShortRSAKey512 { // reset the security property to make sure that the algorithms // and keys used in this test are not disabled. Security.setProperty("jdk.certpath.disabledAlgorithms", "MD2"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/javax/net/ssl/TLSv12/ShortRSAKeyGCM.java b/jdk/test/javax/net/ssl/TLSv12/ShortRSAKeyGCM.java index fe4f91460d6..6ccfa03bcc1 100644 --- a/jdk/test/javax/net/ssl/TLSv12/ShortRSAKeyGCM.java +++ b/jdk/test/javax/net/ssl/TLSv12/ShortRSAKeyGCM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -303,6 +303,8 @@ public class ShortRSAKeyGCM { // reset the security property to make sure that the algorithms // and keys used in this test are not disabled. Security.setProperty("jdk.certpath.disabledAlgorithms", "MD2"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) { System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java index 44c60a2318a..e0c46743d4d 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -745,8 +745,10 @@ public class DNSIdentities { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java index 6743d1c66d1..e282c2c888f 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPAddressIPIdentities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -746,8 +746,10 @@ public class IPAddressIPIdentities { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java index cf548d48355..8cc09a76252 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/IPIdentities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -745,8 +745,10 @@ public class IPIdentities { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/Identities.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/Identities.java index 4f3343fa61e..28f61c79f1c 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/Identities.java +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/Identities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -745,8 +745,10 @@ public class Identities { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/SSLContextImpl/MD2InTrustAnchor.java b/jdk/test/sun/security/ssl/SSLContextImpl/MD2InTrustAnchor.java index 9b695a2fc7b..9d8ee1d5287 100644 --- a/jdk/test/sun/security/ssl/SSLContextImpl/MD2InTrustAnchor.java +++ b/jdk/test/sun/security/ssl/SSLContextImpl/MD2InTrustAnchor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -287,8 +287,10 @@ public class MD2InTrustAnchor { public static void main(String[] args) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java index 01fc5dc5d86..b812ba5f60e 100644 --- a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java +++ b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -339,8 +339,10 @@ public class TrustTrustedCert { public static void main(String[] args) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/X509KeyManager/PreferredKey.java b/jdk/test/sun/security/ssl/X509KeyManager/PreferredKey.java index 0006090a866..0f249f53516 100644 --- a/jdk/test/sun/security/ssl/X509KeyManager/PreferredKey.java +++ b/jdk/test/sun/security/ssl/X509KeyManager/PreferredKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -57,8 +57,10 @@ public class PreferredKey { public static void main(String[] args) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); KeyStore ks; KeyManagerFactory kmf; diff --git a/jdk/test/sun/security/ssl/X509TrustManagerImpl/BasicConstraints.java b/jdk/test/sun/security/ssl/X509TrustManagerImpl/BasicConstraints.java index 4f64cd1b758..69d3384bafa 100644 --- a/jdk/test/sun/security/ssl/X509TrustManagerImpl/BasicConstraints.java +++ b/jdk/test/sun/security/ssl/X509TrustManagerImpl/BasicConstraints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -458,8 +458,10 @@ public class BasicConstraints { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java b/jdk/test/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java index 3b2587f6913..8a5db1064e0 100644 --- a/jdk/test/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java +++ b/jdk/test/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -794,8 +794,10 @@ public class PKIXExtendedTM { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/X509TrustManagerImpl/SelfIssuedCert.java b/jdk/test/sun/security/ssl/X509TrustManagerImpl/SelfIssuedCert.java index a17541212b6..deaf18fb872 100644 --- a/jdk/test/sun/security/ssl/X509TrustManagerImpl/SelfIssuedCert.java +++ b/jdk/test/sun/security/ssl/X509TrustManagerImpl/SelfIssuedCert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -306,8 +306,10 @@ public class SelfIssuedCert { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/jdk/test/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java b/jdk/test/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java index 54b2de89219..ec893f90703 100644 --- a/jdk/test/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java +++ b/jdk/test/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -796,8 +796,10 @@ public class SunX509ExtendedTM { public static void main(String args[]) throws Exception { // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty( - "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.certpath.disabledAlgorithms", + "MD2, RSA keySize < 1024"); + Security.setProperty("jdk.tls.disabledAlgorithms", + "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); From 30fa8bd480ff3e9591e600d5ee36a746eec42430 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 17 Dec 2015 10:03:30 +0100 Subject: [PATCH 031/109] 8136924: Vectorized support for array equals/compare/mismatch using Unsafe Reviewed-by: plevart, jrose, kvn --- .../share/classes/java/util/Arrays.java | 480 ++++++--------- .../classes/java/util/ArraysSupport.java | 545 ++++++++++++++++++ 2 files changed, 732 insertions(+), 293 deletions(-) create mode 100644 jdk/src/java.base/share/classes/java/util/ArraysSupport.java diff --git a/jdk/src/java.base/share/classes/java/util/Arrays.java b/jdk/src/java.base/share/classes/java/util/Arrays.java index af64264b3f3..cc7b19de64e 100644 --- a/jdk/src/java.base/share/classes/java/util/Arrays.java +++ b/jdk/src/java.base/share/classes/java/util/Arrays.java @@ -110,7 +110,7 @@ public class Arrays { * Checks that {@code fromIndex} and {@code toIndex} are in * the range and throws an exception if they aren't. */ - private static void rangeCheck(int arrayLength, int fromIndex, int toIndex) { + static void rangeCheck(int arrayLength, int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IllegalArgumentException( "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); @@ -2579,11 +2579,7 @@ public class Arrays { if (a2.length != length) return false; - for (int i=0; i= 0) { + return Boolean.compare(a[i], b[i]); } return a.length - b.length; @@ -5880,11 +5819,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - boolean va = a[aFromIndex++]; - boolean vb = b[bFromIndex++]; - if (va != vb) return Boolean.compare(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Boolean.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -5939,9 +5878,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Byte.compare(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Byte.compare(a[i], b[i]); } return a.length - b.length; @@ -6014,11 +5954,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - byte va = a[aFromIndex++]; - byte vb = b[bFromIndex++]; - if (va != vb) return Byte.compare(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Byte.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6066,9 +6006,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Byte.compareUnsigned(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Byte.compareUnsigned(a[i], b[i]); } return a.length - b.length; @@ -6133,11 +6074,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - byte va = a[aFromIndex++]; - byte vb = b[bFromIndex++]; - if (va != vb) return Byte.compareUnsigned(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Byte.compareUnsigned(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6192,9 +6133,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Short.compare(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Short.compare(a[i], b[i]); } return a.length - b.length; @@ -6267,11 +6209,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - short va = a[aFromIndex++]; - short vb = b[bFromIndex++]; - if (va != vb) return Short.compare(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Short.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6319,9 +6261,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Short.compareUnsigned(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Short.compareUnsigned(a[i], b[i]); } return a.length - b.length; @@ -6385,11 +6328,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - short va = a[aFromIndex++]; - short vb = b[bFromIndex++]; - if (va != vb) return Short.compareUnsigned(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Short.compareUnsigned(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6444,9 +6387,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Character.compare(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Character.compare(a[i], b[i]); } return a.length - b.length; @@ -6519,11 +6463,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - char va = a[aFromIndex++]; - char vb = b[bFromIndex++]; - if (va != vb) return Character.compare(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Character.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6578,9 +6522,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Integer.compare(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Integer.compare(a[i], b[i]); } return a.length - b.length; @@ -6653,11 +6598,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - int va = a[aFromIndex++]; - int vb = b[bFromIndex++]; - if (va != vb) return Integer.compare(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Integer.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6705,9 +6650,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Integer.compareUnsigned(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Integer.compareUnsigned(a[i], b[i]); } return a.length - b.length; @@ -6771,11 +6717,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - int va = a[aFromIndex++]; - int vb = b[bFromIndex++]; - if (va != vb) return Integer.compareUnsigned(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Integer.compareUnsigned(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6830,9 +6776,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Long.compare(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Long.compare(a[i], b[i]); } return a.length - b.length; @@ -6905,11 +6852,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - long va = a[aFromIndex++]; - long vb = b[bFromIndex++]; - if (va != vb) return Long.compare(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Long.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -6957,9 +6904,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return Long.compareUnsigned(a[i], b[i]); + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Long.compareUnsigned(a[i], b[i]); } return a.length - b.length; @@ -7023,11 +6971,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - long va = a[aFromIndex++]; - long vb = b[bFromIndex++]; - if (va != vb) return Long.compareUnsigned(va, vb); + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Long.compareUnsigned(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -7082,13 +7030,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - float va = a[i], vb = b[i]; - if (Float.floatToRawIntBits(va) != Float.floatToRawIntBits(vb)) { - int c = Float.compare(va, vb); - if (c != 0) return c; - } + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Float.compare(a[i], b[i]); } return a.length - b.length; @@ -7161,13 +7106,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - float va = a[aFromIndex++], vb = b[bFromIndex++]; - if (Float.floatToRawIntBits(va) != Float.floatToRawIntBits(vb)) { - int c = Float.compare(va, vb); - if (c != 0) return c; - } + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Float.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -7222,13 +7165,10 @@ public class Arrays { if (a == null || b == null) return a == null ? -1 : 1; - int length = Math.min(a.length, b.length); - for (int i = 0; i < length; i++) { - double va = a[i], vb = b[i]; - if (Double.doubleToRawLongBits(va) != Double.doubleToRawLongBits(vb)) { - int c = Double.compare(va, vb); - if (c != 0) return c; - } + int i = ArraysSupport.mismatch(a, b, + Math.min(a.length, b.length)); + if (i >= 0) { + return Double.compare(a[i], b[i]); } return a.length - b.length; @@ -7301,13 +7241,11 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; - int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - double va = a[aFromIndex++], vb = b[bFromIndex++]; - if (Double.doubleToRawLongBits(va) != Double.doubleToRawLongBits(vb)) { - int c = Double.compare(va, vb); - if (c != 0) return c; - } + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + Math.min(aLength, bLength)); + if (i >= 0) { + return Double.compare(a[aFromIndex + i], b[bFromIndex + i]); } return aLength - bLength; @@ -7673,11 +7611,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -7749,11 +7684,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - if (a[aFromIndex++] != b[bFromIndex++]) return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch byte @@ -7804,11 +7738,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -7880,11 +7811,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - if (a[aFromIndex++] != b[bFromIndex++]) return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch char @@ -7935,11 +7865,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -8011,11 +7938,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - if (a[aFromIndex++] != b[bFromIndex++]) return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch short @@ -8066,11 +7992,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -8142,11 +8065,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - if (a[aFromIndex++] != b[bFromIndex++]) return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch int @@ -8197,11 +8119,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -8273,11 +8192,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - if (a[aFromIndex++] != b[bFromIndex++]) return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch long @@ -8328,11 +8246,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - if (a[i] != b[i]) return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -8404,11 +8319,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - if (a[aFromIndex++] != b[bFromIndex++]) return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch float @@ -8459,14 +8373,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - float va = a[i], vb = b[i]; - if (Float.floatToRawIntBits(va) != Float.floatToRawIntBits(vb)) - if (!Float.isNaN(va) || !Float.isNaN(vb)) - return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -8538,14 +8446,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - float va = a[aFromIndex++], vb = b[bFromIndex++]; - if (Float.floatToRawIntBits(va) != Float.floatToRawIntBits(vb)) - if (!Float.isNaN(va) || !Float.isNaN(vb)) - return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch double @@ -8596,14 +8500,8 @@ public class Arrays { if (a == b) return -1; - for (int i = 0; i < length; i++) { - double va = a[i], vb = b[i]; - if (Double.doubleToRawLongBits(va) != Double.doubleToRawLongBits(vb)) - if (!Double.isNaN(va) || !Double.isNaN(vb)) - return i; - } - - return a.length != b.length ? length : -1; + int i = ArraysSupport.mismatch(a, b, length); + return (i < 0 && a.length != b.length) ? length : i; } /** @@ -8675,14 +8573,10 @@ public class Arrays { int aLength = aToIndex - aFromIndex; int bLength = bToIndex - bFromIndex; int length = Math.min(aLength, bLength); - for (int i = 0; i < length; i++) { - double va = a[aFromIndex++], vb = b[bFromIndex++]; - if (Double.doubleToRawLongBits(va) != Double.doubleToRawLongBits(vb)) - if (!Double.isNaN(va) || !Double.isNaN(vb)) - return i; - } - - return aLength != bLength ? length : -1; + int i = ArraysSupport.mismatch(a, aFromIndex, + b, bFromIndex, + length); + return (i < 0 && aLength != bLength) ? length : i; } // Mismatch objects diff --git a/jdk/src/java.base/share/classes/java/util/ArraysSupport.java b/jdk/src/java.base/share/classes/java/util/ArraysSupport.java new file mode 100644 index 00000000000..31612a7d4f8 --- /dev/null +++ b/jdk/src/java.base/share/classes/java/util/ArraysSupport.java @@ -0,0 +1,545 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.util; + +import jdk.internal.HotSpotIntrinsicCandidate; +import jdk.internal.misc.Unsafe; + +/** + * Utility methods to find a mismatch between two primitive arrays. + * + *

Array equality and lexicographical comparison can be built on top of + * array mismatch functionality. + * + *

The mismatch method implementation, {@link #vectorizedMismatch}, leverages + * vector-based techniques to access and compare the contents of two arrays. + * The Java implementation uses {@code Unsafe.getLongUnaligned} to access the + * content of an array, thus access is supported on platforms that do not + * support unaligned access. For a byte[] array, 8 bytes (64 bits) can be + * accessed and compared as a unit rather than individually, which increases + * the performance when the method is compiled by the HotSpot VM. On supported + * platforms the mismatch implementation is intrinsified to leverage SIMD + * instructions. So for a byte[] array, 16 bytes (128 bits), 32 bytes + * (256 bits), and perhaps in the future even 64 bytes (512 bits), platform + * permitting, can be accessed and compared as a unit, which further increases + * the performance over the Java implementation. + * + *

None of the mismatch methods perform array bounds checks. It is the + * responsibility of the caller (direct or otherwise) to perform such checks + * before calling this method. + */ +class ArraysSupport { + static final Unsafe U = Unsafe.getUnsafe(); + + private static final boolean BIG_ENDIAN = U.isBigEndian(); + + private static final int LOG2_ARRAY_BOOLEAN_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE); + private static final int LOG2_ARRAY_BYTE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BYTE_INDEX_SCALE); + private static final int LOG2_ARRAY_CHAR_INDEX_SCALE = exactLog2(Unsafe.ARRAY_CHAR_INDEX_SCALE); + private static final int LOG2_ARRAY_SHORT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_SHORT_INDEX_SCALE); + private static final int LOG2_ARRAY_INT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_INT_INDEX_SCALE); + private static final int LOG2_ARRAY_LONG_INDEX_SCALE = exactLog2(Unsafe.ARRAY_LONG_INDEX_SCALE); + private static final int LOG2_ARRAY_FLOAT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_FLOAT_INDEX_SCALE); + private static final int LOG2_ARRAY_DOUBLE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_DOUBLE_INDEX_SCALE); + + private static final int LOG2_BYTE_BIT_SIZE = exactLog2(Byte.SIZE); + + private static int exactLog2(int scale) { + if ((scale & (scale - 1)) != 0) + throw new Error("data type scale not a power of two"); + return Integer.numberOfTrailingZeros(scale); + } + + private ArraysSupport() {} + + /** + * Find the relative index of the first mismatching pair of elements in two + * primitive arrays of the same component type. Pairs of elements will be + * tested in order relative to given offsets into both arrays. + * + *

This method does not perform type checks or bounds checks. It is the + * responsibility of the caller to perform such checks before calling this + * method. + * + *

The given offsets, in bytes, need not be aligned according to the + * given log2 size the array elements. More specifically, an + * offset modulus the size need not be zero. + * + * @param a the first array to be tested for mismatch, or {@code null} for + * direct memory access + * @param aOffset the relative offset, in bytes, from the base address of + * the first array to test from, otherwise if the first array is + * {@code null}, an absolute address pointing to the first element to test. + * @param b the second array to be tested for mismatch, or {@code null} for + * direct memory access + * @param bOffset the relative offset, in bytes, from the base address of + * the second array to test from, otherwise if the second array is + * {@code null}, an absolute address pointing to the first element to test. + * @param length the number of array elements to test + * @param log2ArrayIndexScale log2 of the array index scale, that + * corresponds to the size, in bytes, of an array element. + * @return if a mismatch is found a relative index, between 0 (inclusive) + * and {@code length} (exclusive), of the first mismatching pair of elements + * in the two arrays. Otherwise, if a mismatch is not found the bitwise + * compliment of the number of remaining pairs of elements to be checked in + * the tail of the two arrays. + */ + @HotSpotIntrinsicCandidate + static int vectorizedMismatch(Object a, long aOffset, + Object b, long bOffset, + int length, + int log2ArrayIndexScale) { + // assert a.getClass().isArray(); + // assert b.getClass().isArray(); + // assert 0 <= length <= sizeOf(a) + // assert 0 <= length <= sizeOf(b) + // assert 0 <= log2ArrayIndexScale <= 3 + + int log2ValuesPerWidth = LOG2_ARRAY_LONG_INDEX_SCALE - log2ArrayIndexScale; + int wi = 0; + for (; wi < length >> log2ValuesPerWidth; wi++) { + long bi = ((long) wi) << LOG2_ARRAY_LONG_INDEX_SCALE; + long av = U.getLongUnaligned(a, aOffset + bi); + long bv = U.getLongUnaligned(b, bOffset + bi); + if (av != bv) { + long x = av ^ bv; + int o = BIG_ENDIAN + ? Long.numberOfLeadingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale) + : Long.numberOfTrailingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale); + return (wi << log2ValuesPerWidth) + o; + } + } + + // Calculate the tail of remaining elements to check + int tail = length - (wi << log2ValuesPerWidth); + + if (log2ArrayIndexScale < LOG2_ARRAY_INT_INDEX_SCALE) { + int wordTail = 1 << (LOG2_ARRAY_INT_INDEX_SCALE - log2ArrayIndexScale); + // Handle 4 bytes or 2 chars in the tail using int width + if (tail >= wordTail) { + long bi = ((long) wi) << LOG2_ARRAY_LONG_INDEX_SCALE; + int av = U.getIntUnaligned(a, aOffset + bi); + int bv = U.getIntUnaligned(b, bOffset + bi); + if (av != bv) { + int x = av ^ bv; + int o = BIG_ENDIAN + ? Integer.numberOfLeadingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale) + : Integer.numberOfTrailingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale); + return (wi << log2ValuesPerWidth) + o; + } + tail -= wordTail; + } + return ~tail; + } + else { + return ~tail; + } + } + + // Booleans + // Each boolean element takes up one byte + + static int mismatch(boolean[] a, + boolean[] b, + int length) { + int i = 0; + if (length > 7) { + i = vectorizedMismatch( + a, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, + b, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, + length, LOG2_ARRAY_BOOLEAN_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[i] != b[i]) + return i; + } + return -1; + } + + static int mismatch(boolean[] a, int aFromIndex, + boolean[] b, int bFromIndex, + int length) { + int i = 0; + if (length > 7) { + int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex; + int bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex; + i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_BOOLEAN_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[aFromIndex + i] != b[bFromIndex + i]) + return i; + } + return -1; + } + + + // Bytes + + /** + * Find the index of a mismatch between two arrays. + * + *

This method does not perform bounds checks. It is the responsibility + * of the caller to perform such bounds checks before calling this method. + * + * @param a the first array to be tested for a mismatch + * @param b the second array to be tested for a mismatch + * @param length the number of bytes from each array to check + * @return the index of a mismatch between the two arrays, otherwise -1 if + * no mismatch. The index will be within the range of (inclusive) 0 to + * (exclusive) the smaller of the two array lengths. + */ + static int mismatch(byte[] a, + byte[] b, + int length) { + // ISSUE: defer to index receiving methods if performance is good + // assert length <= a.length + // assert length <= b.length + + int i = 0; + if (length > 7) { + i = vectorizedMismatch( + a, Unsafe.ARRAY_BYTE_BASE_OFFSET, + b, Unsafe.ARRAY_BYTE_BASE_OFFSET, + length, LOG2_ARRAY_BYTE_INDEX_SCALE); + if (i >= 0) + return i; + // Align to tail + i = length - ~i; +// assert i >= 0 && i <= 7; + } + // Tail < 8 bytes + for (; i < length; i++) { + if (a[i] != b[i]) + return i; + } + return -1; + } + + /** + * Find the relative index of a mismatch between two arrays starting from + * given indexes. + * + *

This method does not perform bounds checks. It is the responsibility + * of the caller to perform such bounds checks before calling this method. + * + * @param a the first array to be tested for a mismatch + * @param aFromIndex the index of the first element (inclusive) in the first + * array to be compared + * @param b the second array to be tested for a mismatch + * @param bFromIndex the index of the first element (inclusive) in the + * second array to be compared + * @param length the number of bytes from each array to check + * @return the relative index of a mismatch between the two arrays, + * otherwise -1 if no mismatch. The index will be within the range of + * (inclusive) 0 to (exclusive) the smaller of the two array bounds. + */ + static int mismatch(byte[] a, int aFromIndex, + byte[] b, int bFromIndex, + int length) { + // assert 0 <= aFromIndex < a.length + // assert 0 <= aFromIndex + length <= a.length + // assert 0 <= bFromIndex < b.length + // assert 0 <= bFromIndex + length <= b.length + // assert length >= 0 + + int i = 0; + if (length > 7) { + int aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex; + int bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex; + i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_BYTE_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[aFromIndex + i] != b[bFromIndex + i]) + return i; + } + return -1; + } + + + // Chars + + static int mismatch(char[] a, + char[] b, + int length) { + int i = 0; + if (length > 3) { + i = vectorizedMismatch( + a, Unsafe.ARRAY_CHAR_BASE_OFFSET, + b, Unsafe.ARRAY_CHAR_BASE_OFFSET, + length, LOG2_ARRAY_CHAR_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[i] != b[i]) + return i; + } + return -1; + } + + static int mismatch(char[] a, int aFromIndex, + char[] b, int bFromIndex, + int length) { + int i = 0; + if (length > 3) { + int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); + int bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); + i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_CHAR_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[aFromIndex + i] != b[bFromIndex + i]) + return i; + } + return -1; + } + + + // Shorts + + static int mismatch(short[] a, + short[] b, + int length) { + int i = 0; + if (length > 3) { + i = vectorizedMismatch( + a, Unsafe.ARRAY_SHORT_BASE_OFFSET, + b, Unsafe.ARRAY_SHORT_BASE_OFFSET, + length, LOG2_ARRAY_SHORT_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[i] != b[i]) + return i; + } + return -1; + } + + static int mismatch(short[] a, int aFromIndex, + short[] b, int bFromIndex, + int length) { + int i = 0; + if (length > 3) { + int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); + int bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); + i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_SHORT_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[aFromIndex + i] != b[bFromIndex + i]) + return i; + } + return -1; + } + + + // Ints + + static int mismatch(int[] a, + int[] b, + int length) { + int i = 0; + if (length > 1) { + i = vectorizedMismatch( + a, Unsafe.ARRAY_INT_BASE_OFFSET, + b, Unsafe.ARRAY_INT_BASE_OFFSET, + length, LOG2_ARRAY_INT_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[i] != b[i]) + return i; + } + return -1; + } + + static int mismatch(int[] a, int aFromIndex, + int[] b, int bFromIndex, + int length) { + int i = 0; + if (length > 1) { + int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); + int bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); + i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_INT_INDEX_SCALE); + if (i >= 0) + return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a[aFromIndex + i] != b[bFromIndex + i]) + return i; + } + return -1; + } + + + // Floats + + static int mismatch(float[] a, + float[] b, + int length) { + return mismatch(a, 0, b, 0, length); + } + + static int mismatch(float[] a, int aFromIndex, + float[] b, int bFromIndex, + int length) { + int i = 0; + if (length > 1) { + int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); + int bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); + i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_FLOAT_INDEX_SCALE); + // Mismatched + if (i >= 0) { + // Check if mismatch is not associated with two NaN values + if (!Float.isNaN(a[aFromIndex + i]) || !Float.isNaN(b[bFromIndex + i])) + return i; + + // Mismatch on two different NaN values that are normalized to match + // Fall back to slow mechanism + // ISSUE: Consider looping over vectorizedMismatch adjusting ranges + // However, requires that returned value be relative to input ranges + i++; + } + // Matched + else { + i = length - ~i; + } + } + for (; i < length; i++) { + if (Float.floatToIntBits(a[aFromIndex + i]) != Float.floatToIntBits(b[bFromIndex + i])) + return i; + } + return -1; + } + + // 64 bit sizes + + // Long + + static int mismatch(long[] a, + long[] b, + int length) { + if (length == 0) { + return -1; + } + int i = vectorizedMismatch( + a, Unsafe.ARRAY_LONG_BASE_OFFSET, + b, Unsafe.ARRAY_LONG_BASE_OFFSET, + length, LOG2_ARRAY_LONG_INDEX_SCALE); + return i >= 0 ? i : -1; + } + + static int mismatch(long[] a, int aFromIndex, + long[] b, int bFromIndex, + int length) { + if (length == 0) { + return -1; + } + int aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); + int bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); + int i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_LONG_INDEX_SCALE); + return i >= 0 ? i : -1; + } + + + // Double + + static int mismatch(double[] a, + double[] b, + int length) { + return mismatch(a, 0, b, 0, length); + } + + static int mismatch(double[] a, int aFromIndex, + double[] b, int bFromIndex, + int length) { + if (length == 0) { + return -1; + } + int aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); + int bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); + int i = vectorizedMismatch( + a, aOffset, + b, bOffset, + length, LOG2_ARRAY_DOUBLE_INDEX_SCALE); + if (i >= 0) { + // Check if mismatch is not associated with two NaN values + if (!Double.isNaN(a[aFromIndex + i]) || !Double.isNaN(b[bFromIndex + i])) + return i; + + // Mismatch on two different NaN values that are normalized to match + // Fall back to slow mechanism + // ISSUE: Consider looping over vectorizedMismatch adjusting ranges + // However, requires that returned value be relative to input ranges + i++; + for (; i < length; i++) { + if (Double.doubleToLongBits(a[aFromIndex + i]) != Double.doubleToLongBits(b[bFromIndex + i])) + return i; + } + } + + return -1; + } +} From b8c892909bf0fd44478be911430e332e52c557ad Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Fri, 18 Dec 2015 08:30:26 +0100 Subject: [PATCH 032/109] 6425769: Allow specifying an address to bind JMX remote connector Reviewed-by: jbachorik, dfuchs --- .../jmxremote/ConnectorBootstrap.java | 212 ++++++++++++- .../share/conf/management.properties | 13 + .../bootstrap/JMXAgentInterfaceBinding.java | 297 ++++++++++++++++++ .../bootstrap/JMXInterfaceBindingTest.java | 193 ++++++++++++ 4 files changed, 706 insertions(+), 9 deletions(-) create mode 100644 jdk/test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java create mode 100644 jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java diff --git a/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java b/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java index 06b26a0fe91..5ef0f7f1708 100644 --- a/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java +++ b/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java @@ -30,9 +30,12 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.Serializable; import java.lang.management.ManagementFactory; import java.net.InetAddress; import java.net.MalformedURLException; +import java.net.Socket; +import java.net.ServerSocket; import java.net.UnknownHostException; import java.rmi.NoSuchObjectException; import java.rmi.Remote; @@ -40,6 +43,7 @@ import java.rmi.RemoteException; import java.rmi.registry.Registry; import java.rmi.server.RMIClientSocketFactory; import java.rmi.server.RMIServerSocketFactory; +import java.rmi.server.RMISocketFactory; import java.rmi.server.RemoteObject; import java.rmi.server.UnicastRemoteObject; import java.security.KeyStore; @@ -60,6 +64,8 @@ import javax.management.remote.JMXServiceURL; import javax.management.remote.rmi.RMIConnectorServer; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManagerFactory; import javax.rmi.ssl.SslRMIClientSocketFactory; import javax.rmi.ssl.SslRMIServerSocketFactory; @@ -107,6 +113,8 @@ public final class ConnectorBootstrap { public static final String PORT = "com.sun.management.jmxremote.port"; + public static final String HOST = + "com.sun.management.jmxremote.host"; public static final String RMI_PORT = "com.sun.management.jmxremote.rmi.port"; public static final String CONFIG_FILE_NAME = @@ -424,10 +432,14 @@ public final class ConnectorBootstrap { checkAccessFile(accessFileName); } + final String bindAddress = + props.getProperty(PropertyNames.HOST); + if (log.debugOn()) { log.debug("startRemoteConnectorServer", Agent.getText("jmxremote.ConnectorBootstrap.starting") + "\n\t" + PropertyNames.PORT + "=" + port + + (bindAddress == null ? "" : "\n\t" + PropertyNames.HOST + "=" + bindAddress) + "\n\t" + PropertyNames.RMI_PORT + "=" + rmiPort + "\n\t" + PropertyNames.USE_SSL + "=" + useSsl + "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl + @@ -458,7 +470,7 @@ public final class ConnectorBootstrap { sslConfigFileName, enabledCipherSuitesList, enabledProtocolsList, sslNeedClientAuth, useAuthentication, loginConfigName, - passwordFileName, accessFileName); + passwordFileName, accessFileName, bindAddress); cs = data.jmxConnectorServer; url = data.jmxRemoteURL; log.config("startRemoteConnectorServer", @@ -628,12 +640,13 @@ public final class ConnectorBootstrap { String sslConfigFileName, String[] enabledCipherSuites, String[] enabledProtocols, - boolean sslNeedClientAuth) { + boolean sslNeedClientAuth, + String bindAddress) { if (sslConfigFileName == null) { - return new SslRMIServerSocketFactory( + return new HostAwareSslSocketFactory( enabledCipherSuites, enabledProtocols, - sslNeedClientAuth); + sslNeedClientAuth, bindAddress); } else { checkRestrictedFile(sslConfigFileName); try { @@ -687,11 +700,11 @@ public final class ConnectorBootstrap { SSLContext ctx = SSLContext.getInstance("SSL"); ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - return new SslRMIServerSocketFactory( + return new HostAwareSslSocketFactory( ctx, enabledCipherSuites, enabledProtocols, - sslNeedClientAuth); + sslNeedClientAuth, bindAddress); } catch (Exception e) { throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString()); } @@ -711,7 +724,8 @@ public final class ConnectorBootstrap { boolean useAuthentication, String loginConfigName, String passwordFileName, - String accessFileName) + String accessFileName, + String bindAddress) throws IOException, MalformedURLException { /* Make sure we use non-guessable RMI object IDs. Otherwise @@ -719,7 +733,7 @@ public final class ConnectorBootstrap { * IDs. */ System.setProperty("java.rmi.server.randomIDs", "true"); - JMXServiceURL url = new JMXServiceURL("rmi", null, rmiPort); + JMXServiceURL url = new JMXServiceURL("rmi", bindAddress, rmiPort); Map env = new HashMap<>(); @@ -727,6 +741,8 @@ public final class ConnectorBootstrap { env.put(RMIExporter.EXPORTER_ATTRIBUTE, exporter); + boolean useSocketFactory = bindAddress != null && !useSsl; + if (useAuthentication) { if (loginConfigName != null) { env.put("jmx.remote.x.login.config", loginConfigName); @@ -751,7 +767,7 @@ public final class ConnectorBootstrap { csf = new SslRMIClientSocketFactory(); ssf = createSslRMIServerSocketFactory( sslConfigFileName, enabledCipherSuites, - enabledProtocols, sslNeedClientAuth); + enabledProtocols, sslNeedClientAuth, bindAddress); } if (useSsl) { @@ -761,6 +777,12 @@ public final class ConnectorBootstrap { ssf); } + if (useSocketFactory) { + ssf = new HostAwareSocketFactory(bindAddress); + env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, + ssf); + } + JMXConnectorServer connServer = null; try { connServer = @@ -780,6 +802,10 @@ public final class ConnectorBootstrap { registry = new SingleEntryRegistry(port, csf, ssf, "jmxrmi", exporter.firstExported); + } else if (useSocketFactory) { + registry = + new SingleEntryRegistry(port, csf, ssf, + "jmxrmi", exporter.firstExported); } else { registry = new SingleEntryRegistry(port, @@ -813,4 +839,172 @@ public final class ConnectorBootstrap { private static final ClassLogger log = new ClassLogger(ConnectorBootstrap.class.getPackage().getName(), "ConnectorBootstrap"); + + private static class HostAwareSocketFactory implements RMIServerSocketFactory { + + private final String bindAddress; + + private HostAwareSocketFactory(String bindAddress) { + this.bindAddress = bindAddress; + } + + @Override + public ServerSocket createServerSocket(int port) throws IOException { + if (bindAddress == null) { + return new ServerSocket(port); + } else { + try { + InetAddress addr = InetAddress.getByName(bindAddress); + return new ServerSocket(port, 0, addr); + } catch (UnknownHostException e) { + return new ServerSocket(port); + } + } + } + } + + private static class HostAwareSslSocketFactory extends SslRMIServerSocketFactory { + + private final String bindAddress; + private final String[] enabledCipherSuites; + private final String[] enabledProtocols; + private final boolean needClientAuth; + private final SSLContext context; + + private HostAwareSslSocketFactory(String[] enabledCipherSuites, + String[] enabledProtocols, + boolean sslNeedClientAuth, + String bindAddress) throws IllegalArgumentException { + this(null, enabledCipherSuites, enabledProtocols, sslNeedClientAuth, bindAddress); + } + + private HostAwareSslSocketFactory(SSLContext ctx, + String[] enabledCipherSuites, + String[] enabledProtocols, + boolean sslNeedClientAuth, + String bindAddress) throws IllegalArgumentException { + this.context = ctx; + this.bindAddress = bindAddress; + this.enabledProtocols = enabledProtocols; + this.enabledCipherSuites = enabledCipherSuites; + this.needClientAuth = sslNeedClientAuth; + checkValues(ctx, enabledCipherSuites, enabledProtocols); + } + + @Override + public ServerSocket createServerSocket(int port) throws IOException { + if (bindAddress != null) { + try { + InetAddress addr = InetAddress.getByName(bindAddress); + return new SslServerSocket(port, 0, addr, context, + enabledCipherSuites, enabledProtocols, needClientAuth); + } catch (UnknownHostException e) { + return new SslServerSocket(port, context, + enabledCipherSuites, enabledProtocols, needClientAuth); + } + } else { + return new SslServerSocket(port, context, + enabledCipherSuites, enabledProtocols, needClientAuth); + } + } + + private static void checkValues(SSLContext context, + String[] enabledCipherSuites, + String[] enabledProtocols) throws IllegalArgumentException { + // Force the initialization of the default at construction time, + // rather than delaying it to the first time createServerSocket() + // is called. + // + final SSLSocketFactory sslSocketFactory = + context == null ? + (SSLSocketFactory)SSLSocketFactory.getDefault() : context.getSocketFactory(); + SSLSocket sslSocket = null; + if (enabledCipherSuites != null || enabledProtocols != null) { + try { + sslSocket = (SSLSocket) sslSocketFactory.createSocket(); + } catch (Exception e) { + final String msg = "Unable to check if the cipher suites " + + "and protocols to enable are supported"; + throw (IllegalArgumentException) + new IllegalArgumentException(msg).initCause(e); + } + } + + // Check if all the cipher suites and protocol versions to enable + // are supported by the underlying SSL/TLS implementation and if + // true create lists from arrays. + // + if (enabledCipherSuites != null) { + sslSocket.setEnabledCipherSuites(enabledCipherSuites); + } + if (enabledProtocols != null) { + sslSocket.setEnabledProtocols(enabledProtocols); + } + } + } + + private static class SslServerSocket extends ServerSocket { + + private static SSLSocketFactory defaultSSLSocketFactory; + private final String[] enabledCipherSuites; + private final String[] enabledProtocols; + private final boolean needClientAuth; + private final SSLContext context; + + private SslServerSocket(int port, + SSLContext ctx, + String[] enabledCipherSuites, + String[] enabledProtocols, + boolean needClientAuth) throws IOException { + super(port); + this.enabledProtocols = enabledProtocols; + this.enabledCipherSuites = enabledCipherSuites; + this.needClientAuth = needClientAuth; + this.context = ctx; + } + + private SslServerSocket(int port, + int backlog, + InetAddress bindAddr, + SSLContext ctx, + String[] enabledCipherSuites, + String[] enabledProtocols, + boolean needClientAuth) throws IOException { + super(port, backlog, bindAddr); + this.enabledProtocols = enabledProtocols; + this.enabledCipherSuites = enabledCipherSuites; + this.needClientAuth = needClientAuth; + this.context = ctx; + } + + @Override + public Socket accept() throws IOException { + final SSLSocketFactory sslSocketFactory = + context == null ? + getDefaultSSLSocketFactory() : context.getSocketFactory(); + Socket socket = super.accept(); + SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket( + socket, socket.getInetAddress().getHostName(), + socket.getPort(), true); + sslSocket.setUseClientMode(false); + if (enabledCipherSuites != null) { + sslSocket.setEnabledCipherSuites(enabledCipherSuites); + } + if (enabledProtocols != null) { + sslSocket.setEnabledProtocols(enabledProtocols); + } + sslSocket.setNeedClientAuth(needClientAuth); + return sslSocket; + } + + private static synchronized SSLSocketFactory getDefaultSSLSocketFactory() { + if (defaultSSLSocketFactory == null) { + defaultSSLSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault(); + return defaultSSLSocketFactory; + } else { + return defaultSSLSocketFactory; + } + } + + } } diff --git a/jdk/src/java.management/share/conf/management.properties b/jdk/src/java.management/share/conf/management.properties index 529fd3b099c..02401d78bec 100644 --- a/jdk/src/java.management/share/conf/management.properties +++ b/jdk/src/java.management/share/conf/management.properties @@ -316,3 +316,16 @@ # For a non-default password file location use the following line # com.sun.management.jmxremote.access.file=filepath +# + +# ################ Management agent listen interface ######################### +# +# com.sun.management.jmxremote.host= +# Specifies the local interface on which the JMX RMI agent will bind. +# This is useful when running on machines which have several +# interfaces defined. It makes it possible to listen to a specific +# subnet accessible through that interface. +# +# The format of the value for that property is any string accepted +# by java.net.InetAddress.getByName(String). +# diff --git a/jdk/test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java b/jdk/test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java new file mode 100644 index 00000000000..8b46a4c3169 --- /dev/null +++ b/jdk/test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2015, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.MalformedURLException; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; +import javax.management.remote.rmi.RMIConnectorServer; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.rmi.ssl.SslRMIClientSocketFactory; + +/** + * Tests client connections to the JDK's built-in JMX agent server on the given + * ports/interface combinations. + * + * @see JMXInterfaceBindingTest + * + * @author Severin Gehwolf + * + * Usage: + * + * SSL: + * java -Dcom.sun.management.jmxremote.ssl.need.client.auth=true \ + * -Dcom.sun.management.jmxremote.host=127.0.0.1 \ + * -Dcom.sun.management.jmxremote.port=9111 \ + * -Dcom.sun.management.jmxremote.rmi.port=9112 \ + * -Dcom.sun.management.jmxremote.authenticate=false \ + * -Dcom.sun.management.jmxremote.ssl=true \ + * -Dcom.sun.management.jmxremote.registry.ssl=true + * -Djavax.net.ssl.keyStore=... \ + * -Djavax.net.ssl.keyStorePassword=... \ + * JMXAgentInterfaceBinding 127.0.0.1 9111 9112 true + * + * Non-SSL: + * java -Dcom.sun.management.jmxremote.host=127.0.0.1 \ + * -Dcom.sun.management.jmxremote.port=9111 \ + * -Dcom.sun.management.jmxremote.rmi.port=9112 \ + * -Dcom.sun.management.jmxremote.authenticate=false \ + * -Dcom.sun.management.jmxremote.ssl=false \ + * JMXAgentInterfaceBinding 127.0.0.1 9111 9112 false + * + */ +public class JMXAgentInterfaceBinding { + + private final MainThread mainThread; + + public JMXAgentInterfaceBinding(InetAddress bindAddress, + int jmxPort, + int rmiPort, + boolean useSSL) { + this.mainThread = new MainThread(bindAddress, jmxPort, rmiPort, useSSL); + } + + public void startEndpoint() { + mainThread.start(); + try { + mainThread.join(); + } catch (InterruptedException e) { + throw new RuntimeException("Test failed", e); + } + if (mainThread.isFailed()) { + mainThread.rethrowException(); + } + } + + public static void main(String[] args) { + if (args.length != 4) { + throw new RuntimeException( + "Test failed. usage: java JMXInterfaceBindingTest {true|false}"); + } + int jmxPort = parsePortFromString(args[1]); + int rmiPort = parsePortFromString(args[2]); + boolean useSSL = Boolean.parseBoolean(args[3]); + String strBindAddr = args[0]; + System.out.println( + "DEBUG: Running test for triplet (hostname,jmxPort,rmiPort) = (" + + strBindAddr + "," + jmxPort + "," + rmiPort + "), useSSL = " + useSSL); + InetAddress bindAddress; + try { + bindAddress = InetAddress.getByName(args[0]); + } catch (UnknownHostException e) { + throw new RuntimeException("Test failed. Unknown ip: " + args[0]); + } + JMXAgentInterfaceBinding test = new JMXAgentInterfaceBinding(bindAddress, + jmxPort, rmiPort, useSSL); + test.startEndpoint(); // Expect for main test to terminate process + } + + private static int parsePortFromString(String port) { + try { + return Integer.parseInt(port); + } catch (NumberFormatException e) { + throw new RuntimeException( + "Invalid port specified. Not an integer! Value was: " + + port); + } + } + + private static class JMXConnectorThread extends Thread { + + private final InetAddress addr; + private final int jmxPort; + private final int rmiPort; + private final boolean useSSL; + private final CountDownLatch latch; + private boolean failed; + private boolean jmxConnectWorked; + private boolean rmiConnectWorked; + + private JMXConnectorThread(InetAddress addr, + int jmxPort, + int rmiPort, + boolean useSSL, + CountDownLatch latch) { + this.addr = addr; + this.jmxPort = jmxPort; + this.rmiPort = rmiPort; + this.latch = latch; + this.useSSL = useSSL; + } + + @Override + public void run() { + try { + connect(); + } catch (IOException e) { + failed = true; + } + } + + private void connect() throws IOException { + System.out.println( + "JMXConnectorThread: Attempting JMX connection on: " + + addr.getHostAddress() + " on port " + jmxPort); + JMXServiceURL url; + try { + url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + + addr.getHostAddress() + ":" + jmxPort + "/jmxrmi"); + } catch (MalformedURLException e) { + throw new RuntimeException("Test failed.", e); + } + Map env = new HashMap<>(); + if (useSSL) { + SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory(); + env.put("com.sun.jndi.rmi.factory.socket", csf); + env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf); + } + // connect and immediately close + JMXConnector c = JMXConnectorFactory.connect(url, env); + c.close(); + System.out.println("JMXConnectorThread: connection to JMX worked"); + jmxConnectWorked = true; + checkRmiSocket(); + latch.countDown(); // signal we are done. + } + + private void checkRmiSocket() throws IOException { + Socket rmiConnection; + if (useSSL) { + rmiConnection = SSLSocketFactory.getDefault().createSocket(); + } else { + rmiConnection = new Socket(); + } + SocketAddress target = new InetSocketAddress(addr, rmiPort); + rmiConnection.connect(target); + if (useSSL) { + ((SSLSocket)rmiConnection).startHandshake(); + } + System.out.println( + "JMXConnectorThread: connection to rmi socket worked host/port = " + + addr.getHostAddress() + "/" + rmiPort); + rmiConnectWorked = true; + // Closing the channel without sending any data will cause an + // java.io.EOFException on the server endpoint. We don't care about this + // though, since we only want to test if we can connect. + rmiConnection.close(); + } + + public boolean isFailed() { + return failed; + } + + public boolean jmxConnectionWorked() { + return jmxConnectWorked; + } + + public boolean rmiConnectionWorked() { + return rmiConnectWorked; + } + } + + private static class MainThread extends Thread { + + private static final int WAIT_FOR_JMX_AGENT_TIMEOUT_MS = 500; + private final InetAddress bindAddress; + private final int jmxPort; + private final int rmiPort; + private final boolean useSSL; + private boolean terminated = false; + private boolean jmxAgentStarted = false; + private Exception excptn; + + private MainThread(InetAddress bindAddress, int jmxPort, int rmiPort, boolean useSSL) { + this.bindAddress = bindAddress; + this.jmxPort = jmxPort; + this.rmiPort = rmiPort; + this.useSSL = useSSL; + } + + @Override + public void run() { + try { + waitUntilReadyForConnections(); + // Do nothing, but wait for termination. + try { + while (!terminated) { + Thread.sleep(100); + } + } catch (InterruptedException e) { // ignore + } + System.out.println("MainThread: Thread stopped."); + } catch (Exception e) { + this.excptn = e; + } + } + + private void waitUntilReadyForConnections() { + CountDownLatch latch = new CountDownLatch(1); + JMXConnectorThread connectionTester = new JMXConnectorThread( + bindAddress, jmxPort, rmiPort, useSSL, latch); + connectionTester.start(); + boolean expired = false; + try { + expired = !latch.await(WAIT_FOR_JMX_AGENT_TIMEOUT_MS, TimeUnit.MILLISECONDS); + System.out.println( + "MainThread: Finished waiting for JMX agent to become available: expired == " + + expired); + jmxAgentStarted = !expired; + } catch (InterruptedException e) { + throw new RuntimeException("Test failed", e); + } + if (!jmxAgentStarted) { + throw new RuntimeException( + "Test failed. JMX server agents not becoming available."); + } + if (connectionTester.isFailed() + || !connectionTester.jmxConnectionWorked() + || !connectionTester.rmiConnectionWorked()) { + throw new RuntimeException( + "Test failed. JMX agent does not seem ready. See log output for details."); + } + // The main test expects this exact message being printed + System.out.println("MainThread: Ready for connections"); + } + + private boolean isFailed() { + return excptn != null; + } + + private void rethrowException() throws RuntimeException { + throw new RuntimeException(excptn); + } + } + +} diff --git a/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java b/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java new file mode 100644 index 00000000000..94ebb1e54d1 --- /dev/null +++ b/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2015, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; + +import jdk.testlibrary.ProcessThread; +import jdk.testlibrary.ProcessTools; + +/** + * NOTE: + * This test requires at least a setup similar to the following in + * /etc/hosts file (or the windows equivalent). I.e. it expects it to + * be multi-homed and not both being the loop-back interface. + * For example: + * ----->8-------- /etc/hosts ----------->8--- + * 127.0.0.1 localhost + * 192.168.0.1 localhost + * ----->8-------- /etc/hosts ----------->8--- + * + * @test + * @bug 6425769 + * @summary Test JMX agent host address binding. Same ports but different + * interfaces to bind to (using plain sockets and SSL sockets). + * + * @modules java.management/sun.management + * java.management/sun.management.jmxremote + * @library /lib/testlibrary + * @build jdk.testlibrary.* JMXAgentInterfaceBinding + * @run main/timeout=5 JMXInterfaceBindingTest + */ +public class JMXInterfaceBindingTest { + + public static final int COMMUNICATION_ERROR_EXIT_VAL = 1; + public static final int STOP_PROCESS_EXIT_VAL = 143; + public static final int JMX_PORT = 9111; + public static final int RMI_PORT = 9112; + public static final String READY_MSG = "MainThread: Ready for connections"; + public static final String TEST_CLASS = JMXAgentInterfaceBinding.class.getSimpleName(); + public static final String KEYSTORE_LOC = System.getProperty("test.src", ".") + + File.separator + + "ssl" + + File.separator + + "keystore"; + public static final String TRUSTSTORE_LOC = System.getProperty("test.src", ".") + + File.separator + + "ssl" + + File.separator + + "truststore"; + public static final String TEST_CLASSPATH = System.getProperty("test.classes", "."); + + public void run(InetAddress[] addrs) { + System.out.println("DEBUG: Running tests with plain sockets."); + runTests(addrs, false); + System.out.println("DEBUG: Running tests with SSL sockets."); + runTests(addrs, true); + } + + private void runTests(InetAddress[] addrs, boolean useSSL) { + ProcessThread[] jvms = new ProcessThread[addrs.length]; + for (int i = 0; i < addrs.length; i++) { + System.out.println(); + String msg = String.format("DEBUG: Launching java tester for triplet (HOSTNAME,JMX_PORT,RMI_PORT) == (%s,%d,%d)", + addrs[i].getHostAddress(), + JMX_PORT, + RMI_PORT); + System.out.println(msg); + jvms[i] = runJMXBindingTest(addrs[i], useSSL); + jvms[i].start(); + System.out.println("DEBUG: Started " + (i + 1) + " Process(es)."); + } + int failedProcesses = 0; + for (ProcessThread pt: jvms) { + try { + pt.stopProcess(); + pt.join(); + } catch (InterruptedException e) { + System.err.println("Failed to stop process: " + pt.getName()); + throw new RuntimeException("Test failed", e); + } + int exitValue = pt.getOutput().getExitValue(); + // If there is a communication error (the case we care about) + // we get a exit code of 1 + if (exitValue == COMMUNICATION_ERROR_EXIT_VAL) { + // Failure case since the java processes should still be + // running. + System.err.println("Test FAILURE on " + pt.getName()); + failedProcesses++; + } else if (exitValue == STOP_PROCESS_EXIT_VAL) { + System.out.println("DEBUG: OK. Spawned java process terminated with expected exit code of " + STOP_PROCESS_EXIT_VAL); + } else { + System.err.println("Test FAILURE on " + pt.getName() + " reason: Unexpected exit code => " + exitValue); + failedProcesses++; + } + } + if (failedProcesses > 0) { + throw new RuntimeException("Test FAILED. " + failedProcesses + " out of " + addrs.length + " process(es) failed to start the JMX agent."); + } + } + + private ProcessThread runJMXBindingTest(InetAddress a, boolean useSSL) { + List args = new ArrayList<>(); + args.add("-classpath"); + args.add(TEST_CLASSPATH); + args.add("-Dcom.sun.management.jmxremote.host=" + a.getHostAddress()); + args.add("-Dcom.sun.management.jmxremote.port=" + JMX_PORT); + args.add("-Dcom.sun.management.jmxremote.rmi.port=" + RMI_PORT); + args.add("-Dcom.sun.management.jmxremote.authenticate=false"); + args.add("-Dcom.sun.management.jmxremote.ssl=" + Boolean.toString(useSSL)); + if (useSSL) { + args.add("-Dcom.sun.management.jmxremote.registry.ssl=true"); + args.add("-Djavax.net.ssl.keyStore=" + KEYSTORE_LOC); + args.add("-Djavax.net.ssl.trustStore=" + TRUSTSTORE_LOC); + args.add("-Djavax.net.ssl.keyStorePassword=password"); + args.add("-Djavax.net.ssl.trustStorePassword=trustword"); + } + args.add(TEST_CLASS); + args.add(a.getHostAddress()); + args.add(Integer.toString(JMX_PORT)); + args.add(Integer.toString(RMI_PORT)); + args.add(Boolean.toString(useSSL)); + try { + ProcessBuilder builder = ProcessTools.createJavaProcessBuilder(args.toArray(new String[] {})); + System.out.println(ProcessTools.getCommandLine(builder)); + ProcessThread jvm = new ProcessThread("JMX-Tester-" + a.getHostAddress(), JMXInterfaceBindingTest::isJMXAgentResponseAvailable, builder); + return jvm; + } catch (Exception e) { + throw new RuntimeException("Test failed", e); + } + + } + + private static boolean isJMXAgentResponseAvailable(String line) { + if (line.equals(READY_MSG)) { + System.out.println("DEBUG: Found expected READY_MSG."); + return true; + } else if (line.startsWith("Error:")) { + // Allow for a JVM process that exits with + // "Error: JMX connector server communication error: ..." + // to continue as well since we handle that case elsewhere. + // This has the effect that the test does not timeout and + // fails with an exception in the test. + System.err.println("PROBLEM: JMX agent of target JVM did not start as it should."); + return true; + } else { + return false; + } + } + + public static void main(String[] args) { + InetAddress[] addrs = getAddressesForLocalHost(); + if (addrs.length < 2) { + System.out.println("Ignoring manual test since no more than one IPs are configured for 'localhost'"); + System.exit(0); + } + JMXInterfaceBindingTest test = new JMXInterfaceBindingTest(); + test.run(addrs); + System.out.println("All tests PASSED."); + } + + private static InetAddress[] getAddressesForLocalHost() { + InetAddress[] addrs; + try { + addrs = InetAddress.getAllByName("localhost"); + } catch (UnknownHostException e) { + throw new RuntimeException("Test failed", e); + } + return addrs; + } +} From 6435c91346aaebf2166daf726f7d1affbd2bb48b Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Tue, 22 Dec 2015 09:50:09 +0300 Subject: [PATCH 033/109] 8145551: Test failed with Crash for Improved font lookups Reviewed-by: prr, vadim --- .../share/native/libfontmanager/layout/Features.cpp | 7 ++++--- .../share/native/libfontmanager/layout/Lookups.cpp | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp index 0621888504d..730ad52a0bf 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/Features.cpp @@ -43,9 +43,10 @@ LEReferenceTo FeatureListTable::getFeatureTable(const LETableRefer LEReferenceToArrayOf featureRecordArrayRef(base, success, featureRecordArray, SWAPW(featureCount)); - if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) { - return LEReferenceTo(); - } + if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) { + success = LE_INDEX_OUT_OF_BOUNDS_ERROR; + return LEReferenceTo(); + } Offset featureTableOffset = featureRecordArray[featureIndex].featureTableOffset; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/layout/Lookups.cpp b/jdk/src/java.desktop/share/native/libfontmanager/layout/Lookups.cpp index f914f2d7ee0..ed2f6673311 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/layout/Lookups.cpp +++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/Lookups.cpp @@ -42,6 +42,7 @@ const LEReferenceTo LookupListTable::getLookupTable(const LEReferen LEReferenceToArrayOf lookupTableOffsetArrayRef(base, success, (const Offset*)&lookupTableOffsetArray, SWAPW(lookupCount)); if(LE_FAILURE(success) || lookupTableIndex>lookupTableOffsetArrayRef.getCount()) { + success = LE_INDEX_OUT_OF_BOUNDS_ERROR; return LEReferenceTo(); } else { return LEReferenceTo(base, success, SWAPW(lookupTableOffsetArrayRef.getObject(lookupTableIndex, success))); @@ -53,6 +54,7 @@ const LEReferenceTo LookupTable::getLookupSubtable(const LERefer LEReferenceToArrayOf subTableOffsetArrayRef(base, success, (const Offset*)&subTableOffsetArray, SWAPW(subTableCount)); if(LE_FAILURE(success) || subtableIndex>subTableOffsetArrayRef.getCount()) { + success = LE_INDEX_OUT_OF_BOUNDS_ERROR; return LEReferenceTo(); } else { return LEReferenceTo(base, success, SWAPW(subTableOffsetArrayRef.getObject(subtableIndex, success))); From dfa133a79676cd0b4b6cba7cf91f8ae7f1a8dda9 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Wed, 23 Dec 2015 13:12:46 +0300 Subject: [PATCH 034/109] 8067194: Restructure hotspot/agent/src to conform the modular source layout Move sources under jdk.hotspot.agent Reviewed-by: ihse, erikj, jbachorik --- jdk/make/gensrc/Gensrc-jdk.jdi.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/make/gensrc/Gensrc-jdk.jdi.gmk b/jdk/make/gensrc/Gensrc-jdk.jdi.gmk index 9fd609f5fb0..036388395fc 100644 --- a/jdk/make/gensrc/Gensrc-jdk.jdi.gmk +++ b/jdk/make/gensrc/Gensrc-jdk.jdi.gmk @@ -70,7 +70,7 @@ endef # Filter com.sun.jdi.connect.Connector $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector: \ $(JDK_TOPDIR)/src/jdk.jdi/share/classes/META-INF/services/com.sun.jdi.connect.Connector \ - $(HOTSPOT_TOPDIR)/agent/src/share/classes/META-INF/services/com.sun.jdi.connect.Connector + $(HOTSPOT_TOPDIR)/src/jdk.hotspot.agent/share/classes/META-INF/services/com.sun.jdi.connect.Connector $(process-provider) # Copy the same service file into jdk.hotspot.agent so that they are kept the same. From 08dadf30159430877399bab7724bab1b57e8b3f9 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Mon, 28 Dec 2015 14:03:39 -0500 Subject: [PATCH 035/109] 8071507: (ref) Clear phantom reference as soft and weak references do GC clears phantom refs on notification; update spec accordingly. Reviewed-by: mchung, jmasa --- .../java/lang/ref/PhantomReference.java | 25 ++--- .../classes/java/lang/ref/package-info.java | 21 +--- .../lang/ref/PhantomReferentClearing.java | 101 ++++++++++++++++++ 3 files changed, 117 insertions(+), 30 deletions(-) create mode 100644 jdk/test/java/lang/ref/PhantomReferentClearing.java diff --git a/jdk/src/java.base/share/classes/java/lang/ref/PhantomReference.java b/jdk/src/java.base/share/classes/java/lang/ref/PhantomReference.java index 88fe8fe9fa1..b79e3385a7f 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/PhantomReference.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/PhantomReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -29,23 +29,20 @@ package java.lang.ref; /** * Phantom reference objects, which are enqueued after the collector * determines that their referents may otherwise be reclaimed. Phantom - * references are most often used for scheduling pre-mortem cleanup actions in - * a more flexible way than is possible with the Java finalization mechanism. + * references are most often used to schedule post-mortem cleanup actions. * - *

If the garbage collector determines at a certain point in time that the - * referent of a phantom reference is phantom reachable, then at that - * time or at some later time it will enqueue the reference. + *

Suppose the garbage collector determines at a certain point in time + * that an object is + * phantom reachable. At that time it will atomically clear + * all phantom references to that object and all phantom references to + * any other phantom-reachable objects from which that object is reachable. + * At the same time or at some later time it will enqueue those newly-cleared + * phantom references that are registered with reference queues. * *

In order to ensure that a reclaimable object remains so, the referent of * a phantom reference may not be retrieved: The {@code get} method of a * phantom reference always returns {@code null}. * - *

Unlike soft and weak references, phantom references are not - * automatically cleared by the garbage collector as they are enqueued. An - * object that is reachable via phantom references will remain so until all - * such references are cleared or themselves become unreachable. - * * @author Mark Reinhold * @since 1.2 */ @@ -69,8 +66,8 @@ public class PhantomReference extends Reference { * *

It is possible to create a phantom reference with a {@code null} * queue, but such a reference is completely useless: Its {@code get} - * method will always return null and, since it does not have a queue, it - * will never be enqueued. + * method will always return {@code null} and, since it does not have a queue, + * it will never be enqueued. * * @param referent the object the new phantom reference will refer to * @param q the queue with which the reference is to be registered, diff --git a/jdk/src/java.base/share/classes/java/lang/ref/package-info.java b/jdk/src/java.base/share/classes/java/lang/ref/package-info.java index a6273a92183..0922d3b11c8 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/package-info.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,8 +43,7 @@ * implementing memory-sensitive caches, weak references are for * implementing canonicalizing mappings that do not prevent their keys * (or values) from being reclaimed, and phantom references are for - * scheduling pre-mortem cleanup actions in a more flexible way than - * is possible with the Java finalization mechanism. + * scheduling post-mortem cleanup actions. * *

Each reference-object type is implemented by a subclass of the * abstract base {@link java.lang.ref.Reference} class. @@ -64,9 +63,9 @@ * object with a reference queue at the time the reference * object is created. Some time after the garbage collector * determines that the reachability of the referent has changed to the - * value corresponding to the type of the reference, it will add the - * reference to the associated queue. At this point, the reference is - * considered to be enqueued. The program may remove + * value corresponding to the type of the reference, it will clear the + * reference and add it to the associated queue. At this point, the + * reference is considered to be enqueued. The program may remove * references from a queue either by polling or by blocking until a * reference becomes available. Reference queues are implemented by * the {@link java.lang.ref.ReferenceQueue} class. @@ -92,16 +91,6 @@ * structure, this check will add little overhead to the hashtable * access methods. * - *

Automatically-cleared references

- * - * Soft and weak references are automatically cleared by the collector - * before being added to the queues with which they are registered, if - * any. Therefore soft and weak references need not be registered - * with a queue in order to be useful, while phantom references do. - * An object that is reachable via phantom references will remain so - * until all such references are cleared or themselves become - * unreachable. - * * *

Reachability

* diff --git a/jdk/test/java/lang/ref/PhantomReferentClearing.java b/jdk/test/java/lang/ref/PhantomReferentClearing.java new file mode 100644 index 00000000000..7d126c7b23d --- /dev/null +++ b/jdk/test/java/lang/ref/PhantomReferentClearing.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8071507 + * @summary Test that PhantomReferences are cleared when notified. + * @run main/othervm PhantomReferentClearing + */ + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +import java.util.ArrayList; +import java.util.List; + +public class PhantomReferentClearing { + + private static final long ENQUEUE_TIMEOUT = 1000; // 1 sec, in millis + + // P1 & P2 are PhantomReference objects + // O1 & O2 are objects + // + // -> is a strong reference + // => is a referent reference + // + // root -> P1 + // root -> P2 + // root -> O1 + // root -> O2 + // O1 -> O2 + // P1 => O1 + // P2 => O2 + // + // (1) Remove root -> O1 and collect. P1 notified, P2 !notified. + // (2) Remove root -> O2 and collect. + // + // If phantom references are cleared when notified, as proposed by + // 8071507, then P2 should be notified, and the test passes. + // + // Otherwise, P2 does not get notified because it remains reachable + // from O1, which is being retained by P1. This fails the test. + + private static final ReferenceQueue Q1 = new ReferenceQueue<>(); + private static final ReferenceQueue Q2 = new ReferenceQueue<>(); + + private static volatile Object O2 = new Object(); + private static volatile List O1 = new ArrayList<>(); + static { + O1.add(O2); + } + + private static final PhantomReference P1 = new PhantomReference<>(O1, Q1); + private static final PhantomReference P2 = new PhantomReference<>(O2, Q2); + + public static void main(String[] args) throws InterruptedException { + + // Collect, and verify neither P1 or P2 notified. + System.gc(); + if (Q1.remove(ENQUEUE_TIMEOUT) != null) { + throw new RuntimeException("P1 already notified"); + } else if (Q2.poll() != null) { + throw new RuntimeException("P2 already notified"); + } + + // Delete root -> O1, collect, verify P1 notified, P2 not notified. + O1 = null; + System.gc(); + if (Q1.remove(ENQUEUE_TIMEOUT) == null) { + throw new RuntimeException("P1 not notified by O1 deletion"); + } else if (Q2.remove(ENQUEUE_TIMEOUT) != null) { + throw new RuntimeException("P2 notified by O1 deletion."); + } + + // Delete root -> O2, collect. P2 should be notified. + O2 = null; + System.gc(); + if (Q2.remove(ENQUEUE_TIMEOUT) == null) { + throw new RuntimeException("P2 not notified by O2 deletion"); + } + } +} From 7763f8d12ddcd440bf84d0e643dc4d9d303c4266 Mon Sep 17 00:00:00 2001 From: Kishor Kharbas Date: Mon, 28 Dec 2015 22:28:49 -0800 Subject: [PATCH 036/109] 8143925: Enhancing CounterMode.crypt() for AES Add intrinsic for CounterMode.crypt() to leverage the parallel nature of AES in Counter(CTR) Mode. Reviewed-by: kvn, ascarpino --- .../com/sun/crypto/provider/CounterMode.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/CounterMode.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/CounterMode.java index af52bd74474..684be4f0d76 100644 --- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/CounterMode.java +++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/CounterMode.java @@ -26,7 +26,9 @@ package com.sun.crypto.provider; import java.security.InvalidKeyException; +import java.util.Objects; +import jdk.internal.HotSpotIntrinsicCandidate; /** * This class represents ciphers in counter (CTR) mode. @@ -138,7 +140,7 @@ final class CounterMode extends FeedbackCipher { * cipherOffset. * * @param in the buffer with the input data to be encrypted - * @param inOffset the offset in plain + * @param inOff the offset in plain * @param len the length of the input data * @param out the buffer for the result * @param outOff the offset in cipher @@ -170,6 +172,15 @@ final class CounterMode extends FeedbackCipher { * are encrypted on demand. */ private int crypt(byte[] in, int inOff, int len, byte[] out, int outOff) { + + cryptBlockCheck(in, inOff, len); + cryptBlockCheck(out, outOff, len); + return implCrypt(in, inOff, len, out, outOff); + } + + // Implementation of crpyt() method. Possibly replaced with a compiler intrinsic. + @HotSpotIntrinsicCandidate + private int implCrypt(byte[] in, int inOff, int len, byte[] out, int outOff) { int result = len; while (len-- > 0) { if (used >= blockSize) { @@ -181,4 +192,23 @@ final class CounterMode extends FeedbackCipher { } return result; } + + // Used to perform all checks required by the Java semantics + // (i.e., null checks and bounds checks) on the input parameters to crypt(). + // Normally, the Java Runtime performs these checks, however, as crypt() is + // possibly replaced with compiler intrinsic, the JDK performs the + // required checks instead. + // Does not check accesses to class-internal (private) arrays. + private static void cryptBlockCheck(byte[] array, int offset, int len) { + Objects.requireNonNull(array); + + if (offset < 0 || len < 0 || offset >= array.length) { + throw new ArrayIndexOutOfBoundsException(offset); + } + + int largestIndex = offset + len - 1; + if (largestIndex < 0 || largestIndex >= array.length) { + throw new ArrayIndexOutOfBoundsException(largestIndex); + } + } } From 27368685db4a2bfe7dc6e902a6778f769264f85a Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Mon, 4 Jan 2016 10:07:08 +0100 Subject: [PATCH 037/109] 8145982: JMXInterfaceBindingTest is failing intermittently Reviewed-by: chegar, sgehwolf, olagneau --- .../management/jmxremote/bootstrap/JMXInterfaceBindingTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java b/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java index 94ebb1e54d1..45370151d22 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java @@ -174,7 +174,7 @@ public class JMXInterfaceBindingTest { InetAddress[] addrs = getAddressesForLocalHost(); if (addrs.length < 2) { System.out.println("Ignoring manual test since no more than one IPs are configured for 'localhost'"); - System.exit(0); + return; } JMXInterfaceBindingTest test = new JMXInterfaceBindingTest(); test.run(addrs); From d47aca611add0537cfb52d725d72072990235f68 Mon Sep 17 00:00:00 2001 From: Harsha Wardhana B Date: Mon, 4 Jan 2016 13:45:39 +0100 Subject: [PATCH 038/109] 7065236: To interpret case-insensitive string locale independently Reviewed-by: jbachorik --- .../javax/management/loading/MLetParser.java | 5 +- .../modelmbean/DescriptorSupport.java | 5 +- .../management/remote/JMXServiceURL.java | 7 +- .../loading/MletParserLocaleTest.java | 109 ++++++++++++++++++ jdk/test/javax/management/loading/mlet4.html | 2 + .../DescriptorSupportXMLLocaleTest.java | 64 ++++++++++ .../connection/JMXServiceURLLocaleTest.java | 68 +++++++++++ 7 files changed, 253 insertions(+), 7 deletions(-) create mode 100644 jdk/test/javax/management/loading/MletParserLocaleTest.java create mode 100644 jdk/test/javax/management/loading/mlet4.html create mode 100644 jdk/test/javax/management/modelmbean/DescriptorSupportXMLLocaleTest.java create mode 100644 jdk/test/javax/management/remote/mandatory/connection/JMXServiceURLLocaleTest.java diff --git a/jdk/src/java.management/share/classes/javax/management/loading/MLetParser.java b/jdk/src/java.management/share/classes/javax/management/loading/MLetParser.java index 4291c5bcbf7..ff261f39235 100644 --- a/jdk/src/java.management/share/classes/javax/management/loading/MLetParser.java +++ b/jdk/src/java.management/share/classes/javax/management/loading/MLetParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -37,6 +37,7 @@ import java.net.URLConnection; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.logging.Level; @@ -142,7 +143,7 @@ class MLetParser { skipSpace(in); val = buf.toString(); } - atts.put(att.toLowerCase(), val); + atts.put(att.toLowerCase(Locale.ENGLISH), val); skipSpace(in); } return atts; diff --git a/jdk/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java b/jdk/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java index f2534a62269..8499be40cc8 100644 --- a/jdk/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java +++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -45,6 +45,7 @@ import java.lang.reflect.Constructor; import java.security.AccessController; import java.util.HashMap; import java.util.Iterator; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.SortedMap; @@ -283,7 +284,7 @@ public class DescriptorSupport throw new RuntimeOperationsException(iae, msg); } - final String lowerInStr = inStr.toLowerCase(); + final String lowerInStr = inStr.toLowerCase(Locale.ENGLISH); if (!lowerInStr.startsWith("") || !lowerInStr.endsWith("")) { throw new XMLParseException("No , pair"); diff --git a/jdk/src/java.management/share/classes/javax/management/remote/JMXServiceURL.java b/jdk/src/java.management/share/classes/javax/management/remote/JMXServiceURL.java index 4f9c36e9509..bdac521bec3 100644 --- a/jdk/src/java.management/share/classes/javax/management/remote/JMXServiceURL.java +++ b/jdk/src/java.management/share/classes/javax/management/remote/JMXServiceURL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -38,6 +38,7 @@ import java.net.InetAddress; import java.net.MalformedURLException; import java.net.UnknownHostException; import java.util.BitSet; +import java.util.Locale; import java.util.StringTokenizer; /** @@ -168,7 +169,7 @@ public class JMXServiceURL implements Serializable { final int protoStart = requiredPrefixLength; final int protoEnd = indexOf(serviceURL, ':', protoStart); this.protocol = - serviceURL.substring(protoStart, protoEnd).toLowerCase(); + serviceURL.substring(protoStart, protoEnd).toLowerCase(Locale.ENGLISH); if (!serviceURL.regionMatches(protoEnd, "://", 0, 3)) { throw new MalformedURLException("Missing \"://\" after " + @@ -328,7 +329,7 @@ public class JMXServiceURL implements Serializable { throw new MalformedURLException("More than one [[...]]"); } - this.protocol = protocol.toLowerCase(); + this.protocol = protocol.toLowerCase(Locale.ENGLISH); this.host = host; this.port = port; diff --git a/jdk/test/javax/management/loading/MletParserLocaleTest.java b/jdk/test/javax/management/loading/MletParserLocaleTest.java new file mode 100644 index 00000000000..b541e57a149 --- /dev/null +++ b/jdk/test/javax/management/loading/MletParserLocaleTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7065236 + * @summary Checking MletParser for Locale insensitive strings + * @author Harsha Wardhana B + * @modules java.management + * @run clean MletParserLocaleTest + * @run build MletParserLocaleTest + * @run main/othervm/timeout=5 MletParserLocaleTest mlet4.html + */ + +import java.io.File; +import java.util.Locale; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.ObjectName; +import javax.management.loading.MLet; + +public class MletParserLocaleTest { + + public static void main(String[] args) throws Exception { + + boolean error = false; + + // Instantiate the MBean server + // + System.out.println("Create the MBean server"); + MBeanServer mbs = MBeanServerFactory.createMBeanServer(); + + // Get Default Locale + Locale loc = Locale.getDefault(); + + // Instantiate an MLet + // + System.out.println("Create the MLet"); + MLet mlet = new MLet(); + + // Register the MLet MBean with the MBeanServer + // + System.out.println("Register the MLet MBean"); + ObjectName mletObjectName = new ObjectName("Test:type=MLet"); + mbs.registerMBean(mlet, mletObjectName); + + // Call getMBeansFromURL + // + System.out.println("Call mlet.getMBeansFromURL()"); + String testSrc = System.getProperty("test.src"); + System.out.println("test.src = " + testSrc); + String urlCodebase; + if (testSrc.startsWith("/")) { + urlCodebase = + "file:" + testSrc.replace(File.separatorChar, '/') + "/"; + } else { + urlCodebase = + "file:/" + testSrc.replace(File.separatorChar, '/') + "/"; + } + String mletFile = urlCodebase + args[0]; + System.out.println("MLet File = " + mletFile); + try { + // Change default Locale to Turkish + Locale.setDefault(new Locale("tr", "TR")); + mlet.getMBeansFromURL(mletFile); + System.out.println("Test Passes"); + } catch (Exception e) { + error = true; + e.printStackTrace(System.out); + }finally { + Locale.setDefault(loc); + } + + // Unregister the MLet MBean + // + System.out.println("Unregister the MLet MBean"); + mbs.unregisterMBean(mletObjectName); + + // Release MBean server + // + System.out.println("Release the MBean server"); + MBeanServerFactory.releaseMBeanServer(mbs); + + // End Test + // + System.out.println("Bye! Bye!"); + if (error) System.exit(1); + } +} diff --git a/jdk/test/javax/management/loading/mlet4.html b/jdk/test/javax/management/loading/mlet4.html new file mode 100644 index 00000000000..522ab27252d --- /dev/null +++ b/jdk/test/javax/management/loading/mlet4.html @@ -0,0 +1,2 @@ + + diff --git a/jdk/test/javax/management/modelmbean/DescriptorSupportXMLLocaleTest.java b/jdk/test/javax/management/modelmbean/DescriptorSupportXMLLocaleTest.java new file mode 100644 index 00000000000..402bff7f6e0 --- /dev/null +++ b/jdk/test/javax/management/modelmbean/DescriptorSupportXMLLocaleTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + /* + * @test + * @bug 7065236 + * @summary Test for locale insensitive strings in DescriptorSupport class + * @author Harsha Wardhana B + * @modules java.management + * @run clean DescriptorSupportXMLLocaleTest + * @run build DescriptorSupportXMLLocaleTest + * @run main DescriptorSupportXMLLocaleTest + */ +import java.util.Locale; +import javax.management.modelmbean.DescriptorSupport; + +public class DescriptorSupportXMLLocaleTest { + + public static void main(String[] args) throws Exception { + boolean failed = false; + String xmlDesc = "" + + "" + + "" + + ""; + Locale loc = Locale.getDefault(); + try { + Locale.setDefault(new Locale("tr", "TR")); + new DescriptorSupport(xmlDesc); + } catch (Exception e) { + e.printStackTrace(System.out); + failed = true; + }finally{ + Locale.setDefault(loc); + } + + if (!failed) { + System.out.println("OK: all tests passed"); + } else { + System.out.println("TEST FAILED"); + throw new IllegalArgumentException("Test Failed"); + } + } +} + diff --git a/jdk/test/javax/management/remote/mandatory/connection/JMXServiceURLLocaleTest.java b/jdk/test/javax/management/remote/mandatory/connection/JMXServiceURLLocaleTest.java new file mode 100644 index 00000000000..4ff6020ea41 --- /dev/null +++ b/jdk/test/javax/management/remote/mandatory/connection/JMXServiceURLLocaleTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7065236 + * @summary Test for locale insensitive strings in JMXServiceURL class + * @author Harsha Wardhana B + * @modules java.management + * @run clean JMXServiceURLLocaleTest + * @run build JMXServiceURLLocaleTest + * @run main JMXServiceURLLocaleTest +*/ + +import java.util.Locale; +import javax.management.remote.JMXServiceURL; + +public class JMXServiceURLLocaleTest { + public static void main(String[] args) throws Exception { + + boolean error = false; + Locale loc = Locale.getDefault(); + + try { + echo("Setting Turkish locale"); + // Set locale other than Locale.ENGLISH + Locale.setDefault(new Locale("tr", "TR")); + new JMXServiceURL("service:jmx:RMI://"); + } catch (Exception e) { + e.printStackTrace(System.out); + error = true; + } finally { + Locale.setDefault(loc); + echo("\n>>> Bye! Bye!"); + } + + if (error) { + echo("\nTest failed! "); + throw new IllegalArgumentException("Test failed"); + } else { + echo("\nTest passed!\n"); + } + } + + private static void echo(String msg) { + System.out.println(msg); + } +} From 91e7b0bd8ae86caa71b1012df40c62586749ce1e Mon Sep 17 00:00:00 2001 From: Harsha Wardhana B Date: Mon, 4 Jan 2016 13:49:11 +0100 Subject: [PATCH 039/109] 6744127: NullPointerException at com.sun.tools.jdi.EventRequestManagerImpl.request Reviewed-by: jbachorik, sspitsyn --- .../tools/jdi/EventRequestManagerImpl.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java index 93c10f0b00f..6f928785255 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,7 +43,7 @@ import java.util.*; class EventRequestManagerImpl extends MirrorImpl implements EventRequestManager { - List[] requestLists; + private final List[] requestLists; private static int methodExitEventCmd = 0; static int JDWPtoJDISuspendPolicy(byte jdwpPolicy) { @@ -83,7 +83,7 @@ class EventRequestManagerImpl extends MirrorImpl return System.identityHashCode(this); } - abstract class EventRequestImpl extends MirrorImpl implements EventRequest { + private abstract class EventRequestImpl extends MirrorImpl implements EventRequest { int id; /* @@ -734,7 +734,7 @@ class EventRequestManagerImpl extends MirrorImpl } requestLists = new List[highest+1]; for (int i=0; i <= highest; i++) { - requestLists[i] = new ArrayList<>(); + requestLists[i] = Collections.synchronizedList(new ArrayList<>()); } } @@ -933,22 +933,27 @@ class EventRequestManagerImpl extends MirrorImpl } List unmodifiableRequestList(int eventCmd) { - return Collections.unmodifiableList(requestList(eventCmd)); + // No need of explicit synchronization for requestList here. + // It is taken care internally by SynchronizedList class. + return Collections.unmodifiableList(new ArrayList<>(requestList(eventCmd))); } EventRequest request(int eventCmd, int requestId) { List rl = requestList(eventCmd); - for (int i = rl.size() - 1; i >= 0; i--) { - EventRequestImpl er = (EventRequestImpl)rl.get(i); - if (er.id == requestId) { - return er; + synchronized(rl) { // Refer Collections.synchronizedList javadoc. + Iterator itr = rl.iterator(); + while (itr.hasNext()){ + EventRequestImpl er = (EventRequestImpl)itr.next(); + if (er.id == requestId) + return er; } } return null; } - List requestList(int eventCmd) { + private List requestList(int eventCmd) { return requestLists[eventCmd]; } } + From f8e1f9dc01ff3d6dec2a1fe0f01096be774842e8 Mon Sep 17 00:00:00 2001 From: Andreas Lundblad Date: Fri, 8 Jan 2016 17:05:32 +0100 Subject: [PATCH 040/109] 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent Updated include/exclude pattern arguments for sjavac. Reviewed-by: erikj --- make/common/JavaCompilation.gmk | 61 +++++++++++++++---------------- test/make/TestJavaCompilation.gmk | 1 + 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/make/common/JavaCompilation.gmk b/make/common/JavaCompilation.gmk index 7eb7a95a48e..4bf3a0d5774 100644 --- a/make/common/JavaCompilation.gmk +++ b/make/common/JavaCompilation.gmk @@ -202,23 +202,28 @@ define SetupJavaCompilationBody # CacheFind does not preserve order so need to call it for each root. $1_ALL_SRCS += $$(foreach s, $$($1_SRC), $$(call CacheFind, $$(s))) # Extract the java files. - ifneq ($$($1_EXCLUDE_FILES),) - $1_EXCLUDE_FILES_PATTERN:=$$(addprefix %,$$($1_EXCLUDE_FILES)) + $1_SRCS := $$(filter %.java, $$($1_ALL_SRCS)) + + # Translate include/exclude into patterns + ifneq ($$($1_EXCLUDE_FILES), ) + $1_EXCLUDE_PATTERN := $$(addprefix %, $$($1_EXCLUDE_FILES)) endif - $1_SRCS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$(filter %.java,$$($1_ALL_SRCS))) - ifneq ($$($1_INCLUDE_FILES),) - $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES))) - $1_SRCS := $$(filter $$($1_INCLUDE_FILES), $$($1_SRCS)) + ifneq ($$($1_INCLUDE_FILES), ) + $1_INCLUDE_PATTERN := $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$($1_INCLUDE_FILES))) + endif + ifneq ($$($1_EXCLUDES), ) + $1_EXCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_EXCLUDES)))) + endif + ifneq ($$($1_INCLUDES), ) + $1_INCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_INCLUDES)))) endif - # Prepend the source/bin path to the filter expressions. - ifneq ($$($1_INCLUDES),) - $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES)))) - $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS)) + # Apply include/exclude patterns to java sources + ifneq ($$($1_EXCLUDE_PATTERN), ) + $1_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_SRCS)) endif - ifneq ($$($1_EXCLUDES),) - $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) - $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) + ifneq ($$($1_INCLUDE_PATTERN), ) + $1_SRCS := $$(filter $$($1_INCLUDE_PATTERN), $$($1_SRCS)) endif ifneq ($$($1_KEEP_DUPS), true) @@ -242,10 +247,10 @@ define SetupJavaCompilationBody $1_SAFE_NAME := $$(strip $$(subst /,_, $1)) # Create the corresponding smart javac wrapper command line. - $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix /*,$$($1_EXCLUDES))) \ - $$(addprefix -i ,$$(addsuffix /*,$$($1_INCLUDES))) \ - $$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES) $$($1_SJAVAC_EXCLUDE_FILES))) \ - $$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \ + $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix /**,$$($1_EXCLUDES))) \ + $$(addprefix -i ,$$(addsuffix /**,$$($1_INCLUDES))) \ + $$(addprefix -x **,$$(strip $$($1_EXCLUDE_FILES) $$($1_SJAVAC_EXCLUDE_FILES))) \ + $$(addprefix -i **,$$(strip $$($1_INCLUDE_FILES))) \ -src $$(call PathList, $$($1_SRC)) # All files below META-INF are always copied. @@ -258,14 +263,11 @@ define SetupJavaCompilationBody $1_ALL_COPIES += $$($1_COPY_FILES) endif # Copy must also respect filters. - ifneq (,$$($1_INCLUDES)) - $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES)) + ifneq (,$$($1_INCLUDE_PATTERN)) + $1_ALL_COPIES := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_COPIES)) endif - ifneq (,$$($1_EXCLUDES)) - $1_ALL_COPIES := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_COPIES)) - endif - ifneq (,$$($1_EXCLUDE_FILES)) - $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES)) + ifneq (,$$($1_EXCLUDE_PATTERN)) + $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDES_PATTERN),$$($1_ALL_COPIES)) endif ifneq (,$$($1_ALL_COPIES)) # Yep, there are files to be copied! @@ -281,14 +283,11 @@ define SetupJavaCompilationBody # Clean these explicitly $1_ALL_CLEANS += $$($1_CLEAN_FILES) # Copy and clean must also respect filters. - ifneq (,$$($1_INCLUDES)) - $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS)) + ifneq (,$$($1_INCLUDE_PATTERN)) + $1_ALL_CLEANS := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_CLEANS)) endif - ifneq (,$$($1_EXCLUDES)) - $1_ALL_CLEANS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_CLEANS)) - endif - ifneq (,$$($1_EXCLUDE_FILES)) - $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_CLEANS)) + ifneq (,$$($1_EXCLUDE_PATTERN)) + $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_CLEANS)) endif ifneq (,$$($1_ALL_CLEANS)) # Yep, there are files to be copied and cleaned! diff --git a/test/make/TestJavaCompilation.gmk b/test/make/TestJavaCompilation.gmk index 40f64018e00..f38d02c4327 100644 --- a/test/make/TestJavaCompilation.gmk +++ b/test/make/TestJavaCompilation.gmk @@ -239,6 +239,7 @@ TEST_TARGETS += $(OUTPUT_DIR)/_jar3_updated $(eval $(call SetupJavaCompiler,BOOT_JAVAC, \ JAVAC := $(JAVAC), \ + DISABLE_SJAVAC := true, \ )) JAVA_SRC_ROOT1 := $(OUTPUT_DIR)/javaroot1 From b345518d32f7b1617425e73fa02fae54822f56a7 Mon Sep 17 00:00:00 2001 From: Andreas Lundblad Date: Fri, 8 Jan 2016 17:14:10 +0100 Subject: [PATCH 041/109] 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent Rewrote sjavac include/exclude pattern handling. Reviewed-by: jlahoda --- .../classes/com/sun/tools/sjavac/Source.java | 307 ++++++------------ .../classes/com/sun/tools/sjavac/Util.java | 6 + .../com/sun/tools/sjavac/comp/SjavacImpl.java | 160 ++++----- .../com/sun/tools/sjavac/options/Option.java | 22 +- .../tools/sjavac/options/OptionHelper.java | 6 - .../com/sun/tools/sjavac/options/Options.java | 18 +- .../tools/sjavac/options/SourceLocation.java | 41 ++- .../sjavac/CompileExcludingDependency.java | 4 +- .../test/tools/sjavac/CompileWithAtFile.java | 4 +- .../sjavac/CompileWithInvisibleSources.java | 2 +- .../sjavac/CompileWithOverrideSources.java | 2 +- langtools/test/tools/sjavac/ExclPattern.java | 94 ------ langtools/test/tools/sjavac/HiddenFiles.java | 67 ++++ .../tools/sjavac/IncludeExcludePatterns.java | 166 ++++++++++ .../test/tools/sjavac/OptionDecoding.java | 77 +---- .../test/tools/sjavac/Serialization.java | 4 - .../tools/sjavac/util/OptionTestUtil.java | 4 +- 17 files changed, 462 insertions(+), 522 deletions(-) delete mode 100644 langtools/test/tools/sjavac/ExclPattern.java create mode 100644 langtools/test/tools/sjavac/HiddenFiles.java create mode 100644 langtools/test/tools/sjavac/IncludeExcludePatterns.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Source.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Source.java index cc54eb57e2a..b288955b9a1 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Source.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Source.java @@ -26,11 +26,20 @@ package com.sun.tools.sjavac; import java.io.File; +import java.io.IOException; +import java.nio.file.FileSystem; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; import java.util.Set; import java.util.Collections; import java.util.List; import java.util.ArrayList; import java.util.Map; +import java.util.regex.PatternSyntaxException; /** A Source object maintains information about a source file. * For example which package it belongs to and kind of source it is. @@ -56,8 +65,6 @@ public class Source implements Comparable { private long lastModified; // The source File. private File file; - // The source root under which file resides. - private File root; // If the source is generated. private boolean isGenerated; // If the source is only linked to, not compiled. @@ -78,7 +85,7 @@ public class Source implements Comparable { return name.hashCode(); } - public Source(Module m, String n, File f, File r) { + public Source(Module m, String n, File f) { name = n; int dp = n.lastIndexOf("."); if (dp != -1) { @@ -87,7 +94,6 @@ public class Source implements Comparable { suffix = ""; } file = f; - root = r; lastModified = f.lastModified(); linkedOnly = false; } @@ -102,7 +108,6 @@ public class Source implements Comparable { suffix = ""; } file = null; - root = null; lastModified = lm; linkedOnly = false; int ls = n.lastIndexOf('/'); @@ -112,7 +117,6 @@ public class Source implements Comparable { public String suffix() { return suffix; } public Package pkg() { return pkg; } public File file() { return file; } - public File root() { return root; } public long lastModified() { return lastModified; } @@ -183,225 +187,122 @@ public class Source implements Comparable { */ static public void scanRoot(File root, Set suffixes, - List excludes, List includes, - List excludeFiles, List includeFiles, + List excludes, + List includes, Map foundFiles, Map foundModules, - Module currentModule, + final Module currentModule, boolean permitSourcesWithoutPackage, boolean inGensrc, boolean inLinksrc) - throws ProblemException { + throws IOException, ProblemException { - if (root == null) return; - int root_prefix = root.getPath().length()+1; - // This is the root source directory, it must not contain any Java sources files - // because we do not allow Java source files without a package. - // (Unless of course --permit-sources-without-package has been specified.) - // It might contain other source files however, (for -tr and -copy) these will - // always be included, since no package pattern can match the root directory. - currentModule = addFilesInDir(root, root_prefix, root, suffixes, permitSourcesWithoutPackage, - excludeFiles, includeFiles, - foundFiles, foundModules, currentModule, - inGensrc, inLinksrc); + if (root == null) + return; - File[] dirfiles = root.listFiles(); - for (File d : dirfiles) { - if (d.isDirectory()) { - // Descend into the directory structure. - scanDirectory(d, root_prefix, root, suffixes, - excludes, includes, excludeFiles, includeFiles, - foundFiles, foundModules, currentModule, inGensrc, inLinksrc); - } + FileSystem fs = root.toPath().getFileSystem(); + + if (includes.isEmpty()) { + includes = Collections.singletonList("**"); } - } - /** - * Test if a path matches any of the patterns given. - * The pattern foo/bar matches only foo/bar - * The pattern foo/* matches foo/bar and foo/bar/zoo etc - */ - static private boolean hasMatch(String path, List patterns) { + List includeMatchers = createPathMatchers(fs, includes); + List excludeMatchers = createPathMatchers(fs, excludes); - // Convert Windows '\' to '/' for the sake of comparing with the patterns - path = path.replace(File.separatorChar, '/'); + Files.walkFileTree(root.toPath(), new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - for (String p : patterns) { - // Exact match - if (p.equals(path)) - return true; + Path relToRoot = root.toPath().relativize(file); - // Single dot the end matches this package and all its subpackages. - if (p.endsWith("/*")) { - // Remove the wildcard - String patprefix = p.substring(0,p.length()-2); - // Does the path start with the pattern prefix? - if (path.startsWith(patprefix)) { - // If the path has the same length as the pattern prefix, then it is a match. - // If the path is longer, then make sure that - // the next part of the path starts with a dot (.) to prevent - // wildcard matching in the middle of a package name. - if (path.length()==patprefix.length() || path.charAt(patprefix.length())=='/') { - return true; + if (includeMatchers.stream().anyMatch(im -> im.matches(relToRoot)) + && excludeMatchers.stream().noneMatch(em -> em.matches(relToRoot)) + && suffixes.contains(Util.fileSuffix(file))) { + + // TODO: Test this. + Source existing = foundFiles.get(file); + if (existing != null) { + throw new IOException("You have already added the file "+file+" from "+existing.file().getPath()); } - } - } - } - return false; - } + existing = currentModule.lookupSource(file.toString()); + if (existing != null) { - /** - * Matches patterns with the asterisk first. */ - // The pattern foo/bar.java only matches foo/bar.java - // The pattern */bar.java matches foo/bar.java and zoo/bar.java etc - static private boolean hasFileMatch(String path, List patterns) { - // Convert Windows '\' to '/' for the sake of comparing with the patterns - path = path.replace(File.separatorChar, '/'); + // Oups, the source is already added, could be ok, could be not, lets check. + if (inLinksrc) { + // So we are collecting sources for linking only. + if (existing.isLinkedOnly()) { + // Ouch, this one is also for linking only. Bad. + throw new IOException("You have already added the link only file " + file + " from " + existing.file().getPath()); + } + // Ok, the existing source is to be compiled. Thus this link only is redundant + // since all compiled are also linked to. Continue to the next source. + // But we need to add the source, so that it will be visible to linking, + // if not the multi core compile will fail because a JavaCompiler cannot + // find the necessary dependencies for its part of the source. + foundFiles.put(file.toString(), existing); + } else { + // We are looking for sources to compile, if we find an existing to be compiled + // source with the same name, it is an internal error, since we must + // find the sources to be compiled before we find the sources to be linked to. + throw new IOException("Internal error: Double add of file " + file + " from " + existing.file().getPath()); + } - path = Util.normalizeDriveLetter(path); - for (String p : patterns) { - // Exact match - if (p.equals(path)) { - return true; - } - // Single dot the end matches this package and all its subpackages. - if (p.startsWith("*")) { - // Remove the wildcard - String patsuffix = p.substring(1); - // Does the path start with the pattern prefix? - if (path.endsWith(patsuffix)) { - return true; - } - } - } - return false; - } - - /** - * Add the files in the directory, assuming that the file has not been excluded. - * Returns a fresh Module object, if this was a dir with a module-info.java file. - */ - static private Module addFilesInDir(File dir, int rootPrefix, File root, - Set suffixes, boolean allow_javas, - List excludeFiles, List includeFiles, - Map foundFiles, - Map foundModules, - Module currentModule, - boolean inGensrc, - boolean inLinksrc) - throws ProblemException - { - for (File f : dir.listFiles()) { - - if (!f.isFile()) - continue; - - boolean should_add = - (excludeFiles == null || excludeFiles.isEmpty() || !hasFileMatch(f.getPath(), excludeFiles)) - && (includeFiles == null || includeFiles.isEmpty() || hasFileMatch(f.getPath(), includeFiles)); - - if (!should_add) - continue; - - if (!allow_javas && f.getName().endsWith(".java")) { - throw new ProblemException("No .java files are allowed in the source root "+dir.getPath()+ - ", please remove "+f.getName()); - } - // Extract the file name relative the root. - String fn = f.getPath().substring(rootPrefix); - // Extract the package name. - int sp = fn.lastIndexOf(File.separatorChar); - String pkg = ""; - if (sp != -1) { - pkg = fn.substring(0,sp).replace(File.separatorChar,'.'); - } - // Is this a module-info.java file? - if (fn.endsWith("module-info.java")) { - // Aha! We have recursed into a module! - if (!currentModule.name().equals("")) { - throw new ProblemException("You have an extra module-info.java inside a module! Please remove "+fn); - } - String module_name = fn.substring(0,fn.length()-16); - currentModule = new Module(module_name, f.getPath()); - foundModules.put(module_name, currentModule); - } - // Extract the suffix. - int dp = fn.lastIndexOf("."); - String suffix = ""; - if (dp > 0) { - suffix = fn.substring(dp); - } - // Should the file be added? - if (suffixes.contains(suffix)) { - Source of = foundFiles.get(f.getPath()); - if (of != null) { - throw new ProblemException("You have already added the file "+fn+" from "+of.file().getPath()); - } - of = currentModule.lookupSource(f.getPath()); - if (of != null) { - // Oups, the source is already added, could be ok, could be not, lets check. - if (inLinksrc) { - // So we are collecting sources for linking only. - if (of.isLinkedOnly()) { - // Ouch, this one is also for linking only. Bad. - throw new ProblemException("You have already added the link only file "+fn+" from "+of.file().getPath()); - } - // Ok, the existing source is to be compiled. Thus this link only is redundant - // since all compiled are also linked to. Continue to the next source. - // But we need to add the source, so that it will be visible to linking, - // if not the multi core compile will fail because a JavaCompiler cannot - // find the necessary dependencies for its part of the source. - foundFiles.put(f.getPath(), of); - continue; } else { - // We are looking for sources to compile, if we find an existing to be compiled - // source with the same name, it is an internal error, since we must - // find the sources to be compiled before we find the sources to be linked to. - throw new ProblemException("Internal error: Double add of file "+fn+" from "+of.file().getPath()); + + ////////////////////////////////////////////////////////////// + // Add source + Source s = new Source(currentModule, file.toString(), file.toFile()); + if (inGensrc) { + s.markAsGenerated(); + } + if (inLinksrc) { + s.markAsLinkedOnly(); + } + String pkg = packageOfJavaFile(root.toPath(), file); + pkg = currentModule.name() + ":" + pkg; + foundFiles.put(file.toString(), s); + currentModule.addSource(pkg, s); + ////////////////////////////////////////////////////////////// } } - Source s = new Source(currentModule, f.getPath(), f, root); - if (inGensrc) s.markAsGenerated(); - if (inLinksrc) { - s.markAsLinkedOnly(); - } - pkg = currentModule.name()+":"+pkg; - foundFiles.put(f.getPath(), s); - currentModule.addSource(pkg, s); + + return FileVisitResult.CONTINUE; } - } - return currentModule; + }); } - static private void scanDirectory(File dir, int rootPrefix, File root, - Set suffixes, - List excludes, List includes, - List excludeFiles, List includeFiles, - Map foundFiles, - Map foundModules, - Module currentModule, boolean inGensrc, boolean inLinksrc) - throws ProblemException { - - String path = ""; - // Remove the root prefix from the dir path - if (dir.getPath().length() > rootPrefix) { - path = dir.getPath().substring(rootPrefix); - } - // Should this package directory be included and not excluded? - if ((includes==null || includes.isEmpty() || hasMatch(path, includes)) && - (excludes==null || excludes.isEmpty() || !hasMatch(path, excludes))) { - // Add the source files. - currentModule = addFilesInDir(dir, rootPrefix, root, suffixes, true, excludeFiles, includeFiles, - foundFiles, foundModules, currentModule, inGensrc, inLinksrc); - } - - for (File d : dir.listFiles()) { - if (d.isDirectory()) { - // Descend into the directory structure. - scanDirectory(d, rootPrefix, root, suffixes, - excludes, includes, excludeFiles, includeFiles, - foundFiles, foundModules, currentModule, inGensrc, inLinksrc); + private static List createPathMatchers(FileSystem fs, List patterns) { + List matchers = new ArrayList<>(); + for (String pattern : patterns) { + try { + matchers.add(fs.getPathMatcher("glob:" + pattern)); + } catch (PatternSyntaxException e) { + Log.error("Invalid pattern: " + pattern); + throw e; } } + return matchers; + } + + private static String packageOfJavaFile(Path sourceRoot, Path javaFile) { + Path javaFileDir = javaFile.getParent(); + Path packageDir = sourceRoot.relativize(javaFileDir); + List separateDirs = new ArrayList<>(); + for (Path pathElement : packageDir) { + separateDirs.add(pathElement.getFileName().toString()); + } + return String.join(".", separateDirs); + } + + @Override + public String toString() { + return String.format("%s[pkg: %s, name: %s, suffix: %s, file: %s, isGenerated: %b, linkedOnly: %b]", + getClass().getSimpleName(), + pkg, + name, + suffix, + file, + isGenerated, + linkedOnly); } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Util.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Util.java index 5d137ef8be7..03fcc537244 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Util.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Util.java @@ -230,4 +230,10 @@ public class Util { Function indexFunction) { return c.stream().collect(Collectors.toMap(indexFunction, o -> o)); } + + public static String fileSuffix(Path file) { + String fileNameStr = file.getFileName().toString(); + int dotIndex = fileNameStr.indexOf('.'); + return dotIndex == -1 ? "" : fileNameStr.substring(dotIndex); + } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java index 092501b483b..5a6194acb8e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java @@ -144,77 +144,77 @@ public class SjavacImpl implements Sjavac { Module current_module = new Module("", ""); modules.put("", current_module); - // Find all sources, use the suffix rules to know which files are sources. - Map sources = new HashMap<>(); - - // Find the files, this will automatically populate the found modules - // with found packages where the sources are found! - findSourceFiles(options.getSources(), - suffixRules.keySet(), - sources, - modules, - current_module, - options.isDefaultPackagePermitted(), - false); - - if (sources.isEmpty()) { - Log.error("Found nothing to compile!"); - return RC_FATAL; - } - - - // Create a map of all source files that are available for linking. Both -src and - // -sourcepath point to such files. It is possible to specify multiple - // -sourcepath options to enable different filtering rules. If the - // filters are the same for multiple sourcepaths, they may be concatenated - // using :(;). Before sending the list of sourcepaths to javac, they are - // all concatenated. The list created here is used by the SmartFileWrapper to - // make sure only the correct sources are actually available. - // We might find more modules here as well. - Map sources_to_link_to = new HashMap<>(); - - List sourceResolutionLocations = new ArrayList<>(); - sourceResolutionLocations.addAll(options.getSources()); - sourceResolutionLocations.addAll(options.getSourceSearchPaths()); - findSourceFiles(sourceResolutionLocations, - Collections.singleton(".java"), - sources_to_link_to, - modules, - current_module, - options.isDefaultPackagePermitted(), - true); - - // Add the set of sources to the build database. - javac_state.now().flattenPackagesSourcesAndArtifacts(modules); - javac_state.now().checkInternalState("checking sources", false, sources); - javac_state.now().checkInternalState("checking linked sources", true, sources_to_link_to); - javac_state.setVisibleSources(sources_to_link_to); - - int round = 0; - printRound(round); - - // If there is any change in the source files, taint packages - // and mark the database in need of saving. - javac_state.checkSourceStatus(false); - - // Find all existing artifacts. Their timestamp will match the last modified timestamps stored - // in javac_state, simply because loading of the JavacState will clean out all artifacts - // that do not match the javac_state database. - javac_state.findAllArtifacts(); - - // Remove unidentified artifacts from the bin, gensrc and header dirs. - // (Unless we allow them to be there.) - // I.e. artifacts that are not known according to the build database (javac_state). - // For examples, files that have been manually copied into these dirs. - // Artifacts with bad timestamps (ie the on disk timestamp does not match the timestamp - // in javac_state) have already been removed when the javac_state was loaded. - if (!options.areUnidentifiedArtifactsPermitted()) { - javac_state.removeUnidentifiedArtifacts(); - } - // Go through all sources and taint all packages that miss artifacts. - javac_state.taintPackagesThatMissArtifacts(); - try { + // Find all sources, use the suffix rules to know which files are sources. + Map sources = new HashMap<>(); + + // Find the files, this will automatically populate the found modules + // with found packages where the sources are found! + findSourceFiles(options.getSources(), + suffixRules.keySet(), + sources, + modules, + current_module, + options.isDefaultPackagePermitted(), + false); + + if (sources.isEmpty()) { + Log.error("Found nothing to compile!"); + return RC_FATAL; + } + + + // Create a map of all source files that are available for linking. Both -src and + // -sourcepath point to such files. It is possible to specify multiple + // -sourcepath options to enable different filtering rules. If the + // filters are the same for multiple sourcepaths, they may be concatenated + // using :(;). Before sending the list of sourcepaths to javac, they are + // all concatenated. The list created here is used by the SmartFileWrapper to + // make sure only the correct sources are actually available. + // We might find more modules here as well. + Map sources_to_link_to = new HashMap<>(); + + List sourceResolutionLocations = new ArrayList<>(); + sourceResolutionLocations.addAll(options.getSources()); + sourceResolutionLocations.addAll(options.getSourceSearchPaths()); + findSourceFiles(sourceResolutionLocations, + Collections.singleton(".java"), + sources_to_link_to, + modules, + current_module, + options.isDefaultPackagePermitted(), + true); + + // Add the set of sources to the build database. + javac_state.now().flattenPackagesSourcesAndArtifacts(modules); + javac_state.now().checkInternalState("checking sources", false, sources); + javac_state.now().checkInternalState("checking linked sources", true, sources_to_link_to); + javac_state.setVisibleSources(sources_to_link_to); + + int round = 0; + printRound(round); + + // If there is any change in the source files, taint packages + // and mark the database in need of saving. + javac_state.checkSourceStatus(false); + + // Find all existing artifacts. Their timestamp will match the last modified timestamps stored + // in javac_state, simply because loading of the JavacState will clean out all artifacts + // that do not match the javac_state database. + javac_state.findAllArtifacts(); + + // Remove unidentified artifacts from the bin, gensrc and header dirs. + // (Unless we allow them to be there.) + // I.e. artifacts that are not known according to the build database (javac_state). + // For examples, files that have been manually copied into these dirs. + // Artifacts with bad timestamps (ie the on disk timestamp does not match the timestamp + // in javac_state) have already been removed when the javac_state was loaded. + if (!options.areUnidentifiedArtifactsPermitted()) { + javac_state.removeUnidentifiedArtifacts(); + } + // Go through all sources and taint all packages that miss artifacts. + javac_state.taintPackagesThatMissArtifacts(); + // Check recorded classpath public apis. Taint packages that depend on // classpath classes whose public apis have changed. javac_state.taintPackagesDependingOnChangedClasspathPackages(); @@ -229,8 +229,16 @@ public class SjavacImpl implements Sjavac { // (Generated sources must always have a package.) Map generated_sources = new HashMap<>(); - Source.scanRoot(Util.pathToFile(options.getGenSrcDir()), Util.set(".java"), null, null, null, null, - generated_sources, modules, current_module, false, true, false); + Source.scanRoot(Util.pathToFile(options.getGenSrcDir()), + Util.set(".java"), + Collections.emptyList(), + Collections.emptyList(), + generated_sources, + modules, + current_module, + false, + true, + false); javac_state.now().flattenPackagesSourcesAndArtifacts(modules); // Recheck the the source files and their timestamps again. javac_state.checkSourceStatus(true); @@ -254,7 +262,10 @@ public class SjavacImpl implements Sjavac { printRound(round); // Clean out artifacts in tainted packages. javac_state.deleteClassArtifactsInTaintedPackages(); - again = javac_state.performJavaCompilations(compilationService, options, recently_compiled, rc); + again = javac_state.performJavaCompilations(compilationService, + options, + recently_compiled, + rc); if (!rc[0]) { Log.debug("Compilation failed."); break; @@ -344,7 +355,8 @@ public class SjavacImpl implements Sjavac { Map foundModules, Module currentModule, boolean permitSourcesInDefaultPackage, - boolean inLinksrc) { + boolean inLinksrc) + throws IOException { for (SourceLocation source : sourceLocations) { source.findSourceFiles(sourceTypes, diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java index 364c48b4117..d64d3182cc0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java @@ -93,7 +93,7 @@ public enum Option { CLASSPATH.processMatching(iter, helper); } }, - X("-x", "Exclude directory from the subsequent source directory") { + X("-x", "Exclude files matching the given pattern") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { String pattern = getFilePatternArg(iter, helper); @@ -101,7 +101,7 @@ public enum Option { helper.exclude(pattern); } }, - I("-i", "Include only the given directory from the subsequent source directory") { + I("-i", "Include only files matching the given pattern") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { String pattern = getFilePatternArg(iter, helper); @@ -109,22 +109,6 @@ public enum Option { helper.include(pattern); } }, - XF("-xf", "Exclude a given file") { - @Override - protected void processMatching(ArgumentIterator iter, OptionHelper helper) { - String pattern = getFilePatternArg(iter, helper); - if (pattern != null) - helper.excludeFile(pattern); - } - }, - IF("-if", "Include only the given file") { - @Override - protected void processMatching(ArgumentIterator iter, OptionHelper helper) { - String pattern = getFilePatternArg(iter, helper); - if (pattern != null) - helper.includeFile(pattern); - } - }, TR("-tr", "Translate resources") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { @@ -338,7 +322,7 @@ public enum Option { String getFilePatternArg(ArgumentIterator iter, OptionHelper helper) { if (!iter.hasNext()) { - helper.reportError(arg + " must be followed by a file or directory pattern."); + helper.reportError(arg + " must be followed by a glob pattern."); return null; } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/OptionHelper.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/OptionHelper.java index 7f3304a4008..709bf835a5b 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/OptionHelper.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/OptionHelper.java @@ -53,12 +53,6 @@ public abstract class OptionHelper { /** Record a package inclusion pattern */ public abstract void include(String incl); - /** Record a file exclusion */ - public abstract void excludeFile(String exclFile); - - /** Record a file inclusion */ - public abstract void includeFile(String inclFile); - /** Record a root of sources to be compiled */ public abstract void sourceRoots(List path); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java index 6b4fbf7ef98..61d1ec13545 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java @@ -220,8 +220,6 @@ public class Options { for (SourceLocation sl : locs) { for (String pkg : sl.includes) addArg(Option.I, pkg); for (String pkg : sl.excludes) addArg(Option.X, pkg); - for (String f : sl.excludedFiles) addArg(Option.XF, f); - for (String f : sl.includedFiles) addArg(Option.IF, f); addArg(opt, sl.getPath()); } } @@ -379,18 +377,6 @@ public class Options { includes.add(inclPattern); } - @Override - public void excludeFile(String exclFilePattern) { - exclFilePattern = Util.normalizeDriveLetter(exclFilePattern); - excludeFiles.add(exclFilePattern); - } - - @Override - public void includeFile(String inclFilePattern) { - inclFilePattern = Util.normalizeDriveLetter(inclFilePattern); - includeFiles.add(inclFilePattern); - } - @Override public void addTransformer(String suffix, Transformer tr) { if (trRules.containsKey(suffix)) { @@ -519,9 +505,7 @@ public class Options { result.add(new SourceLocation( path, includes, - excludes, - includeFiles, - excludeFiles)); + excludes)); } resetFilters(); return result; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/SourceLocation.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/SourceLocation.java index ecc5b96c8c6..2b6b12c27f5 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/SourceLocation.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/SourceLocation.java @@ -25,11 +25,13 @@ package com.sun.tools.sjavac.options; +import java.io.IOException; import java.nio.file.Path; import java.util.List; import java.util.Map; import java.util.Set; +import com.sun.tools.sjavac.Log; import com.sun.tools.sjavac.Module; import com.sun.tools.sjavac.ProblemException; import com.sun.tools.sjavac.Source; @@ -49,18 +51,14 @@ public class SourceLocation { private Path path; // Package include / exclude patterns and file includes / excludes. - List includes, excludes, includedFiles, excludedFiles; + List includes, excludes; public SourceLocation(Path path, List includes, - List excludes, - List includedFiles, - List excludedFiles) { + List excludes) { this.path = path; this.includes = includes; this.excludes = excludes; - this.includedFiles = includedFiles; - this.excludedFiles = excludedFiles; } @@ -81,17 +79,23 @@ public class SourceLocation { Map foundModules, Module currentModule, boolean permitSourcesInDefaultPackage, - boolean inLinksrc) { + boolean inLinksrc) + throws IOException { try { - Source.scanRoot(path.toFile(), suffixes, excludes, includes, - excludedFiles, includedFiles, foundFiles, foundModules, - currentModule, permitSourcesInDefaultPackage, false, - inLinksrc); + Source.scanRoot(path.toFile(), + suffixes, + excludes, + includes, + foundFiles, + foundModules, + currentModule, + permitSourcesInDefaultPackage, + false, + inLinksrc); } catch (ProblemException e) { e.printStackTrace(); } } - /** Get the root directory of this source location */ public Path getPath() { return path; @@ -107,14 +111,9 @@ public class SourceLocation { return excludes; } - /** Get the file include patterns */ - public List getIncludedFiles() { - return includedFiles; + @Override + public String toString() { + return String.format("%s[\"%s\", includes: %s, excludes: %s]", + getClass().getSimpleName(), path, includes, excludes); } - - /** Get the file exclude patterns */ - public List getExcludedFiles() { - return excludedFiles; - } - } diff --git a/langtools/test/tools/sjavac/CompileExcludingDependency.java b/langtools/test/tools/sjavac/CompileExcludingDependency.java index 24174f1bfb3..cd650a83310 100644 --- a/langtools/test/tools/sjavac/CompileExcludingDependency.java +++ b/langtools/test/tools/sjavac/CompileExcludingDependency.java @@ -55,9 +55,9 @@ public class CompileExcludingDependency extends SJavacTester { tb.writeFile(GENSRC.resolve("beta/B.java"), "package beta; public class B { }"); - compile("-x", "beta", + compile("-x", "beta/*", "-src", GENSRC.toString(), - "-x", "alfa/omega", + "-x", "alfa/omega/*", "-sourcepath", GENSRC.toString(), "-d", BIN.toString(), "--state-dir=" + BIN, diff --git a/langtools/test/tools/sjavac/CompileWithAtFile.java b/langtools/test/tools/sjavac/CompileWithAtFile.java index 1107595cec8..580f8ae4aa8 100644 --- a/langtools/test/tools/sjavac/CompileWithAtFile.java +++ b/langtools/test/tools/sjavac/CompileWithAtFile.java @@ -47,8 +47,8 @@ public class CompileWithAtFile extends SJavacTester { void test() throws Exception { tb.writeFile(GENSRC.resolve("list.txt"), - "-if */alfa/omega/A.java\n" + - "-if */beta/B.java\n" + + "-i alfa/omega/A.java\n" + + "-i beta/B.java\n" + GENSRC + "\n" + "-d " + BIN + "\n" + "--state-dir=" + BIN + "\n"); diff --git a/langtools/test/tools/sjavac/CompileWithInvisibleSources.java b/langtools/test/tools/sjavac/CompileWithInvisibleSources.java index 099b518217d..d39b4427988 100644 --- a/langtools/test/tools/sjavac/CompileWithInvisibleSources.java +++ b/langtools/test/tools/sjavac/CompileWithInvisibleSources.java @@ -64,7 +64,7 @@ public class CompileWithInvisibleSources extends SJavacTester { "package beta; public class B { }"); compile(GENSRC.toString(), - "-x", "beta", + "-x", "beta/*", "-sourcepath", GENSRC2.toString(), "-sourcepath", GENSRC3.toString(), "-d", BIN.toString(), diff --git a/langtools/test/tools/sjavac/CompileWithOverrideSources.java b/langtools/test/tools/sjavac/CompileWithOverrideSources.java index a010177e634..b3bc9a5d8bb 100644 --- a/langtools/test/tools/sjavac/CompileWithOverrideSources.java +++ b/langtools/test/tools/sjavac/CompileWithOverrideSources.java @@ -62,7 +62,7 @@ public class CompileWithOverrideSources extends SJavacTester { tb.writeFile(GENSRC2.resolve("beta/B.java"), "package beta; public class B { }"); - compile("-x", "beta", + compile("-x", "beta/*", GENSRC.toString(), GENSRC2.toString(), "-d", BIN.toString(), diff --git a/langtools/test/tools/sjavac/ExclPattern.java b/langtools/test/tools/sjavac/ExclPattern.java deleted file mode 100644 index cd98da56082..00000000000 --- a/langtools/test/tools/sjavac/ExclPattern.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2014, 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 8037085 - * @summary Ensures that sjavac can handle various exclusion patterns. - * - * @modules jdk.compiler/com.sun.tools.sjavac - * @build Wrapper - * @run main Wrapper ExclPattern - */ - -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -public class ExclPattern { - - public static void main(String[] ignore) throws IOException { - - String toBeExcluded = "pkg/excl-dir/excluded.txt"; - String toBeIncluded = "pkg/incl-dir/included.txt"; - - // Set up source directory with directory to be excluded - populate(Paths.get("srcdir"), - "pkg/SomeClass.java", - "package pkg; public class SomeClass { }", - - toBeExcluded, - "This file should not end up in the dest directory.", - - toBeIncluded, - "This file should end up in the dest directory."); - - String[] args = { - "-x", "pkg/excl-dir/*", - "-src", "srcdir", - "-d", "dest", - "--state-dir=dest", - "-j", "1", - "-copy", ".txt", - "--server:portfile=testserver,background=false", - "--log=debug" - }; - - int rc = com.sun.tools.sjavac.Main.go(args); - if (rc != 0) throw new RuntimeException("Error during compile!"); - - if (!Files.exists(Paths.get("dest/" + toBeIncluded))) - throw new AssertionError("File missing: " + toBeIncluded); - - if (Files.exists(Paths.get("dest/" + toBeExcluded))) - throw new AssertionError("File present: " + toBeExcluded); - } - - static void populate(Path root, String... args) throws IOException { - if (!Files.exists(root)) - Files.createDirectory(root); - for (int i = 0; i < args.length; i += 2) { - String filename = args[i]; - String content = args[i+1]; - Path p = root.resolve(filename); - Files.createDirectories(p.getParent()); - try (PrintWriter out = new PrintWriter(Files.newBufferedWriter(p, - Charset.defaultCharset()))) { - out.println(content); - } - } - } -} diff --git a/langtools/test/tools/sjavac/HiddenFiles.java b/langtools/test/tools/sjavac/HiddenFiles.java new file mode 100644 index 00000000000..32eead0de58 --- /dev/null +++ b/langtools/test/tools/sjavac/HiddenFiles.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8144226 + * @summary Ensures that excluded files are inaccessible (even for implicit + * compilation) + * + * @modules jdk.compiler/com.sun.tools.sjavac + * @library /tools/lib + * @build Wrapper ToolBox + * @run main Wrapper HiddenFiles + */ + +import com.sun.tools.javac.util.Assert; +import com.sun.tools.sjavac.server.Sjavac; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class HiddenFiles extends SjavacBase { + + public static void main(String[] ignore) throws Exception { + Path BIN = Paths.get("bin"); + Path STATE_DIR = Paths.get("state-dir"); + Path SRC = Paths.get("src"); + + Files.createDirectories(BIN); + Files.createDirectories(STATE_DIR); + + toolbox.writeJavaFiles(SRC, "package pkg; class A { B b; }"); + toolbox.writeJavaFiles(SRC, "package pkg; class B { }"); + + // This compilation should fail (return RC_FATAL) since A.java refers to B.java and B.java + // is excluded. + int rc = compile("-x", "pkg/B.java", SRC.toString(), + "--server:portfile=testportfile,background=false", + "-d", BIN.toString(), + "--state-dir=" + STATE_DIR); + + Assert.check(rc == Sjavac.RC_FATAL, "Compilation succeeded unexpectedly."); + } +} diff --git a/langtools/test/tools/sjavac/IncludeExcludePatterns.java b/langtools/test/tools/sjavac/IncludeExcludePatterns.java new file mode 100644 index 00000000000..50d88fb85b0 --- /dev/null +++ b/langtools/test/tools/sjavac/IncludeExcludePatterns.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2014, 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 8037085 + * @summary Ensures that sjavac can handle various exclusion patterns. + * + * @modules jdk.compiler/com.sun.tools.sjavac + * @library /tools/lib + * @build Wrapper ToolBox + * @run main Wrapper IncludeExcludePatterns + */ + +import com.sun.tools.javac.util.Assert; +import com.sun.tools.sjavac.server.Sjavac; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class IncludeExcludePatterns extends SjavacBase { + + final Path SRC = Paths.get("src"); + final Path BIN = Paths.get("bin"); + final Path STATE_DIR = Paths.get("state-dir"); + + // An arbitrarily but sufficiently complicated source tree. + final Path A = Paths.get("pkga/A.java"); + final Path X1 = Paths.get("pkga/subpkg/Xx.java"); + final Path Y = Paths.get("pkga/subpkg/subsubpkg/Y.java"); + final Path B = Paths.get("pkgb/B.java"); + final Path C = Paths.get("pkgc/C.java"); + final Path X2 = Paths.get("pkgc/Xx.java"); + + final Path[] ALL_PATHS = {A, X1, Y, B, C, X2}; + + public static void main(String[] ignore) throws Exception { + new IncludeExcludePatterns().runTest(); + } + + public void runTest() throws IOException, ReflectiveOperationException { + Files.createDirectories(BIN); + Files.createDirectories(STATE_DIR); + for (Path p : ALL_PATHS) { + writeDummyClass(p); + } + + // Single file + testPattern("pkga/A.java", A); + + // Leading wild cards + testPattern("*/A.java", A); + testPattern("**/Xx.java", X1, X2); + testPattern("**x.java", X1, X2); + + // Wild card in middle of path + testPattern("pkga/*/Xx.java", X1); + testPattern("pkga/**/Y.java", Y); + + // Trailing wild cards + testPattern("pkga/*", A); + testPattern("pkga/**", A, X1, Y); + + // Multiple wildcards + testPattern("pkga/*/*/Y.java", Y); + testPattern("**/*/**", X1, Y); + + } + + // Given "src/pkg/subpkg/A.java" this method returns "A" + String classNameOf(Path javaFile) { + return javaFile.getFileName() + .toString() + .replace(".java", ""); + } + + // Puts an empty (dummy) class definition in the given path. + void writeDummyClass(Path javaFile) throws IOException { + String pkg = javaFile.getParent().toString().replace('/', '.'); + String cls = javaFile.getFileName().toString().replace(".java", ""); + toolbox.writeFile(SRC.resolve(javaFile), "package " + pkg + "; class " + cls + " {}"); + } + + void testPattern(String filterArgs, Path... sourcesExpectedToBeVisible) + throws ReflectiveOperationException, IOException { + testFilter("-i " + filterArgs, Arrays.asList(sourcesExpectedToBeVisible)); + + Set complement = new HashSet<>(Arrays.asList(ALL_PATHS)); + complement.removeAll(Arrays.asList(sourcesExpectedToBeVisible)); + testFilter("-x " + filterArgs, complement); + } + + void testFilter(String filterArgs, Collection sourcesExpectedToBeVisible) + throws IOException, ReflectiveOperationException { + System.out.println("Testing filter: " + filterArgs); + toolbox.cleanDirectory(BIN); + toolbox.cleanDirectory(STATE_DIR); + String args = filterArgs + " " + SRC + + " --server:portfile=testportfile,background=false" + + " -d " + BIN + + " --state-dir=" + STATE_DIR; + int rc = compile((Object[]) args.split(" ")); + + // Compilation should always pass in these tests + Assert.check(rc == Sjavac.RC_OK, "Compilation failed unexpectedly."); + + // The resulting .class files should correspond to the visible source files + Set result = allFilesInDir(BIN); + Set expected = correspondingClassFiles(sourcesExpectedToBeVisible); + if (!result.equals(expected)) { + System.out.println("Result:"); + printPaths(result); + System.out.println("Expected:"); + printPaths(expected); + Assert.error("Test case failed: " + filterArgs); + } + } + + void printPaths(Collection paths) { + paths.stream() + .sorted() + .forEachOrdered(p -> System.out.println(" " + p)); + } + + // Given "pkg/A.java, pkg/B.java" this method returns "bin/pkg/A.class, bin/pkg/B.class" + Set correspondingClassFiles(Collection javaFiles) { + return javaFiles.stream() + .map(javaFile -> javaFile.resolveSibling(classNameOf(javaFile) + ".class")) + .map(BIN::resolve) + .collect(Collectors.toSet()); + } + + Set allFilesInDir(Path p) throws IOException { + try (Stream files = Files.walk(p).filter(Files::isRegularFile)) { + return files.collect(Collectors.toSet()); + } + } +} diff --git a/langtools/test/tools/sjavac/OptionDecoding.java b/langtools/test/tools/sjavac/OptionDecoding.java index 2ba5167b1fc..423b56b32ea 100644 --- a/langtools/test/tools/sjavac/OptionDecoding.java +++ b/langtools/test/tools/sjavac/OptionDecoding.java @@ -61,7 +61,6 @@ public class OptionDecoding { public static void main(String[] args) throws IOException { testPaths(); testDupPaths(); - testSourceLocations(); testSimpleOptions(); testServerConf(); testSearchPaths(); @@ -110,78 +109,6 @@ public class OptionDecoding { } } - // Test source locations and -x, -i, -xf, -if filters - static void testSourceLocations() throws IOException { - Path a1 = Paths.get("root/pkg1/ClassA1.java"); - Path a2 = Paths.get("root/pkg1/ClassA2.java"); - Path b1 = Paths.get("root/pkg1/pkg2/ClassB1.java"); - Path b2 = Paths.get("root/pkg1/pkg2/ClassB2.java"); - Path c1 = Paths.get("root/pkg3/ClassC1.java"); - Path c2 = Paths.get("root/pkg3/ClassC2.java"); - - for (Path p : Arrays.asList(a1, a2, b1, b2, c1, c2)) { - Files.createDirectories(p.getParent()); - Files.createFile(p); - } - - // Test -if - { - Options options = Options.parseArgs("-if", "root/pkg1/ClassA1.java", "root"); - - Map foundFiles = new HashMap<>(); - SjavacImpl.findSourceFiles(options.getSources(), Collections.singleton(".java"), foundFiles, - new HashMap(), new Module("", ""), false, true); - - checkFilesFound(foundFiles.keySet(), a1); - } - - // Test -i - System.out.println("--------------------------- CHECKING -i ----------------"); - { - Options options = Options.parseArgs("-i", "pkg1/*", "root"); - - Map foundFiles = new HashMap<>(); - SjavacImpl.findSourceFiles(options.getSources(), Collections.singleton(".java"), foundFiles, - new HashMap(), new Module("", ""), false, true); - - checkFilesFound(foundFiles.keySet(), a1, a2, b1, b2); - } - System.out.println("--------------------------------------------------------"); - - // Test -xf - { - Options options = Options.parseArgs("-xf", "root/pkg1/ClassA1.java", "root"); - - Map foundFiles = new HashMap<>(); - SjavacImpl.findSourceFiles(options.getSources(), Collections.singleton(".java"), foundFiles, - new HashMap(), new Module("", ""), false, true); - - checkFilesFound(foundFiles.keySet(), a2, b1, b2, c1, c2); - } - - // Test -x - { - Options options = Options.parseArgs("-i", "pkg1/*", "root"); - - Map foundFiles = new HashMap<>(); - SjavacImpl.findSourceFiles(options.getSources(), Collections.singleton(".java"), foundFiles, - new HashMap(), new Module("", ""), false, true); - - checkFilesFound(foundFiles.keySet(), a1, a2, b1, b2); - } - - // Test -x and -i - { - Options options = Options.parseArgs("-i", "pkg1/*", "-x", "pkg1/pkg2/*", "root"); - - Map foundFiles = new HashMap<>(); - SjavacImpl.findSourceFiles(options.getSources(), Collections.singleton(".java"), foundFiles, - new HashMap(), new Module("", ""), false, true); - - checkFilesFound(foundFiles.keySet(), a1, a2); - } - } - // Test basic options static void testSimpleOptions() { Options options = Options.parseArgs("-j", "17", "--log=debug"); @@ -216,8 +143,8 @@ public class OptionDecoding { List i, x, iF, xF; i = x = iF = xF = new ArrayList<>(); - SourceLocation dir1 = new SourceLocation(Paths.get("dir1"), i, x, iF, xF); - SourceLocation dir2 = new SourceLocation(Paths.get("dir2"), i, x, iF, xF); + SourceLocation dir1 = new SourceLocation(Paths.get("dir1"), i, x); + SourceLocation dir2 = new SourceLocation(Paths.get("dir2"), i, x); String dir1_PS_dir2 = "dir1" + File.pathSeparator + "dir2"; Options options = Options.parseArgs("-sourcepath", dir1_PS_dir2); diff --git a/langtools/test/tools/sjavac/Serialization.java b/langtools/test/tools/sjavac/Serialization.java index d8363622ea1..58d0cefd135 100644 --- a/langtools/test/tools/sjavac/Serialization.java +++ b/langtools/test/tools/sjavac/Serialization.java @@ -58,8 +58,6 @@ public class Serialization { Option.D.arg, "dest", Option.I.arg, "pkg/*", Option.X.arg, "pkg/pkg/*", - Option.IF.arg, "root/pkg/MyClass1.java", - Option.XF.arg, "root/pkg/MyClass2.java", Option.SRC.arg, "root", Option.SOURCEPATH.arg, "sourcepath", Option.CLASSPATH.arg, "classpath", @@ -87,8 +85,6 @@ public class Serialization { assertEquals(sl1.getPath(), sl2.getPath()); assertEquals(sl1.getIncludes(), sl2.getIncludes()); assertEquals(sl1.getExcludes(), sl2.getExcludes()); - assertEquals(sl1.getIncludedFiles(), sl2.getIncludedFiles()); - assertEquals(sl1.getExcludedFiles(), sl2.getExcludedFiles()); assertEquals(options1.getClassSearchPath(), options2.getClassSearchPath()); assertEquals(options1.getSourceSearchPaths(), options2.getSourceSearchPaths()); diff --git a/langtools/test/tools/sjavac/util/OptionTestUtil.java b/langtools/test/tools/sjavac/util/OptionTestUtil.java index 54581005432..f751d6d4ad8 100644 --- a/langtools/test/tools/sjavac/util/OptionTestUtil.java +++ b/langtools/test/tools/sjavac/util/OptionTestUtil.java @@ -62,9 +62,7 @@ public class OptionTestUtil { if (!sl1.getPath().equals(sl2.getPath()) || !sl1.getIncludes().equals(sl2.getIncludes()) || - !sl1.getExcludes().equals(sl2.getExcludes()) || - !sl1.getIncludedFiles().equals(sl2.getIncludedFiles()) || - !sl1.getExcludedFiles().equals(sl2.getExcludedFiles())) + !sl1.getExcludes().equals(sl2.getExcludes())) throw new AssertionError("Expected " + sl1 + " but got " + sl2); } } From a4d59b2815adcf23dc925de79a05cad6453055b3 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Fri, 8 Jan 2016 10:51:34 -0800 Subject: [PATCH 042/109] 8144967: javax.xml.transform.Source and org.xml.sax.InputSource can be empty Reviewed-by: darcy, rriggs --- .../classes/javax/xml/transform/Source.java | 15 +- .../javax/xml/transform/dom/DOMSource.java | 21 +- .../javax/xml/transform/sax/SAXSource.java | 22 +- .../javax/xml/transform/stax/StAXSource.java | 16 +- .../xml/transform/stream/StreamSource.java | 59 ++++- .../classes/org/xml/sax/InputSource.java | 52 ++++- .../xml/jaxp/unittest/common/Sources.java | 202 ++++++++++++++++++ 7 files changed, 381 insertions(+), 6 deletions(-) create mode 100644 jaxp/test/javax/xml/jaxp/unittest/common/Sources.java diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/Source.java b/jaxp/src/java.xml/share/classes/javax/xml/transform/Source.java index fe3d7111439..a9b75f2c42f 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/transform/Source.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/Source.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,4 +52,17 @@ public interface Source { * if setSystemId was not called. */ public String getSystemId(); + + /** + * Indicates whether the {@code Source} object is empty. Empty means + * that there is no input available from this Source. + * + * @implSpec The default implementation of this method throws + * {@link UnsupportedOperationException}. + * + * @return true if the {@code Source} object is empty, false otherwise + */ + default boolean isEmpty() { + throw new UnsupportedOperationException("The isEmpty method is not supported."); + } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/dom/DOMSource.java b/jaxp/src/java.xml/share/classes/javax/xml/transform/dom/DOMSource.java index dc4e93e07f1..b977c14f035 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/transform/dom/DOMSource.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/dom/DOMSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,6 +122,7 @@ public class DOMSource implements Source { * * @param systemID Base URL for this DOM tree. */ + @Override public void setSystemId(String systemID) { this.systemID = systemID; } @@ -132,7 +133,25 @@ public class DOMSource implements Source { * * @return Base URL for this DOM tree. */ + @Override public String getSystemId() { return this.systemID; } + + /** + * Indicates whether the {@code DOMSource} object is empty. Empty is + * defined as follows: + *
    + *
  • if the system identifier and node are {@code null}; + *
  • + *
  • if the system identifier is null, and the {@code node} has no child nodes. + *
  • + *
+ * + * @return true if the {@code DOMSource} object is empty, false otherwise + */ + @Override + public boolean isEmpty() { + return systemID == null && (node == null || !node.hasChildNodes()); + } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/sax/SAXSource.java b/jaxp/src/java.xml/share/classes/javax/xml/transform/sax/SAXSource.java index 0d573780e56..1829042e899 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/transform/sax/SAXSource.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/sax/SAXSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -147,6 +147,7 @@ public class SAXSource implements Source { * * @param systemId The system identifier as a URI string. */ + @Override public void setSystemId(String systemId) { if (null == inputSource) { @@ -162,6 +163,7 @@ public class SAXSource implements Source { * * @return Base URL for the Source, or null. */ + @Override public String getSystemId() { if (inputSource == null) { @@ -207,4 +209,22 @@ public class SAXSource implements Source { return null; } } + + /** + * Indicates whether the {@code SAXSource} object is empty. Empty is + * defined as follows: + *
    + *
  • if the system identifier and {@code InputSource} are {@code null}; + *
  • + *
  • if the system identifier is {@code null}, and the {@code InputSource} + * is empty. + *
  • + *
+ * + * @return true if the {@code SAXSource} object is empty, false otherwise + */ + @Override + public boolean isEmpty() { + return getSystemId() == null && (inputSource == null || inputSource.isEmpty()); + } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/StAXSource.java b/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/StAXSource.java index dd04b63fb69..43e17c6e14e 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/StAXSource.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/stax/StAXSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -209,6 +209,7 @@ public class StAXSource implements Source { * @throws UnsupportedOperationException Is always * thrown by this method. */ + @Override public void setSystemId(final String systemId) { throw new UnsupportedOperationException( @@ -229,8 +230,21 @@ public class StAXSource implements Source { * * @return System identifier used by this StAXSource. */ + @Override public String getSystemId() { return systemId; } + + /** + * Indicates whether the {@code StAXSource} object is empty. Since a + * {@code StAXSource} object can never be empty, this method always returns + * false. + * + * @return unconditionally false + */ + @Override + public boolean isEmpty() { + return false; + } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/stream/StreamSource.java b/jaxp/src/java.xml/share/classes/javax/xml/transform/stream/StreamSource.java index 7627d5e3b55..a708db3017d 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/transform/stream/StreamSource.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/stream/StreamSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,10 @@ package javax.xml.transform.stream; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.io.Reader; +import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -233,6 +235,7 @@ public class StreamSource implements Source { * * @param systemId The system identifier as a URL string. */ + @Override public void setSystemId(String systemId) { this.systemId = systemId; } @@ -243,6 +246,7 @@ public class StreamSource implements Source { * @return The system identifier that was set with setSystemId, or null * if setSystemId was not called. */ + @Override public String getSystemId() { return systemId; } @@ -259,6 +263,59 @@ public class StreamSource implements Source { this.systemId = f.toURI().toASCIIString(); } + /** + * Indicates whether the {@code StreamSource} object is empty. Empty is + * defined as follows: + *
    + *
  • All of the input sources, including the public identifier, system + * identifier, byte stream, and character stream, are {@code null}. + *
  • + *
  • The public identifier and system identifier are {@code null}, and + * byte and character stream are either {@code null} or contain no byte or + * character. + *

    + * Note that this method will reset the byte stream if it is provided, or + * the character stream if the byte stream is not provided. + *

  • + *
+ *

+ * In case of error while checking the byte or character stream, the method + * will return false to allow the XML processor to handle the error. + * + * @return true if the {@code StreamSource} object is empty, false otherwise + */ + @Override + public boolean isEmpty() { + return (publicId == null && systemId == null && isStreamEmpty()); + } + + private boolean isStreamEmpty() { + boolean empty = true; + try { + if (inputStream != null) { + inputStream.reset(); + int bytesRead = inputStream.available(); + if (bytesRead > 0) { + return false; + } + } + + if (reader != null) { + reader.reset(); + int c = reader.read(); + reader.reset(); + if (c != -1) { + return false; + } + } + } catch (IOException ex) { + //in case of error, return false + return false; + } + + return empty; + } + ////////////////////////////////////////////////////////////////////// // Internal state. ////////////////////////////////////////////////////////////////////// diff --git a/jaxp/src/java.xml/share/classes/org/xml/sax/InputSource.java b/jaxp/src/java.xml/share/classes/org/xml/sax/InputSource.java index 9498da395c7..f05d23f5108 100644 --- a/jaxp/src/java.xml/share/classes/org/xml/sax/InputSource.java +++ b/jaxp/src/java.xml/share/classes/org/xml/sax/InputSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ package org.xml.sax; +import java.io.IOException; import java.io.Reader; import java.io.InputStream; @@ -343,8 +344,57 @@ public class InputSource { return characterStream; } + /** + * Indicates whether the {@code InputSource} object is empty. Empty is + * defined as follows: + *

    + *
  • All of the input sources, including the public identifier, system + * identifier, byte stream, and character stream, are {@code null}. + *
  • + *
  • The public identifier and system identifier are {@code null}, and + * byte and character stream are either {@code null} or contain no byte + * or character. + *

    + * Note that this method will reset the byte stream if it is provided, or + * the character stream if the byte stream is not provided. + *

  • + *
+ *

+ * In case of error while checking the byte or character stream, the method + * will return false to allow the XML processor to handle the error. + * + * @return true if the {@code InputSource} object is empty, false otherwise + */ + public boolean isEmpty() { + return (publicId == null && systemId == null && isStreamEmpty()); + } + private boolean isStreamEmpty() { + boolean empty = true; + try { + if (byteStream != null) { + byteStream.reset(); + int bytesRead = byteStream.available(); + if (bytesRead > 0) { + return false; + } + } + if (characterStream != null) { + characterStream.reset(); + int c = characterStream.read(); + characterStream.reset(); + if (c != -1) { + return false; + } + } + } catch (IOException ex) { + //in case of error, return false + return false; + } + + return empty; + } //////////////////////////////////////////////////////////////////// // Internal state. //////////////////////////////////////////////////////////////////// diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java b/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java new file mode 100644 index 00000000000..f3deba62395 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package common; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.StringReader; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stax.StAXSource; +import javax.xml.transform.stream.StreamSource; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +/* + * @bug 8144967 + * @summary Tests related to the javax.xml.transform.Source + * and org.xml.sax.InputSource + */ +public class Sources { + + /** + * @bug 8144967 + * Tests whether a Source object is empty + * @param source the Source object + */ + @Test(dataProvider = "emptySources") + public void testIsEmpty(Source source) { + Assert.assertTrue(source.isEmpty(), "The source is not empty"); + } + + /** + * @bug 8144967 + * Tests that the source is not empty + * @param source the Source object + */ + @Test(dataProvider = "nonEmptySources") + public void testIsNotEmpty(Source source) { + Assert.assertTrue(!source.isEmpty(), "The source is empty"); + } + + /** + * @bug 8144967 + * Tests whether an InputSource object is empty + * @param source the InputSource object + */ + @Test(dataProvider = "emptyInputSource") + public void testISIsEmpty(InputSource source) { + Assert.assertTrue(source.isEmpty(), "The source is not empty"); + } + + /* + * DataProvider: sources that are empty + */ + @DataProvider(name = "emptySources") + Object[][] getSources() throws URISyntaxException { + + return new Object[][]{ + {new DOMSource()}, + {new DOMSource(getDocument())}, + {new SAXSource()}, + {new SAXSource(new InputSource(new StringReader("")))}, + {new SAXSource(getXMLReader(), new InputSource(new StringReader("")))}, + {new StreamSource()}, + {new StreamSource(new ByteArrayInputStream("".getBytes()))}, + {new StreamSource(new StringReader(""))}, + {new StreamSource(new StringReader(""), null)}, + {new StreamSource((String) null)} + }; + } + + /* + * DataProvider: sources that are not empty + */ + @DataProvider(name = "nonEmptySources") + Object[][] getSourcesEx() throws URISyntaxException { + StAXSource ss = null; + try { + ss = new StAXSource(getXMLEventReader()); + } catch (XMLStreamException ex) {} + + return new Object[][]{ + //This will set a non-null systemId on the resulting StreamSource + {new StreamSource(new File(""))}, + //Can't tell because XMLStreamReader is a pull parser, cursor advancement + //would have been required in order to examine the reader. + {new StAXSource(getXMLStreamReader())}, + {ss} + }; + } + + /* + * DataProvider: sources that are empty + */ + @DataProvider(name = "emptyInputSource") + Object[][] getInputSources() throws URISyntaxException { + byte[] utf8Bytes = null; + try { + utf8Bytes = "".getBytes("UTF8"); + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex.getMessage()); + } + return new Object[][]{ + {new InputSource()}, + {new InputSource(new ByteArrayInputStream(utf8Bytes))}, + {new InputSource(new StringReader(""))}, + {new InputSource((String) null)} + }; + } + + /** + * Returns an instance of Document. + * + * @return an instance of Document. + */ + private Document getDocument() { + Document doc = null; + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + doc = dbf.newDocumentBuilder().newDocument(); + } catch (ParserConfigurationException ex) {} + return doc; + } + + /** + * Returns an instance of XMLReader. + * + * @return an instance of XMLReader. + */ + private XMLReader getXMLReader() { + XMLReader reader = null; + try { + reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); + } catch (ParserConfigurationException | SAXException ex) {} + return reader; + } + + /** + * Returns an instance of XMLStreamReader. + * + * @return an instance of XMLStreamReader. + */ + private XMLStreamReader getXMLStreamReader() { + XMLStreamReader r = null; + try { + XMLInputFactory xif = XMLInputFactory.newInstance(); + r = xif.createXMLStreamReader(new ByteArrayInputStream("".getBytes())); + } catch (XMLStreamException ex) {} + + return r; + } + + /** + * Returns an instance of XMLEventReader. + * + * @return an instance of XMLEventReader. + */ + private XMLEventReader getXMLEventReader() { + XMLEventReader r = null; + try { + r = XMLInputFactory.newInstance().createXMLEventReader( + new ByteArrayInputStream("".getBytes())); + } catch (XMLStreamException ex) {} + + return r; + } +} From 879e0ab0aae5af0a0c580c0353c404455d7a0244 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 8 Jan 2016 12:29:02 -0700 Subject: [PATCH 043/109] 8037789: Surprising more-specific results for lambda bodies with no return expressions Reviewed-by: mcimadamore, vromero --- .../com/sun/tools/javac/comp/Resolve.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java index 557b921e20f..ffa14d75e00 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -1219,18 +1219,21 @@ public class Resolve { result &= true; } else if (ret_t.hasTag(VOID)) { result &= false; - } else if (unrelatedFunctionalInterfaces(ret_t, ret_s)) { - for (JCExpression expr : lambdaResults(tree)) { - result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr); - } - } else if (ret_t.isPrimitive() != ret_s.isPrimitive()) { - for (JCExpression expr : lambdaResults(tree)) { - boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); - result &= (retValIsPrimitive == ret_t.isPrimitive()) && - (retValIsPrimitive != ret_s.isPrimitive()); - } } else { - result &= compatibleBySubtyping(ret_t, ret_s); + List lambdaResults = lambdaResults(tree); + if (!lambdaResults.isEmpty() && unrelatedFunctionalInterfaces(ret_t, ret_s)) { + for (JCExpression expr : lambdaResults) { + result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr); + } + } else if (!lambdaResults.isEmpty() && ret_t.isPrimitive() != ret_s.isPrimitive()) { + for (JCExpression expr : lambdaResults) { + boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); + result &= (retValIsPrimitive == ret_t.isPrimitive()) && + (retValIsPrimitive != ret_s.isPrimitive()); + } + } else { + result &= compatibleBySubtyping(ret_t, ret_s); + } } } } From 760776aebe44fe6bf083a145b722f3446361d933 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 8 Jan 2016 14:24:51 -0800 Subject: [PATCH 044/109] 8146719: javac test BootClassPathPrepend.java should be deleted Reviewed-by: jjg --- .../javac/file/BootClassPathPrepend.java | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 langtools/test/tools/javac/file/BootClassPathPrepend.java diff --git a/langtools/test/tools/javac/file/BootClassPathPrepend.java b/langtools/test/tools/javac/file/BootClassPathPrepend.java deleted file mode 100644 index 9bd38b61715..00000000000 --- a/langtools/test/tools/javac/file/BootClassPathPrepend.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014, 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 8067445 - * @summary Verify that file.Locations analyze sun.boot.class.path for BCP prepends/appends - * @library /tools/lib - * @modules jdk.compiler/com.sun.tools.javac.api - * jdk.compiler/com.sun.tools.javac.file - * jdk.compiler/com.sun.tools.javac.main - */ - -import java.io.IOException; -import java.util.EnumSet; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.JavaFileObject.Kind; -import javax.tools.StandardLocation; -import javax.tools.ToolProvider; - -public class BootClassPathPrepend { - public static void main(String... args) throws IOException { - if (args.length == 0) { - new BootClassPathPrepend().reRun(); - } else { - new BootClassPathPrepend().run(); - } - } - - void reRun() { - String testClasses = System.getProperty("test.classes"); - ToolBox tb = new ToolBox(); - tb.new JavaTask().vmOptions("-Xbootclasspath/p:" + testClasses) - .classArgs("real-run") - .className("BootClassPathPrepend") - .run() - .writeAll(); - } - - EnumSet classKind = EnumSet.of(JavaFileObject.Kind.CLASS); - - void run() throws IOException { - JavaCompiler toolProvider = ToolProvider.getSystemJavaCompiler(); - try (JavaFileManager fm = toolProvider.getStandardFileManager(null, null, null)) { - Iterable files = - fm.list(StandardLocation.PLATFORM_CLASS_PATH, "", classKind, false); - for (JavaFileObject fo : files) { - if (fo.isNameCompatible("BootClassPathPrepend", JavaFileObject.Kind.CLASS)) { - System.err.println("Found BootClassPathPrepend on bootclasspath"); - return ;//found - } - } - - throw new AssertionError("Cannot find class that was prepended on BCP"); - } - } -} From c2eb8c18a2d60f6a858c92369663c4769e947997 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 8 Jan 2016 15:15:21 -0800 Subject: [PATCH 045/109] 8146722: javac remove test T6430241.java as irrelevant in 9 Reviewed-by: jjg --- langtools/test/tools/javac/api/T6430241.java | 259 ------------------- 1 file changed, 259 deletions(-) delete mode 100644 langtools/test/tools/javac/api/T6430241.java diff --git a/langtools/test/tools/javac/api/T6430241.java b/langtools/test/tools/javac/api/T6430241.java deleted file mode 100644 index c607d8bfee0..00000000000 --- a/langtools/test/tools/javac/api/T6430241.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 2011, 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 6430241 - * @summary Hard to disable symbol file feature through API - * @library /tools/lib - * @modules jdk.compiler/com.sun.tools.javac.api - * jdk.compiler/com.sun.tools.javac.file - * jdk.compiler/com.sun.tools.javac.main - * jdk.compiler/com.sun.tools.javac.util - * @build ToolBox - * @run main T6430241 - */ - -import java.io.*; -import java.util.*; - -import javax.tools.*; - -import com.sun.source.util.JavacTask; -import com.sun.tools.javac.api.JavacTool; -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.util.Context; - -public class T6430241 { - public static void main(String... args) throws Exception { - new T6430241().run(); - } - - void run() throws Exception { - setup(); - testCommandLine(); - testSimpleAPI(); - testTaskAPI(); - - if (errors > 0) - throw new Exception(errors + " errors found"); - } - - void setup() throws Exception { - classesDir = new File("classes"); - classesDir.mkdirs(); - - emptyDir = new File("empty"); - emptyDir.mkdirs(); - - bootClassPath = createJar().getPath(); - - File srcDir = new File("src"); - String test = "import sun.misc.Unsafe; class Test { }"; - testFile = writeFile(srcDir, "Test.java", test); - } - - //----- tests for command line invocation - - void testCommandLine() throws Exception { - testCommandLine(true); - testCommandLine(false, "-Xbootclasspath/p:" + emptyDir); - testCommandLine(false, "-Xbootclasspath:" + bootClassPath); - testCommandLine(false, "-Xbootclasspath/a:" + emptyDir); - testCommandLine(false, "-XDignore.symbol.file"); - System.err.println(); - } - - void testCommandLine(boolean expectWarnings, String... opts) throws Exception { - System.err.println("test command line: " + Arrays.asList(opts)); - - String[] args = initArgs(opts); - - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - int rc = com.sun.tools.javac.Main.compile(args, pw); - String out = showOutput(sw.toString()); - - checkCompilationOK(rc); - checkOutput(out, expectWarnings); - } - - //----- tests for simple API invocation - - void testSimpleAPI() { - testSimpleAPI(true); - testSimpleAPI(false, "-Xbootclasspath/p:" + emptyDir); - testSimpleAPI(false, "-Xbootclasspath:" + bootClassPath); - testSimpleAPI(false, "-Xbootclasspath/a:" + emptyDir); - testSimpleAPI(false, "-XDignore.symbol.file"); - System.err.println(); - } - - void testSimpleAPI(boolean expectWarnings, String... opts) { - System.err.println("test simple API: " + Arrays.asList(opts)); - - String[] args = initArgs(opts); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - - JavacTool tool = JavacTool.create(); - int rc = tool.run(null, null, ps, args); - - String out = showOutput(baos.toString()); - - checkCompilationOK(rc); - checkOutput(out, expectWarnings); - } - - //----- tests for CompilationTask API invocation - - void testTaskAPI() throws Exception { - List bcp = new ArrayList(); - for (String f: bootClassPath.split(File.pathSeparator)) { - if (!f.isEmpty()) - bcp.add(new File(f)); - } - - testTaskAPI(true, null); - testTaskAPI(false, bcp); - System.err.println(); - } - - void testTaskAPI(boolean expectWarnings, Iterable pcp) throws Exception { - System.err.println("test task API: " + pcp); - - JavacTool tool = JavacTool.create(); - try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) { - - if (pcp != null) - fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp); - - Iterable files = fm.getJavaFileObjects(testFile); - - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - JavacTask task = tool.getTask(pw, fm, null, null, null, files); - boolean ok = task.call(); - String out = showOutput(sw.toString()); - - checkCompilationOK(ok); - checkOutput(out, expectWarnings); - } - } - - //----- utility methods - - File createJar() throws IOException { - File f = new File("test.jar"); - try (JavaFileManager fm = new JavacFileManager(new Context(), false, null)) { - ToolBox tb = new ToolBox(); - tb.new JarTask(f.getPath()) - .files(fm, StandardLocation.PLATFORM_CLASS_PATH, "java.lang.*", "sun.misc.*") - .run(); - } - return f; - } - - /** - * Create a file with given content. - */ - File writeFile(File dir, String path, String content) throws IOException { - File f = new File(dir, path); - f.getParentFile().mkdirs(); - FileWriter out = new FileWriter(f); - try { - out.write(content); - } finally { - out.close(); - } - return f; - } - - /** - * Initialize args for compilation with given opts. - * @return opts -d classesDir testFile - */ - String[] initArgs(String[] opts) { - List args = new ArrayList(); - args.addAll(Arrays.asList(opts)); - args.add("-d"); - args.add(classesDir.getPath()); - args.add(testFile.getPath()); - return args.toArray(new String[args.size()]); - } - - /** - * Show output from compilation if non empty. - */ - String showOutput(String out) { - if (!out.isEmpty()) - System.err.println(out); - return out; - } - - /** - * Verify compilation succeeded. - */ - void checkCompilationOK(boolean ok) { - if (!ok) - error("compilation failed"); - } - - /** - * Verify compilation succeeded. - */ - void checkCompilationOK(int rc) { - if (rc != 0) - error("compilation failed, rc: " + rc); - } - - /** - * Check whether output contains warnings if and only if warnings - * are expected. - */ - void checkOutput(String out, boolean expectWarnings) { - boolean foundWarnings = out.contains("warning"); - if (foundWarnings) { - if (!expectWarnings) - error("unexpected warnings found"); - } else { - if (expectWarnings) - error("expected warnings not found"); - } - } - - /** - * Report an error. - */ - void error(String msg) { - System.err.println("error: " + msg); - errors++; - } - - String bootClassPath; - File classesDir; - File emptyDir; - File testFile; - int errors; -} From cbaccb91f05e49f215d840423b4a42680c80de06 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 8 Jan 2016 17:02:29 -0700 Subject: [PATCH 046/109] 8143852: Implement type variable renaming for functional interface most specific test Reviewed-by: mcimadamore, vromero --- .../com/sun/tools/javac/code/Types.java | 19 ++- .../com/sun/tools/javac/comp/Resolve.java | 135 +++++++++++------- .../tools/javac/lambda/MostSpecific15.java | 43 ++++++ .../tools/javac/lambda/MostSpecific16.java | 20 +++ .../tools/javac/lambda/MostSpecific16.out | 2 + .../tools/javac/lambda/MostSpecific17.java | 47 ++++++ .../tools/javac/lambda/MostSpecific18.java | 43 ++++++ .../tools/javac/lambda/MostSpecific19.java | 20 +++ .../tools/javac/lambda/MostSpecific19.out | 2 + .../tools/javac/lambda/MostSpecific20.java | 43 ++++++ .../tools/javac/lambda/MostSpecific21.java | 20 +++ .../tools/javac/lambda/MostSpecific21.out | 2 + .../tools/javac/lambda/MostSpecific22.java | 43 ++++++ .../tools/javac/lambda/MostSpecific23.java | 20 +++ .../tools/javac/lambda/MostSpecific23.out | 2 + .../tools/javac/lambda/MostSpecific24.java | 20 +++ .../tools/javac/lambda/MostSpecific24.out | 2 + .../tools/javac/lambda/MostSpecific25.java | 20 +++ .../tools/javac/lambda/MostSpecific25.out | 2 + .../tools/javac/lambda/MostSpecific26.java | 20 +++ .../tools/javac/lambda/MostSpecific26.out | 2 + .../tools/javac/lambda/MostSpecific27.java | 43 ++++++ .../tools/javac/lambda/MostSpecific28.java | 21 +++ .../tools/javac/lambda/MostSpecific28.out | 2 + 24 files changed, 533 insertions(+), 60 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/MostSpecific15.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific16.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific16.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific17.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific18.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific19.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific19.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific20.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific21.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific21.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific22.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific23.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific23.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific24.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific24.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific25.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific25.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific26.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific26.out create mode 100644 langtools/test/tools/javac/lambda/MostSpecific27.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific28.java create mode 100644 langtools/test/tools/javac/lambda/MostSpecific28.out diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java index 590ca4377c0..33029b46497 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java @@ -1146,14 +1146,21 @@ public class Types { if (!visit(supertype(t), supertype(s))) return false; - HashSet set = new HashSet<>(); - for (Type x : interfaces(t)) - set.add(new UniqueType(x, Types.this)); - for (Type x : interfaces(s)) { - if (!set.remove(new UniqueType(x, Types.this))) + Map tMap = new HashMap<>(); + for (Type ti : interfaces(t)) { + if (tMap.containsKey(ti)) { + throw new AssertionError("Malformed intersection"); + } + tMap.put(ti.tsym, ti); + } + for (Type si : interfaces(s)) { + if (!tMap.containsKey(si.tsym)) + return false; + Type ti = tMap.remove(si.tsym); + if (!visit(ti, si)) return false; } - return (set.isEmpty()); + return tMap.isEmpty(); } return t.tsym == s.tsym && visit(t.getEnclosingType(), s.getEnclosingType()) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java index ffa14d75e00..b5dfb11dc42 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -1137,7 +1137,56 @@ public class Resolve { /** Parameters {@code t} and {@code s} are unrelated functional interface types. */ private boolean functionalInterfaceMostSpecific(Type t, Type s, JCTree tree) { - FunctionalInterfaceMostSpecificChecker msc = new FunctionalInterfaceMostSpecificChecker(t, s); + Type tDesc = types.findDescriptorType(t); + Type sDesc = types.findDescriptorType(s); + + // compare type parameters -- can't use Types.hasSameBounds because bounds may have ivars + final List tTypeParams = tDesc.getTypeArguments(); + final List sTypeParams = sDesc.getTypeArguments(); + List tIter = tTypeParams; + List sIter = sTypeParams; + while (tIter.nonEmpty() && sIter.nonEmpty()) { + Type tBound = tIter.head.getUpperBound(); + Type sBound = types.subst(sIter.head.getUpperBound(), sTypeParams, tTypeParams); + if (tBound.containsAny(tTypeParams) && inferenceContext().free(sBound)) { + return false; + } + if (!types.isSameType(tBound, inferenceContext().asUndetVar(sBound))) { + return false; + } + tIter = tIter.tail; + sIter = sIter.tail; + } + if (!tIter.isEmpty() || !sIter.isEmpty()) { + return false; + } + + // compare parameters + List tParams = tDesc.getParameterTypes(); + List sParams = sDesc.getParameterTypes(); + while (tParams.nonEmpty() && sParams.nonEmpty()) { + Type tParam = tParams.head; + Type sParam = types.subst(sParams.head, sTypeParams, tTypeParams); + if (tParam.containsAny(tTypeParams) && inferenceContext().free(sParam)) { + return false; + } + if (!types.isSameType(tParam, inferenceContext().asUndetVar(sParam))) { + return false; + } + tParams = tParams.tail; + sParams = sParams.tail; + } + if (!tParams.isEmpty() || !sParams.isEmpty()) { + return false; + } + + // compare returns + Type tRet = tDesc.getReturnType(); + Type sRet = types.subst(sDesc.getReturnType(), sTypeParams, tTypeParams); + if (tRet.containsAny(tTypeParams) && inferenceContext().free(sRet)) { + return false; + } + MostSpecificFunctionReturnChecker msc = new MostSpecificFunctionReturnChecker(tRet, sRet); msc.scan(tree); return msc.result; } @@ -1146,16 +1195,16 @@ public class Resolve { * Tests whether one functional interface type can be considered more specific * than another unrelated functional interface type for the scanned expression. */ - class FunctionalInterfaceMostSpecificChecker extends DeferredAttr.PolyScanner { + class MostSpecificFunctionReturnChecker extends DeferredAttr.PolyScanner { - final Type t; - final Type s; + final Type tRet; + final Type sRet; boolean result; /** Parameters {@code t} and {@code s} are unrelated functional interface types. */ - FunctionalInterfaceMostSpecificChecker(Type t, Type s) { - this.t = t; - this.s = s; + MostSpecificFunctionReturnChecker(Type tRet, Type sRet) { + this.tRet = tRet; + this.sRet = sRet; result = true; } @@ -1172,29 +1221,18 @@ public class Resolve { @Override public void visitReference(JCMemberReference tree) { - Type desc_t = types.findDescriptorType(t); - Type desc_s = types.findDescriptorType(s); - // use inference variables here for more-specific inference (18.5.4) - if (!types.isSameTypes(desc_t.getParameterTypes(), - inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { + if (sRet.hasTag(VOID)) { + result &= true; + } else if (tRet.hasTag(VOID)) { result &= false; + } else if (tRet.isPrimitive() != sRet.isPrimitive()) { + boolean retValIsPrimitive = + tree.refPolyKind == PolyKind.STANDALONE && + tree.sym.type.getReturnType().isPrimitive(); + result &= (retValIsPrimitive == tRet.isPrimitive()) && + (retValIsPrimitive != sRet.isPrimitive()); } else { - // compare return types - Type ret_t = desc_t.getReturnType(); - Type ret_s = desc_s.getReturnType(); - if (ret_s.hasTag(VOID)) { - result &= true; - } else if (ret_t.hasTag(VOID)) { - result &= false; - } else if (ret_t.isPrimitive() != ret_s.isPrimitive()) { - boolean retValIsPrimitive = - tree.refPolyKind == PolyKind.STANDALONE && - tree.sym.type.getReturnType().isPrimitive(); - result &= (retValIsPrimitive == ret_t.isPrimitive()) && - (retValIsPrimitive != ret_s.isPrimitive()); - } else { - result &= compatibleBySubtyping(ret_t, ret_s); - } + result &= compatibleBySubtyping(tRet, sRet); } } @@ -1205,35 +1243,24 @@ public class Resolve { @Override public void visitLambda(JCLambda tree) { - Type desc_t = types.findDescriptorType(t); - Type desc_s = types.findDescriptorType(s); - // use inference variables here for more-specific inference (18.5.4) - if (!types.isSameTypes(desc_t.getParameterTypes(), - inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { + if (sRet.hasTag(VOID)) { + result &= true; + } else if (tRet.hasTag(VOID)) { result &= false; } else { - // compare return types - Type ret_t = desc_t.getReturnType(); - Type ret_s = desc_s.getReturnType(); - if (ret_s.hasTag(VOID)) { - result &= true; - } else if (ret_t.hasTag(VOID)) { - result &= false; - } else { - List lambdaResults = lambdaResults(tree); - if (!lambdaResults.isEmpty() && unrelatedFunctionalInterfaces(ret_t, ret_s)) { - for (JCExpression expr : lambdaResults) { - result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr); - } - } else if (!lambdaResults.isEmpty() && ret_t.isPrimitive() != ret_s.isPrimitive()) { - for (JCExpression expr : lambdaResults) { - boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); - result &= (retValIsPrimitive == ret_t.isPrimitive()) && - (retValIsPrimitive != ret_s.isPrimitive()); - } - } else { - result &= compatibleBySubtyping(ret_t, ret_s); + List lambdaResults = lambdaResults(tree); + if (!lambdaResults.isEmpty() && unrelatedFunctionalInterfaces(tRet, sRet)) { + for (JCExpression expr : lambdaResults) { + result &= functionalInterfaceMostSpecific(tRet, sRet, expr); } + } else if (!lambdaResults.isEmpty() && tRet.isPrimitive() != sRet.isPrimitive()) { + for (JCExpression expr : lambdaResults) { + boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); + result &= (retValIsPrimitive == tRet.isPrimitive()) && + (retValIsPrimitive != sRet.isPrimitive()); + } + } else { + result &= compatibleBySubtyping(tRet, sRet); } } } diff --git a/langtools/test/tools/javac/lambda/MostSpecific15.java b/langtools/test/tools/javac/lambda/MostSpecific15.java new file mode 100644 index 00000000000..1c2db64c9a3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific15.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8143852 + * @summary Rename functional interface method type parameters during most specific test + * @compile MostSpecific15.java + */ +class MostSpecific15 { + interface F1 { Object apply(X arg); } + interface F2 { String apply(Y arg); } + + static void m1(F1 f) {} + static void m1(F2 f) {} + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific15::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific16.java b/langtools/test/tools/javac/lambda/MostSpecific16.java new file mode 100644 index 00000000000..c3ed651b7ec --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific16.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Rename functional interface method type parameters during most specific test + * @compile/fail/ref=MostSpecific16.out -XDrawDiagnostics MostSpecific16.java + */ +class MostSpecific16 { + interface F1 { Object apply(Object arg); } + interface F2 { String apply(Object arg); } + + static void m1(F1 f) {} + static void m1(F2 f) {} + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific16::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific16.out b/langtools/test/tools/javac/lambda/MostSpecific16.out new file mode 100644 index 00000000000..f80856c1f7f --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific16.out @@ -0,0 +1,2 @@ +MostSpecific16.java:17:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific16.F1), MostSpecific16, kindname.method, m1(MostSpecific16.F2), MostSpecific16 +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific17.java b/langtools/test/tools/javac/lambda/MostSpecific17.java new file mode 100644 index 00000000000..907c00d9bd4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific17.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8143852 + * @summary Rename functional interface method type parameters during most specific test + * @compile MostSpecific17.java + */ +class MostSpecific17 { + + interface A {} + interface B extends A {} + + interface F1 { A apply(Object arg); } + interface F2 { B apply(Object arg); } + + static void m1(F1 f) {} + static void m1(F2 f) {} + + static B foo(Object in) { return null; } + + void test() { + m1(MostSpecific17::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific18.java b/langtools/test/tools/javac/lambda/MostSpecific18.java new file mode 100644 index 00000000000..40536982de8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific18.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8143852 + * @summary Test that generic function interface method bounds are the same + * @compile MostSpecific18.java + */ +class MostSpecific18 { + interface F1 { Object apply(X arg); } + interface F2 { String apply(Y arg); } + + static void m1(F1 f) {} + static void m1(F2 f) {} + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific18::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific19.java b/langtools/test/tools/javac/lambda/MostSpecific19.java new file mode 100644 index 00000000000..6f600e02fd4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific19.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Test that generic function interface method bounds are the same + * @compile/fail/ref=MostSpecific19.out -XDrawDiagnostics MostSpecific19.java + */ +class MostSpecific19 { + interface F1 { Object apply(X arg); } + interface F2 { String apply(Y arg); } + + static void m1(F1 f) {} + static void m1(F2 f) {} + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific19::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific19.out b/langtools/test/tools/javac/lambda/MostSpecific19.out new file mode 100644 index 00000000000..90a824febee --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific19.out @@ -0,0 +1,2 @@ +MostSpecific19.java:17:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific19.F1), MostSpecific19, kindname.method, m1(MostSpecific19.F2), MostSpecific19 +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific20.java b/langtools/test/tools/javac/lambda/MostSpecific20.java new file mode 100644 index 00000000000..3b5d56e3e52 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific20.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8143852 + * @summary Test that generic function interface method bounds are the same + * @compile MostSpecific20.java + */ +class MostSpecific20 { + interface F1 { > Object apply(X arg); } + interface F2 { > String apply(Y arg); } + + static void m1(F1 f) {} + static void m1(F2 f) {} + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific20::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific21.java b/langtools/test/tools/javac/lambda/MostSpecific21.java new file mode 100644 index 00000000000..e86c39adf34 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific21.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Most specific inference constraints derived from both functional interface method parameters and tparam bounds + * @compile/fail/ref=MostSpecific21.out -XDrawDiagnostics MostSpecific21.java + */ +class MostSpecific21 { + interface F1 { Object apply(T arg); } + interface F2 { String apply(Integer arg); } + + static T m1(F1 f) { return null; } + static Object m1(F2 f) { return null; } + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific21::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific21.out b/langtools/test/tools/javac/lambda/MostSpecific21.out new file mode 100644 index 00000000000..8ed90048b33 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific21.out @@ -0,0 +1,2 @@ +MostSpecific21.java:17:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific21.F1), MostSpecific21, kindname.method, m1(MostSpecific21.F2), MostSpecific21 +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific22.java b/langtools/test/tools/javac/lambda/MostSpecific22.java new file mode 100644 index 00000000000..5c56f8546e2 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific22.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8143852 + * @summary Most specific inference constraints derived from both functional interface method parameters and tparam bounds + * @compile MostSpecific22.java + */ +class MostSpecific22 { + interface F1 { Object apply(T arg); } + interface F2 { String apply(Number arg); } + + static T m1(F1 f) { return null; } + static Object m1(F2 f) { return null; } + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific22::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific23.java b/langtools/test/tools/javac/lambda/MostSpecific23.java new file mode 100644 index 00000000000..796344ab4ad --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific23.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Most specific failure if ivar can be bounded by functional interface method tparam + * @compile/fail/ref=MostSpecific23.out -XDrawDiagnostics MostSpecific23.java + */ +class MostSpecific23 { + interface F1 { Object apply(Integer arg); } + interface F2 { > String apply(Integer arg); } + + static T m1(F1 f) { return null; } + static Object m1(F2 f) { return null; } + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific23::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific23.out b/langtools/test/tools/javac/lambda/MostSpecific23.out new file mode 100644 index 00000000000..2e53c137d59 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific23.out @@ -0,0 +1,2 @@ +MostSpecific23.java:17:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific23.F1), MostSpecific23, kindname.method, m1(MostSpecific23.F2), MostSpecific23 +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific24.java b/langtools/test/tools/javac/lambda/MostSpecific24.java new file mode 100644 index 00000000000..f073e8ce966 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific24.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Most specific failure if ivar can be bounded by functional interface method tparam + * @compile/fail/ref=MostSpecific24.out -XDrawDiagnostics MostSpecific24.java + */ +class MostSpecific24 { + interface F1 { Object apply(Class arg); } + interface F2 { String apply(Class arg); } + + static T m1(F1 f) { return null; } + static Object m1(F2 f) { return null; } + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific24::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific24.out b/langtools/test/tools/javac/lambda/MostSpecific24.out new file mode 100644 index 00000000000..0f0b0afd85c --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific24.out @@ -0,0 +1,2 @@ +MostSpecific24.java:17:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific24.F1), MostSpecific24, kindname.method, m1(MostSpecific24.F2), MostSpecific24 +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific25.java b/langtools/test/tools/javac/lambda/MostSpecific25.java new file mode 100644 index 00000000000..1aeab2e1460 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific25.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Most specific failure if ivar can be bounded by functional interface method tparam + * @compile/fail/ref=MostSpecific25.out -XDrawDiagnostics MostSpecific25.java + */ +class MostSpecific25 { + interface F1 { T apply(Integer arg); } + interface F2 { Class apply(Integer arg); } + + static T m1(F1 f) { return null; } + static Object m1(F2 f) { return null; } + + static Class foo(Object in) { return Object.class; } + + void test() { + m1(MostSpecific25::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific25.out b/langtools/test/tools/javac/lambda/MostSpecific25.out new file mode 100644 index 00000000000..e8568590db8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific25.out @@ -0,0 +1,2 @@ +MostSpecific25.java:17:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific25.F1), MostSpecific25, kindname.method, m1(MostSpecific25.F2), MostSpecific25 +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific26.java b/langtools/test/tools/javac/lambda/MostSpecific26.java new file mode 100644 index 00000000000..f4bfd5240dd --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific26.java @@ -0,0 +1,20 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Most specific inference constraints derived from intersection bound + * @compile/fail/ref=MostSpecific26.out -XDrawDiagnostics MostSpecific26.java + */ +class MostSpecific26 { + interface F1 { & Runnable> Object apply(T arg); } + interface F2 { & Runnable> String apply(Integer arg); } + + static T m1(F1 f) { return null; } + static Object m1(F2 f) { return null; } + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific26::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific26.out b/langtools/test/tools/javac/lambda/MostSpecific26.out new file mode 100644 index 00000000000..3f39d392e81 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific26.out @@ -0,0 +1,2 @@ +MostSpecific26.java:17:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific26.F1), MostSpecific26, kindname.method, m1(MostSpecific26.F2), MostSpecific26 +1 error diff --git a/langtools/test/tools/javac/lambda/MostSpecific27.java b/langtools/test/tools/javac/lambda/MostSpecific27.java new file mode 100644 index 00000000000..2c758b2b3e4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific27.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8143852 + * @summary Most specific inference constraints derived from intersection bound + * @compile MostSpecific27.java + */ +class MostSpecific27 { + interface F1 { & Runnable> Object apply(T arg); } + interface F2 { & Runnable> String apply(Number arg); } + + static T m1(F1 f) { return null; } + static Object m1(F2 f) { return null; } + + static String foo(Object in) { return "a"; } + + void test() { + m1(MostSpecific27::foo); + } + +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific28.java b/langtools/test/tools/javac/lambda/MostSpecific28.java new file mode 100644 index 00000000000..417adf03bcb --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific28.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8143852 + * @summary Test that functional interface method parameter types are equal, even for an explicit lambda + * @compile/fail/ref=MostSpecific28.out -XDrawDiagnostics MostSpecific28.java + */ +class MostSpecific28 { + + interface Pred { boolean test(T arg); } + interface Fun { R apply(T arg); } + + static void m1(Pred f) {} + static void m1(Fun f) {} + + static String foo(Object in) { return "a"; } + + void test() { + m1((Number n) -> true); + } + +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific28.out b/langtools/test/tools/javac/lambda/MostSpecific28.out new file mode 100644 index 00000000000..f3097b7fc40 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific28.out @@ -0,0 +1,2 @@ +MostSpecific28.java:18:9: compiler.err.ref.ambiguous: m1, kindname.method, m1(MostSpecific28.Pred), MostSpecific28, kindname.method, m1(MostSpecific28.Fun), MostSpecific28 +1 error From aeca638f857ac6cdeb19d4f9576ae2ebba968773 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 8 Jan 2016 22:24:15 -0800 Subject: [PATCH 047/109] 8146727: test tools/sjavac/IncludeExcludePatterns.java fails on Windows Reviewed-by: darcy --- langtools/test/tools/sjavac/IncludeExcludePatterns.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/langtools/test/tools/sjavac/IncludeExcludePatterns.java b/langtools/test/tools/sjavac/IncludeExcludePatterns.java index 50d88fb85b0..a263726ae84 100644 --- a/langtools/test/tools/sjavac/IncludeExcludePatterns.java +++ b/langtools/test/tools/sjavac/IncludeExcludePatterns.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import com.sun.tools.javac.util.Assert; import com.sun.tools.sjavac.server.Sjavac; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -104,7 +105,7 @@ public class IncludeExcludePatterns extends SjavacBase { // Puts an empty (dummy) class definition in the given path. void writeDummyClass(Path javaFile) throws IOException { - String pkg = javaFile.getParent().toString().replace('/', '.'); + String pkg = javaFile.getParent().toString().replace(File.separatorChar, '.'); String cls = javaFile.getFileName().toString().replace(".java", ""); toolbox.writeFile(SRC.resolve(javaFile), "package " + pkg + "; class " + cls + " {}"); } From 0fbaf41ad99b760ed07e6dee0a46c5fb64f3bc84 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 11 Jan 2016 11:21:10 +0100 Subject: [PATCH 048/109] 8056897: Improve error recovery for empty binary and hexadecimal literals Reviewed-by: mcimadamore --- .../sun/tools/javac/parser/JavaTokenizer.java | 35 ++++---- .../test/tools/javac/BadHexConstant.java | 2 +- langtools/test/tools/javac/BadHexConstant.out | 3 +- .../diags/examples/IdentifierExpected.java | 8 +- .../test/tools/javac/lexer/JavaLexerTest.java | 81 +++++++++++++++++++ .../test/tools/javac/literals/T6891079.java | 2 +- .../test/tools/javac/literals/T6891079.out | 4 +- 7 files changed, 106 insertions(+), 29 deletions(-) create mode 100644 langtools/test/tools/javac/lexer/JavaLexerTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java index ba68b58457a..28be92d14df 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -301,15 +301,16 @@ public class JavaTokenizer { } /** Read a number. - * @param radix The radix of the number; one of 2, j8, 10, 16. + * @param radix The radix of the number; one of 2, 8, 10, 16. */ private void scanNumber(int pos, int radix) { // for octal, allow base-10 digit in case it's a float literal this.radix = radix; int digitRadix = (radix == 8 ? 10 : radix); - boolean seendigit = false; - if (reader.digit(pos, digitRadix) >= 0) { - seendigit = true; + int firstDigit = reader.digit(pos, Math.max(10, digitRadix)); + boolean seendigit = firstDigit >= 0; + boolean seenValidDigit = firstDigit >= 0 && firstDigit < digitRadix; + if (seendigit) { scanDigits(pos, digitRadix); } if (radix == 16 && reader.ch == '.') { @@ -325,6 +326,16 @@ public class JavaTokenizer { reader.ch == 'd' || reader.ch == 'D')) { scanFractionAndSuffix(pos); } else { + if (!seenValidDigit) { + switch (radix) { + case 2: + lexError(pos, "invalid.binary.number"); + break; + case 16: + lexError(pos, "invalid.hex.number"); + break; + } + } if (reader.ch == 'l' || reader.ch == 'L') { reader.scanChar(); tk = TokenKind.LONGLITERAL; @@ -491,13 +502,7 @@ public class JavaTokenizer { if (reader.ch == 'x' || reader.ch == 'X') { reader.scanChar(); skipIllegalUnderscores(); - if (reader.ch == '.') { - scanHexFractionAndSuffix(pos, false); - } else if (reader.digit(pos, 16) < 0) { - lexError(pos, "invalid.hex.number"); - } else { - scanNumber(pos, 16); - } + scanNumber(pos, 16); } else if (reader.ch == 'b' || reader.ch == 'B') { if (!allowBinaryLiterals) { lexError(pos, "unsupported.binary.lit", source.name); @@ -505,11 +510,7 @@ public class JavaTokenizer { } reader.scanChar(); skipIllegalUnderscores(); - if (reader.digit(pos, 2) < 0) { - lexError(pos, "invalid.binary.number"); - } else { - scanNumber(pos, 2); - } + scanNumber(pos, 2); } else { reader.putChar('0'); if (reader.ch == '_') { diff --git a/langtools/test/tools/javac/BadHexConstant.java b/langtools/test/tools/javac/BadHexConstant.java index b9f88f1ccf4..c88bff561a1 100644 --- a/langtools/test/tools/javac/BadHexConstant.java +++ b/langtools/test/tools/javac/BadHexConstant.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 4049982 + * @bug 4049982 8056897 * @summary Compiler permitted invalid hex literal. * @author turnidge * diff --git a/langtools/test/tools/javac/BadHexConstant.out b/langtools/test/tools/javac/BadHexConstant.out index e73e871e96c..cda08f8761a 100644 --- a/langtools/test/tools/javac/BadHexConstant.out +++ b/langtools/test/tools/javac/BadHexConstant.out @@ -1,3 +1,2 @@ BadHexConstant.java:12:14: compiler.err.invalid.hex.number -BadHexConstant.java:12:17: compiler.err.expected: token.identifier -2 errors +1 error diff --git a/langtools/test/tools/javac/diags/examples/IdentifierExpected.java b/langtools/test/tools/javac/diags/examples/IdentifierExpected.java index f36b8ad2161..fd79267f00d 100644 --- a/langtools/test/tools/javac/diags/examples/IdentifierExpected.java +++ b/langtools/test/tools/javac/diags/examples/IdentifierExpected.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,9 @@ // key: compiler.misc.token.identifier // key: compiler.err.expected -// key: compiler.err.invalid.binary.number -// key: compiler.misc.count.error.plural +// key: compiler.misc.count.error // key: compiler.err.error // run: backdoor -class IdentifierExpected { - long bl = 0BL; +class { } diff --git a/langtools/test/tools/javac/lexer/JavaLexerTest.java b/langtools/test/tools/javac/lexer/JavaLexerTest.java new file mode 100644 index 00000000000..caa4c140d12 --- /dev/null +++ b/langtools/test/tools/javac/lexer/JavaLexerTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8056897 + * @summary Proper lexing of integer literals. + */ + +import java.io.IOException; +import java.net.URI; +import java.util.Objects; + +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; + +import com.sun.tools.javac.parser.JavaTokenizer; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.parser.Tokens.Token; +import com.sun.tools.javac.parser.Tokens.TokenKind; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Log; + +public class JavaLexerTest { + public static void main(String... args) throws Exception { + new JavaLexerTest().run(); + } + + void run() throws Exception { + Context ctx = new Context(); + Log log = Log.instance(ctx); + String input = "0bL 0b20L 0xL "; + log.useSource(new SimpleJavaFileObject(new URI("mem://Test.java"), JavaFileObject.Kind.SOURCE) { + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return input; + } + }); + char[] inputArr = input.toCharArray(); + JavaTokenizer tokenizer = new JavaTokenizer(ScannerFactory.instance(ctx), inputArr, inputArr.length) { + }; + + assertKind(input, tokenizer, TokenKind.LONGLITERAL, "0bL"); + assertKind(input, tokenizer, TokenKind.LONGLITERAL, "0b20L"); + assertKind(input, tokenizer, TokenKind.LONGLITERAL, "0xL"); + } + + void assertKind(String input, JavaTokenizer tokenizer, TokenKind kind, String expectedText) { + Token token = tokenizer.readToken(); + + if (token.kind != kind) { + throw new AssertionError("Unexpected token kind: " + token.kind); + } + + String actualText = input.substring(token.pos, token.endPos); + + if (!Objects.equals(actualText, expectedText)) { + throw new AssertionError("Unexpected token text: " + actualText); + } + } +} \ No newline at end of file diff --git a/langtools/test/tools/javac/literals/T6891079.java b/langtools/test/tools/javac/literals/T6891079.java index 8d5edbcf71a..b454d20cc8a 100644 --- a/langtools/test/tools/javac/literals/T6891079.java +++ b/langtools/test/tools/javac/literals/T6891079.java @@ -1,5 +1,5 @@ /* @test /nodynamiccopyright/ - * @bug 6891079 + * @bug 6891079 8056897 * @summary Compiler allows invalid binary literals 0b and oBL * @compile/fail/ref=T6891079.out -XDrawDiagnostics T6891079.java */ diff --git a/langtools/test/tools/javac/literals/T6891079.out b/langtools/test/tools/javac/literals/T6891079.out index 4472d62bb7f..63aef8effc9 100644 --- a/langtools/test/tools/javac/literals/T6891079.out +++ b/langtools/test/tools/javac/literals/T6891079.out @@ -1,7 +1,5 @@ T6891079.java:8:14: compiler.err.invalid.binary.number T6891079.java:9:15: compiler.err.invalid.binary.number -T6891079.java:9:18: compiler.err.expected: token.identifier T6891079.java:10:14: compiler.err.invalid.hex.number T6891079.java:11:15: compiler.err.invalid.hex.number -T6891079.java:11:18: compiler.err.expected: token.identifier -6 errors +4 errors From 3512de403f7cf836f750c753a873ef8d25f55559 Mon Sep 17 00:00:00 2001 From: Andreas Lundblad Date: Mon, 11 Jan 2016 17:08:20 +0100 Subject: [PATCH 049/109] 8145944: sjavac client could not connect to server Wait for port file to get deleted before returning from PortFile::delete Reviewed-by: jlahoda --- .../com/sun/tools/sjavac/server/PortFile.java | 15 ++++++++++++--- .../com/sun/tools/sjavac/server/SjavacServer.java | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java index 3d5f1952b43..c66730a928b 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -174,11 +174,20 @@ public class PortFile { /** * Delete the port file. */ - public void delete() throws IOException { + public void delete() throws IOException, InterruptedException { // Access to file must be closed before deleting. rwfile.close(); - // Now delete. + file.delete(); + + // Wait until file has been deleted (deletes are asynchronous on Windows!) otherwise we + // might shutdown the server and prevent another one from starting. + for (int i = 0; i < 10 && file.exists(); i++) { + Thread.sleep(1000); + } + if (file.exists()) { + throw new IOException("Failed to delete file."); + } } /** diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java index 1e506ac5275..1f9ec7504d4 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -279,7 +279,7 @@ public class SjavacServer implements Terminable { // failed connection attempts try { portFile.delete(); - } catch (IOException e) { + } catch (IOException | InterruptedException e) { e.printStackTrace(theLog); } try { From d15f6a78b311e61442cc2b592fe0d538880b6785 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Mon, 11 Jan 2016 08:41:00 -0800 Subject: [PATCH 050/109] 8081845: JShell: Need way to refresh relative to external state Add the ability to record and replay relevant parts of history Reviewed-by: jlahoda --- .../jdk/internal/jshell/tool/JShellTool.java | 301 +++++++++++++----- langtools/test/jdk/jshell/ToolReloadTest.java | 197 ++++++++++++ 2 files changed, 419 insertions(+), 79 deletions(-) create mode 100644 langtools/test/jdk/jshell/ToolReloadTest.java diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index a66d9cbc1aa..2c027fda9a4 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -90,8 +91,10 @@ import java.util.MissingResourceException; import java.util.Optional; import java.util.ResourceBundle; import java.util.Spliterators; +import java.util.function.Function; import java.util.function.Supplier; import static java.util.stream.Collectors.toList; +import static jdk.jshell.Snippet.SubKind.VAR_VALUE_SUBKIND; /** * Command line REPL tool for Java using the JShell API. @@ -102,6 +105,7 @@ public class JShellTool { private static final Pattern LINEBREAK = Pattern.compile("\\R"); private static final Pattern HISTORY_ALL_START_FILENAME = Pattern.compile( "((?(all|history|start))(\\z|\\p{javaWhitespace}+))?(?.*)"); + private static final String RECORD_SEPARATOR = "\u241E"; final InputStream cmdin; final PrintStream cmdout; @@ -150,9 +154,14 @@ public class JShellTool { private String cmdlineStartup = null; private String editor = null; - static final Preferences PREFS = Preferences.userRoot().node("tool/REPL"); + // Commands and snippets which should be replayed + private List replayableHistory; + private List replayableHistoryPrevious; + + static final Preferences PREFS = Preferences.userRoot().node("tool/JShell"); static final String STARTUP_KEY = "STARTUP"; + static final String REPLAY_RESTORE_KEY = "REPLAY_RESTORE"; static final String DEFAULT_STARTUP = "\n" + @@ -165,11 +174,14 @@ public class JShellTool { "import java.util.regex.*;\n" + "void printf(String format, Object... args) { System.out.printf(format, args); }\n"; - // Tool id (tid) mapping + // Tool id (tid) mapping: the three name spaces NameSpace mainNamespace; NameSpace startNamespace; NameSpace errorNamespace; + + // Tool id (tid) mapping: the current name spaces NameSpace currentNameSpace; + Map mapSnippet; void debug(String format, Object... args) { @@ -252,6 +264,12 @@ public class JShellTool { private void start(IOContext in, List loadList) { resetState(); // Initialize + // Read replay history from last jshell session into previous history + String prevReplay = PREFS.get(REPLAY_RESTORE_KEY, null); + if (prevReplay != null) { + replayableHistoryPrevious = Arrays.asList(prevReplay.split(RECORD_SEPARATOR)); + } + for (String loadFile : loadList) { cmdOpen(loadFile); } @@ -370,6 +388,10 @@ public class JShellTool { mapSnippet = new LinkedHashMap<>(); currentNameSpace = startNamespace; + // Reset the replayable history, saving the old for restore + replayableHistoryPrevious = replayableHistory; + replayableHistory = new ArrayList<>(); + state = JShell.builder() .in(userin) .out(userout) @@ -382,7 +404,8 @@ public class JShellTool { analysis = state.sourceCodeAnalysis(); shutdownSubscription = state.onShutdown((JShell deadState) -> { if (deadState == state) { - hard("State engine terminated. See /history"); + hard("State engine terminated."); + hard("Restore definitions with: /reload restore"); live = false; } }); @@ -392,7 +415,6 @@ public class JShellTool { state.addToClasspath(cmdlineClasspath); } - String start; if (cmdlineStartup == null) { start = PREFS.get(STARTUP_KEY, ""); @@ -431,7 +453,7 @@ public class JShellTool { String incomplete = ""; while (live) { String prompt; - if (in.interactiveOutput() && displayPrompt) { + if (displayPrompt) { prompt = testPrompt ? incomplete.isEmpty() ? "\u0005" //ENQ @@ -480,6 +502,12 @@ public class JShellTool { } } + private void addToReplayHistory(String s) { + if (currentNameSpace == mainNamespace) { + replayableHistory.add(s); + } + } + private String processSourceCatchingReset(String src) { try { input.beforeUserCode(); @@ -516,7 +544,12 @@ public class JShellTool { fluff("Type /help for help."); } } else if (candidates.length == 1) { - candidates[0].run.accept(arg); + Command command = candidates[0]; + + // If comand was successful and is of a replayable kind, add it the replayable history + if (command.run.apply(arg) && command.kind == CommandKind.REPLAY) { + addToReplayHistory((command.command + " " + arg).trim()); + } } else { hard("Command: %s is ambiguous: %s", cmd, Arrays.stream(candidates).map(c -> c.command).collect(Collectors.joining(", "))); fluff("Type /help for help."); @@ -546,15 +579,15 @@ public class JShellTool { public final String command; public final String params; public final String description; - public final Consumer run; + public final Function run; public final CompletionProvider completions; public final CommandKind kind; - public Command(String command, String params, String description, Consumer run, CompletionProvider completions) { + public Command(String command, String params, String description, Function run, CompletionProvider completions) { this(command, params, description, run, completions, CommandKind.NORMAL); } - public Command(String command, String params, String description, Consumer run, CompletionProvider completions, CommandKind kind) { + public Command(String command, String params, String description, Function run, CompletionProvider completions, CommandKind kind) { this.command = command; this.params = params; this.description = description; @@ -571,6 +604,7 @@ public class JShellTool { enum CommandKind { NORMAL, + REPLAY, HIDDEN, HELP_ONLY; } @@ -602,6 +636,7 @@ public class JShellTool { private static final CompletionProvider EMPTY_COMPLETION_PROVIDER = new FixedCompletionProvider(); private static final CompletionProvider KEYWORD_COMPLETION_PROVIDER = new FixedCompletionProvider("all ", "start ", "history "); + private static final CompletionProvider RELOAD_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("restore", "quiet"); private static final CompletionProvider FILE_COMPLETION_PROVIDER = fileCompletions(p -> true); private final Map commands = new LinkedHashMap<>(); private void registerCommand(Command cmd) { @@ -674,6 +709,16 @@ public class JShellTool { }; } + private static CompletionProvider reloadCompletion() { + return (code, cursor, anchor) -> { + List result = new ArrayList<>(); + int pastSpace = code.indexOf(' ') + 1; // zero if no space + result.addAll(RELOAD_OPTIONS_COMPLETION_PROVIDER.completionSuggestions(code.substring(pastSpace), cursor - pastSpace, anchor)); + anchor[0] += pastSpace; + return result; + }; + } + // Table of commands -- with command forms, argument kinds, help message, implementation, ... { @@ -688,7 +733,8 @@ public class JShellTool { editCompletion())); registerCommand(new Command("/drop", "", "delete a source entry referenced by name or id", arg -> cmdDrop(arg), - editCompletion())); + editCompletion(), + CommandKind.REPLAY)); registerCommand(new Command("/save", "[all|history|start] ", "save: - current source;\n" + " all - source including overwritten, failed, and start-up code;\n" + " history - editing history;\n" + @@ -716,6 +762,9 @@ public class JShellTool { registerCommand(new Command("/reset", null, "reset everything in the REPL", arg -> cmdReset(), EMPTY_COMPLETION_PROVIDER)); + registerCommand(new Command("/reload", "[restore] [quiet]", "reset and replay relevant history -- current or previous (restore)", + arg -> cmdReload(arg), + reloadCompletion())); registerCommand(new Command("/feedback", "", "feedback information: off, concise, normal, verbose, default, or ?", arg -> cmdFeedback(arg), new FixedCompletionProvider("off", "concise", "normal", "verbose", "default", "?"))); @@ -724,7 +773,8 @@ public class JShellTool { EMPTY_COMPLETION_PROVIDER)); registerCommand(new Command("/classpath", "", "add a path to the classpath", arg -> cmdClasspath(arg), - classPathCompletion())); + classPathCompletion(), + CommandKind.REPLAY)); registerCommand(new Command("/history", null, "history of what you have typed", arg -> cmdHistory(), EMPTY_COMPLETION_PROVIDER)); @@ -801,25 +851,29 @@ public class JShellTool { // --- Command implementations --- - void cmdSetEditor(String arg) { + boolean cmdSetEditor(String arg) { if (arg.isEmpty()) { hard("/seteditor requires a path argument"); + return false; } else { editor = arg; fluff("Editor set to: %s", arg); + return true; } } - void cmdClasspath(String arg) { + boolean cmdClasspath(String arg) { if (arg.isEmpty()) { hard("/classpath requires a path argument"); + return false; } else { state.addToClasspath(toPathResolvingUserHome(arg).toString()); fluff("Path %s added to classpath", arg); + return true; } } - void cmdDebug(String arg) { + boolean cmdDebug(String arg) { if (arg.isEmpty()) { debug = !debug; InternalDebugControl.setDebugFlags(state, debug ? InternalDebugControl.DBG_GEN : 0); @@ -860,20 +914,26 @@ public class JShellTool { default: hard("Unknown debugging option: %c", ch); fluff("Use: 0 r g f c d"); - break; + return false; } } InternalDebugControl.setDebugFlags(state, flags); } + return true; } - private void cmdExit() { + private boolean cmdExit() { regenerateOnDeath = false; live = false; + if (!replayableHistory.isEmpty()) { + PREFS.put(REPLAY_RESTORE_KEY, replayableHistory.stream().reduce( + (a, b) -> a + RECORD_SEPARATOR + b).get()); + } fluff("Goodbye\n"); + return true; } - private void cmdFeedback(String arg) { + private boolean cmdFeedback(String arg) { switch (arg) { case "": case "d": @@ -905,12 +965,13 @@ public class JShellTool { hard(" default"); hard("You may also use just the first letter, for example: /f c"); hard("In interactive mode 'default' is the same as 'normal', from a file it is the same as 'off'"); - return; + return false; } fluff("Feedback mode: %s", feedback.name().toLowerCase()); + return true; } - void cmdHelp() { + boolean cmdHelp() { int synopsisLen = 0; Map synopsis2Description = new LinkedHashMap<>(); for (Command cmd : new LinkedHashSet<>(commands.values())) { @@ -936,14 +997,16 @@ public class JShellTool { cmdout.println("Supported shortcuts include:"); cmdout.println(" -- show possible completions for the current text"); cmdout.println("Shift- -- for current method or constructor invocation, show a synopsis of the method/constructor"); + return true; } - private void cmdHistory() { + private boolean cmdHistory() { cmdout.println(); for (String s : input.currentSessionHistory()) { // No number prefix, confusing with snippet ids cmdout.printf("%s\n", s); } + return true; } /** @@ -1010,23 +1073,23 @@ public class JShellTool { } } - private void cmdDrop(String arg) { + private boolean cmdDrop(String arg) { if (arg.isEmpty()) { hard("In the /drop argument, please specify an import, variable, method, or class to drop."); hard("Specify by id or name. Use /list to see ids. Use /reset to reset all state."); - return; + return false; } Stream stream = argToSnippets(arg, false); if (stream == null) { hard("No definition or id named %s found. See /classes, /methods, /vars, or /list", arg); - return; + return false; } List snippets = stream .filter(sn -> state.status(sn).isActive && sn instanceof PersistentSnippet) .collect(toList()); if (snippets.isEmpty()) { hard("The argument did not specify an active import, variable, method, or class to drop."); - return; + return false; } if (snippets.size() > 1) { hard("The argument references more than one import, variable, method, or class."); @@ -1034,17 +1097,18 @@ public class JShellTool { for (Snippet sn : snippets) { cmdout.printf("%4s : %s\n", sn.id(), sn.source().replace("\n", "\n ")); } - return; + return false; } PersistentSnippet psn = (PersistentSnippet) snippets.get(0); state.drop(psn).forEach(this::handleEvent); + return true; } - private void cmdEdit(String arg) { + private boolean cmdEdit(String arg) { Stream stream = argToSnippets(arg, true); if (stream == null) { hard("No definition or id named %s found. See /classes, /methods, /vars, or /list", arg); - return; + return false; } Set srcSet = new LinkedHashSet<>(); stream.forEachOrdered(sn -> { @@ -1078,6 +1142,7 @@ public class JShellTool { } else { ExternalEditor.edit(editor, errorHandler, src, saveHandler, input); } + return true; } //where // receives editor requests to save @@ -1135,10 +1200,9 @@ public class JShellTool { } } - private void cmdList(String arg) { + private boolean cmdList(String arg) { if (arg.equals("history")) { - cmdHistory(); - return; + return cmdHistory(); } Stream stream = argToSnippets(arg, true); if (stream == null) { @@ -1148,7 +1212,7 @@ public class JShellTool { } else { hard("No definition or id named %s found. There are no active definitions.", arg); } - return; + return false; } // prevent double newline on empty list @@ -1160,38 +1224,72 @@ public class JShellTool { } cmdout.printf("%4s : %s\n", sn.id(), sn.source().replace("\n", "\n ")); }); + return true; } - private void cmdOpen(String filename) { + private boolean cmdOpen(String filename) { if (filename.isEmpty()) { hard("The /open command requires a filename argument."); + return false; } else { try { run(new FileScannerIOContext(toPathResolvingUserHome(filename).toString())); } catch (FileNotFoundException e) { hard("File '%s' is not found: %s", filename, e.getMessage()); + return false; } catch (Exception e) { hard("Exception while reading file: %s", e); + return false; } } + return true; } - private void cmdPrompt() { + private boolean cmdPrompt() { displayPrompt = !displayPrompt; fluff("Prompt will %sdisplay. Use /prompt to toggle.", displayPrompt ? "" : "NOT "); concise("Prompt: %s", displayPrompt ? "on" : "off"); + return true; } - private void cmdReset() { + private boolean cmdReset() { live = false; fluff("Resetting state."); + return true; } - private void cmdSave(String arg_filename) { + private boolean cmdReload(String arg) { + Iterable history = replayableHistory; + boolean echo = true; + if (arg.length() > 0) { + if ("restore".startsWith(arg)) { + if (replayableHistoryPrevious == null) { + hard("No previous history to restore\n", arg); + return false; + } + history = replayableHistoryPrevious; + } else if ("quiet".startsWith(arg)) { + echo = false; + } else { + hard("Invalid argument to reload command: %s\nUse 'restore', 'quiet', or no argument\n", arg); + return false; + } + } + fluff("Restarting and restoring %s.", + history == replayableHistoryPrevious + ? "from previous state" + : "state"); + resetState(); + run(new ReloadIOContext(history, + echo? cmdout : null)); + return true; + } + + private boolean cmdSave(String arg_filename) { Matcher mat = HISTORY_ALL_START_FILENAME.matcher(arg_filename); if (!mat.find()) { hard("Malformed argument to the /save command: %s", arg_filename); - return; + return false; } boolean useHistory = false; String saveAll = ""; @@ -1211,7 +1309,7 @@ public class JShellTool { String filename = mat.group("filename"); if (filename == null ||filename.isEmpty()) { hard("The /save command requires a filename argument."); - return; + return false; } try (BufferedWriter writer = Files.newBufferedWriter(toPathResolvingUserHome(filename), Charset.defaultCharset(), @@ -1234,12 +1332,15 @@ public class JShellTool { } } catch (FileNotFoundException e) { hard("File '%s' for save is not accessible: %s", filename, e.getMessage()); + return false; } catch (Exception e) { hard("Exception while saving: %s", e); + return false; } + return true; } - private void cmdSetStart(String filename) { + private boolean cmdSetStart(String filename) { if (filename.isEmpty()) { hard("The /setstart command requires a filename argument."); } else { @@ -1249,30 +1350,36 @@ public class JShellTool { PREFS.put(STARTUP_KEY, init); } catch (AccessDeniedException e) { hard("File '%s' for /setstart is not accessible.", filename); + return false; } catch (NoSuchFileException e) { hard("File '%s' for /setstart is not found.", filename); + return false; } catch (Exception e) { hard("Exception while reading start set file: %s", e); + return false; } } + return true; } - private void cmdVars() { + private boolean cmdVars() { for (VarSnippet vk : state.variables()) { String val = state.status(vk) == Status.VALID ? state.varValue(vk) : "(not-active)"; hard(" %s %s = %s", vk.typeName(), vk.name(), val); } + return true; } - private void cmdMethods() { + private boolean cmdMethods() { for (MethodSnippet mk : state.methods()) { hard(" %s %s", mk.name(), mk.signature()); } + return true; } - private void cmdClasses() { + private boolean cmdClasses() { for (TypeDeclSnippet ck : state.types()) { String kind; switch (ck.subKind()) { @@ -1295,15 +1402,17 @@ public class JShellTool { } hard(" %s %s", kind, ck.name()); } + return true; } - private void cmdImports() { + private boolean cmdImports() { state.imports().forEach(ik -> { hard(" import %s%s", ik.isStatic() ? "static " : "", ik.fullname()); }); + return true; } - private void cmdUseHistoryEntry(int index) { + private boolean cmdUseHistoryEntry(int index) { List keys = state.snippets(); if (index < 0) index += keys.size(); @@ -1313,7 +1422,9 @@ public class JShellTool { rerunSnippet(keys.get(index)); } else { hard("Cannot find snippet %d", index + 1); + return false; } + return true; } private boolean rerunHistoryEntryById(String id) { @@ -1425,10 +1536,24 @@ public class JShellTool { private boolean processCompleteSource(String source) throws IllegalStateException { debug("Compiling: %s", source); boolean failed = false; + boolean isActive = false; List events = state.eval(source); for (SnippetEvent e : events) { + // Report the event, recording failure failed |= handleEvent(e); + + // If any main snippet is active, this should be replayable + // also ignore var value queries + isActive |= e.causeSnippet() == null && + e.status().isActive && + e.snippet().subKind() != VAR_VALUE_SUBKIND; } + // If this is an active snippet and it didn't cause the backend to die, + // add it to the replayable history + if (isActive && live) { + addToReplayHistory(source); + } + return failed; } @@ -1784,31 +1909,11 @@ public class JShellTool { } } -class ScannerIOContext extends IOContext { - - private final Scanner scannerIn; - private final PrintStream pStream; - - public ScannerIOContext(Scanner scannerIn, PrintStream pStream) { - this.scannerIn = scannerIn; - this.pStream = pStream; - } - - @Override - public String readLine(String prompt, String prefix) { - if (pStream != null && prompt != null) { - pStream.print(prompt); - } - if (scannerIn.hasNextLine()) { - return scannerIn.nextLine(); - } else { - return null; - } - } +abstract class NonInteractiveIOContext extends IOContext { @Override public boolean interactiveOutput() { - return true; + return false; } @Override @@ -1816,11 +1921,6 @@ class ScannerIOContext extends IOContext { return Collections.emptyList(); } - @Override - public void close() { - scannerIn.close(); - } - @Override public boolean terminalEditorRunning() { return false; @@ -1847,19 +1947,62 @@ class ScannerIOContext extends IOContext { } } -class FileScannerIOContext extends ScannerIOContext { +class ScannerIOContext extends NonInteractiveIOContext { + private final Scanner scannerIn; - public FileScannerIOContext(String fn) throws FileNotFoundException { - this(new FileReader(fn)); - } - - public FileScannerIOContext(Reader rdr) throws FileNotFoundException { - super(new Scanner(rdr), null); + ScannerIOContext(Scanner scannerIn) { + this.scannerIn = scannerIn; } @Override - public boolean interactiveOutput() { - return false; + public String readLine(String prompt, String prefix) { + if (scannerIn.hasNextLine()) { + return scannerIn.nextLine(); + } else { + return null; + } + } + + @Override + public void close() { + scannerIn.close(); } } +class FileScannerIOContext extends ScannerIOContext { + + FileScannerIOContext(String fn) throws FileNotFoundException { + this(new FileReader(fn)); + } + + FileScannerIOContext(Reader rdr) throws FileNotFoundException { + super(new Scanner(rdr)); + } +} + +class ReloadIOContext extends NonInteractiveIOContext { + private final Iterator it; + private final PrintStream echoStream; + + ReloadIOContext(Iterable history, PrintStream echoStream) { + this.it = history.iterator(); + this.echoStream = echoStream; + } + + @Override + public String readLine(String prompt, String prefix) { + String s = it.hasNext() + ? it.next() + : null; + if (echoStream != null && s != null) { + String p = "-: "; + String p2 = "\n "; + echoStream.printf("%s%s\n", p, s.replace("\n", p2)); + } + return s; + } + + @Override + public void close() { + } +} diff --git a/langtools/test/jdk/jshell/ToolReloadTest.java b/langtools/test/jdk/jshell/ToolReloadTest.java new file mode 100644 index 00000000000..0d41b1aa922 --- /dev/null +++ b/langtools/test/jdk/jshell/ToolReloadTest.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8081845 + * @summary Tests for /reload in JShell tool + * @library /tools/lib + * @build KullaTesting TestingInputStream ToolBox Compiler + * @run testng ToolReloadTest + */ + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.function.Function; + +import org.testng.annotations.Test; + + +@Test +public class ToolReloadTest extends ReplToolTesting { + + public void testReloadSnippets() { + test( + (a) -> assertVariable(a, "int", "x", "5", "5"), + (a) -> assertMethod(a, "int m(int z) { return z * z; }", + "(int)int", "m"), + (a) -> evaluateExpression(a, "int", "m(x)", "25"), + (a) -> assertCommand(a, "/reload", + "| Restarting and restoring state.\n" + + "-: int x = 5;\n" + + "-: int m(int z) { return z * z; }\n" + + "-: m(x)\n"), + (a) -> evaluateExpression(a, "int", "m(x)", "25"), + (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()), + (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()) + ); + } + + public void testReloadClasspath() { + Function prog = (s) -> String.format( + "package pkg; public class A { public String toString() { return \"%s\"; } }\n", s); + Compiler compiler = new Compiler(); + Path outDir = Paths.get("testClasspathDirectory"); + compiler.compile(outDir, prog.apply("A")); + Path classpath = compiler.getPath(outDir); + test( + (a) -> assertCommand(a, "/classpath " + classpath, + String.format("| Path %s added to classpath\n", classpath)), + (a) -> assertMethod(a, "String foo() { return (new pkg.A()).toString(); }", + "()String", "foo"), + (a) -> assertVariable(a, "String", "v", "foo()", "\"A\""), + (a) -> { + if (!a) compiler.compile(outDir, prog.apply("Aprime")); + assertCommand(a, "/reload", + "| Restarting and restoring state.\n" + + "-: /classpath " + classpath + "\n" + + "-: String foo() { return (new pkg.A()).toString(); }\n" + + "-: String v = foo();\n"); + }, + (a) -> assertCommand(a, "v", "| Variable v of type String has value \"Aprime\"\n"), + (a) -> evaluateExpression(a, "String", "foo()", "\"Aprime\""), + (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"Aprime\"") + ); + } + + public void testReloadDrop() { + test(false, new String[]{"-nostartup"}, + a -> assertVariable(a, "int", "a"), + a -> dropVariable(a, "/dr 1", "int a = 0"), + a -> assertMethod(a, "int b() { return 0; }", "()I", "b"), + a -> dropMethod(a, "/drop b", "b ()I"), + a -> assertClass(a, "class A {}", "class", "A"), + a -> dropClass(a, "/dr A", "class A"), + a -> assertCommand(a, "/reload", + "| Restarting and restoring state.\n" + + "-: int a;\n" + + "-: /drop 1\n" + + "-: int b() { return 0; }\n" + + "-: /drop b\n" + + "-: class A {}\n" + + "-: /drop A\n"), + a -> assertCommandCheckOutput(a, "/vars", assertVariables()), + a -> assertCommandCheckOutput(a, "/methods", assertMethods()), + a -> assertCommandCheckOutput(a, "/classes", assertClasses()), + a -> assertCommandCheckOutput(a, "/imports", assertImports()) + ); + } + + public void testReloadRepeat() { + test(false, new String[]{"-nostartup"}, + (a) -> assertVariable(a, "int", "c", "7", "7"), + (a) -> assertCommand(a, "++c", null), + (a) -> assertCommand(a, "/!", null), + (a) -> assertCommand(a, "/2", null), + (a) -> assertCommand(a, "/-1", null), + (a) -> assertCommand(a, "/reload", + "| Restarting and restoring state.\n" + + "-: int c = 7;\n" + + "-: ++c\n" + + "-: ++c\n" + + "-: ++c\n" + + "-: ++c\n" + ), + (a) -> assertCommand(a, "c", "| Variable c of type int has value 11\n"), + (a) -> assertCommand(a, "$4", "| Variable $4 of type int has value 10\n") + ); + } + + public void testReloadIgnore() { + test(false, new String[]{"-nostartup"}, + (a) -> assertCommand(a, "(-)", null), + (a) -> assertCommand(a, "/list", null), + (a) -> assertCommand(a, "/history", null), + (a) -> assertCommand(a, "/help", null), + (a) -> assertCommand(a, "/vars", null), + (a) -> assertCommand(a, "/save abcd", null), + (a) -> assertCommand(a, "/reload", + "| Restarting and restoring state.\n") + ); + } + + public void testReloadResetRestore() { + test( + (a) -> assertVariable(a, "int", "x", "5", "5"), + (a) -> assertMethod(a, "int m(int z) { return z * z; }", + "(int)int", "m"), + (a) -> evaluateExpression(a, "int", "m(x)", "25"), + (a) -> assertCommand(a, "/reset", "| Resetting state.\n"), + (a) -> assertCommand(a, "/reload restore", + "| Restarting and restoring from previous state.\n" + + "-: int x = 5;\n" + + "-: int m(int z) { return z * z; }\n" + + "-: m(x)\n"), + (a) -> evaluateExpression(a, "int", "m(x)", "25"), + (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()), + (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()) + ); + } + + public void testReloadCrashRestore() { + test( + (a) -> assertVariable(a, "int", "x", "5", "5"), + (a) -> assertMethod(a, "int m(int z) { return z * z; }", + "(int)int", "m"), + (a) -> evaluateExpression(a, "int", "m(x)", "25"), + (a) -> assertCommand(a, "System.exit(1);", + "| State engine terminated.\n" + + "| Restore definitions with: /reload restore\n"), + (a) -> assertCommand(a, "/reload restore", + "| Restarting and restoring from previous state.\n" + + "-: int x = 5;\n" + + "-: int m(int z) { return z * z; }\n" + + "-: m(x)\n"), + (a) -> evaluateExpression(a, "int", "m(x)", "25"), + (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()), + (a) -> assertCommandCheckOutput(a, "/methods", assertMethods()) + ); + } + + public void testReloadExitRestore() { + test(false, new String[]{"-nostartup"}, + (a) -> assertVariable(a, "int", "x", "5", "5"), + (a) -> assertMethod(a, "int m(int z) { return z * z; }", + "(int)int", "m"), + (a) -> evaluateExpression(a, "int", "m(x)", "25") + ); + test(false, new String[]{"-nostartup"}, + (a) -> assertCommand(a, "/reload restore", + "| Restarting and restoring from previous state.\n" + + "-: int x = 5;\n" + + "-: int m(int z) { return z * z; }\n" + + "-: m(x)\n"), + (a) -> evaluateExpression(a, "int", "m(x)", "25") + ); + } +} From 6d4c26ee9ca224c4834d0cb72943ba7ad62619f3 Mon Sep 17 00:00:00 2001 From: Shinya Yoshida Date: Mon, 11 Jan 2016 19:32:36 -0800 Subject: [PATCH 051/109] 8146368: JShell: couldn't smash the error when it's Japanese locale Reviewed-by: rfield --- .../jdk/internal/jshell/tool/JShellTool.java | 2 +- .../share/classes/jdk/jshell/OuterWrap.java | 8 ++-- .../share/classes/jdk/jshell/TaskFactory.java | 7 ++- .../share/classes/jdk/jshell/Unit.java | 3 +- .../share/classes/jdk/jshell/Util.java | 3 ++ .../jshell/T8146368/JShellTest8146368.java | 42 ++++++++++++++++++ .../T8146368/JShellToolTest8146368.java | 43 +++++++++++++++++++ 7 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 langtools/test/jdk/jshell/T8146368/JShellTest8146368.java create mode 100644 langtools/test/jdk/jshell/T8146368/JShellToolTest8146368.java diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index 2c027fda9a4..180fc4d8206 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -1468,7 +1468,7 @@ public class JShellTool { } } - for (String line : diag.getMessage(null).split("\\r?\\n")) { + for (String line : diag.getMessage(null).split("\\r?\\n")) { // TODO: Internationalize if (!line.trim().startsWith("location:")) { hard("%s%s", padding, line); } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java index 8892b54c964..89e2463f4a8 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrap.java @@ -182,9 +182,9 @@ final class OuterWrap implements GeneralWrap { return null; } - @Override - public String toString() { - return "WrappedDiagnostic(" + getMessage(null) + ":" + getPosition() + ")"; - } + @Override + public String toString() { + return "WrappedDiagnostic(" + getMessage(null) + ":" + getPosition() + ")"; + } } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java index 93f52e2e93b..0582fd66cae 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java @@ -33,7 +33,6 @@ import com.sun.tools.javac.api.JavacTool; import com.sun.tools.javac.util.Context; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; @@ -395,7 +394,7 @@ class TaskFactory { LinkedHashMap diagMap = new LinkedHashMap<>(); for (Diagnostic in : diagnostics.getDiagnostics()) { Diag d = diag(in); - String uniqueKey = d.getCode() + ":" + d.getPosition() + ":" + d.getMessage(null); + String uniqueKey = d.getCode() + ":" + d.getPosition() + ":" + d.getMessage(PARSED_LOCALE); diagMap.put(uniqueKey, d); } diags = new DiagList(diagMap.values()); @@ -410,7 +409,7 @@ class TaskFactory { String shortErrorMessage() { StringBuilder sb = new StringBuilder(); for (Diag diag : getDiagnostics()) { - for (String line : diag.getMessage(null).split("\\r?\\n")) { + for (String line : diag.getMessage(PARSED_LOCALE).split("\\r?\\n")) { if (!line.trim().startsWith("location:")) { sb.append(line); } @@ -422,7 +421,7 @@ class TaskFactory { void debugPrintDiagnostics(String src) { for (Diag diag : getDiagnostics()) { state.debug(DBG_GEN, "ERROR --\n"); - for (String line : diag.getMessage(null).split("\\r?\\n")) { + for (String line : diag.getMessage(PARSED_LOCALE).split("\\r?\\n")) { if (!line.trim().startsWith("location:")) { state.debug(DBG_GEN, "%s\n", line); } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java index 6233afe12fa..774f25663a1 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java @@ -50,6 +50,7 @@ import static jdk.jshell.Snippet.Status.RECOVERABLE_DEFINED; import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED; import static jdk.jshell.Snippet.Status.REJECTED; import static jdk.jshell.Snippet.Status.VALID; +import static jdk.jshell.Util.PARSED_LOCALE; import static jdk.jshell.Util.expunge; /** @@ -456,7 +457,7 @@ final class Unit { for (Diag diag : diags) { if (diag.isError()) { if (diag.isResolutionError()) { - String m = diag.getMessage(null); + String m = diag.getMessage(PARSED_LOCALE); int symPos = m.indexOf(RESOLVE_ERROR_SYMBOL); if (symPos >= 0) { m = m.substring(symPos + RESOLVE_ERROR_SYMBOL.length()); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java index 9ee8a826dbb..8cc42150790 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Util.java @@ -25,6 +25,7 @@ package jdk.jshell; +import java.util.Locale; import java.util.stream.Stream; import java.util.stream.StreamSupport; import javax.lang.model.element.Name; @@ -40,6 +41,8 @@ class Util { static final String REPL_CLASS_PREFIX = "$REPL"; static final String REPL_DOESNOTMATTER_CLASS_NAME = REPL_CLASS_PREFIX+"00DOESNOTMATTER"; + static final Locale PARSED_LOCALE = Locale.ROOT; + static boolean isDoIt(Name name) { return isDoIt(name.toString()); } diff --git a/langtools/test/jdk/jshell/T8146368/JShellTest8146368.java b/langtools/test/jdk/jshell/T8146368/JShellTest8146368.java new file mode 100644 index 00000000000..8cf92545bb5 --- /dev/null +++ b/langtools/test/jdk/jshell/T8146368/JShellTest8146368.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8146368 + * @summary Test Smashing Error when user language is Japanese + * @library /tools/lib /jdk/jshell + * @build KullaTesting + * @run testng/othervm -Duser.language=ja JShellTest8146368 + */ + +import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED; +import org.testng.annotations.Test; + +@Test +public class JShellTest8146368 extends KullaTesting { + public void test() { + assertEval("class A extends B {}", added(RECOVERABLE_NOT_DEFINED)); + assertEval("und m() { return new und(); }", added(RECOVERABLE_NOT_DEFINED)); + } +} diff --git a/langtools/test/jdk/jshell/T8146368/JShellToolTest8146368.java b/langtools/test/jdk/jshell/T8146368/JShellToolTest8146368.java new file mode 100644 index 00000000000..3e3273add7c --- /dev/null +++ b/langtools/test/jdk/jshell/T8146368/JShellToolTest8146368.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8146368 + * @summary Test Smashing Error when user language is Japanese + * @library /tools/lib /jdk/jshell + * @build ReplToolTesting + * @run testng/othervm -Duser.language=ja JShellToolTest8146368 + */ + +import org.testng.annotations.Test; + +@Test +public class JShellToolTest8146368 extends ReplToolTesting { + public void test() { + test( + a -> assertCommand(a, "class A extends B {}", "| Added class A, however, it cannot be referenced until class B is declared\n"), + a -> assertCommand(a, "und m() { return new und(); }", "| Added method m(), however, it cannot be referenced until class und is declared\n") + ); + } +} From ff26874c25073d3915d80f3e46ac7bb9fa911f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Tue, 12 Jan 2016 15:38:07 +0100 Subject: [PATCH 052/109] 8146888: Wrong license headers in test files Reviewed-by: mhaupt, jlaskey --- nashorn/test/script/nosecurity/treeapi/for.js | 32 +++++++++---------- .../test/script/nosecurity/treeapi/forin.js | 32 +++++++++---------- .../script/nosecurity/treeapi/functionCall.js | 32 +++++++++---------- .../nosecurity/treeapi/functionDeclaration.js | 30 ++++++++--------- .../script/nosecurity/treeapi/functionExpr.js | 30 ++++++++--------- .../script/nosecurity/treeapi/identifier.js | 30 ++++++++--------- nashorn/test/script/nosecurity/treeapi/if.js | 30 ++++++++--------- .../script/nosecurity/treeapi/instanceof.js | 30 ++++++++--------- 8 files changed, 123 insertions(+), 123 deletions(-) diff --git a/nashorn/test/script/nosecurity/treeapi/for.js b/nashorn/test/script/nosecurity/treeapi/for.js index 97e97d24516..ed674618476 100644 --- a/nashorn/test/script/nosecurity/treeapi/for.js +++ b/nashorn/test/script/nosecurity/treeapi/for.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ @@ -47,4 +47,4 @@ parse("forloop.js", code, "-nse", new (Java.extend(visitor, { visitForLoop : function (node, obj) { obj.push(convert(node)) } -}))) \ No newline at end of file +}))) diff --git a/nashorn/test/script/nosecurity/treeapi/forin.js b/nashorn/test/script/nosecurity/treeapi/forin.js index 2c3f5067569..a8f467a22ac 100644 --- a/nashorn/test/script/nosecurity/treeapi/forin.js +++ b/nashorn/test/script/nosecurity/treeapi/forin.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ @@ -45,4 +45,4 @@ parse("forinloop.js", code, "-nse", new (Java.extend(visitor, { visitForInLoop : function (node, obj) { obj.push(convert(node)) } -}))) \ No newline at end of file +}))) diff --git a/nashorn/test/script/nosecurity/treeapi/functionCall.js b/nashorn/test/script/nosecurity/treeapi/functionCall.js index c15667106bd..72c752dfa00 100644 --- a/nashorn/test/script/nosecurity/treeapi/functionCall.js +++ b/nashorn/test/script/nosecurity/treeapi/functionCall.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ @@ -51,4 +51,4 @@ parse("functionCall.js", code, "-nse", new (Java.extend(visitor, { visitFunctionCall : function (node, obj) { obj.push(convert(node)) } -}))) \ No newline at end of file +}))) diff --git a/nashorn/test/script/nosecurity/treeapi/functionDeclaration.js b/nashorn/test/script/nosecurity/treeapi/functionDeclaration.js index 0ad4c19b7a2..c27375740b7 100644 --- a/nashorn/test/script/nosecurity/treeapi/functionDeclaration.js +++ b/nashorn/test/script/nosecurity/treeapi/functionDeclaration.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ diff --git a/nashorn/test/script/nosecurity/treeapi/functionExpr.js b/nashorn/test/script/nosecurity/treeapi/functionExpr.js index 0a16d38dd24..c70b3264ea1 100644 --- a/nashorn/test/script/nosecurity/treeapi/functionExpr.js +++ b/nashorn/test/script/nosecurity/treeapi/functionExpr.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ diff --git a/nashorn/test/script/nosecurity/treeapi/identifier.js b/nashorn/test/script/nosecurity/treeapi/identifier.js index 137fe5a5abe..0aa27c9471e 100644 --- a/nashorn/test/script/nosecurity/treeapi/identifier.js +++ b/nashorn/test/script/nosecurity/treeapi/identifier.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ diff --git a/nashorn/test/script/nosecurity/treeapi/if.js b/nashorn/test/script/nosecurity/treeapi/if.js index 407dfee4f9b..e62f36056b1 100644 --- a/nashorn/test/script/nosecurity/treeapi/if.js +++ b/nashorn/test/script/nosecurity/treeapi/if.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ diff --git a/nashorn/test/script/nosecurity/treeapi/instanceof.js b/nashorn/test/script/nosecurity/treeapi/instanceof.js index ccf4a377f10..c80abf62993 100644 --- a/nashorn/test/script/nosecurity/treeapi/instanceof.js +++ b/nashorn/test/script/nosecurity/treeapi/instanceof.js @@ -1,23 +1,23 @@ /* - * Copyright (c) 2014, Or1cle 1nd/or its 1ffili1tes. 1ll rights reserved. - * DO NOT 1LTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HE1DER. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This code is free softw1re; you c1n redistri2ute it 1nd/or modify it - * under the terms of the GNU Gener1l Pu2lic License version 2 only, 1s - * pu2lished 2y the Free Softw1re Found1tion. + * 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 distri2uted in the hope th1t it will 2e useful, 2ut WITHOUT - * 1NY W1RR1NTY; without even the implied w1rr1nty of MERCH1NT12ILITY or - * FITNESS FOR 1 P1RTICUL1R PURPOSE. See the GNU Gener1l Pu2lic License - * version 2 for more det1ils (1 copy is included in the LICENSE file th1t - * 1ccomp1nied 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 h1ve received 1 copy of the GNU Gener1l Pu2lic License version - * 2 1long with this work; if not, write to the Free Softw1re Found1tion, - * Inc., 51 Fr1nklin St, Fifth Floor, 2oston, M1 02110-1301 US1. + * 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. * - * Ple1se cont1ct Or1cle, 500 Or1cle P1rkw1y, Redwood Shores, C1 94065 US1 - * or visit www.or1cle.com if you need 1ddition1l inform1tion or h1ve 1ny + * 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. */ From dd9c62130ff71e16b62ad89e0d126d1e7b1722c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Tue, 12 Jan 2016 16:30:10 +0100 Subject: [PATCH 053/109] 8143896: java.lang.Long is implicitly converted to double Reviewed-by: mhaupt, jlaskey --- .../nashorn/internal/objects/NativeArray.java | 33 +- .../nashorn/internal/objects/NativeDate.java | 5 +- .../internal/objects/NativeNumber.java | 3 +- .../objects/NativeRegExpExecResult.java | 2 +- .../internal/objects/NativeString.java | 6 +- .../jdk/nashorn/internal/runtime/JSType.java | 34 +- .../runtime/arrays/ContinuousArrayData.java | 16 +- .../internal/runtime/arrays/IntArrayData.java | 7 +- .../runtime/arrays/NumberArrayData.java | 6 +- .../runtime/arrays/ObjectArrayData.java | 8 +- .../runtime/linker/NashornGuards.java | 26 +- .../linker/NashornPrimitiveLinker.java | 5 +- nashorn/test/script/basic/JDK-8030200.js | 2 +- .../test/script/basic/JDK-8079145.js.EXPECTED | 16 +- nashorn/test/script/basic/JDK-8143896.js | 107 + nashorn/test/script/nosecurity/parserapi.js | 91 +- .../script/nosecurity/parserapi.js.EXPECTED | 1875 +++++++++-------- 17 files changed, 1236 insertions(+), 1006 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8143896.js diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java index 5151e8bf419..4441dd8bed8 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java @@ -284,8 +284,8 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin // Step 3c and 3d - get new length and convert to long final long newLen = NativeArray.validLength(newLenDesc.getValue()); - // Step 3e - newLenDesc.setValue(newLen); + // Step 3e - note that we need to convert to int or double as long is not considered a JS number type anymore + newLenDesc.setValue(JSType.isRepresentableAsInt(newLen) ? Integer.valueOf((int) newLen) : Double.valueOf((double) newLen)); // Step 3f // increasing array length - just need to set new length value (and attributes if any) and return @@ -908,21 +908,6 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin return getContinuousNonEmptyArrayDataCCE(self, IntElements.class).fastPopInt(); } - /** - * Specialization of pop for ContinuousArrayData - * - * Primitive specialization, {@link LinkLogic} - * - * @param self self reference - * @return element popped - * @throws ClassCastException if array is empty, facilitating Undefined return value - */ - @SpecializedFunction(name="pop", linkLogic=PopLinkLogic.class) - public static long popLong(final Object self) { - //must be non empty Int or LongArrayData - return getContinuousNonEmptyArrayDataCCE(self, IntOrLongElements.class).fastPopLong(); - } - /** * Specialization of pop for ContinuousArrayData * @@ -997,7 +982,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @return array length after push */ @SpecializedFunction(linkLogic=PushLinkLogic.class) - public static long push(final Object self, final int arg) { + public static double push(final Object self, final int arg) { return getContinuousArrayDataCCE(self, Integer.class).fastPush(arg); } @@ -1011,7 +996,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @return array length after push */ @SpecializedFunction(linkLogic=PushLinkLogic.class) - public static long push(final Object self, final long arg) { + public static double push(final Object self, final long arg) { return getContinuousArrayDataCCE(self, Long.class).fastPush(arg); } @@ -1025,7 +1010,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @return array length after push */ @SpecializedFunction(linkLogic=PushLinkLogic.class) - public static long push(final Object self, final double arg) { + public static double push(final Object self, final double arg) { return getContinuousArrayDataCCE(self, Double.class).fastPush(arg); } @@ -1039,7 +1024,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @return array length after push */ @SpecializedFunction(name="push", linkLogic=PushLinkLogic.class) - public static long pushObject(final Object self, final Object arg) { + public static double pushObject(final Object self, final Object arg) { return getContinuousArrayDataCCE(self, Object.class).fastPush(arg); } @@ -1081,7 +1066,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @return array after pushes */ @SpecializedFunction - public static long push(final Object self, final Object arg) { + public static double push(final Object self, final Object arg) { try { final ScriptObject sobj = (ScriptObject)self; final ArrayData arrayData = sobj.getArray(); @@ -1498,7 +1483,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @return index of element, or -1 if not found */ @Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1) - public static long indexOf(final Object self, final Object searchElement, final Object fromIndex) { + public static double indexOf(final Object self, final Object searchElement, final Object fromIndex) { try { final ScriptObject sobj = (ScriptObject)Global.toObject(self); final long len = JSType.toUint32(sobj.getLength()); @@ -1534,7 +1519,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @return index of element, or -1 if not found */ @Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1) - public static long lastIndexOf(final Object self, final Object... args) { + public static double lastIndexOf(final Object self, final Object... args) { try { final ScriptObject sobj = (ScriptObject)Global.toObject(self); final long len = JSType.toUint32(sobj.getLength()); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDate.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDate.java index 3d3f24899de..78dd464be9a 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDate.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDate.java @@ -256,8 +256,9 @@ public final class NativeDate extends ScriptObject { * @return a Date that points to the current moment in time */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) - public static long now(final Object self) { - return System.currentTimeMillis(); + public static double now(final Object self) { + // convert to double as long does not represent the primitive JS number type + return (double) System.currentTimeMillis(); } /** diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeNumber.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeNumber.java index 84513b5b511..c52e1b35fe8 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeNumber.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeNumber.java @@ -48,6 +48,7 @@ import jdk.nashorn.internal.runtime.PropertyMap; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.doubleconv.DoubleConversion; +import jdk.nashorn.internal.runtime.linker.NashornGuards; import jdk.nashorn.internal.runtime.linker.PrimitiveLookup; /** @@ -315,7 +316,7 @@ public final class NativeNumber extends ScriptObject { * @return Link to be invoked at call site. */ public static GuardedInvocation lookupPrimitive(final LinkRequest request, final Object receiver) { - return PrimitiveLookup.lookupPrimitive(request, Number.class, new NativeNumber(((Number)receiver).doubleValue()), WRAPFILTER, PROTOFILTER); + return PrimitiveLookup.lookupPrimitive(request, NashornGuards.getNumberGuard(), new NativeNumber(((Number)receiver).doubleValue()), WRAPFILTER, PROTOFILTER); } @SuppressWarnings("unused") diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeRegExpExecResult.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeRegExpExecResult.java index 0df0eca4a3c..1ec733cf32e 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeRegExpExecResult.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeRegExpExecResult.java @@ -74,7 +74,7 @@ public final class NativeRegExpExecResult extends ScriptObject { @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE) public static Object length(final Object self) { if (self instanceof ScriptObject) { - return JSType.toUint32(((ScriptObject)self).getArray().length()); + return (double) JSType.toUint32(((ScriptObject)self).getArray().length()); } return 0; diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java index 52e326a3fae..0b7869b8844 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java @@ -146,7 +146,7 @@ public final class NativeString extends ScriptObject implements OptimisticBuilti if (returnType == Object.class && JSType.isString(self)) { try { - return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getInstanceOf2Guard(String.class, ConsString.class)); + return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getStringGuard()); } catch (final LookupException e) { //empty. Shouldn't happen. Fall back to super } @@ -1235,8 +1235,8 @@ public final class NativeString extends ScriptObject implements OptimisticBuilti * @return Link to be invoked at call site. */ public static GuardedInvocation lookupPrimitive(final LinkRequest request, final Object receiver) { - final MethodHandle guard = NashornGuards.getInstanceOf2Guard(String.class, ConsString.class); - return PrimitiveLookup.lookupPrimitive(request, guard, new NativeString((CharSequence)receiver), WRAPFILTER, PROTOFILTER); + return PrimitiveLookup.lookupPrimitive(request, NashornGuards.getStringGuard(), + new NativeString((CharSequence)receiver), WRAPFILTER, PROTOFILTER); } @SuppressWarnings("unused") diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java index 2ecd40cc577..b791acd92d1 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java @@ -178,6 +178,12 @@ public enum JSType { /** Method handle for void returns. */ public static final Call VOID_RETURN = staticCall(JSTYPE_LOOKUP, JSType.class, "voidReturn", void.class); + /** Method handle for isString method */ + public static final Call IS_STRING = staticCall(JSTYPE_LOOKUP, JSType.class, "isString", boolean.class, Object.class); + + /** Method handle for isNumber method */ + public static final Call IS_NUMBER = staticCall(JSTYPE_LOOKUP, JSType.class, "isNumber", boolean.class, Object.class); + /** * The list of available accessor types in width order. This order is used for type guesses narrow{@literal ->} wide * in the dual--fields world @@ -280,7 +286,7 @@ public enum JSType { return JSType.STRING; } - if (obj instanceof Number) { + if (isNumber(obj)) { return JSType.NUMBER; } @@ -322,7 +328,7 @@ public enum JSType { return JSType.STRING; } - if (obj instanceof Number) { + if (isNumber(obj)) { return JSType.NUMBER; } @@ -434,7 +440,7 @@ public enum JSType { return obj == null || obj == ScriptRuntime.UNDEFINED || isString(obj) || - obj instanceof Number || + isNumber(obj) || obj instanceof Boolean || obj instanceof Symbol; } @@ -609,6 +615,24 @@ public enum JSType { return obj instanceof String || obj instanceof ConsString; } + /** + * Returns true if object represents a primitive JavaScript number value. Note that we only + * treat wrapper objects of Java primitive number types as objects that can be fully represented + * as JavaScript numbers (doubles). This means we exclude {@code long} and special purpose Number + * instances such as {@link java.util.concurrent.atomic.AtomicInteger}, as well as arbitrary precision + * numbers such as {@link java.math.BigInteger}. + * + * @param obj the object + * @return true if the object represents a primitive JavaScript number value. + */ + public static boolean isNumber(final Object obj) { + if (obj != null) { + final Class c = obj.getClass(); + return c == Integer.class || c == Double.class || c == Float.class || c == Short.class || c == Byte.class; + } + return false; + } + /** * JavaScript compliant conversion of integer to String * @@ -761,7 +785,7 @@ public enum JSType { if (obj instanceof Double) { return (Double)obj; } - if (obj instanceof Number) { + if (isNumber(obj)) { return ((Number)obj).doubleValue(); } return Double.NaN; @@ -1337,7 +1361,7 @@ public enum JSType { return obj.toString(); } - if (obj instanceof Number) { + if (isNumber(obj)) { return toString(((Number)obj).doubleValue()); } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java index 81146a39383..f891afad46e 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java @@ -287,7 +287,7 @@ public abstract class ContinuousArrayData extends ArrayData { * @param arg argument * @return new array length */ - public long fastPush(final int arg) { + public double fastPush(final int arg) { throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink } @@ -296,7 +296,7 @@ public abstract class ContinuousArrayData extends ArrayData { * @param arg argument * @return new array length */ - public long fastPush(final long arg) { + public double fastPush(final long arg) { throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink } @@ -305,7 +305,7 @@ public abstract class ContinuousArrayData extends ArrayData { * @param arg argument * @return new array length */ - public long fastPush(final double arg) { + public double fastPush(final double arg) { throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink } @@ -314,7 +314,7 @@ public abstract class ContinuousArrayData extends ArrayData { * @param arg argument * @return new array length */ - public long fastPush(final Object arg) { + public double fastPush(final Object arg) { throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink } @@ -326,14 +326,6 @@ public abstract class ContinuousArrayData extends ArrayData { throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink } - /** - * Specialization - fast pop implementation - * @return element value - */ - public long fastPopLong() { - throw new ClassCastException(String.valueOf(getClass())); //type is wrong, relink - } - /** * Specialization - fast pop implementation * @return element value diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java index b7837bbaeaa..ef899fc691c 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java @@ -340,7 +340,7 @@ final class IntArrayData extends ContinuousArrayData implements IntElements { } @Override - public long fastPush(final int arg) { + public double fastPush(final int arg) { final int len = (int)length(); if (len == array.length) { array = Arrays.copyOf(array, nextSize(len)); @@ -361,11 +361,6 @@ final class IntArrayData extends ContinuousArrayData implements IntElements { return elem; } - @Override - public long fastPopLong() { - return fastPopInt(); - } - @Override public double fastPopDouble() { return fastPopInt(); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java index 5f70751e41f..73fcb083d72 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java @@ -303,17 +303,17 @@ final class NumberArrayData extends ContinuousArrayData implements NumericElemen } @Override - public long fastPush(final int arg) { + public double fastPush(final int arg) { return fastPush((double)arg); } @Override - public long fastPush(final long arg) { + public double fastPush(final long arg) { return fastPush((double)arg); } @Override - public long fastPush(final double arg) { + public double fastPush(final double arg) { final int len = (int)length(); if (len == array.length) { //note that fastpush never creates spares arrays, there is nothing to gain by that - it will just use even more memory diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java index 27b7d91772f..cb99de829f4 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java @@ -236,22 +236,22 @@ final class ObjectArrayData extends ContinuousArrayData implements AnyElements { } @Override - public long fastPush(final int arg) { + public double fastPush(final int arg) { return fastPush((Object)arg); } @Override - public long fastPush(final long arg) { + public double fastPush(final long arg) { return fastPush((Object)arg); } @Override - public long fastPush(final double arg) { + public double fastPush(final double arg) { return fastPush((Object)arg); } @Override - public long fastPush(final Object arg) { + public double fastPush(final Object arg) { final int len = (int)length(); if (len == array.length) { array = Arrays.copyOf(array, nextSize(len)); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java index a3cbe3480c9..32368c07a06 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java @@ -34,6 +34,7 @@ import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.linker.LinkRequest; import jdk.nashorn.api.scripting.JSObject; import jdk.nashorn.internal.objects.Global; +import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.Property; import jdk.nashorn.internal.runtime.PropertyMap; import jdk.nashorn.internal.runtime.ScriptFunction; @@ -46,10 +47,9 @@ import jdk.nashorn.internal.runtime.options.Options; public final class NashornGuards { private static final MethodHandle IS_MAP = findOwnMH("isMap", boolean.class, ScriptObject.class, PropertyMap.class); private static final MethodHandle IS_MAP_SCRIPTOBJECT = findOwnMH("isMap", boolean.class, Object.class, PropertyMap.class); - private static final MethodHandle IS_INSTANCEOF_2 = findOwnMH("isInstanceOf2", boolean.class, Object.class, Class.class, Class.class); private static final MethodHandle IS_SCRIPTOBJECT = findOwnMH("isScriptObject", boolean.class, Object.class); private static final MethodHandle IS_NOT_JSOBJECT = findOwnMH("isNotJSObject", boolean.class, Object.class); - private static final MethodHandle SAME_OBJECT = findOwnMH("sameObject", boolean.class, Object.class, WeakReference.class); + private static final MethodHandle SAME_OBJECT = findOwnMH("sameObject", boolean.class, Object.class, WeakReference.class); //TODO - maybe put this back in ScriptFunction instead of the ClassCastException.class relinkage //private static final MethodHandle IS_SCRIPTFUNCTION = findOwnMH("isScriptFunction", boolean.class, Object.class); @@ -165,14 +165,21 @@ public final class NashornGuards { } /** - * Get a guard that checks if in item is an instance of either of two classes. + * Get a guard that checks if in item is a JS string. * - * @param class1 the first class - * @param class2 the second class * @return method handle for guard */ - public static MethodHandle getInstanceOf2Guard(final Class class1, final Class class2) { - return MH.insertArguments(IS_INSTANCEOF_2, 1, class1, class2); + public static MethodHandle getStringGuard() { + return JSType.IS_STRING.methodHandle(); + } + + /** + * Get a guard that checks if in item is a JS number. + * + * @return method handle for guard + */ + public static MethodHandle getNumberGuard() { + return JSType.IS_NUMBER.methodHandle(); } /** @@ -223,11 +230,6 @@ public final class NashornGuards { return self == ref.get(); } - @SuppressWarnings("unused") - private static boolean isInstanceOf2(final Object self, final Class class1, final Class class2) { - return class1.isInstance(self) || class2.isInstance(self); - } - @SuppressWarnings("unused") private static boolean isScriptFunction(final Object self) { return self instanceof ScriptFunction; diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java index c73d24fa4cb..830c03445c7 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java @@ -57,7 +57,8 @@ final class NashornPrimitiveLinker implements TypeBasedGuardingDynamicLinker, Gu } private static boolean canLinkTypeStatic(final Class type) { - return type == String.class || type == Boolean.class || type == ConsString.class || Number.class.isAssignableFrom(type); + return type == String.class || type == Boolean.class || type == ConsString.class || type == Integer.class + || type == Double.class || type == Float.class || type == Short.class || type == Byte.class; } @Override @@ -167,7 +168,7 @@ final class NashornPrimitiveLinker implements TypeBasedGuardingDynamicLinker, Gu @SuppressWarnings("unused") private static boolean isJavaScriptPrimitive(final Object o) { - return JSType.isString(o) || o instanceof Boolean || o instanceof Number || o == null; + return JSType.isString(o) || o instanceof Boolean || JSType.isNumber(o) || o == null; } private static final MethodHandle GUARD_PRIMITIVE = findOwnMH("isJavaScriptPrimitive", boolean.class, Object.class); diff --git a/nashorn/test/script/basic/JDK-8030200.js b/nashorn/test/script/basic/JDK-8030200.js index a62fa498723..5803d54c579 100644 --- a/nashorn/test/script/basic/JDK-8030200.js +++ b/nashorn/test/script/basic/JDK-8030200.js @@ -33,4 +33,4 @@ print(n); var s = n.toString(5); var m = parseInt(s, 5); print(m === n); -print(n); +print(m); diff --git a/nashorn/test/script/basic/JDK-8079145.js.EXPECTED b/nashorn/test/script/basic/JDK-8079145.js.EXPECTED index 6b84c5e66b5..aef418432e2 100644 --- a/nashorn/test/script/basic/JDK-8079145.js.EXPECTED +++ b/nashorn/test/script/basic/JDK-8079145.js.EXPECTED @@ -5,8 +5,8 @@ int array: check widen for false [class java.lang.Boolean] int array: check widen for true [class java.lang.Boolean] int array: check widen for 34 [class java.lang.Byte] int array: check widen for 344454 [class java.lang.Integer] -int array: check widen for 454545 [class java.lang.Long] -int array: check widen for 2147483648 [class java.lang.Long] +int array: check widen for 454545 +int array: check widen for 2147483648 int array: check widen for 34.29999923706055 [class java.lang.Float] int array: check widen for 3.141592653589793 [class java.lang.Double] int array: check widen for s @@ -17,8 +17,8 @@ long array: check widen for false [class java.lang.Boolean] long array: check widen for true [class java.lang.Boolean] long array: check widen for 34 [class java.lang.Byte] long array: check widen for 344454 [class java.lang.Integer] -long array: check widen for 454545 [class java.lang.Long] -long array: check widen for 2147483648 [class java.lang.Long] +long array: check widen for 454545 +long array: check widen for 2147483648 long array: check widen for 34.29999923706055 [class java.lang.Float] long array: check widen for 3.141592653589793 [class java.lang.Double] long array: check widen for s @@ -29,8 +29,8 @@ number array: check widen for false [class java.lang.Boolean] number array: check widen for true [class java.lang.Boolean] number array: check widen for 34 [class java.lang.Byte] number array: check widen for 344454 [class java.lang.Integer] -number array: check widen for 454545 [class java.lang.Long] -number array: check widen for 2147483648 [class java.lang.Long] +number array: check widen for 454545 +number array: check widen for 2147483648 number array: check widen for 34.29999923706055 [class java.lang.Float] number array: check widen for 3.141592653589793 [class java.lang.Double] number array: check widen for s @@ -41,8 +41,8 @@ object array: check widen for false [class java.lang.Boolean] object array: check widen for true [class java.lang.Boolean] object array: check widen for 34 [class java.lang.Byte] object array: check widen for 344454 [class java.lang.Integer] -object array: check widen for 454545 [class java.lang.Long] -object array: check widen for 2147483648 [class java.lang.Long] +object array: check widen for 454545 +object array: check widen for 2147483648 object array: check widen for 34.29999923706055 [class java.lang.Float] object array: check widen for 3.141592653589793 [class java.lang.Double] object array: check widen for s diff --git a/nashorn/test/script/basic/JDK-8143896.js b/nashorn/test/script/basic/JDK-8143896.js new file mode 100644 index 00000000000..84bcd669018 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8143896.js @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8143896: java.lang.Long is implicitly converted to double + * + * @test + * @run + */ + +Assert.assertTrue(java.lang.Long.valueOf("301077366599181567").toString() === "301077366599181567"); +Assert.assertTrue(java.lang.Long.valueOf("-301077366599181567").toString() === "-301077366599181567"); +Assert.assertTrue(java.lang.Long.valueOf("301077366599181567") == 301077366599181567); +Assert.assertFalse(java.lang.Long.valueOf("301077366599181567") === 301077366599181567); + +Assert.assertTrue(new java.math.BigInteger("301077366599181567").toString() === "301077366599181567"); +Assert.assertTrue(new java.math.BigInteger("-301077366599181567").toString() === "-301077366599181567"); +Assert.assertTrue(new java.math.BigInteger("301077366599181567") == 301077366599181567); +Assert.assertFalse(new java.math.BigInteger("301077366599181567") === 301077366599181567); + + +var n = new java.lang.Byte("123"); +Assert.assertTrue(typeof n === "number"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertTrue(n === 123); + +n = new java.lang.Short("123"); +Assert.assertTrue(typeof n === "number"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertTrue(n === 123); + +n = new java.lang.Integer("123"); +Assert.assertTrue(typeof n === "number"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertTrue(n === 123); + +n = new java.lang.Float("123"); +Assert.assertTrue(typeof n === "number"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertTrue(n === 123); + +n = new java.lang.Double("123"); +Assert.assertTrue(typeof n === "number"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertTrue(n === 123); + +n = new java.lang.Long("123"); +Assert.assertTrue(typeof n === "object"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertFalse(n === 123); + +n = new java.util.concurrent.atomic.DoubleAdder(); +n.add("123"); +Assert.assertTrue(typeof n === "object"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertFalse(n === 123); + +n = new java.util.concurrent.atomic.AtomicInteger(123); +Assert.assertTrue(typeof n === "object"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertFalse(n === 123); + +n = new java.util.concurrent.atomic.AtomicLong(123); +Assert.assertTrue(typeof n === "object"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertFalse(n === 123); + +n = new java.math.BigInteger("123"); +Assert.assertTrue(typeof n === "object"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertFalse(n === 123); + +n = new java.math.BigDecimal("123"); +Assert.assertTrue(typeof n === "object"); +Assert.assertTrue(n + 1 === 124); +Assert.assertTrue(n == 123); +Assert.assertFalse(n === 123); diff --git a/nashorn/test/script/nosecurity/parserapi.js b/nashorn/test/script/nosecurity/parserapi.js index 22b1fd2822b..3c1086f4ef3 100644 --- a/nashorn/test/script/nosecurity/parserapi.js +++ b/nashorn/test/script/nosecurity/parserapi.js @@ -30,8 +30,8 @@ */ function Parser() { - // create nashorn parser - this._parser = Parser.create(); + // create nashorn parser + this._parser = Parser.create(); } // Java types used @@ -54,59 +54,60 @@ Parser.create = function() { // convert Nashorn parser Tree, Diagnostic as a script friendly object Parser.prototype.convert = function(tree) { - if (!tree || typeof tree != 'object') { + if (!tree || typeof tree != 'object' || tree instanceof java.lang.Long) { return tree; } var obj = Object.bindProperties({}, tree); var result = {}; for (var i in obj) { - var val = obj[i]; - if (val instanceof Parser.Tree) { - result[i] = this.convert(val); - } else if (val instanceof Parser.List) { - var arr = new Array(val.size()); - for (var j in val) { - arr[j] = this.convert(val[j]); - } - - result[i] = arr; - } else { - switch (typeof val) { - case 'number': - case 'string': - case 'boolean': - result[i] = String(val); - default: - if (val instanceof Parser.Enum) { - result[i] = String(val); - } - } - } - } - return result; + var val = obj[i]; + if (val instanceof Parser.Tree) { + result[i] = this.convert(val); + } else if (val instanceof Parser.List) { + var arr = new Array(val.size()); + for (var j in val) { + arr[j] = this.convert(val[j]); + } + + result[i] = arr; + } else { + switch (typeof val) { + case 'number': + case 'string': + case 'boolean': + result[i] = String(val); + break; + default: + if (val instanceof java.lang.Long || val instanceof Parser.Enum) { + result[i] = String(val); + } + } + } + } + return result; } function processFiles(subdir) { - var File = Java.type("java.io.File"); - var files = new File(__DIR__ + subdir).listFiles(); - java.util.Arrays.sort(files); - for each (var file in files) { - if (file.name.endsWith(".js")) { - var script = readFully(file); - var parser = new Parser(); - var tree = parser.parse(subdir + "/" + file.name, script, - function(diagnostic) { - print(JSON.stringify(parser.convert(diagnostic), null, 2).replace(/\\r/g, '')); - print(","); - }); + var File = Java.type("java.io.File"); + var files = new File(__DIR__ + subdir).listFiles(); + java.util.Arrays.sort(files); + for each (var file in files) { + if (file.name.endsWith(".js")) { + var script = readFully(file); + var parser = new Parser(); + var tree = parser.parse(subdir + "/" + file.name, script, + function(diagnostic) { + print(JSON.stringify(parser.convert(diagnostic), null, 2).replace(/\\r/g, '')); + print(","); + }); - if (tree != null) { - print(JSON.stringify(tree, null, 2)); - print(","); - } - } - } + if (tree != null) { + print(JSON.stringify(tree, null, 2)); + print(","); + } + } + } } // parse files in parsertests directory diff --git a/nashorn/test/script/nosecurity/parserapi.js.EXPECTED b/nashorn/test/script/nosecurity/parserapi.js.EXPECTED index ebd72ba610b..eabe2d4cae8 100644 --- a/nashorn/test/script/nosecurity/parserapi.js.EXPECTED +++ b/nashorn/test/script/nosecurity/parserapi.js.EXPECTED @@ -1,4 +1,4 @@ -[ +[ { "endPosition": "1113", "kind": "COMPILATION_UNIT", @@ -132,8 +132,8 @@ "sourceName": "parsertests/array_literal.js", "strict": "false", "startPosition": "1113" -} -, +} +, { "endPosition": "1126", "kind": "COMPILATION_UNIT", @@ -406,8 +406,8 @@ "sourceName": "parsertests/assignmentExpr.js", "strict": "false", "startPosition": "1126" -} -, +} +, { "endPosition": "1116", "kind": "COMPILATION_UNIT", @@ -912,8 +912,8 @@ "sourceName": "parsertests/binaryExpr.js", "strict": "false", "startPosition": "1116" -} -, +} +, { "endPosition": "1117", "kind": "COMPILATION_UNIT", @@ -959,8 +959,8 @@ "sourceName": "parsertests/block.js", "strict": "false", "startPosition": "1117" -} -, +} +, { "endPosition": "1117", "kind": "COMPILATION_UNIT", @@ -1060,8 +1060,8 @@ "sourceName": "parsertests/breakStat.js", "strict": "false", "startPosition": "1117" -} -, +} +, { "endPosition": "1117", "kind": "COMPILATION_UNIT", @@ -1098,8 +1098,8 @@ "sourceName": "parsertests/condExpr.js", "strict": "false", "startPosition": "1117" -} -, +} +, { "endPosition": "1120", "kind": "COMPILATION_UNIT", @@ -1199,8 +1199,8 @@ "sourceName": "parsertests/continueStat.js", "strict": "false", "startPosition": "1120" -} -, +} +, { "endPosition": "1118", "kind": "COMPILATION_UNIT", @@ -1214,8 +1214,8 @@ "sourceName": "parsertests/debuggerStat.js", "strict": "false", "startPosition": "1118" -} -, +} +, { "endPosition": "1137", "kind": "COMPILATION_UNIT", @@ -1500,8 +1500,8 @@ "sourceName": "parsertests/functions.js", "strict": "false", "startPosition": "1137" -} -, +} +, { "endPosition": "1114", "kind": "COMPILATION_UNIT", @@ -1604,8 +1604,8 @@ "sourceName": "parsertests/ifStat.js", "strict": "false", "startPosition": "1114" -} -, +} +, { "endPosition": "1113", "kind": "COMPILATION_UNIT", @@ -1668,8 +1668,8 @@ "sourceName": "parsertests/labelledStat.js", "strict": "false", "startPosition": "1113" -} -, +} +, { "endPosition": "1125", "kind": "COMPILATION_UNIT", @@ -2066,8 +2066,8 @@ "sourceName": "parsertests/lhsExpr.js", "strict": "false", "startPosition": "1125" -} -, +} +, { "endPosition": "1110", "kind": "COMPILATION_UNIT", @@ -2350,8 +2350,8 @@ "sourceName": "parsertests/loopStat.js", "strict": "false", "startPosition": "1110" -} -, +} +, { "endPosition": "1125", "kind": "COMPILATION_UNIT", @@ -2705,8 +2705,8 @@ "sourceName": "parsertests/objectLitExpr.js", "strict": "false", "startPosition": "1125" -} -, +} +, { "endPosition": "1118", "kind": "COMPILATION_UNIT", @@ -2781,8 +2781,8 @@ "sourceName": "parsertests/parenExpr.js", "strict": "false", "startPosition": "1118" -} -, +} +, { "endPosition": "1119", "kind": "COMPILATION_UNIT", @@ -2995,8 +2995,8 @@ "sourceName": "parsertests/primaryExpr.js", "strict": "false", "startPosition": "1119" -} -, +} +, { "endPosition": "1114", "kind": "COMPILATION_UNIT", @@ -3044,8 +3044,8 @@ "sourceName": "parsertests/regexp_literal.js", "strict": "false", "startPosition": "1114" -} -, +} +, { "endPosition": "1118", "kind": "COMPILATION_UNIT", @@ -3144,8 +3144,8 @@ "sourceName": "parsertests/returnStat.js", "strict": "false", "startPosition": "1118" -} -, +} +, { "endPosition": "1111", "kind": "COMPILATION_UNIT", @@ -3309,8 +3309,8 @@ "sourceName": "parsertests/switchStat.js", "strict": "false", "startPosition": "1111" -} -, +} +, { "endPosition": "1110", "kind": "COMPILATION_UNIT", @@ -3421,8 +3421,8 @@ "sourceName": "parsertests/throwStat.js", "strict": "false", "startPosition": "1110" -} -, +} +, { "endPosition": "1121", "kind": "COMPILATION_UNIT", @@ -3783,8 +3783,8 @@ "sourceName": "parsertests/tryCatchStat.js", "strict": "false", "startPosition": "1121" -} -, +} +, { "endPosition": "1115", "kind": "COMPILATION_UNIT", @@ -3969,8 +3969,8 @@ "sourceName": "parsertests/unaryExpr.js", "strict": "false", "startPosition": "1115" -} -, +} +, { "endPosition": "1122", "kind": "COMPILATION_UNIT", @@ -4016,8 +4016,8 @@ "sourceName": "parsertests/useStrict.js", "strict": "true", "startPosition": "1122" -} -, +} +, { "endPosition": "1143", "kind": "COMPILATION_UNIT", @@ -4092,8 +4092,8 @@ "sourceName": "parsertests/varDecl.js", "strict": "false", "startPosition": "1143" -} -, +} +, { "endPosition": "1111", "kind": "COMPILATION_UNIT", @@ -4142,8 +4142,8 @@ "sourceName": "parsertests/withStat.js", "strict": "false", "startPosition": "1111" -} -, +} +, { "fileName": "parsernegativetests/caseoutofswitch.js", "code": "case (1090, 4)", @@ -4152,8 +4152,8 @@ "position": "1090", "message": "parsernegativetests/caseoutofswitch.js:29:0 Expected an operand but found case\ncase 23:\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/caseoutofswitch.js", "code": "default (1112, 7)", @@ -4162,8 +4162,8 @@ "position": "1112", "message": "parsernegativetests/caseoutofswitch.js:31:0 Expected an operand but found default\ndefault:\n^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4240,8 +4240,8 @@ "sourceName": "parsernegativetests/caseoutofswitch.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegalbreak.js", "code": "break (1090, 5)", @@ -4250,8 +4250,8 @@ "position": "1090", "message": "parsernegativetests/illegalbreak.js:29:0 Illegal break statement\nbreak;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/illegalbreak.js", "code": "ident (1103, 3)", @@ -4260,8 +4260,8 @@ "position": "1103", "message": "parsernegativetests/illegalbreak.js:30:6 Undefined Label \"foo\"\nbreak foo;\n ^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4290,8 +4290,8 @@ "sourceName": "parsernegativetests/illegalbreak.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegalcontinue.js", "code": "continue (1090, 8)", @@ -4300,8 +4300,8 @@ "position": "1090", "message": "parsernegativetests/illegalcontinue.js:29:0 Illegal continue statement\ncontinue;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/illegalcontinue.js", "code": "ident (1109, 3)", @@ -4310,8 +4310,8 @@ "position": "1109", "message": "parsernegativetests/illegalcontinue.js:30:9 Undefined Label \"foo\"\ncontinue foo;\n ^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4340,8 +4340,8 @@ "sourceName": "parsernegativetests/illegalcontinue.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegallvalue.js", "code": "decimal (1090, 2)", @@ -4350,8 +4350,8 @@ "position": "1090", "message": "parsernegativetests/illegallvalue.js:29:0 Invalid left hand side for assignment\n44 = 54;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/illegallvalue.js", "code": "decimal (1099, 3)", @@ -4360,8 +4360,8 @@ "position": "1099", "message": "parsernegativetests/illegallvalue.js:30:0 Invalid left hand side for assignment\n233 += 33;\n^", "lineNumber": "30" -} -, +} +, { "fileName": "parsernegativetests/illegallvalue.js", "code": "decimal (1110, 4)", @@ -4370,8 +4370,8 @@ "position": "1110", "message": "parsernegativetests/illegallvalue.js:31:0 Invalid left hand side for assignment\n3423 -= 234;\n^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4410,8 +4410,8 @@ "sourceName": "parsernegativetests/illegallvalue.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/illegaloperator.js", "code": "* (1093, 1)", @@ -4420,8 +4420,8 @@ "position": "1093", "message": "parsernegativetests/illegaloperator.js:29:3 Expected an operand but found *\nx ** y\n ^", "lineNumber": "29" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4440,8 +4440,8 @@ "sourceName": "parsernegativetests/illegaloperator.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/keywordident.js", "code": "var (1094, 3)", @@ -4450,8 +4450,8 @@ "position": "1094", "message": "parsernegativetests/keywordident.js:29:4 Expected ident but found var\nvar var = 23;\n ^", "lineNumber": "29" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4482,8 +4482,8 @@ "sourceName": "parsernegativetests/keywordident.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/parenmissing.js", "code": "; (1096, 1)", @@ -4492,8 +4492,8 @@ "position": "1096", "message": "parsernegativetests/parenmissing.js:29:6 Expected ) but found ;\n(1 + 2;\n ^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/parenmissing.js", "code": ") (1103, 1)", @@ -4502,8 +4502,8 @@ "position": "1103", "message": "parsernegativetests/parenmissing.js:30:5 Expected ; but found )\nx * y);\n ^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4554,8 +4554,8 @@ "sourceName": "parsernegativetests/parenmissing.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1111, 3)", @@ -4564,8 +4564,8 @@ "position": "1111", "message": "parsernegativetests/repeatedproperty.js:29:21 Property \"foo\" already defined\nvar obj = { foo: 34, get foo() { return 'hello' } };\n ^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1165, 3)", @@ -4574,8 +4574,8 @@ "position": "1165", "message": "parsernegativetests/repeatedproperty.js:30:22 Property \"foo\" already defined\nvar obj1 = { foo: 34, set foo(x) { } };\n ^", "lineNumber": "30" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1205, 3)", @@ -4584,8 +4584,8 @@ "position": "1205", "message": "parsernegativetests/repeatedproperty.js:31:22 Property \"foo\" already defined\nvar obj2 = { foo: 34, set foo(x) { } };\n ^", "lineNumber": "31" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1251, 3)", @@ -4594,8 +4594,8 @@ "position": "1251", "message": "parsernegativetests/repeatedproperty.js:32:28 Property \"bar\" already defined\nvar obj3 = { get bar() { }, get bar() {} };\n ^", "lineNumber": "32" -} -, +} +, { "fileName": "parsernegativetests/repeatedproperty.js", "code": "ident (1296, 3)", @@ -4604,8 +4604,8 @@ "position": "1296", "message": "parsernegativetests/repeatedproperty.js:33:29 Property \"bar\" already defined\nvar obj4 = { set bar(x) { }, set bar(x) {} };\n ^", "lineNumber": "33" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4664,8 +4664,8 @@ "sourceName": "parsernegativetests/repeatedproperty.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/strict_repeatedproperty.js", "code": "ident (1126, 3)", @@ -4674,8 +4674,8 @@ "position": "1126", "message": "parsernegativetests/strict_repeatedproperty.js:31:21 Property \"foo\" already defined\nvar obj = { foo: 34, foo: 'hello' };\n ^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4705,8 +4705,8 @@ "sourceName": "parsernegativetests/strict_repeatedproperty.js", "strict": "true", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/strict_repeatparam.js", "code": "ident (1119, 1)", @@ -4715,8 +4715,8 @@ "position": "1119", "message": "parsernegativetests/strict_repeatparam.js:31:14 strict mode function cannot have duplicate parameter name \"x\"\nfunction func(x, x) {}\n ^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4746,8 +4746,8 @@ "sourceName": "parsernegativetests/strict_repeatparam.js", "strict": "true", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/strict_with.js", "code": "with (1105, 4)", @@ -4756,8 +4756,8 @@ "position": "1105", "message": "parsernegativetests/strict_with.js:31:0 \"with\" statement cannot be used in strict mode\nwith({}) {}\n^", "lineNumber": "31" -} -, +} +, { "fileName": "parsernegativetests/strict_with.js", "code": ") (1112, 1)", @@ -4766,8 +4766,8 @@ "position": "1112", "message": "parsernegativetests/strict_with.js:31:7 Expected ; but found )\nwith({}) {}\n ^", "lineNumber": "31" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4807,8 +4807,8 @@ "sourceName": "parsernegativetests/strict_with.js", "strict": "true", "startPosition": "1090" -} -, +} +, { "fileName": "parsernegativetests/toplevelreturn.js", "code": "return (1090, 6)", @@ -4817,8 +4817,8 @@ "position": "1090", "message": "parsernegativetests/toplevelreturn.js:29:0 Invalid return statement\nreturn;\n^", "lineNumber": "29" -} -, +} +, { "fileName": "parsernegativetests/toplevelreturn.js", "code": "return (1098, 6)", @@ -4827,8 +4827,8 @@ "position": "1098", "message": "parsernegativetests/toplevelreturn.js:30:0 Invalid return statement\nreturn 23;\n^", "lineNumber": "30" -} -, +} +, { "endPosition": "1090", "kind": "COMPILATION_UNIT", @@ -4857,59 +4857,59 @@ "sourceName": "parsernegativetests/toplevelreturn.js", "strict": "false", "startPosition": "1090" -} -, +} +, { "endPosition": "1136", "kind": "COMPILATION_UNIT", "sourceElements": [ { - "endPosition": "1240", + "endPosition": "1242", "kind": "FUNCTION", "name": "Parser", "body": { - "endPosition": "1218", + "endPosition": "1220", "kind": "BLOCK", "statements": [ { "expression": { "expression": { - "endPosition": "1217", + "endPosition": "1219", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "create", "expression": { - "endPosition": "1208", + "endPosition": "1210", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1202" + "startPosition": "1204" }, - "endPosition": "1215", + "endPosition": "1217", "kind": "MEMBER_SELECT", - "startPosition": "1202" + "startPosition": "1204" }, "arguments": [], - "startPosition": "1202" + "startPosition": "1204" }, - "endPosition": "1217", + "endPosition": "1219", "kind": "ASSIGNMENT", "variable": { "identifier": "_parser", "expression": { - "endPosition": "1191", + "endPosition": "1193", "kind": "IDENTIFIER", "name": "this", - "startPosition": "1187" + "startPosition": "1189" }, - "endPosition": "1199", + "endPosition": "1201", "kind": "MEMBER_SELECT", - "startPosition": "1187" + "startPosition": "1189" }, - "startPosition": "1187" + "startPosition": "1189" }, - "endPosition": "1217", + "endPosition": "1219", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1187" + "startPosition": "1189" } ], "startPosition": "1154" @@ -4921,1368 +4921,1489 @@ { "expression": { "expression": { - "endPosition": "1305", + "endPosition": "1307", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "1265", + "endPosition": "1267", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "1261" + "startPosition": "1263" }, - "endPosition": "1270", + "endPosition": "1272", "kind": "MEMBER_SELECT", - "startPosition": "1261" + "startPosition": "1263" }, "arguments": [ { - "endPosition": "1303", + "endPosition": "1305", "kind": "STRING_LITERAL", "value": "jdk.nashorn.api.tree.Diagnostic", - "startPosition": "1272" + "startPosition": "1274" } ], - "startPosition": "1261" + "startPosition": "1263" }, - "endPosition": "1305", + "endPosition": "1307", "kind": "ASSIGNMENT", "variable": { "identifier": "Diagnostic", "expression": { - "endPosition": "1247", + "endPosition": "1249", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1241" + "startPosition": "1243" }, - "endPosition": "1258", + "endPosition": "1260", "kind": "MEMBER_SELECT", - "startPosition": "1241" + "startPosition": "1243" }, - "startPosition": "1241" + "startPosition": "1243" }, - "endPosition": "1305", + "endPosition": "1307", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1241" + "startPosition": "1243" }, { "expression": { "expression": { - "endPosition": "1390", + "endPosition": "1392", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "1338", + "endPosition": "1340", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "1334" + "startPosition": "1336" }, - "endPosition": "1343", + "endPosition": "1345", "kind": "MEMBER_SELECT", - "startPosition": "1334" + "startPosition": "1336" }, "arguments": [ { - "endPosition": "1388", + "endPosition": "1390", "kind": "STRING_LITERAL", "value": "jdk.nashorn.api.tree.SimpleTreeVisitorES5_1", - "startPosition": "1345" + "startPosition": "1347" } ], - "startPosition": "1334" + "startPosition": "1336" }, - "endPosition": "1390", + "endPosition": "1392", "kind": "ASSIGNMENT", "variable": { "identifier": "SimpleTreeVisitor", "expression": { - "endPosition": "1313", + "endPosition": "1315", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1307" + "startPosition": "1309" }, - "endPosition": "1331", + "endPosition": "1333", "kind": "MEMBER_SELECT", - "startPosition": "1307" + "startPosition": "1309" }, - "startPosition": "1307" + "startPosition": "1309" }, - "endPosition": "1390", + "endPosition": "1392", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1307" + "startPosition": "1309" }, { "expression": { "expression": { - "endPosition": "1444", + "endPosition": "1446", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "1410", + "endPosition": "1412", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "1406" + "startPosition": "1408" }, - "endPosition": "1415", + "endPosition": "1417", "kind": "MEMBER_SELECT", - "startPosition": "1406" + "startPosition": "1408" }, "arguments": [ { - "endPosition": "1442", + "endPosition": "1444", "kind": "STRING_LITERAL", "value": "jdk.nashorn.api.tree.Tree", - "startPosition": "1417" + "startPosition": "1419" } ], - "startPosition": "1406" + "startPosition": "1408" }, - "endPosition": "1444", + "endPosition": "1446", "kind": "ASSIGNMENT", "variable": { "identifier": "Tree", "expression": { - "endPosition": "1398", + "endPosition": "1400", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1392" + "startPosition": "1394" }, - "endPosition": "1403", + "endPosition": "1405", "kind": "MEMBER_SELECT", - "startPosition": "1392" + "startPosition": "1394" }, - "startPosition": "1392" + "startPosition": "1394" }, - "endPosition": "1444", + "endPosition": "1446", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1392" + "startPosition": "1394" }, { "expression": { "expression": { - "endPosition": "1487", + "endPosition": "1489", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "1464", + "endPosition": "1466", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "1460" + "startPosition": "1462" }, - "endPosition": "1469", + "endPosition": "1471", "kind": "MEMBER_SELECT", - "startPosition": "1460" + "startPosition": "1462" }, "arguments": [ { - "endPosition": "1485", + "endPosition": "1487", "kind": "STRING_LITERAL", "value": "java.util.List", - "startPosition": "1471" + "startPosition": "1473" } ], - "startPosition": "1460" + "startPosition": "1462" }, - "endPosition": "1487", + "endPosition": "1489", "kind": "ASSIGNMENT", "variable": { "identifier": "List", "expression": { - "endPosition": "1452", + "endPosition": "1454", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1446" + "startPosition": "1448" }, - "endPosition": "1457", + "endPosition": "1459", "kind": "MEMBER_SELECT", - "startPosition": "1446" + "startPosition": "1448" }, - "startPosition": "1446" + "startPosition": "1448" }, - "endPosition": "1487", + "endPosition": "1489", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1446" + "startPosition": "1448" }, { "expression": { "expression": { - "endPosition": "1530", + "endPosition": "1532", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "1507", + "endPosition": "1509", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "1503" + "startPosition": "1505" }, - "endPosition": "1512", + "endPosition": "1514", "kind": "MEMBER_SELECT", - "startPosition": "1503" + "startPosition": "1505" }, "arguments": [ { - "endPosition": "1528", + "endPosition": "1530", "kind": "STRING_LITERAL", "value": "java.lang.Enum", - "startPosition": "1514" + "startPosition": "1516" } ], - "startPosition": "1503" + "startPosition": "1505" }, - "endPosition": "1530", + "endPosition": "1532", "kind": "ASSIGNMENT", "variable": { "identifier": "Enum", "expression": { - "endPosition": "1495", + "endPosition": "1497", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1489" + "startPosition": "1491" }, - "endPosition": "1500", + "endPosition": "1502", "kind": "MEMBER_SELECT", - "startPosition": "1489" + "startPosition": "1491" }, - "startPosition": "1489" + "startPosition": "1491" }, - "endPosition": "1530", + "endPosition": "1532", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1489" + "startPosition": "1491" }, { "expression": { "expression": { - "endPosition": "1657", + "endPosition": "1659", "kind": "FUNCTION_EXPRESSION", "body": { - "endPosition": "1803", + "endPosition": "1805", "kind": "BLOCK", "statements": [ { - "endPosition": "1716", + "endPosition": "1718", "kind": "VARIABLE", "name": "tree", - "startPosition": "1667", + "startPosition": "1669", "initializer": { - "endPosition": "1716", + "endPosition": "1718", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "parse", "expression": { "identifier": "_parser", "expression": { - "endPosition": "1678", + "endPosition": "1680", "kind": "IDENTIFIER", "name": "this", - "startPosition": "1674" + "startPosition": "1676" }, - "endPosition": "1686", + "endPosition": "1688", "kind": "MEMBER_SELECT", - "startPosition": "1674" + "startPosition": "1676" }, - "endPosition": "1692", + "endPosition": "1694", "kind": "MEMBER_SELECT", - "startPosition": "1674" + "startPosition": "1676" }, "arguments": [ { - "endPosition": "1697", + "endPosition": "1699", "kind": "IDENTIFIER", "name": "name", - "startPosition": "1693" + "startPosition": "1695" }, { - "endPosition": "1705", + "endPosition": "1707", "kind": "IDENTIFIER", "name": "script", - "startPosition": "1699" + "startPosition": "1701" }, { - "endPosition": "1715", + "endPosition": "1717", "kind": "IDENTIFIER", "name": "listener", - "startPosition": "1707" + "startPosition": "1709" } ], - "startPosition": "1674" + "startPosition": "1676" } }, { "expression": { - "endPosition": "1771", + "endPosition": "1773", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "accept", "expression": { - "endPosition": "1726", + "endPosition": "1728", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "1722" + "startPosition": "1724" }, - "endPosition": "1733", + "endPosition": "1735", "kind": "MEMBER_SELECT", - "startPosition": "1722" + "startPosition": "1724" }, "arguments": [ { "constructorExpression": { - "endPosition": "1764", + "endPosition": "1766", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "SimpleTreeVisitor", "expression": { - "endPosition": "1744", + "endPosition": "1746", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1738" + "startPosition": "1740" }, - "endPosition": "1762", + "endPosition": "1764", "kind": "MEMBER_SELECT", - "startPosition": "1738" + "startPosition": "1740" }, "arguments": [], - "startPosition": "1744" + "startPosition": "1746" }, - "endPosition": "1764", + "endPosition": "1766", "kind": "NEW", - "startPosition": "1734" + "startPosition": "1736" }, { - "endPosition": "1770", + "endPosition": "1772", "kind": "NULL_LITERAL", - "startPosition": "1766" + "startPosition": "1768" } ], - "startPosition": "1722" + "startPosition": "1724" }, - "endPosition": "1771", + "endPosition": "1773", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1722" + "startPosition": "1724" }, { "expression": { - "endPosition": "1802", + "endPosition": "1804", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "convert", "expression": { - "endPosition": "1788", + "endPosition": "1790", "kind": "IDENTIFIER", "name": "this", - "startPosition": "1784" + "startPosition": "1786" }, - "endPosition": "1796", + "endPosition": "1798", "kind": "MEMBER_SELECT", - "startPosition": "1784" + "startPosition": "1786" }, "arguments": [ { - "endPosition": "1801", + "endPosition": "1803", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "1797" + "startPosition": "1799" } ], - "startPosition": "1784" + "startPosition": "1786" }, - "endPosition": "1803", + "endPosition": "1805", "kind": "RETURN", - "startPosition": "1777" + "startPosition": "1779" } ], - "startPosition": "1657" + "startPosition": "1659" }, "strict": "false", - "startPosition": "1657", + "startPosition": "1659", "parameters": [ { - "endPosition": "1637", + "endPosition": "1639", "kind": "IDENTIFIER", "name": "name", - "startPosition": "1633" + "startPosition": "1635" }, { - "endPosition": "1645", + "endPosition": "1647", "kind": "IDENTIFIER", "name": "script", - "startPosition": "1639" + "startPosition": "1641" }, { - "endPosition": "1655", + "endPosition": "1657", "kind": "IDENTIFIER", "name": "listener", - "startPosition": "1647" + "startPosition": "1649" } ] }, - "endPosition": "1657", + "endPosition": "1659", "kind": "ASSIGNMENT", "variable": { "identifier": "parse", "expression": { "identifier": "prototype", "expression": { - "endPosition": "1605", + "endPosition": "1607", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1599" + "startPosition": "1601" }, - "endPosition": "1615", + "endPosition": "1617", "kind": "MEMBER_SELECT", - "startPosition": "1599" + "startPosition": "1601" }, - "endPosition": "1621", + "endPosition": "1623", "kind": "MEMBER_SELECT", - "startPosition": "1599" + "startPosition": "1601" }, - "startPosition": "1599" + "startPosition": "1601" }, - "endPosition": "1805", + "endPosition": "1807", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1599" + "startPosition": "1601" }, { "expression": { "expression": { - "endPosition": "1834", + "endPosition": "1836", "kind": "FUNCTION_EXPRESSION", "body": { - "endPosition": "1897", + "endPosition": "1899", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "1896", + "endPosition": "1898", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "create", "expression": { - "endPosition": "1887", + "endPosition": "1889", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "1851", + "endPosition": "1853", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "1847" + "startPosition": "1849" }, - "endPosition": "1856", + "endPosition": "1858", "kind": "MEMBER_SELECT", - "startPosition": "1847" + "startPosition": "1849" }, "arguments": [ { - "endPosition": "1885", + "endPosition": "1887", "kind": "STRING_LITERAL", "value": "jdk.nashorn.api.tree.Parser", - "startPosition": "1858" + "startPosition": "1860" } ], - "startPosition": "1847" + "startPosition": "1849" }, - "endPosition": "1894", + "endPosition": "1896", "kind": "MEMBER_SELECT", - "startPosition": "1847" + "startPosition": "1849" }, "arguments": [], - "startPosition": "1894" + "startPosition": "1896" }, - "endPosition": "1897", + "endPosition": "1899", "kind": "RETURN", - "startPosition": "1840" + "startPosition": "1842" } ], - "startPosition": "1834" + "startPosition": "1836" }, "strict": "false", - "startPosition": "1834", + "startPosition": "1836", "parameters": [] }, - "endPosition": "1834", + "endPosition": "1836", "kind": "ASSIGNMENT", "variable": { "identifier": "create", "expression": { - "endPosition": "1813", + "endPosition": "1815", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1807" + "startPosition": "1809" }, - "endPosition": "1820", + "endPosition": "1822", "kind": "MEMBER_SELECT", - "startPosition": "1807" + "startPosition": "1809" }, - "startPosition": "1807" + "startPosition": "1809" }, - "endPosition": "1971", + "endPosition": "1973", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1807" + "startPosition": "1809" }, { "expression": { "expression": { - "endPosition": "2014", + "endPosition": "2016", "kind": "FUNCTION_EXPRESSION", "body": { - "endPosition": "2863", + "endPosition": "2994", "kind": "BLOCK", "statements": [ { "condition": { "leftOperand": { - "expression": { - "endPosition": "2029", - "kind": "IDENTIFIER", - "name": "tree", - "startPosition": "2025" + "leftOperand": { + "expression": { + "endPosition": "2031", + "kind": "IDENTIFIER", + "name": "tree", + "startPosition": "2027" + }, + "endPosition": "2031", + "kind": "LOGICAL_COMPLEMENT", + "startPosition": "2026" }, - "endPosition": "2029", - "kind": "LOGICAL_COMPLEMENT", - "startPosition": "2024" + "endPosition": "2057", + "kind": "CONDITIONAL_OR", + "rightOperand": { + "leftOperand": { + "expression": { + "endPosition": "2046", + "kind": "IDENTIFIER", + "name": "tree", + "startPosition": "2042" + }, + "endPosition": "2046", + "kind": "TYPEOF", + "startPosition": "2035" + }, + "endPosition": "2057", + "kind": "NOT_EQUAL_TO", + "rightOperand": { + "endPosition": "2057", + "kind": "STRING_LITERAL", + "value": "object", + "startPosition": "2051" + }, + "startPosition": "2035" + }, + "startPosition": "2026" }, - "endPosition": "2055", + "endPosition": "2092", "kind": "CONDITIONAL_OR", "rightOperand": { "leftOperand": { - "expression": { - "endPosition": "2044", - "kind": "IDENTIFIER", - "name": "tree", - "startPosition": "2040" - }, - "endPosition": "2044", - "kind": "TYPEOF", - "startPosition": "2033" + "endPosition": "2066", + "kind": "IDENTIFIER", + "name": "tree", + "startPosition": "2062" }, - "endPosition": "2055", - "kind": "NOT_EQUAL_TO", + "expression": { + "endPosition": "2066", + "kind": "IDENTIFIER", + "name": "tree", + "startPosition": "2062" + }, + "endPosition": "2092", + "kind": "INSTANCE_OF", "rightOperand": { - "endPosition": "2055", - "kind": "STRING_LITERAL", - "value": "object", - "startPosition": "2049" + "identifier": "Long", + "expression": { + "identifier": "lang", + "expression": { + "endPosition": "2082", + "kind": "IDENTIFIER", + "name": "java", + "startPosition": "2078" + }, + "endPosition": "2087", + "kind": "MEMBER_SELECT", + "startPosition": "2078" + }, + "endPosition": "2092", + "kind": "MEMBER_SELECT", + "startPosition": "2078" }, - "startPosition": "2033" + "type": { + "identifier": "Long", + "expression": { + "identifier": "lang", + "expression": { + "endPosition": "2082", + "kind": "IDENTIFIER", + "name": "java", + "startPosition": "2078" + }, + "endPosition": "2087", + "kind": "MEMBER_SELECT", + "startPosition": "2078" + }, + "endPosition": "2092", + "kind": "MEMBER_SELECT", + "startPosition": "2078" + }, + "startPosition": "2062" }, - "startPosition": "2024" + "startPosition": "2026" }, - "endPosition": "2086", + "endPosition": "2122", "kind": "IF", - "startPosition": "2020", + "startPosition": "2022", "thenStatement": { - "endPosition": "2086", + "endPosition": "2122", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "2079", + "endPosition": "2115", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "2075" + "startPosition": "2111" }, - "endPosition": "2080", + "endPosition": "2116", "kind": "RETURN", - "startPosition": "2068" + "startPosition": "2104" } ], - "startPosition": "2058" + "startPosition": "2094" } }, { - "endPosition": "2133", + "endPosition": "2169", "kind": "VARIABLE", "name": "obj", - "startPosition": "2096", + "startPosition": "2132", "initializer": { - "endPosition": "2133", + "endPosition": "2169", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "bindProperties", "expression": { - "endPosition": "2108", + "endPosition": "2144", "kind": "IDENTIFIER", "name": "Object", - "startPosition": "2102" + "startPosition": "2138" }, - "endPosition": "2123", + "endPosition": "2159", "kind": "MEMBER_SELECT", - "startPosition": "2102" + "startPosition": "2138" }, "arguments": [ { - "endPosition": "2126", + "endPosition": "2162", "kind": "OBJECT_LITERAL", - "startPosition": "2124", + "startPosition": "2160", "properties": [] }, { - "endPosition": "2132", + "endPosition": "2168", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "2128" + "startPosition": "2164" } ], - "startPosition": "2102" + "startPosition": "2138" } }, { - "endPosition": "2154", + "endPosition": "2190", "kind": "VARIABLE", "name": "result", - "startPosition": "2143", + "startPosition": "2179", "initializer": { - "endPosition": "2154", + "endPosition": "2190", "kind": "OBJECT_LITERAL", - "startPosition": "2152", + "startPosition": "2188", "properties": [] } }, { - "endPosition": "2170", + "endPosition": "2206", "kind": "VARIABLE", "name": "i", - "startPosition": "2169" + "startPosition": "2205" }, { "expression": { - "endPosition": "2177", + "endPosition": "2213", "kind": "IDENTIFIER", "name": "obj", - "startPosition": "2174" + "startPosition": "2210" }, - "endPosition": "2845", + "endPosition": "2975", "kind": "FOR_IN_LOOP", "forEach": "false", "variable": { - "endPosition": "2170", + "endPosition": "2206", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2169" + "startPosition": "2205" }, "statement": { - "endPosition": "2845", + "endPosition": "2975", "kind": "BLOCK", "statements": [ { - "endPosition": "2204", + "endPosition": "2241", "kind": "VARIABLE", "name": "val", - "startPosition": "2192", + "startPosition": "2229", "initializer": { "expression": { - "endPosition": "2201", + "endPosition": "2238", "kind": "IDENTIFIER", "name": "obj", - "startPosition": "2198" + "startPosition": "2235" }, - "endPosition": "2204", + "endPosition": "2241", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2203", + "endPosition": "2240", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2202" + "startPosition": "2239" }, - "startPosition": "2198" + "startPosition": "2235" } }, { "condition": { "leftOperand": { - "endPosition": "2220", + "endPosition": "2258", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2217" + "startPosition": "2255" }, "expression": { - "endPosition": "2220", + "endPosition": "2258", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2217" + "startPosition": "2255" }, - "endPosition": "2243", + "endPosition": "2281", "kind": "INSTANCE_OF", "rightOperand": { "identifier": "Tree", "expression": { - "endPosition": "2238", + "endPosition": "2276", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2232" + "startPosition": "2270" }, - "endPosition": "2243", + "endPosition": "2281", "kind": "MEMBER_SELECT", - "startPosition": "2232" + "startPosition": "2270" }, "type": { "identifier": "Tree", "expression": { - "endPosition": "2238", + "endPosition": "2276", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2232" + "startPosition": "2270" }, - "endPosition": "2243", + "endPosition": "2281", "kind": "MEMBER_SELECT", - "startPosition": "2232" + "startPosition": "2270" }, - "startPosition": "2217" + "startPosition": "2255" }, "elseStatement": { "condition": { "leftOperand": { - "endPosition": "2309", + "endPosition": "2350", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2306" + "startPosition": "2347" }, "expression": { - "endPosition": "2309", + "endPosition": "2350", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2306" + "startPosition": "2347" }, - "endPosition": "2332", + "endPosition": "2373", "kind": "INSTANCE_OF", "rightOperand": { "identifier": "List", "expression": { - "endPosition": "2327", + "endPosition": "2368", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2321" + "startPosition": "2362" }, - "endPosition": "2332", + "endPosition": "2373", "kind": "MEMBER_SELECT", - "startPosition": "2321" + "startPosition": "2362" }, "type": { "identifier": "List", "expression": { - "endPosition": "2327", + "endPosition": "2368", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "2321" + "startPosition": "2362" }, - "endPosition": "2332", + "endPosition": "2373", "kind": "MEMBER_SELECT", - "startPosition": "2321" + "startPosition": "2362" }, - "startPosition": "2306" + "startPosition": "2347" }, "elseStatement": { - "endPosition": "2840", + "endPosition": "2969", "kind": "BLOCK", "statements": [ { "cases": [ { "expression": { - "endPosition": "2574", + "endPosition": "2625", "kind": "STRING_LITERAL", "value": "number", - "startPosition": "2568" + "startPosition": "2619" }, - "endPosition": "2576", + "endPosition": "2627", "kind": "CASE", "statements": [], - "startPosition": "2562" + "startPosition": "2613" }, { "expression": { - "endPosition": "2603", + "endPosition": "2656", "kind": "STRING_LITERAL", "value": "string", - "startPosition": "2597" + "startPosition": "2650" }, - "endPosition": "2605", + "endPosition": "2658", "kind": "CASE", "statements": [], - "startPosition": "2591" + "startPosition": "2644" }, { "expression": { - "endPosition": "2633", + "endPosition": "2688", "kind": "STRING_LITERAL", "value": "boolean", - "startPosition": "2626" + "startPosition": "2681" }, - "endPosition": "2678", + "endPosition": "2762", "kind": "CASE", "statements": [ { "expression": { "expression": { - "endPosition": "2677", + "endPosition": "2734", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "2672", + "endPosition": "2729", "kind": "IDENTIFIER", "name": "String", - "startPosition": "2666" + "startPosition": "2723" }, "arguments": [ { - "endPosition": "2676", + "endPosition": "2733", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2673" + "startPosition": "2730" } ], - "startPosition": "2666" + "startPosition": "2723" }, - "endPosition": "2677", + "endPosition": "2734", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2660", + "endPosition": "2717", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2654" + "startPosition": "2711" }, - "endPosition": "2663", + "endPosition": "2720", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2662", + "endPosition": "2719", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2661" + "startPosition": "2718" }, - "startPosition": "2654" + "startPosition": "2711" }, - "startPosition": "2654" + "startPosition": "2711" }, - "endPosition": "2677", + "endPosition": "2734", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2654" + "startPosition": "2711" + }, + { + "endPosition": "2762", + "kind": "BREAK", + "startPosition": "2756" } ], - "startPosition": "2620" + "startPosition": "2675" }, { - "endPosition": "2820", + "endPosition": "2945", "kind": "CASE", "statements": [ { "condition": { "leftOperand": { - "endPosition": "2727", - "kind": "IDENTIFIER", - "name": "val", - "startPosition": "2724" + "leftOperand": { + "endPosition": "2815", + "kind": "IDENTIFIER", + "name": "val", + "startPosition": "2812" + }, + "expression": { + "endPosition": "2815", + "kind": "IDENTIFIER", + "name": "val", + "startPosition": "2812" + }, + "endPosition": "2841", + "kind": "INSTANCE_OF", + "rightOperand": { + "identifier": "Long", + "expression": { + "identifier": "lang", + "expression": { + "endPosition": "2831", + "kind": "IDENTIFIER", + "name": "java", + "startPosition": "2827" + }, + "endPosition": "2836", + "kind": "MEMBER_SELECT", + "startPosition": "2827" + }, + "endPosition": "2841", + "kind": "MEMBER_SELECT", + "startPosition": "2827" + }, + "type": { + "identifier": "Long", + "expression": { + "identifier": "lang", + "expression": { + "endPosition": "2831", + "kind": "IDENTIFIER", + "name": "java", + "startPosition": "2827" + }, + "endPosition": "2836", + "kind": "MEMBER_SELECT", + "startPosition": "2827" + }, + "endPosition": "2841", + "kind": "MEMBER_SELECT", + "startPosition": "2827" + }, + "startPosition": "2812" }, - "expression": { - "endPosition": "2727", - "kind": "IDENTIFIER", - "name": "val", - "startPosition": "2724" - }, - "endPosition": "2750", - "kind": "INSTANCE_OF", + "endPosition": "2871", + "kind": "CONDITIONAL_OR", "rightOperand": { - "identifier": "Enum", - "expression": { - "endPosition": "2745", + "leftOperand": { + "endPosition": "2848", "kind": "IDENTIFIER", - "name": "Parser", - "startPosition": "2739" + "name": "val", + "startPosition": "2845" }, - "endPosition": "2750", - "kind": "MEMBER_SELECT", - "startPosition": "2739" - }, - "type": { - "identifier": "Enum", "expression": { - "endPosition": "2745", + "endPosition": "2848", "kind": "IDENTIFIER", - "name": "Parser", - "startPosition": "2739" + "name": "val", + "startPosition": "2845" }, - "endPosition": "2750", - "kind": "MEMBER_SELECT", - "startPosition": "2739" + "endPosition": "2871", + "kind": "INSTANCE_OF", + "rightOperand": { + "identifier": "Enum", + "expression": { + "endPosition": "2866", + "kind": "IDENTIFIER", + "name": "Parser", + "startPosition": "2860" + }, + "endPosition": "2871", + "kind": "MEMBER_SELECT", + "startPosition": "2860" + }, + "type": { + "identifier": "Enum", + "expression": { + "endPosition": "2866", + "kind": "IDENTIFIER", + "name": "Parser", + "startPosition": "2860" + }, + "endPosition": "2871", + "kind": "MEMBER_SELECT", + "startPosition": "2860" + }, + "startPosition": "2845" }, - "startPosition": "2724" + "startPosition": "2812" }, - "endPosition": "2820", + "endPosition": "2945", "kind": "IF", - "startPosition": "2720", + "startPosition": "2808", "thenStatement": { - "endPosition": "2820", + "endPosition": "2945", "kind": "BLOCK", "statements": [ { "expression": { "expression": { - "endPosition": "2799", + "endPosition": "2922", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "2794", + "endPosition": "2917", "kind": "IDENTIFIER", "name": "String", - "startPosition": "2788" + "startPosition": "2911" }, "arguments": [ { - "endPosition": "2798", + "endPosition": "2921", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2795" + "startPosition": "2918" } ], - "startPosition": "2788" + "startPosition": "2911" }, - "endPosition": "2799", + "endPosition": "2922", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2782", + "endPosition": "2905", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2776" + "startPosition": "2899" }, - "endPosition": "2785", + "endPosition": "2908", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2784", + "endPosition": "2907", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2783" + "startPosition": "2906" }, - "startPosition": "2776" + "startPosition": "2899" }, - "startPosition": "2776" + "startPosition": "2899" }, - "endPosition": "2799", + "endPosition": "2922", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2776" + "startPosition": "2899" } ], - "startPosition": "2752" + "startPosition": "2873" } } ], - "startPosition": "2693" + "startPosition": "2779" } ], "expression": { "expression": { - "endPosition": "2544", + "endPosition": "2593", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2541" + "startPosition": "2590" }, - "endPosition": "2544", + "endPosition": "2593", "kind": "TYPEOF", - "startPosition": "2534" + "startPosition": "2583" }, - "endPosition": "2832", + "endPosition": "2959", "kind": "SWITCH", - "startPosition": "2526" + "startPosition": "2575" } ], - "startPosition": "2514" + "startPosition": "2561" }, - "endPosition": "2840", + "endPosition": "2969", "kind": "IF", - "startPosition": "2302", + "startPosition": "2343", "thenStatement": { - "endPosition": "2508", + "endPosition": "2555", "kind": "BLOCK", "statements": [ { - "endPosition": "2377", + "endPosition": "2420", "kind": "VARIABLE", "name": "arr", - "startPosition": "2350", + "startPosition": "2393", "initializer": { "constructorExpression": { - "endPosition": "2377", + "endPosition": "2420", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "2365", + "endPosition": "2408", "kind": "IDENTIFIER", "name": "Array", - "startPosition": "2360" + "startPosition": "2403" }, "arguments": [ { - "endPosition": "2376", + "endPosition": "2419", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "size", "expression": { - "endPosition": "2369", + "endPosition": "2412", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2366" + "startPosition": "2409" }, - "endPosition": "2374", + "endPosition": "2417", "kind": "MEMBER_SELECT", - "startPosition": "2366" + "startPosition": "2409" }, "arguments": [], - "startPosition": "2366" + "startPosition": "2409" } ], - "startPosition": "2360" + "startPosition": "2403" }, - "endPosition": "2377", + "endPosition": "2420", "kind": "NEW", - "startPosition": "2356" + "startPosition": "2399" } }, { - "endPosition": "2399", + "endPosition": "2444", "kind": "VARIABLE", "name": "j", - "startPosition": "2398" + "startPosition": "2443" }, { "expression": { - "endPosition": "2406", + "endPosition": "2451", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2403" + "startPosition": "2448" }, - "endPosition": "2466", + "endPosition": "2515", "kind": "FOR_IN_LOOP", "forEach": "false", "variable": { - "endPosition": "2399", + "endPosition": "2444", "kind": "IDENTIFIER", "name": "j", - "startPosition": "2398" + "startPosition": "2443" }, "statement": { - "endPosition": "2466", + "endPosition": "2515", "kind": "BLOCK", "statements": [ { "expression": { "expression": { - "endPosition": "2453", + "endPosition": "2500", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "convert", "expression": { - "endPosition": "2437", + "endPosition": "2484", "kind": "IDENTIFIER", "name": "this", - "startPosition": "2433" + "startPosition": "2480" }, - "endPosition": "2445", + "endPosition": "2492", "kind": "MEMBER_SELECT", - "startPosition": "2433" + "startPosition": "2480" }, "arguments": [ { "expression": { - "endPosition": "2449", + "endPosition": "2496", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2446" + "startPosition": "2493" }, - "endPosition": "2452", + "endPosition": "2499", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2451", + "endPosition": "2498", "kind": "IDENTIFIER", "name": "j", - "startPosition": "2450" + "startPosition": "2497" }, - "startPosition": "2446" + "startPosition": "2493" } ], - "startPosition": "2433" + "startPosition": "2480" }, - "endPosition": "2453", + "endPosition": "2500", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2427", + "endPosition": "2474", "kind": "IDENTIFIER", "name": "arr", - "startPosition": "2424" + "startPosition": "2471" }, - "endPosition": "2430", + "endPosition": "2477", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2429", + "endPosition": "2476", "kind": "IDENTIFIER", "name": "j", - "startPosition": "2428" + "startPosition": "2475" }, - "startPosition": "2424" + "startPosition": "2471" }, - "startPosition": "2424" + "startPosition": "2471" }, - "endPosition": "2453", + "endPosition": "2500", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2424" + "startPosition": "2471" } ], - "startPosition": "2408" + "startPosition": "2453" }, - "startPosition": "2389" + "startPosition": "2434" }, { "expression": { "expression": { - "endPosition": "2499", + "endPosition": "2544", "kind": "IDENTIFIER", "name": "arr", - "startPosition": "2496" + "startPosition": "2541" }, - "endPosition": "2499", + "endPosition": "2544", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2490", + "endPosition": "2535", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2484" + "startPosition": "2529" }, - "endPosition": "2493", + "endPosition": "2538", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2492", + "endPosition": "2537", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2491" + "startPosition": "2536" }, - "startPosition": "2484" + "startPosition": "2529" }, - "startPosition": "2484" + "startPosition": "2529" }, - "endPosition": "2499", + "endPosition": "2544", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2484" + "startPosition": "2529" } ], - "startPosition": "2334" + "startPosition": "2375" } }, - "endPosition": "2840", + "endPosition": "2969", "kind": "IF", - "startPosition": "2213", + "startPosition": "2251", "thenStatement": { - "endPosition": "2296", + "endPosition": "2337", "kind": "BLOCK", "statements": [ { "expression": { "expression": { - "endPosition": "2286", + "endPosition": "2326", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "convert", "expression": { - "endPosition": "2273", + "endPosition": "2313", "kind": "IDENTIFIER", "name": "this", - "startPosition": "2269" + "startPosition": "2309" }, - "endPosition": "2281", + "endPosition": "2321", "kind": "MEMBER_SELECT", - "startPosition": "2269" + "startPosition": "2309" }, "arguments": [ { - "endPosition": "2285", + "endPosition": "2325", "kind": "IDENTIFIER", "name": "val", - "startPosition": "2282" + "startPosition": "2322" } ], - "startPosition": "2269" + "startPosition": "2309" }, - "endPosition": "2286", + "endPosition": "2326", "kind": "ASSIGNMENT", "variable": { "expression": { - "endPosition": "2263", + "endPosition": "2303", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2257" + "startPosition": "2297" }, - "endPosition": "2266", + "endPosition": "2306", "kind": "ARRAY_ACCESS", "index": { - "endPosition": "2265", + "endPosition": "2305", "kind": "IDENTIFIER", "name": "i", - "startPosition": "2264" + "startPosition": "2304" }, - "startPosition": "2257" + "startPosition": "2297" }, - "startPosition": "2257" + "startPosition": "2297" }, - "endPosition": "2286", + "endPosition": "2326", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2257" + "startPosition": "2297" } ], - "startPosition": "2245" + "startPosition": "2283" } } ], - "startPosition": "2179" + "startPosition": "2215" }, - "startPosition": "2160" + "startPosition": "2196" }, { "expression": { - "endPosition": "2862", + "endPosition": "2993", "kind": "IDENTIFIER", "name": "result", - "startPosition": "2856" + "startPosition": "2987" }, - "endPosition": "2863", + "endPosition": "2994", "kind": "RETURN", - "startPosition": "2849" + "startPosition": "2980" } ], - "startPosition": "2014" + "startPosition": "2016" }, "strict": "false", - "startPosition": "2014", + "startPosition": "2016", "parameters": [ { - "endPosition": "2012", + "endPosition": "2014", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "2008" + "startPosition": "2010" } ] }, - "endPosition": "2014", + "endPosition": "2016", "kind": "ASSIGNMENT", "variable": { "identifier": "convert", "expression": { "identifier": "prototype", "expression": { - "endPosition": "1978", + "endPosition": "1980", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "1972" + "startPosition": "1974" }, - "endPosition": "1988", + "endPosition": "1990", "kind": "MEMBER_SELECT", - "startPosition": "1972" + "startPosition": "1974" }, - "endPosition": "1996", + "endPosition": "1998", "kind": "MEMBER_SELECT", - "startPosition": "1972" + "startPosition": "1974" }, - "startPosition": "1972" + "startPosition": "1974" }, - "endPosition": "2865", + "endPosition": "2996", "kind": "EXPRESSION_STATEMENT", - "startPosition": "1972" + "startPosition": "1974" }, { - "endPosition": "3618", + "endPosition": "3767", "kind": "FUNCTION", "name": "processFiles", "body": { - "endPosition": "3575", + "endPosition": "3724", "kind": "BLOCK", "statements": [ { - "endPosition": "2938", + "endPosition": "3070", "kind": "VARIABLE", "name": "File", - "startPosition": "2906", + "startPosition": "3038", "initializer": { - "endPosition": "2938", + "endPosition": "3070", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "type", "expression": { - "endPosition": "2917", + "endPosition": "3049", "kind": "IDENTIFIER", "name": "Java", - "startPosition": "2913" + "startPosition": "3045" }, - "endPosition": "2922", + "endPosition": "3054", "kind": "MEMBER_SELECT", - "startPosition": "2913" + "startPosition": "3045" }, "arguments": [ { - "endPosition": "2936", + "endPosition": "3068", "kind": "STRING_LITERAL", "value": "java.io.File", - "startPosition": "2924" + "startPosition": "3056" } ], - "startPosition": "2913" + "startPosition": "3045" } }, { - "endPosition": "2993", + "endPosition": "3126", "kind": "VARIABLE", "name": "files", - "startPosition": "2947", + "startPosition": "3080", "initializer": { - "endPosition": "2993", + "endPosition": "3126", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "listFiles", "expression": { "constructorExpression": { - "endPosition": "2981", + "endPosition": "3114", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "2963", + "endPosition": "3096", "kind": "IDENTIFIER", "name": "File", - "startPosition": "2959" + "startPosition": "3092" }, "arguments": [ { "leftOperand": { - "endPosition": "2971", + "endPosition": "3104", "kind": "IDENTIFIER", "name": "__DIR__", - "startPosition": "2964" + "startPosition": "3097" }, - "endPosition": "2980", + "endPosition": "3113", "kind": "PLUS", "rightOperand": { - "endPosition": "2980", + "endPosition": "3113", "kind": "IDENTIFIER", "name": "subdir", - "startPosition": "2974" + "startPosition": "3107" }, - "startPosition": "2964" + "startPosition": "3097" } ], - "startPosition": "2959" + "startPosition": "3092" }, - "endPosition": "2981", + "endPosition": "3114", "kind": "NEW", - "startPosition": "2955" + "startPosition": "3088" }, - "endPosition": "2991", + "endPosition": "3124", "kind": "MEMBER_SELECT", - "startPosition": "2955" + "startPosition": "3088" }, "arguments": [], - "startPosition": "2955" + "startPosition": "3088" } }, { "expression": { - "endPosition": "3026", + "endPosition": "3160", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "sort", @@ -6291,751 +6412,751 @@ "expression": { "identifier": "util", "expression": { - "endPosition": "3002", + "endPosition": "3136", "kind": "IDENTIFIER", "name": "java", - "startPosition": "2998" + "startPosition": "3132" }, - "endPosition": "3007", + "endPosition": "3141", "kind": "MEMBER_SELECT", - "startPosition": "2998" + "startPosition": "3132" }, - "endPosition": "3014", + "endPosition": "3148", "kind": "MEMBER_SELECT", - "startPosition": "2998" + "startPosition": "3132" }, - "endPosition": "3019", + "endPosition": "3153", "kind": "MEMBER_SELECT", - "startPosition": "2998" + "startPosition": "3132" }, "arguments": [ { - "endPosition": "3025", + "endPosition": "3159", "kind": "IDENTIFIER", "name": "files", - "startPosition": "3020" + "startPosition": "3154" } ], - "startPosition": "2998" + "startPosition": "3132" }, - "endPosition": "3026", + "endPosition": "3160", "kind": "EXPRESSION_STATEMENT", - "startPosition": "2998" + "startPosition": "3132" }, { - "endPosition": "3049", + "endPosition": "3184", "kind": "VARIABLE", "name": "file", - "startPosition": "3045" + "startPosition": "3180" }, { "expression": { - "endPosition": "3058", + "endPosition": "3193", "kind": "IDENTIFIER", "name": "files", - "startPosition": "3053" + "startPosition": "3188" }, - "endPosition": "3575", + "endPosition": "3724", "kind": "FOR_IN_LOOP", "forEach": "true", "variable": { - "endPosition": "3049", + "endPosition": "3184", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3045" + "startPosition": "3180" }, "statement": { - "endPosition": "3575", + "endPosition": "3724", "kind": "BLOCK", "statements": [ { "condition": { - "endPosition": "3098", + "endPosition": "3234", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "endsWith", "expression": { "identifier": "name", "expression": { - "endPosition": "3077", + "endPosition": "3213", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3073" + "startPosition": "3209" }, - "endPosition": "3082", + "endPosition": "3218", "kind": "MEMBER_SELECT", - "startPosition": "3073" + "startPosition": "3209" }, - "endPosition": "3091", + "endPosition": "3227", "kind": "MEMBER_SELECT", - "startPosition": "3073" + "startPosition": "3209" }, "arguments": [ { - "endPosition": "3096", + "endPosition": "3232", "kind": "STRING_LITERAL", "value": ".js", - "startPosition": "3093" + "startPosition": "3229" } ], - "startPosition": "3073" + "startPosition": "3209" }, - "endPosition": "3570", + "endPosition": "3718", "kind": "IF", - "startPosition": "3069", + "startPosition": "3205", "thenStatement": { - "endPosition": "3570", + "endPosition": "3718", "kind": "BLOCK", "statements": [ { - "endPosition": "3141", + "endPosition": "3278", "kind": "VARIABLE", "name": "script", - "startPosition": "3117", + "startPosition": "3254", "initializer": { - "endPosition": "3141", + "endPosition": "3278", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3135", + "endPosition": "3272", "kind": "IDENTIFIER", "name": "readFully", - "startPosition": "3126" + "startPosition": "3263" }, "arguments": [ { - "endPosition": "3140", + "endPosition": "3277", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3136" + "startPosition": "3273" } ], - "startPosition": "3126" + "startPosition": "3263" } }, { - "endPosition": "3179", + "endPosition": "3317", "kind": "VARIABLE", "name": "parser", - "startPosition": "3158", + "startPosition": "3296", "initializer": { "constructorExpression": { - "endPosition": "3179", + "endPosition": "3317", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3177", + "endPosition": "3315", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "3171" + "startPosition": "3309" }, "arguments": [], - "startPosition": "3171" + "startPosition": "3309" }, - "endPosition": "3179", + "endPosition": "3317", "kind": "NEW", - "startPosition": "3167" + "startPosition": "3305" } }, { - "endPosition": "3435", + "endPosition": "3578", "kind": "VARIABLE", "name": "tree", - "startPosition": "3196", + "startPosition": "3335", "initializer": { - "endPosition": "3435", + "endPosition": "3578", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "parse", "expression": { - "endPosition": "3209", + "endPosition": "3348", "kind": "IDENTIFIER", "name": "parser", - "startPosition": "3203" + "startPosition": "3342" }, - "endPosition": "3215", + "endPosition": "3354", "kind": "MEMBER_SELECT", - "startPosition": "3203" + "startPosition": "3342" }, "arguments": [ { "leftOperand": { "leftOperand": { - "endPosition": "3222", + "endPosition": "3361", "kind": "IDENTIFIER", "name": "subdir", - "startPosition": "3216" + "startPosition": "3355" }, - "endPosition": "3227", + "endPosition": "3366", "kind": "PLUS", "rightOperand": { - "endPosition": "3227", + "endPosition": "3366", "kind": "STRING_LITERAL", "value": "/", - "startPosition": "3226" + "startPosition": "3365" }, - "startPosition": "3216" + "startPosition": "3355" }, - "endPosition": "3240", + "endPosition": "3379", "kind": "PLUS", "rightOperand": { "identifier": "name", "expression": { - "endPosition": "3235", + "endPosition": "3374", "kind": "IDENTIFIER", "name": "file", - "startPosition": "3231" + "startPosition": "3370" }, - "endPosition": "3240", + "endPosition": "3379", "kind": "MEMBER_SELECT", - "startPosition": "3231" + "startPosition": "3370" }, - "startPosition": "3216" + "startPosition": "3355" }, { - "endPosition": "3248", + "endPosition": "3387", "kind": "IDENTIFIER", "name": "script", - "startPosition": "3242" + "startPosition": "3381" }, { - "endPosition": "3286", + "endPosition": "3426", "kind": "FUNCTION_EXPRESSION", "body": { - "endPosition": "3417", + "endPosition": "3559", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "3385", + "endPosition": "3526", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3312", + "endPosition": "3453", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3307" + "startPosition": "3448" }, "arguments": [ { - "endPosition": "3384", + "endPosition": "3525", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "replace", "expression": { - "endPosition": "3364", + "endPosition": "3505", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "stringify", "expression": { - "endPosition": "3317", + "endPosition": "3458", "kind": "IDENTIFIER", "name": "JSON", - "startPosition": "3313" + "startPosition": "3454" }, - "endPosition": "3327", + "endPosition": "3468", "kind": "MEMBER_SELECT", - "startPosition": "3313" + "startPosition": "3454" }, "arguments": [ { - "endPosition": "3354", + "endPosition": "3495", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "convert", "expression": { - "endPosition": "3334", + "endPosition": "3475", "kind": "IDENTIFIER", "name": "parser", - "startPosition": "3328" + "startPosition": "3469" }, - "endPosition": "3342", + "endPosition": "3483", "kind": "MEMBER_SELECT", - "startPosition": "3328" + "startPosition": "3469" }, "arguments": [ { - "endPosition": "3353", + "endPosition": "3494", "kind": "IDENTIFIER", "name": "diagnostic", - "startPosition": "3343" + "startPosition": "3484" } ], - "startPosition": "3328" + "startPosition": "3469" }, { - "endPosition": "3360", + "endPosition": "3501", "kind": "NULL_LITERAL", - "startPosition": "3356" + "startPosition": "3497" }, { - "endPosition": "3363", + "endPosition": "3504", "kind": "NUMBER_LITERAL", "value": "2", - "startPosition": "3362" + "startPosition": "3503" } ], - "startPosition": "3313" + "startPosition": "3454" }, - "endPosition": "3372", + "endPosition": "3513", "kind": "MEMBER_SELECT", - "startPosition": "3313" + "startPosition": "3454" }, "arguments": [ { - "endPosition": "3379", + "endPosition": "3520", "kind": "REGEXP_LITERAL", "options": "g", "pattern": "\\\\r", - "startPosition": "3373" + "startPosition": "3514" }, { - "endPosition": "3382", + "endPosition": "3523", "kind": "STRING_LITERAL", "value": "", - "startPosition": "3382" + "startPosition": "3523" } ], - "startPosition": "3372" + "startPosition": "3513" } ], - "startPosition": "3307" + "startPosition": "3448" }, - "endPosition": "3385", + "endPosition": "3526", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3307" + "startPosition": "3448" }, { "expression": { - "endPosition": "3416", + "endPosition": "3558", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3411", + "endPosition": "3553", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3406" + "startPosition": "3548" }, "arguments": [ { - "endPosition": "3414", + "endPosition": "3556", "kind": "STRING_LITERAL", "value": ",", - "startPosition": "3413" + "startPosition": "3555" } ], - "startPosition": "3406" + "startPosition": "3548" }, - "endPosition": "3416", + "endPosition": "3558", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3406" + "startPosition": "3548" } ], - "startPosition": "3286" + "startPosition": "3426" }, "strict": "false", - "startPosition": "3286", + "startPosition": "3426", "parameters": [ { - "endPosition": "3284", + "endPosition": "3424", "kind": "IDENTIFIER", "name": "diagnostic", - "startPosition": "3274" + "startPosition": "3414" } ] } ], - "startPosition": "3203" + "startPosition": "3342" } }, { "condition": { "leftOperand": { - "endPosition": "3457", + "endPosition": "3601", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "3453" + "startPosition": "3597" }, - "endPosition": "3465", + "endPosition": "3609", "kind": "NOT_EQUAL_TO", "rightOperand": { - "endPosition": "3465", + "endPosition": "3609", "kind": "NULL_LITERAL", - "startPosition": "3461" + "startPosition": "3605" }, - "startPosition": "3453" + "startPosition": "3597" }, - "endPosition": "3561", + "endPosition": "3708", "kind": "IF", - "startPosition": "3449", + "startPosition": "3593", "thenStatement": { - "endPosition": "3561", + "endPosition": "3708", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "3520", + "endPosition": "3665", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3489", + "endPosition": "3634", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3484" + "startPosition": "3629" }, "arguments": [ { - "endPosition": "3519", + "endPosition": "3664", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "stringify", "expression": { - "endPosition": "3494", + "endPosition": "3639", "kind": "IDENTIFIER", "name": "JSON", - "startPosition": "3490" + "startPosition": "3635" }, - "endPosition": "3504", + "endPosition": "3649", "kind": "MEMBER_SELECT", - "startPosition": "3490" + "startPosition": "3635" }, "arguments": [ { - "endPosition": "3509", + "endPosition": "3654", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "3505" + "startPosition": "3650" }, { - "endPosition": "3515", + "endPosition": "3660", "kind": "NULL_LITERAL", - "startPosition": "3511" + "startPosition": "3656" }, { - "endPosition": "3518", + "endPosition": "3663", "kind": "NUMBER_LITERAL", "value": "2", - "startPosition": "3517" + "startPosition": "3662" } ], - "startPosition": "3490" + "startPosition": "3635" } ], - "startPosition": "3484" + "startPosition": "3629" }, - "endPosition": "3520", + "endPosition": "3665", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3484" + "startPosition": "3629" }, { "expression": { - "endPosition": "3547", + "endPosition": "3693", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3542", + "endPosition": "3688", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3537" + "startPosition": "3683" }, "arguments": [ { - "endPosition": "3545", + "endPosition": "3691", "kind": "STRING_LITERAL", "value": ",", - "startPosition": "3544" + "startPosition": "3690" } ], - "startPosition": "3537" + "startPosition": "3683" }, - "endPosition": "3547", + "endPosition": "3693", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3537" + "startPosition": "3683" } ], - "startPosition": "3467" + "startPosition": "3611" } } ], - "startPosition": "3100" + "startPosition": "3236" } } ], - "startPosition": "3060" + "startPosition": "3195" }, - "startPosition": "3031" + "startPosition": "3166" } ], - "startPosition": "2897" + "startPosition": "3028" }, "strict": "false", - "startPosition": "2867", + "startPosition": "2998", "parameters": [ { - "endPosition": "2895", + "endPosition": "3026", "kind": "IDENTIFIER", "name": "subdir", - "startPosition": "2889" + "startPosition": "3020" } ] }, { - "endPosition": "3921", + "endPosition": "4070", "kind": "FUNCTION", "name": "main", "body": { - "endPosition": "3919", + "endPosition": "4068", "kind": "BLOCK", "statements": [ { "expression": { - "endPosition": "3651", + "endPosition": "3800", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3646", + "endPosition": "3795", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3641" + "startPosition": "3790" }, "arguments": [ { - "endPosition": "3649", + "endPosition": "3798", "kind": "STRING_LITERAL", "value": "[", - "startPosition": "3648" + "startPosition": "3797" } ], - "startPosition": "3641" + "startPosition": "3790" }, - "endPosition": "3651", + "endPosition": "3800", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3641" + "startPosition": "3790" }, { "expression": { - "endPosition": "3685", + "endPosition": "3834", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3670", + "endPosition": "3819", "kind": "IDENTIFIER", "name": "processFiles", - "startPosition": "3658" + "startPosition": "3807" }, "arguments": [ { - "endPosition": "3683", + "endPosition": "3832", "kind": "STRING_LITERAL", "value": "parsertests", - "startPosition": "3672" + "startPosition": "3821" } ], - "startPosition": "3658" + "startPosition": "3807" }, - "endPosition": "3685", + "endPosition": "3834", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3658" + "startPosition": "3807" }, { "expression": { - "endPosition": "3726", + "endPosition": "3875", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3703", + "endPosition": "3852", "kind": "IDENTIFIER", "name": "processFiles", - "startPosition": "3691" + "startPosition": "3840" }, "arguments": [ { - "endPosition": "3724", + "endPosition": "3873", "kind": "STRING_LITERAL", "value": "parsernegativetests", - "startPosition": "3705" + "startPosition": "3854" } ], - "startPosition": "3691" + "startPosition": "3840" }, - "endPosition": "3726", + "endPosition": "3875", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3691" + "startPosition": "3840" }, { - "endPosition": "3795", + "endPosition": "3944", "kind": "VARIABLE", "name": "script", - "startPosition": "3767", + "startPosition": "3916", "initializer": { - "endPosition": "3795", + "endPosition": "3944", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3785", + "endPosition": "3934", "kind": "IDENTIFIER", "name": "readFully", - "startPosition": "3776" + "startPosition": "3925" }, "arguments": [ { - "endPosition": "3794", + "endPosition": "3943", "kind": "IDENTIFIER", "name": "__FILE__", - "startPosition": "3786" + "startPosition": "3935" } ], - "startPosition": "3776" + "startPosition": "3925" } }, { - "endPosition": "3860", + "endPosition": "4009", "kind": "VARIABLE", "name": "tree", - "startPosition": "3805", + "startPosition": "3954", "initializer": { - "endPosition": "3860", + "endPosition": "4009", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "parse", "expression": { "constructorExpression": { - "endPosition": "3824", + "endPosition": "3973", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3822", + "endPosition": "3971", "kind": "IDENTIFIER", "name": "Parser", - "startPosition": "3816" + "startPosition": "3965" }, "arguments": [], - "startPosition": "3816" + "startPosition": "3965" }, - "endPosition": "3824", + "endPosition": "3973", "kind": "NEW", - "startPosition": "3812" + "startPosition": "3961" }, - "endPosition": "3830", + "endPosition": "3979", "kind": "MEMBER_SELECT", - "startPosition": "3812" + "startPosition": "3961" }, "arguments": [ { - "endPosition": "3844", + "endPosition": "3993", "kind": "STRING_LITERAL", "value": "parserapi.js", - "startPosition": "3832" + "startPosition": "3981" }, { - "endPosition": "3853", + "endPosition": "4002", "kind": "IDENTIFIER", "name": "script", - "startPosition": "3847" + "startPosition": "3996" }, { - "endPosition": "3859", + "endPosition": "4008", "kind": "NULL_LITERAL", - "startPosition": "3855" + "startPosition": "4004" } ], - "startPosition": "3812" + "startPosition": "3961" } }, { "expression": { - "endPosition": "3902", + "endPosition": "4051", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3871", + "endPosition": "4020", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3866" + "startPosition": "4015" }, "arguments": [ { - "endPosition": "3901", + "endPosition": "4050", "kind": "FUNCTION_INVOCATION", "functionSelect": { "identifier": "stringify", "expression": { - "endPosition": "3876", + "endPosition": "4025", "kind": "IDENTIFIER", "name": "JSON", - "startPosition": "3872" + "startPosition": "4021" }, - "endPosition": "3886", + "endPosition": "4035", "kind": "MEMBER_SELECT", - "startPosition": "3872" + "startPosition": "4021" }, "arguments": [ { - "endPosition": "3891", + "endPosition": "4040", "kind": "IDENTIFIER", "name": "tree", - "startPosition": "3887" + "startPosition": "4036" }, { - "endPosition": "3897", + "endPosition": "4046", "kind": "NULL_LITERAL", - "startPosition": "3893" + "startPosition": "4042" }, { - "endPosition": "3900", + "endPosition": "4049", "kind": "NUMBER_LITERAL", "value": "2", - "startPosition": "3899" + "startPosition": "4048" } ], - "startPosition": "3872" + "startPosition": "4021" } ], - "startPosition": "3866" + "startPosition": "4015" }, - "endPosition": "3902", + "endPosition": "4051", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3866" + "startPosition": "4015" }, { "expression": { - "endPosition": "3918", + "endPosition": "4067", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3913", + "endPosition": "4062", "kind": "IDENTIFIER", "name": "print", - "startPosition": "3908" + "startPosition": "4057" }, "arguments": [ { - "endPosition": "3916", + "endPosition": "4065", "kind": "STRING_LITERAL", "value": "]", - "startPosition": "3915" + "startPosition": "4064" } ], - "startPosition": "3908" + "startPosition": "4057" }, - "endPosition": "3918", + "endPosition": "4067", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3908" + "startPosition": "4057" } ], - "startPosition": "3635" + "startPosition": "3784" }, "strict": "false", - "startPosition": "3619", + "startPosition": "3768", "parameters": [] }, { "expression": { - "endPosition": "3929", + "endPosition": "4078", "kind": "FUNCTION_INVOCATION", "functionSelect": { - "endPosition": "3927", + "endPosition": "4076", "kind": "IDENTIFIER", "name": "main", - "startPosition": "3923" + "startPosition": "4072" }, "arguments": [], - "startPosition": "3923" + "startPosition": "4072" }, - "endPosition": "3929", + "endPosition": "4078", "kind": "EXPRESSION_STATEMENT", - "startPosition": "3923" + "startPosition": "4072" } ], "sourceName": "parserapi.js", "strict": "false", "startPosition": "1136" -} -] +} +] From a937465980afc40f237a586a4f8373421a310123 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Tue, 12 Jan 2016 17:54:09 -0500 Subject: [PATCH 054/109] 8146671: [TEST BUG] java/lang/ref/CleanerTest.java required more memory for -UseCompressedOops runs Reviewed-by: joehw --- jdk/test/java/lang/ref/CleanerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/java/lang/ref/CleanerTest.java b/jdk/test/java/lang/ref/CleanerTest.java index 83fa9e5f734..fedcaf88713 100644 --- a/jdk/test/java/lang/ref/CleanerTest.java +++ b/jdk/test/java/lang/ref/CleanerTest.java @@ -53,7 +53,7 @@ import org.testng.annotations.Test; * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run testng/othervm * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. - * -verbose:gc -Xmx4m CleanerTest + * -verbose:gc CleanerTest */ @Test From 05799f8d81080b229c163ec3c758b46070a6d6d8 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 12 Jan 2016 15:07:27 -0800 Subject: [PATCH 055/109] 8145722: NullPointerException in javadoc Reviewed-by: ksrini --- .../tools/doclets/internal/toolkit/util/VisibleMemberMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java index 17743cd7166..487215ca4a0 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -248,7 +248,7 @@ public class VisibleMemberMap { for (ProgramElementDoc element : list) { Object key = getMemberKey(element); Map memberLevelMap = memberNameMap.get(key); - if (level.equals(memberLevelMap.get(element))) + if (memberLevelMap != null && level.equals(memberLevelMap.get(element))) memberLevelMap.remove(element); } } From fdb8990307ced67675065f3c95d26dfca8bcea31 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 12 Jan 2016 15:29:21 -0800 Subject: [PATCH 056/109] 8144966: Catalog API: Null handling and reference to Reader Reviewed-by: mchung, rriggs --- .../javax/xml/catalog/CatalogImpl.java | 42 ++++++--- .../javax/xml/catalog/CatalogManager.java | 91 +++++++++++-------- .../javax/xml/catalog/CatalogUriResolver.java | 6 +- .../functional/catalog/DeferFeatureTest.java | 25 ++--- .../jaxp/libs/catalog/CatalogTestUtils.java | 14 +-- .../libs/jaxp/library/JAXPTestUtilities.java | 2 +- .../jaxp/unittest/catalog/CatalogTest.java | 26 +++++- 7 files changed, 123 insertions(+), 83 deletions(-) diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java index ee6a29bfa26..7be69b9ea29 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java @@ -32,7 +32,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -43,6 +42,7 @@ import java.util.stream.StreamSupport; import static javax.xml.catalog.BaseEntry.CatalogEntryType; import static javax.xml.catalog.CatalogFeatures.DEFER_TRUE; import javax.xml.catalog.CatalogFeatures.Feature; +import static javax.xml.catalog.CatalogMessages.formatMessage; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; @@ -109,25 +109,20 @@ class CatalogImpl extends GroupEntry implements Catalog { */ public CatalogImpl(CatalogImpl parent, CatalogFeatures f, String... file) throws CatalogException { super(CatalogEntryType.CATALOG); - this.parent = parent; - if (parent == null) { - level = 0; - } else { - level = parent.level + 1; - } if (f == null) { - this.features = CatalogFeatures.defaults(); - } else { - this.features = f; + throw new NullPointerException( + formatMessage(CatalogMessages.ERR_NULL_ARGUMENT, new Object[]{"CatalogFeatures"})); } - setPrefer(features.get(Feature.PREFER)); - setDeferred(features.get(Feature.DEFER)); - setResolve(features.get(Feature.RESOLVE)); + + if (file.length > 0) { + CatalogMessages.reportNPEOnNull("The path to the catalog file", file[0]); + } + + init(parent, f); //Path of catalog files String[] catalogFile = file; - if (level == 0 - && (file == null || (file.length == 0 || file[0] == null))) { + if (level == 0 && file.length == 0) { String files = features.get(Feature.FILES); if (files != null) { catalogFile = files.split(";[ ]*"); @@ -166,6 +161,23 @@ class CatalogImpl extends GroupEntry implements Catalog { } } + private void init(CatalogImpl parent, CatalogFeatures f) { + this.parent = parent; + if (parent == null) { + level = 0; + } else { + level = parent.level + 1; + } + if (f == null) { + this.features = CatalogFeatures.defaults(); + } else { + this.features = f; + } + setPrefer(features.get(Feature.PREFER)); + setDeferred(features.get(Feature.DEFER)); + setResolve(features.get(Feature.RESOLVE)); + } + /** * Resets the Catalog instance to its initial state. */ diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java index 7539ec00be9..2e3c5b4f74b 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java @@ -38,33 +38,38 @@ public final class CatalogManager { } /** - * Creates a Catalog object using the specified feature settings and path to - * a catalog file. If the features is null, the default features will be used. - * If the path is empty, System property {@code javax.xml.catalog.files} will - * be read to locate the initial list of catalog files. + * Creates a {@code Catalog} object using the specified feature settings and + * path to one or more catalog files. *

- * If more than one catalog files are specified through the path argument or + * If {@code paths} is empty, system property {@code javax.xml.catalog.files} + * will be read to locate the initial list of catalog files. + *

+ * If more than one catalog files are specified through the paths argument or * {@code javax.xml.catalog.files} property, the first entry is considered * the main catalog, while others are treated as alternative catalogs after * those referenced by the {@code nextCatalog} elements in the main catalog. + *

+ * As specified in + * + * XML Catalogs, OASIS Standard V1.1, invalid path entries will be ignored. + * No error will be reported. In case all entries are invalid, the resolver + * will return as no mapping is found. * * @param features the catalog features - * @param path path(s) to one or more catalogs. + * @param paths path(s) to one or more catalogs. * - * @return a catalog instance - * @throws CatalogException If no catalog can be found whether through the - * specified path or the System property {@code javax.xml.catalog.files}, or - * an error occurs while parsing the catalog + * @return an instance of a {@code Catalog} + * @throws CatalogException If an error occurs while parsing the catalog */ - public static Catalog catalog(CatalogFeatures features, String... path) { - return new CatalogImpl(features, path); + public static Catalog catalog(CatalogFeatures features, String... paths) { + return new CatalogImpl(features, paths); } /** - * Creates an instance of a CatalogResolver using the specified catalog. + * Creates an instance of a {@code CatalogResolver} using the specified catalog. * * @param catalog the catalog instance - * @return an instance of a CatalogResolver + * @return an instance of a {@code CatalogResolver} */ public static CatalogResolver catalogResolver(Catalog catalog) { if (catalog == null) CatalogMessages.reportNPEOnNull("catalog", null); @@ -72,10 +77,10 @@ public final class CatalogManager { } /** - * Creates an instance of a CatalogUriResolver using the specified catalog. + * Creates an instance of a {@code CatalogUriResolver} using the specified catalog. * * @param catalog the catalog instance - * @return an instance of a CatalogResolver + * @return an instance of a {@code CatalogResolver} */ public static CatalogUriResolver catalogUriResolver(Catalog catalog) { if (catalog == null) CatalogMessages.reportNPEOnNull("catalog", null); @@ -83,50 +88,60 @@ public final class CatalogManager { } /** - * Creates an instance of a CatalogResolver using the specified feature settings - * and path to a catalog file. If the features is null, the default features will - * be used. If the path is empty, System property {@code javax.xml.catalog.files} + * Creates an instance of a {@code CatalogResolver} using the specified feature + * settings and path to one or more catalog files. + *

+ * If {@code paths} is empty, system property {@code javax.xml.catalog.files} * will be read to locate the initial list of catalog files. *

- * If more than one catalog files are specified through the path argument or + * If more than one catalog files are specified through the paths argument or * {@code javax.xml.catalog.files} property, the first entry is considered * the main catalog, while others are treated as alternative catalogs after * those referenced by the {@code nextCatalog} elements in the main catalog. + *

+ * As specified in + * + * XML Catalogs, OASIS Standard V1.1, invalid path entries will be ignored. + * No error will be reported. In case all entries are invalid, the resolver + * will return as no mapping is found. * * @param features the catalog features - * @param path the path(s) to one or more catalogs + * @param paths the path(s) to one or more catalogs * - * @return an instance of a CatalogResolver - * @throws CatalogException If no catalog can be found whether through the - * specified path or the System property {@code javax.xml.catalog.files}, or - * an error occurs while parsing the catalog + * @return an instance of a {@code CatalogResolver} + * @throws CatalogException If an error occurs while parsing the catalog */ - public static CatalogResolver catalogResolver(CatalogFeatures features, String... path) { - Catalog catalog = catalog(features, path); + public static CatalogResolver catalogResolver(CatalogFeatures features, String... paths) { + Catalog catalog = catalog(features, paths); return new CatalogResolverImpl(catalog); } /** - * Creates an instance of a CatalogUriResolver using the specified feature settings - * and path to a catalog file. If the features is null, the default features will - * be used. If the path is empty, System property {@code javax.xml.catalog.files} + * Creates an instance of a {@code CatalogUriResolver} using the specified + * feature settings and path to one or more catalog files. + *

+ * If {@code paths} is empty, system property {@code javax.xml.catalog.files} * will be read to locate the initial list of catalog files. *

- * If more than one catalog files are specified through the path argument or + * If more than one catalog files are specified through the paths argument or * {@code javax.xml.catalog.files} property, the first entry is considered * the main catalog, while others are treated as alternative catalogs after * those referenced by the {@code nextCatalog} elements in the main catalog. + *

+ * As specified in + * + * XML Catalogs, OASIS Standard V1.1, invalid path entries will be ignored. + * No error will be reported. In case all entries are invalid, the resolver + * will return as no mapping is found. * * @param features the catalog features - * @param path the path(s) to one or more catalogs + * @param paths the path(s) to one or more catalogs * - * @return an instance of a CatalogResolver - * @throws CatalogException If no catalog can be found whether through the - * specified path or the System property {@code javax.xml.catalog.files}, or - * an error occurs while parsing the catalog + * @return an instance of a {@code CatalogUriResolver} + * @throws CatalogException If an error occurs while parsing the catalog */ - public static CatalogUriResolver catalogUriResolver(CatalogFeatures features, String... path) { - Catalog catalog = catalog(features, path); + public static CatalogUriResolver catalogUriResolver(CatalogFeatures features, String... paths) { + Catalog catalog = catalog(features, paths); return new CatalogUriResolverImpl(catalog); } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java index 13c0e3791e4..76ba60dd2eb 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java @@ -43,9 +43,9 @@ public interface CatalogUriResolver extends URIResolver { * absolute if the absolute URI is required * * @return a {@link javax.xml.transform.Source} object if a mapping is found. - * If no mapping is found, returns a {@link javax.xml.transform.Source} object - * containing an empty {@link java.io.Reader} if the - * {@code javax.xml.catalog.resolve} property is set to {@code ignore}; + * If no mapping is found, returns an empty {@link javax.xml.transform.Source} + * object if the {@code javax.xml.catalog.resolve} property is set to + * {@code ignore}; * returns a {@link javax.xml.transform.Source} object with the original URI * (href, or href resolved with base if base is not null) if the * {@code javax.xml.catalog.resolve} property is set to {@code continue}. diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java index cde6fafa8cc..a0066a9a0e5 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java @@ -56,23 +56,14 @@ public class DeferFeatureTest { @DataProvider(name = "catalog-countOfLoadedCatalogFile") private Object[][] data() { - return new Object[][] { - // This catalog specifies null catalog explicitly, - // and the count of loaded catalogs should be 0. - { createCatalog(null), 0 }, - - // This catalog specifies null catalog implicitly, - // and the count of loaded catalogs should be 0. - { createCatalog(CatalogFeatures.defaults()), 0 }, - - // This catalog loads null catalog with true DEFER, - // and the count of loaded catalogs should be 0. - { createCatalog(createDeferFeature(DEFER_TRUE)), 0 }, - - // This catalog loads null catalog with false DEFER. - // It should load all of none-current catalogs and the - // count of loaded catalogs should be 3. - { createCatalog(createDeferFeature(DEFER_FALSE)), 3 } }; + return new Object[][]{ + // By default, alternative catalogs are not loaded. + {createCatalog(CatalogFeatures.defaults()), 0}, + // Alternative catalogs are not loaded when DEFER is set to true. + {createCatalog(createDeferFeature(DEFER_TRUE)), 0}, + // The 3 alternative catalogs are not pre-loaded + //when DEFER is set to false. + {createCatalog(createDeferFeature(DEFER_FALSE)), 3}}; } private CatalogFeatures createDeferFeature(String defer) { diff --git a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java index 291d86d02c0..0e0ff9f194c 100644 --- a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java +++ b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java @@ -83,7 +83,7 @@ final class CatalogTestUtils { * Creates CatalogResolver with a set of catalogs. */ static CatalogResolver catalogResolver(String... catalogName) { - return catalogResolver(null, catalogName); + return catalogResolver(CatalogFeatures.defaults(), catalogName); } /* @@ -91,15 +91,16 @@ final class CatalogTestUtils { */ static CatalogResolver catalogResolver(CatalogFeatures features, String... catalogName) { - return CatalogManager.catalogResolver(features, - getCatalogPaths(catalogName)); + return (catalogName == null) ? + CatalogManager.catalogResolver(features) : + CatalogManager.catalogResolver(features, getCatalogPaths(catalogName)); } /* * Creates catalogUriResolver with a set of catalogs. */ static CatalogUriResolver catalogUriResolver(String... catalogName) { - return catalogUriResolver(null, catalogName); + return catalogUriResolver(CatalogFeatures.defaults(), catalogName); } /* @@ -107,8 +108,9 @@ final class CatalogTestUtils { */ static CatalogUriResolver catalogUriResolver( CatalogFeatures features, String... catalogName) { - return CatalogManager.catalogUriResolver(features, - getCatalogPaths(catalogName)); + return (catalogName == null) ? + CatalogManager.catalogUriResolver(features) : + CatalogManager.catalogUriResolver(features, getCatalogPaths(catalogName)); } // Gets the paths of the specified catalogs. diff --git a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java index a7f18083d30..8269f05eee1 100644 --- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java +++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java @@ -89,7 +89,7 @@ public class JAXPTestUtilities { /** * BOM table for storing BOM header. */ - private final static Map bom = new HashMap(); + private final static Map bom = new HashMap<>(); /** * Initialize all BOM headers. diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java index a9515da6676..42cb5601aa0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java @@ -42,11 +42,31 @@ import org.xml.sax.XMLReader; import org.xml.sax.ext.DefaultHandler2; /* - * @bug 8081248 + * @bug 8081248, 8144966 * @summary Tests basic Catalog functions. */ public class CatalogTest { + /* + @bug 8144966 + Verifies that passing null as CatalogFeatures will result in a NPE. + */ + @Test(expectedExceptions = NullPointerException.class) + public void testFeatureNull() { + CatalogResolver resolver = CatalogManager.catalogResolver(null, ""); + + } + + /* + @bug 8144966 + Verifies that passing null as the path will result in a NPE. + */ + @Test(expectedExceptions = NullPointerException.class) + public void testPathNull() { + String path = null; + CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), path); + } + /* Tests basic catalog feature by using a CatalogResolver instance to resolve a DTD reference to a locally specified DTD file. If the resolution @@ -61,7 +81,7 @@ public class CatalogTest { } String url = getClass().getResource(xml).getFile(); try { - CatalogResolver cr = CatalogManager.catalogResolver(null, catalog); + CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); XMLReader reader = saxParser.getXMLReader(); reader.setEntityResolver(cr); MyHandler handler = new MyHandler(saxParser); @@ -84,7 +104,7 @@ public class CatalogTest { String test = "testInvalidCatalog"; try { - CatalogResolver resolver = CatalogManager.catalogResolver(null, catalog); + CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); String actualSystemId = resolver.resolveEntity(null, "http://remote/xml/dtd/sys/alice/docAlice.dtd").getSystemId(); } catch (Exception e) { String msg = e.getMessage(); From 94ec0f9c5732f3d656105ba8b92699003664faf2 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Wed, 13 Jan 2016 14:51:40 +0800 Subject: [PATCH 057/109] 8146762: Move back java/util/concurrent/Phaser/Basic.java to tier1 Reviewed-by: chegar --- jdk/test/TEST.groups | 2 -- 1 file changed, 2 deletions(-) diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 487d22633b1..b62eeb51377 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -31,7 +31,6 @@ tier1 = \ -java/util/zip/TestLocalTime.java \ :jdk_util \ -java/util/WeakHashMap/GCDuringIteration.java \ - -java/util/concurrent/Phaser/Basic.java \ -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java sun/nio/cs/ISO8859x.java \ java/nio/Buffer \ @@ -41,7 +40,6 @@ tier1 = \ tier2 = \ java/lang/ProcessHandle/TreeTest.java \ java/util/zip/TestLocalTime.java \ - java/util/concurrent/Phaser/Basic.java \ java/util/WeakHashMap/GCDuringIteration.java \ java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ :jdk_io \ From 1ee440e9bcae9d722bd7210dc9dc70f96121673e Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 13 Jan 2016 14:24:34 +0100 Subject: [PATCH 058/109] 8144906: Fix jshell's ToolBasicTest Various fixes to fix the ToolBasicTest - line endings normalization, ordering for output from RemoteAgent, synchronization. Reviewed-by: rfield --- .../internal/jshell/remote/RemoteAgent.java | 70 +++++++++- .../classes/jdk/jshell/ExecutionControl.java | 125 +++++++++++++++++- .../classes/jdk/jshell/JDIConnection.java | 12 +- .../test/jdk/jshell/ReplToolTesting.java | 12 +- langtools/test/jdk/jshell/ToolBasicTest.java | 21 ++- 5 files changed, 220 insertions(+), 20 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java index bbebbfe2077..5ac073b1b9a 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteAgent.java @@ -28,6 +28,9 @@ import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -35,7 +38,9 @@ import java.net.Socket; import java.util.ArrayList; import java.util.List; + import static jdk.internal.jshell.remote.RemoteCodes.*; + import java.util.Map; import java.util.TreeMap; @@ -59,7 +64,10 @@ class RemoteAgent { void commandLoop(Socket socket) throws IOException { // in before out -- so we don't hang the controlling process ObjectInputStream in = new ObjectInputStream(socket.getInputStream()); - ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); + OutputStream socketOut = socket.getOutputStream(); + System.setOut(new PrintStream(new MultiplexingOutputStream("out", socketOut), true)); + System.setErr(new PrintStream(new MultiplexingOutputStream("err", socketOut), true)); + ObjectOutputStream out = new ObjectOutputStream(new MultiplexingOutputStream("command", socketOut)); while (true) { int cmd = in.readInt(); switch (cmd) { @@ -260,4 +268,64 @@ class RemoteAgent { } return sb.toString(); } + + private static final class MultiplexingOutputStream extends OutputStream { + + private static final int PACKET_SIZE = 127; + + private final byte[] name; + private final OutputStream delegate; + + public MultiplexingOutputStream(String name, OutputStream delegate) { + try { + this.name = name.getBytes("UTF-8"); + this.delegate = delegate; + } catch (UnsupportedEncodingException ex) { + throw new IllegalStateException(ex); //should not happen + } + } + + @Override + public void write(int b) throws IOException { + synchronized (delegate) { + delegate.write(name.length); //assuming the len is small enough to fit into byte + delegate.write(name); + delegate.write(1); + delegate.write(b); + delegate.flush(); + } + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + synchronized (delegate) { + int i = 0; + while (len > 0) { + int size = Math.min(PACKET_SIZE, len); + + delegate.write(name.length); //assuming the len is small enough to fit into byte + delegate.write(name); + delegate.write(size); + delegate.write(b, off + i, size); + i += size; + len -= size; + } + + delegate.flush(); + } + } + + @Override + public void flush() throws IOException { + super.flush(); + delegate.flush(); + } + + @Override + public void close() throws IOException { + super.close(); + delegate.close(); + } + + } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java index 6e6b02ae9b9..ad115656661 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java @@ -26,9 +26,12 @@ package jdk.jshell; import static jdk.internal.jshell.remote.RemoteCodes.*; +import java.io.DataInputStream; +import java.io.InputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.PrintStream; import java.net.ServerSocket; import java.net.Socket; import com.sun.jdi.*; @@ -69,7 +72,9 @@ class ExecutionControl { socket = listener.accept(); // out before in -- match remote creation so we don't hang out = new ObjectOutputStream(socket.getOutputStream()); - in = new ObjectInputStream(socket.getInputStream()); + PipeInputStream commandIn = new PipeInputStream(); + new DemultiplexInput(socket.getInputStream(), commandIn, proc.out, proc.err).start(); + in = new ObjectInputStream(commandIn); } } @@ -117,11 +122,13 @@ class ExecutionControl { String result = in.readUTF(); return result; } - } catch (EOFException ex) { - env.shutdown(); } catch (IOException | ClassNotFoundException ex) { - proc.debug(DBG_GEN, "Exception on remote invoke: %s\n", ex); - return "Execution failure: " + ex.getMessage(); + if (!env.connection().isRunning()) { + env.shutdown(); + } else { + proc.debug(DBG_GEN, "Exception on remote invoke: %s\n", ex); + return "Execution failure: " + ex.getMessage(); + } } finally { synchronized (STOP_LOCK) { userCodeRunning = false; @@ -310,4 +317,112 @@ class ExecutionControl { } } } + + private final class DemultiplexInput extends Thread { + + private final DataInputStream delegate; + private final PipeInputStream command; + private final PrintStream out; + private final PrintStream err; + + public DemultiplexInput(InputStream input, + PipeInputStream command, + PrintStream out, + PrintStream err) { + super("output reader"); + this.delegate = new DataInputStream(input); + this.command = command; + this.out = out; + this.err = err; + } + + public void run() { + try { + while (true) { + int nameLen = delegate.read(); + if (nameLen == (-1)) + break; + byte[] name = new byte[nameLen]; + DemultiplexInput.this.delegate.readFully(name); + int dataLen = delegate.read(); + byte[] data = new byte[dataLen]; + DemultiplexInput.this.delegate.readFully(data); + switch (new String(name, "UTF-8")) { + case "err": + err.write(data); + break; + case "out": + out.write(data); + break; + case "command": + for (byte b : data) { + command.write(Byte.toUnsignedInt(b)); + } + break; + } + } + } catch (IOException ex) { + proc.debug(ex, "Failed reading output"); + } finally { + command.close(); + } + } + + } + + public static final class PipeInputStream extends InputStream { + public static final int INITIAL_SIZE = 128; + + private int[] buffer = new int[INITIAL_SIZE]; + private int start; + private int end; + private boolean closed; + + @Override + public synchronized int read() { + while (start == end) { + if (closed) { + return -1; + } + try { + wait(); + } catch (InterruptedException ex) { + //ignore + } + } + try { + return buffer[start]; + } finally { + start = (start + 1) % buffer.length; + } + } + + public synchronized void write(int b) { + if (closed) + throw new IllegalStateException("Already closed."); + int newEnd = (end + 1) % buffer.length; + if (newEnd == start) { + //overflow: + int[] newBuffer = new int[buffer.length * 2]; + int rightPart = (end > start ? end : buffer.length) - start; + int leftPart = end > start ? 0 : start - 1; + System.arraycopy(buffer, start, newBuffer, 0, rightPart); + System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart); + buffer = newBuffer; + start = 0; + end = rightPart + leftPart; + newEnd = end + 1; + } + buffer[end] = b; + end = newEnd; + notifyAll(); + } + + @Override + public synchronized void close() { + closed = true; + notifyAll(); + } + + } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java index d1a68130c67..56cf4d95f9d 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java @@ -133,7 +133,7 @@ class JDIConnection { return vm; } - boolean setConnectorArg(String name, String value) { + synchronized boolean setConnectorArg(String name, String value) { /* * Too late if the connection already made */ @@ -165,7 +165,7 @@ class JDIConnection { } } - boolean isOpen() { + synchronized boolean isOpen() { return (vm != null); } @@ -173,13 +173,17 @@ class JDIConnection { return (connector instanceof LaunchingConnector); } - public void disposeVM() { + synchronized boolean isRunning() { + return process != null && process.isAlive(); + } + + public synchronized void disposeVM() { try { if (vm != null) { vm.dispose(); // This could NPE, so it is caught below vm = null; } - } catch (VMDisconnectedException | NullPointerException ex) { + } catch (VMDisconnectedException ex) { // Ignore if already closed } finally { if (process != null) { diff --git a/langtools/test/jdk/jshell/ReplToolTesting.java b/langtools/test/jdk/jshell/ReplToolTesting.java index a4d1fab3f21..05dd5389e0b 100644 --- a/langtools/test/jdk/jshell/ReplToolTesting.java +++ b/langtools/test/jdk/jshell/ReplToolTesting.java @@ -152,13 +152,13 @@ public class ReplToolTesting { } public String getCommandOutput() { - String s = cmdout.toString(); + String s = normalizeLineEndings(cmdout.toString()); cmdout.reset(); return s; } public String getCommandErrorOutput() { - String s = cmderr.toString(); + String s = normalizeLineEndings(cmderr.toString()); cmderr.reset(); return s; } @@ -168,13 +168,13 @@ public class ReplToolTesting { } public String getUserOutput() { - String s = userout.toString(); + String s = normalizeLineEndings(userout.toString()); userout.reset(); return s; } public String getUserErrorOutput() { - String s = usererr.toString(); + String s = normalizeLineEndings(usererr.toString()); usererr.reset(); return s; } @@ -461,6 +461,10 @@ public class ReplToolTesting { } } + private String normalizeLineEndings(String text) { + return text.replace(System.getProperty("line.separator"), "\n"); + } + public static abstract class MemberInfo { public final String source; public final String type; diff --git a/langtools/test/jdk/jshell/ToolBasicTest.java b/langtools/test/jdk/jshell/ToolBasicTest.java index 03c0e29d9af..eff362d7f1f 100644 --- a/langtools/test/jdk/jshell/ToolBasicTest.java +++ b/langtools/test/jdk/jshell/ToolBasicTest.java @@ -23,14 +23,16 @@ /* * @test - * @bug 8143037 8142447 8144095 8140265 + * @bug 8143037 8142447 8144095 8140265 8144906 + * @requires os.family != "solaris" * @summary Tests for Basic tests for REPL tool * @library /tools/lib * @ignore 8139873 * @build KullaTesting TestingInputStream ToolBox Compiler - * @run testng ToolBasicTest + * @run testng/timeout=600 ToolBasicTest */ +import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; @@ -460,8 +462,7 @@ public class ToolBasicTest extends ReplToolTesting { Path unknown = compiler.getPath("UNKNOWN.jar"); test(true, new String[]{unknown.toString()}, "| File '" + unknown - + "' is not found: " + unknown - + " (No such file or directory)\n"); + + "' is not found: " + unresolvableMessage(unknown) + "\n"); } public void testReset() { @@ -514,8 +515,7 @@ public class ToolBasicTest extends ReplToolTesting { test( (a) -> assertCommand(a, s + " " + unknown, "| File '" + unknown - + "' is not found: " + unknown - + " (No such file or directory)\n") + + "' is not found: " + unresolvableMessage(unknown) + "\n") ); } } @@ -874,6 +874,15 @@ public class ToolBasicTest extends ReplToolTesting { ); } + private String unresolvableMessage(Path p) { + try { + new FileInputStream(p.toFile()); + throw new AssertionError("Expected exception did not occur."); + } catch (IOException ex) { + return ex.getMessage(); + } + } + public void testCommandPrefix() { test(a -> assertCommandCheckOutput(a, "/s", assertStartsWith("| Command: /s is ambiguous: /seteditor, /save, /setstart")), From 9884b80330e99970f5500b21c7062fc089016816 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 13 Jan 2016 13:33:37 +0000 Subject: [PATCH 059/109] 8146735: Move sun.misc.PerformanceLogger to sun.awt.util Reviewed-by: alanb, mchung, rriggs --- jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java | 2 +- .../share/classes/sun/awt/util}/PerformanceLogger.java | 2 +- .../java.desktop/share/classes/sun/java2d/SunGraphics2D.java | 2 +- jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java | 1 + .../java.desktop/windows/classes/sun/awt/windows/WToolkit.java | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) rename jdk/src/{java.base/share/classes/sun/misc => java.desktop/share/classes/sun/awt/util}/PerformanceLogger.java (99%) diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java index 2283e2fe8ec..7ef9e111171 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java @@ -43,8 +43,8 @@ import sun.awt.AWTAccessor; import sun.awt.AppContext; import sun.awt.EmbeddedFrame; import sun.awt.SunToolkit; +import sun.awt.util.PerformanceLogger; import sun.misc.ManagedLocalsThread; -import sun.misc.PerformanceLogger; import sun.security.util.SecurityConstants; /** diff --git a/jdk/src/java.base/share/classes/sun/misc/PerformanceLogger.java b/jdk/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java similarity index 99% rename from jdk/src/java.base/share/classes/sun/misc/PerformanceLogger.java rename to jdk/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java index 6e8917b4545..b35727f4627 100644 --- a/jdk/src/java.base/share/classes/sun/misc/PerformanceLogger.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java @@ -25,7 +25,7 @@ -package sun.misc; +package sun.awt.util; import java.util.Vector; import java.io.FileWriter; diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java index c7facaf62b6..3cb7207ad2b 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java @@ -88,9 +88,9 @@ import java.awt.font.FontRenderContext; import sun.java2d.loops.XORComposite; import sun.awt.ConstrainableGraphics; import sun.awt.SunHints; +import sun.awt.util.PerformanceLogger; import java.util.Map; import java.util.Iterator; -import sun.misc.PerformanceLogger; import java.lang.annotation.Native; import java.awt.image.MultiResolutionImage; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java index 3852193bd4a..7297ef72287 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java @@ -52,6 +52,7 @@ import sun.awt.datatransfer.DataTransferer; import sun.font.FontConfigManager; import sun.java2d.SunGraphicsEnvironment; import sun.misc.*; +import sun.awt.util.PerformanceLogger; import sun.awt.util.ThreadGroupUtils; import sun.print.PrintJob2D; import sun.security.action.GetPropertyAction; diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java index 970ab07f843..fed3e231731 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java @@ -67,10 +67,10 @@ import java.util.Locale; import java.util.Map; import java.util.Properties; +import sun.awt.util.PerformanceLogger; import sun.font.FontManager; import sun.font.FontManagerFactory; import sun.font.SunFontManager; -import sun.misc.PerformanceLogger; import sun.util.logging.PlatformLogger; public final class WToolkit extends SunToolkit implements Runnable { From 2ed4c9cc8c6a87a960d86e7c5de556cedd2bc85c Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 13 Jan 2016 13:56:19 +0000 Subject: [PATCH 060/109] 8146736: Move sun.misc performance counters to jdk.internal.perf Reviewed-by: alanb, mchung, rriggs --- modules.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules.xml b/modules.xml index d7db4ed42d8..8cb87dd0766 100644 --- a/modules.xml +++ b/modules.xml @@ -238,6 +238,12 @@ jdk.management.resource jdk.scripting.nashorn + + jdk.internal.perf + java.desktop + java.management + jdk.jvmstat + jdk.internal.org.objectweb.asm java.instrument From ed581c190a2b0f83ef81ce8179dc92969d50a417 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 13 Jan 2016 14:32:42 +0000 Subject: [PATCH 061/109] 8146736: Move sun.misc performance counters to jdk.internal.perf Reviewed-by: alanb, mchung, rriggs --- .../share/classes/java/lang/ClassLoader.java | 8 ++- .../classes/java/net/URLClassLoader.java | 5 +- .../share/classes/java/util/zip/ZipFile.java | 5 +- .../{sun/misc => jdk/internal/perf}/Perf.java | 55 +++++++++++-------- .../internal/perf}/PerfCounter.java | 2 +- .../sun/java2d/d3d/D3DGraphicsDevice.java | 5 +- .../sun/management/ConnectorAddressLink.java | 2 +- .../sun/management/VMManagementImpl.java | 2 +- .../perfdata/monitor/AbstractMonitoredVm.java | 2 +- .../monitor/AbstractPerfDataBuffer.java | 1 - .../protocol/local/PerfDataBuffer.java | 2 +- 11 files changed, 51 insertions(+), 38 deletions(-) rename jdk/src/java.base/share/classes/{sun/misc => jdk/internal/perf}/Perf.java (94%) rename jdk/src/java.base/share/classes/{sun/misc => jdk/internal/perf}/PerfCounter.java (99%) diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java index 76cdd25dcd7..1bb15800454 100644 --- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java @@ -50,6 +50,8 @@ import java.util.Vector; import java.util.Hashtable; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; + +import jdk.internal.perf.PerfCounter; import sun.misc.Resource; import sun.misc.URLClassPath; import sun.reflect.CallerSensitive; @@ -423,9 +425,9 @@ public abstract class ClassLoader { c = findClass(name); // this is the defining class loader; record the stats - sun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0); - sun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1); - sun.misc.PerfCounter.getFindClasses().increment(); + PerfCounter.getParentDelegationTime().addTime(t1 - t0); + PerfCounter.getFindClassTime().addElapsedTimeFrom(t1); + PerfCounter.getFindClasses().increment(); } } if (resolve) { diff --git a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java index 05ebeed39a5..1cf064d1afa 100644 --- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java +++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java @@ -52,6 +52,7 @@ import java.util.jar.Manifest; import jdk.internal.misc.JavaNetAccess; import jdk.internal.misc.SharedSecrets; +import jdk.internal.perf.PerfCounter; import sun.misc.Resource; import sun.misc.URLClassPath; import sun.net.www.ParseUtil; @@ -459,14 +460,14 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { // Use (direct) ByteBuffer: CodeSigner[] signers = res.getCodeSigners(); CodeSource cs = new CodeSource(url, signers); - sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0); + PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0); return defineClass(name, bb, cs); } else { byte[] b = res.getBytes(); // must read certificates AFTER reading bytes. CodeSigner[] signers = res.getCodeSigners(); CodeSource cs = new CodeSource(url, signers); - sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0); + PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0); return defineClass(name, b, 0, b.length, cs); } } diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java index 31ff8eaf329..1cba038d6e5 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -54,6 +54,7 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; import jdk.internal.misc.JavaUtilZipFileAccess; import jdk.internal.misc.SharedSecrets; +import jdk.internal.perf.PerfCounter; import static java.util.zip.ZipConstants.*; import static java.util.zip.ZipConstants64.*; @@ -210,8 +211,8 @@ class ZipFile implements ZipConstants, Closeable { this.name = name; long t0 = System.nanoTime(); this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0); - sun.misc.PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0); - sun.misc.PerfCounter.getZipFileCount().increment(); + PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0); + PerfCounter.getZipFileCount().increment(); } /** diff --git a/jdk/src/java.base/share/classes/sun/misc/Perf.java b/jdk/src/java.base/share/classes/jdk/internal/perf/Perf.java similarity index 94% rename from jdk/src/java.base/share/classes/sun/misc/Perf.java rename to jdk/src/java.base/share/classes/jdk/internal/perf/Perf.java index 311e92c8f64..e660cdf3ebe 100644 --- a/jdk/src/java.base/share/classes/sun/misc/Perf.java +++ b/jdk/src/java.base/share/classes/jdk/internal/perf/Perf.java @@ -22,13 +22,14 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package sun.misc; +package jdk.internal.perf; import java.nio.ByteBuffer; import java.security.Permission; import java.security.PrivilegedAction; import java.io.IOException; import java.io.UnsupportedEncodingException; +import jdk.internal.ref.CleanerFactory; /** * The Perf class provides the ability to attach to an instrumentation @@ -46,7 +47,7 @@ import java.io.UnsupportedEncodingException; * @author Brian Doherty * @since 1.4.2 * @see #getPerf - * @see sun.misc.Perf$GetPerfAction + * @see jdk.internal.perf.Perf.GetPerfAction * @see java.nio.ByteBuffer */ public final class Perf { @@ -123,10 +124,10 @@ public final class Perf { * Please note that the "sun.misc.Perf.getPerf" permission * is not a JDK specified permission. * - * @return A reference to the singleton Perf instance. - * @throws AccessControlException if a security manager exists and - * its checkPermission method doesn't allow - * access to the "sun.misc.Perf.getPerf" target. + * @return A reference to the singleton Perf instance. + * @throws SecurityException if a security manager exists and its + * checkPermission method doesn't allow access + * to the "jdk.internal.perf.Perf.getPerf"" target. * @see java.lang.RuntimePermission * @see #attach */ @@ -134,7 +135,7 @@ public final class Perf { { SecurityManager security = System.getSecurityManager(); if (security != null) { - Permission perm = new RuntimePermission("sun.misc.Perf.getPerf"); + Permission perm = new RuntimePermission("jdk.internal.perf.Perf.getPerf"); security.checkPermission(perm); } @@ -277,27 +278,35 @@ public final class Perf { // This is an instrumentation buffer for another Java virtual // machine with native resources that need to be managed. We // create a duplicate of the native ByteBuffer and manage it - // with a Cleaner object (PhantomReference). When the duplicate - // becomes only phantomly reachable, the native resources will - // be released. + // with a Cleaner. When the duplicate becomes phantom reachable, + // the native resources will be released. final ByteBuffer dup = b.duplicate(); - Cleaner.create(dup, new Runnable() { - public void run() { - try { - instance.detach(b); - } - catch (Throwable th) { - // avoid crashing the reference handler thread, - // but provide for some diagnosability - assert false : th.toString(); - } - } - }); + + CleanerFactory.cleaner() + .register(dup, new CleanerAction(instance, b)); return dup; } } + private static class CleanerAction implements Runnable { + private final ByteBuffer bb; + private final Perf perf; + CleanerAction(Perf perf, ByteBuffer bb) { + this.perf = perf; + this.bb = bb; + } + public void run() { + try { + perf.detach(bb); + } catch (Throwable th) { + // avoid crashing the reference handler thread, + // but provide for some diagnosability + assert false : th.toString(); + } + } + } + /** * Native method to perform the implementation specific attach mechanism. *

@@ -341,7 +350,7 @@ public final class Perf { * machine running this method (lvmid=0, for example), then the detach * request is silently ignored. * - * @param ByteBuffer A direct allocated byte buffer created by the + * @param bb A direct allocated byte buffer created by the * attach method. * @see java.nio.ByteBuffer * @see #attach diff --git a/jdk/src/java.base/share/classes/sun/misc/PerfCounter.java b/jdk/src/java.base/share/classes/jdk/internal/perf/PerfCounter.java similarity index 99% rename from jdk/src/java.base/share/classes/sun/misc/PerfCounter.java rename to jdk/src/java.base/share/classes/jdk/internal/perf/PerfCounter.java index aa054707937..1c0d0a1f341 100644 --- a/jdk/src/java.base/share/classes/sun/misc/PerfCounter.java +++ b/jdk/src/java.base/share/classes/jdk/internal/perf/PerfCounter.java @@ -23,7 +23,7 @@ * questions. */ -package sun.misc; +package jdk.internal.perf; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java index 794746c12a9..8f110fe8c72 100644 --- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java +++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java @@ -38,6 +38,7 @@ import java.awt.event.WindowListener; import java.awt.peer.WindowPeer; import java.util.ArrayList; +import jdk.internal.perf.PerfCounter; import sun.awt.AWTAccessor; import sun.awt.AWTAccessor.ComponentAccessor; import sun.awt.Win32GraphicsDevice; @@ -69,9 +70,9 @@ public class D3DGraphicsDevice extends Win32GraphicsDevice { if (d3dAvailable) { // we don't use pixel formats for the d3d pipeline pfDisabled = true; - sun.misc.PerfCounter.getD3DAvailable().set(1); + PerfCounter.getD3DAvailable().set(1); } else { - sun.misc.PerfCounter.getD3DAvailable().set(0); + PerfCounter.getD3DAvailable().set(0); } } diff --git a/jdk/src/java.management/share/classes/sun/management/ConnectorAddressLink.java b/jdk/src/java.management/share/classes/sun/management/ConnectorAddressLink.java index 4ec5ec799cc..b1bd0f311d1 100644 --- a/jdk/src/java.management/share/classes/sun/management/ConnectorAddressLink.java +++ b/jdk/src/java.management/share/classes/sun/management/ConnectorAddressLink.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import sun.misc.Perf; +import jdk.internal.perf.Perf; import sun.management.counter.Units; import sun.management.counter.Counter; import sun.management.counter.perf.PerfInstrumentation; diff --git a/jdk/src/java.management/share/classes/sun/management/VMManagementImpl.java b/jdk/src/java.management/share/classes/sun/management/VMManagementImpl.java index d9e8d64b9aa..0600a7aeee0 100644 --- a/jdk/src/java.management/share/classes/sun/management/VMManagementImpl.java +++ b/jdk/src/java.management/share/classes/sun/management/VMManagementImpl.java @@ -25,7 +25,7 @@ package sun.management; -import sun.misc.Perf; +import jdk.internal.perf.Perf; import sun.management.counter.*; import sun.management.counter.perf.*; import java.nio.ByteBuffer; diff --git a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractMonitoredVm.java b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractMonitoredVm.java index 8df13ca7f30..fc93d5c678e 100644 --- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractMonitoredVm.java +++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractMonitoredVm.java @@ -95,7 +95,7 @@ public abstract class AbstractMonitoredVm implements BufferedMonitoredVm { public void detach() { /* * no default action required because the detach operation for the - * native byte buffer is managed by the sun.misc.Perf class. + * native byte buffer is managed by the Perf class. */ } diff --git a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java index 7a5e9998bc9..a2d3ad4c2a4 100644 --- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java +++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java @@ -25,7 +25,6 @@ package sun.jvmstat.perfdata.monitor; -import sun.misc.Perf; import sun.jvmstat.monitor.*; import java.util.*; import java.io.*; diff --git a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java index 5932312d1ab..0ab643e106a 100644 --- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java +++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java @@ -25,7 +25,7 @@ package sun.jvmstat.perfdata.monitor.protocol.local; -import sun.misc.Perf; +import jdk.internal.perf.Perf; import sun.jvmstat.monitor.*; import sun.jvmstat.perfdata.monitor.*; import java.util.*; From 8f8cd2d815351b9c3ae780ec5844e7e5bd535078 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 13 Jan 2016 14:34:11 +0000 Subject: [PATCH 062/109] 8146736: Move sun.misc performance counters to jdk.internal.perf Reviewed-by: alanb, mchung, rriggs --- hotspot/src/share/vm/prims/nativeLookup.cpp | 4 ++-- hotspot/src/share/vm/prims/perf.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/prims/nativeLookup.cpp b/hotspot/src/share/vm/prims/nativeLookup.cpp index fecef0a5055..d54f711c67d 100644 --- a/hotspot/src/share/vm/prims/nativeLookup.cpp +++ b/hotspot/src/share/vm/prims/nativeLookup.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,7 +124,7 @@ static JNINativeMethod lookup_special_native_methods[] = { { CC"Java_jdk_internal_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterUnsafeMethods) }, { CC"Java_sun_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterUnsafeMethods) }, { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, - { CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) }, + { CC"Java_jdk_internal_perf_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) }, { CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) }, #if INCLUDE_JVMCI { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) }, diff --git a/hotspot/src/share/vm/prims/perf.cpp b/hotspot/src/share/vm/prims/perf.cpp index 435cb0146cb..1cbb9568298 100644 --- a/hotspot/src/share/vm/prims/perf.cpp +++ b/hotspot/src/share/vm/prims/perf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -34,7 +34,7 @@ #include "runtime/perfMemory.hpp" /* - * Implementation of class sun.misc.Perf + * Implementation of class jdk.internal.perf.Perf */ From 40987b7c03cf460dbdd766a2885d510fe969e772 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Wed, 13 Jan 2016 09:39:26 -0500 Subject: [PATCH 063/109] 8085903: New fix for memory leak in ProtectionDomain cache Reviewed-by: xuelei, igerasim --- .../java/security/ProtectionDomain.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java index 203ec8eed41..c7a0893b7d3 100644 --- a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java +++ b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,12 +27,12 @@ package java.security; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.Map; -import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import jdk.internal.misc.JavaSecurityAccess; import jdk.internal.misc.JavaSecurityProtectionDomainAccess; @@ -472,11 +472,15 @@ public class ProtectionDomain { * * This class stores ProtectionDomains as weak keys in a ConcurrentHashMap * with additional support for checking and removing weak keys that are no - * longer in use. + * longer in use. There can be cases where the permission collection may + * have a chain of strong references back to the ProtectionDomain, which + * ordinarily would prevent the entry from being removed from the map. To + * address that, we wrap the permission collection in a SoftReference so + * that it can be reclaimed by the garbage collector due to memory demand. */ private static class PDCache implements ProtectionDomainCache { private final ConcurrentHashMap + SoftReference> pdMap = new ConcurrentHashMap<>(); private final ReferenceQueue queue = new ReferenceQueue<>(); @@ -485,15 +489,15 @@ public class ProtectionDomain { processQueue(queue, pdMap); WeakProtectionDomainKey weakPd = new WeakProtectionDomainKey(pd, queue); - pdMap.putIfAbsent(weakPd, pc); + pdMap.put(weakPd, new SoftReference<>(pc)); } @Override public PermissionCollection get(ProtectionDomain pd) { processQueue(queue, pdMap); - WeakProtectionDomainKey weakPd = - new WeakProtectionDomainKey(pd, queue); - return pdMap.get(weakPd); + WeakProtectionDomainKey weakPd = new WeakProtectionDomainKey(pd); + SoftReference sr = pdMap.get(weakPd); + return (sr == null) ? null : sr.get(); } /** @@ -533,11 +537,20 @@ public class ProtectionDomain { this((pd == null ? NULL_KEY : pd.key), rq); } + WeakProtectionDomainKey(ProtectionDomain pd) { + this(pd == null ? NULL_KEY : pd.key); + } + private WeakProtectionDomainKey(Key key, ReferenceQueue rq) { super(key, rq); hash = key.hashCode(); } + private WeakProtectionDomainKey(Key key) { + super(key); + hash = key.hashCode(); + } + /** * Returns the identity hash code of the original referent. */ From 9bc2df068ed684685aaa0649fe61468fc3c2f4c3 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 13 Jan 2016 14:42:41 +0000 Subject: [PATCH 064/109] 8146774: Remove sun.misc.JarFilter Reviewed-by: alanb, mchung --- .../share/classes/sun/misc/JarFilter.java | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/sun/misc/JarFilter.java diff --git a/jdk/src/java.base/share/classes/sun/misc/JarFilter.java b/jdk/src/java.base/share/classes/sun/misc/JarFilter.java deleted file mode 100644 index 9036ecaed87..00000000000 --- a/jdk/src/java.base/share/classes/sun/misc/JarFilter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.misc; - -import java.io.File; -import java.io.FilenameFilter; - -/** - * This class checks that only jar and zip files are included in the file list. - * This class is used in extension installation support (ExtensionDependency). - * - * @deprecated this class will be removed in a future release. - * @author Michael Colburn - */ -@Deprecated -public class JarFilter implements FilenameFilter { - - public boolean accept(File dir, String name) { - String lower = name.toLowerCase(); - return lower.endsWith(".jar") || lower.endsWith(".zip"); - } -} From e0be7af3ce189d6122aa7244cdb325790dbbb978 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 13 Jan 2016 14:44:16 +0000 Subject: [PATCH 065/109] 8146771: Remove unused CEFormatException and CEStreamExhausted from sun.misc Reviewed-by: alanb, rriggs --- .../classes/sun/misc/CEFormatException.java | 36 ------------------- .../classes/sun/misc/CEStreamExhausted.java | 33 ----------------- 2 files changed, 69 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/sun/misc/CEFormatException.java delete mode 100644 jdk/src/java.base/share/classes/sun/misc/CEStreamExhausted.java diff --git a/jdk/src/java.base/share/classes/sun/misc/CEFormatException.java b/jdk/src/java.base/share/classes/sun/misc/CEFormatException.java deleted file mode 100644 index 6d53fa23d74..00000000000 --- a/jdk/src/java.base/share/classes/sun/misc/CEFormatException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.misc; - -import java.io.IOException; - -public class CEFormatException extends IOException { - static final long serialVersionUID = -7139121221067081482L; - public CEFormatException(String s) { - super(s); - } -} - diff --git a/jdk/src/java.base/share/classes/sun/misc/CEStreamExhausted.java b/jdk/src/java.base/share/classes/sun/misc/CEStreamExhausted.java deleted file mode 100644 index fb2054eaf1d..00000000000 --- a/jdk/src/java.base/share/classes/sun/misc/CEStreamExhausted.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package sun.misc; - -import java.io.IOException; - -/** This exception is thrown when EOF is reached */ -public class CEStreamExhausted extends IOException { - static final long serialVersionUID = -5889118049525891904L; -} - From 0224290c87bc96dffb15ab4879c7a9810ddae0fd Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 13 Jan 2016 10:12:39 -0800 Subject: [PATCH 066/109] 8146606: Catalog.matchSystem() appends an extra '/' to the matched result Reviewed-by: lancea --- .../javax/xml/catalog/RewriteSystem.java | 18 +++++--- .../classes/javax/xml/catalog/RewriteUri.java | 17 +++++--- .../jaxp/unittest/catalog/CatalogTest.java | 41 +++++++++++++++++-- .../jaxp/unittest/catalog/rewriteCatalog.xml | 11 +++++ 4 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteCatalog.xml diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteSystem.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteSystem.java index cf136f2cd59..f3f470243d5 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteSystem.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,6 +72,7 @@ final class RewriteSystem extends BaseEntry { public String getSystemIdStartString () { return systemIdStartString; } + /** * Get the rewritePrefix attribute. * @return The rewritePrefix attribute value. @@ -80,7 +81,6 @@ final class RewriteSystem extends BaseEntry { return rewritePrefix; } - /** * Try to match the specified systemId with the entry. Return the match if it * is successful and the length of the systemIdStartString is longer than the @@ -91,14 +91,20 @@ final class RewriteSystem extends BaseEntry { * @return The replacement URI if the match is successful, null if not. */ public String match(String systemId, int currentMatch) { - if (systemIdStartString.length() <= systemId.length() && + if (systemIdStartString.length() < systemId.length() && systemIdStartString.equals(systemId.substring(0, systemIdStartString.length()))) { if (currentMatch < systemIdStartString.length()) { String prefix = rewritePrefix.toExternalForm(); - if (!prefix.endsWith(SLASH) && !systemId.startsWith(SLASH)) { - return prefix + SLASH + systemId.substring(systemIdStartString.length()); + String sysId; + if (systemIdStartString.endsWith(SLASH)) { + sysId = systemId.substring(systemIdStartString.length()); } else { - return prefix + systemId.substring(systemIdStartString.length()); + sysId = systemId.substring(systemIdStartString.length() + 1); + } + if (prefix.endsWith(SLASH)) { + return prefix + sysId; + } else { + return prefix + SLASH + sysId; } } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteUri.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteUri.java index 0aec4e41d29..f5c60b06730 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteUri.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/RewriteUri.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,6 +72,7 @@ final class RewriteUri extends BaseEntry { public String getURIStartString () { return uriStartString; } + /** * Get the rewritePrefix attribute. * @return The rewritePrefix attribute value. @@ -91,14 +92,20 @@ final class RewriteUri extends BaseEntry { */ @Override public String match(String systemId, int currentMatch) { - if (uriStartString.length() <= systemId.length() && + if (uriStartString.length() < systemId.length() && uriStartString.equals(systemId.substring(0, uriStartString.length()))) { if (currentMatch < uriStartString.length()) { String prefix = rewritePrefix.toExternalForm(); - if (!prefix.endsWith(SLASH) && !systemId.startsWith(SLASH)) { - return prefix + SLASH + systemId.substring(uriStartString.length()); + String sysId; + if (uriStartString.endsWith(SLASH)) { + sysId = systemId.substring(uriStartString.length()); } else { - return prefix + systemId.substring(uriStartString.length()); + sysId = systemId.substring(uriStartString.length() + 1); + } + if (prefix.endsWith(SLASH)) { + return prefix + sysId; + } else { + return prefix + SLASH + sysId; } } } diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java index 42cb5601aa0..08830042132 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,14 +27,13 @@ import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogFeatures.Feature; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; +import javax.xml.catalog.CatalogUriResolver; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import static jaxp.library.JAXPTestUtilities.getPathByClassName; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import org.w3c.dom.Element; import org.xml.sax.Attributes; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; @@ -42,11 +41,45 @@ import org.xml.sax.XMLReader; import org.xml.sax.ext.DefaultHandler2; /* - * @bug 8081248, 8144966 + * @bug 8081248, 8144966, 8146606 * @summary Tests basic Catalog functions. */ public class CatalogTest { + /* + @bug 8146606 + Verifies that the resulting systemId does not contain duplicate slashes + */ + public void testRewriteSystem() { + String catalog = getClass().getResource("rewriteCatalog.xml").getFile(); + + try { + CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); + String actualSystemId = resolver.resolveEntity(null, "http://remote.com/dtd/book.dtd").getSystemId(); + Assert.assertTrue(!actualSystemId.contains("//"), "result contains duplicate slashes"); + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + + } + + /* + @bug 8146606 + Verifies that the resulting systemId does not contain duplicate slashes + */ + public void testRewriteUri() { + String catalog = getClass().getResource("rewriteCatalog.xml").getFile(); + + try { + + CatalogUriResolver resolver = CatalogManager.catalogUriResolver(CatalogFeatures.defaults(), catalog); + String actualSystemId = resolver.resolve("http://remote.com/import/import.xsl", null).getSystemId(); + Assert.assertTrue(!actualSystemId.contains("//"), "result contains duplicate slashes"); + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + } + /* @bug 8144966 Verifies that passing null as CatalogFeatures will result in a NPE. diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteCatalog.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteCatalog.xml new file mode 100644 index 00000000000..8ef5c9b0117 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteCatalog.xml @@ -0,0 +1,11 @@ + + + + + + + + + From bfa98d042c6622bf5c697787a4ae8a34439b545c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Wed, 13 Jan 2016 19:34:13 +0100 Subject: [PATCH 067/109] 8147008: Nashorn primitive linker should handle ES6 symbols Reviewed-by: attila, sundar --- .../jdk/nashorn/internal/objects/Global.java | 2 + .../internal/objects/NativeBoolean.java | 4 +- .../internal/objects/NativeSymbol.java | 42 +++++++++++++++++++ .../linker/NashornPrimitiveLinker.java | 6 ++- nashorn/test/script/basic/es6/symbols.js | 32 ++++++++------ 5 files changed, 70 insertions(+), 16 deletions(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java index 8db99dd6fd5..136c2f97880 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java @@ -1133,6 +1133,8 @@ public final class Global extends Scope { return NativeNumber.lookupPrimitive(request, self); } else if (self instanceof Boolean) { return NativeBoolean.lookupPrimitive(request, self); + } else if (self instanceof Symbol) { + return NativeSymbol.lookupPrimitive(request, self); } throw new IllegalArgumentException("Unsupported primitive: " + self); } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeBoolean.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeBoolean.java index bda848d8c00..0bafc47a46c 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeBoolean.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeBoolean.java @@ -168,9 +168,9 @@ public final class NativeBoolean extends ScriptObject { } /** - * Wrap a native string in a NativeString object. + * Wrap a native boolean in a NativeBoolean object. * - * @param receiver Native string. + * @param receiver Native boolean. * @return Wrapped object. */ @SuppressWarnings("unused") diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeSymbol.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeSymbol.java index 41f40680781..d2c316241b6 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeSymbol.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeSymbol.java @@ -25,8 +25,14 @@ package jdk.nashorn.internal.objects; +import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import jdk.dynalink.linker.GuardedInvocation; +import jdk.dynalink.linker.LinkRequest; import jdk.nashorn.internal.WeakValueCache; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; @@ -39,6 +45,7 @@ import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.Symbol; import jdk.nashorn.internal.runtime.Undefined; +import jdk.nashorn.internal.runtime.linker.PrimitiveLookup; /** * ECMAScript 6 - 19.4 Symbol Objects @@ -48,12 +55,21 @@ public final class NativeSymbol extends ScriptObject { private final Symbol symbol; + /** Method handle to create an object wrapper for a primitive symbol. */ + static final MethodHandle WRAPFILTER = findOwnMH("wrapFilter", MH.type(NativeSymbol.class, Object.class)); + /** Method handle to retrieve the Symbol prototype object. */ + private static final MethodHandle PROTOFILTER = findOwnMH("protoFilter", MH.type(Object.class, Object.class)); + // initialized by nasgen private static PropertyMap $nasgenmap$; /** See ES6 19.4.2.1 */ private static WeakValueCache globalSymbolRegistry = new WeakValueCache<>(); + NativeSymbol(final Symbol symbol) { + this(symbol, Global.instance()); + } + NativeSymbol(final Symbol symbol, final Global global) { this(symbol, global.getSymbolPrototype(), $nasgenmap$); } @@ -73,6 +89,17 @@ public final class NativeSymbol extends ScriptObject { } } + /** + * Lookup the appropriate method for an invoke dynamic call. + * + * @param request The link request + * @param receiver The receiver for the call + * @return Link to be invoked at call site. + */ + public static GuardedInvocation lookupPrimitive(final LinkRequest request, final Object receiver) { + return PrimitiveLookup.lookupPrimitive(request, Symbol.class, new NativeSymbol((Symbol)receiver), WRAPFILTER, PROTOFILTER); + } + // ECMA 6 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint ) @Override public Object getDefaultValue(final Class typeHint) { @@ -149,4 +176,19 @@ public final class NativeSymbol extends ScriptObject { final String name = ((Symbol) arg).getName(); return globalSymbolRegistry.get(name) == arg ? name : Undefined.getUndefined(); } + + @SuppressWarnings("unused") + private static NativeSymbol wrapFilter(final Object receiver) { + return new NativeSymbol((Symbol)receiver); + } + + @SuppressWarnings("unused") + private static Object protoFilter(final Object object) { + return Global.instance().getSymbolPrototype(); + } + + private static MethodHandle findOwnMH(final String name, final MethodType type) { + return MH.findStatic(MethodHandles.lookup(), NativeSymbol.class, name, type); + } + } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java index 830c03445c7..16778813a95 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java @@ -41,6 +41,7 @@ import jdk.nashorn.internal.objects.Global; import jdk.nashorn.internal.runtime.ConsString; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptRuntime; +import jdk.nashorn.internal.runtime.Symbol; /** * Internal linker for String, Boolean, and Number objects, only ever used by Nashorn engine and not exposed to other @@ -58,7 +59,8 @@ final class NashornPrimitiveLinker implements TypeBasedGuardingDynamicLinker, Gu private static boolean canLinkTypeStatic(final Class type) { return type == String.class || type == Boolean.class || type == ConsString.class || type == Integer.class - || type == Double.class || type == Float.class || type == Short.class || type == Byte.class; + || type == Double.class || type == Float.class || type == Short.class || type == Byte.class + || type == Symbol.class; } @Override @@ -168,7 +170,7 @@ final class NashornPrimitiveLinker implements TypeBasedGuardingDynamicLinker, Gu @SuppressWarnings("unused") private static boolean isJavaScriptPrimitive(final Object o) { - return JSType.isString(o) || o instanceof Boolean || JSType.isNumber(o) || o == null; + return JSType.isString(o) || o instanceof Boolean || JSType.isNumber(o) || o == null || o instanceof Symbol; } private static final MethodHandle GUARD_PRIMITIVE = findOwnMH("isJavaScriptPrimitive", boolean.class, Object.class); diff --git a/nashorn/test/script/basic/es6/symbols.js b/nashorn/test/script/basic/es6/symbols.js index efaa79ed3df..f5f70aae458 100644 --- a/nashorn/test/script/basic/es6/symbols.js +++ b/nashorn/test/script/basic/es6/symbols.js @@ -40,11 +40,11 @@ Assert.assertTrue(Symbol([1, 2, 3]).toString() === 'Symbol(1,2,3)'); Assert.assertTrue(Symbol(null).toString() === 'Symbol(null)'); Assert.assertTrue(Symbol(undefined).toString() === 'Symbol()'); -var s1 = Symbol(); -var s2 = Symbol("s2"); +const s1 = Symbol(); +const s2 = Symbol("s2"); Assert.assertFalse(s1 instanceof Symbol); // not an object -var obj = {}; +let obj = {}; obj['foo'] = 'foo'; obj[s1] = s1; obj['bar'] = 'bar'; @@ -57,17 +57,17 @@ Assert.assertTrue(obj['bar'] === 'bar'); Assert.assertTrue(obj[1] === 1); Assert.assertTrue(obj[s2] === s2); -var expectedNames = ['1', 'foo', 'bar']; -var expectedSymbols = [s1, s2]; -var actualNames = Object.getOwnPropertyNames(obj); -var actualSymbols = Object.getOwnPropertySymbols(obj); +const expectedNames = ['1', 'foo', 'bar']; +const expectedSymbols = [s1, s2]; +const actualNames = Object.getOwnPropertyNames(obj); +let actualSymbols = Object.getOwnPropertySymbols(obj); Assert.assertTrue(expectedNames.length == actualNames.length); Assert.assertTrue(expectedSymbols.length == actualSymbols.length); -for (var key in expectedNames) { +for (let key in expectedNames) { Assert.assertTrue(expectedNames[key] === actualNames[key]); } -for (var key in expectedSymbols) { +for (let key in expectedSymbols) { Assert.assertTrue(expectedSymbols[key] === actualSymbols[key]); } @@ -114,8 +114,8 @@ try { // Symbol.for and Symbol.keyFor -var uncached = Symbol('foo'); -var cached = Symbol.for('foo'); +const uncached = Symbol('foo'); +const cached = Symbol.for('foo'); Assert.assertTrue(uncached !== cached); Assert.assertTrue(Symbol.keyFor(uncached) === undefined); @@ -123,9 +123,15 @@ Assert.assertTrue(Symbol.keyFor(cached) === 'foo'); Assert.assertTrue(cached === Symbol.for('foo')); Assert.assertTrue(cached === Symbol.for('f' + 'oo')); +// JDK-8147008: Make sure symbols are handled by primitive linker +Symbol.prototype.foo = 123; +Symbol.prototype[s2] = s2; +Assert.assertEquals(s1.foo, 123); +Assert.assertEquals(s2[s2], s2); + // Object wrapper -var o = Object(s1); +const o = Object(s1); obj = {}; obj[s1] = "s1"; Assert.assertTrue(o == s1); @@ -134,6 +140,8 @@ Assert.assertTrue(typeof o === 'object'); Assert.assertTrue(o instanceof Symbol); Assert.assertTrue(obj[o] == 's1'); Assert.assertTrue(o in obj); +Assert.assertEquals(o.foo, 123); +Assert.assertEquals(o[s2], s2); // various non-strict comparisons that should fail From 751dd7f031ccdc6d253b3391dfdd657c253daca9 Mon Sep 17 00:00:00 2001 From: Amanda Jiang Date: Wed, 13 Jan 2016 17:36:01 -0800 Subject: [PATCH 068/109] 8145849: ALPN: getHandshakeApplicationProtocol() always return null Reviewed-by: wetmore, vinnie --- .../sun/security/ssl/SSLEngineImpl.java | 2 +- .../sun/security/ssl/SSLSocketImpl.java | 2 +- .../ssl/ALPN/MyX509ExtendedKeyManager.java | 130 ++++++++++++++++++ .../javax/net/ssl/ALPN/SSLEngineAlpnTest.java | 30 +++- .../javax/net/ssl/ALPN/SSLSocketAlpnTest.java | 111 +++++++++++---- 5 files changed, 239 insertions(+), 36 deletions(-) create mode 100644 jdk/test/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java index b9b3937f2bd..e7cd2acf126 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java @@ -2211,7 +2211,7 @@ public final class SSLEngineImpl extends SSLEngine { @Override public synchronized String getHandshakeApplicationProtocol() { - if ((handshaker != null) && !handshaker.started()) { + if ((handshaker != null) && handshaker.started()) { return handshaker.getHandshakeApplicationProtocol(); } return null; diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java index 9b357d3b42f..86b772c09da 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java @@ -2598,7 +2598,7 @@ public final class SSLSocketImpl extends BaseSSLSocketImpl { @Override public synchronized String getHandshakeApplicationProtocol() { - if ((handshaker != null) && !handshaker.started()) { + if ((handshaker != null) && handshaker.started()) { return handshaker.getHandshakeApplicationProtocol(); } return null; diff --git a/jdk/test/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java b/jdk/test/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java new file mode 100644 index 00000000000..d457766d5d4 --- /dev/null +++ b/jdk/test/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.net.Socket; +import java.security.Principal; +import java.security.PrivateKey; +import java.security.cert.X509Certificate; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.X509ExtendedKeyManager; + +public class MyX509ExtendedKeyManager extends X509ExtendedKeyManager { + + static final String ERROR = "ERROR"; + X509ExtendedKeyManager akm; + String expectedAP; + + MyX509ExtendedKeyManager(X509ExtendedKeyManager akm) { + this.akm = akm; + } + + public MyX509ExtendedKeyManager( + X509ExtendedKeyManager akm, String expectedAP) { + this.akm = akm; + this.expectedAP = expectedAP; + + } + + @Override + public String[] getClientAliases(String keyType, Principal[] issuers) { + return akm.getClientAliases(keyType, issuers); + } + + @Override + public String chooseClientAlias(String[] keyType, Principal[] issuers, + Socket socket) { + String nap = ((SSLSocket) socket).getHandshakeApplicationProtocol(); + checkALPN(nap); + + return akm.chooseClientAlias(keyType, issuers, socket); + } + + @Override + public String[] getServerAliases(String keyType, Principal[] issuers) { + return akm.getServerAliases(keyType, issuers); + } + + @Override + public String chooseServerAlias(String keyType, Principal[] issuers, + Socket socket) { + String nap = ((SSLSocket) socket).getHandshakeApplicationProtocol(); + checkALPN(nap); + + return akm.chooseServerAlias(keyType, issuers, socket); + } + + @Override + public X509Certificate[] getCertificateChain(String alias) { + return akm.getCertificateChain(alias); + } + + @Override + public PrivateKey getPrivateKey(String alias) { + return akm.getPrivateKey(alias); + } + + @Override + public String chooseEngineClientAlias(String[] keyType, Principal[] issuers, + SSLEngine engine) { + String nap = engine.getHandshakeApplicationProtocol(); + checkALPN(nap); + + return akm.chooseEngineClientAlias(keyType, issuers, engine); + } + + @Override + public String chooseEngineServerAlias(String keyType, Principal[] issuers, + SSLEngine engine) { + String nap = engine.getHandshakeApplicationProtocol(); + checkALPN(nap); + + return akm.chooseEngineServerAlias(keyType, issuers, engine); + } + + private void checkALPN(String ap) { + + if (ERROR.equals(expectedAP)) { + throw new RuntimeException("Should not reach here"); + } + + System.out.println("Expected ALPN value: " + expectedAP + + " Got: " + ap); + + if (ap == null) { + throw new RuntimeException( + "ALPN should be negotiated, but null was received"); + } + if (expectedAP.equals("NONE")) { + if (!ap.isEmpty()) { + throw new RuntimeException("Expected no ALPN value"); + } else { + System.out.println("No ALPN value negotiated, as expected"); + } + } else if (!expectedAP.equals(ap)) { + throw new RuntimeException(expectedAP + + " ALPN value not available on negotiated connection"); + } + + } +} diff --git a/jdk/test/javax/net/ssl/ALPN/SSLEngineAlpnTest.java b/jdk/test/javax/net/ssl/ALPN/SSLEngineAlpnTest.java index b5cb0a1ac6c..de4ea6cc0b6 100644 --- a/jdk/test/javax/net/ssl/ALPN/SSLEngineAlpnTest.java +++ b/jdk/test/javax/net/ssl/ALPN/SSLEngineAlpnTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,9 @@ /* * @test - * @bug 8051498 + * @bug 8051498 8145849 * @summary JEP 244: TLS Application-Layer Protocol Negotiation Extension + * @compile MyX509ExtendedKeyManager.java * @run main/othervm SSLEngineAlpnTest h2 h2 h2 * @run main/othervm SSLEngineAlpnTest h2 h2,http/1.1 h2 * @run main/othervm SSLEngineAlpnTest h2,http/1.1 h2,http/1.1 h2 @@ -162,7 +163,7 @@ public class SSLEngineAlpnTest { throw new Exception("Invalid number of test parameters"); } - SSLEngineAlpnTest test = new SSLEngineAlpnTest(); + SSLEngineAlpnTest test = new SSLEngineAlpnTest(args[2]); try { test.runTest(convert(args[0]), convert(args[1]), args[2]); } catch (SSLHandshakeException she) { @@ -179,7 +180,7 @@ public class SSLEngineAlpnTest { /* * Create an initialized SSLContext to use for these tests. */ - public SSLEngineAlpnTest() throws Exception { + public SSLEngineAlpnTest(String expectedAP) throws Exception { KeyStore ks = KeyStore.getInstance("JKS"); KeyStore ts = KeyStore.getInstance("JKS"); @@ -192,12 +193,20 @@ public class SSLEngineAlpnTest { KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); + KeyManager [] kms = kmf.getKeyManagers(); + if (!(kms[0] instanceof X509ExtendedKeyManager)) { + throw new Exception("kms[0] not X509ExtendedKeyManager"); + } + + kms = new KeyManager[] { new MyX509ExtendedKeyManager( + (X509ExtendedKeyManager) kms[0], expectedAP) }; + TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(ts); SSLContext sslCtx = SSLContext.getInstance("TLS"); - sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + sslCtx.init(kms, tmf.getTrustManagers(), null); sslc = sslCtx; } @@ -327,6 +336,11 @@ public class SSLEngineAlpnTest { return; } + if (engine.getHandshakeApplicationProtocol() != null) { + throw new Exception ("getHandshakeApplicationProtocol() should " + + "return null after the handshake is completed"); + } + String ap = engine.getApplicationProtocol(); System.out.println("Application Protocol: \"" + ap + "\""); @@ -384,6 +398,12 @@ public class SSLEngineAlpnTest { sslp = clientEngine.getSSLParameters(); sslp.setApplicationProtocols(clientAPs); clientEngine.setSSLParameters(sslp); + + if ((clientEngine.getHandshakeApplicationProtocol() != null) || + (serverEngine.getHandshakeApplicationProtocol() != null)) { + throw new Exception ("getHandshakeApplicationProtocol() should " + + "return null before the handshake starts"); + } } /* diff --git a/jdk/test/javax/net/ssl/ALPN/SSLSocketAlpnTest.java b/jdk/test/javax/net/ssl/ALPN/SSLSocketAlpnTest.java index 792f8dd750b..fd52f251f9d 100644 --- a/jdk/test/javax/net/ssl/ALPN/SSLSocketAlpnTest.java +++ b/jdk/test/javax/net/ssl/ALPN/SSLSocketAlpnTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,9 @@ /* * @test - * @bug 8051498 + * @bug 8051498 8145849 * @summary JEP 244: TLS Application-Layer Protocol Negotiation Extension + * @compile MyX509ExtendedKeyManager.java * @run main/othervm SSLSocketAlpnTest h2 h2 h2 * @run main/othervm SSLSocketAlpnTest h2 h2,http/1.1 h2 * @run main/othervm SSLSocketAlpnTest h2,http/1.1 h2,http/1.1 h2 @@ -40,6 +41,8 @@ * @author Brad Wetmore */ import java.io.*; +import java.security.KeyStore; + import javax.net.ssl.*; public class SSLSocketAlpnTest { @@ -65,6 +68,16 @@ public class SSLSocketAlpnTest { static String trustStoreFile = "truststore"; static String passwd = "passphrase"; + static String keyFilename = System.getProperty("test.src", ".") + "/" + + pathToStores + "/" + keyStoreFile; + static String trustFilename = System.getProperty("test.src", ".") + "/" + + pathToStores + "/" + trustStoreFile; + + /* + * SSLContext + */ + SSLContext mySSLContext = null; + /* * Is the server ready to serve? */ @@ -82,7 +95,7 @@ public class SSLSocketAlpnTest { /* * 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 + * 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.... @@ -95,10 +108,11 @@ public class SSLSocketAlpnTest { * to avoid infinite hangs. */ void doServerSide() throws Exception { - SSLServerSocketFactory sslssf - = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); + SSLServerSocketFactory sslssf = mySSLContext.getServerSocketFactory(); SSLServerSocket sslServerSocket = (SSLServerSocket) sslssf.createServerSocket(serverPort); + // for both client/server to call into X509KM + sslServerSocket.setNeedClientAuth(true); serverPort = sslServerSocket.getLocalPort(); @@ -119,20 +133,30 @@ public class SSLSocketAlpnTest { */ String[] suites = sslp.getCipherSuites(); sslp.setCipherSuites(suites); - sslp.setUseCipherSuitesOrder(true); // Set server side order + sslp.setUseCipherSuitesOrder(true); // Set server side order // Set the ALPN selection. sslp.setApplicationProtocols(serverAPs); sslSocket.setSSLParameters(sslp); + if (sslSocket.getHandshakeApplicationProtocol() != null) { + throw new Exception ("getHandshakeApplicationProtocol() should " + + "return null before the handshake starts"); + } + sslSocket.startHandshake(); + if (sslSocket.getHandshakeApplicationProtocol() != null) { + throw new Exception ("getHandshakeApplicationProtocol() should " + + "return null after the handshake is completed"); + } + String ap = sslSocket.getApplicationProtocol(); System.out.println("Application Protocol: \"" + ap + "\""); if (ap == null) { throw new Exception( - "Handshake was completed but null was received"); + "Handshake was completed but null was received"); } if (expectedAP.equals("NONE")) { if (!ap.isEmpty()) { @@ -141,8 +165,8 @@ public class SSLSocketAlpnTest { System.out.println("No ALPN value negotiated, as expected"); } } else if (!expectedAP.equals(ap)) { - throw new Exception(expectedAP + - " ALPN value not available on negotiated connection"); + throw new Exception(expectedAP + + " ALPN value not available on negotiated connection"); } InputStream sslIS = sslSocket.getInputStream(); @@ -170,8 +194,7 @@ public class SSLSocketAlpnTest { Thread.sleep(50); } - SSLSocketFactory sslsf - = (SSLSocketFactory) SSLSocketFactory.getDefault(); + SSLSocketFactory sslsf = mySSLContext.getSocketFactory(); SSLSocket sslSocket = (SSLSocket) sslsf.createSocket("localhost", serverPort); @@ -185,28 +208,35 @@ public class SSLSocketAlpnTest { */ String[] suites = sslp.getCipherSuites(); sslp.setCipherSuites(suites); - sslp.setUseCipherSuitesOrder(true); // Set server side order + sslp.setUseCipherSuitesOrder(true); // Set server side order // Set the ALPN selection. sslp.setApplicationProtocols(clientAPs); sslSocket.setSSLParameters(sslp); + if (sslSocket.getHandshakeApplicationProtocol() != null) { + throw new Exception ("getHandshakeApplicationProtocol() should " + + "return null before the handshake starts"); + } + sslSocket.startHandshake(); + if (sslSocket.getHandshakeApplicationProtocol() != null) { + throw new Exception ("getHandshakeApplicationProtocol() should " + + "return null after the handshake is completed"); + } + /* * Check that the resulting connection meets our defined ALPN * criteria. If we were connecting to a non-JSSE implementation, * the server might have negotiated something we shouldn't accept. - * - * We were expecting H2 from server, let's make sure the - * conditions match. */ String ap = sslSocket.getApplicationProtocol(); System.out.println("Application Protocol: \"" + ap + "\""); if (ap == null) { throw new Exception( - "Handshake was completed but null was received"); + "Handshake was completed but null was received"); } if (expectedAP.equals("NONE")) { if (!ap.isEmpty()) { @@ -215,8 +245,8 @@ public class SSLSocketAlpnTest { System.out.println("No ALPN value negotiated, as expected"); } } else if (!expectedAP.equals(ap)) { - throw new Exception(expectedAP + - " ALPN value not available on negotiated connection"); + throw new Exception(expectedAP + + " ALPN value not available on negotiated connection"); } InputStream sslIS = sslSocket.getInputStream(); @@ -240,17 +270,6 @@ public class SSLSocketAlpnTest { 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"); @@ -280,6 +299,39 @@ public class SSLSocketAlpnTest { System.out.println("Test Passed."); } + SSLContext getSSLContext(String keyFilename, String trustFilename) + throws Exception { + SSLContext ctx = SSLContext.getInstance("TLS"); + + // Keystores + KeyStore keyKS = KeyStore.getInstance("JKS"); + keyKS.load(new FileInputStream(keyFilename), passwd.toCharArray()); + + KeyStore trustKS = KeyStore.getInstance("JKS"); + trustKS.load(new FileInputStream(trustFilename), passwd.toCharArray()); + + // Generate KeyManager and TrustManager + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(keyKS, passwd.toCharArray()); + + KeyManager[] kms = kmf.getKeyManagers(); + if (!(kms[0] instanceof X509ExtendedKeyManager)) { + throw new Exception("kms[0] not X509ExtendedKeyManager"); + } + + kms = new KeyManager[] { new MyX509ExtendedKeyManager( + (X509ExtendedKeyManager) kms[0], expectedAP) }; + + TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); + tmf.init(trustKS); + TrustManager[] tms = tmf.getTrustManagers(); + + // initial SSLContext + ctx.init(kms, tms, null); + + return ctx; + } + /* * Convert a comma-separated list into an array of strings. */ @@ -309,6 +361,7 @@ public class SSLSocketAlpnTest { */ SSLSocketAlpnTest() throws Exception { Exception startException = null; + mySSLContext = getSSLContext(keyFilename, trustFilename); try { if (separateServerThread) { startServer(true); From 16899859109257f255800c71fa8f8a91368a4594 Mon Sep 17 00:00:00 2001 From: Michael Haupt Date: Thu, 14 Jan 2016 10:55:26 +0100 Subject: [PATCH 069/109] 8036977: Make process singleton options to be context wide The bug was fixed in an earlier change. This change contributes a test. Reviewed-by: hannesw, sundar --- .../nosecurity/context-dependent-logging.js | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 nashorn/test/script/nosecurity/context-dependent-logging.js diff --git a/nashorn/test/script/nosecurity/context-dependent-logging.js b/nashorn/test/script/nosecurity/context-dependent-logging.js new file mode 100644 index 00000000000..65391fa3457 --- /dev/null +++ b/nashorn/test/script/nosecurity/context-dependent-logging.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Test that logging configuration is per engine, rather than per process. + * + * @test + * @bug 8036977 + * @run/ignore-std-error + * @fork + * @option -scripting + */ + +// To test, start another engine (testEngine) with a time logger and ensure the +// logger exists. + +var NashornFactory = new (Java.type('jdk.nashorn.api.scripting.NashornScriptEngineFactory'))(), + testEngine = NashornFactory.getScriptEngine("-scripting", "--log=time") + +if (!testEngine.eval('$OPTIONS._loggers.time')) { + throw 'fresh testEngine does not have time logger' +} + +// To test further, have the testEngine start yet another engine (e) without +// time logging, but with compiler logging. Check the logging is as configured, +// and verify the testEngine still has time logging, but no compiler logging. + +var script = < Date: Thu, 14 Jan 2016 15:35:43 +0530 Subject: [PATCH 070/109] 8147070: Dynalink GuardedInvocation must check the Class object passed Reviewed-by: hannesw, mhaupt, attila --- .../classes/jdk/dynalink/linker/GuardedInvocation.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java index bc5b260e4ff..87993a3c1d4 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java @@ -202,6 +202,9 @@ public class GuardedInvocation { this.invocation = Objects.requireNonNull(invocation); this.guard = guard; this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint }; + if (exception != null && !Throwable.class.isAssignableFrom(exception)) { + throw new IllegalArgumentException(exception.getName() + " is not assignable from Throwable"); + } this.exception = exception; } @@ -228,6 +231,9 @@ public class GuardedInvocation { this.invocation = Objects.requireNonNull(invocation); this.guard = guard; this.switchPoints = switchPoints == null ? null : switchPoints.clone(); + if (exception != null && !Throwable.class.isAssignableFrom(exception)) { + throw new IllegalArgumentException(exception.getName() + " is not assignable from Throwable"); + } this.exception = exception; } From 6559500ac217b21a20558c3fe997a52c6008b249 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 14 Jan 2016 11:58:32 +0100 Subject: [PATCH 071/109] 8146995: Introduce named arguments in configure Reviewed-by: erikj --- common/autoconf/basics.m4 | 68 ++++ common/autoconf/flags.m4 | 60 +-- common/autoconf/generated-configure.sh | 517 ++++++++++++++++++++++++- common/autoconf/toolchain.m4 | 22 +- 4 files changed, 624 insertions(+), 43 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index f6b11c8a3bf..da287403bd5 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -23,6 +23,74 @@ # questions. # +# Create a function/macro that takes a series of named arguments. The call is +# similar to AC_DEFUN, but the setup of the function looks like this: +# BASIC_DEFUN_NAMED([MYFUNC], [FOO *BAR], [$@], [ +# ... do something +# AC_MSG_NOTICE([Value of BAR is ARG_BAR]) +# ]) +# A star (*) in front of a named argument means that it is required and it's +# presence will be verified. To pass e.g. the first value as a normal indexed +# argument, use [m4_shift($@)] as the third argument instead of [$@]. These +# arguments are referenced in the function by their name prefixed by ARG_, e.g. +# "ARG_FOO". +# +# The generated function can be called like this: +# MYFUNC(FOO: [foo-val], BAR: +# [ +# $ECHO hello world +# ]) +# +# +# Argument 1: Name of the function to define +# Argument 2: List of legal named arguments, with a * prefix for required arguments +# Argument 3: Argument array to treat as named, typically $@ +# Argument 4: The main function body +AC_DEFUN([BASIC_DEFUN_NAMED], +[ + AC_DEFUN($1, [ + m4_foreach(arg, m4_split($2), [ + m4_if(m4_bregexp(arg, [^\*]), -1, + [ + m4_set_add(legal_named_args, arg) + ], + [ + m4_set_add(legal_named_args, m4_substr(arg, 1)) + m4_set_add(required_named_args, m4_substr(arg, 1)) + ] + ) + ]) + + m4_foreach([arg], [$3], [ + m4_define(arg_name, m4_substr(arg, 0, m4_bregexp(arg, [: ]))) + m4_set_contains(legal_named_args, arg_name, [],[AC_MSG_ERROR([Internal error: arg_name is not a valid named argument to [$1]. Valid arguments are 'm4_set_contents(legal_named_args, [ ])'.])]) + m4_set_remove(required_named_args, arg_name) + m4_set_remove(legal_named_args, arg_name) + m4_pushdef([ARG_][]arg_name, m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ]))))) + m4_set_add(defined_args, arg_name) + m4_undefine([arg_name]) + ]) + m4_set_empty(required_named_args, [], [ + AC_MSG_ERROR([Internal error: Required named arguments are missing for [$1]. Missing arguments: 'm4_set_contents(required_named_args, [ ])']) + ]) + m4_foreach([arg], m4_indir([m4_dquote]m4_set_listc([legal_named_args])), [ + m4_pushdef([ARG_][]arg, []) + m4_set_add(defined_args, arg) + ]) + m4_set_delete(legal_named_args) + m4_set_delete(required_named_args) + + # Execute function body + $4 + + m4_foreach([arg], m4_indir([m4_dquote]m4_set_listc([defined_args])), [ + m4_popdef([ARG_][]arg) + ]) + + m4_set_delete(defined_args) + ]) +]) + # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3) # If so, then append $1 to $2 \ # Also set JVM_ARG_OK to true/false depending on outcome. diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index 927bb522bcd..b34b2fb7a85 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -425,7 +425,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], # Add runtime stack smashing and undefined behavior checks. # Not all versions of gcc support -fstack-protector STACK_PROTECTOR_CFLAG="-fstack-protector-all" - FLAGS_COMPILER_CHECK_ARGUMENTS([$STACK_PROTECTOR_CFLAG], [], [STACK_PROTECTOR_CFLAG=""]) + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG], IF_FALSE: [STACK_PROTECTOR_CFLAG=""]) CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1" CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1" @@ -742,7 +742,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], -I${JDK_TOPDIR}/src/java.base/share/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \ - -I${JDK_TOPDIR}/src/java.base/share/native/libjava \ + -I${JDK_TOPDIR}/src/java.base/share/native/libjava \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava" # The shared libraries are compiled using the picflag. @@ -896,17 +896,18 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], AC_SUBST(LDFLAGS_TESTEXE) ]) -# FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], -# [RUN-IF-FALSE]) +# FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE], +# IF_FALSE: [RUN-IF-FALSE]) # ------------------------------------------------------------ # Check that the c and c++ compilers support an argument -AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], +BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS], + [*ARGUMENT IF_TRUE IF_FALSE], [$@], [ - AC_MSG_CHECKING([if compiler supports "$1"]) + AC_MSG_CHECKING([if compiler supports "ARG_ARGUMENT"]) supports=yes saved_cflags="$CFLAGS" - CFLAGS="$CFLAGS $1" + CFLAGS="$CFLAGS ARG_ARGUMENT" AC_LANG_PUSH([C]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], [supports=no]) @@ -914,7 +915,7 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], CFLAGS="$saved_cflags" saved_cxxflags="$CXXFLAGS" - CXXFLAGS="$CXXFLAG $1" + CXXFLAGS="$CXXFLAG ARG_ARGUMENT" AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], [supports=no]) @@ -923,23 +924,26 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], AC_MSG_RESULT([$supports]) if test "x$supports" = "xyes" ; then - m4_ifval([$2], [$2], [:]) + : + ARG_IF_TRUE else - m4_ifval([$3], [$3], [:]) + : + ARG_IF_FALSE fi ]) -# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], -# [RUN-IF-FALSE]) +# FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE], +# IF_FALSE: [RUN-IF-FALSE]) # ------------------------------------------------------------ # Check that the linker support an argument -AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS], +BASIC_DEFUN_NAMED([FLAGS_LINKER_CHECK_ARGUMENTS], + [*ARGUMENT IF_TRUE IF_FALSE], [$@], [ - AC_MSG_CHECKING([if linker supports "$1"]) + AC_MSG_CHECKING([if linker supports "ARG_ARGUMENT"]) supports=yes saved_ldflags="$LDFLAGS" - LDFLAGS="$LDFLAGS $1" + LDFLAGS="$LDFLAGS ARG_ARGUMENT" AC_LANG_PUSH([C]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])], [], [supports=no]) @@ -948,9 +952,11 @@ AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS], AC_MSG_RESULT([$supports]) if test "x$supports" = "xyes" ; then - m4_ifval([$2], [$2], [:]) + : + ARG_IF_TRUE else - m4_ifval([$3], [$3], [:]) + : + ARG_IF_FALSE fi ]) @@ -965,14 +971,14 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], *) ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}" esac - FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""]) + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$ZERO_ARCHFLAG], IF_FALSE: [ZERO_ARCHFLAG=""]) AC_SUBST(ZERO_ARCHFLAG) # Check that the compiler supports -mX (or -qX on AIX) flags # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does - FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}], - [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true], - [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false]) + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}], + IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true], + IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false]) AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG) AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors], @@ -1013,9 +1019,9 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], ;; gcc) # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error - FLAGS_COMPILER_CHECK_ARGUMENTS([-Wno-this-is-a-warning-that-do-not-exist], - [GCC_CAN_DISABLE_WARNINGS=true], - [GCC_CAN_DISABLE_WARNINGS=false] + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist], + IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true], + IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false] ) if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then DISABLE_WARNING_PREFIX="-Wno-" @@ -1026,9 +1032,9 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], # Repeate the check for the BUILD_CC CC_OLD="$CC" CC="$BUILD_CC" - FLAGS_COMPILER_CHECK_ARGUMENTS([-Wno-this-is-a-warning-that-do-not-exist], - [BUILD_CC_CAN_DISABLE_WARNINGS=true], - [BUILD_CC_CAN_DISABLE_WARNINGS=false] + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist], + IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true], + IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false] ) if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-" diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index de0cce655ce..df36d8dc4ec 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3451,6 +3451,31 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # questions. # +# Create a function/macro that takes a series of named arguments. The call is +# similar to AC_DEFUN, but the setup of the function looks like this: +# BASIC_DEFUN_NAMED([MYFUNC], [FOO *BAR], [$@], [ +# ... do something +# AC_MSG_NOTICE([Value of BAR is ARG_BAR]) +# ]) +# A star (*) in front of a named argument means that it is required and it's +# presence will be verified. To pass e.g. the first value as a normal indexed +# argument, use [m4_shift($@)] as the third argument instead of [$@]. These +# arguments are referenced in the function by their name prefixed by ARG_, e.g. +# "ARG_FOO". +# +# The generated function can be called like this: +# MYFUNC(FOO: [foo-val], BAR: +# [ +# $ECHO hello world +# ]) +# +# +# Argument 1: Name of the function to define +# Argument 2: List of legal named arguments, with a * prefix for required arguments +# Argument 3: Argument array to treat as named, typically $@ +# Argument 4: The main function body + + # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3) # If so, then append $1 to $2 \ # Also set JVM_ARG_OK to true/false depending on outcome. @@ -3886,20 +3911,24 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. -# FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], -# [RUN-IF-FALSE]) +# FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE], +# IF_FALSE: [RUN-IF-FALSE]) # ------------------------------------------------------------ # Check that the c and c++ compilers support an argument -# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], -# [RUN-IF-FALSE]) + + +# FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE], +# IF_FALSE: [RUN-IF-FALSE]) # ------------------------------------------------------------ # Check that the linker support an argument + + # # Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -4810,7 +4839,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1452261921 +DATE_WHEN_GENERATED=1452769076 ############################################################################### # @@ -45358,6 +45387,54 @@ $as_echo "$as_me: Rewriting BUILD_AR to \"$new_complete\"" >&6;} # "-Og" suppported for GCC 4.8 and later CFLAG_OPTIMIZE_DEBUG_FLAG="-Og" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"" >&5 $as_echo_n "checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"... " >&6; } supports=yes @@ -45417,15 +45494,76 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then + : HAS_CFLAG_OPTIMIZE_DEBUG=true else + : HAS_CFLAG_OPTIMIZE_DEBUG=false fi + + + + + + + + + + + # "-z relro" supported in GNU binutils 2.17 and later LINKER_RELRO_FLAG="-Wl,-z,relro" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_RELRO_FLAG\"" >&5 $as_echo_n "checking if linker supports \"$LINKER_RELRO_FLAG\"... " >&6; } supports=yes @@ -45467,15 +45605,76 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then + : HAS_LINKER_RELRO=true else + : HAS_LINKER_RELRO=false fi + + + + + + + + + + + # "-z now" supported in GNU binutils 2.11 and later LINKER_NOW_FLAG="-Wl,-z,now" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_NOW_FLAG\"" >&5 $as_echo_n "checking if linker supports \"$LINKER_NOW_FLAG\"... " >&6; } supports=yes @@ -45517,11 +45716,24 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then + : HAS_LINKER_NOW=true else + : HAS_LINKER_NOW=false fi + + + + + + + + + + + fi # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed @@ -46842,6 +47054,49 @@ $as_echo "$ac_cv_c_bigendian" >&6; } # Not all versions of gcc support -fstack-protector STACK_PROTECTOR_CFLAG="-fstack-protector-all" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$STACK_PROTECTOR_CFLAG\"" >&5 $as_echo_n "checking if compiler supports \"$STACK_PROTECTOR_CFLAG\"... " >&6; } supports=yes @@ -46902,11 +47157,24 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then : + else + : STACK_PROTECTOR_CFLAG="" fi + + + + + + + + + + + CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1" CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1" ;; @@ -47384,6 +47652,49 @@ $as_echo "$supports" >&6; } ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}" esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$ZERO_ARCHFLAG\"" >&5 $as_echo_n "checking if compiler supports \"$ZERO_ARCHFLAG\"... " >&6; } supports=yes @@ -47444,15 +47755,76 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then : + else + : ZERO_ARCHFLAG="" fi + + + + + + + + + + + # Check that the compiler supports -mX (or -qX on AIX) flags # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"" >&5 $as_echo_n "checking if compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"... " >&6; } supports=yes @@ -47512,13 +47884,26 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then + : COMPILER_SUPPORTS_TARGET_BITS_FLAG=true else + : COMPILER_SUPPORTS_TARGET_BITS_FLAG=false fi + + + + + + + + + + + # Check whether --enable-warnings-as-errors was given. if test "${enable_warnings_as_errors+set}" = set; then : enableval=$enable_warnings_as_errors; @@ -47565,6 +47950,54 @@ $as_echo "yes (default)" >&6; } gcc) # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"" >&5 $as_echo_n "checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"... " >&6; } supports=yes @@ -47624,12 +48057,25 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then + : GCC_CAN_DISABLE_WARNINGS=true else + : GCC_CAN_DISABLE_WARNINGS=false fi + + + + + + + + + + + if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then DISABLE_WARNING_PREFIX="-Wno-" else @@ -47640,6 +48086,54 @@ $as_echo "$supports" >&6; } CC_OLD="$CC" CC="$BUILD_CC" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Execute function body + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"" >&5 $as_echo_n "checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"... " >&6; } supports=yes @@ -47699,12 +48193,25 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 $as_echo "$supports" >&6; } if test "x$supports" = "xyes" ; then + : BUILD_CC_CAN_DISABLE_WARNINGS=true else + : BUILD_CC_CAN_DISABLE_WARNINGS=false fi + + + + + + + + + + + if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-" else diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 3f5750dcc89..4254d86a4fb 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -75,8 +75,8 @@ AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS], # For full static builds, we're overloading the SHARED_LIBRARY # variables in order to limit the amount of changes required. # It would be better to remove SHARED and just use LIBRARY and - # LIBRARY_SUFFIX for libraries that can be built either - # shared or static and use STATIC_* for libraries that are + # LIBRARY_SUFFIX for libraries that can be built either + # shared or static and use STATIC_* for libraries that are # always built statically. if test "x$STATIC_BUILD" = xtrue; then SHARED_LIBRARY='lib[$]1.a' @@ -824,21 +824,21 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], # "-Og" suppported for GCC 4.8 and later CFLAG_OPTIMIZE_DEBUG_FLAG="-Og" - FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG], - [HAS_CFLAG_OPTIMIZE_DEBUG=true], - [HAS_CFLAG_OPTIMIZE_DEBUG=false]) + FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CFLAG_OPTIMIZE_DEBUG_FLAG], + IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true], + IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false]) # "-z relro" supported in GNU binutils 2.17 and later LINKER_RELRO_FLAG="-Wl,-z,relro" - FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG], - [HAS_LINKER_RELRO=true], - [HAS_LINKER_RELRO=false]) + FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_RELRO_FLAG], + IF_TRUE: [HAS_LINKER_RELRO=true], + IF_FALSE: [HAS_LINKER_RELRO=false]) # "-z now" supported in GNU binutils 2.11 and later LINKER_NOW_FLAG="-Wl,-z,now" - FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG], - [HAS_LINKER_NOW=true], - [HAS_LINKER_NOW=false]) + FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_NOW_FLAG], + IF_TRUE: [HAS_LINKER_NOW=true], + IF_FALSE: [HAS_LINKER_NOW=false]) fi # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed From 0beda5bcab7fb056d69a2d80d34b166c2ba7c65b Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 14 Jan 2016 13:22:58 +0100 Subject: [PATCH 072/109] 8144917: Prepare AbstractJavaLinker/BeanLinker codebase for missing member implementation Reviewed-by: mhaupt, sundar --- .../dynalink/beans/AbstractJavaLinker.java | 198 ++++++++++-------- .../jdk/dynalink/beans/BeanLinker.java | 46 ++-- .../jdk/dynalink/beans/StaticClassLinker.java | 22 ++ 3 files changed, 155 insertions(+), 111 deletions(-) diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java index 72c35a99b7e..01c6eb9d3fd 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java @@ -359,45 +359,70 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { } } - List operations = Arrays.asList( - CompositeOperation.getOperations( - NamedOperation.getBaseOperation(operation))); - final Object name = NamedOperation.getName(operation); + final GuardedInvocationComponent gic = getGuardedInvocationComponent( + new ComponentLinkRequest(request, linkerServices)); + return gic != null ? gic.getGuardedInvocation() : null; + } - while(!operations.isEmpty()) { - final GuardedInvocationComponent gic = - getGuardedInvocationComponent(callSiteDescriptor, - linkerServices, operations, name); - if(gic != null) { - return gic.getGuardedInvocation(); + static final class ComponentLinkRequest { + final LinkRequest linkRequest; + final LinkerServices linkerServices; + final List operations; + final Object name; + + ComponentLinkRequest(final LinkRequest linkRequest, + final LinkerServices linkerServices) { + this.linkRequest = linkRequest; + this.linkerServices = linkerServices; + final Operation operation = linkRequest.getCallSiteDescriptor().getOperation(); + this.operations = Arrays.asList( + CompositeOperation.getOperations( + NamedOperation.getBaseOperation(operation))); + this.name = NamedOperation.getName(operation); + } + + private ComponentLinkRequest(final LinkRequest linkRequest, + final LinkerServices linkerServices, + final List operations, final Object name) { + this.linkRequest = linkRequest; + this.linkerServices = linkerServices; + this.operations = operations; + this.name = name; + } + + CallSiteDescriptor getDescriptor() { + return linkRequest.getCallSiteDescriptor(); + } + + ComponentLinkRequest popOperations() { + return new ComponentLinkRequest(linkRequest, linkerServices, + operations.subList(1, operations.size()), name); + } + } + + protected GuardedInvocationComponent getGuardedInvocationComponent(final ComponentLinkRequest req) + throws Exception { + final Operation op = req.operations.get(0); + if (op instanceof StandardOperation) { + switch((StandardOperation)op) { + case GET_PROPERTY: return getPropertyGetter(req.popOperations()); + case SET_PROPERTY: return getPropertySetter(req.popOperations()); + case GET_METHOD: return getMethodGetter(req.popOperations()); + default: } - operations = pop(operations); } return null; } - protected GuardedInvocationComponent getGuardedInvocationComponent( - final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, - final List operations, final Object name) - throws Exception { - if(operations.isEmpty()) { + GuardedInvocationComponent getNextComponent(final ComponentLinkRequest req) throws Exception { + if (req.operations.isEmpty()) { return null; } - final Operation op = operations.get(0); - // Either GET_PROPERTY:name(this) or GET_PROPERTY(this, name) - if(op == StandardOperation.GET_PROPERTY) { - return getPropertyGetter(callSiteDescriptor, linkerServices, pop(operations), name); + final GuardedInvocationComponent gic = getGuardedInvocationComponent(req); + if (gic != null) { + return gic; } - // Either SET_PROPERTY:name(this, value) or SET_PROPERTY(this, name, value) - if(op == StandardOperation.SET_PROPERTY) { - return getPropertySetter(callSiteDescriptor, linkerServices, pop(operations), name); - } - // Either GET_METHOD:name(this), or GET_METHOD(this, name) - if(op == StandardOperation.GET_METHOD) { - return getMethodGetter(callSiteDescriptor, linkerServices, pop(operations), name); - } - return null; + return getNextComponent(req.popOperations()); } static final List pop(final List l) { @@ -483,16 +508,15 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { private static final MethodHandle CONSTANT_NULL_DROP_METHOD_HANDLE = MethodHandles.dropArguments( MethodHandles.constant(Object.class, null), 0, MethodHandle.class); - private GuardedInvocationComponent getPropertySetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List operations, final Object name) throws Exception { - if (name == null) { - return getUnnamedPropertySetter(callSiteDescriptor, linkerServices, operations); + private GuardedInvocationComponent getPropertySetter(final ComponentLinkRequest req) throws Exception { + if (req.name == null) { + return getUnnamedPropertySetter(req); } - return getNamedPropertySetter(callSiteDescriptor, linkerServices, operations, name); + return getNamedPropertySetter(req); } - private GuardedInvocationComponent getUnnamedPropertySetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List operations) throws Exception { + private GuardedInvocationComponent getUnnamedPropertySetter(final ComponentLinkRequest req) throws Exception { + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); // Must have three arguments: target object, property name, and property value. assertParameterCount(callSiteDescriptor, 3); @@ -501,6 +525,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { // invoked, we'll conservatively presume Object return type. The one exception is void return. final MethodType origType = callSiteDescriptor.getMethodType(); final MethodType type = origType.returnType() == void.class ? origType : origType.changeReturnType(Object.class); + final LinkerServices linkerServices = req.linkerServices; // What's below is basically: // foldArguments(guardWithTest(isNotNull, invoke, null|nextComponent.invocation), @@ -527,11 +552,10 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { // Handle to invoke the setter, dropping unnecessary fold arguments R(MethodHandle, O, N, V) final MethodHandle invokeHandleFolded = MethodHandles.dropArguments(invokeHandle, 2, type.parameterType( 1)); - final GuardedInvocationComponent nextComponent = getGuardedInvocationComponent(callSiteDescriptor, - linkerServices, operations, null); + final GuardedInvocationComponent nextComponent = getNextComponent(req); final MethodHandle fallbackFolded; - if(nextComponent == null) { + if (nextComponent == null) { // Object(MethodHandle)->Object(MethodHandle, O, N, V); returns constant null fallbackFolded = MethodHandles.dropArguments(CONSTANT_NULL_DROP_METHOD_HANDLE, 1, type.parameterList()).asType(type.insertParameterTypes(0, MethodHandle.class)); @@ -551,19 +575,19 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { return nextComponent.compose(compositeSetter, getClassGuard(type), clazz, ValidationType.EXACT_CLASS); } - private GuardedInvocationComponent getNamedPropertySetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List operations, final Object name) throws Exception { + private GuardedInvocationComponent getNamedPropertySetter(final ComponentLinkRequest req) throws Exception { + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); // Must have two arguments: target object and property value assertParameterCount(callSiteDescriptor, 2); - final GuardedInvocation gi = createGuardedDynamicMethodInvocation(callSiteDescriptor, linkerServices, - name.toString(), propertySetters); + final GuardedInvocation gi = createGuardedDynamicMethodInvocation(callSiteDescriptor, req.linkerServices, + req.name.toString(), propertySetters); // If we have a property setter with this name, this composite operation will always stop here if(gi != null) { return new GuardedInvocationComponent(gi, clazz, ValidationType.EXACT_CLASS); } // If we don't have a property setter with this name, always fall back to the next operation in the // composite (if any) - return getGuardedInvocationComponent(callSiteDescriptor, linkerServices, operations, name); + return getNextComponent(req); } private static final Lookup privateLookup = new Lookup(MethodHandles.lookup()); @@ -576,20 +600,18 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { "getTarget", MethodType.methodType(MethodHandle.class, CallSiteDescriptor.class, LinkerServices.class)); private static final MethodHandle GETTER_INVOKER = MethodHandles.invoker(MethodType.methodType(Object.class, Object.class)); - private GuardedInvocationComponent getPropertyGetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List ops, final Object name) throws Exception { - if (name == null) { - return getUnnamedPropertyGetter(callSiteDescriptor, linkerServices, ops); + private GuardedInvocationComponent getPropertyGetter(final ComponentLinkRequest req) throws Exception { + if (req.name == null) { + return getUnnamedPropertyGetter(req); } - - return getNamedPropertyGetter(callSiteDescriptor, linkerServices, ops, name); + return getNamedPropertyGetter(req); } - private GuardedInvocationComponent getUnnamedPropertyGetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List ops) throws Exception { + private GuardedInvocationComponent getUnnamedPropertyGetter(final ComponentLinkRequest req) throws Exception { // Since we can't know what kind of a getter we'll get back on different invocations, we'll just // conservatively presume Object. Note we can't just coerce to a narrower call site type as the linking // runtime might not allow coercing at that call site. + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); final MethodType type = callSiteDescriptor.getMethodType().changeReturnType(Object.class); // Must have exactly two arguments: receiver and name assertParameterCount(callSiteDescriptor, 2); @@ -600,6 +622,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { // AnnotatedDynamicMethod; if it is non-null, invoke its "handle" field, otherwise either return null, // or delegate to next component's invocation. + final LinkerServices linkerServices = req.linkerServices; final MethodHandle typedGetter = linkerServices.asType(getPropertyGetterHandle, type.changeReturnType( AnnotatedDynamicMethod.class)); final MethodHandle callSiteBoundMethodGetter = MethodHandles.insertArguments( @@ -613,8 +636,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { // Object(AnnotatedDynamicMethod, T0)->Object(AnnotatedDynamicMethod, T0, T1) final MethodHandle invokeHandleFolded = MethodHandles.dropArguments(invokeHandleTyped, 2, type.parameterType(1)); - final GuardedInvocationComponent nextComponent = getGuardedInvocationComponent(callSiteDescriptor, - linkerServices, ops, null); + final GuardedInvocationComponent nextComponent = getNextComponent(req); final MethodHandle fallbackFolded; if(nextComponent == null) { @@ -639,17 +661,17 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { return nextComponent.compose(compositeGetter, getClassGuard(type), clazz, ValidationType.EXACT_CLASS); } - private GuardedInvocationComponent getNamedPropertyGetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List ops, final Object name) throws Exception { + private GuardedInvocationComponent getNamedPropertyGetter(final ComponentLinkRequest req) throws Exception { + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); // Must have exactly one argument: receiver assertParameterCount(callSiteDescriptor, 1); // Fixed name - final AnnotatedDynamicMethod annGetter = propertyGetters.get(name.toString()); + final AnnotatedDynamicMethod annGetter = propertyGetters.get(req.name.toString()); if(annGetter == null) { // We have no such property, always delegate to the next component operation - return getGuardedInvocationComponent(callSiteDescriptor, linkerServices, ops, name); + return getNextComponent(req); } - final MethodHandle getter = annGetter.getInvocation(callSiteDescriptor, linkerServices); + final MethodHandle getter = annGetter.getInvocation(req); // NOTE: since property getters (not field getters!) are no-arg, we don't have to worry about them being // overloaded in a subclass. Therefore, we can discover the most abstract superclass that has the // method, and use that as the guard with Guards.isInstance() for a more stably linked call site. If @@ -686,28 +708,27 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { MethodType.methodType(boolean.class, Object.class)); private static final MethodHandle OBJECT_IDENTITY = MethodHandles.identity(Object.class); - private GuardedInvocationComponent getMethodGetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List ops, final Object name) throws Exception { - // The created method handle will always return a DynamicMethod (or null), but since we don't want that type to - // be visible outside of this linker, declare it to return Object. - final MethodType type = callSiteDescriptor.getMethodType().changeReturnType(Object.class); - if (name == null) { - return getUnnamedMethodGetter(callSiteDescriptor, linkerServices, ops, type); + private GuardedInvocationComponent getMethodGetter(final ComponentLinkRequest req) throws Exception { + if (req.name == null) { + return getUnnamedMethodGetter(req); } - - return getNamedMethodGetter(callSiteDescriptor, linkerServices, ops, name, type); + return getNamedMethodGetter(req); } - private GuardedInvocationComponent getUnnamedMethodGetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List ops, final MethodType type) throws Exception { + private static MethodType getMethodGetterType(final ComponentLinkRequest req) { + // The created method handle will always return a DynamicMethod (or null), but since we don't want that type to + // be visible outside of this linker, declare it to return Object. + return req.getDescriptor().getMethodType().changeReturnType(Object.class); + } + + private GuardedInvocationComponent getUnnamedMethodGetter(final ComponentLinkRequest req) throws Exception { // Must have exactly two arguments: receiver and name - assertParameterCount(callSiteDescriptor, 2); - final GuardedInvocationComponent nextComponent = getGuardedInvocationComponent(callSiteDescriptor, - linkerServices, ops, null); - if(nextComponent == null || !InternalTypeUtilities.areAssignable(DynamicMethod.class, - nextComponent.getGuardedInvocation().getInvocation().type().returnType())) { - // No next component operation, or it can never produce a dynamic method; just return a component - // for this operation. + assertParameterCount(req.getDescriptor(), 2); + final GuardedInvocationComponent nextComponent = getNextComponent(req); + final LinkerServices linkerServices = req.linkerServices; + final MethodType type = getMethodGetterType(req); + if(nextComponent == null) { + // No next component operation; just return a component for this operation. return getClassGuardedInvocationComponent(linkerServices.asType(getDynamicMethod, type), type); } @@ -728,25 +749,28 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { final MethodHandle nextCombinedInvocation = MethodHandles.dropArguments(nextComponentInvocation, 0, Object.class); // Assemble it all into a fold(guard(isNotNull, identity, nextInvocation), get) + // Note that nextCombinedInvocation needs to have its return type changed to Object final MethodHandle compositeGetter = MethodHandles.foldArguments(MethodHandles.guardWithTest( - IS_DYNAMIC_METHOD, returnMethodHandle, nextCombinedInvocation), typedGetter); + IS_DYNAMIC_METHOD, returnMethodHandle, + nextCombinedInvocation.asType(nextCombinedInvocation.type().changeReturnType(Object.class))), + typedGetter); return nextComponent.compose(compositeGetter, getClassGuard(type), clazz, ValidationType.EXACT_CLASS); } - private GuardedInvocationComponent getNamedMethodGetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List ops, final Object name, final MethodType type) + private GuardedInvocationComponent getNamedMethodGetter(final ComponentLinkRequest req) throws Exception { // Must have exactly one argument: receiver - assertParameterCount(callSiteDescriptor, 1); - final DynamicMethod method = getDynamicMethod(name.toString()); + assertParameterCount(req.getDescriptor(), 1); + final DynamicMethod method = getDynamicMethod(req.name.toString()); if(method == null) { // We have no such method, always delegate to the next component - return getGuardedInvocationComponent(callSiteDescriptor, linkerServices, ops, name); + return getNextComponent(req); } // No delegation to the next component of the composite operation; if we have a method with that name, // we'll always return it at this point. - return getClassGuardedInvocationComponent(linkerServices.asType(MethodHandles.dropArguments( + final MethodType type = getMethodGetterType(req); + return getClassGuardedInvocationComponent(req.linkerServices.asType(MethodHandles.dropArguments( MethodHandles.constant(Object.class, method), 0, type.parameterType(0)), type), type); } @@ -876,8 +900,8 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { this.validationType = validationType; } - MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) { - return method.getInvocation(callSiteDescriptor, linkerServices); + MethodHandle getInvocation(final ComponentLinkRequest req) { + return method.getInvocation(req.getDescriptor(), req.linkerServices); } @SuppressWarnings("unused") diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java index dc9b4fe4e8e..289b9321401 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java @@ -129,25 +129,21 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL } @Override - protected GuardedInvocationComponent getGuardedInvocationComponent(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List operations, final Object name) throws Exception { - final GuardedInvocationComponent superGic = super.getGuardedInvocationComponent(callSiteDescriptor, - linkerServices, operations, name); + protected GuardedInvocationComponent getGuardedInvocationComponent(final ComponentLinkRequest req) throws Exception { + final GuardedInvocationComponent superGic = super.getGuardedInvocationComponent(req); if(superGic != null) { return superGic; } - if(operations.isEmpty()) { - return null; - } - final Operation op = operations.get(0); - if(op == StandardOperation.GET_ELEMENT) { - return getElementGetter(callSiteDescriptor, linkerServices, pop(operations), name); - } - if(op == StandardOperation.SET_ELEMENT) { - return getElementSetter(callSiteDescriptor, linkerServices, pop(operations), name); - } - if(op == StandardOperation.GET_LENGTH) { - return getLengthGetter(callSiteDescriptor); + if (!req.operations.isEmpty()) { + final Operation op = req.operations.get(0); + if (op instanceof StandardOperation) { + switch ((StandardOperation)op) { + case GET_ELEMENT: return getElementGetter(req.popOperations()); + case SET_ELEMENT: return getElementSetter(req.popOperations()); + case GET_LENGTH: return getLengthGetter(req.getDescriptor()); + default: + } + } } return null; } @@ -170,12 +166,12 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL ARRAY, LIST, MAP }; - private GuardedInvocationComponent getElementGetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List operations, final Object name) throws Exception { + private GuardedInvocationComponent getElementGetter(final ComponentLinkRequest req) throws Exception { + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); + final LinkerServices linkerServices = req.linkerServices; final MethodType callSiteType = callSiteDescriptor.getMethodType(); final Class declaredType = callSiteType.parameterType(0); - final GuardedInvocationComponent nextComponent = getGuardedInvocationComponent(callSiteDescriptor, - linkerServices, operations, name); + final GuardedInvocationComponent nextComponent = getNextComponent(req); // If declared type of receiver at the call site is already an array, a list or map, bind without guard. Thing // is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance they're @@ -211,6 +207,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Convert the key to a number if we're working with a list or array final Object typedName; + final Object name = req.name; if(collectionType != CollectionType.MAP && name != null) { typedName = convertKeyToInteger(name, linkerServices); if(typedName == null) { @@ -399,8 +396,9 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL private static final MethodHandle PUT_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "put", MethodType.methodType(Object.class, Object.class, Object.class)); - private GuardedInvocationComponent getElementSetter(final CallSiteDescriptor callSiteDescriptor, - final LinkerServices linkerServices, final List operations, final Object name) throws Exception { + private GuardedInvocationComponent getElementSetter(final ComponentLinkRequest req) throws Exception { + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); + final LinkerServices linkerServices = req.linkerServices; final MethodType callSiteType = callSiteDescriptor.getMethodType(); final Class declaredType = callSiteType.parameterType(0); @@ -441,14 +439,14 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // In contrast to, say, getElementGetter, we only compute the nextComponent if the target object is not a map, // as maps will always succeed in setting the element and will never need to fall back to the next component // operation. - final GuardedInvocationComponent nextComponent = collectionType == CollectionType.MAP ? null : getGuardedInvocationComponent( - callSiteDescriptor, linkerServices, operations, name); + final GuardedInvocationComponent nextComponent = collectionType == CollectionType.MAP ? null : getNextComponent(req); if(gic == null) { return nextComponent; } // Convert the key to a number if we're working with a list or array final Object typedName; + final Object name = req.name; if(collectionType != CollectionType.MAP && name != null) { typedName = convertKeyToInteger(name, linkerServices); if(typedName == null) { diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClassLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClassLinker.java index 9ca1b52f33f..c81e8d1f8d8 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClassLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/StaticClassLinker.java @@ -91,6 +91,7 @@ import java.util.Arrays; import java.util.Set; import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.NamedOperation; +import jdk.dynalink.Operation; import jdk.dynalink.StandardOperation; import jdk.dynalink.beans.GuardedInvocationComponent.ValidationType; import jdk.dynalink.linker.GuardedInvocation; @@ -161,6 +162,27 @@ class StaticClassLinker implements TypeBasedGuardingDynamicLinker { return null; } + @Override + protected GuardedInvocationComponent getGuardedInvocationComponent(final ComponentLinkRequest req) throws Exception { + final GuardedInvocationComponent superGic = super.getGuardedInvocationComponent(req); + if (superGic != null) { + return superGic; + } + if (!req.operations.isEmpty()) { + final Operation op = req.operations.get(0); + if (op instanceof StandardOperation) { + switch ((StandardOperation)op) { + case GET_ELEMENT: + case SET_ELEMENT: + // StaticClass doesn't behave as a collection + return getNextComponent(req.popOperations()); + default: + } + } + } + return null; + } + @Override SingleDynamicMethod getConstructorMethod(final String signature) { return constructor != null? constructor.getMethodForExactParamTypes(signature) : null; From df1606c088841c9358466624cb3cc4cd7c6d766a Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 14 Jan 2016 13:24:03 +0100 Subject: [PATCH 073/109] 8144919: Implement missing member handler for BeansLinker Reviewed-by: lagergren, mhaupt, sundar --- .../dynalink/beans/AbstractJavaLinker.java | 51 +++++- .../jdk/dynalink/beans/BeanLinker.java | 120 ++++++++---- .../jdk/dynalink/beans/BeansLinker.java | 67 ++++++- ...rvicesWithMissingMemberHandlerFactory.java | 80 ++++++++ .../beans/MissingMemberHandlerFactory.java | 86 +++++++++ .../internal/objects/NativeObject.java | 2 +- .../nashorn/internal/runtime/Undefined.java | 3 + .../internal/runtime/linker/Bootstrap.java | 69 ++++--- .../linker/JavaSuperAdapterLinker.java | 21 ++- .../runtime/linker/NashornBeansLinker.java | 6 +- .../runtime/linker/NashornBottomLinker.java | 118 ++++++++---- .../linker/NashornStaticClassLinker.java | 8 +- .../test/script/basic/JDK-8049242.js.EXPECTED | 10 +- nashorn/test/script/basic/JDK-8066669.js | 11 +- .../test/script/basic/JDK-8066669.js.EXPECTED | 17 +- nashorn/test/script/basic/list.js | 21 +-- nashorn/test/script/basic/list.js.EXPECTED | 13 +- nashorn/test/script/basic/map.js | 4 +- nashorn/test/script/basic/map.js.EXPECTED | 4 +- .../dynalink/beans/test/BeanLinkerTest.java | 172 +++++++++++++----- .../dynalink/beans/test/BeansLinkerTest.java | 30 +++ .../beans/test/CallerSensitiveTest.java | 2 +- .../beans/test/CallerSensitiveTest.java | 38 ---- 23 files changed, 714 insertions(+), 239 deletions(-) create mode 100644 nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java create mode 100644 nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/MissingMemberHandlerFactory.java delete mode 100644 nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java index 01c6eb9d3fd..035b492d751 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AbstractJavaLinker.java @@ -349,31 +349,52 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { throws Exception { final CallSiteDescriptor callSiteDescriptor = request.getCallSiteDescriptor(); + final MissingMemberHandlerFactory missingMemberHandlerFactory; + final LinkerServices directLinkerServices; + if (linkerServices instanceof LinkerServicesWithMissingMemberHandlerFactory) { + final LinkerServicesWithMissingMemberHandlerFactory lswmmhf = ((LinkerServicesWithMissingMemberHandlerFactory)linkerServices); + missingMemberHandlerFactory = lswmmhf.missingMemberHandlerFactory; + directLinkerServices = lswmmhf.linkerServices; + } else { + missingMemberHandlerFactory = null; + directLinkerServices = linkerServices; + } + // Handle NamedOperation(CALL_METHOD, name) separately final Operation operation = callSiteDescriptor.getOperation(); if (operation instanceof NamedOperation) { final NamedOperation namedOperation = (NamedOperation)operation; if (namedOperation.getBaseOperation() == StandardOperation.CALL_METHOD) { - return createGuardedDynamicMethodInvocation(callSiteDescriptor, - linkerServices, namedOperation.getName().toString(), methods); + final GuardedInvocation inv = + createGuardedDynamicMethodInvocation(callSiteDescriptor, + directLinkerServices, namedOperation.getName().toString(), methods); + if (inv == null) { + return createNoSuchMemberHandler(missingMemberHandlerFactory, + request, directLinkerServices).getGuardedInvocation(); + } + return inv; } } final GuardedInvocationComponent gic = getGuardedInvocationComponent( - new ComponentLinkRequest(request, linkerServices)); + new ComponentLinkRequest(request, directLinkerServices, + missingMemberHandlerFactory)); return gic != null ? gic.getGuardedInvocation() : null; } static final class ComponentLinkRequest { final LinkRequest linkRequest; final LinkerServices linkerServices; + final MissingMemberHandlerFactory missingMemberHandlerFactory; final List operations; final Object name; ComponentLinkRequest(final LinkRequest linkRequest, - final LinkerServices linkerServices) { + final LinkerServices linkerServices, + final MissingMemberHandlerFactory missingMemberHandlerFactory) { this.linkRequest = linkRequest; this.linkerServices = linkerServices; + this.missingMemberHandlerFactory = missingMemberHandlerFactory; final Operation operation = linkRequest.getCallSiteDescriptor().getOperation(); this.operations = Arrays.asList( CompositeOperation.getOperations( @@ -383,9 +404,11 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { private ComponentLinkRequest(final LinkRequest linkRequest, final LinkerServices linkerServices, + final MissingMemberHandlerFactory missingMemberHandlerFactory, final List operations, final Object name) { this.linkRequest = linkRequest; this.linkerServices = linkerServices; + this.missingMemberHandlerFactory = missingMemberHandlerFactory; this.operations = operations; this.name = name; } @@ -396,6 +419,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { ComponentLinkRequest popOperations() { return new ComponentLinkRequest(linkRequest, linkerServices, + missingMemberHandlerFactory, operations.subList(1, operations.size()), name); } } @@ -416,7 +440,8 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { GuardedInvocationComponent getNextComponent(final ComponentLinkRequest req) throws Exception { if (req.operations.isEmpty()) { - return null; + return createNoSuchMemberHandler(req.missingMemberHandlerFactory, + req.linkRequest, req.linkerServices); } final GuardedInvocationComponent gic = getGuardedInvocationComponent(req); if (gic != null) { @@ -425,6 +450,22 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker { return getNextComponent(req.popOperations()); } + private GuardedInvocationComponent createNoSuchMemberHandler( + final MissingMemberHandlerFactory missingMemberHandlerFactory, + final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { + if (missingMemberHandlerFactory == null) { + return null; + } + final MethodHandle handler = missingMemberHandlerFactory.createMissingMemberHandler(linkRequest, linkerServices); + if (handler == null) { + return null; + } + final MethodType type = linkRequest.getCallSiteDescriptor().getMethodType(); + // The returned handler is allowed to differ in return type. + assert handler.type().changeReturnType(type.returnType()).equals(type); + return getClassGuardedInvocationComponent(handler, type); + } + static final List pop(final List l) { return l.subList(1, l.size()); } diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java index 289b9321401..9b580f12df2 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java @@ -88,6 +88,7 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.reflect.Array; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import jdk.dynalink.CallSiteDescriptor; @@ -162,12 +163,27 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL private static final MethodHandle LIST_GUARD = Guards.getInstanceOfGuard(List.class); private static final MethodHandle MAP_GUARD = Guards.getInstanceOfGuard(Map.class); + private static final MethodHandle NULL_GETTER_1; + private static final MethodHandle NULL_GETTER_2; + static { + final MethodHandle constantNull = MethodHandles.constant(Object.class, null); + NULL_GETTER_1 = dropObjectArguments(constantNull, 1); + NULL_GETTER_2 = dropObjectArguments(constantNull, 2); + } + + private static MethodHandle dropObjectArguments(final MethodHandle m, final int n) { + return MethodHandles.dropArguments(m, 0, Collections.nCopies(n, Object.class)); + } + private enum CollectionType { ARRAY, LIST, MAP }; private GuardedInvocationComponent getElementGetter(final ComponentLinkRequest req) throws Exception { final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); + final Object name = req.name; + final boolean isFixedKey = name != null; + assertParameterCount(callSiteDescriptor, isFixedKey ? 1 : 2); final LinkerServices linkerServices = req.linkerServices; final MethodType callSiteType = callSiteDescriptor.getMethodType(); final Class declaredType = callSiteType.parameterType(0); @@ -207,13 +223,14 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Convert the key to a number if we're working with a list or array final Object typedName; - final Object name = req.name; - if(collectionType != CollectionType.MAP && name != null) { - typedName = convertKeyToInteger(name, linkerServices); - if(typedName == null) { - // key is not numeric, it can never succeed + if (collectionType != CollectionType.MAP && isFixedKey) { + final Integer integer = convertKeyToInteger(name, linkerServices); + if (integer == null || integer.intValue() < 0) { + // key is not a non-negative integer, it can never address an + // array or list element return nextComponent; } + typedName = integer; } else { typedName = name; } @@ -222,30 +239,33 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL final Binder binder = new Binder(linkerServices, callSiteType, typedName); final MethodHandle invocation = gi.getInvocation(); - if(nextComponent == null) { - return gic.replaceInvocation(binder.bind(invocation)); - } - final MethodHandle checkGuard; switch(collectionType) { case LIST: - checkGuard = convertArgToInt(RANGE_CHECK_LIST, linkerServices, callSiteDescriptor); + checkGuard = convertArgToNumber(RANGE_CHECK_LIST, linkerServices, callSiteDescriptor); break; case MAP: - // TODO: A more complex solution could be devised for maps, one where we do a get() first, and fold it - // into a GWT that tests if it returned null, and if it did, do another GWT with containsKey() - // that returns constant null (on true), or falls back to next component (on false) checkGuard = linkerServices.filterInternalObjects(CONTAINS_MAP); break; case ARRAY: - checkGuard = convertArgToInt(RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor); + checkGuard = convertArgToNumber(RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor); break; default: throw new AssertionError(); } + + // If there's no next component, produce a fixed null-returning one + final GuardedInvocationComponent finalNextComponent; + if (nextComponent != null) { + finalNextComponent = nextComponent; + } else { + final MethodHandle nullGetterHandle = isFixedKey ? NULL_GETTER_1 : NULL_GETTER_2; + finalNextComponent = createGuardedInvocationComponentAsType(nullGetterHandle, callSiteType, linkerServices); + } + final MethodPair matchedInvocations = matchReturnTypes(binder.bind(invocation), - nextComponent.getGuardedInvocation().getInvocation()); - return nextComponent.compose(matchedInvocations.guardWithTest(binder.bindTest(checkGuard)), gi.getGuard(), + finalNextComponent.getGuardedInvocation().getInvocation()); + return finalNextComponent.compose(matchedInvocations.guardWithTest(binder.bindTest(checkGuard)), gi.getGuard(), gic.getValidatorClass(), gic.getValidationType()); } @@ -254,6 +274,11 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL return new GuardedInvocationComponent(linkerServices.filterInternalObjects(invocation)); } + private static GuardedInvocationComponent createGuardedInvocationComponentAsType( + final MethodHandle invocation, final MethodType fromType, final LinkerServices linkerServices) { + return new GuardedInvocationComponent(linkerServices.asType(invocation, fromType)); + } + private static GuardedInvocationComponent createInternalFilteredGuardedInvocationComponent( final MethodHandle invocation, final MethodHandle guard, final Class validatorClass, final ValidationType validationType, final LinkerServices linkerServices) { @@ -307,7 +332,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL return intIndex; } - private static MethodHandle convertArgToInt(final MethodHandle mh, final LinkerServices ls, final CallSiteDescriptor desc) { + private static MethodHandle convertArgToNumber(final MethodHandle mh, final LinkerServices ls, final CallSiteDescriptor desc) { final Class sourceType = desc.getMethodType().parameterType(1); if(TypeUtilities.isMethodInvocationConvertible(sourceType, Number.class)) { return mh; @@ -363,14 +388,10 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL } final Number n = (Number)index; final int intIndex = n.intValue(); - final double doubleValue = n.doubleValue(); - if(intIndex != doubleValue && !Double.isInfinite(doubleValue)) { // let infinite trigger IOOBE + if (intIndex != n.doubleValue()) { return false; } - if(0 <= intIndex && intIndex < Array.getLength(array)) { - return true; - } - throw new ArrayIndexOutOfBoundsException("Array index out of range: " + n); + return 0 <= intIndex && intIndex < Array.getLength(array); } @SuppressWarnings("unused") @@ -380,14 +401,14 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL } final Number n = (Number)index; final int intIndex = n.intValue(); - final double doubleValue = n.doubleValue(); - if(intIndex != doubleValue && !Double.isInfinite(doubleValue)) { // let infinite trigger IOOBE + if (intIndex != n.doubleValue()) { return false; } - if(0 <= intIndex && intIndex < list.size()) { - return true; - } - throw new IndexOutOfBoundsException("Index: " + n + ", Size: " + list.size()); + return 0 <= intIndex && intIndex < list.size(); + } + + @SuppressWarnings("unused") + private static void noOpSetter() { } private static final MethodHandle SET_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "set", @@ -396,8 +417,19 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL private static final MethodHandle PUT_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "put", MethodType.methodType(Object.class, Object.class, Object.class)); + private static final MethodHandle NO_OP_SETTER_2; + private static final MethodHandle NO_OP_SETTER_3; + static { + final MethodHandle noOpSetter = Lookup.findOwnStatic(MethodHandles.lookup(), "noOpSetter", void.class); + NO_OP_SETTER_2 = dropObjectArguments(noOpSetter, 2); + NO_OP_SETTER_3 = dropObjectArguments(noOpSetter, 3); + } + private GuardedInvocationComponent getElementSetter(final ComponentLinkRequest req) throws Exception { final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); + final Object name = req.name; + final boolean isFixedKey = name != null; + assertParameterCount(callSiteDescriptor, isFixedKey ? 2 : 3); final LinkerServices linkerServices = req.linkerServices; final MethodType callSiteType = callSiteDescriptor.getMethodType(); final Class declaredType = callSiteType.parameterType(0); @@ -446,13 +478,14 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Convert the key to a number if we're working with a list or array final Object typedName; - final Object name = req.name; - if(collectionType != CollectionType.MAP && name != null) { - typedName = convertKeyToInteger(name, linkerServices); - if(typedName == null) { - // key is not numeric, it can never succeed + if (collectionType != CollectionType.MAP && isFixedKey) { + final Integer integer = convertKeyToInteger(name, linkerServices); + if (integer == null || integer.intValue() < 0) { + // key is not a non-negative integer, it can never address an + // array or list element return nextComponent; } + typedName = integer; } else { typedName = name; } @@ -461,16 +494,27 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL final Binder binder = new Binder(linkerServices, callSiteType, typedName); final MethodHandle invocation = gi.getInvocation(); - if(nextComponent == null) { + if (collectionType == CollectionType.MAP) { + assert nextComponent == null; return gic.replaceInvocation(binder.bind(invocation)); } assert collectionType == CollectionType.LIST || collectionType == CollectionType.ARRAY; - final MethodHandle checkGuard = convertArgToInt(collectionType == CollectionType.LIST ? RANGE_CHECK_LIST : + final MethodHandle checkGuard = convertArgToNumber(collectionType == CollectionType.LIST ? RANGE_CHECK_LIST : RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor); + + // If there's no next component, produce a no-op one. + final GuardedInvocationComponent finalNextComponent; + if (nextComponent != null) { + finalNextComponent = nextComponent; + } else { + final MethodHandle noOpSetterHandle = isFixedKey ? NO_OP_SETTER_2 : NO_OP_SETTER_3; + finalNextComponent = createGuardedInvocationComponentAsType(noOpSetterHandle, callSiteType, linkerServices); + } + final MethodPair matchedInvocations = matchReturnTypes(binder.bind(invocation), - nextComponent.getGuardedInvocation().getInvocation()); - return nextComponent.compose(matchedInvocations.guardWithTest(binder.bindTest(checkGuard)), gi.getGuard(), + finalNextComponent.getGuardedInvocation().getInvocation()); + return finalNextComponent.compose(matchedInvocations.guardWithTest(binder.bindTest(checkGuard)), gi.getGuard(), gic.getValidatorClass(), gic.getValidationType()); } diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java index b68d1aa58f1..4ea49f2e560 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java @@ -146,7 +146,11 @@ import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker; * are otherwise public and link requests have call site descriptors carrying * full-strength {@link Lookup} objects and not weakened lookups or the public * lookup.

- *

The class also exposes various static methods for discovery of available + *

The behavior for handling missing members can be + * customized by passing a {@link MissingMemberHandlerFactory} to the + * {@link BeansLinker#BeansLinker(MissingMemberHandlerFactory) constructor}. + *

+ *

The class also exposes various methods for discovery of available * property and method names on classes and class instances, as well as access * to per-class linkers using the {@link #getLinkerForClass(Class)} * method.

@@ -164,10 +168,27 @@ public class BeansLinker implements GuardingDynamicLinker { } }; + private final MissingMemberHandlerFactory missingMemberHandlerFactory; + /** - * Creates a new beans linker. + * Creates a new beans linker. Equivalent to + * {@link BeansLinker#BeansLinker(MissingMemberHandlerFactory)} with + * {@code null} passed as the missing member handler factory, resulting in + * the default behavior for linking and evaluating missing members. */ public BeansLinker() { + this(null); + } + + /** + * Creates a new beans linker with the specified factory for creating + * missing member handlers. The passed factory can be null if the default + * behavior is adequate. See {@link MissingMemberHandlerFactory} for details. + * @param missingMemberHandlerFactory a factory for creating handlers for + * operations on missing members. + */ + public BeansLinker(final MissingMemberHandlerFactory missingMemberHandlerFactory) { + this.missingMemberHandlerFactory = missingMemberHandlerFactory; } /** @@ -178,7 +199,37 @@ public class BeansLinker implements GuardingDynamicLinker { * @param clazz the class * @return a bean linker for that class */ - public static TypeBasedGuardingDynamicLinker getLinkerForClass(final Class clazz) { + public TypeBasedGuardingDynamicLinker getLinkerForClass(final Class clazz) { + final TypeBasedGuardingDynamicLinker staticLinker = getStaticLinkerForClass(clazz); + if (missingMemberHandlerFactory == null) { + return staticLinker; + } + return new NoSuchMemberHandlerBindingLinker(staticLinker, missingMemberHandlerFactory); + } + + private static class NoSuchMemberHandlerBindingLinker implements TypeBasedGuardingDynamicLinker { + private final TypeBasedGuardingDynamicLinker linker; + private final MissingMemberHandlerFactory missingMemberHandlerFactory; + + NoSuchMemberHandlerBindingLinker(final TypeBasedGuardingDynamicLinker linker, final MissingMemberHandlerFactory missingMemberHandlerFactory) { + this.linker = linker; + this.missingMemberHandlerFactory = missingMemberHandlerFactory; + } + + @Override + public boolean canLinkType(final Class type) { + return linker.canLinkType(type); + } + + @Override + public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { + return linker.getGuardedInvocation(linkRequest, + LinkerServicesWithMissingMemberHandlerFactory.get( + linkerServices, missingMemberHandlerFactory)); + } + } + + static TypeBasedGuardingDynamicLinker getStaticLinkerForClass(final Class clazz) { return linkers.get(clazz); } @@ -234,7 +285,7 @@ public class BeansLinker implements GuardingDynamicLinker { * @return a set of names of all readable instance properties of a class. */ public static Set getReadableInstancePropertyNames(final Class clazz) { - final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); + final TypeBasedGuardingDynamicLinker linker = getStaticLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getReadablePropertyNames(); } @@ -247,7 +298,7 @@ public class BeansLinker implements GuardingDynamicLinker { * @return a set of names of all writable instance properties of a class. */ public static Set getWritableInstancePropertyNames(final Class clazz) { - final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); + final TypeBasedGuardingDynamicLinker linker = getStaticLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getWritablePropertyNames(); } @@ -260,7 +311,7 @@ public class BeansLinker implements GuardingDynamicLinker { * @return a set of names of all instance methods of a class. */ public static Set getInstanceMethodNames(final Class clazz) { - final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); + final TypeBasedGuardingDynamicLinker linker = getStaticLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getMethodNames(); } @@ -302,6 +353,8 @@ public class BeansLinker implements GuardingDynamicLinker { // Can't operate on null return null; } - return getLinkerForClass(receiver.getClass()).getGuardedInvocation(request, linkerServices); + return getLinkerForClass(receiver.getClass()).getGuardedInvocation(request, + LinkerServicesWithMissingMemberHandlerFactory.get(linkerServices, + missingMemberHandlerFactory)); } } diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java new file mode 100644 index 00000000000..916eced7c2f --- /dev/null +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.dynalink.beans; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodType; +import jdk.dynalink.linker.ConversionComparator.Comparison; +import jdk.dynalink.linker.GuardedInvocation; +import jdk.dynalink.linker.LinkRequest; +import jdk.dynalink.linker.LinkerServices; + +final class LinkerServicesWithMissingMemberHandlerFactory implements LinkerServices { + final LinkerServices linkerServices; + final MissingMemberHandlerFactory missingMemberHandlerFactory; + + static LinkerServices get(final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory) { + if (missingMemberHandlerFactory == null) { + return linkerServices; + } + return new LinkerServicesWithMissingMemberHandlerFactory(linkerServices, missingMemberHandlerFactory); + } + + private LinkerServicesWithMissingMemberHandlerFactory(final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory) { + this.linkerServices = linkerServices; + this.missingMemberHandlerFactory = missingMemberHandlerFactory; + } + + @Override + public MethodHandle asType(final MethodHandle handle, final MethodType fromType) { + return linkerServices.asType(handle, fromType); + } + + @Override + public MethodHandle getTypeConverter(final Class sourceType, final Class targetType) { + return linkerServices.getTypeConverter(sourceType, targetType); + } + + @Override + public boolean canConvert(final Class from, final Class to) { + return linkerServices.canConvert(from, to); + } + + @Override + public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest) throws Exception { + return linkerServices.getGuardedInvocation(linkRequest); + } + + @Override + public Comparison compareConversion(final Class sourceType, final Class targetType1, final Class targetType2) { + return linkerServices.compareConversion(sourceType, targetType1, targetType2); + } + + @Override + public MethodHandle filterInternalObjects(final MethodHandle target) { + return linkerServices.filterInternalObjects(target); + } +} diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/MissingMemberHandlerFactory.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/MissingMemberHandlerFactory.java new file mode 100644 index 00000000000..1fe50b916d9 --- /dev/null +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/MissingMemberHandlerFactory.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.dynalink.beans; + +import java.lang.invoke.MethodHandle; +import jdk.dynalink.DynamicLinkerFactory; +import jdk.dynalink.NamedOperation; +import jdk.dynalink.NoSuchDynamicMethodException; +import jdk.dynalink.StandardOperation; +import jdk.dynalink.linker.LinkRequest; +import jdk.dynalink.linker.LinkerServices; + +/** + * A factory for creating method handles for linking missing member behavior + * in {@link BeansLinker}. BeansLinker links these method handles into guarded + * invocations for link requests specifying {@code GET_*} and {@code SET_*} + * {@link StandardOperation}s when it is either certain or possible that the + * requested member (property, method, or element) is missing. They will be + * linked both for {@link NamedOperation named} and unnamed operations. The + * implementer must ensure that the parameter types of the returned method + * handle match the parameter types of the call site described in the link + * request. The return types can differ, though, to allow + * {@link DynamicLinkerFactory#setPrelinkTransformer(jdk.dynalink.linker.GuardedInvocationTransformer)} + * late return type transformations}. It is allowed to return {@code null} for a + * method handle if the default behavior is sufficient. + *

Default missing member behavior

+ * When a {@link BeansLinker} is configured without a missing member handler + * factory, or the factory returns {@code null} for a particular handler + * creation invocation, the default behavior is used. The default behavior is to + * return {@code null} from + * {@link BeansLinker#getGuardedInvocation(LinkRequest, LinkerServices)} when it + * can be determined at link time that the linked operation will never address + * an existing member. This lets the {@code DynamicLinker} attempt the next + * linker if there is one, or ultimately fail the link request with + * {@link NoSuchDynamicMethodException}. For other cases (typically all unnamed + * member operations as well as most named operations on collection elements) + * {@code BeansLinker} will produce a conditional linkage that will return + * {@code null} when invoked at runtime with a name that does not match any + * member for getters and silently ignore the passed values for setters. + *

Implementing exception-throwing behavior

+ * Note that if the language-specific behavior for an operation on a missing + * member is to throw an exception then the factory should produce a method + * handle that throws the exception when invoked, and must not throw an + * exception itself, as the linkage for the missing member is often conditional. + * + * @see BeansLinker#BeansLinker(MissingMemberHandlerFactory) + */ +@FunctionalInterface +public interface MissingMemberHandlerFactory { + /** + * Returns a method handle suitable for implementing missing member behavior + * for a particular link request. See the class description for details. + * @param linkRequest the current link request + * @param linkerServices the current link services + * @return a method handle that can be invoked if the property, element, or + * method being addressed by an operation is missing. The return value can + * be null. + * @throws Exception if the operation fails for any reason. Please observe + * the class documentation notes for implementing exception-throwing + * missing member behavior. + */ + public MethodHandle createMissingMemberHandler(LinkRequest linkRequest, LinkerServices linkerServices) throws Exception; +} diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java index 1f1488a7e33..bdd8c2a9cd1 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java @@ -776,7 +776,7 @@ public final class NativeObject { final MethodType getterType = MethodType.methodType(Object.class, clazz); final MethodType setterType = MethodType.methodType(Object.class, clazz, Object.class); - final GuardingDynamicLinker linker = BeansLinker.getLinkerForClass(clazz); + final GuardingDynamicLinker linker = Bootstrap.getBeanLinkerForClass(clazz); final List properties = new ArrayList<>(propertyNames.size() + methodNames.size()); for(final String methodName: methodNames) { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java index bb29198bc5d..da172b07939 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Undefined.java @@ -94,6 +94,9 @@ public final class Undefined extends DefaultPropertyAccess { */ public static GuardedInvocation lookup(final CallSiteDescriptor desc) { final StandardOperation op = NashornCallSiteDescriptor.getFirstStandardOperation(desc); + if (op == null) { + return null; + } switch (op) { case CALL: case NEW: diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java index eecb008922f..3e41a7dcd6a 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java @@ -40,10 +40,11 @@ import jdk.dynalink.DynamicLinkerFactory; import jdk.dynalink.beans.BeansLinker; import jdk.dynalink.beans.StaticClass; import jdk.dynalink.linker.GuardedInvocation; -import jdk.dynalink.linker.GuardedInvocationTransformer; +import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.MethodTypeConversionStrategy; +import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker; import jdk.dynalink.linker.support.TypeUtilities; import jdk.nashorn.api.scripting.JSObject; import jdk.nashorn.internal.codegen.CompilerConstants.Call; @@ -67,6 +68,24 @@ public final class Bootstrap { private static final MethodHandle VOID_TO_OBJECT = MH.constant(Object.class, ScriptRuntime.UNDEFINED); + private static final BeansLinker beansLinker = new BeansLinker(Bootstrap::createMissingMemberHandler); + private static final GuardingDynamicLinker[] prioritizedLinkers; + private static final GuardingDynamicLinker[] fallbackLinkers; + static { + final NashornBeansLinker nashornBeansLinker = new NashornBeansLinker(beansLinker); + prioritizedLinkers = new GuardingDynamicLinker[] { + new NashornLinker(), + new NashornPrimitiveLinker(), + new NashornStaticClassLinker(beansLinker), + new BoundCallableLinker(), + new JavaSuperAdapterLinker(beansLinker), + new JSObjectLinker(nashornBeansLinker), + new BrowserJSObjectLinker(nashornBeansLinker), + new ReflectionCheckLinker() + }; + fallbackLinkers = new GuardingDynamicLinker[] {nashornBeansLinker, new NashornBottomLinker() }; + } + // do not create me!! private Bootstrap() { } @@ -81,31 +100,14 @@ public final class Bootstrap { public static DynamicLinker createDynamicLinker(final ClassLoader appLoader, final int unstableRelinkThreshold) { final DynamicLinkerFactory factory = new DynamicLinkerFactory(); - final NashornBeansLinker nashornBeansLinker = new NashornBeansLinker(); - factory.setPrioritizedLinkers( - new NashornLinker(), - new NashornPrimitiveLinker(), - new NashornStaticClassLinker(), - new BoundCallableLinker(), - new JavaSuperAdapterLinker(), - new JSObjectLinker(nashornBeansLinker), - new BrowserJSObjectLinker(nashornBeansLinker), - new ReflectionCheckLinker()); - factory.setFallbackLinkers(nashornBeansLinker, new NashornBottomLinker()); + factory.setPrioritizedLinkers(prioritizedLinkers); + factory.setFallbackLinkers(fallbackLinkers); factory.setSyncOnRelink(true); - factory.setPrelinkTransformer(new GuardedInvocationTransformer() { - @Override - public GuardedInvocation filter(final GuardedInvocation inv, final LinkRequest request, final LinkerServices linkerServices) { - final CallSiteDescriptor desc = request.getCallSiteDescriptor(); - return OptimisticReturnFilters.filterOptimisticReturnValue(inv, desc).asType(linkerServices, desc.getMethodType()); - } - }); - factory.setAutoConversionStrategy(new MethodTypeConversionStrategy() { - @Override - public MethodHandle asType(final MethodHandle target, final MethodType newType) { - return unboxReturnType(target, newType); - } + factory.setPrelinkTransformer((inv, request, linkerServices) -> { + final CallSiteDescriptor desc = request.getCallSiteDescriptor(); + return OptimisticReturnFilters.filterOptimisticReturnValue(inv, desc).asType(linkerServices, desc.getMethodType()); }); + factory.setAutoConversionStrategy(Bootstrap::unboxReturnType); factory.setInternalObjectsFilter(NashornBeansLinker.createHiddenObjectFilter()); factory.setUnstableRelinkThreshold(unstableRelinkThreshold); @@ -114,6 +116,15 @@ public final class Bootstrap { return factory.createLinker(); } + /** + * Returns a dynamic linker for the specific Java class using beans semantics. + * @param clazz the Java class + * @return a dynamic linker for the specific Java class using beans semantics. + */ + public static TypeBasedGuardingDynamicLinker getBeanLinkerForClass(final Class clazz) { + return beansLinker.getLinkerForClass(clazz); + } + /** * Returns if the given object is a "callable" * @param obj object to be checked for callability @@ -475,4 +486,14 @@ public final class Bootstrap { } return target; } + + private static MethodHandle createMissingMemberHandler( + final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { + if (BrowserJSObjectLinker.canLinkTypeStatic(linkRequest.getReceiver().getClass())) { + // Don't create missing member handlers for the browser JS objects as they + // have their own logic. + return null; + } + return NashornBottomLinker.linkMissingBeanMember(linkRequest, linkerServices); + } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapterLinker.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapterLinker.java index 669badfaba3..6629b1ada5d 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapterLinker.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapterLinker.java @@ -25,7 +25,6 @@ package jdk.nashorn.internal.runtime.linker; -import static jdk.nashorn.internal.lookup.Lookup.EMPTY_GETTER; import static jdk.nashorn.internal.runtime.linker.JavaAdapterBytecodeGenerator.SUPER_PREFIX; import java.lang.invoke.MethodHandle; @@ -62,6 +61,12 @@ final class JavaSuperAdapterLinker implements TypeBasedGuardingDynamicLinker { IS_ADAPTER_OF_CLASS = lookup.findOwnStatic("isAdapterOfClass", boolean.class, Class.class, Object.class); } + private final BeansLinker beansLinker; + + JavaSuperAdapterLinker(final BeansLinker beansLinker) { + this.beansLinker = beansLinker; + } + @Override public boolean canLinkType(final Class type) { return type == JavaSuperAdapter.class; @@ -101,17 +106,13 @@ final class JavaSuperAdapterLinker implements TypeBasedGuardingDynamicLinker { // Delegate to BeansLinker final GuardedInvocation guardedInv = NashornBeansLinker.getGuardedInvocation( - BeansLinker.getLinkerForClass(adapterClass), linkRequest.replaceArguments(newDescriptor, args), + beansLinker, linkRequest.replaceArguments(newDescriptor, args), linkerServices); + // Even for non-existent methods, Bootstrap's BeansLinker will link a + // noSuchMember handler. + assert guardedInv != null; final MethodHandle guard = IS_ADAPTER_OF_CLASS.bindTo(adapterClass); - if(guardedInv == null) { - // Short circuit the lookup here for non-existent methods by linking an empty getter. If we just returned - // null instead, BeansLinker would find final methods on the JavaSuperAdapter instead: getClass() and - // wait(). - return new GuardedInvocation(MethodHandles.dropArguments(EMPTY_GETTER, 1,type.parameterList().subList(1, - type.parameterCount())), guard).asType(descriptor); - } final MethodHandle invocation = guardedInv.getInvocation(); final MethodType invType = invocation.type(); @@ -165,7 +166,7 @@ final class JavaSuperAdapterLinker implements TypeBasedGuardingDynamicLinker { */ @SuppressWarnings("unused") private static Object bindDynamicMethod(final Object dynamicMethod, final Object boundThis) { - return dynamicMethod == null ? ScriptRuntime.UNDEFINED : Bootstrap.bindCallable(dynamicMethod, boundThis, null); + return dynamicMethod == ScriptRuntime.UNDEFINED ? ScriptRuntime.UNDEFINED : Bootstrap.bindCallable(dynamicMethod, boundThis, null); } /** diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java index 97c6b404943..19d5fa9dd74 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java @@ -85,7 +85,11 @@ public class NashornBeansLinker implements GuardingDynamicLinker { } }; - private final BeansLinker beansLinker = new BeansLinker(); + private final BeansLinker beansLinker; + + NashornBeansLinker(final BeansLinker beansLinker) { + this.beansLinker = beansLinker; + } @Override public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java index 79353d02cea..8c4735f234e 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java @@ -27,26 +27,27 @@ package jdk.nashorn.internal.runtime.linker; import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; -import static jdk.nashorn.internal.runtime.JSType.GET_UNDEFINED; -import static jdk.nashorn.internal.runtime.JSType.TYPE_OBJECT_INDEX; import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.util.HashMap; import java.util.Map; import java.util.function.Supplier; import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.NamedOperation; import jdk.dynalink.Operation; +import jdk.dynalink.StandardOperation; import jdk.dynalink.beans.BeansLinker; import jdk.dynalink.linker.GuardedInvocation; import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingTypeConverterFactory; import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkerServices; -import jdk.dynalink.linker.support.Guards; +import jdk.dynalink.linker.support.Lookup; import jdk.nashorn.internal.codegen.types.Type; +import jdk.nashorn.internal.runtime.ECMAException; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; @@ -73,7 +74,7 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo // this point is a generic Java bean. Therefore, reaching here with a ScriptObject is a Nashorn bug. assert isExpectedObject(self) : "Couldn't link " + linkRequest.getCallSiteDescriptor() + " for " + self.getClass().getName(); - return linkBean(linkRequest, linkerServices); + return linkBean(linkRequest); } private static final MethodHandle EMPTY_PROP_GETTER = @@ -85,7 +86,18 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo private static final MethodHandle EMPTY_ELEM_SETTER = MH.dropArguments(EMPTY_PROP_SETTER, 0, Object.class); - private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { + private static final MethodHandle THROW_NO_SUCH_FUNCTION; + private static final MethodHandle THROW_STRICT_PROPERTY_SETTER; + private static final MethodHandle THROW_OPTIMISTIC_UNDEFINED; + + static { + final Lookup lookup = new Lookup(MethodHandles.lookup()); + THROW_NO_SUCH_FUNCTION = lookup.findOwnStatic("throwNoSuchFunction", Object.class, Object.class, Object.class); + THROW_STRICT_PROPERTY_SETTER = lookup.findOwnStatic("throwStrictPropertySetter", void.class, Object.class, Object.class); + THROW_OPTIMISTIC_UNDEFINED = lookup.findOwnStatic("throwOptimisticUndefined", Object.class, int.class); + } + + private static GuardedInvocation linkBean(final LinkRequest linkRequest) throws Exception { final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); switch (NashornCallSiteDescriptor.getFirstStandardOperation(desc)) { @@ -105,35 +117,79 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", NashornCallSiteDescriptor.getFunctionErrorMessage(desc, self)); - case CALL_METHOD: - throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); - case GET_METHOD: - // evaluate to undefined, later on Undefined will take care of throwing TypeError - return getInvocation(MH.dropArguments(GET_UNDEFINED.get(TYPE_OBJECT_INDEX), 0, Object.class), self, linkerServices, desc); - case GET_PROPERTY: - case GET_ELEMENT: - if(NashornCallSiteDescriptor.isOptimistic(desc)) { - throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT); - } - if (NashornCallSiteDescriptor.getOperand(desc) != null) { - return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); - } - return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); - case SET_PROPERTY: - case SET_ELEMENT: - final boolean strict = NashornCallSiteDescriptor.isStrict(desc); - if (strict) { - throw typeError("cant.set.property", getArgument(linkRequest), ScriptRuntime.safeToString(self)); - } - if (NashornCallSiteDescriptor.getOperand(desc) != null) { - return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); - } - return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); default: + // Everything else is supposed to have been already handled by Bootstrap.beansLinker + // delegating to linkNoSuchBeanMember throw new AssertionError("unknown call type " + desc); } } + static MethodHandle linkMissingBeanMember(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { + final CallSiteDescriptor desc = linkRequest.getCallSiteDescriptor(); + final StandardOperation op = NashornCallSiteDescriptor.getFirstStandardOperation(desc); + if (op != null) { + final String operand = NashornCallSiteDescriptor.getOperand(desc); + switch (op) { + case CALL_METHOD: + return adaptThrower(bindOperand(THROW_NO_SUCH_FUNCTION, operand), desc); + case GET_METHOD: + case GET_PROPERTY: + case GET_ELEMENT: { + if (NashornCallSiteDescriptor.isOptimistic(desc)) { + return adaptThrower(MethodHandles.insertArguments(THROW_OPTIMISTIC_UNDEFINED, 0, NashornCallSiteDescriptor.getProgramPoint(desc)), desc); + } + if (NashornCallSiteDescriptor.getOperand(desc) != null) { + return getInvocation(EMPTY_PROP_GETTER, linkerServices, desc); + } + return getInvocation(EMPTY_ELEM_GETTER, linkerServices, desc); + } + case SET_PROPERTY: + case SET_ELEMENT: + final boolean strict = NashornCallSiteDescriptor.isStrict(desc); + if (strict) { + return adaptThrower(bindOperand(THROW_STRICT_PROPERTY_SETTER, operand), desc); + } + if (NashornCallSiteDescriptor.getOperand(desc) != null) { + return getInvocation(EMPTY_PROP_SETTER, linkerServices, desc); + } + return getInvocation(EMPTY_ELEM_SETTER, linkerServices, desc); + default: + } + } + throw new AssertionError("unknown call type " + desc); + } + + private static MethodHandle bindOperand(final MethodHandle handle, final String operand) { + return operand == null ? handle : MethodHandles.insertArguments(handle, 1, operand); + } + + private static MethodHandle adaptThrower(final MethodHandle handle, final CallSiteDescriptor desc) { + final MethodType targetType = desc.getMethodType(); + final int paramCount = handle.type().parameterCount(); + return MethodHandles + .dropArguments(handle, paramCount, targetType.parameterList().subList(paramCount, targetType.parameterCount())) + .asType(targetType); + } + + @SuppressWarnings("unused") + private static Object throwNoSuchFunction(final Object self, final Object name) { + throw createTypeError(self, name, "no.such.function"); + } + + @SuppressWarnings("unused") + private static void throwStrictPropertySetter(final Object self, final Object name) { + throw createTypeError(self, name, "cant.set.property"); + } + + private static ECMAException createTypeError(final Object self, final Object name, final String msg) { + return typeError(msg, String.valueOf(name), ScriptRuntime.safeToString(self)); + } + + @SuppressWarnings("unused") + private static Object throwOptimisticUndefined(final int programPoint) { + throw new UnwarrantedOptimismException(UNDEFINED, programPoint, Type.OBJECT); + } + @Override public GuardedInvocation convertToType(final Class sourceType, final Class targetType, final Supplier lookupSupplier) throws Exception { final GuardedInvocation gi = convertToTypeNoCast(sourceType, targetType); @@ -158,8 +214,8 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo return null; } - private static GuardedInvocation getInvocation(final MethodHandle handle, final Object self, final LinkerServices linkerServices, final CallSiteDescriptor desc) { - return Bootstrap.asTypeSafeReturn(new GuardedInvocation(handle, Guards.getClassGuard(self.getClass())), linkerServices, desc); + private static MethodHandle getInvocation(final MethodHandle handle, final LinkerServices linkerServices, final CallSiteDescriptor desc) { + return linkerServices.asTypeLosslessReturn(handle, desc.getMethodType()); } // Used solely in an assertion to figure out if the object we get here is something we in fact expect. Objects diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java index a6c1d4a012d..8201aa631cf 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java @@ -53,7 +53,11 @@ import jdk.nashorn.internal.runtime.ECMAErrors; * */ final class NashornStaticClassLinker implements TypeBasedGuardingDynamicLinker { - private static final GuardingDynamicLinker staticClassLinker = BeansLinker.getLinkerForClass(StaticClass.class); + private final GuardingDynamicLinker staticClassLinker; + + NashornStaticClassLinker(final BeansLinker beansLinker) { + this.staticClassLinker = beansLinker.getLinkerForClass(StaticClass.class); + } @Override public boolean canLinkType(final Class type) { @@ -100,7 +104,7 @@ final class NashornStaticClassLinker implements TypeBasedGuardingDynamicLinker { return delegate(linkerServices, request); } - private static GuardedInvocation delegate(final LinkerServices linkerServices, final LinkRequest request) throws Exception { + private GuardedInvocation delegate(final LinkerServices linkerServices, final LinkRequest request) throws Exception { return NashornBeansLinker.getGuardedInvocation(staticClassLinker, request, linkerServices); } diff --git a/nashorn/test/script/basic/JDK-8049242.js.EXPECTED b/nashorn/test/script/basic/JDK-8049242.js.EXPECTED index 660ec15af11..cec6dd89ffb 100644 --- a/nashorn/test/script/basic/JDK-8049242.js.EXPECTED +++ b/nashorn/test/script/basic/JDK-8049242.js.EXPECTED @@ -1,10 +1,10 @@ abc [jdk.dynalink.beans.SimpleDynamicMethod java.lang.String(char[],int,int)] ava -TypeError: null is not a function -TypeError: null is not a function -TypeError: null is not a function +TypeError: Java.type("java.lang.Object")["()xxxxx"] is not a function +TypeError: Java.type("java.lang.Object")["("] is not a function +TypeError: Java.type("java.lang.Object")[")"] is not a function TypeError: Constructor [jdk.dynalink.beans.SimpleDynamicMethod java.lang.String(char[],int,int)] requires "new". -TypeError: null is not a function -TypeError: null is not a function +TypeError: Java.type("java.lang.Runnable")["()"] is not a function +TypeError: Java.type("java.lang.Runnable")["(int)"] is not a function java.lang.InstantiationException: java.io.InputStream diff --git a/nashorn/test/script/basic/JDK-8066669.js b/nashorn/test/script/basic/JDK-8066669.js index ea5a2860cac..65371e57faf 100644 --- a/nashorn/test/script/basic/JDK-8066669.js +++ b/nashorn/test/script/basic/JDK-8066669.js @@ -29,12 +29,13 @@ */ // Make sure index access on Java objects is working as expected. -var map = new java.util.HashMap(); +var map = new java.util.LinkedHashMap(); map["foo"] = "bar"; map[1] = 2; map[false] = true; map[null] = 0; +map["a"] = null; print(map); @@ -49,10 +50,12 @@ print(typeof map["foo"], map["foo"]); print(typeof map[1], map[1]); print(typeof map[false], map[false]); print(typeof map[null], map[null]); +print(typeof map["a"], map["a"]); -print(map.foo); -print(map.false); -print(map.null); +print("map.foo=" + map.foo); +print("map.false=" + map.false); +print("map.null=" + map.null); +print("map.a=" + map.a); map.foo = "baz"; print(map); diff --git a/nashorn/test/script/basic/JDK-8066669.js.EXPECTED b/nashorn/test/script/basic/JDK-8066669.js.EXPECTED index 4af5381706a..86b817d1a5c 100644 --- a/nashorn/test/script/basic/JDK-8066669.js.EXPECTED +++ b/nashorn/test/script/basic/JDK-8066669.js.EXPECTED @@ -1,13 +1,16 @@ -{null=0, 1=2, false=true, foo=bar} -object null +{foo=bar, 1=2, false=true, null=0, a=null} +string foo number 1 boolean false -string foo +object null +string a string bar number 2 boolean true number 0 -bar -null -null -{null=0, 1=2, false=true, foo=baz} +object null +map.foo=bar +map.false=undefined +map.null=undefined +map.a=null +{foo=baz, 1=2, false=true, null=0, a=null} diff --git a/nashorn/test/script/basic/list.js b/nashorn/test/script/basic/list.js index acbffca72be..c1f7de42f95 100644 --- a/nashorn/test/script/basic/list.js +++ b/nashorn/test/script/basic/list.js @@ -54,15 +54,14 @@ print("l['blah']=" + l['blah']) // non-number indices don't retrieve anything... var size_name = "size" print("l[size_name]()=" + l[size_name]()) // ... but existing methods can be accessed with [] -expectException(2) // Java lists don't auto-expand to accommodate new indices -expectException(java.lang.Double.POSITIVE_INFINITY) // Dynalink will throw IOOBE -expectException(java.lang.Double.NEGATIVE_INFINITY) // Dynalink will throw IOOBE +// All illegal indices, even those out of bounds, return undefined +print("l[2]=" + l[2]); +print("l[-1]=" + l[-1]); +print("l[2.1]=" + l[2.1]); +print("l[-1.1]=" + l[-1.1]); +print("l[Infinity]=" + l[Infinity]); +print("l[-Infinity]=" + l[-Infinity]); +print("l[NaN]=" + l[NaN]); -function expectException(index) { - try { - l[index] = "x" - print("Not caught out-of-bounds assignment for " + index) - } catch(e) { - print(e) - } -} +l[1.1]="b"; // should be no-op +print("l[0]=" + l[0]); diff --git a/nashorn/test/script/basic/list.js.EXPECTED b/nashorn/test/script/basic/list.js.EXPECTED index 3e4109828aa..57846fccd46 100644 --- a/nashorn/test/script/basic/list.js.EXPECTED +++ b/nashorn/test/script/basic/list.js.EXPECTED @@ -9,9 +9,14 @@ bar --for each end-- l[0]=foo l[1]=a -l[0.9]=null +l[0.9]=undefined l['blah']=undefined l[size_name]()=2 -java.lang.IndexOutOfBoundsException: Index: 2, Size: 2 -java.lang.IndexOutOfBoundsException: Index: Infinity, Size: 2 -java.lang.IndexOutOfBoundsException: Index: -Infinity, Size: 2 +l[2]=undefined +l[-1]=undefined +l[2.1]=undefined +l[-1.1]=undefined +l[Infinity]=undefined +l[-Infinity]=undefined +l[NaN]=undefined +l[0]=foo diff --git a/nashorn/test/script/basic/map.js b/nashorn/test/script/basic/map.js index 79bf3d3f019..c17e8453a22 100644 --- a/nashorn/test/script/basic/map.js +++ b/nashorn/test/script/basic/map.js @@ -44,8 +44,8 @@ print("m.empty = " + m.empty) // prints "false" print("m['empty'] = " + m['empty']) print("m[empty_key] = " + m[empty_key]) // prints "foo" -print("m.bwah = " + m.bwah) // prints "null" -print("m['bwah'] = " + m['bwah']) // prints "null" +print("m.bwah = " + m.bwah) // prints "undefined" +print("m['bwah'] = " + m['bwah']) // prints "undefined" m.put("twonk", "ding") print("m.twonk = " + m.twonk) // prints "ding" diff --git a/nashorn/test/script/basic/map.js.EXPECTED b/nashorn/test/script/basic/map.js.EXPECTED index 471e86e9f1b..b83609ab158 100644 --- a/nashorn/test/script/basic/map.js.EXPECTED +++ b/nashorn/test/script/basic/map.js.EXPECTED @@ -7,8 +7,8 @@ m = {empty=foo} m.empty = false m['empty'] = foo m[empty_key] = foo -m.bwah = null -m['bwah'] = null +m.bwah = undefined +m['bwah'] = undefined m.twonk = ding m['twonk'] = ding m.size()=2 diff --git a/nashorn/test/src/jdk/dynalink/beans/test/BeanLinkerTest.java b/nashorn/test/src/jdk/dynalink/beans/test/BeanLinkerTest.java index f5ba9aee9fa..b74f6cc981d 100644 --- a/nashorn/test/src/jdk/dynalink/beans/test/BeanLinkerTest.java +++ b/nashorn/test/src/jdk/dynalink/beans/test/BeanLinkerTest.java @@ -24,7 +24,17 @@ */ package jdk.dynalink.beans.test; +import static jdk.dynalink.StandardOperation.CALL; +import static jdk.dynalink.StandardOperation.CALL_METHOD; +import static jdk.dynalink.StandardOperation.GET_ELEMENT; +import static jdk.dynalink.StandardOperation.GET_LENGTH; +import static jdk.dynalink.StandardOperation.GET_METHOD; +import static jdk.dynalink.StandardOperation.GET_PROPERTY; +import static jdk.dynalink.StandardOperation.NEW; +import static jdk.dynalink.StandardOperation.SET_ELEMENT; + import java.lang.invoke.CallSite; +import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.security.AccessControlException; @@ -38,7 +48,6 @@ import jdk.dynalink.DynamicLinkerFactory; import jdk.dynalink.NamedOperation; import jdk.dynalink.NoSuchDynamicMethodException; import jdk.dynalink.Operation; -import jdk.dynalink.StandardOperation; import jdk.dynalink.beans.BeansLinker; import jdk.dynalink.beans.StaticClass; import jdk.dynalink.support.SimpleRelinkableCallSite; @@ -72,9 +81,80 @@ public class BeanLinkerTest { return createCallSite(publicLookup, new NamedOperation(op, name), mt); } + private static final MethodHandle throwArrayIndexOutOfBounds = findThrower("throwArrayIndexOutOfBounds"); + private static final MethodHandle throwIndexOutOfBounds = findThrower("throwIndexOutOfBounds"); + + private static final MethodHandle findThrower(final String name) { + try { + return MethodHandles.lookup().findStatic(BeanLinkerTest.class, name, + MethodType.methodType(Object.class, Object.class, Object.class)); + } catch (NoSuchMethodException | IllegalAccessException e) { + Assert.fail("Unexpected exception", e); + return null; + } + } + + private static Object throwArrayIndexOutOfBounds(final Object receiver, final Object index) { + throw new ArrayIndexOutOfBoundsException(String.valueOf(index)); + } + + private static Object throwIndexOutOfBounds(final Object receiver, final Object index) { + throw new IndexOutOfBoundsException(String.valueOf(index)); + } + @BeforeTest public void initLinker() { final DynamicLinkerFactory factory = new DynamicLinkerFactory(); + factory.setFallbackLinkers(new BeansLinker((req, services) -> { + // This is a MissingMemberHandlerFactory that creates a missing + // member handler for element getters and setters that throw an + // ArrayIndexOutOfBoundsException when applied to an array and an + // IndexOutOfBoundsException when applied to a list. + + final CallSiteDescriptor desc = req.getCallSiteDescriptor(); + final Operation op = desc.getOperation(); + final Operation baseOp = NamedOperation.getBaseOperation(op); + if (baseOp != GET_ELEMENT && baseOp != SET_ELEMENT) { + // We only handle GET_ELEMENT and SET_ELEMENT. + return null; + } + + final Object receiver = req.getReceiver(); + Assert.assertNotNull(receiver); + + final Class clazz = receiver.getClass(); + final MethodHandle throwerHandle; + if (clazz.isArray()) { + throwerHandle = throwArrayIndexOutOfBounds; + } else if (List.class.isAssignableFrom(clazz)) { + throwerHandle = throwIndexOutOfBounds; + } else { + Assert.fail("Unexpected receiver type " + clazz.getName()); + return null; + } + + final Object name = NamedOperation.getName(op); + final MethodHandle nameBoundHandle; + if (name == null) { + nameBoundHandle = throwerHandle; + } else { + // If the operation is for a fixed index, bind it + nameBoundHandle = MethodHandles.insertArguments(throwerHandle, 1, name); + } + + final MethodType callSiteType = desc.getMethodType(); + final MethodHandle arityMatchedHandle; + if (baseOp == SET_ELEMENT) { + // Drop "value" parameter for a setter + final int handleArity = nameBoundHandle.type().parameterCount(); + arityMatchedHandle = MethodHandles.dropArguments(nameBoundHandle, + handleArity, callSiteType.parameterType(handleArity)); + } else { + arityMatchedHandle = nameBoundHandle; + } + + return arityMatchedHandle.asType(callSiteType); + })); this.linker = factory.createLinker(); } @@ -86,7 +166,7 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void getPropertyTest(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(Object.class, Object.class, String.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_PROPERTY, mt); + final CallSite cs = createCallSite(publicLookup, GET_PROPERTY, mt); Assert.assertEquals(cs.getTarget().invoke(new Object(), "class"), Object.class); Assert.assertEquals(cs.getTarget().invoke(new Date(), "class"), Date.class); } @@ -94,14 +174,14 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void getPropertyNegativeTest(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(Object.class, Object.class, String.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_PROPERTY, mt); + final CallSite cs = createCallSite(publicLookup, GET_PROPERTY, mt); Assert.assertNull(cs.getTarget().invoke(new Object(), "DOES_NOT_EXIST")); } @Test(dataProvider = "flags") public void getPropertyTest2(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(Object.class, Object.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_PROPERTY, "class", mt); + final CallSite cs = createCallSite(publicLookup, GET_PROPERTY, "class", mt); Assert.assertEquals(cs.getTarget().invoke(new Object()), Object.class); Assert.assertEquals(cs.getTarget().invoke(new Date()), Date.class); } @@ -109,12 +189,12 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void getPropertyNegativeTest2(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(Object.class, Object.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_PROPERTY, "DOES_NOT_EXIST", mt); + final CallSite cs = createCallSite(publicLookup, GET_PROPERTY, "DOES_NOT_EXIST", mt); try { cs.getTarget().invoke(new Object()); throw new RuntimeException("Expected NoSuchDynamicMethodException"); - } catch (Throwable th) { + } catch (final Throwable th) { Assert.assertTrue(th instanceof NoSuchDynamicMethodException); } } @@ -122,7 +202,7 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void getLengthPropertyTest(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(int.class, Object.class, String.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_PROPERTY, mt); + final CallSite cs = createCallSite(publicLookup, GET_PROPERTY, mt); Assert.assertEquals((int) cs.getTarget().invoke(new int[10], "length"), 10); Assert.assertEquals((int) cs.getTarget().invoke(new String[33], "length"), 33); @@ -131,7 +211,7 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void getlengthTest(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(int.class, Object.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_LENGTH, mt); + final CallSite cs = createCallSite(publicLookup, GET_LENGTH, mt); final int[] arr = {23, 42}; Assert.assertEquals((int) cs.getTarget().invoke((Object) arr), 2); @@ -151,21 +231,21 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void getElementTest(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(int.class, Object.class, int.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_ELEMENT, mt); + final CallSite cs = createCallSite(publicLookup, GET_ELEMENT, mt); final int[] arr = {23, 42}; Assert.assertEquals((int) cs.getTarget().invoke(arr, 0), 23); Assert.assertEquals((int) cs.getTarget().invoke(arr, 1), 42); try { - int x = (int) cs.getTarget().invoke(arr, -1); + final int x = (int) cs.getTarget().invoke(arr, -1); throw new RuntimeException("expected ArrayIndexOutOfBoundsException"); - } catch (ArrayIndexOutOfBoundsException ex) { + } catch (final ArrayIndexOutOfBoundsException ex) { } try { - int x = (int) cs.getTarget().invoke(arr, arr.length); + final int x = (int) cs.getTarget().invoke(arr, arr.length); throw new RuntimeException("expected ArrayIndexOutOfBoundsException"); - } catch (ArrayIndexOutOfBoundsException ex) { + } catch (final ArrayIndexOutOfBoundsException ex) { } final List list = new ArrayList<>(); @@ -176,22 +256,22 @@ public class BeanLinkerTest { Assert.assertEquals((int) cs.getTarget().invoke(list, 1), (int) list.get(1)); Assert.assertEquals((int) cs.getTarget().invoke(list, 2), (int) list.get(2)); try { - int x = (int) cs.getTarget().invoke(list, -1); + final int x = (int) cs.getTarget().invoke(list, -1); throw new RuntimeException("expected IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException ex) { + } catch (final IndexOutOfBoundsException ex) { } try { - int x = (int) cs.getTarget().invoke(list, list.size()); + final int x = (int) cs.getTarget().invoke(list, list.size()); throw new RuntimeException("expected IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException ex) { + } catch (final IndexOutOfBoundsException ex) { } } @Test(dataProvider = "flags") public void setElementTest(final boolean publicLookup) throws Throwable { final MethodType mt = MethodType.methodType(void.class, Object.class, int.class, int.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.SET_ELEMENT, mt); + final CallSite cs = createCallSite(publicLookup, SET_ELEMENT, mt); final int[] arr = {23, 42}; cs.getTarget().invoke(arr, 0, 0); @@ -202,13 +282,13 @@ public class BeanLinkerTest { try { cs.getTarget().invoke(arr, -1, 12); throw new RuntimeException("expected ArrayIndexOutOfBoundsException"); - } catch (ArrayIndexOutOfBoundsException ex) { + } catch (final ArrayIndexOutOfBoundsException ex) { } try { cs.getTarget().invoke(arr, arr.length, 20); throw new RuntimeException("expected ArrayIndexOutOfBoundsException"); - } catch (ArrayIndexOutOfBoundsException ex) { + } catch (final ArrayIndexOutOfBoundsException ex) { } final List list = new ArrayList<>(); @@ -223,25 +303,25 @@ public class BeanLinkerTest { try { cs.getTarget().invoke(list, -1, 343); throw new RuntimeException("expected IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException ex) { + } catch (final IndexOutOfBoundsException ex) { } try { cs.getTarget().invoke(list, list.size(), 43543); throw new RuntimeException("expected IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException ex) { + } catch (final IndexOutOfBoundsException ex) { } } @Test(dataProvider = "flags") public void newObjectTest(final boolean publicLookup) { final MethodType mt = MethodType.methodType(Object.class, Object.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.NEW, mt); + final CallSite cs = createCallSite(publicLookup, NEW, mt); Object obj = null; try { obj = cs.getTarget().invoke(StaticClass.forClass(Date.class)); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -251,12 +331,12 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void staticPropertyTest(final boolean publicLookup) { final MethodType mt = MethodType.methodType(Object.class, Class.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_PROPERTY, "static", mt); + final CallSite cs = createCallSite(publicLookup, GET_PROPERTY, "static", mt); Object obj = null; try { obj = cs.getTarget().invoke(Object.class); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -265,7 +345,7 @@ public class BeanLinkerTest { try { obj = cs.getTarget().invoke(Date.class); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -274,7 +354,7 @@ public class BeanLinkerTest { try { obj = cs.getTarget().invoke(Object[].class); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -285,14 +365,14 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void instanceMethodCallTest(final boolean publicLookup) { final MethodType mt = MethodType.methodType(Object.class, Object.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_METHOD, "getClass", mt); + final CallSite cs = createCallSite(publicLookup, GET_METHOD, "getClass", mt); final MethodType mt2 = MethodType.methodType(Class.class, Object.class, Object.class); - final CallSite cs2 = createCallSite(publicLookup, StandardOperation.CALL, mt2); + final CallSite cs2 = createCallSite(publicLookup, CALL, mt2); Object method = null; try { method = cs.getTarget().invoke(new Date()); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -301,7 +381,7 @@ public class BeanLinkerTest { Class clz = null; try { clz = (Class) cs2.getTarget().invoke(method, new Date()); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -311,11 +391,11 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void instanceMethodCallTest2(final boolean publicLookup) { final MethodType mt = MethodType.methodType(Class.class, Object.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.CALL_METHOD, "getClass", mt); + final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getClass", mt); Class clz = null; try { clz = (Class) cs.getTarget().invoke(new Date()); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -325,14 +405,14 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void staticMethodCallTest(final boolean publicLookup) { final MethodType mt = MethodType.methodType(Object.class, StaticClass.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.GET_METHOD, "getProperty", mt); + final CallSite cs = createCallSite(publicLookup, GET_METHOD, "getProperty", mt); final MethodType mt2 = MethodType.methodType(String.class, Object.class, Object.class, String.class); - final CallSite cs2 = createCallSite(publicLookup, StandardOperation.CALL, mt2); + final CallSite cs2 = createCallSite(publicLookup, CALL, mt2); Object method = null; try { method = cs.getTarget().invoke(StaticClass.forClass(System.class)); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } @@ -342,7 +422,7 @@ public class BeanLinkerTest { String str = null; try { str = (String) cs2.getTarget().invoke(method, null, "os.name"); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } Assert.assertEquals(str, System.getProperty("os.name")); @@ -351,12 +431,12 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void staticMethodCallTest2(final boolean publicLookup) { final MethodType mt = MethodType.methodType(String.class, Object.class, String.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.CALL_METHOD, "getProperty", mt); + final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getProperty", mt); String str = null; try { str = (String) cs.getTarget().invoke(StaticClass.forClass(System.class), "os.name"); - } catch (Throwable th) { + } catch (final Throwable th) { throw new RuntimeException(th); } Assert.assertEquals(str, System.getProperty("os.name")); @@ -366,12 +446,12 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void systemGetenvTest(final boolean publicLookup) { final MethodType mt = MethodType.methodType(Object.class, Object.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.CALL_METHOD, "getenv", mt); + final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getenv", mt); try { cs.getTarget().invoke(StaticClass.forClass(System.class)); throw new RuntimeException("should not reach here in any case!"); - } catch (Throwable th) { + } catch (final Throwable th) { Assert.assertTrue(th instanceof SecurityException); } } @@ -380,12 +460,12 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void systemGetPropertyTest(final boolean publicLookup) { final MethodType mt = MethodType.methodType(String.class, Object.class, String.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.CALL_METHOD, "getProperty", mt); + final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "getProperty", mt); try { cs.getTarget().invoke(StaticClass.forClass(System.class), "java.home"); throw new RuntimeException("should not reach here in any case!"); - } catch (Throwable th) { + } catch (final Throwable th) { Assert.assertTrue(th instanceof SecurityException); } } @@ -394,12 +474,12 @@ public class BeanLinkerTest { @Test(dataProvider = "flags") public void systemLoadLibraryTest(final boolean publicLookup) { final MethodType mt = MethodType.methodType(void.class, Object.class, String.class); - final CallSite cs = createCallSite(publicLookup, StandardOperation.CALL_METHOD, "loadLibrary", mt); + final CallSite cs = createCallSite(publicLookup, CALL_METHOD, "loadLibrary", mt); try { cs.getTarget().invoke(StaticClass.forClass(System.class), "foo"); throw new RuntimeException("should not reach here in any case!"); - } catch (Throwable th) { + } catch (final Throwable th) { if (publicLookup) { Assert.assertTrue(th instanceof IllegalAccessError); } else { diff --git a/nashorn/test/src/jdk/dynalink/beans/test/BeansLinkerTest.java b/nashorn/test/src/jdk/dynalink/beans/test/BeansLinkerTest.java index 33bffbbf645..8ef147fab44 100644 --- a/nashorn/test/src/jdk/dynalink/beans/test/BeansLinkerTest.java +++ b/nashorn/test/src/jdk/dynalink/beans/test/BeansLinkerTest.java @@ -33,6 +33,7 @@ import static jdk.dynalink.StandardOperation.SET_PROPERTY; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -44,6 +45,7 @@ import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.CompositeOperation; import jdk.dynalink.DynamicLinkerFactory; import jdk.dynalink.NamedOperation; +import jdk.dynalink.NoSuchDynamicMethodException; import jdk.dynalink.Operation; import jdk.dynalink.StandardOperation; import jdk.dynalink.support.SimpleRelinkableCallSite; @@ -207,6 +209,30 @@ public class BeansLinkerTest { Assert.assertEquals("element2", map.get("name")); } + @Test + public static void testMissingMembersAtLinkTime() { + testPermutations(GETTER_PERMUTATIONS, (op) -> expectNoSuchDynamicMethodException(()-> call(named("foo", op), new Object()))); + testPermutations(SETTER_PERMUTATIONS, (op) -> expectNoSuchDynamicMethodException(()-> call(named("foo", op), new Object(), "newValue"))); + } + + @Test + public static void testMissingMembersAtRunTime() { + call(GET_ELEMENT, new ArrayList<>(), "foo"); + Stream.of(new HashMap(), new ArrayList(), new Object[0]).forEach((receiver) -> { + testPermutations(GETTER_PERMUTATIONS, (op) -> { System.err.println(op + " " + receiver.getClass().getName()); Assert.assertNull(call(op, receiver, "foo"));}); + // No assertion for the setter; we just expect it to silently succeed + testPermutations(SETTER_PERMUTATIONS, (op) -> call(op, receiver, "foo", "newValue")); + }); + } + + private static void expectNoSuchDynamicMethodException(final Runnable r) { + try { + r.run(); + Assert.fail("Should've thrown NoSuchDynamicMethodException"); + } catch(final NoSuchDynamicMethodException e) { + } + } + private static Operation[] GETTER_PERMUTATIONS = new Operation[] { GET_PROPERTY, GET_METHOD, @@ -240,6 +266,10 @@ public class BeansLinkerTest { testPermutationsWithFilter(ops, (op)->regex.matcher(op.toString()).matches(), expectedCount, test); } + private static void testPermutations(final Operation[] ops, final Consumer test) { + testPermutationsWithFilter(ops, (op)->true, ops.length, test); + } + private static void testPermutationsWithFilter(final Operation[] ops, final Predicate filter, final int expectedCount, final Consumer test) { final int[] counter = new int[1]; Stream.of(ops).filter(filter).forEach((op)-> { counter[0]++; test.accept(op); }); diff --git a/nashorn/test/src/jdk/dynalink/beans/test/CallerSensitiveTest.java b/nashorn/test/src/jdk/dynalink/beans/test/CallerSensitiveTest.java index 0e0d8c2d127..68656c7d039 100644 --- a/nashorn/test/src/jdk/dynalink/beans/test/CallerSensitiveTest.java +++ b/nashorn/test/src/jdk/dynalink/beans/test/CallerSensitiveTest.java @@ -33,6 +33,6 @@ import org.testng.annotations.Test; public class CallerSensitiveTest { @Test public void testCallerSensitive() { - BeansLinker.getLinkerForClass(ClassLoaderAware.class); + new BeansLinker().getLinkerForClass(ClassLoaderAware.class); } } diff --git a/nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java b/nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java deleted file mode 100644 index a23404bed0a..00000000000 --- a/nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.internal.dynalink.beans.test; - -import jdk.dynalink.beans.BeansLinker; -import jdk.nashorn.test.models.ClassLoaderAware; -import org.testng.annotations.Test; - -@SuppressWarnings("javadoc") -public class CallerSensitiveTest { - @Test - public void testCallerSensitive() { - BeansLinker.getLinkerForClass(ClassLoaderAware.class); - } -} From f89a58df619e654e38e7d32ed5cc301dbf54b6a7 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 14 Jan 2016 13:50:40 +0100 Subject: [PATCH 074/109] 8147086: Excluding of copy files broken after JDK-8144226 Reviewed-by: ihse --- make/common/JavaCompilation.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/common/JavaCompilation.gmk b/make/common/JavaCompilation.gmk index 4bf3a0d5774..c569557ec34 100644 --- a/make/common/JavaCompilation.gmk +++ b/make/common/JavaCompilation.gmk @@ -267,7 +267,7 @@ define SetupJavaCompilationBody $1_ALL_COPIES := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_COPIES)) endif ifneq (,$$($1_EXCLUDE_PATTERN)) - $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDES_PATTERN),$$($1_ALL_COPIES)) + $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_COPIES)) endif ifneq (,$$($1_ALL_COPIES)) # Yep, there are files to be copied! From d64d6d86629014ebdd85dec6fa6e52f278d4aad4 Mon Sep 17 00:00:00 2001 From: Michael Haupt Date: Thu, 14 Jan 2016 13:53:13 +0100 Subject: [PATCH 075/109] 8147078: MethodHandles.catchException does not enforce Throwable subtype Reviewed-by: psandoz, sundar --- .../java/lang/invoke/MethodHandles.java | 4 +- .../java/lang/invoke/8147078/Test8147078.java | 82 +++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/lang/invoke/8147078/Test8147078.java diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index 1448ded8b03..4925829a985 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3120,6 +3120,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); MethodHandle handler) { MethodType ttype = target.type(); MethodType htype = handler.type(); + if (!Throwable.class.isAssignableFrom(exType)) + throw new ClassCastException(exType.getName()); if (htype.parameterCount() < 1 || !htype.parameterType(0).isAssignableFrom(exType)) throw newIllegalArgumentException("handler does not accept exception type "+exType); diff --git a/jdk/test/java/lang/invoke/8147078/Test8147078.java b/jdk/test/java/lang/invoke/8147078/Test8147078.java new file mode 100644 index 00000000000..6814b2ff73a --- /dev/null +++ b/jdk/test/java/lang/invoke/8147078/Test8147078.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8147078 + * @run testng/othervm -ea -esa Test8147078 + */ + +import org.testng.annotations.Test; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; + +import static java.lang.invoke.MethodType.methodType; + +import static org.testng.AssertJUnit.*; + +public class Test8147078 { + + static int target(int x) { + throw new RuntimeException("ieps"); + } + + static int handler(String s, int x) { + return 4*x; + } + + static final MethodHandle MH_target; + static final MethodHandle MH_handler; + static final MethodHandle MH_catchException; + + static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); + + static { + try { + Class C = Test8147078.class; + MH_target = LOOKUP.findStatic(C, "target", methodType(int.class, int.class)); + MH_handler = LOOKUP.findStatic(C, "handler", methodType(int.class, String.class, int.class)); + MH_catchException = LOOKUP.findStatic(MethodHandles.class, "catchException", + methodType(MethodHandle.class, MethodHandle.class, Class.class, MethodHandle.class)); + } catch (Exception e) { + throw new ExceptionInInitializerError(e); + } + } + + @Test + public void testNoExceptionType() { + boolean caught = false; + try { + MethodHandle eek = (MethodHandle) MH_catchException.invoke(MH_target, String.class, MH_handler); + } catch (ClassCastException cce) { + assertEquals("java.lang.String", cce.getMessage()); + caught = true; + } catch (Throwable t) { + fail("unexpected exception caught: " + t); + } + assertTrue(caught); + } + +} \ No newline at end of file From 299843c5f389f31c4cbbc778a7d12175c67d95a2 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 14 Jan 2016 15:05:22 +0100 Subject: [PATCH 076/109] 8147091: Remove debug output in basics.m4 Reviewed-by: erikj --- common/autoconf/basics.m4 | 1 - common/autoconf/generated-configure.sh | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index da287403bd5..be85de751eb 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -1190,7 +1190,6 @@ AC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT], # Move configure.log from current directory to the build output root if test -e ./configure.log; then - echo found it $MV -f ./configure.log "$OUTPUT_ROOT/configure.log" 2> /dev/null fi diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index df36d8dc4ec..5ecfef8e2af 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -4839,7 +4839,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1452769076 +DATE_WHEN_GENERATED=1452780299 ############################################################################### # @@ -62030,7 +62030,6 @@ fi # Move configure.log from current directory to the build output root if test -e ./configure.log; then - echo found it $MV -f ./configure.log "$OUTPUT_ROOT/configure.log" 2> /dev/null fi From cd819992869a781a9caa8c98d472bab8148c3dd8 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Thu, 14 Jan 2016 18:22:32 +0300 Subject: [PATCH 077/109] 8145409: Better detect JRE that JLI will be using Reviewed-by: ksrini --- .../java.base/windows/native/libjli/java_md.c | 47 +++++++++++++++++-- .../java.base/windows/native/libjli/java_md.h | 3 ++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/windows/native/libjli/java_md.c b/jdk/src/java.base/windows/native/libjli/java_md.c index 98f3e985c90..65422bc039f 100644 --- a/jdk/src/java.base/windows/native/libjli/java_md.c +++ b/jdk/src/java.base/windows/native/libjli/java_md.c @@ -337,6 +337,15 @@ GetJREPath(char *path, jint pathsize) } } + /* Try getting path to JRE from path to JLI.DLL */ + if (GetApplicationHomeFromDll(path, pathsize)) { + JLI_Snprintf(javadll, sizeof(javadll), "%s\\bin\\" JAVA_DLL, path); + if (stat(javadll, &s) == 0) { + JLI_TraceLauncher("JRE path is %s\n", path); + return JNI_TRUE; + } + } + JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); return JNI_FALSE; @@ -404,17 +413,17 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) } /* - * If app is "c:\foo\bin\javac", then put "c:\foo" into buf. + * Removes the trailing file name and one sub-folder from a path. + * If buf is "c:\foo\bin\javac", then put "c:\foo" into buf. */ jboolean -GetApplicationHome(char *buf, jint bufsize) +TruncatePath(char *buf) { char *cp; - GetModuleFileName(0, buf, bufsize); *JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */ if ((cp = JLI_StrRChr(buf, '\\')) == 0) { /* This happens if the application is in a drive root, and - * there is no bin directory. */ + * there is no bin directory. */ buf[0] = '\0'; return JNI_FALSE; } @@ -422,6 +431,36 @@ GetApplicationHome(char *buf, jint bufsize) return JNI_TRUE; } +/* + * Retrieves the path to the JRE home by locating the executable file + * of the current process and then truncating the path to the executable + */ +jboolean +GetApplicationHome(char *buf, jint bufsize) +{ + GetModuleFileName(NULL, buf, bufsize); + return TruncatePath(buf); +} + +/* + * Retrieves the path to the JRE home by locating JLI.DLL and + * then truncating the path to JLI.DLL + */ +jboolean +GetApplicationHomeFromDll(char *buf, jint bufsize) +{ + HMODULE hModule; + DWORD dwFlags = + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; + + if (GetModuleHandleEx(dwFlags, (LPCSTR)&GetJREPath, &hModule) == 0) { + return JNI_FALSE; + }; + GetModuleFileName(hModule, buf, bufsize); + return TruncatePath(buf); +} + /* * Support for doing cheap, accurate interval timing. */ diff --git a/jdk/src/java.base/windows/native/libjli/java_md.h b/jdk/src/java.base/windows/native/libjli/java_md.h index 76c15ea8e32..ec3131f6b61 100644 --- a/jdk/src/java.base/windows/native/libjli/java_md.h +++ b/jdk/src/java.base/windows/native/libjli/java_md.h @@ -54,4 +54,7 @@ extern jlong Counter2Micros(jlong counts); int UnsetEnv(char *name); +jboolean +GetApplicationHomeFromDll(char *buf, jint bufsize); + #endif /* JAVA_MD_H */ From 2fd84cae8308cdf8a05df4047a1a2d0bd35188d2 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:13 -0800 Subject: [PATCH 078/109] Added tag jdk-9+101 for changeset f2b58023ac04 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 67085b3ac37..ad5eaa36b36 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -343,3 +343,4 @@ cf1dc4c035fb84693d4ae5ad818785cb4d1465d1 jdk9-b90 48987460c7d49a29013963ee44d090194396bb61 jdk-9+98 7c0577bea4c65d69c5bef67023a89d2efa4fb2f7 jdk-9+99 c1f30ac14db0eaff398429c04cd9fab92e1b4b2a jdk-9+100 +c4d72a1620835b5d657b7b6792c2879367d0154f jdk-9+101 From b6c6afc1744e8fb71cb8eaf8df5411d4d8b95133 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:14 -0800 Subject: [PATCH 079/109] Added tag jdk-9+101 for changeset e5bebbbe0a34 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 4a5ada00d4a..621cce92dcc 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -343,3 +343,4 @@ feb1bd85d7990dcf5584ca9e53104269c01db006 jdk-9+96 ea285530245cf4e0edf0479121a41347d3030eba jdk-9+98 180212ee1d8710691ba9944593dfc1ff3e4f1532 jdk-9+99 791d0d3ac0138faeb6110bd840a4545bc1950df2 jdk-9+100 +30dfb3bd3d06b4bb80a087babc0d1841edba187b jdk-9+101 From 1517e0a82f9ef90e1ff17d5d07c2993724f281ad Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:15 -0800 Subject: [PATCH 080/109] Added tag jdk-9+101 for changeset 8319ac454c80 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 271e5408b1a..2861744a267 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -503,3 +503,4 @@ de592ea5f7ba0f8a8c5afc03bd169f7690c72b6f jdk-9+97 e5b1a23be1e105417ba1c4c576ab373eb3fa2c2b jdk-9+98 f008e8cc10d5b3212fb22d58c96fa01d38654f19 jdk-9+99 bdb0acafc63c42e84d9d8195bf2e2b25ee9c3306 jdk-9+100 +9f45d3d57d6948cf526fbc2e2891a9a74ac6941a jdk-9+101 From af7d25e14bcccc3b858523ba859d36870a12fd16 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:18 -0800 Subject: [PATCH 081/109] Added tag jdk-9+101 for changeset 8927994dbcdb --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index b016abbf315..89a01eeb6d6 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -343,3 +343,4 @@ c8d0845877a811ab4350935892f826929359a3ff jdk-9+95 52b01339235f24c93b679bd6b8fb36a1072ad0ac jdk-9+98 52774b544850c791f1d1c67db2601b33739b18c9 jdk-9+99 d45bcd374f6057851e3c2dcd45607cd362afadfa jdk-9+100 +d3e834ff74e724a2b92a558e18e8cbf81c6dbc59 jdk-9+101 From 2be12511cce3d437d4924ae131aceae12c61c745 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:18 -0800 Subject: [PATCH 082/109] Added tag jdk-9+101 for changeset d391c2d25bea --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 4f84f88fb74..5450b82df39 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -346,3 +346,4 @@ b55cebc47555293cf9c2aefb3bf63c56e847ab19 jdk-9+96 67c84077edc3db6b24998b35970b37c01aae985e jdk-9+98 97b31ca0dd77483cf20ff99a033a455673639578 jdk-9+99 d0a97e57d2336238edf6a4cd60aafe67deb7258d jdk-9+100 +3e99318616da903e0dc8f07f9f9203dc1bd49921 jdk-9+101 From 3561ae517bd2d5707574b4465a79e4fac96ac1a5 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:19 -0800 Subject: [PATCH 083/109] Added tag jdk-9+101 for changeset 3248b89d1921 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 9608d22d83d..20eb3f6d94f 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -343,3 +343,4 @@ fdd84b2265ddce7f50e084b7c8635189bba6f012 jdk-9+97 f86ee68d1107dad41a27efc34306e0e56244a12e jdk-9+98 e1a789be1535741274c9779f4d4ca3495196b5c3 jdk-9+99 3d452840f48299a36842760d17c0c8402f0e1266 jdk-9+100 +5e8370fb3ed925335164afe340d1e54beab2d4d5 jdk-9+101 From 793a32922d28d43524a16c499e15523c3225afd9 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:24 -0800 Subject: [PATCH 084/109] Added tag jdk-9+101 for changeset 16043fc1d90b --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 0d8509b1d1f..f116222c244 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -343,3 +343,4 @@ ae8cdc734bab4f19ef8babd2434dcf024672ad38 jdk-9+97 345520da2ec17100cb512a53d541a307a195305e jdk-9+98 cb73b474703e2de266542b505cffd658bcc052da jdk-9+99 51136404ee5e6cd5868b60d66ebd55a02170b508 jdk-9+100 +3b3bea483542bc08278af529fb25f2e5930da945 jdk-9+101 From d204070d50c6ff68bf04331bc6c6d6d5b3e7e53c Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 14 Jan 2016 08:08:25 -0800 Subject: [PATCH 085/109] Added tag jdk-9+101 for changeset 0a5536ef0eec --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index a50648283a7..b4dc358f38d 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -334,3 +334,4 @@ d52c09d5d98a81ee6102a25f662ec4b9ae614163 jdk-9+96 68a36216f70c0de4c7e36f8978995934fc72ec03 jdk-9+98 74ddd1339c57cf2c2a13e34e1760006c2e54d1fc jdk-9+99 da397aea8adad7e6f743b60bfe0c415fc8508df5 jdk-9+100 +1916a2c680d8c33b59943dbb6dc2dd2000ec821a jdk-9+101 From f01220d47bac8a184d15fc87934a978840ad5b2c Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 14 Jan 2016 19:07:33 +0000 Subject: [PATCH 086/109] 7067728: Remove stopThread RuntimePermission from the default java.policy Reviewed-by: alanb, mchung, mullan --- jdk/src/java.base/share/conf/security/java.policy | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/jdk/src/java.base/share/conf/security/java.policy b/jdk/src/java.base/share/conf/security/java.policy index b32e8cdfd7c..8ea368707a2 100644 --- a/jdk/src/java.base/share/conf/security/java.policy +++ b/jdk/src/java.base/share/conf/security/java.policy @@ -98,17 +98,6 @@ grant codeBase "jrt:/java.activation" { // default permissions granted to all domains grant { - // Allows any thread to stop itself using the java.lang.Thread.stop() - // method that takes no argument. - // Note that this permission is granted by default only to remain - // backwards compatible. - // It is strongly recommended that you either remove this permission - // from this policy file or further restrict it to code sources - // that you specify, because Thread.stop() is potentially unsafe. - // See the API specification of java.lang.Thread.stop() for more - // information. - permission java.lang.RuntimePermission "stopThread"; - // allows anyone to listen on dynamic ports permission java.net.SocketPermission "localhost:0", "listen"; From e5b7cbe7d205926c291be28cba0db067e1db9423 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Fri, 15 Jan 2016 14:33:11 +0900 Subject: [PATCH 087/109] 8026766: Add toString() to j.u.Locale.LanguageRange Reviewed-by: okutsu --- .../share/classes/java/util/Locale.java | 12 +++++ jdk/test/java/util/Locale/Bug8026766.java | 45 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 jdk/test/java/util/Locale/Bug8026766.java diff --git a/jdk/src/java.base/share/classes/java/util/Locale.java b/jdk/src/java.base/share/classes/java/util/Locale.java index 25697ca0c9d..2d121e2e7ef 100644 --- a/jdk/src/java.base/share/classes/java/util/Locale.java +++ b/jdk/src/java.base/share/classes/java/util/Locale.java @@ -3144,6 +3144,18 @@ public final class Locale implements Cloneable, Serializable { && range.equals(other.range) && weight == other.weight; } + + /** + * Returns an informative string representation of this {@code LanguageRange} + * object, consisting of language range and weight if the range is + * weighted and the weight is less than the max weight. + * + * @return a string representation of this {@code LanguageRange} object. + */ + @Override + public String toString() { + return (weight == MAX_WEIGHT) ? range : range + ";q=" + weight; + } } /** diff --git a/jdk/test/java/util/Locale/Bug8026766.java b/jdk/test/java/util/Locale/Bug8026766.java new file mode 100644 index 00000000000..630737fdf99 --- /dev/null +++ b/jdk/test/java/util/Locale/Bug8026766.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8026766 + * @summary Confirm that LanguageRange.toString() returns an expected result. + * @run main Bug8026766 + */ + +import java.util.Locale.LanguageRange; + +public class Bug8026766 { + + public static void main(String[] args) { + LanguageRange lr1 = new LanguageRange("ja", 1.0); + LanguageRange lr2 = new LanguageRange("fr", 0.0); + + if (!lr1.toString().equals("ja") || + !lr2.toString().equals("fr;q=0.0")) { + throw new RuntimeException("LanguageRange.toString() returned an unexpected result."); + } + } + +} From 9d40f3ec9bdab178fe32e9d17ccda1c792fd43b2 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Fri, 15 Jan 2016 11:49:36 +0300 Subject: [PATCH 088/109] 8146967: [TEST_BUG] javax/security/auth/SubjectDomainCombiner/Optimize.java should use 4-args ProtectionDomain constructor Reviewed-by: mullan, valeriep --- .../security/auth/SubjectDomainCombiner/Optimize.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jdk/test/javax/security/auth/SubjectDomainCombiner/Optimize.java b/jdk/test/javax/security/auth/SubjectDomainCombiner/Optimize.java index 99ec943caaf..df5adef42a6 100644 --- a/jdk/test/javax/security/auth/SubjectDomainCombiner/Optimize.java +++ b/jdk/test/javax/security/auth/SubjectDomainCombiner/Optimize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -37,13 +37,16 @@ public class Optimize { ProtectionDomain pd1 = new ProtectionDomain( new CodeSource(null, (java.security.cert.Certificate[]) null), - new Permissions()); + new Permissions(), + null, null); ProtectionDomain pd2 = new ProtectionDomain( new CodeSource(null, (java.security.cert.Certificate[]) null), - new Permissions()); + new Permissions(), + null, null); ProtectionDomain pd3 = new ProtectionDomain( new CodeSource(null, (java.security.cert.Certificate[]) null), - new Permissions()); + new Permissions(), + null, null); ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2}; ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2}; From 5df533dc6ddf06b694835a89ef36228cccd36954 Mon Sep 17 00:00:00 2001 From: Huaming Li Date: Fri, 15 Jan 2016 10:58:09 +0000 Subject: [PATCH 089/109] 8143100: (sc) java/nio/channels/ServerSocketChannel/Basic.java fails intermittently Reviewed-by: alanb --- jdk/test/java/nio/channels/ServerSocketChannel/Basic.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/nio/channels/ServerSocketChannel/Basic.java b/jdk/test/java/nio/channels/ServerSocketChannel/Basic.java index be30778759f..d821d28a89d 100644 --- a/jdk/test/java/nio/channels/ServerSocketChannel/Basic.java +++ b/jdk/test/java/nio/channels/ServerSocketChannel/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,7 @@ */ /* @test + * @bug 4286936 8143100 * @summary Unit test for server-socket channels * @library .. */ @@ -130,7 +131,7 @@ public class Basic { Client client = new Client(port, block); server.start(); client.start(); - if ((server.finish(2000) & client.finish(100)) == 0) + if ((server.finish(0) & client.finish(0)) == 0) throw new Exception("Failure"); log.println(); } From 380495673aced888c6ddf561ee90256f5da3378b Mon Sep 17 00:00:00 2001 From: Huaming Li Date: Fri, 15 Jan 2016 11:09:25 +0000 Subject: [PATCH 090/109] 8141595: (so) java/nio/channels/ServerSocketChannel/NonBlockingAccept.java fails intermittently Reviewed-by: alanb --- .../ServerSocketChannel/NonBlockingAccept.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/nio/channels/ServerSocketChannel/NonBlockingAccept.java b/jdk/test/java/nio/channels/ServerSocketChannel/NonBlockingAccept.java index 1b985e8c68a..a210402903a 100644 --- a/jdk/test/java/nio/channels/ServerSocketChannel/NonBlockingAccept.java +++ b/jdk/test/java/nio/channels/ServerSocketChannel/NonBlockingAccept.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 4801882 5046333 + * @bug 4801882 5046333 8141595 * @summary test ServerSocketAdaptor.accept on nonblocking channel * @library .. * @build TestUtil @@ -57,8 +57,17 @@ public class NonBlockingAccept { SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); sc.connect(isa); - Thread.sleep(100); - ss.accept(); + + // loop until accepted + while (true) { + try { + ss.accept(); + break; + } catch (IllegalBlockingModeException ex) { + System.out.println(ex + ", sleeping ..."); + Thread.sleep(100); + } + } } From a56d95529c99a325be22e3c088b294ffb2af50f7 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 15 Jan 2016 10:30:56 -0800 Subject: [PATCH 091/109] 8147480: Mark FJExceptionTableLeak.java as intermittently failing Reviewed-by: martin, lancea, rriggs --- jdk/test/TEST.groups | 4 +++- .../java/util/concurrent/forkjoin/FJExceptionTableLeak.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index b62eeb51377..769e9ab7f7e 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -1,4 +1,4 @@ -# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ tier1 = \ :jdk_util \ -java/util/WeakHashMap/GCDuringIteration.java \ -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java + -java/util/concurrent/forkjoin/FJExceptionTableLeak.java sun/nio/cs/ISO8859x.java \ java/nio/Buffer \ com/sun/crypto/provider/Cipher \ @@ -42,6 +43,7 @@ tier2 = \ java/util/zip/TestLocalTime.java \ java/util/WeakHashMap/GCDuringIteration.java \ java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ + java/util/concurrent/forkjoin/FJExceptionTableLeak.java :jdk_io \ :jdk_nio \ -sun/nio/cs/ISO8859x.java \ diff --git a/jdk/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java b/jdk/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java index 372febce6b8..c236bd231cc 100644 --- a/jdk/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java +++ b/jdk/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java @@ -37,6 +37,7 @@ * @bug 8004138 * @summary Check if ForkJoinPool table leaks thrown exceptions. * @run main/othervm -Xmx2200k FJExceptionTableLeak + * @key intermittent */ import java.util.concurrent.ForkJoinPool; From c100bda1b54e544702cc14ca9946699c3186ed89 Mon Sep 17 00:00:00 2001 From: Svetlana Nikandrova Date: Sat, 16 Jan 2016 00:27:53 +0300 Subject: [PATCH 092/109] 8143554: UnsupportedOperationException is not thrown for unsupported options Reviewed-by: alanb --- .../share/classes/java/net/SocketImpl.java | 24 ++- .../java/net/PlainDatagramSocketImpl.java | 6 + .../classes/java/net/PlainSocketImpl.java | 6 + .../SocketOption/UnsupportedOptionsTest.java | 141 ++++++++++++++++++ 4 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java diff --git a/jdk/src/java.base/share/classes/java/net/SocketImpl.java b/jdk/src/java.base/share/classes/java/net/SocketImpl.java index 600c68457af..b4b9c1900c7 100644 --- a/jdk/src/java.base/share/classes/java/net/SocketImpl.java +++ b/jdk/src/java.base/share/classes/java/net/SocketImpl.java @@ -376,19 +376,23 @@ public abstract class SocketImpl implements SocketOptions { * @since 1.9 */ protected void setOption(SocketOption name, T value) throws IOException { - if (name == StandardSocketOptions.SO_KEEPALIVE) { + if (name == StandardSocketOptions.SO_KEEPALIVE && + (getSocket() != null)) { setOption(SocketOptions.SO_KEEPALIVE, value); - } else if (name == StandardSocketOptions.SO_SNDBUF) { + } else if (name == StandardSocketOptions.SO_SNDBUF && + (getSocket() != null)) { setOption(SocketOptions.SO_SNDBUF, value); } else if (name == StandardSocketOptions.SO_RCVBUF) { setOption(SocketOptions.SO_RCVBUF, value); } else if (name == StandardSocketOptions.SO_REUSEADDR) { setOption(SocketOptions.SO_REUSEADDR, value); - } else if (name == StandardSocketOptions.SO_LINGER) { + } else if (name == StandardSocketOptions.SO_LINGER && + (getSocket() != null)) { setOption(SocketOptions.SO_LINGER, value); } else if (name == StandardSocketOptions.IP_TOS) { setOption(SocketOptions.IP_TOS, value); - } else if (name == StandardSocketOptions.TCP_NODELAY) { + } else if (name == StandardSocketOptions.TCP_NODELAY && + (getSocket() != null)) { setOption(SocketOptions.TCP_NODELAY, value); } else { throw new UnsupportedOperationException("unsupported option"); @@ -412,19 +416,23 @@ public abstract class SocketImpl implements SocketOptions { */ @SuppressWarnings("unchecked") protected T getOption(SocketOption name) throws IOException { - if (name == StandardSocketOptions.SO_KEEPALIVE) { + if (name == StandardSocketOptions.SO_KEEPALIVE && + (getSocket() != null)) { return (T)getOption(SocketOptions.SO_KEEPALIVE); - } else if (name == StandardSocketOptions.SO_SNDBUF) { + } else if (name == StandardSocketOptions.SO_SNDBUF && + (getSocket() != null)) { return (T)getOption(SocketOptions.SO_SNDBUF); } else if (name == StandardSocketOptions.SO_RCVBUF) { return (T)getOption(SocketOptions.SO_RCVBUF); } else if (name == StandardSocketOptions.SO_REUSEADDR) { return (T)getOption(SocketOptions.SO_REUSEADDR); - } else if (name == StandardSocketOptions.SO_LINGER) { + } else if (name == StandardSocketOptions.SO_LINGER && + (getSocket() != null)) { return (T)getOption(SocketOptions.SO_LINGER); } else if (name == StandardSocketOptions.IP_TOS) { return (T)getOption(SocketOptions.IP_TOS); - } else if (name == StandardSocketOptions.TCP_NODELAY) { + } else if (name == StandardSocketOptions.TCP_NODELAY && + (getSocket() != null)) { return (T)getOption(SocketOptions.TCP_NODELAY); } else { throw new UnsupportedOperationException("unsupported option"); diff --git a/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java b/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java index c8885841ada..31715d40c82 100644 --- a/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java +++ b/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java @@ -47,6 +47,9 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { super.setOption(name, value); } else { + if (!flowSupported()) { + throw new UnsupportedOperationException("unsupported option"); + } if (isClosed()) { throw new SocketException("Socket closed"); } @@ -61,6 +64,9 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { return super.getOption(name); } + if (!flowSupported()) { + throw new UnsupportedOperationException("unsupported option"); + } if (isClosed()) { throw new SocketException("Socket closed"); } diff --git a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java index d07c90da5af..272130bd6b9 100644 --- a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java +++ b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java @@ -61,6 +61,9 @@ class PlainSocketImpl extends AbstractPlainSocketImpl if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { super.setOption(name, value); } else { + if (getSocket() == null || !flowSupported()) { + throw new UnsupportedOperationException("unsupported option"); + } if (isClosedOrPending()) { throw new SocketException("Socket closed"); } @@ -75,6 +78,9 @@ class PlainSocketImpl extends AbstractPlainSocketImpl if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { return super.getOption(name); } + if (getSocket() == null || !flowSupported()) { + throw new UnsupportedOperationException("unsupported option"); + } if (isClosedOrPending()) { throw new SocketException("Socket closed"); } diff --git a/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java b/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java new file mode 100644 index 00000000000..074f7644b9d --- /dev/null +++ b/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.net.ExtendedSocketOptions; + +import java.io.IOException; +import java.net.*; + +/* + * @test + * @bug 8143554 + * @run main UnsupportedOptionsTest + * @summary Test checks that UnsupportedOperationException for unsupported + * SOCKET_OPTIONS is thrown by both getOption() and setOption() methods. + */ +public class UnsupportedOptionsTest { + + private static final SocketOption[] SOCKET_OPTIONS = { + StandardSocketOptions.IP_MULTICAST_IF, + StandardSocketOptions.IP_MULTICAST_LOOP, + StandardSocketOptions.IP_MULTICAST_TTL, + StandardSocketOptions.IP_TOS, + StandardSocketOptions.SO_BROADCAST, + StandardSocketOptions.SO_KEEPALIVE, + StandardSocketOptions.SO_LINGER, + StandardSocketOptions.SO_RCVBUF, + StandardSocketOptions.SO_REUSEADDR, + StandardSocketOptions.SO_SNDBUF, + StandardSocketOptions.TCP_NODELAY, + ExtendedSocketOptions.SO_FLOW_SLA + }; + + public static void main(String[] args) throws IOException { + Socket s = new Socket(); + ServerSocket ss = new ServerSocket(); + DatagramSocket ds = new DatagramSocket(); + MulticastSocket ms = new MulticastSocket(); + + for (SocketOption option : SOCKET_OPTIONS) { + if (!s.supportedOptions().contains(option)) { + testUnsupportedSocketOption(s, option); + } + + if (!ss.supportedOptions().contains(option)) { + testUnsupportedSocketOption(ss, option); + } + + if (!ms.supportedOptions().contains(option)) { + testUnsupportedSocketOption(ms, option); + } + + if (!ds.supportedOptions().contains(option)) { + testUnsupportedSocketOption(ds, option); + } + } + } + + /* + * Check that UnsupportedOperationException for unsupported option is + * thrown from both getOption() and setOption() methods. + */ + private static void testUnsupportedSocketOption(Object socket, + SocketOption option) { + testSet(socket, option); + testGet(socket, option); + } + + private static void testSet(Object socket, SocketOption option) { + try { + setOption(socket, option); + } catch (UnsupportedOperationException e) { + System.out.println("UnsupportedOperationException was throw " + + "as expected. Socket: " + socket + " Option: " + option); + return; + } catch (Exception e) { + throw new RuntimeException("FAIL. Unexpected exception.", e); + } + throw new RuntimeException("FAIL. UnsupportedOperationException " + + "hasn't been thrown. Socket: " + socket + " Option: " + option); + } + + private static void testGet(Object socket, SocketOption option) { + try { + getOption(socket, option); + } catch (UnsupportedOperationException e) { + System.out.println("UnsupportedOperationException was throw " + + "as expected. Socket: " + socket + " Option: " + option); + return; + } catch (Exception e) { + throw new RuntimeException("FAIL. Unexpected exception.", e); + } + throw new RuntimeException("FAIL. UnsupportedOperationException " + + "hasn't been thrown. Socket: " + socket + " Option: " + option); + } + + private static void getOption(Object socket, + SocketOption option) throws IOException { + if (socket instanceof Socket) { + ((Socket) socket).getOption(option); + } else if (socket instanceof ServerSocket) { + ((ServerSocket) socket).getOption(option); + } else if (socket instanceof DatagramSocket) { + ((DatagramSocket) socket).getOption(option); + } else { + throw new RuntimeException("Unsupported socket type"); + } + } + + private static void setOption(Object socket, + SocketOption option) throws IOException { + if (socket instanceof Socket) { + ((Socket) socket).setOption(option, null); + } else if (socket instanceof ServerSocket) { + ((ServerSocket) socket).setOption(option, null); + } else if (socket instanceof DatagramSocket) { + ((DatagramSocket) socket).setOption(option, null); + } else { + throw new RuntimeException("Unsupported socket type"); + } + } +} From 92b9b68225142018922b7f0e1ee78c7f8a48bfbf Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Sat, 16 Jan 2016 00:18:33 +0000 Subject: [PATCH 093/109] 8146669: Test SessionTimeOutTests fails intermittently Reviewed-by: mullan --- .../ssl/SSLSession/SSLCtxAccessToSessCtx.java | 32 +++++++++++++------ .../ssl/SSLSession/SessionTimeOutTests.java | 9 +++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/jdk/test/javax/net/ssl/SSLSession/SSLCtxAccessToSessCtx.java b/jdk/test/javax/net/ssl/SSLSession/SSLCtxAccessToSessCtx.java index 14ed3eab716..95b9aae3512 100644 --- a/jdk/test/javax/net/ssl/SSLSession/SSLCtxAccessToSessCtx.java +++ b/jdk/test/javax/net/ssl/SSLSession/SSLCtxAccessToSessCtx.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -35,6 +35,7 @@ import java.io.*; import java.net.*; import javax.net.ssl.*; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.security.KeyStore; public class SSLCtxAccessToSessCtx { @@ -63,7 +64,7 @@ public class SSLCtxAccessToSessCtx { /* * Is the server ready to serve? */ - volatile static boolean serverReady = false; + AtomicInteger serverReady = new AtomicInteger(1); // only one port now /* * Turn on SSL debugging? @@ -89,12 +90,13 @@ public class SSLCtxAccessToSessCtx { SSLServerSocket sslServerSocket = (SSLServerSocket) sslssf.createServerSocket(serverPort); - serverPorts[createdPorts++] = sslServerSocket.getLocalPort(); + int slot = createdPorts.getAndIncrement(); + serverPorts[slot] = sslServerSocket.getLocalPort(); /* * Signal Client, we're ready for his connect. */ - serverReady = true; + serverReady.getAndDecrement(); int read = 0; SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); InputStream sslIS = sslSocket.getInputStream(); @@ -121,7 +123,7 @@ public class SSLCtxAccessToSessCtx { /* * Wait for server to get started. */ - while (!serverReady) { + while (serverReady.get() > 0) { Thread.sleep(50); } /* @@ -151,8 +153,8 @@ public class SSLCtxAccessToSessCtx { * The remainder is just support stuff */ - volatile int serverPorts[] = new int[]{0}; - volatile int createdPorts = 0; + int serverPorts[] = new int[]{0}; // only one port at present + AtomicInteger createdPorts = new AtomicInteger(0); static SSLServerSocketFactory sslssf; static SSLSocketFactory sslsf; static SSLContext sslctx; @@ -255,14 +257,20 @@ public class SSLCtxAccessToSessCtx { */ System.err.println("Server died..."); e.printStackTrace(); - serverReady = true; + serverReady.set(0); serverException = e; } } }; serverThread.start(); } else { - doServerSide(port); + try { + doServerSide(port); + } catch (Exception e) { + serverException = e; + } finally { + serverReady.set(0); + } } } @@ -284,7 +292,11 @@ public class SSLCtxAccessToSessCtx { }; clientThread.start(); } else { - doClientSide(); + try { + doClientSide(); + } catch (Exception e) { + clientException = e; + } } } } diff --git a/jdk/test/javax/net/ssl/SSLSession/SessionTimeOutTests.java b/jdk/test/javax/net/ssl/SSLSession/SessionTimeOutTests.java index 05aa61df609..ce592fece7f 100644 --- a/jdk/test/javax/net/ssl/SSLSession/SessionTimeOutTests.java +++ b/jdk/test/javax/net/ssl/SSLSession/SessionTimeOutTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -112,7 +112,8 @@ public class SessionTimeOutTests { SSLServerSocket sslServerSocket = (SSLServerSocket) sslssf.createServerSocket(serverPort); - serverPorts[createdPorts++] = sslServerSocket.getLocalPort(); + int slot = createdPorts.getAndIncrement(); + serverPorts[slot] = sslServerSocket.getLocalPort(); /* * Signal Client, we're ready for his connect. @@ -288,8 +289,8 @@ public class SessionTimeOutTests { * The remainder is just support stuff */ - volatile int serverPorts[] = new int[PORTS]; - volatile int createdPorts = 0; + int serverPorts[] = new int[PORTS]; + AtomicInteger createdPorts = new AtomicInteger(0); static SSLServerSocketFactory sslssf; static SSLSocketFactory sslsf; static SSLContext sslctx; From 264f84a2f96b8e8a5ea528122ea973c8a910ca85 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Sat, 16 Jan 2016 13:01:44 +0100 Subject: [PATCH 094/109] 8146403: Windows build can be faster Reviewed-by: ihse --- jdk/make/CompileDemos.gmk | 3 +- jdk/make/CompileTools.gmk | 83 +++++++++++++++++++++++ jdk/make/CopySamples.gmk | 45 ++++++------ jdk/make/Import.gmk | 2 +- jdk/make/Tools.gmk | 57 ++-------------- jdk/make/copy/Copy-java.base.gmk | 20 +++--- jdk/make/gendata/GendataBreakIterator.gmk | 8 +-- jdk/make/gendata/GendataHtml32dtd.gmk | 2 +- jdk/make/gendata/GendataPolicyJars.gmk | 5 +- jdk/make/gensrc/Gensrc-jdk.charsets.gmk | 15 ++-- jdk/make/gensrc/Gensrc-jdk.jdi.gmk | 11 ++- jdk/make/gensrc/GensrcBuffer.gmk | 8 +-- jdk/make/gensrc/GensrcCharacterData.gmk | 6 +- jdk/make/gensrc/GensrcCharsetMapping.gmk | 6 +- jdk/make/gensrc/GensrcExceptions.gmk | 19 ++---- jdk/make/gensrc/GensrcIcons.gmk | 7 +- jdk/make/gensrc/GensrcLocaleData.gmk | 27 +++++--- jdk/make/gensrc/GensrcMisc.gmk | 6 +- jdk/make/gensrc/GensrcProperties.gmk | 2 +- jdk/make/gensrc/GensrcSwing.gmk | 5 +- jdk/make/gensrc/GensrcX11Wrappers.gmk | 14 ++-- jdk/make/launcher/LauncherCommon.gmk | 8 +-- jdk/make/lib/Awt2dLibraries.gmk | 3 +- jdk/make/lib/Lib-java.base.gmk | 2 +- jdk/make/lib/Lib-jdk.jdwp.agent.gmk | 2 +- jdk/make/lib/LibCommon.gmk | 4 +- 26 files changed, 201 insertions(+), 169 deletions(-) create mode 100644 jdk/make/CompileTools.gmk diff --git a/jdk/make/CompileDemos.gmk b/jdk/make/CompileDemos.gmk index 73f3edff8a0..ac2ce41de82 100644 --- a/jdk/make/CompileDemos.gmk +++ b/jdk/make/CompileDemos.gmk @@ -38,7 +38,8 @@ include TextFileProcessing.gmk include ZipArchive.gmk # Prepare the find cache. -$(eval $(call FillCacheFind, $(JDK_TOPDIR)/src)) +$(eval $(call FillCacheFind, $(wildcard $(JDK_TOPDIR)/src/demo \ + $(JDK_TOPDIR)/src/*/demo))) # Append demo goals to this variable. TARGETS = diff --git a/jdk/make/CompileTools.gmk b/jdk/make/CompileTools.gmk new file mode 100644 index 00000000000..27aaffaafdb --- /dev/null +++ b/jdk/make/CompileTools.gmk @@ -0,0 +1,83 @@ +# +# Copyright (c) 2011, 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. +# + +default: all + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk +include SetupJavaCompilers.gmk + +################################################################################ + +JIMAGE_PKGS := \ + jdk/internal/jimage \ + jdk/internal/jrtfs \ + # + +$(eval $(call SetupJavaCompilation,BUILD_INTERIM_JIMAGE, \ + SETUP := GENERATE_OLDBYTECODE, \ + SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \ + INCLUDES := $(JIMAGE_PKGS), \ + BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes)) + +TARGETS += $(BUILD_INTERIM_JIMAGE) + +# Because of the explicit INCLUDES in the compilation setup above, the service provider +# file will not be copied unless META-INF/services would also be added to the INCLUDES. +# Adding META-INF/services would include all files in that directory when only the one +# is needed, which is why this explicit copy is defined instead. +$(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \ + SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \ + DEST := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes, \ + FILES := META-INF/services/java.nio.file.spi.FileSystemProvider)) + +TARGETS += $(COPY_JIMAGE_SERVICE_PROVIDER) + +################################################################################ + +$(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \ + SETUP := GENERATE_OLDBYTECODE, \ + ADD_JAVAC_FLAGS := -Xbootclasspath/p:$(call PathList, \ + $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \ + $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes), \ + SRC := $(JDK_TOPDIR)/make/src/classes $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes, \ + BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \ + COPY := boot.modules ext.modules)) + +$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER) + +TARGETS += $(BUILD_TOOLS_JDK) + +$(eval $(call SetupCopyFiles,COPY_NIMBUS_TEMPLATES, \ + SRC := $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus, \ + DEST := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes/build/tools/generatenimbus/resources, \ + FILES := $(wildcard $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus/*.template))) + +TARGETS += $(COPY_NIMBUS_TEMPLATES) + +################################################################################ + +all: $(TARGETS) diff --git a/jdk/make/CopySamples.gmk b/jdk/make/CopySamples.gmk index be20f92fd17..09d0bf7ba44 100644 --- a/jdk/make/CopySamples.gmk +++ b/jdk/make/CopySamples.gmk @@ -28,41 +28,38 @@ default: all include $(SPEC) include MakeBase.gmk +################################################################################ + SAMPLE_TARGET_DIR := $(SUPPORT_OUTPUTDIR)/sample/image SAMPLE_SOURCE_DIR := $(JDK_TOPDIR)/src/sample/share -SAMPLE_CLOSED_SOURCE_DIR := $(JDK_TOPDIR)/src/closed/sample/share SAMPLE_SOLARIS_SOURCE_DIR := $(JDK_TOPDIR)/src/sample/solaris # Exclude the vm directory -SAMPLE_FIND_FILTER := -name vm -prune -o +$(eval $(call SetupCopyFiles, COPY_SHARE_SAMPLES, \ + SRC := $(SAMPLE_SOURCE_DIR), \ + DEST := $(SAMPLE_TARGET_DIR), \ + FILES := $(filter-out $(SAMPLE_SOURCE_DIR)/vm/%, \ + $(call CacheFind, $(SAMPLE_SOURCE_DIR))), \ +)) -SAMPLE_SOURCE := $(shell $(FIND) $(SAMPLE_SOURCE_DIR) $(SAMPLE_FIND_FILTER) -type f -print) -SAMPLE_TARGET := $(subst $(SAMPLE_SOURCE_DIR),$(SAMPLE_TARGET_DIR),$(SAMPLE_SOURCE)) - -ifndef OPENJDK -# Exclude Main.java in EbayClient dir - SAMPLE_CLOSED_SOURCE := $(shell $(FIND) $(SAMPLE_CLOSED_SOURCE_DIR) -type f -print | $(GREP) -v EbayClient/Main.java) - SAMPLE_CLOSED_TARGET := $(subst $(SAMPLE_CLOSED_SOURCE_DIR),$(SAMPLE_TARGET_DIR),$(SAMPLE_CLOSED_SOURCE)) - SAMPLE_TARGET += $(SAMPLE_CLOSED_TARGET) -endif +TARGETS += $(COPY_SHARE_SAMPLES) ifneq (, $(filter $(OPENJDK_TARGET_OS), solaris macosx)) - SAMPLE_SOLARIS_SOURCE := $(shell $(FIND) $(SAMPLE_SOLARIS_SOURCE_DIR) -type f -print) - SAMPLE_SOLARIS_TARGET := $(subst $(SAMPLE_SOLARIS_SOURCE_DIR),$(SAMPLE_TARGET_DIR),$(SAMPLE_SOLARIS_SOURCE)) - SAMPLE_TARGET += $(SAMPLE_SOLARIS_TARGET) + $(eval $(call SetupCopyFiles, COPY_SOLARIS_SAMPLES, \ + SRC := $(SAMPLE_SOLARIS_SOURCE_DIR), \ + DEST := $(SAMPLE_TARGET_DIR), \ + FILES := $(call CacheFind, $(SAMPLE_SOLARIS_SOURCE_DIR)), \ + )) + + TARGETS += $(COPY_SOLARIS_SAMPLES) endif -$(SAMPLE_TARGET_DIR)/dtrace/%: $(SAMPLE_SOLARIS_SOURCE_DIR)/dtrace/% - $(call install-file) +################################################################################ -$(SAMPLE_TARGET_DIR)/webservices/%: $(SAMPLE_CLOSED_SOURCE_DIR)/webservices/% - $(call install-file) +$(eval $(call IncludeCustomExtension, jdk, CopySamples.gmk)) -$(SAMPLE_TARGET_DIR)/%: $(SAMPLE_SOURCE_DIR)/% - $(call install-file) +################################################################################ -COPY_FILES += $(SAMPLE_TARGET) +all: $(TARGETS) -all: $(COPY_FILES) - -.PHONY: all +.PHONY: all default diff --git a/jdk/make/Import.gmk b/jdk/make/Import.gmk index d4c5654aeac..42155494fb2 100644 --- a/jdk/make/Import.gmk +++ b/jdk/make/Import.gmk @@ -48,7 +48,7 @@ endif ifneq ($(STATIC_BUILD), true) JSIG_IMPORT = jsig.* else - JSIG_IMPORT = + JSIG_IMPORT = endif HOTSPOT_BASE_IMPORT_FILES := \ diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index 7668928ff65..cd8d7e867a1 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -26,31 +26,14 @@ ifndef _TOOLS_GMK _TOOLS_GMK := 1 -default: all - -include $(SPEC) -include MakeBase.gmk include JavaCompilation.gmk -include NativeCompilation.gmk -include SetupJavaCompilers.gmk ################################################################################ - -$(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \ - SETUP := GENERATE_OLDBYTECODE, \ - ADD_JAVAC_FLAGS := -Xbootclasspath/p:$(call PathList, \ - $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \ - $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes), \ - SRC := $(JDK_TOPDIR)/make/src/classes $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes, \ - BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \ - COPY := boot.modules ext.modules)) - -$(eval $(call SetupCopyFiles,COPY_NIMBUS_TEMPLATES, \ - SRC := $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus, \ - DEST := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes/build/tools/generatenimbus/resources, \ - FILES := $(wildcard $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus/*.template))) - -BUILD_TOOLS_JDK += $(COPY_NIMBUS_TEMPLATES) +# To avoid reevaluating the compilation setup for the tools each time this file +# is included, the actual compilation is handled by CompileTools.gmk. The +# following trick is used to be able to declare a dependency on the built tools. +BUILD_TOOLS_JDK := $(call SetupJavaCompilationCompileTarget, \ + BUILD_TOOLS_JDK, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes) ################################################################################ @@ -135,34 +118,4 @@ TOOL_IMAGEBUILDER = $(JAVA_SMALL) -Xbootclasspath/p:$(BUILDTOOLS_OUTPUTDIR)/inte -cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes $(JDK_OUTPUTDIR)) \ build.tools.module.ImageBuilder -########################################################################################## - -JIMAGE_PKGS := \ - jdk/internal/jimage \ - jdk/internal/jrtfs \ - # - -$(eval $(call SetupJavaCompilation,BUILD_INTERIM_JIMAGE, \ - SETUP := GENERATE_OLDBYTECODE, \ - SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \ - INCLUDES := $(JIMAGE_PKGS), \ - BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes)) - -# Because of the explicit INCLUDES in the compilation setup above, the service provider -# file will not be copied unless META-INF/services would also be added to the INCLUDES. -# Adding META-INF/services would include all files in that directory when only the one -# is needed, which is why this explicit copy is defined instead. -$(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \ - SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \ - DEST := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes, \ - FILES := META-INF/services/java.nio.file.spi.FileSystemProvider)) - -########################################################################################## - -$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER) - -java-tools: $(BUILD_TOOLS_JDK) - -all: java-tools - endif # _TOOLS_GMK diff --git a/jdk/make/copy/Copy-java.base.gmk b/jdk/make/copy/Copy-java.base.gmk index 46687333361..ed8e42ae272 100644 --- a/jdk/make/copy/Copy-java.base.gmk +++ b/jdk/make/copy/Copy-java.base.gmk @@ -187,27 +187,31 @@ TARGETS += $(POLICY_DST) ifeq ($(CACERTS_FILE), ) CACERTS_FILE := $(JDK_TOPDIR)/src/java.base/share/conf/security/cacerts endif + CACERTS_DST := $(LIB_DST_DIR)/security/cacerts $(CACERTS_DST): $(CACERTS_FILE) + $(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%, %, $@)) $(call install-file) TARGETS += $(CACERTS_DST) ################################################################################ -$(CONF_DST_DIR)/net.properties: $(JDK_TOPDIR)/src/java.base/share/conf/net.properties - $(ECHO) $(LOG_INFO) Copying $(@F) - $(call install-file) +$(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \ + FILES := $(JDK_TOPDIR)/src/java.base/share/conf/net.properties, \ + DEST := $(CONF_DST_DIR), \ +)) -TARGETS += $(CONF_DST_DIR)/net.properties +TARGETS += $(COPY_NET_PROPERTIES) ifeq ($(OPENJDK_TARGET_OS), solaris) - $(CONF_DST_DIR)/sdp/sdp.conf.template: $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template - $(ECHO) $(LOG_INFO) Copying $(@F) - $(call install-file) + $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \ + FILES := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \ + DEST := $(CONF_DST_DIR)/sdp, \ + )) - TARGETS += $(CONF_DST_DIR)/sdp/sdp.conf.template + TARGETS += $(COPY_SDP_CONF) endif ################################################################################ diff --git a/jdk/make/gendata/GendataBreakIterator.gmk b/jdk/make/gendata/GendataBreakIterator.gmk index 38bf0e537bb..b2827da2f0f 100644 --- a/jdk/make/gendata/GendataBreakIterator.gmk +++ b/jdk/make/gendata/GendataBreakIterator.gmk @@ -68,8 +68,8 @@ BIFILES_TH := $(LD_DATA_PKG_DIR)/th/WordBreakIteratorData_th \ $(BIFILES): $(BASE_DATA_PKG_DIR)/_the.bifiles $(BASE_DATA_PKG_DIR)/_the.bifiles: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES) $(BASE_DATA_PKG_DIR)/_the.bifiles: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR) - $(ECHO) $(LOG_INFO) "Generating BreakIteratorData" - $(MKDIR) -p $(@D) + $(call LogInfo, Generating BreakIteratorData) + $(call MakeDir, $(@D)) $(RM) $(BIFILES) $(TOOL_GENERATEBREAKITERATORDATA) \ -o $(@D) \ @@ -79,8 +79,8 @@ $(BASE_DATA_PKG_DIR)/_the.bifiles: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKIT $(BIFILES_TH): $(LD_DATA_PKG_DIR)/_the.bifiles_th $(LD_DATA_PKG_DIR)/_the.bifiles_th: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES) $(LD_DATA_PKG_DIR)/_the.bifiles_th: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR) - $(ECHO) $(LOG_INFO) "Generating BreakIteratorData_th" - $(MKDIR) -p $(@D)/th + $(call LogInfo, Generating BreakIteratorData_th) + $(call MakeDir, $(@D)/th) $(RM) $(BIFILES_TH) $(TOOL_GENERATEBREAKITERATORDATA) \ -o $(@D) \ diff --git a/jdk/make/gendata/GendataHtml32dtd.gmk b/jdk/make/gendata/GendataHtml32dtd.gmk index 1adb85ad0aa..2bc0e708673 100644 --- a/jdk/make/gendata/GendataHtml32dtd.gmk +++ b/jdk/make/gendata/GendataHtml32dtd.gmk @@ -27,7 +27,7 @@ GENDATA_HTML32DTD := HTML32DTD = $(JDK_OUTPUTDIR)/modules/java.desktop/javax/swing/text/html/parser/html32.bdtd $(HTML32DTD): $(BUILD_TOOLS_JDK) - $(ECHO) "Generating HTML DTD file" + $(call LogInfo, Generating HTML DTD file) $(MKDIR) -p $(@D) $(RM) $@ ($(TOOL_DTDBUILDER) $(LOG_INFO) html32 > $@) || exit 1 diff --git a/jdk/make/gendata/GendataPolicyJars.gmk b/jdk/make/gendata/GendataPolicyJars.gmk index 82e2e424446..ffed629f011 100644 --- a/jdk/make/gendata/GendataPolicyJars.gmk +++ b/jdk/make/gendata/GendataPolicyJars.gmk @@ -87,8 +87,7 @@ $(eval $(call SetupJarArchive, BUILD_US_EXPORT_POLICY_JAR, \ $(US_EXPORT_POLICY_JAR_LIMITED): \ $(US_EXPORT_POLICY_JAR_UNLIMITED) - $(ECHO) $(LOG_INFO) \ - Copying unlimited $(patsubst $(OUTPUT_ROOT)/%,%,$@) + $(call LogInfo, Copying unlimited $(patsubst $(OUTPUT_ROOT)/%,%,$@)) $(install-file) TARGETS += $(US_EXPORT_POLICY_JAR_LIMITED) $(US_EXPORT_POLICY_JAR_UNLIMITED) @@ -99,7 +98,7 @@ ifeq ($(UNLIMITED_CRYPTO), true) else $(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_LIMITED) $(install-file) -endif +endif ifndef OPENJDK ifneq ($(UNLIMITED_CRYPTO), true) diff --git a/jdk/make/gensrc/Gensrc-jdk.charsets.gmk b/jdk/make/gensrc/Gensrc-jdk.charsets.gmk index fc6c481f523..c5f79ce54c9 100644 --- a/jdk/make/gensrc/Gensrc-jdk.charsets.gmk +++ b/jdk/make/gensrc/Gensrc-jdk.charsets.gmk @@ -46,30 +46,34 @@ $(CHARSET_DONE_CS)-extcs: $(CHARSET_DATA_DIR)/charsets \ $(wildcard $(CHARSET_DATA_DIR)/$(CHARSET_STANDARD_OS)) \ $(CHARSET_TEMPLATES) $(CHARSET_EXTENDED_JAVA_TEMPLATES) \ $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(@D) + $(call LogInfo, Generating jdk.charsets extcs) + $(call MakeDir, $(@D)) $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) \ extcs charsets $(CHARSET_STANDARD_OS) \ $(CHARSET_EXTENDED_JAVA_TEMPLATES) \ $(CHARSET_EXTENDED_JAVA_DIR) \ $(CHARSET_COPYRIGHT_HEADER) \ - $(LOG_INFO) + $(LOG_DEBUG) $(TOUCH) '$@' $(CHARSET_DONE_CS)-hkscs: $(CHARSET_COPYRIGHT_HEADER)/HKSCS.java \ $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(@D) + $(call LogInfo, Generating jdk.charsets hkscs) + $(call MakeDir, $(@D)) $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) hkscs '$<' $(TOUCH) '$@' $(CHARSET_DONE_CS)-euctw: $(CHARSET_COPYRIGHT_HEADER)/EUC_TW.java \ $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(@D) + $(call LogInfo, Generating jdk.charsets euctw) + $(call MakeDir, $(@D)) $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) euctw '$<' $(TOUCH) '$@' $(CHARSET_GENSRC_JAVA_DIR_CS)/sjis0213.dat: $(CHARSET_DATA_DIR)/sjis0213.map \ $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(@D) + $(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $@)) + $(call MakeDir, $(@D)) $(TOOL_CHARSETMAPPING) '$<' '$@' sjis0213 GENSRC_JDK_CHARSETS += \ @@ -86,4 +90,3 @@ jdk.charsets: $(GENSRC_JDK_CHARSETS) all: jdk.charsets .PHONY: all jdk.charsets - diff --git a/jdk/make/gensrc/Gensrc-jdk.jdi.gmk b/jdk/make/gensrc/Gensrc-jdk.jdi.gmk index 9fd609f5fb0..3b99359175b 100644 --- a/jdk/make/gensrc/Gensrc-jdk.jdi.gmk +++ b/jdk/make/gensrc/Gensrc-jdk.jdi.gmk @@ -40,19 +40,18 @@ $(HEADER_FILE): $(JDWP_SPEC_FILE) $(BUILD_TOOLS_JDK) # Touch the target of this rule at the end to avoid triggering false rebuilds $(JAVA_FILE): $(JDWP_SPEC_FILE) $(BUILD_TOOLS_JDK) $(HEADER_FILE) - $(MKDIR) -p $(@D) - $(MKDIR) -p $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent + $(call LogInfo, Creating JDWP.java and JDWPCommands.h from jdwp.spec) + $(call MakeDir, $(@D) $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent) $(RM) $@ $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent/JDWPCommands.h - $(ECHO) $(LOG_INFO) Creating JDWP.java and JDWPCommands.h from jdwp.spec $(TOOL_JDWPGEN) $< -jdi $@ -include \ $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent/JDWPCommands.h $(TOUCH) $@ $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html: $(JDWP_SPEC_FILE) \ $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(@D) + $(call LogInfo, Creating $(@F) from jdwp.spec) + $(call MakeDir, $(@D)) $(RM) $@ - $(ECHO) $(LOG_INFO) Creating $(@F) from jdwp.spec $(TOOL_JDWPGEN) $< -doc $@ GENSRC_JDWP := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/com/sun/tools/jdi/JDWP.java \ @@ -63,7 +62,7 @@ GENSRC_JDK_JDI += $(GENSRC_JDWP) ################################################################################ define process-provider - $(MKDIR) -p $(@D) + $(call MakeDir, $(@D)) $(CAT) $^ | $(SED) -e "s/^#\[$(OPENJDK_TARGET_OS)\]//" > $@ endef diff --git a/jdk/make/gensrc/GensrcBuffer.gmk b/jdk/make/gensrc/GensrcBuffer.gmk index 2f5d789cd60..34c67125aea 100644 --- a/jdk/make/gensrc/GensrcBuffer.gmk +++ b/jdk/make/gensrc/GensrcBuffer.gmk @@ -23,7 +23,7 @@ # questions. # -GENSRC_BUFFER := +GENSRC_BUFFER := GENSRC_BUFFER_DST := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/nio @@ -31,9 +31,9 @@ GENSRC_BUFFER_SRC := $(JDK_TOPDIR)/src/java.base/share/classes/java/nio ### -$(GENSRC_BUFFER_DST)/_the.buffer.dir: - $(ECHO) "Generating buffer classes" - $(MKDIR) -p $(@D) +$(GENSRC_BUFFER_DST)/_the.buffer.dir: + $(call LogInfo, Generating buffer classes) + $(call MakeDir, $(@D)) $(TOUCH) $@ define fixRw diff --git a/jdk/make/gensrc/GensrcCharacterData.gmk b/jdk/make/gensrc/GensrcCharacterData.gmk index b0b5eddacde..3994902edb2 100644 --- a/jdk/make/gensrc/GensrcCharacterData.gmk +++ b/jdk/make/gensrc/GensrcCharacterData.gmk @@ -35,8 +35,8 @@ UNICODEDATA = $(JDK_TOPDIR)/make/data/unicodedata define SetupCharacterData $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/$1.java: \ $(CHARACTERDATA)/$1.java.template - $(MKDIR) -p $$(@D) - $(ECHO) $(LOG_INFO) Generating $1.java + $$(call LogInfo, Generating $1.java) + $$(call MakeDir, $$(@D)) $(TOOL_GENERATECHARACTER) $2 \ -template $(CHARACTERDATA)/$1.java.template \ -spec $(UNICODEDATA)/UnicodeData.txt \ @@ -56,7 +56,7 @@ $(eval $(call SetupCharacterData,CharacterData0E, -plane 14, 11 4 1)) # Copy two Java files that need no preprocessing. $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/%.java: $(CHARACTERDATA)/%.java.template - $(ECHO) $(LOG_INFO) Generating $(@F) + $(call LogInfo, Generating $(@F)) $(call install-file) GENSRC_CHARACTERDATA += $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/CharacterDataUndefined.java \ diff --git a/jdk/make/gensrc/GensrcCharsetMapping.gmk b/jdk/make/gensrc/GensrcCharsetMapping.gmk index 0218d4a1039..c904c54de23 100644 --- a/jdk/make/gensrc/GensrcCharsetMapping.gmk +++ b/jdk/make/gensrc/GensrcCharsetMapping.gmk @@ -44,13 +44,13 @@ $(CHARSET_DONE_BASE)-stdcs: $(CHARSET_DATA_DIR)/charsets \ $(wildcard $(CHARSET_DATA_DIR)/$(CHARSET_STANDARD_OS)) \ $(CHARSET_TEMPLATES) $(CHARSET_STANDARD_JAVA_TEMPLATES) \ $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(@D) + $(call LogInfo, Generating java.base charset mapping) + $(call MakeDir, $(@D)) $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_BASE) \ stdcs charsets $(CHARSET_STANDARD_OS) \ $(CHARSET_STANDARD_JAVA_TEMPLATES) $(CHARSET_EXTSRC_DIR) \ $(CHARSET_COPYRIGHT_HEADER) \ - $(LOG_INFO) + $(LOG_DEBUG) $(TOUCH) '$@' GENSRC_JAVA_BASE += $(CHARSET_DONE_BASE)-stdcs - diff --git a/jdk/make/gensrc/GensrcExceptions.gmk b/jdk/make/gensrc/GensrcExceptions.gmk index 398a8857963..947cd019eec 100644 --- a/jdk/make/gensrc/GensrcExceptions.gmk +++ b/jdk/make/gensrc/GensrcExceptions.gmk @@ -32,21 +32,12 @@ GENSRC_EXCEPTIONS_CMD := $(JDK_TOPDIR)/make/scripts/genExceptions.sh GENSRC_EXCEPTIONS_SRC_DIRS := . charset channels -### - -$(GENSRC_EXCEPTIONS_DST)/_the.exceptions.dir: - $(ECHO) "Generating exceptions classes" - $(MKDIR) -p $(@D) - $(TOUCH) $@ - - -### - $(GENSRC_EXCEPTIONS_DST)/_the.%.marker: $(GENSRC_EXCEPTIONS_SRC)/%/exceptions \ - $(GENSRC_EXCEPTIONS_CMD) \ - $(GENSRC_EXCEPTIONS_DST)/_the.exceptions.dir - $(MKDIR) -p $(@D)/$* - SCRIPTS="$(JDK_TOPDIR)/make/scripts" NAWK="$(NAWK)" SH="$(SH)" $(SH) $(GENSRC_EXCEPTIONS_CMD) $< $(@D)/$* $(LOG_INFO) + $(GENSRC_EXCEPTIONS_CMD) + $(call LogInfo, Generating exceptions java.nio $*) + $(call MakeDir, $(@D)/$*) + SCRIPTS="$(JDK_TOPDIR)/make/scripts" NAWK="$(NAWK)" SH="$(SH)" $(SH) \ + $(GENSRC_EXCEPTIONS_CMD) $< $(@D)/$* $(LOG_DEBUG) $(TOUCH) $@ GENSRC_EXCEPTIONS += $(foreach D,$(GENSRC_EXCEPTIONS_SRC_DIRS),$(GENSRC_EXCEPTIONS_DST)/_the.$(D).marker) diff --git a/jdk/make/gensrc/GensrcIcons.gmk b/jdk/make/gensrc/GensrcIcons.gmk index 6e1b5df596f..32ab58a3137 100644 --- a/jdk/make/gensrc/GensrcIcons.gmk +++ b/jdk/make/gensrc/GensrcIcons.gmk @@ -65,8 +65,8 @@ GENSRC_AWT_ICONS_DST_NAME = AWTIcon$(2)_$(subst .,_,$(subst -,_,$(1))) ################################################################################ $(GENSRC_AWT_ICONS_TMP)/_the.icons.dir: - $(ECHO) Generating icon classes - $(MKDIR) -p $(GENSRC_AWT_ICONS_DST) + $(call LogInfo, Generating icon classes) + $(call MakeDir, $(GENSRC_AWT_ICONS_DST)) $(TOUCH) $@ ################################################################################ @@ -121,8 +121,9 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) endif $(GENSRC_OSX_ICONS): $(GENSRC_OSX_ICONS_SRC) $(BUILD_TOOLS_JDK) + $(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $@)) + $(call MakeDir, $(@D)) $(RM) $@ $@.tmp - $(MKDIR) -p $(dir $@) $(ECHO) "static unsigned char sAWTIconData[] = { " >> $@.tmp $(CAT) $< | $(TOOL_OSX_TOBIN) >> $@.tmp $(ECHO) "};" >> $@.tmp diff --git a/jdk/make/gensrc/GensrcLocaleData.gmk b/jdk/make/gensrc/GensrcLocaleData.gmk index 71b091bac8a..602a4f4752f 100644 --- a/jdk/make/gensrc/GensrcLocaleData.gmk +++ b/jdk/make/gensrc/GensrcLocaleData.gmk @@ -28,8 +28,9 @@ # into LocaleDataMetaInfo.java # First go look for all locale files -LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/java.base/share/classes \ - $(JDK_TOPDIR)/src/jdk.localedata/share/classes \ +LOCALE_FILES := $(shell $(FIND) \ + $(JDK_TOPDIR)/src/$(MODULE)/share/classes/sun/text/resources \ + $(JDK_TOPDIR)/src/$(MODULE)/share/classes/sun/util/resources \ -name "FormatData_*.java" -o -name "FormatData_*.properties" -o \ -name "CollationData_*.java" -o -name "CollationData_*.properties" -o \ -name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \ @@ -42,17 +43,21 @@ LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/java.base/share/classes \ LOCALE_RESOURCES := $(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES))))) # Include the list of resources found during the previous compile. --include $(SUPPORT_OUTPUTDIR)/gensrc/_the.locale_resources +-include $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.locale_resources MISSING_RESOURCES := $(filter-out $(LOCALE_RESOURCES), $(PREV_LOCALE_RESOURCES)) NEW_RESOURCES := $(filter-out $(PREV_LOCALE_RESOURCES), $(LOCALE_RESOURCES)) ifneq (, $(MISSING_RESOURCES)$(NEW_RESOURCES)) # There is a difference in the number of supported resources. Trigger a regeneration. - $(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java \ - $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java \ - $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/cldr/CLDRBaseLocaleDataMetaInfo.java \ - $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo_jdk_localedata.java) + ifeq ($(MODULE), java.base) + $(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java \ + $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/cldr/CLDRBaseLocaleDataMetaInfo.java) + endif + ifeq ($(MODULE), jdk.localedata) + $(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java \ + $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo_jdk_localedata.java) + endif endif # The base locales @@ -121,18 +126,18 @@ SED_NONBASEARGS += -e 's/$(HASH)AvailableLocales_Locales$(HASH)/$(sort $(ALL_NON $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java: \ $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template + $(call LogInfo, Creating sun/util/locale/provider/BaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources) $(MKDIR) -p $(@D) - $(ECHO) Creating sun/util/locale/provider/BaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources. $(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" \ - > $(SUPPORT_OUTPUTDIR)/gensrc/_the.locale_resources + > $(SUPPORT_OUTPUTDIR)/gensrc/java.base/_the.locale_resources $(SED) $(SED_BASEARGS) $< > $@ $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java: \ $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template + $(call LogInfo, Creating sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources) $(MKDIR) -p $(@D) - $(ECHO) Creating sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources. $(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" \ - > $(SUPPORT_OUTPUTDIR)/gensrc/_the.locale_resources + > $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/_the.locale_resources $(SED) $(SED_NONBASEARGS) $< > $@ GENSRC_BASELOCALEDATA := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk index 6e3cc38950d..bc70e0e01f0 100644 --- a/jdk/make/gensrc/GensrcMisc.gmk +++ b/jdk/make/gensrc/GensrcMisc.gmk @@ -50,7 +50,7 @@ GENSRC_SOR_BIN := $(BUILDTOOLS_OUTPUTDIR)/native/genSocketOptionRegistry SOR_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOR_SRC)/$(GENSRC_SOR_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') -$(eval $(call SetupNativeCompilation,BUILD_GENSRC_SOR_EXE, \ +$(eval $(call SetupNativeCompilation, BUILD_GENSRC_SOR_EXE, \ SRC := $(GENSRC_SOR_SRC), \ INCLUDE_FILES := $(GENSRC_SOR_SRC_FILE), \ TOOLCHAIN := TOOLCHAIN_BUILD, \ @@ -86,7 +86,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows) UC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_UC_SRC)/$(GENSRC_UC_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') - $(eval $(call SetupNativeCompilation,BUILD_GENSRC_UC_EXE, \ + $(eval $(call SetupNativeCompilation, BUILD_GENSRC_UC_EXE, \ SRC := $(GENSRC_UC_SRC), \ INCLUDE_FILES := $(GENSRC_UC_SRC_FILE), \ TOOLCHAIN := TOOLCHAIN_BUILD, \ @@ -124,7 +124,7 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) SOL_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOL_SRC)/$(GENSRC_SOL_SRC_FILE) | \ $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }') - $(eval $(call SetupNativeCompilation,BUILD_GENSRC_SOL_EXE, \ + $(eval $(call SetupNativeCompilation, BUILD_GENSRC_SOL_EXE, \ SRC := $(GENSRC_SOL_SRC), \ INCLUDE_FILES := $(GENSRC_SOL_SRC_FILE), \ TOOLCHAIN := TOOLCHAIN_BUILD, \ diff --git a/jdk/make/gensrc/GensrcProperties.gmk b/jdk/make/gensrc/GensrcProperties.gmk index 2cc6231175e..7293a19bbeb 100644 --- a/jdk/make/gensrc/GensrcProperties.gmk +++ b/jdk/make/gensrc/GensrcProperties.gmk @@ -75,7 +75,7 @@ define SetupCompilePropertiesBody # Convert .../src//share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties # to .../support/gensrc//com/sun/tools/javac/resources/javac_zh_CN.java - # Strip away prefix and suffix, leaving for example only: + # Strip away prefix and suffix, leaving for example only: # "/share/classes/com/sun/tools/javac/resources/javac_zh_CN" $1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \ $(SUPPORT_OUTPUTDIR)/gensrc/%, \ diff --git a/jdk/make/gensrc/GensrcSwing.gmk b/jdk/make/gensrc/GensrcSwing.gmk index 2f643d4abc2..eee0c044f2f 100644 --- a/jdk/make/gensrc/GensrcSwing.gmk +++ b/jdk/make/gensrc/GensrcSwing.gmk @@ -31,12 +31,11 @@ NIMBUS_GENSRC_DIR = $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/javax/swing/plaf/ni NIMBUS_SKIN_FILE = $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated_nimbus: $(NIMBUS_SKIN_FILE) $(BUILD_TOOLS_JDK) + $(call LogInfo, Generating Nimbus source files) $(MKDIR) -p $(@D) - $(ECHO) "Generating Nimbus source files" - $(TOOL_GENERATENIMBUS) $(LOG_INFO) \ + $(TOOL_GENERATENIMBUS) $(LOG_DEBUG) \ -skinFile $(NIMBUS_SKIN_FILE) -buildDir $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop \ -packagePrefix $(NIMBUS_PACKAGE).nimbus -lafName Nimbus - $(ECHO) $(LOG_INFO) "Finished generating Nimbus source files" $(TOUCH) $@ GENSRC_SWING_NIMBUS := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated_nimbus diff --git a/jdk/make/gensrc/GensrcX11Wrappers.gmk b/jdk/make/gensrc/GensrcX11Wrappers.gmk index b9823c36be5..e4e3bba5745 100644 --- a/jdk/make/gensrc/GensrcX11Wrappers.gmk +++ b/jdk/make/gensrc/GensrcX11Wrappers.gmk @@ -63,14 +63,14 @@ GENSRC_X11_SIZES_USED := $(addprefix $(GENSRC_X11WRAPPERS_TMP)/sizes., $(GENSRC_ # Copy only the sizes.* files that are actually needed. WrapperGenerator picks up any it finds from the # file prefix it is given so those not needed need to be hidden. $(GENSRC_X11WRAPPERS_TMP)/sizes.%: $(GENSRC_SIZER_DIR)/sizes.% - $(MKDIR) -p $(@D) + $(call MakeDir, $(@D)) $(RM) '$@' $(SORT) $< > $@ # Run the tool on the offset files copied from the source repository to generate several Java classes # used in awt. $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated.x11: $(GENSRC_X11_SIZES_USED) $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(GENSRC_X11WRAPPERS_DST) + $(call MakeDir, $(GENSRC_X11WRAPPERS_DST)) $(TOOL_WRAPPERGENERATOR) $(GENSRC_X11WRAPPERS_DST) $(GENSRC_SIZER_DIR)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizes $(TOUCH) $@ @@ -82,8 +82,8 @@ ifneq ($(COMPILE_TYPE), cross) # Generate the C code for the program that will output the offset file. $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c: $(GENSRC_SIZER_DIR)/xlibtypes.txt $(BUILD_TOOLS_JDK) - $(ECHO) "Generating X11 wrapper ($*-bit version)" - $(MKDIR) -p $(@D) + $(call LogInfo, Generating X11 wrapper ($*-bit version)) + $(call MakeDir, $(@D)) $(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $* # use -m32/-m64 only if the compiler supports it @@ -103,7 +103,7 @@ ifneq ($(COMPILE_TYPE), cross) # Compile the C code into an executable. $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c - $(MKDIR) -p $(@D) + $(call MakeDir, $(@D)) (cd $(@D) && $(CC) $(MEMORY_MODEL_FLAG) -o $@ $< \ $(X_CFLAGS) \ $(X_LIBS) \ @@ -114,9 +114,9 @@ ifneq ($(COMPILE_TYPE), cross) # Run the executable create the offset file and check that it is identical # to the offset file in the source code repository. $(GENSRC_X11WRAPPERS_TMP)/sizes.%.verification: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe - $(MKDIR) -p $(@D) + $(call LogInfo, Verifying X11 wrapper sizes) + $(call MakeDir, $(@D)) $(GENSRC_X11WRAPPERS_TMP)/sizer.$*.exe | $(SORT) > $@.tmp - $(ECHO) Verifying $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp to $(GENSRC_X11WRAPPERS_TMP)/sizes.$* $(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp $(GENSRC_X11WRAPPERS_TMP)/sizes.$* mv $@.tmp $@ diff --git a/jdk/make/launcher/LauncherCommon.gmk b/jdk/make/launcher/LauncherCommon.gmk index aeee54a2d0a..701b2a962e3 100644 --- a/jdk/make/launcher/LauncherCommon.gmk +++ b/jdk/make/launcher/LauncherCommon.gmk @@ -31,9 +31,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) ENABLE_DEBUG_SYMBOLS := false endif -# Prepare the find cache. -$(eval $(call FillCacheFind, $(JDK_TOPDIR)/src/java.base/share/native/launcher)) - ifeq ($(OPENJDK_TARGET_OS), macosx) ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN) else @@ -124,7 +121,7 @@ define SetupBuildLauncherBody $1_LDFLAGS += -exported_symbols_list \ $(SUPPORT_OUTPUTDIR)/build-static/exported.symbols $1_LIBS += \ - $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \ + $$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \ $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libdt_socket.a \ $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libjdwp.a \ $(SUPPORT_OUTPUTDIR)/native/java.base/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) \ @@ -174,8 +171,7 @@ define SetupBuildLauncherBody endif $$(eval $$(call SetupNativeCompilation, BUILD_LAUNCHER_$1, \ - SRC := $(LAUNCHER_SRC), \ - INCLUDE_FILES := main.c, \ + EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \ OPTIMIZATION := $$($1_OPTIMIZATION), \ CFLAGS := $$($1_CFLAGS) \ $(LAUNCHER_CFLAGS) \ diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 08cd4d774ab..395521c5da8 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -750,7 +750,8 @@ ifeq ($(OPENJDK_TARGET_OS), windows) $(BUILD_LIBJAWT): $(BUILD_LIBAWT) $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX): $(BUILD_LIBJAWT) - $(ECHO) Copying $(@F) + $(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%, %, $@)) + $(call MakeDir, $(@D)) $(CP) $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX) $@ TARGETS += $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX) diff --git a/jdk/make/lib/Lib-java.base.gmk b/jdk/make/lib/Lib-java.base.gmk index 0699a42dd34..345fda65908 100644 --- a/jdk/make/lib/Lib-java.base.gmk +++ b/jdk/make/lib/Lib-java.base.gmk @@ -49,7 +49,7 @@ ifeq ($(STATIC_BUILD), true) JAVA_BASE_EXPORT_SYMBOL_FILE := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/java.base.symbols $(JAVA_BASE_EXPORT_SYMBOL_FILE): $(JAVA_BASE_EXPORT_SYMBOLS_SRC) - $(ECHO) $(LOG_INFO) "Generating java.base.symbols file" + $(call LogInfo, Generating java.base.symbols file) $(CAT) $^ > $@ # The individual symbol files is generated when the respective lib is built diff --git a/jdk/make/lib/Lib-jdk.jdwp.agent.gmk b/jdk/make/lib/Lib-jdk.jdwp.agent.gmk index 14784d3796a..d64b395c163 100644 --- a/jdk/make/lib/Lib-jdk.jdwp.agent.gmk +++ b/jdk/make/lib/Lib-jdk.jdwp.agent.gmk @@ -111,7 +111,7 @@ ifeq ($(STATIC_BUILD), true) JDK_JDWP_AGENT_EXPORT_SYMBOL_FILE := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/jdk.jdwp.agent.symbols $(JDK_JDWP_AGENT_EXPORT_SYMBOL_FILE): $(JDK_JDWP_AGENT_EXPORT_SYMBOLS_SRC) - $(ECHO) $(LOG_INFO) "Generating jdk.jdwp.agent symbols file" + $(call LogInfo, Generating jdk.jdwp.agent symbols file) $(CAT) $^ > $@ # The individual symbol files is generated when the respective lib is built diff --git a/jdk/make/lib/LibCommon.gmk b/jdk/make/lib/LibCommon.gmk index 68bdcc0a414..7ca5228c8e9 100644 --- a/jdk/make/lib/LibCommon.gmk +++ b/jdk/make/lib/LibCommon.gmk @@ -23,8 +23,6 @@ # questions. # -include $(SPEC) -include MakeBase.gmk include NativeCompilation.gmk GLOBAL_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/common/version.rc @@ -87,3 +85,5 @@ ifeq ($(USE_EXTERNAL_LIBZ), true) else ZLIB_CPPFLAGS := -I$(JDK_TOPDIR)/src/java.base/share/native/libzip/zlib-1.2.8 endif + +############################################################################### From 0d980c2b94a5f72bfba86abd50776cd176bf265e Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Sat, 16 Jan 2016 10:44:40 -0800 Subject: [PATCH 095/109] 8147508: Correct fix for JDK-8147480 Reviewed-by: martin --- jdk/test/TEST.groups | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 769e9ab7f7e..fbe25e8224f 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -31,8 +31,8 @@ tier1 = \ -java/util/zip/TestLocalTime.java \ :jdk_util \ -java/util/WeakHashMap/GCDuringIteration.java \ - -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java - -java/util/concurrent/forkjoin/FJExceptionTableLeak.java + -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ + -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ sun/nio/cs/ISO8859x.java \ java/nio/Buffer \ com/sun/crypto/provider/Cipher \ @@ -43,7 +43,7 @@ tier2 = \ java/util/zip/TestLocalTime.java \ java/util/WeakHashMap/GCDuringIteration.java \ java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \ - java/util/concurrent/forkjoin/FJExceptionTableLeak.java + java/util/concurrent/forkjoin/FJExceptionTableLeak.java \ :jdk_io \ :jdk_nio \ -sun/nio/cs/ISO8859x.java \ From 9fdfd0fc8fe127ba133009ddd2b8ffcdb322b10d Mon Sep 17 00:00:00 2001 From: Huaming Li Date: Sun, 17 Jan 2016 08:43:49 +0000 Subject: [PATCH 096/109] 8146213: (so) Test java/nio/channels/ServerSocketChannel/AdaptServerSocket.java failed intermittently with Connection refused Reviewed-by: bpb, alanb --- .../AdaptServerSocket.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/jdk/test/java/nio/channels/ServerSocketChannel/AdaptServerSocket.java b/jdk/test/java/nio/channels/ServerSocketChannel/AdaptServerSocket.java index 13aeea1bba4..79391ecca99 100644 --- a/jdk/test/java/nio/channels/ServerSocketChannel/AdaptServerSocket.java +++ b/jdk/test/java/nio/channels/ServerSocketChannel/AdaptServerSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,8 +22,8 @@ */ /* @test + * @bug 4286936 8146213 * @summary Unit test for server-socket-channel adaptors - * @key intermittent */ import java.io.*; @@ -77,6 +77,9 @@ public class AdaptServerSocket { static void test(int clientDally, int timeout, boolean shouldTimeout) throws Exception { + boolean needClient = !shouldTimeout; + client = null; + clientException = null; clientStarted = false; out.println(); @@ -90,9 +93,11 @@ public class AdaptServerSocket { sso.bind(null); out.println("bound: " + ssc); out.println(" " + sso); - startClient(sso.getLocalPort(), clientDally); - while (!clientStarted) { - Thread.sleep(20); + if (needClient) { + startClient(sso.getLocalPort(), clientDally); + while (!clientStarted) { + Thread.sleep(20); + } } Socket so = null; try { @@ -115,10 +120,12 @@ public class AdaptServerSocket { out.println("server: read " + b); } } - client.interrupt(); - client.join(); - if (clientException != null) - throw clientException; + if (needClient) { + client.interrupt(); + client.join(); + if (clientException != null) + throw clientException; + } } public static void main(String[] args) throws Exception { From 6c65f7751704325742cf3dc64ace3025bcf1adca Mon Sep 17 00:00:00 2001 From: Miroslav Kos Date: Mon, 18 Jan 2016 15:21:34 +0100 Subject: [PATCH 097/109] 8146086: Publishing two webservices on same port fails with "java.net.BindException: Address already in use" Reviewed-by: chegar --- jdk/test/javax/xml/ws/publish/WSTest.java | 86 +++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 jdk/test/javax/xml/ws/publish/WSTest.java diff --git a/jdk/test/javax/xml/ws/publish/WSTest.java b/jdk/test/javax/xml/ws/publish/WSTest.java new file mode 100644 index 00000000000..539f2d4b53b --- /dev/null +++ b/jdk/test/javax/xml/ws/publish/WSTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8146086 + * @summary Publishing two webservices on same port fails with "java.net.BindException: Address already in use" + * @run main/othervm WSTest + */ +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.xml.ws.Endpoint; +import java.net.ServerSocket; + +public class WSTest { + + @WebService(targetNamespace = "test") + public static class Method1 { + @WebMethod + public String getMethod1Value() { + return "from Method1"; + } + } + + @WebService(targetNamespace = "test") + public static class Method2 { + @WebMethod + public String getMethod2Value() { + return "from Method2"; + } + } + + public static void main(String[] args) throws Exception { + + // find a free port + ServerSocket ss = new ServerSocket(0); + int port = ss.getLocalPort(); + ss.close(); + + Endpoint endPoint1 = null; + Endpoint endPoint2 = null; + try { + endPoint1 = Endpoint.publish("http://0.0.0.0:" + port + "/method1", + new Method1()); + endPoint2 = Endpoint.publish("http://0.0.0.0:" + port + "/method2", + new Method2()); + + System.out.println("Sleep 3 secs..."); + + Thread.sleep(3000); + } finally { + stop(endPoint2); + stop(endPoint1); + } + } + + private static void stop(Endpoint endPoint) { + if (endPoint == null) return; + + try { + endPoint.stop(); + } catch (Throwable ignored) { + } + } + +} From 6452a8d8e35770ff33cd2580e6e3f61b241f73db Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Tue, 19 Jan 2016 09:40:55 -0800 Subject: [PATCH 098/109] 8147629: quarantine tests failing in 2016.01.14 PIT snapshot Ignore test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java and test/tools/launcher/TooSmallStackSize.java Reviewed-by: rdurbin, amurillo --- .../com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java | 2 ++ jdk/test/tools/launcher/TooSmallStackSize.java | 1 + 2 files changed, 3 insertions(+) diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java index 9b8afea79e9..b94644d1fd1 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -24,6 +24,8 @@ /* * @test * @bug 8028994 + * @ignore 8147477 + * @ignore 8147494 * @author Staffan Larsen * @library /lib/testlibrary * @modules jdk.attach/sun.tools.attach diff --git a/jdk/test/tools/launcher/TooSmallStackSize.java b/jdk/test/tools/launcher/TooSmallStackSize.java index dac1c7f0325..9635eaee5bd 100644 --- a/jdk/test/tools/launcher/TooSmallStackSize.java +++ b/jdk/test/tools/launcher/TooSmallStackSize.java @@ -24,6 +24,7 @@ /* * @test * @bug 6762191 + * @ignore 8146751 * @summary Setting stack size to 16K causes segmentation fault * @compile TooSmallStackSize.java * @run main TooSmallStackSize From 559932b6fcb5bf07d02b2e841ef432e059914029 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 20 Jan 2016 09:54:13 +0100 Subject: [PATCH 099/109] 8145596: Enable debug symbols for all libraries Reviewed-by: erikj --- jdk/make/launcher/Launcher-java.base.gmk | 1 - .../launcher/Launcher-jdk.accessibility.gmk | 3 --- jdk/make/launcher/Launcher-jdk.pack200.gmk | 1 - jdk/make/launcher/LauncherCommon.gmk | 7 ----- jdk/make/lib/Awt2dLibraries.gmk | 26 +++++++++---------- jdk/make/lib/CoreLibraries.gmk | 21 +++++++-------- jdk/make/lib/Lib-java.instrument.gmk | 2 +- jdk/make/lib/Lib-java.management.gmk | 4 +-- jdk/make/lib/Lib-java.prefs.gmk | 2 +- jdk/make/lib/Lib-java.security.jgss.gmk | 4 +-- jdk/make/lib/Lib-java.smartcardio.gmk | 2 +- jdk/make/lib/Lib-jdk.accessibility.gmk | 6 ++--- jdk/make/lib/Lib-jdk.attach.gmk | 2 +- jdk/make/lib/Lib-jdk.crypto.ec.gmk | 2 +- jdk/make/lib/Lib-jdk.crypto.mscapi.gmk | 2 +- jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk | 2 +- jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk | 2 +- jdk/make/lib/Lib-jdk.deploy.osx.gmk | 2 +- jdk/make/lib/Lib-jdk.internal.le.gmk | 2 +- jdk/make/lib/Lib-jdk.jdi.gmk | 2 +- jdk/make/lib/Lib-jdk.jdwp.agent.gmk | 4 +-- jdk/make/lib/Lib-jdk.management.gmk | 4 +-- jdk/make/lib/Lib-jdk.pack200.gmk | 2 +- jdk/make/lib/Lib-jdk.sctp.gmk | 2 +- jdk/make/lib/Lib-jdk.security.auth.gmk | 2 +- jdk/make/lib/LibCommon.gmk | 19 -------------- jdk/make/lib/NetworkingLibraries.gmk | 2 +- jdk/make/lib/NioLibraries.gmk | 2 +- jdk/make/lib/PlatformLibraries.gmk | 2 +- jdk/make/lib/SecurityLibraries.gmk | 2 +- jdk/make/lib/SoundLibraries.gmk | 6 ++--- 31 files changed, 55 insertions(+), 87 deletions(-) diff --git a/jdk/make/launcher/Launcher-java.base.gmk b/jdk/make/launcher/Launcher-java.base.gmk index 4214de4ec22..77d241405c3 100644 --- a/jdk/make/launcher/Launcher-java.base.gmk +++ b/jdk/make/launcher/Launcher-java.base.gmk @@ -130,7 +130,6 @@ ifneq ($(BUILD_JEXEC_SRC), ) LDFLAGS := $(LDFLAGS_JDKEXE), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jexec_obj, \ OUTPUT_DIR := $(BUILD_JEXEC_DST_DIR), \ - DEBUG_SYMBOLS := true, \ PROGRAM := jexec)) TARGETS += $(BUILD_JEXEC) diff --git a/jdk/make/launcher/Launcher-jdk.accessibility.gmk b/jdk/make/launcher/Launcher-jdk.accessibility.gmk index e954e550f30..6815e6d378d 100644 --- a/jdk/make/launcher/Launcher-jdk.accessibility.gmk +++ b/jdk/make/launcher/Launcher-jdk.accessibility.gmk @@ -45,7 +45,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jabswitch, \ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \ PROGRAM := jabswitch, \ - DEBUG_SYMBOLS := true, \ VERSIONINFO_RESOURCE := $(ACCESSBRIDGE_SRC)/AccessBridgeStatusWindow.RC, \ RC_FLAGS := $(RC_FLAGS) \ -D "JDK_FNAME=jabswitch.exe" \ @@ -79,7 +78,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jaccessinspector$1, \ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \ PROGRAM := jaccessinspector$1, \ - DEBUG_SYMBOLS := true, \ VERSIONINFO_RESOURCE := $(TOPDIR)/jaccessinspector/jaccessinspectorWindow.rc, \ RC_FLAGS := $$(RC_FLAGS) \ -D "JDK_FNAME=jaccessinspector$1.exe" \ @@ -107,7 +105,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jaccesswalker$1, \ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \ PROGRAM := jaccesswalker$1, \ - DEBUG_SYMBOLS := true, \ VERSIONINFO_RESOURCE := $(TOPDIR)/jaccesswalker/jaccesswalkerWindow.rc, \ RC_FLAGS := $$(RC_FLAGS) \ -D "JDK_FNAME=jaccesswalker$1.exe" \ diff --git a/jdk/make/launcher/Launcher-jdk.pack200.gmk b/jdk/make/launcher/Launcher-jdk.pack200.gmk index 55c03865f71..818828a2929 100644 --- a/jdk/make/launcher/Launcher-jdk.pack200.gmk +++ b/jdk/make/launcher/Launcher-jdk.pack200.gmk @@ -100,7 +100,6 @@ $(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \ -D "JDK_FNAME=unpack200.exe" \ -D "JDK_INTERNAL_NAME=unpack200" \ -D "JDK_FTYPE=0x1L", \ - DEBUG_SYMBOLS := true, \ MANIFEST := $(JDK_TOPDIR)/src/jdk.pack200/windows/native/unpack200/unpack200_proto.exe.manifest, \ MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \ )) diff --git a/jdk/make/launcher/LauncherCommon.gmk b/jdk/make/launcher/LauncherCommon.gmk index 701b2a962e3..8e79d758693 100644 --- a/jdk/make/launcher/LauncherCommon.gmk +++ b/jdk/make/launcher/LauncherCommon.gmk @@ -25,12 +25,6 @@ include NativeCompilation.gmk -# SetupNativeCompilation now supports debug symbols on macosx for hotspot. -# Disable it here for the jdk binaries until we decide to enable them. -ifeq ($(OPENJDK_TARGET_OS), macosx) - ENABLE_DEBUG_SYMBOLS := false -endif - ifeq ($(OPENJDK_TARGET_OS), macosx) ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN) else @@ -200,7 +194,6 @@ define SetupBuildLauncherBody OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$1_objs, \ OUTPUT_DIR := $$($1_OUTPUT_DIR), \ PROGRAM := $1, \ - DEBUG_SYMBOLS := true, \ VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \ RC_FLAGS := $$(RC_FLAGS) \ -D "JDK_FNAME=$1$(EXE_SUFFIX)" \ diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 395521c5da8..abd7edc0021 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -69,7 +69,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBMLIB_IMAGE, \ -D "JDK_INTERNAL_NAME=mlib_image" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmlib_image, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBMLIB_IMAGE): $(call FindLib, java.base, java) @@ -134,7 +134,7 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) $(call SET_SHARED_LIBRARY_ORIGIN), \ LIBS := -ljava -ljvm -lc $(BUILD_LIBMLIB_LDLIBS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmlib_image_v, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBMLIB_IMAGE_V): $(call FindLib, java.base, java) @@ -279,7 +279,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT, \ -D "JDK_INTERNAL_NAME=awt" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBAWT): $(call FindLib, java.base, java) @@ -369,7 +369,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) -D "JDK_INTERNAL_NAME=xawt" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_xawt, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBAWT_XAWT): $(call FindLib, java.base, java) @@ -433,7 +433,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBLCMS, \ -D "JDK_INTERNAL_NAME=lcms" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/liblcms, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) TARGETS += $(BUILD_LIBLCMS) @@ -509,7 +509,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVAJPEG, \ -D "JDK_FTYPE=0x2L", \ REORDER := $(BUILD_LIBJAVAJPEG_REORDER), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjavajpeg, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBJAVAJPEG): $(call FindLib, java.base, java) @@ -578,7 +578,7 @@ ifeq ($(BUILD_HEADLESS), true) LIBS_linux := -lm $(LIBDL), \ LIBS_solaris := -lm $(LIBDL) $(LIBCXX) -lc, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT) @@ -700,7 +700,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \ -D "JDK_INTERNAL_NAME=fontmanager" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfontmanager, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT) @@ -745,7 +745,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -D "JDK_INTERNAL_NAME=jawt" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBJAWT): $(BUILD_LIBAWT) @@ -805,7 +805,7 @@ else # OPENJDK_TARGET_OS not windows LIBS_solaris := $(X_LIBS) -lXrender, \ LIBS_macosx := -framework Cocoa, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) ifndef BUILD_HEADLESS_ONLY $(BUILD_LIBJAWT): $(BUILD_LIBAWT_XAWT) @@ -927,7 +927,7 @@ ifndef BUILD_HEADLESS_ONLY -D "JDK_INTERNAL_NAME=splashscreen" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsplashscreen, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBSPLASHSCREEN) @@ -1003,7 +1003,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework OpenGL \ -framework QuartzCore -ljava, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_lwawt, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBAWT_LWAWT) @@ -1045,7 +1045,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework JavaRuntimeSupport \ -ljava -ljvm, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosxui, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBOSXUI) diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index 926ebc7ce38..5cbeb4b03f7 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -55,7 +55,7 @@ ifneq ($(OPENJDK_TARGET_OS), macosx) DISABLED_WARNINGS_microsoft := 4146 4244 4018, \ ARFLAGS := $(ARFLAGS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) else @@ -68,7 +68,7 @@ else CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \ LDFLAGS := -nostdlib -r -arch x86_64, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) BUILD_LIBFDLIBM := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) $(BUILD_LIBFDLIBM): $(BUILD_LIBFDLIBM_MAC) @@ -86,7 +86,7 @@ endif LIBVERIFY_OPTIMIZATION := HIGH ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) - ifeq ($(ENABLE_DEBUG_SYMBOLS), true) + ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBVERIFY_OPTIMIZATION := LOW endif endif @@ -110,7 +110,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBVERIFY, \ -D "JDK_FTYPE=0x2L", \ REORDER := $(BUILD_LIBVERIFY_REORDER), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libverify, \ - DEBUG_SYMBOLS := true)) +)) TARGETS += $(BUILD_LIBVERIFY) @@ -178,7 +178,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ -D "JDK_FTYPE=0x2L", \ REORDER := $(LIBJAVA_REORDER), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) TARGETS += $(BUILD_LIBJAVA) @@ -235,8 +235,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBZIP, \ -D "JDK_INTERNAL_NAME=zip" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libzip, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) - +)) $(BUILD_LIBZIP): $(BUILD_LIBJAVA) @@ -280,7 +279,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJIMAGE, \ -D "JDK_INTERNAL_NAME=jimage" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjimage, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBJIMAGE): $(BUILD_LIBJAVA) @@ -396,7 +395,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJLI, \ -D "JDK_INTERNAL_NAME=jli" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) TARGETS += $(BUILD_LIBJLI) @@ -414,7 +413,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS), \ ARFLAGS := $(ARFLAGS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBJLI_STATIC) @@ -433,7 +432,7 @@ else ifeq ($(OPENJDK_TARGET_OS), macosx) CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \ LDFLAGS := -nostdlib -r, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) ifeq ($(STATIC_BUILD), true) TARGETS += $(BUILD_LIBJLI_STATIC) diff --git a/jdk/make/lib/Lib-java.instrument.gmk b/jdk/make/lib/Lib-java.instrument.gmk index 834cdc2850d..02df76073af 100644 --- a/jdk/make/lib/Lib-java.instrument.gmk +++ b/jdk/make/lib/Lib-java.instrument.gmk @@ -84,7 +84,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT, \ -D "JDK_INTERNAL_NAME=instrument" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libinstrument, \ - DEBUG_SYMBOLS := true)) +)) ifneq (, $(findstring $(OPENJDK_TARGET_OS), macosx windows aix)) $(BUILD_LIBINSTRUMENT): $(SUPPORT_OUTPUTDIR)/native/java.base/$(LIBRARY_PREFIX)jli_static$(STATIC_LIBRARY_SUFFIX) diff --git a/jdk/make/lib/Lib-java.management.gmk b/jdk/make/lib/Lib-java.management.gmk index e2b30c8dae9..2533f786ec3 100644 --- a/jdk/make/lib/Lib-java.management.gmk +++ b/jdk/make/lib/Lib-java.management.gmk @@ -40,7 +40,7 @@ LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/java.management/share/native/include LIBMANAGEMENT_OPTIMIZATION := HIGH ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) - ifeq ($(ENABLE_DEBUG_SYMBOLS), true) + ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBMANAGEMENT_OPTIMIZATION := LOW endif endif @@ -64,7 +64,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT, \ -D "JDK_INTERNAL_NAME=management" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmanagement, \ - DEBUG_SYMBOLS := true)) +)) $(BUILD_LIBMANAGEMENT): $(call FindLib, java.base, java) diff --git a/jdk/make/lib/Lib-java.prefs.gmk b/jdk/make/lib/Lib-java.prefs.gmk index a34083510e6..4652415c0c5 100644 --- a/jdk/make/lib/Lib-java.prefs.gmk +++ b/jdk/make/lib/Lib-java.prefs.gmk @@ -55,7 +55,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBPREFS, \ -D "JDK_INTERNAL_NAME=prefs" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libprefs, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBPREFS): $(call FindLib, java.base, java) diff --git a/jdk/make/lib/Lib-java.security.jgss.gmk b/jdk/make/lib/Lib-java.security.jgss.gmk index 5d84a22a050..6f37b623288 100644 --- a/jdk/make/lib/Lib-java.security.jgss.gmk +++ b/jdk/make/lib/Lib-java.security.jgss.gmk @@ -46,7 +46,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows) LIBS := $(LIBDL), \ LIBS_solaris := -lc, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2gss, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBJ2GSS) endif @@ -92,7 +92,7 @@ ifneq ($(BUILD_CRYPTO), no) -D "JDK_INTERNAL_NAME=$(BUILD_LIBKRB5_NAME)" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libkrb5, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBKRB5) endif diff --git a/jdk/make/lib/Lib-java.smartcardio.gmk b/jdk/make/lib/Lib-java.smartcardio.gmk index a078e5f03e3..e013203d4e9 100644 --- a/jdk/make/lib/Lib-java.smartcardio.gmk +++ b/jdk/make/lib/Lib-java.smartcardio.gmk @@ -52,7 +52,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PCSC, \ -D "JDK_INTERNAL_NAME=j2pcsc" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2pcsc, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) TARGETS += $(BUILD_LIBJ2PCSC) diff --git a/jdk/make/lib/Lib-jdk.accessibility.gmk b/jdk/make/lib/Lib-jdk.accessibility.gmk index 66cee50e40b..565b76a9e8a 100644 --- a/jdk/make/lib/Lib-jdk.accessibility.gmk +++ b/jdk/make/lib/Lib-jdk.accessibility.gmk @@ -61,7 +61,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -D "JDK_INTERNAL_NAME=javaaccessbridge$1" \ -D "JDK_FTYPE=0x02L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjavaaccessbridge$1, \ - DEBUG_SYMBOLS := true) + ) $$(BUILD_JAVAACCESSBRIDGE$1): $(SUPPORT_OUTPUTDIR)/native/java.desktop/libjawt/jawt.lib @@ -91,7 +91,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -D "JDK_INTERNAL_NAME=windowsaccessbridge$1" \ -D "JDK_FTYPE=0x02L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libwindowsaccessbridge$1, \ - DEBUG_SYMBOLS := true) + ) TARGETS += $$(BUILD_WINDOWSACCESSBRIDGE$1) @@ -113,7 +113,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -D "JDK_INTERNAL_NAME=jabsysinfo" \ -D "JDK_FTYPE=0x02L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/lib/libjabsysinfo, \ - DEBUG_SYMBOLS := true) + ) TARGETS += $$(BUILD_ACCESSBRIDGESYSINFO) diff --git a/jdk/make/lib/Lib-jdk.attach.gmk b/jdk/make/lib/Lib-jdk.attach.gmk index c227414646d..552b855594a 100644 --- a/jdk/make/lib/Lib-jdk.attach.gmk +++ b/jdk/make/lib/Lib-jdk.attach.gmk @@ -56,7 +56,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH, \ LIBS_solaris := -ldoor, \ LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib psapi.lib, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libattach, \ - DEBUG_SYMBOLS := true)) +)) $(BUILD_LIBATTACH): $(call FindLib, java.base, java) diff --git a/jdk/make/lib/Lib-jdk.crypto.ec.gmk b/jdk/make/lib/Lib-jdk.crypto.ec.gmk index 6c62ba68011..fa0d1ff8893 100644 --- a/jdk/make/lib/Lib-jdk.crypto.ec.gmk +++ b/jdk/make/lib/Lib-jdk.crypto.ec.gmk @@ -68,7 +68,7 @@ ifeq ($(ENABLE_INTREE_EC), yes) -D "JDK_INTERNAL_NAME=sunec" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsunec, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBSUNEC) endif diff --git a/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk b/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk index 8a3bb4e9ccf..ea73c1c55e4 100644 --- a/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk +++ b/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk @@ -47,7 +47,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -D "JDK_INTERNAL_NAME=sunmscapi" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsunmscapi, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBSUNMSCAPI) endif diff --git a/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk b/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk index 21c19b9e5d4..c74f77960bb 100644 --- a/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk +++ b/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk @@ -51,7 +51,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PKCS11, \ -D "JDK_INTERNAL_NAME=j2pkcs11" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2pkcs11, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) TARGETS += $(BUILD_LIBJ2PKCS11) diff --git a/jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk b/jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk index c71634166b2..31c39f1bb69 100644 --- a/jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk +++ b/jdk/make/lib/Lib-jdk.crypto.ucrypto.gmk @@ -44,7 +44,7 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) LIBS := $(LIBDL), \ LIBS_solaris := -lc, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2ucrypto, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBJ2UCRYPTO): $(BUILD_LIBJAVA) diff --git a/jdk/make/lib/Lib-jdk.deploy.osx.gmk b/jdk/make/lib/Lib-jdk.deploy.osx.gmk index 08125ce9d23..881a387e14d 100644 --- a/jdk/make/lib/Lib-jdk.deploy.osx.gmk +++ b/jdk/make/lib/Lib-jdk.deploy.osx.gmk @@ -57,7 +57,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework SystemConfiguration \ $(JDKLIB_LIBS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosx, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBOSX) diff --git a/jdk/make/lib/Lib-jdk.internal.le.gmk b/jdk/make/lib/Lib-jdk.internal.le.gmk index 7aeeac3711d..cd9eaba1923 100644 --- a/jdk/make/lib/Lib-jdk.internal.le.gmk +++ b/jdk/make/lib/Lib-jdk.internal.le.gmk @@ -51,7 +51,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -D "JDK_INTERNAL_NAME=le" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/lible, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBLE) diff --git a/jdk/make/lib/Lib-jdk.jdi.gmk b/jdk/make/lib/Lib-jdk.jdi.gmk index 0c7de8144df..8bed1f9abd1 100644 --- a/jdk/make/lib/Lib-jdk.jdi.gmk +++ b/jdk/make/lib/Lib-jdk.jdi.gmk @@ -55,7 +55,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -D "JDK_INTERNAL_NAME=dt_shmem" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libdt_shmem, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBDT_SHMEM) diff --git a/jdk/make/lib/Lib-jdk.jdwp.agent.gmk b/jdk/make/lib/Lib-jdk.jdwp.agent.gmk index d64b395c163..198dc2c2433 100644 --- a/jdk/make/lib/Lib-jdk.jdwp.agent.gmk +++ b/jdk/make/lib/Lib-jdk.jdwp.agent.gmk @@ -56,7 +56,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBDT_SOCKET, \ -D "JDK_INTERNAL_NAME=dt_socket" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libdt_socket, \ - DEBUG_SYMBOLS := true)) +)) $(BUILD_LIBDT_SOCKET): $(call FindLib, java.base, java) @@ -95,7 +95,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJDWP, \ -D "JDK_INTERNAL_NAME=jdwp" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjdwp, \ - DEBUG_SYMBOLS := true)) +)) $(BUILD_LIBJDWP): $(call FindLib, java.base, java) diff --git a/jdk/make/lib/Lib-jdk.management.gmk b/jdk/make/lib/Lib-jdk.management.gmk index da9e15bd2be..7f38553c61e 100644 --- a/jdk/make/lib/Lib-jdk.management.gmk +++ b/jdk/make/lib/Lib-jdk.management.gmk @@ -48,7 +48,7 @@ endif LIBMANAGEMENT_EXT_OPTIMIZATION := HIGH ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), ) - ifeq ($(ENABLE_DEBUG_SYMBOLS), true) + ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true) LIBMANAGEMENT_EXT_OPTIMIZATION := LOW endif endif @@ -73,7 +73,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBMANAGEMENT_EXT, \ -D "JDK_INTERNAL_NAME=management_ext" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmanagement_ext, \ - DEBUG_SYMBOLS := true)) +)) $(BUILD_LIBMANAGEMENT_EXT): $(call FindLib, java.base, java) diff --git a/jdk/make/lib/Lib-jdk.pack200.gmk b/jdk/make/lib/Lib-jdk.pack200.gmk index 824fabdb343..7f942fcfb41 100644 --- a/jdk/make/lib/Lib-jdk.pack200.gmk +++ b/jdk/make/lib/Lib-jdk.pack200.gmk @@ -52,7 +52,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \ -D "JDK_FNAME=unpack.dll" \ -D "JDK_INTERNAL_NAME=unpack" \ -D "JDK_FTYPE=0x2L", \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBUNPACK): $(call FindLib, java.base, java) diff --git a/jdk/make/lib/Lib-jdk.sctp.gmk b/jdk/make/lib/Lib-jdk.sctp.gmk index 574bc0e9841..e527aa8d9c5 100644 --- a/jdk/make/lib/Lib-jdk.sctp.gmk +++ b/jdk/make/lib/Lib-jdk.sctp.gmk @@ -53,7 +53,7 @@ ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) LIBS_linux := -lpthread $(LIBDL), \ LIBS_solaris := -lsocket -lc, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsctp, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBSCTP) diff --git a/jdk/make/lib/Lib-jdk.security.auth.gmk b/jdk/make/lib/Lib-jdk.security.auth.gmk index 2b1b62b6702..e37e327266c 100644 --- a/jdk/make/lib/Lib-jdk.security.auth.gmk +++ b/jdk/make/lib/Lib-jdk.security.auth.gmk @@ -55,7 +55,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAAS, \ -D "JDK_INTERNAL_NAME=$(LIBJAAS_NAME)" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjaas, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBJAAS): $(call FindLib, java.base, java) diff --git a/jdk/make/lib/LibCommon.gmk b/jdk/make/lib/LibCommon.gmk index b341eac9326..ae47377c712 100644 --- a/jdk/make/lib/LibCommon.gmk +++ b/jdk/make/lib/LibCommon.gmk @@ -36,25 +36,6 @@ GLOBAL_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/commo # elegant solution to this. WIN_JAVA_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib -ifdef OPENJDK - # Build everything with debugging on OpenJDK - DEBUG_ALL_BINARIES := true -else - # Use this variable to set DEBUG_SYMBOLS true on windows for all libraries, but - # not on other platforms. - ifeq ($(OPENJDK_TARGET_OS), windows) - DEBUG_ALL_BINARIES := true - else - DEBUG_ALL_BINARIES := false - endif -endif - -# SetupNativeCompilation now supports debug symbols on macosx for hotspot. -# Disable it here for the jdk libraries until we decide to enable them. -ifeq ($(OPENJDK_TARGET_OS), macosx) - ENABLE_DEBUG_SYMBOLS := false -endif - ################################################################################ # Find the default set of src dirs for a native library. # Param 1 - module name diff --git a/jdk/make/lib/NetworkingLibraries.gmk b/jdk/make/lib/NetworkingLibraries.gmk index df04c8087c1..6b110f8d72e 100644 --- a/jdk/make/lib/NetworkingLibraries.gmk +++ b/jdk/make/lib/NetworkingLibraries.gmk @@ -52,7 +52,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNET, \ -D "JDK_INTERNAL_NAME=net" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libnet, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBNET): $(BUILD_LIBJAVA) diff --git a/jdk/make/lib/NioLibraries.gmk b/jdk/make/lib/NioLibraries.gmk index 6b7d305f914..de2cdea0727 100644 --- a/jdk/make/lib/NioLibraries.gmk +++ b/jdk/make/lib/NioLibraries.gmk @@ -91,7 +91,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNIO, \ -D "JDK_INTERNAL_NAME=nio" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libnio, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) TARGETS += $(BUILD_LIBNIO) diff --git a/jdk/make/lib/PlatformLibraries.gmk b/jdk/make/lib/PlatformLibraries.gmk index c8850ac27c3..85038b91714 100644 --- a/jdk/make/lib/PlatformLibraries.gmk +++ b/jdk/make/lib/PlatformLibraries.gmk @@ -54,7 +54,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework IOSurface \ -framework QuartzCore, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosxapp, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) TARGETS += $(BUILD_LIBOSXAPP) diff --git a/jdk/make/lib/SecurityLibraries.gmk b/jdk/make/lib/SecurityLibraries.gmk index 9c1c65211ca..be73c528c6b 100644 --- a/jdk/make/lib/SecurityLibraries.gmk +++ b/jdk/make/lib/SecurityLibraries.gmk @@ -54,7 +54,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -framework Security \ $(JDKLIB_LIBS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosxsecurity, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBOSXSECURITY): $(BUILD_LIBJAVA) diff --git a/jdk/make/lib/SoundLibraries.gmk b/jdk/make/lib/SoundLibraries.gmk index 9204afd36bf..f5877d3f876 100644 --- a/jdk/make/lib/SoundLibraries.gmk +++ b/jdk/make/lib/SoundLibraries.gmk @@ -138,7 +138,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND, \ -D "JDK_INTERNAL_NAME=jsound" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsound, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) +)) $(BUILD_LIBJSOUND): $(BUILD_LIBJAVA) @@ -173,7 +173,7 @@ ifneq ($(filter jsoundalsa, $(EXTRA_SOUND_JNI_LIBS)), ) $(call SET_SHARED_LIBRARY_ORIGIN), \ LIBS := $(ALSA_LIBS) -ljava -ljvm, \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsoundalsa, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBJSOUNDALSA): $(BUILD_LIBJAVA) @@ -204,7 +204,7 @@ ifneq ($(filter jsoundds, $(EXTRA_SOUND_JNI_LIBS)), ) -D "JDK_INTERNAL_NAME=jsoundds" \ -D "JDK_FTYPE=0x2L", \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsoundds, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + )) $(BUILD_LIBJSOUNDDS): $(BUILD_LIBJAVA) From 41131f7d8126b2a487ea8dece856f3a0c3436cc0 Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Wed, 20 Jan 2016 07:36:42 -0500 Subject: [PATCH 100/109] 8146803: Enhance and update Sharding API Reviewed-by: joehw --- .../classes/javax/sql/CommonDataSource.java | 20 ++- .../javax/sql/ConnectionPoolDataSource.java | 19 ++- .../share/classes/javax/sql/DataSource.java | 21 +--- .../javax/sql/PooledConnectionBuilder.java | 105 ++++++++++++++++ .../share/classes/javax/sql/XAConnection.java | 119 +----------------- .../javax/sql/XAConnectionBuilder.java | 6 +- .../share/classes/javax/sql/XADataSource.java | 20 +-- 7 files changed, 151 insertions(+), 159 deletions(-) create mode 100644 jdk/src/java.sql/share/classes/javax/sql/PooledConnectionBuilder.java diff --git a/jdk/src/java.sql/share/classes/javax/sql/CommonDataSource.java b/jdk/src/java.sql/share/classes/javax/sql/CommonDataSource.java index 9a63ddb0e1e..006560cbe38 100644 --- a/jdk/src/java.sql/share/classes/javax/sql/CommonDataSource.java +++ b/jdk/src/java.sql/share/classes/javax/sql/CommonDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,8 @@ package javax.sql; import java.sql.SQLException; -import java.io.PrintWriter; import java.sql.SQLFeatureNotSupportedException; +import java.sql.ShardingKeyBuilder; import java.util.logging.Logger; /** @@ -128,4 +128,20 @@ public interface CommonDataSource { * @since 1.7 */ public Logger getParentLogger() throws SQLFeatureNotSupportedException; + + //------------------------- JDBC 4.3 ----------------------------------- + + /** + * Creates a new {@code ShardingKeyBuilder} instance + * @implSpec + * The default implementation will throw a {@code SQLFeatureNotSupportedException}. + * @return The ShardingKeyBuilder instance that was created + * @throws SQLException if an error occurs creating the builder + * @throws SQLFeatureNotSupportedException if the driver does not support this method + * @since 9 + * @see ShardingKeyBuilder + */ + default ShardingKeyBuilder createShardingKeyBuilder() throws SQLException { + throw new SQLFeatureNotSupportedException("createShardingKeyBuilder not implemented"); + }; } diff --git a/jdk/src/java.sql/share/classes/javax/sql/ConnectionPoolDataSource.java b/jdk/src/java.sql/share/classes/javax/sql/ConnectionPoolDataSource.java index 6388735adc6..08ae5611a31 100644 --- a/jdk/src/java.sql/share/classes/javax/sql/ConnectionPoolDataSource.java +++ b/jdk/src/java.sql/share/classes/javax/sql/ConnectionPoolDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package javax.sql; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; /** @@ -70,4 +71,20 @@ public interface ConnectionPoolDataSource extends CommonDataSource { */ PooledConnection getPooledConnection(String user, String password) throws SQLException; + + //------------------------- JDBC 4.3 ----------------------------------- + + /** + * Creates a new {@code PooledConnectionBuilder} instance + * @implSpec + * The default implementation will throw a {@code SQLFeatureNotSupportedException}. + * @return The ConnectionBuilder instance that was created + * @throws SQLException if an error occurs creating the builder + * @throws SQLFeatureNotSupportedException if the driver does not support sharding + * @since 9 + * @see PooledConnectionBuilder + */ + default PooledConnectionBuilder createPooledConnectionBuilder() throws SQLException { + throw new SQLFeatureNotSupportedException("createPooledConnectionBuilder not implemented"); + }; } diff --git a/jdk/src/java.sql/share/classes/javax/sql/DataSource.java b/jdk/src/java.sql/share/classes/javax/sql/DataSource.java index f59da21c853..dbdfd4c07de 100644 --- a/jdk/src/java.sql/share/classes/javax/sql/DataSource.java +++ b/jdk/src/java.sql/share/classes/javax/sql/DataSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ import java.sql.Connection; import java.sql.ConnectionBuilder; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; -import java.sql.ShardingKeyBuilder; import java.sql.Wrapper; /** @@ -119,25 +118,11 @@ public interface DataSource extends CommonDataSource, Wrapper { * @return The ConnectionBuilder instance that was created * @throws SQLException if an error occurs creating the builder * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 - * @see createConnectionBuilder + * @since 9 + * @see ConnectionBuilder */ default ConnectionBuilder createConnectionBuilder() throws SQLException { throw new SQLFeatureNotSupportedException("createConnectionBuilder not implemented"); }; - /** - * Create a new {@code ShardingKeyBuilder} instance - * @implSpec - * The default implementation will throw a {@code SQLFeatureNotSupportedException} - * @return The ShardingKeyBuilder instance that was created - * @throws SQLException if an error occurs creating the builder - * @throws SQLFeatureNotSupportedException if the driver does not support this method - * @since 1.9 - * @see ShardingKeyBuilder - */ - default ShardingKeyBuilder createShardingKeyBuilder() - throws SQLException { - throw new SQLFeatureNotSupportedException("createShardingKeyBuilder not implemented"); - }; } diff --git a/jdk/src/java.sql/share/classes/javax/sql/PooledConnectionBuilder.java b/jdk/src/java.sql/share/classes/javax/sql/PooledConnectionBuilder.java new file mode 100644 index 00000000000..0ff0b04bce5 --- /dev/null +++ b/jdk/src/java.sql/share/classes/javax/sql/PooledConnectionBuilder.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package javax.sql; + +import java.sql.SQLException; +import java.sql.ShardingKey; + +/** + * A builder created from a {@code ConnectionPoolDataSource} object, + * used to establish a connection to the database that the + * {@code data source} object represents. The connection + * properties that were specified for the {@code data source} are used as the + * default values by the {@code PooledConnectionBuilder}. + *

The following example illustrates the use of {@code PooledConnectionBuilder} + * to create a {@link XAConnection}: + * + *

{@code
+ *     ConnectionPoolDataSource ds = new MyConnectionPoolDataSource();
+ *     ShardingKey superShardingKey = ds.createShardingKeyBuilder()
+ *                           .subkey("EASTERN_REGION", JDBCType.VARCHAR)
+ *                           .build();
+ *     ShardingKey shardingKey = ds.createShardingKeyBuilder()
+ *                           .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
+ *                           .build();
+ *     PooledConnection con = ds.createPooledConnectionBuilder()
+ *                       .user("rafa")
+ *                       .password("tennis")
+ *                       .setShardingKey(shardingKey)
+ *                       .setSuperShardingKey(superShardingKey)
+ *                       .build();
+ * }
+ * + * @since 9 + * + */ +public interface PooledConnectionBuilder { + + /** + * Specifies the username to be used when creating a connection + * + * @param username the database user on whose behalf the connection is being + * made + * @return the same {@code PooledConnectionBuilder} instance + */ + PooledConnectionBuilder user(String username); + + /** + * Specifies the password to be used when creating a connection + * + * @param password the password to use for this connection. May be {@code null} + * @return the same {@code PooledConnectionBuilder} instance + */ + PooledConnectionBuilder password(String password); + + /** + * Specifies a {@code shardingKey} to be used when creating a connection + * + * @param shardingKey the ShardingKey. May be {@code null} + * @return the same {@code PooledConnectionBuilder} instance + * @see java.sql.ShardingKey + * @see java.sql.ShardingKeyBuilder + */ + PooledConnectionBuilder shardingKey(ShardingKey shardingKey); + + /** + * Specifies a {@code superShardingKey} to be used when creating a connection + * + * @param superShardingKey the SuperShardingKey. May be {@code null} + * @return the same {@code PooledConnectionBuilder} instance + * @see java.sql.ShardingKey + * @see java.sql.ShardingKeyBuilder + */ + PooledConnectionBuilder superShardingKey(ShardingKey superShardingKey); + + /** + * Returns an instance of the object defined by this builder. + * + * @return The built object + * @throws java.sql.SQLException If an error occurs building the object + */ + PooledConnection build() throws SQLException; + +} diff --git a/jdk/src/java.sql/share/classes/javax/sql/XAConnection.java b/jdk/src/java.sql/share/classes/javax/sql/XAConnection.java index a72eff76346..76c1894c219 100644 --- a/jdk/src/java.sql/share/classes/javax/sql/XAConnection.java +++ b/jdk/src/java.sql/share/classes/javax/sql/XAConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,121 +52,4 @@ public interface XAConnection extends PooledConnection { * @since 1.4 */ javax.transaction.xa.XAResource getXAResource() throws SQLException; - - // JDBC 4.3 - - /** - * Sets and validates the sharding keys for this connection. - * - * @implSpec The default implementation will throw a - * {@code SQLFeatureNotSupportedException}. - * - * @apiNote This method validates that the sharding keys are valid for the - * {@code Connection}. The timeout value indicates how long the driver - * should wait for the {@code Connection} to verify that the sharding key is - * valid before {@code setShardingKeyIfValid} returns false. - * @param shardingKey the sharding key to be validated against this - * connection - * @param superShardingKey the super sharding key to be validated against - * this connection. The super sharding key may be {@code null}. - * @param timeout time in seconds before which the validation process is - * expected to be completed, otherwise the validation process is aborted. A - * value of 0 indicates the validation process will not time out. - * @return true if the connection is valid and the sharding keys are valid - * and set on this connection; false if the sharding keys are not valid or - * the timeout period expires before the operation completes. - * @throws SQLException if an error occurs while performing this validation; - * the {@code shardingkey} is {@code null}; a {@code superSharedingKey} is specified - * without a {@code shardingKey}; this method is called on a closed - * {@code connection}; or the {@code timeout} value is less than 0. - * @throws SQLFeatureNotSupportedException if the driver does not support - * sharding - * @since 1.9 - * @see ShardingKey - * @see ShardingKeyBuilder - */ - default boolean setShardingKeyIfValid(ShardingKey shardingKey, - ShardingKey superShardingKey, int timeout) - throws SQLException { - throw new SQLFeatureNotSupportedException("setShardingKeyIfValid not implemented"); - } - - /** - * Sets and validates the sharding key for this connection. - * @implSpec - * The default implementation will throw a - * {@code SQLFeatureNotSupportedException}. - * @apiNote - * This method validates that the sharding key is valid for the - * {@code Connection}. The timeout value indicates how long the driver - * should wait for the {@code Connection} to verify that the sharding key - * is valid before {@code setShardingKeyIfValid} returns false. - * @param shardingKey the sharding key to be validated against this connection - * @param timeout time in seconds before which the validation process is expected to - * be completed,else the validation process is aborted. A value of 0 indicates - * the validation process will not time out. - * @return true if the connection is valid and the sharding key is valid to be - * set on this connection; false if the sharding key is not valid or - * the timeout period expires before the operation completes. - * @throws SQLException if there is an error while performing this validation; - * this method is called on a closed {@code connection}; the {@code shardingkey} - * is {@code null}; or the {@code timeout} value is less than 0. - * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 - * @see ShardingKey - * @see ShardingKeyBuilder - */ - default boolean setShardingKeyIfValid(ShardingKey shardingKey, int timeout) - throws SQLException { - throw new SQLFeatureNotSupportedException("setShardingKeyIfValid not implemented"); - } - - /** - * Specifies a shardingKey and superShardingKey to use with this Connection - * @implSpec - * The default implementation will throw a - * {@code SQLFeatureNotSupportedException}. - * @apiNote - * This method sets the specified sharding keys but does not require a - * round trip to the database to validate that the sharding keys are valid - * for the {@code Connection}. - * @param shardingKey the sharding key to set on this connection. - * @param superShardingKey the super sharding key to set on this connection. - * The super sharding key may be {@code null} - * @throws SQLException if an error occurs setting the sharding keys; - * this method is called on a closed {@code connection}; - * the {@code shardingkey} is {@code null}; or - * a {@code superSharedingKey} is specified without a {@code shardingKey} - * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 - * @see ShardingKey - * @see ShardingKeyBuilder - */ - default void setShardingKey(ShardingKey shardingKey, ShardingKey superShardingKey) - throws SQLException { - throw new SQLFeatureNotSupportedException("setShardingKey not implemented"); - } - - /** - * Specifies a shardingKey to use with this Connection - * @implSpec - * The default implementation will throw a - * {@code SQLFeatureNotSupportedException}. - * @apiNote - * This method sets the specified sharding key but does not require a - * round trip to the database to validate that the sharding key is valid - * for the {@code Connection}. - * @param shardingKey the sharding key to set on this connection. - * @throws SQLException if an error occurs setting the sharding key; - * this method is called on a closed {@code connection}; or the - * {@code shardkingKey} is {@code null} - * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 - * @see ShardingKey - * @see ShardingKeyBuilder - */ - default void setShardingKey(ShardingKey shardingKey) - throws SQLException { - throw new SQLFeatureNotSupportedException("setShardingKey not implemented"); - } } diff --git a/jdk/src/java.sql/share/classes/javax/sql/XAConnectionBuilder.java b/jdk/src/java.sql/share/classes/javax/sql/XAConnectionBuilder.java index 865172a15e5..2e3d91cbe53 100644 --- a/jdk/src/java.sql/share/classes/javax/sql/XAConnectionBuilder.java +++ b/jdk/src/java.sql/share/classes/javax/sql/XAConnectionBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import java.sql.ShardingKey; * to create a {@link XAConnection}: * *
{@code
- *     DataSource ds = new MyDataSource();
+ *     XADataSource ds = new MyXADataSource();
  *     ShardingKey superShardingKey = ds.createShardingKeyBuilder()
  *                           .subkey("EASTERN_REGION", JDBCType.VARCHAR)
  *                           .build();
@@ -52,7 +52,7 @@ import java.sql.ShardingKey;
  *                       .build();
  * }
* - * @since 1.9 + * @since 9 * */ public interface XAConnectionBuilder { diff --git a/jdk/src/java.sql/share/classes/javax/sql/XADataSource.java b/jdk/src/java.sql/share/classes/javax/sql/XADataSource.java index 221dbe41339..83656b205c8 100644 --- a/jdk/src/java.sql/share/classes/javax/sql/XADataSource.java +++ b/jdk/src/java.sql/share/classes/javax/sql/XADataSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,28 +87,14 @@ public interface XADataSource extends CommonDataSource { * Creates a new {@code XAConnectionBuilder} instance * @implSpec * The default implementation will throw a {@code SQLFeatureNotSupportedException}. - * @return The ConnectionBuilder instance that was created + * @return The XAConnectionBuilder instance that was created * @throws SQLException if an error occurs creating the builder * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 + * @since 9 * @see XAConnectionBuilder */ default XAConnectionBuilder createXAConnectionBuilder() throws SQLException { throw new SQLFeatureNotSupportedException("createXAConnectionBuilder not implemented"); }; - /** - * Creates a new {@code ShardingKeyBuilder} instance - * @implSpec - * The default implementation will throw a {@code SQLFeatureNotSupportedException}. - * @return The ShardingKeyBuilder instance that was created - * @throws SQLException if an error occurs creating the builder - * @throws SQLFeatureNotSupportedException if the driver does not support this method - * @since 1.9 - * @see ShardingKeyBuilder - */ - default ShardingKeyBuilder createShardingKeyBuilder() - throws SQLException { - throw new SQLFeatureNotSupportedException("createShardingKeyBuilder not implemented"); - }; } From 0ec48f2c8b5a14bb0aaf3b48bc4c2e71379d45d6 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 20 Jan 2016 11:33:28 -0500 Subject: [PATCH 101/109] 8145459: Cleaner - use Reference.reachabilityFence Reviewed-by: psandoz, mchung, chegar --- .../share/classes/jdk/internal/ref/PhantomCleanable.java | 7 ++++--- .../share/classes/jdk/internal/ref/SoftCleanable.java | 7 ++++--- .../share/classes/jdk/internal/ref/WeakCleanable.java | 8 +++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java b/jdk/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java index 7e177b1e4f4..bbcf99483c1 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java +++ b/jdk/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java @@ -26,6 +26,7 @@ package jdk.internal.ref; import java.lang.ref.Cleaner; +import java.lang.ref.Reference; import java.lang.ref.PhantomReference; import java.util.Objects; @@ -66,9 +67,9 @@ public abstract class PhantomCleanable extends PhantomReference this.list = CleanerImpl.getCleanerImpl(cleaner).phantomCleanableList; insert(); - // TODO: Replace getClass() with ReachabilityFence when it is available - cleaner.getClass(); - referent.getClass(); + // Ensure referent and cleaner remain accessible + Reference.reachabilityFence(referent); + Reference.reachabilityFence(cleaner); } /** diff --git a/jdk/src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java b/jdk/src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java index 45ddf85863b..5463720d561 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java +++ b/jdk/src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java @@ -26,6 +26,7 @@ package jdk.internal.ref; import java.lang.ref.Cleaner; +import java.lang.ref.Reference; import java.lang.ref.SoftReference; import java.util.Objects; @@ -66,9 +67,9 @@ public abstract class SoftCleanable extends SoftReference list = CleanerImpl.getCleanerImpl(cleaner).softCleanableList; insert(); - // TODO: Replace getClass() with ReachabilityFence when it is available - cleaner.getClass(); - referent.getClass(); + // Ensure referent and cleaner remain accessible + Reference.reachabilityFence(referent); + Reference.reachabilityFence(cleaner); } /** diff --git a/jdk/src/java.base/share/classes/jdk/internal/ref/WeakCleanable.java b/jdk/src/java.base/share/classes/jdk/internal/ref/WeakCleanable.java index 40dd22af25c..90c62cf3ce3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/ref/WeakCleanable.java +++ b/jdk/src/java.base/share/classes/jdk/internal/ref/WeakCleanable.java @@ -26,6 +26,7 @@ package jdk.internal.ref; */ import java.lang.ref.Cleaner; +import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.util.Objects; @@ -66,9 +67,10 @@ public abstract class WeakCleanable extends WeakReference list = CleanerImpl.getCleanerImpl(cleaner).weakCleanableList; insert(); - // TODO: Replace getClass() with ReachabilityFence when it is available - cleaner.getClass(); - referent.getClass(); + // Ensure referent and cleaner remain accessible + Reference.reachabilityFence(referent); + Reference.reachabilityFence(cleaner); + } /** From 298315e8f8d4d5f219df4f7d22ce8c90c5f8a9de Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Gopularam Date: Wed, 20 Jan 2016 09:21:57 -0800 Subject: [PATCH 102/109] 8133085: Avoid creating instances of security providers when possible Reviewed-by: mullan --- .../com/sun/crypto/provider/Cipher/DES/PerformanceTest.java | 5 +---- jdk/test/javax/net/ssl/TLS/TestJSSE.java | 6 +----- jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java | 5 +++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java b/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java index 7e3d860d28a..03468133ff1 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import java.security.spec.*; import java.io.*; import javax.crypto.*; import javax.crypto.spec.*; -import com.sun.crypto.provider.*; public class PerformanceTest { @@ -81,8 +80,6 @@ public class PerformanceTest { byte[] in; - SunJCE jce = new SunJCE(); - Security.addProvider(jce); col = new StringBuffer(); printHeadings(); diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSE.java b/jdk/test/javax/net/ssl/TLS/TestJSSE.java index b7a439f8820..d4c41480c0b 100644 --- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java +++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it under @@ -111,8 +111,6 @@ public class TestJSSE { out.println(" Testing - https://" + LOCAL_IP + ":" + testPort); out.println(" Testing - Protocol : " + testProtocols); out.println(" Testing - Cipher : " + testCipher); - Provider p = new sun.security.ec.SunEC(); - Security.insertProviderAt(p, 1); try { CipherTestUtils.main(new JSSEFactory(LOCAL_IP, testPort, testProtocols, @@ -132,8 +130,6 @@ public class TestJSSE { out.println(" Testing Protocol: " + testProtocol); out.println(" Testing Cipher: " + testCipher); out.println(" Testing Port: " + testPort); - Provider p = new sun.security.ec.SunEC(); - Security.insertProviderAt(p, 1); try { CipherTestUtils.main(new JSSEFactory(null, testPort, testProtocol, testCipher, "Server JSSE"), diff --git a/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java b/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java index 774db222eb9..302df9280e6 100644 --- a/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java +++ b/jdk/test/sun/security/pkcs11/fips/ImportKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,8 @@ public class ImportKeyStore { public static void main(String[] args) throws Exception { String nssCfg = "--name=NSS\nnssSecmodDirectory=.\n "; // "attributes(*,CKO_PRIVATE_KEY,CKK_DSA) = { CKA_NETSCAPE_DB = 0h00 }"; - Provider p = new sun.security.pkcs11.SunPKCS11(nssCfg); + Provider p = Security.getProvider("SunPKCS11"); + p.configure(nssCfg); KeyStore ks = KeyStore.getInstance("PKCS11", p); ks.load(null, "test12".toCharArray()); From 9d07dc02e18f55ac6a1a4011e5c7f98e8470b6bf Mon Sep 17 00:00:00 2001 From: Iris Clark Date: Wed, 20 Jan 2016 11:02:36 -0800 Subject: [PATCH 103/109] 8136494: Update "@since 1.9" to "@since 9" to match java.version.specification Reviewed-by: alanb, chegar, lancea, prr --- .../tools/tzdb/TzdbZoneRulesProvider.java | 2 +- .../share/classes/java/io/InputStream.java | 6 +- .../java/lang/AbstractStringBuilder.java | 4 +- .../share/classes/java/lang/Character.java | 150 +++++++++--------- .../share/classes/java/lang/Integer.java | 4 +- .../share/classes/java/lang/Long.java | 4 +- .../share/classes/java/lang/Process.java | 14 +- .../classes/java/lang/ProcessHandle.java | 4 +- .../classes/java/lang/ProcessHandleImpl.java | 4 +- .../share/classes/java/lang/StackWalker.java | 6 +- .../share/classes/java/lang/String.java | 4 +- .../java/lang/reflect/AnnotatedArrayType.java | 2 +- .../reflect/AnnotatedParameterizedType.java | 2 +- .../java/lang/reflect/AnnotatedType.java | 2 +- .../lang/reflect/AnnotatedTypeVariable.java | 2 +- .../lang/reflect/AnnotatedWildcardType.java | 2 +- .../share/classes/java/math/BigInteger.java | 8 +- .../classes/java/math/MutableBigInteger.java | 2 +- .../classes/java/net/DatagramSocket.java | 6 +- .../classes/java/net/DatagramSocketImpl.java | 4 +- .../classes/java/net/NetworkInterface.java | 6 +- .../share/classes/java/net/ServerSocket.java | 6 +- .../share/classes/java/net/Socket.java | 6 +- .../share/classes/java/net/SocketImpl.java | 4 +- .../net/spi/URLStreamHandlerProvider.java | 2 +- .../classes/java/net/spi/package-info.java | 2 +- .../classes/java/nio/MappedByteBuffer.java | 14 +- .../classes/java/nio/X-Buffer.java.template | 14 +- .../share/classes/java/security/KeyStore.java | 6 +- .../java/security/PermissionCollection.java | 2 +- .../security/cert/URICertStoreParameters.java | 2 +- .../java/security/spec/EncodedKeySpec.java | 4 +- .../security/spec/PKCS8EncodedKeySpec.java | 2 +- .../security/spec/X509EncodedKeySpec.java | 2 +- .../share/classes/java/util/Enumeration.java | 2 +- .../share/classes/java/util/Scanner.java | 6 +- .../util/concurrent/CompletableFuture.java | 26 +-- .../classes/java/util/concurrent/Flow.java | 2 +- .../java/util/concurrent/ForkJoinTask.java | 2 +- .../util/concurrent/SubmissionPublisher.java | 2 +- .../classes/java/util/regex/Matcher.java | 10 +- .../java/util/stream/DoubleStream.java | 4 +- .../classes/java/util/stream/IntStream.java | 4 +- .../classes/java/util/stream/LongStream.java | 4 +- .../classes/java/util/stream/Stream.java | 6 +- .../classes/java/util/stream/WhileOps.java | 2 +- .../share/classes/java/util/zip/CRC32C.java | 2 +- .../share/classes/java/util/zip/Checksum.java | 4 +- .../share/classes/java/util/zip/ZipEntry.java | 4 +- .../internal/HotSpotIntrinsicCandidate.java | 2 +- .../jdk/internal/logger/package-info.java | 2 +- .../classes/jdk/internal/misc/Unsafe.java | 8 +- .../provider/certpath/ResponderId.java | 4 +- .../ssl/ClientKeyExchangeService.java | 2 +- .../sun/security/util/KeyStoreDelegator.java | 2 +- .../sun/datatransfer/DataFlavorUtil.java | 2 +- .../DesktopDatatransferService.java | 2 +- .../classes/java/awt/RenderingHints.java | 10 +- .../classes/java/awt/font/NumericShaper.java | 4 +- .../image/AbstractMultiResolutionImage.java | 4 +- .../awt/image/BaseMultiResolutionImage.java | 6 +- .../java/awt/image/MultiResolutionImage.java | 6 +- .../classes/java/beans/BeanProperty.java | 2 +- .../java/beans/IndexedPropertyDescriptor.java | 2 +- .../share/classes/java/beans/JavaBean.java | 2 +- .../java/beans/PropertyDescriptor.java | 2 +- .../accessibility/AccessibilityProvider.java | 2 +- .../metadata/doc-files/tiff_metadata.html | 2 +- .../plugins/tiff/BaselineTIFFTagSet.java | 2 +- .../imageio/plugins/tiff/ExifGPSTagSet.java | 2 +- .../tiff/ExifInteroperabilityTagSet.java | 2 +- .../plugins/tiff/ExifParentTIFFTagSet.java | 2 +- .../imageio/plugins/tiff/ExifTIFFTagSet.java | 2 +- .../imageio/plugins/tiff/FaxTIFFTagSet.java | 2 +- .../imageio/plugins/tiff/GeoTIFFTagSet.java | 2 +- .../imageio/plugins/tiff/TIFFDirectory.java | 2 +- .../javax/imageio/plugins/tiff/TIFFField.java | 2 +- .../plugins/tiff/TIFFImageReadParam.java | 2 +- .../javax/imageio/plugins/tiff/TIFFTag.java | 2 +- .../imageio/plugins/tiff/TIFFTagSet.java | 2 +- .../javax/imageio/plugins/tiff/package.html | 2 +- .../share/classes/javax/swing/JComponent.java | 2 +- .../classes/javax/swing/SwingContainer.java | 2 +- .../javax/swing/text/AbstractDocument.java | 4 +- .../DesktopDatatransferServiceImpl.java | 2 +- .../swing/text/UndoableEditLockSupport.java | 2 +- .../java/util/logging/FileHandler.java | 2 +- .../classes/java/util/logging/LogManager.java | 4 +- .../classes/java/util/logging/LogRecord.java | 10 +- .../classes/java/util/logging/Logger.java | 4 +- .../util/logging/internal/package-info.java | 2 +- .../java/lang/management/ThreadInfo.java | 4 +- .../management/ConstructorParameters.java | 2 +- .../provider/certpath/ldap/JdkLDAP.java | 2 +- .../certpath/ldap/LDAPCertStoreImpl.java | 2 +- .../security/auth/kerberos/EncryptionKey.java | 2 +- .../auth/kerberos/KerberosCredMessage.java | 2 +- .../internal/ssl/Krb5KeyExchangeService.java | 2 +- .../share/classes/java/sql/Connection.java | 12 +- .../classes/java/sql/ConnectionBuilder.java | 2 +- .../classes/java/sql/DatabaseMetaData.java | 2 +- .../share/classes/java/sql/DriverManager.java | 2 +- .../share/classes/java/sql/ShardingKey.java | 2 +- .../AttachOperationFailedException.java | 2 +- .../security/ucrypto/CipherContextRef.java | 2 +- .../com/oracle/security/ucrypto/Config.java | 2 +- .../security/ucrypto/GCMParameters.java | 2 +- .../oracle/security/ucrypto/NativeCipher.java | 2 +- .../ucrypto/NativeCipherWithJavaPadding.java | 2 +- .../oracle/security/ucrypto/NativeDigest.java | 2 +- .../security/ucrypto/NativeGCMCipher.java | 2 +- .../oracle/security/ucrypto/NativeKey.java | 2 +- .../security/ucrypto/NativeRSACipher.java | 2 +- .../security/ucrypto/NativeRSAKeyFactory.java | 2 +- .../security/ucrypto/NativeRSASignature.java | 2 +- .../security/ucrypto/UcryptoException.java | 2 +- .../oracle/security/ucrypto/UcryptoMech.java | 2 +- .../security/ucrypto/UcryptoProvider.java | 2 +- .../jarsigner/ContentSignerParameters.java | 2 +- .../jdk/security/jarsigner/JarSigner.java | 4 +- .../jarsigner/JarSignerException.java | 2 +- .../classes/com/sun/management/VMOption.java | 2 +- .../com/sun/security/jgss/InquireType.java | 6 +- jdk/test/lib/testlibrary/ExtendedRobot.java | 2 +- 124 files changed, 297 insertions(+), 297 deletions(-) diff --git a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java index 4c92ee9a8af..488a1add46d 100644 --- a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java +++ b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java @@ -60,7 +60,7 @@ import java.time.zone.ZoneRulesException; * @author Stephen Colebourne * @author Michael Nascimento Santos * - * @since 1.9 + * @since 9 */ class TzdbZoneRulesProvider { diff --git a/jdk/src/java.base/share/classes/java/io/InputStream.java b/jdk/src/java.base/share/classes/java/io/InputStream.java index 67946b19b1a..c1e4a8e1d60 100644 --- a/jdk/src/java.base/share/classes/java/io/InputStream.java +++ b/jdk/src/java.base/share/classes/java/io/InputStream.java @@ -228,7 +228,7 @@ public abstract class InputStream implements Closeable { * allocated. For example, if an array larger than {@code 2GB} would * be required to store the bytes. * - * @since 1.9 + * @since 9 */ public byte[] readAllBytes() throws IOException { byte[] buf = new byte[DEFAULT_BUFFER_SIZE]; @@ -298,7 +298,7 @@ public abstract class InputStream implements Closeable { * @throws IndexOutOfBoundsException If {@code off} is negative, {@code len} * is negative, or {@code len} is greater than {@code b.length - off} * - * @since 1.9 + * @since 9 */ public int readNBytes(byte[] b, int off, int len) throws IOException { Objects.requireNonNull(b); @@ -514,7 +514,7 @@ public abstract class InputStream implements Closeable { * @throws IOException if an I/O error occurs when reading or writing * @throws NullPointerException if {@code out} is {@code null} * - * @since 1.9 + * @since 9 */ public long transferTo(OutputStream out) throws IOException { Objects.requireNonNull(out, "out"); diff --git a/jdk/src/java.base/share/classes/java/lang/AbstractStringBuilder.java b/jdk/src/java.base/share/classes/java/lang/AbstractStringBuilder.java index 619b7de278a..f1691969666 100644 --- a/jdk/src/java.base/share/classes/java/lang/AbstractStringBuilder.java +++ b/jdk/src/java.base/share/classes/java/lang/AbstractStringBuilder.java @@ -1526,7 +1526,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public IntStream chars() { @@ -1543,7 +1543,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public IntStream codePoints() { diff --git a/jdk/src/java.base/share/classes/java/lang/Character.java b/jdk/src/java.base/share/classes/java/lang/Character.java index ae3d1ef6bd8..42fc39dd183 100644 --- a/jdk/src/java.base/share/classes/java/lang/Character.java +++ b/jdk/src/java.base/share/classes/java/lang/Character.java @@ -493,25 +493,25 @@ class Character implements java.io.Serializable, Comparable { /** * Weak bidirectional character type "LRI" in the Unicode specification. - * @since 1.9 + * @since 9 */ public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_ISOLATE = 19; /** * Weak bidirectional character type "RLI" in the Unicode specification. - * @since 1.9 + * @since 9 */ public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ISOLATE = 20; /** * Weak bidirectional character type "FSI" in the Unicode specification. - * @since 1.9 + * @since 9 */ public static final byte DIRECTIONALITY_FIRST_STRONG_ISOLATE = 21; /** * Weak bidirectional character type "PDI" in the Unicode specification. - * @since 1.9 + * @since 9 */ public static final byte DIRECTIONALITY_POP_DIRECTIONAL_ISOLATE = 22; @@ -2590,7 +2590,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Combining Diacritical Marks Extended" Unicode * character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS_EXTENDED = new UnicodeBlock("COMBINING_DIACRITICAL_MARKS_EXTENDED", @@ -2599,7 +2599,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Myanmar Extended-B" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock MYANMAR_EXTENDED_B = new UnicodeBlock("MYANMAR_EXTENDED_B", @@ -2608,7 +2608,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Latin Extended-E" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock LATIN_EXTENDED_E = new UnicodeBlock("LATIN_EXTENDED_E", @@ -2617,7 +2617,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Coptic Epact Numbers" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock COPTIC_EPACT_NUMBERS = new UnicodeBlock("COPTIC_EPACT_NUMBERS", @@ -2626,7 +2626,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Old Permic" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock OLD_PERMIC = new UnicodeBlock("OLD_PERMIC", @@ -2635,14 +2635,14 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Elbasan" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock ELBASAN = new UnicodeBlock("ELBASAN"); /** * Constant for the "Caucasian Albanian" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock CAUCASIAN_ALBANIAN = new UnicodeBlock("CAUCASIAN_ALBANIAN", @@ -2651,7 +2651,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Linear A" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock LINEAR_A = new UnicodeBlock("LINEAR_A", @@ -2660,21 +2660,21 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Palmyrene" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock PALMYRENE = new UnicodeBlock("PALMYRENE"); /** * Constant for the "Nabataean" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock NABATAEAN = new UnicodeBlock("NABATAEAN"); /** * Constant for the "Old North Arabian" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock OLD_NORTH_ARABIAN = new UnicodeBlock("OLD_NORTH_ARABIAN", @@ -2683,14 +2683,14 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Manichaean" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock MANICHAEAN = new UnicodeBlock("MANICHAEAN"); /** * Constant for the "Psalter Pahlavi" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock PSALTER_PAHLAVI = new UnicodeBlock("PSALTER_PAHLAVI", @@ -2699,14 +2699,14 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Mahajani" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock MAHAJANI = new UnicodeBlock("MAHAJANI"); /** * Constant for the "Sinhala Archaic Numbers" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock SINHALA_ARCHAIC_NUMBERS = new UnicodeBlock("SINHALA_ARCHAIC_NUMBERS", @@ -2715,49 +2715,49 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Khojki" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock KHOJKI = new UnicodeBlock("KHOJKI"); /** * Constant for the "Khudawadi" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock KHUDAWADI = new UnicodeBlock("KHUDAWADI"); /** * Constant for the "Grantha" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock GRANTHA = new UnicodeBlock("GRANTHA"); /** * Constant for the "Tirhuta" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock TIRHUTA = new UnicodeBlock("TIRHUTA"); /** * Constant for the "Siddham" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock SIDDHAM = new UnicodeBlock("SIDDHAM"); /** * Constant for the "Modi" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock MODI = new UnicodeBlock("MODI"); /** * Constant for the "Warang Citi" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock WARANG_CITI = new UnicodeBlock("WARANG_CITI", @@ -2766,7 +2766,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Pau Cin Hau" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock PAU_CIN_HAU = new UnicodeBlock("PAU_CIN_HAU", @@ -2775,14 +2775,14 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Mro" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock MRO = new UnicodeBlock("MRO"); /** * Constant for the "Bassa Vah" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock BASSA_VAH = new UnicodeBlock("BASSA_VAH", @@ -2791,7 +2791,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Pahawh Hmong" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock PAHAWH_HMONG = new UnicodeBlock("PAHAWH_HMONG", @@ -2800,14 +2800,14 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Duployan" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock DUPLOYAN = new UnicodeBlock("DUPLOYAN"); /** * Constant for the "Shorthand Format Controls" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock SHORTHAND_FORMAT_CONTROLS = new UnicodeBlock("SHORTHAND_FORMAT_CONTROLS", @@ -2816,7 +2816,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Mende Kikakui" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock MENDE_KIKAKUI = new UnicodeBlock("MENDE_KIKAKUI", @@ -2825,7 +2825,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Ornamental Dingbats" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock ORNAMENTAL_DINGBATS = new UnicodeBlock("ORNAMENTAL_DINGBATS", @@ -2834,7 +2834,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Geometric Shapes Extended" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock GEOMETRIC_SHAPES_EXTENDED = new UnicodeBlock("GEOMETRIC_SHAPES_EXTENDED", @@ -2843,7 +2843,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Supplemental Arrows-C" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock SUPPLEMENTAL_ARROWS_C = new UnicodeBlock("SUPPLEMENTAL_ARROWS_C", @@ -2852,7 +2852,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Cherokee Supplement" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock CHEROKEE_SUPPLEMENT = new UnicodeBlock("CHEROKEE_SUPPLEMENT", @@ -2861,14 +2861,14 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Hatran" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock HATRAN = new UnicodeBlock("HATRAN"); /** * Constant for the "Old Hungarian" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock OLD_HUNGARIAN = new UnicodeBlock("OLD_HUNGARIAN", @@ -2877,21 +2877,21 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Multani" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock MULTANI = new UnicodeBlock("MULTANI"); /** * Constant for the "Ahom" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock AHOM = new UnicodeBlock("AHOM"); /** * Constant for the "Early Dynastic Cuneiform" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock EARLY_DYNASTIC_CUNEIFORM = new UnicodeBlock("EARLY_DYNASTIC_CUNEIFORM", @@ -2900,7 +2900,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Anatolian Hieroglyphs" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock ANATOLIAN_HIEROGLYPHS = new UnicodeBlock("ANATOLIAN_HIEROGLYPHS", @@ -2909,7 +2909,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Sutton SignWriting" Unicode character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock SUTTON_SIGNWRITING = new UnicodeBlock("SUTTON_SIGNWRITING", @@ -2919,7 +2919,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "Supplemental Symbols and Pictographs" Unicode * character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock SUPPLEMENTAL_SYMBOLS_AND_PICTOGRAPHS = new UnicodeBlock("SUPPLEMENTAL_SYMBOLS_AND_PICTOGRAPHS", @@ -2929,7 +2929,7 @@ class Character implements java.io.Serializable, Comparable { /** * Constant for the "CJK Unified Ideographs Extension E" Unicode * character block. - * @since 1.9 + * @since 9 */ public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_E = new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_E", @@ -4189,175 +4189,175 @@ class Character implements java.io.Serializable, Comparable { /** * Unicode script "Caucasian Albanian". - * @since 1.9 + * @since 9 */ CAUCASIAN_ALBANIAN, /** * Unicode script "Bassa Vah". - * @since 1.9 + * @since 9 */ BASSA_VAH, /** * Unicode script "Duployan". - * @since 1.9 + * @since 9 */ DUPLOYAN, /** * Unicode script "Elbasan". - * @since 1.9 + * @since 9 */ ELBASAN, /** * Unicode script "Grantha". - * @since 1.9 + * @since 9 */ GRANTHA, /** * Unicode script "Pahawh Hmong". - * @since 1.9 + * @since 9 */ PAHAWH_HMONG, /** * Unicode script "Khojki". - * @since 1.9 + * @since 9 */ KHOJKI, /** * Unicode script "Linear A". - * @since 1.9 + * @since 9 */ LINEAR_A, /** * Unicode script "Mahajani". - * @since 1.9 + * @since 9 */ MAHAJANI, /** * Unicode script "Manichaean". - * @since 1.9 + * @since 9 */ MANICHAEAN, /** * Unicode script "Mende Kikakui". - * @since 1.9 + * @since 9 */ MENDE_KIKAKUI, /** * Unicode script "Modi". - * @since 1.9 + * @since 9 */ MODI, /** * Unicode script "Mro". - * @since 1.9 + * @since 9 */ MRO, /** * Unicode script "Old North Arabian". - * @since 1.9 + * @since 9 */ OLD_NORTH_ARABIAN, /** * Unicode script "Nabataean". - * @since 1.9 + * @since 9 */ NABATAEAN, /** * Unicode script "Palmyrene". - * @since 1.9 + * @since 9 */ PALMYRENE, /** * Unicode script "Pau Cin Hau". - * @since 1.9 + * @since 9 */ PAU_CIN_HAU, /** * Unicode script "Old Permic". - * @since 1.9 + * @since 9 */ OLD_PERMIC, /** * Unicode script "Psalter Pahlavi". - * @since 1.9 + * @since 9 */ PSALTER_PAHLAVI, /** * Unicode script "Siddham". - * @since 1.9 + * @since 9 */ SIDDHAM, /** * Unicode script "Khudawadi". - * @since 1.9 + * @since 9 */ KHUDAWADI, /** * Unicode script "Tirhuta". - * @since 1.9 + * @since 9 */ TIRHUTA, /** * Unicode script "Warang Citi". - * @since 1.9 + * @since 9 */ WARANG_CITI, /** * Unicode script "Ahom". - * @since 1.9 + * @since 9 */ AHOM, /** * Unicode script "Anatolian Hieroglyphs". - * @since 1.9 + * @since 9 */ ANATOLIAN_HIEROGLYPHS, /** * Unicode script "Hatran". - * @since 1.9 + * @since 9 */ HATRAN, /** * Unicode script "Multani". - * @since 1.9 + * @since 9 */ MULTANI, /** * Unicode script "Old Hungarian". - * @since 1.9 + * @since 9 */ OLD_HUNGARIAN, /** * Unicode script "SignWriting". - * @since 1.9 + * @since 9 */ SIGNWRITING, diff --git a/jdk/src/java.base/share/classes/java/lang/Integer.java b/jdk/src/java.base/share/classes/java/lang/Integer.java index 11afbef0d47..5302091fb39 100644 --- a/jdk/src/java.base/share/classes/java/lang/Integer.java +++ b/jdk/src/java.base/share/classes/java/lang/Integer.java @@ -716,7 +716,7 @@ public final class Integer extends Number implements Comparable { * {@code radix}, or if {@code radix} is either smaller than * {@link java.lang.Character#MIN_RADIX} or larger than * {@link java.lang.Character#MAX_RADIX}. - * @since 1.9 + * @since 9 */ public static int parseInt(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { @@ -899,7 +899,7 @@ public final class Integer extends Number implements Comparable { * {@code radix}, or if {@code radix} is either smaller than * {@link java.lang.Character#MIN_RADIX} or larger than * {@link java.lang.Character#MAX_RADIX}. - * @since 1.9 + * @since 9 */ public static int parseUnsignedInt(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { diff --git a/jdk/src/java.base/share/classes/java/lang/Long.java b/jdk/src/java.base/share/classes/java/lang/Long.java index d7d232f23b0..191ae2071d4 100644 --- a/jdk/src/java.base/share/classes/java/lang/Long.java +++ b/jdk/src/java.base/share/classes/java/lang/Long.java @@ -747,7 +747,7 @@ public final class Long extends Number implements Comparable { * {@code radix}, or if {@code radix} is either smaller than * {@link java.lang.Character#MIN_RADIX} or larger than * {@link java.lang.Character#MAX_RADIX}. - * @since 1.9 + * @since 9 */ public static long parseLong(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { @@ -993,7 +993,7 @@ public final class Long extends Number implements Comparable { * {@code radix}, or if {@code radix} is either smaller than * {@link java.lang.Character#MIN_RADIX} or larger than * {@link java.lang.Character#MAX_RADIX}. - * @since 1.9 + * @since 9 */ public static long parseUnsignedLong(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { diff --git a/jdk/src/java.base/share/classes/java/lang/Process.java b/jdk/src/java.base/share/classes/java/lang/Process.java index b537bb416d3..3f0ec640a6b 100644 --- a/jdk/src/java.base/share/classes/java/lang/Process.java +++ b/jdk/src/java.base/share/classes/java/lang/Process.java @@ -304,7 +304,7 @@ public abstract class Process { * otherwise, {@link #destroy} forcibly terminates the process * @throws UnsupportedOperationException if the Process implementation * does not support this operation - * @since 1.9 + * @since 9 */ public boolean supportsNormalTermination() { throw new UnsupportedOperationException(this.getClass() @@ -340,7 +340,7 @@ public abstract class Process { * @return the native process id of the process * @throws UnsupportedOperationException if the Process implementation * does not support this operation - * @since 1.9 + * @since 9 */ public long getPid() { return toHandle().getPid(); @@ -409,7 +409,7 @@ public abstract class Process { * * @return a new {@code CompletableFuture} for the Process * - * @since 1.9 + * @since 9 */ public CompletableFuture onExit() { return CompletableFuture.supplyAsync(this::waitForInternal); @@ -471,7 +471,7 @@ public abstract class Process { * does not support this operation * @throws SecurityException if a security manager has been installed and * it denies RuntimePermission("manageProcess") - * @since 1.9 + * @since 9 */ public ProcessHandle toHandle() { throw new UnsupportedOperationException(this.getClass() @@ -491,7 +491,7 @@ public abstract class Process { * @return a snapshot of information about the process, always non-null * @throws UnsupportedOperationException if the Process implementation * does not support this operation - * @since 1.9 + * @since 9 */ public ProcessHandle.Info info() { return toHandle().info(); @@ -516,7 +516,7 @@ public abstract class Process { * does not support this operation * @throws SecurityException if a security manager has been installed and * it denies RuntimePermission("manageProcess") - * @since 1.9 + * @since 9 */ public Stream children() { return toHandle().children(); @@ -542,7 +542,7 @@ public abstract class Process { * does not support this operation * @throws SecurityException if a security manager has been installed and * it denies RuntimePermission("manageProcess") - * @since 1.9 + * @since 9 */ public Stream descendants() { return toHandle().descendants(); diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java b/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java index a7e650fee04..fbf5cfba252 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java @@ -89,7 +89,7 @@ import java.util.stream.Stream; * {@link #compareTo(ProcessHandle) compareTo} methods to compare ProcessHandles. * * @see Process - * @since 1.9 + * @since 9 */ public interface ProcessHandle extends Comparable { @@ -215,7 +215,7 @@ public interface ProcessHandle extends Comparable { * by the operating system privileges of the process making the request. * The return types are {@code Optional} allowing explicit tests * and actions if the value is available. - * @since 1.9 + * @since 9 */ public interface Info { /** diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java index 0019b5724cf..d31a80d740c 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java @@ -50,7 +50,7 @@ import static java.security.AccessController.doPrivileged; * ProcessHandleImpl is the implementation of ProcessHandle. * * @see Process - * @since 1.9 + * @since 9 */ final class ProcessHandleImpl implements ProcessHandle { /** @@ -338,7 +338,7 @@ final class ProcessHandleImpl implements ProcessHandle { * * @return {@code true} if the process represented by this * {@code ProcessHandle} object has not yet terminated. - * @since 1.9 + * @since 9 */ @Override public boolean isAlive() { diff --git a/jdk/src/java.base/share/classes/java/lang/StackWalker.java b/jdk/src/java.base/share/classes/java/lang/StackWalker.java index 2950ca23252..f628459dfb3 100644 --- a/jdk/src/java.base/share/classes/java/lang/StackWalker.java +++ b/jdk/src/java.base/share/classes/java/lang/StackWalker.java @@ -81,7 +81,7 @@ import java.util.stream.Stream; * will cause a {@link NullPointerException NullPointerException} * to be thrown. * - * @since 1.9 + * @since 9 */ public final class StackWalker { /** @@ -92,7 +92,7 @@ public final class StackWalker { * by the {@linkplain Option stack walking options} of a {@linkplain * StackWalker stack walker}. * - * @since 1.9 + * @since 9 * @jvms 2.6 */ public static interface StackFrame { @@ -185,7 +185,7 @@ public final class StackWalker { * Stack walker option to configure the {@linkplain StackFrame stack frame} * information obtained by a {@code StackWalker}. * - * @since 1.9 + * @since 9 */ public enum Option { /** diff --git a/jdk/src/java.base/share/classes/java/lang/String.java b/jdk/src/java.base/share/classes/java/lang/String.java index 63946f2e301..86ec043d5b1 100644 --- a/jdk/src/java.base/share/classes/java/lang/String.java +++ b/jdk/src/java.base/share/classes/java/lang/String.java @@ -2674,7 +2674,7 @@ public final class String * point is passed through uninterpreted. * * @return an IntStream of char values from this sequence - * @since 1.9 + * @since 9 */ @Override public IntStream chars() { @@ -2694,7 +2694,7 @@ public final class String * {@code int} values which are then passed to the stream. * * @return an IntStream of Unicode code points from this sequence - * @since 1.9 + * @since 9 */ @Override public IntStream codePoints() { diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java index 747769e33b2..d9b8223c758 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java @@ -53,7 +53,7 @@ public interface AnnotatedArrayType extends AnnotatedType { * * @return {@code null} * - * @since 1.9 + * @since 9 */ @Override AnnotatedType getAnnotatedOwnerType(); diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java index bb96e6347ed..b42530ef82e 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java @@ -59,7 +59,7 @@ public interface AnnotatedParameterizedType extends AnnotatedType { * refers to a parameterized type that cannot be instantiated * for any reason * - * @since 1.9 + * @since 9 */ @Override AnnotatedType getAnnotatedOwnerType(); diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java index 8ef6130834e..79a8cd15fdd 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java @@ -60,7 +60,7 @@ public interface AnnotatedType extends AnnotatedElement { * refers to a parameterized type that cannot be instantiated * for any reason * - * @since 1.9 + * @since 9 */ default AnnotatedType getAnnotatedOwnerType() { return null; diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedTypeVariable.java b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedTypeVariable.java index c1d8e37482f..cab83f361c3 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedTypeVariable.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedTypeVariable.java @@ -54,7 +54,7 @@ public interface AnnotatedTypeVariable extends AnnotatedType { * * @return {@code null} * - * @since 1.9 + * @since 9 */ @Override AnnotatedType getAnnotatedOwnerType(); diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedWildcardType.java b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedWildcardType.java index 84e44f52e41..d46d269d343 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedWildcardType.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedWildcardType.java @@ -65,7 +65,7 @@ public interface AnnotatedWildcardType extends AnnotatedType { * * @return {@code null} * - * @since 1.9 + * @since 9 */ @Override AnnotatedType getAnnotatedOwnerType(); diff --git a/jdk/src/java.base/share/classes/java/math/BigInteger.java b/jdk/src/java.base/share/classes/java/math/BigInteger.java index c77731b2418..6ef44a5f6f8 100644 --- a/jdk/src/java.base/share/classes/java/math/BigInteger.java +++ b/jdk/src/java.base/share/classes/java/math/BigInteger.java @@ -297,7 +297,7 @@ public class BigInteger extends Number implements Comparable { * @throws IndexOutOfBoundsException if the provided array offset and * length would cause an index into the byte array to be * negative or greater than or equal to the array length. - * @since 1.9 + * @since 9 */ public BigInteger(byte[] val, int off, int len) { if (val.length == 0) { @@ -385,7 +385,7 @@ public class BigInteger extends Number implements Comparable { * @throws IndexOutOfBoundsException if the provided array offset and * length would cause an index into the byte array to be * negative or greater than or equal to the array length. - * @since 1.9 + * @since 9 */ public BigInteger(int signum, byte[] magnitude, int off, int len) { if (signum < -1 || signum > 1) { @@ -2424,7 +2424,7 @@ public class BigInteger extends Number implements Comparable { * {@code (i * sqrt(-val))} where i is the * imaginary unit and is equal to * {@code sqrt(-1)}.) - * @since 1.9 + * @since 9 */ public BigInteger sqrt() { if (this.signum < 0) { @@ -2447,7 +2447,7 @@ public class BigInteger extends Number implements Comparable { * imaginary unit and is equal to * {@code sqrt(-1)}.) * @see #sqrt() - * @since 1.9 + * @since 9 */ public BigInteger[] sqrtAndRemainder() { BigInteger s = sqrt(); diff --git a/jdk/src/java.base/share/classes/java/math/MutableBigInteger.java b/jdk/src/java.base/share/classes/java/math/MutableBigInteger.java index 65eca1e743d..2d7ababd042 100644 --- a/jdk/src/java.base/share/classes/java/math/MutableBigInteger.java +++ b/jdk/src/java.base/share/classes/java/math/MutableBigInteger.java @@ -1878,7 +1878,7 @@ class MutableBigInteger { * @throws ArithmeticException if the value returned by {@code bitLength()} * overflows the range of {@code int}. * @return the integer square root of {@code this} - * @since 1.9 + * @since 9 */ MutableBigInteger sqrt() { // Special cases. diff --git a/jdk/src/java.base/share/classes/java/net/DatagramSocket.java b/jdk/src/java.base/share/classes/java/net/DatagramSocket.java index 3c0e5c66a9b..7a447cb0acd 100644 --- a/jdk/src/java.base/share/classes/java/net/DatagramSocket.java +++ b/jdk/src/java.base/share/classes/java/net/DatagramSocket.java @@ -1338,7 +1338,7 @@ class DatagramSocket implements java.io.Closeable { * * @throws NullPointerException if name is {@code null} * - * @since 1.9 + * @since 9 */ public DatagramSocket setOption(SocketOption name, T value) throws IOException @@ -1368,7 +1368,7 @@ class DatagramSocket implements java.io.Closeable { * {@link java.net.StandardSocketOptions StandardSocketOptions} * do not require any security permission. * - * @since 1.9 + * @since 9 */ public T getOption(SocketOption name) throws IOException { return getImpl().getOption(name); @@ -1386,7 +1386,7 @@ class DatagramSocket implements java.io.Closeable { * @return A set of the socket options supported by this socket. This set * may be empty if the socket's DatagramSocketImpl cannot be created. * - * @since 1.9 + * @since 9 */ public Set> supportedOptions() { synchronized(DatagramSocket.class) { diff --git a/jdk/src/java.base/share/classes/java/net/DatagramSocketImpl.java b/jdk/src/java.base/share/classes/java/net/DatagramSocketImpl.java index 0726dc4cce7..97526bc3712 100644 --- a/jdk/src/java.base/share/classes/java/net/DatagramSocketImpl.java +++ b/jdk/src/java.base/share/classes/java/net/DatagramSocketImpl.java @@ -278,7 +278,7 @@ public abstract class DatagramSocketImpl implements SocketOptions { * * @throws NullPointerException if name is {@code null} * @throws IOException if an I/O problem occurs while attempting to set the option - * @since 1.9 + * @since 9 */ protected void setOption(SocketOption name, T value) throws IOException { if (name == StandardSocketOptions.SO_SNDBUF) { @@ -319,7 +319,7 @@ public abstract class DatagramSocketImpl implements SocketOptions { * @throws NullPointerException if name is {@code null} * @throws IOException if an I/O problem occurs while attempting to set the option * - * @since 1.9 + * @since 9 */ @SuppressWarnings("unchecked") protected T getOption(SocketOption name) throws IOException { diff --git a/jdk/src/java.base/share/classes/java/net/NetworkInterface.java b/jdk/src/java.base/share/classes/java/net/NetworkInterface.java index 8e5ec293646..f505bc48a82 100644 --- a/jdk/src/java.base/share/classes/java/net/NetworkInterface.java +++ b/jdk/src/java.base/share/classes/java/net/NetworkInterface.java @@ -130,7 +130,7 @@ public final class NetworkInterface { * * @return a Stream object with all or a subset of the InetAddresses * bound to this network interface - * @since 1.9 + * @since 9 */ public Stream inetAddresses() { return streamFromArray(getCheckedInetAddresses()); @@ -208,7 +208,7 @@ public final class NetworkInterface { * * @return a Stream object with all of the subinterfaces * of this network interface - * @since 1.9 + * @since 9 */ public Stream subInterfaces() { return streamFromArray(childs); @@ -362,7 +362,7 @@ public final class NetworkInterface { * * @return a Stream of NetworkInterfaces found on this machine * @exception SocketException if an I/O error occurs. - * @since 1.9 + * @since 9 */ public static Stream networkInterfaces() throws SocketException { diff --git a/jdk/src/java.base/share/classes/java/net/ServerSocket.java b/jdk/src/java.base/share/classes/java/net/ServerSocket.java index af0c5152d9a..a86fca6af3c 100644 --- a/jdk/src/java.base/share/classes/java/net/ServerSocket.java +++ b/jdk/src/java.base/share/classes/java/net/ServerSocket.java @@ -946,7 +946,7 @@ class ServerSocket implements java.io.Closeable { * {@link java.net.StandardSocketOptions StandardSocketOptions} * do not require any security permission. * - * @since 1.9 + * @since 9 */ public ServerSocket setOption(SocketOption name, T value) throws IOException @@ -976,7 +976,7 @@ class ServerSocket implements java.io.Closeable { * {@link java.net.StandardSocketOptions StandardSocketOptions} * do not require any security permission. * - * @since 1.9 + * @since 9 */ public T getOption(SocketOption name) throws IOException { return getImpl().getOption(name); @@ -994,7 +994,7 @@ class ServerSocket implements java.io.Closeable { * @return A set of the socket options supported by this socket. This set * may be empty if the socket's SocketImpl cannot be created. * - * @since 1.9 + * @since 9 */ public Set> supportedOptions() { synchronized (ServerSocket.class) { diff --git a/jdk/src/java.base/share/classes/java/net/Socket.java b/jdk/src/java.base/share/classes/java/net/Socket.java index 43e1c5db6bd..47971df5fbb 100644 --- a/jdk/src/java.base/share/classes/java/net/Socket.java +++ b/jdk/src/java.base/share/classes/java/net/Socket.java @@ -1756,7 +1756,7 @@ class Socket implements java.io.Closeable { * {@link java.net.StandardSocketOptions StandardSocketOptions} * do not require any security permission. * - * @since 1.9 + * @since 9 */ public Socket setOption(SocketOption name, T value) throws IOException { getImpl().setOption(name, value); @@ -1784,7 +1784,7 @@ class Socket implements java.io.Closeable { * {@link java.net.StandardSocketOptions StandardSocketOptions} * do not require any security permission. * - * @since 1.9 + * @since 9 */ @SuppressWarnings("unchecked") public T getOption(SocketOption name) throws IOException { @@ -1803,7 +1803,7 @@ class Socket implements java.io.Closeable { * @return A set of the socket options supported by this socket. This set * may be empty if the socket's SocketImpl cannot be created. * - * @since 1.9 + * @since 9 */ public Set> supportedOptions() { synchronized (Socket.class) { diff --git a/jdk/src/java.base/share/classes/java/net/SocketImpl.java b/jdk/src/java.base/share/classes/java/net/SocketImpl.java index b4b9c1900c7..eef92f30b6e 100644 --- a/jdk/src/java.base/share/classes/java/net/SocketImpl.java +++ b/jdk/src/java.base/share/classes/java/net/SocketImpl.java @@ -373,7 +373,7 @@ public abstract class SocketImpl implements SocketOptions { * * @throws IOException if an I/O error occurs, or if the socket is closed. * - * @since 1.9 + * @since 9 */ protected void setOption(SocketOption name, T value) throws IOException { if (name == StandardSocketOptions.SO_KEEPALIVE && @@ -412,7 +412,7 @@ public abstract class SocketImpl implements SocketOptions { * * @throws IOException if an I/O error occurs, or if the socket is closed. * - * @since 1.9 + * @since 9 */ @SuppressWarnings("unchecked") protected T getOption(SocketOption name) throws IOException { diff --git a/jdk/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java b/jdk/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java index 0d6b424205e..b8f2c09bb89 100644 --- a/jdk/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java +++ b/jdk/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java @@ -44,7 +44,7 @@ import java.net.URLStreamHandlerFactory; *

URL stream handler providers are located at runtime, as specified in the * {@linkplain java.net.URL#URL(String,String,int,String) URL constructor}. * - * @since 1.9 + * @since 9 */ public abstract class URLStreamHandlerProvider implements URLStreamHandlerFactory diff --git a/jdk/src/java.base/share/classes/java/net/spi/package-info.java b/jdk/src/java.base/share/classes/java/net/spi/package-info.java index 06ddeccb00d..5a1b2e555af 100644 --- a/jdk/src/java.base/share/classes/java/net/spi/package-info.java +++ b/jdk/src/java.base/share/classes/java/net/spi/package-info.java @@ -29,7 +29,7 @@ *

Only developers who are defining new URL stream handler providers * should need to make direct use of this package. * - * @since 1.9 + * @since 9 */ package java.net.spi; diff --git a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java index a9c6005d28c..838cc40a09a 100644 --- a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java +++ b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java @@ -213,7 +213,7 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public final MappedByteBuffer position(int newPosition) { @@ -223,7 +223,7 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public final MappedByteBuffer limit(int newLimit) { @@ -233,7 +233,7 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public final MappedByteBuffer mark() { @@ -243,7 +243,7 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public final MappedByteBuffer reset() { @@ -253,7 +253,7 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public final MappedByteBuffer clear() { @@ -263,7 +263,7 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public final MappedByteBuffer flip() { @@ -273,7 +273,7 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public final MappedByteBuffer rewind() { diff --git a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template index d34f975526c..72efc279778 100644 --- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -1064,7 +1064,7 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public @@ -1078,7 +1078,7 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public @@ -1092,7 +1092,7 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public @@ -1106,7 +1106,7 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public @@ -1120,7 +1120,7 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public @@ -1134,7 +1134,7 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public @@ -1148,7 +1148,7 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public diff --git a/jdk/src/java.base/share/classes/java/security/KeyStore.java b/jdk/src/java.base/share/classes/java/security/KeyStore.java index 40df29cdd6c..39721622fc2 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyStore.java +++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java @@ -1666,7 +1666,7 @@ public class KeyStore { * * @see Provider * - * @since 1.9 + * @since 9 */ public static final KeyStore getInstance(File file, char[] password) throws KeyStoreException, IOException, NoSuchAlgorithmException, @@ -1722,7 +1722,7 @@ public class KeyStore { * * @see Provider * - * @since 1.9 + * @since 9 */ public static final KeyStore getInstance(File file, LoadStoreParameter param) throws KeyStoreException, IOException, @@ -2006,7 +2006,7 @@ public class KeyStore { * of either PasswordProtection or CallbackHandlerProtection; or * if file does not exist or does not refer to a normal file * - * @since 1.9 + * @since 9 */ public static Builder newInstance(File file, ProtectionParameter protection) { diff --git a/jdk/src/java.base/share/classes/java/security/PermissionCollection.java b/jdk/src/java.base/share/classes/java/security/PermissionCollection.java index 0aa6ce74bc4..1aa41cab022 100644 --- a/jdk/src/java.base/share/classes/java/security/PermissionCollection.java +++ b/jdk/src/java.base/share/classes/java/security/PermissionCollection.java @@ -144,7 +144,7 @@ public abstract class PermissionCollection implements java.io.Serializable { * the enumeration returned from a call to {@link #elements()}. * * @return a stream of all the Permissions. - * @since 1.9 + * @since 9 */ public Stream elementsAsStream() { int characteristics = isReadOnly() diff --git a/jdk/src/java.base/share/classes/java/security/cert/URICertStoreParameters.java b/jdk/src/java.base/share/classes/java/security/cert/URICertStoreParameters.java index 3b6418e4dc2..d8b05485d2d 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/URICertStoreParameters.java +++ b/jdk/src/java.base/share/classes/java/security/cert/URICertStoreParameters.java @@ -43,7 +43,7 @@ import java.net.URI; * provide the necessary locking. Multiple threads each manipulating * separate objects need not synchronize. * - * @since 1.9 + * @since 9 * @see CertStore * @see java.net.URI */ diff --git a/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java b/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java index b43887b4cb0..5aca225d2b2 100644 --- a/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java +++ b/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java @@ -74,7 +74,7 @@ public abstract class EncodedKeySpec implements KeySpec { * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is * the empty string {@code ""} - * @since 1.9 + * @since 9 */ protected EncodedKeySpec(byte[] encodedKey, String algorithm) { if (algorithm == null) { @@ -93,7 +93,7 @@ public abstract class EncodedKeySpec implements KeySpec { * Returns the name of the algorithm of the encoded key. * * @return the name of the algorithm, or null if not specified - * @since 1.9 + * @since 9 */ public String getAlgorithm() { return algorithmName; diff --git a/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java b/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java index 89bf11d94ae..198ca604b8c 100644 --- a/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java +++ b/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java @@ -92,7 +92,7 @@ public class PKCS8EncodedKeySpec extends EncodedKeySpec { * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is * the empty string {@code ""} - * @since 1.9 + * @since 9 */ public PKCS8EncodedKeySpec(byte[] encodedKey, String algorithm) { super(encodedKey, algorithm); diff --git a/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java b/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java index 0ddb97f3ac4..2d23570fe3d 100644 --- a/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java +++ b/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java @@ -82,7 +82,7 @@ public class X509EncodedKeySpec extends EncodedKeySpec { * or {@code algorithm} is null. * @throws IllegalArgumentException if {@code algorithm} is * the empty string {@code ""} - * @since 1.9 + * @since 9 */ public X509EncodedKeySpec(byte[] encodedKey, String algorithm) { super(encodedKey, algorithm); diff --git a/jdk/src/java.base/share/classes/java/util/Enumeration.java b/jdk/src/java.base/share/classes/java/util/Enumeration.java index 2cf2a2708ce..96aa3a90076 100644 --- a/jdk/src/java.base/share/classes/java/util/Enumeration.java +++ b/jdk/src/java.base/share/classes/java/util/Enumeration.java @@ -112,7 +112,7 @@ public interface Enumeration { * * @return an Iterator representing the remaining elements of this Enumeration * - * @since 1.9 + * @since 9 */ default Iterator asIterator() { return new Iterator<>() { diff --git a/jdk/src/java.base/share/classes/java/util/Scanner.java b/jdk/src/java.base/share/classes/java/util/Scanner.java index 1fb17bc65bf..b2f41aecb54 100644 --- a/jdk/src/java.base/share/classes/java/util/Scanner.java +++ b/jdk/src/java.base/share/classes/java/util/Scanner.java @@ -2684,7 +2684,7 @@ public final class Scanner implements Iterator, Closeable { * * @return a sequential stream of token strings * @throws IllegalStateException if this scanner is closed - * @since 1.9 + * @since 9 */ public Stream tokens() { ensureOpen(); @@ -2770,7 +2770,7 @@ public final class Scanner implements Iterator, Closeable { * @return a sequential stream of match results * @throws NullPointerException if pattern is null * @throws IllegalStateException if this scanner is closed - * @since 1.9 + * @since 9 */ public Stream findAll(Pattern pattern) { Objects.requireNonNull(pattern); @@ -2792,7 +2792,7 @@ public final class Scanner implements Iterator, Closeable { * @throws NullPointerException if patString is null * @throws IllegalStateException if this scanner is closed * @throws PatternSyntaxException if the regular expression's syntax is invalid - * @since 1.9 + * @since 9 * @see java.util.regex.Pattern */ public Stream findAll(String patString) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java index 45389ac9109..dd24b82f2cc 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java @@ -2429,7 +2429,7 @@ public class CompletableFuture implements Future, CompletionStage { * * @param the type of the value * @return a new CompletableFuture - * @since 1.9 + * @since 9 */ public CompletableFuture newIncompleteFuture() { return new CompletableFuture(); @@ -2444,7 +2444,7 @@ public class CompletableFuture implements Future, CompletionStage { * an Executor that provides at least one independent thread. * * @return the executor - * @since 1.9 + * @since 9 */ public Executor defaultExecutor() { return ASYNC_POOL; @@ -2462,7 +2462,7 @@ public class CompletableFuture implements Future, CompletionStage { * arrange dependent actions. * * @return the new CompletableFuture - * @since 1.9 + * @since 9 */ public CompletableFuture copy() { return uniCopyStage(); @@ -2479,7 +2479,7 @@ public class CompletableFuture implements Future, CompletionStage { * cause. * * @return the new CompletionStage - * @since 1.9 + * @since 9 */ public CompletionStage minimalCompletionStage() { return uniAsMinimalStage(); @@ -2494,7 +2494,7 @@ public class CompletableFuture implements Future, CompletionStage { * to complete this CompletableFuture * @param executor the executor to use for asynchronous execution * @return this CompletableFuture - * @since 1.9 + * @since 9 */ public CompletableFuture completeAsync(Supplier supplier, Executor executor) { @@ -2512,7 +2512,7 @@ public class CompletableFuture implements Future, CompletionStage { * @param supplier a function returning the value to be used * to complete this CompletableFuture * @return this CompletableFuture - * @since 1.9 + * @since 9 */ public CompletableFuture completeAsync(Supplier supplier) { return completeAsync(supplier, defaultExecutor()); @@ -2528,7 +2528,7 @@ public class CompletableFuture implements Future, CompletionStage { * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return this CompletableFuture - * @since 1.9 + * @since 9 */ public CompletableFuture orTimeout(long timeout, TimeUnit unit) { if (unit == null) @@ -2549,7 +2549,7 @@ public class CompletableFuture implements Future, CompletionStage { * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return this CompletableFuture - * @since 1.9 + * @since 9 */ public CompletableFuture completeOnTimeout(T value, long timeout, TimeUnit unit) { @@ -2573,7 +2573,7 @@ public class CompletableFuture implements Future, CompletionStage { * {@code delay} parameter * @param executor the base executor * @return the new delayed executor - * @since 1.9 + * @since 9 */ public static Executor delayedExecutor(long delay, TimeUnit unit, Executor executor) { @@ -2592,7 +2592,7 @@ public class CompletableFuture implements Future, CompletionStage { * @param unit a {@code TimeUnit} determining how to interpret the * {@code delay} parameter * @return the new delayed executor - * @since 1.9 + * @since 9 */ public static Executor delayedExecutor(long delay, TimeUnit unit) { if (unit == null) @@ -2608,7 +2608,7 @@ public class CompletableFuture implements Future, CompletionStage { * @param value the value * @param the type of the value * @return the completed CompletionStage - * @since 1.9 + * @since 9 */ public static CompletionStage completedStage(U value) { return new MinimalStage((value == null) ? NIL : value); @@ -2621,7 +2621,7 @@ public class CompletableFuture implements Future, CompletionStage { * @param ex the exception * @param the type of the value * @return the exceptionally completed CompletableFuture - * @since 1.9 + * @since 9 */ public static CompletableFuture failedFuture(Throwable ex) { if (ex == null) throw new NullPointerException(); @@ -2636,7 +2636,7 @@ public class CompletableFuture implements Future, CompletionStage { * @param ex the exception * @param the type of the value * @return the exceptionally completed CompletionStage - * @since 1.9 + * @since 9 */ public static CompletionStage failedStage(Throwable ex) { if (ex == null) throw new NullPointerException(); diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java index c1418ffc0d6..fe137386d45 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java @@ -161,7 +161,7 @@ package java.util.concurrent; * }} * * @author Doug Lea - * @since 1.9 + * @since 9 */ public final class Flow { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java index 2b714dff9b4..888794e8e40 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java @@ -1301,7 +1301,7 @@ public abstract class ForkJoinTask implements Future, Serializable { * support extensions, and is unlikely to be useful otherwise. * * @return a task, or {@code null} if none are available - * @since 1.9 + * @since 9 */ protected static ForkJoinTask pollSubmission() { Thread t; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java index 286c31b86a3..d3c4518a3b6 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java @@ -154,7 +154,7 @@ import java.util.function.Consumer; * * @param the published item type * @author Doug Lea - * @since 1.9 + * @since 9 */ public class SubmissionPublisher implements Flow.Publisher, AutoCloseable { diff --git a/jdk/src/java.base/share/classes/java/util/regex/Matcher.java b/jdk/src/java.base/share/classes/java/util/regex/Matcher.java index f8231e83e53..7f030af704a 100644 --- a/jdk/src/java.base/share/classes/java/util/regex/Matcher.java +++ b/jdk/src/java.base/share/classes/java/util/regex/Matcher.java @@ -974,7 +974,7 @@ public final class Matcher implements MatchResult { * @throws IndexOutOfBoundsException * If the replacement string refers to a capturing group * that does not exist in the pattern - * @since 1.9 + * @since 9 */ public Matcher appendReplacement(StringBuilder sb, String replacement) { // If no match, return error @@ -1117,7 +1117,7 @@ public final class Matcher implements MatchResult { * * @return The target string builder * - * @since 1.9 + * @since 9 */ public StringBuilder appendTail(StringBuilder sb) { sb.append(text, lastAppendPosition, getTextLength()); @@ -1229,7 +1229,7 @@ public final class Matcher implements MatchResult { * @throws ConcurrentModificationException if it is detected, on a * best-effort basis, that the replacer function modified this * matcher's state - * @since 1.9 + * @since 9 */ public String replaceAll(Function replacer) { Objects.requireNonNull(replacer); @@ -1273,7 +1273,7 @@ public final class Matcher implements MatchResult { * modification is detected. * * @return a sequential stream of match results. - * @since 1.9 + * @since 9 */ public Stream results() { class MatchResultIterator implements Iterator { @@ -1451,7 +1451,7 @@ public final class Matcher implements MatchResult { * @throws ConcurrentModificationException if it is detected, on a * best-effort basis, that the replacer function modified this * matcher's state - * @since 1.9 + * @since 9 */ public String replaceFirst(Function replacer) { Objects.requireNonNull(replacer); diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java index 79ad66e5b87..574e4f17fc7 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java @@ -329,7 +329,7 @@ public interface DoubleStream extends BaseStream { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default DoubleStream takeWhile(DoublePredicate predicate) { Objects.requireNonNull(predicate); @@ -396,7 +396,7 @@ public interface DoubleStream extends BaseStream { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default DoubleStream dropWhile(DoublePredicate predicate) { Objects.requireNonNull(predicate); diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java index 2da8629e901..91ddad2b2a8 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java @@ -326,7 +326,7 @@ public interface IntStream extends BaseStream { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default IntStream takeWhile(IntPredicate predicate) { Objects.requireNonNull(predicate); @@ -392,7 +392,7 @@ public interface IntStream extends BaseStream { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default IntStream dropWhile(IntPredicate predicate) { Objects.requireNonNull(predicate); diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java index 7468a2715b2..c1a89eb4b76 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java @@ -327,7 +327,7 @@ public interface LongStream extends BaseStream { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default LongStream takeWhile(LongPredicate predicate) { Objects.requireNonNull(predicate); @@ -394,7 +394,7 @@ public interface LongStream extends BaseStream { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default LongStream dropWhile(LongPredicate predicate) { Objects.requireNonNull(predicate); diff --git a/jdk/src/java.base/share/classes/java/util/stream/Stream.java b/jdk/src/java.base/share/classes/java/util/stream/Stream.java index 0ca9e3d2ef2..aef2581d0eb 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java @@ -533,7 +533,7 @@ public interface Stream extends BaseStream> { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default Stream takeWhile(Predicate predicate) { Objects.requireNonNull(predicate); @@ -599,7 +599,7 @@ public interface Stream extends BaseStream> { * predicate to apply to elements to determine the longest * prefix of elements. * @return the new stream - * @since 1.9 + * @since 9 */ default Stream dropWhile(Predicate predicate) { Objects.requireNonNull(predicate); @@ -1146,7 +1146,7 @@ public interface Stream extends BaseStream> { * @param the type of stream elements * @return a stream with a single element if the specified element * is non-null, otherwise an empty stream - * @since 1.9 + * @since 9 */ public static Stream ofNullable(T t) { return t == null ? Stream.empty() diff --git a/jdk/src/java.base/share/classes/java/util/stream/WhileOps.java b/jdk/src/java.base/share/classes/java/util/stream/WhileOps.java index cabe6883528..1288333df01 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/WhileOps.java +++ b/jdk/src/java.base/share/classes/java/util/stream/WhileOps.java @@ -43,7 +43,7 @@ import java.util.function.Predicate; * Factory for instances of a takeWhile and dropWhile operations * that produce subsequences of their input stream. * - * @since 1.9 + * @since 9 */ final class WhileOps { diff --git a/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java b/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java index 2d82625780e..3b414954417 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java +++ b/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java @@ -44,7 +44,7 @@ import sun.nio.ch.DirectBuffer; * {@link NullPointerException} to be thrown. *

* - * @since 1.9 + * @since 9 */ public final class CRC32C implements Checksum { diff --git a/jdk/src/java.base/share/classes/java/util/zip/Checksum.java b/jdk/src/java.base/share/classes/java/util/zip/Checksum.java index 121b687df0b..eb681861785 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/Checksum.java +++ b/jdk/src/java.base/share/classes/java/util/zip/Checksum.java @@ -51,7 +51,7 @@ public interface Checksum { * @throws NullPointerException * if {@code b} is {@code null} * - * @since 1.9 + * @since 9 */ default public void update(byte[] b) { update(b, 0, b.length); @@ -99,7 +99,7 @@ public interface Checksum { * @throws NullPointerException * if {@code buffer} is {@code null} * - * @since 1.9 + * @since 9 */ default public void update(ByteBuffer buffer) { int pos = buffer.position(); diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java index c380058356b..ee91cee3ed8 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java @@ -220,7 +220,7 @@ class ZipEntry implements ZipConstants, Cloneable { * The last modification time of the entry in local date-time * * @see #getTimeLocal() - * @since 1.9 + * @since 9 */ public void setTimeLocal(LocalDateTime time) { int year = time.getYear() - 1980; @@ -259,7 +259,7 @@ class ZipEntry implements ZipConstants, Cloneable { * @return The last modification time of the entry in local date-time * * @see #setTimeLocal(LocalDateTime) - * @since 1.9 + * @since 9 */ public LocalDateTime getTimeLocal() { if (mtime != null) { diff --git a/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java b/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java index 95ea0b44b87..8f3661fbfa3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java +++ b/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java @@ -117,7 +117,7 @@ import java.lang.annotation.*; * and that (2) for all methods of that class annotated with * {@code @HotSpotIntrinsicCandidate} there is an intrinsic in the list. * - * @since 1.9 + * @since 9 */ @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) @Retention(RetentionPolicy.RUNTIME) diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/package-info.java b/jdk/src/java.base/share/classes/jdk/internal/logger/package-info.java index 28c622d4cde..46b571aa137 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/logger/package-info.java +++ b/jdk/src/java.base/share/classes/jdk/internal/logger/package-info.java @@ -63,6 +63,6 @@ * @see sun.util.logging.PlatformLogger.Bridge * @see sun.util.logging.internal * - * @since 1.9 + * @since 9 */ package jdk.internal.logger; diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index 9176784def0..f130d383a84 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -1081,7 +1081,7 @@ public final class Unsafe { * @return the value fetched from the indicated object * @throws RuntimeException No defined exceptions are thrown, not even * {@link NullPointerException} - * @since 1.9 + * @since 9 */ @HotSpotIntrinsicCandidate public final long getLongUnaligned(Object o, long offset) { @@ -1115,7 +1115,7 @@ public final class Unsafe { * @param offset The offset in bytes from the start of the object * @param bigEndian The endianness of the value * @return the value fetched from the indicated object - * @since 1.9 + * @since 9 */ public final long getLongUnaligned(Object o, long offset, boolean bigEndian) { return convEndian(bigEndian, getLongUnaligned(o, offset)); @@ -1193,7 +1193,7 @@ public final class Unsafe { * @param x the value to store * @throws RuntimeException No defined exceptions are thrown, not even * {@link NullPointerException} - * @since 1.9 + * @since 9 */ @HotSpotIntrinsicCandidate public final void putLongUnaligned(Object o, long offset, long x) { @@ -1231,7 +1231,7 @@ public final class Unsafe { * @param bigEndian The endianness of the value * @throws RuntimeException No defined exceptions are thrown, not even * {@link NullPointerException} - * @since 1.9 + * @since 9 */ public final void putLongUnaligned(Object o, long offset, long x, boolean bigEndian) { putLongUnaligned(o, offset, convEndian(bigEndian, x)); diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/ResponderId.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/ResponderId.java index 68d3811265d..f67786e432c 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/ResponderId.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/ResponderId.java @@ -49,7 +49,7 @@ import sun.security.util.DerValue; * * * @see ResponderId.Type - * @since 1.9 + * @since 9 */ public final class ResponderId { @@ -58,7 +58,7 @@ public final class ResponderId { * {@code ResponderId}. * * @see ResponderId - * @since 1.9 + * @since 9 */ public static enum Type { /** diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ClientKeyExchangeService.java b/jdk/src/java.base/share/classes/sun/security/ssl/ClientKeyExchangeService.java index d68f0fad056..8da221961a0 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientKeyExchangeService.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientKeyExchangeService.java @@ -41,7 +41,7 @@ import java.util.*; * Models a service that provides support for a particular client key exchange * mode. Currently used to implement Kerberos-related cipher suites. * - * @since 1.9 + * @since 9 */ public interface ClientKeyExchangeService { diff --git a/jdk/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java b/jdk/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java index 81e52ae3448..b43aa234833 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java +++ b/jdk/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java @@ -37,7 +37,7 @@ import sun.security.util.Debug; /** * This class delegates to a primary or secondary keystore implementation. * - * @since 1.9 + * @since 9 */ public class KeyStoreDelegator extends KeyStoreSpi { diff --git a/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DataFlavorUtil.java b/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DataFlavorUtil.java index 28991f05d4c..8bdc82b7b10 100644 --- a/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DataFlavorUtil.java +++ b/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DataFlavorUtil.java @@ -55,7 +55,7 @@ import java.util.function.Supplier; /** * Utility class with different datatransfer helper functions * - * @since 1.9 + * @since 9 */ public class DataFlavorUtil { diff --git a/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DesktopDatatransferService.java b/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DesktopDatatransferService.java index c0775487607..37499195bed 100644 --- a/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DesktopDatatransferService.java +++ b/jdk/src/java.datatransfer/share/classes/sun/datatransfer/DesktopDatatransferService.java @@ -35,7 +35,7 @@ import java.util.function.Supplier; * to enrich it's functionality * * @author Petr Pchelko - * @since 1.9 + * @since 9 */ public interface DesktopDatatransferService { diff --git a/jdk/src/java.desktop/share/classes/java/awt/RenderingHints.java b/jdk/src/java.desktop/share/classes/java/awt/RenderingHints.java index 09bee025b5f..524fc999ad1 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/RenderingHints.java +++ b/jdk/src/java.desktop/share/classes/java/awt/RenderingHints.java @@ -965,7 +965,7 @@ public class RenderingHints *
  • {@link #VALUE_RESOLUTION_VARIANT_SIZE_FIT} *
  • {@link #VALUE_RESOLUTION_VARIANT_DPI_FIT} * - * @since 1.9 + * @since 9 */ public static final Key KEY_RESOLUTION_VARIANT = SunHints.KEY_RESOLUTION_VARIANT; @@ -976,7 +976,7 @@ public class RenderingHints * of the platform * * @see #KEY_RESOLUTION_VARIANT - * @since 1.9 + * @since 9 */ public static final Object VALUE_RESOLUTION_VARIANT_DEFAULT = SunHints.VALUE_RESOLUTION_VARIANT_DEFAULT; @@ -986,7 +986,7 @@ public class RenderingHints * is always used. * * @see #KEY_RESOLUTION_VARIANT - * @since 1.9 + * @since 9 */ public static final Object VALUE_RESOLUTION_VARIANT_BASE = SunHints.VALUE_RESOLUTION_VARIANT_BASE; @@ -997,7 +997,7 @@ public class RenderingHints * context. * * @see #KEY_RESOLUTION_VARIANT - * @since 1.9 + * @since 9 */ public static final Object VALUE_RESOLUTION_VARIANT_SIZE_FIT = SunHints.VALUE_RESOLUTION_VARIANT_SIZE_FIT; @@ -1007,7 +1007,7 @@ public class RenderingHints * chosen based only on the DPI of the screen. * * @see #KEY_RESOLUTION_VARIANT - * @since 1.9 + * @since 9 */ public static final Object VALUE_RESOLUTION_VARIANT_DPI_FIT = SunHints.VALUE_RESOLUTION_VARIANT_DPI_FIT; diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/NumericShaper.java b/jdk/src/java.desktop/share/classes/java/awt/font/NumericShaper.java index 524d230fdc4..2d486827e3c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/NumericShaper.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/NumericShaper.java @@ -321,12 +321,12 @@ public final class NumericShaper implements java.io.Serializable { MEETEI_MAYEK ('\uabf0', '\uabc0', '\uac00'), /** * The Sinhala range with the Sinhala digits. - * @since 1.9 + * @since 9 */ SINHALA ('\u0de6', '\u0d80', '\u0e00'), /** * The Myanmar Extended-B range with the Myanmar Tai Laing digits. - * @since 1.9 + * @since 9 */ MYANMAR_TAI_LAING ('\ua9f0', '\ua9e0', '\uaa00'); diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java index 606661b3e69..5dc41d88d60 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java @@ -59,7 +59,7 @@ import java.awt.Image; * @see java.awt.Image * @see java.awt.image.MultiResolutionImage * - * @since 1.9 + * @since 9 */ public abstract class AbstractMultiResolutionImage extends java.awt.Image implements MultiResolutionImage { @@ -96,7 +96,7 @@ public abstract class AbstractMultiResolutionImage extends java.awt.Image * * @return the base image of the set of multi-resolution images * - * @since 1.9 + * @since 9 */ protected abstract Image getBaseImage(); } \ No newline at end of file diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/BaseMultiResolutionImage.java b/jdk/src/java.desktop/share/classes/java/awt/image/BaseMultiResolutionImage.java index 653057632a5..fb26bf161fc 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/BaseMultiResolutionImage.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/BaseMultiResolutionImage.java @@ -50,7 +50,7 @@ import java.util.Objects; * @see java.awt.image.MultiResolutionImage * @see java.awt.image.AbstractMultiResolutionImage * - * @since 1.9 + * @since 9 */ public class BaseMultiResolutionImage extends AbstractMultiResolutionImage { @@ -66,7 +66,7 @@ public class BaseMultiResolutionImage extends AbstractMultiResolutionImage { * @throws NullPointerException if the specified {@code resolutionVariants} * contains one or more null elements * - * @since 1.9 + * @since 9 */ public BaseMultiResolutionImage(Image... resolutionVariants) { this(0, resolutionVariants); @@ -86,7 +86,7 @@ public class BaseMultiResolutionImage extends AbstractMultiResolutionImage { * negative or greater than or equal to {@code resolutionVariants} * length. * - * @since 1.9 + * @since 9 */ public BaseMultiResolutionImage(int baseImageIndex, Image... resolutionVariants) { diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/MultiResolutionImage.java b/jdk/src/java.desktop/share/classes/java/awt/image/MultiResolutionImage.java index 26b4b534d81..f5634823e74 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/MultiResolutionImage.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/MultiResolutionImage.java @@ -52,7 +52,7 @@ import java.util.List; * @see java.awt.Toolkit#getImage(java.lang.String filename) * @see java.awt.Toolkit#getImage(java.net.URL url) * - * @since 1.9 + * @since 9 */ public interface MultiResolutionImage { @@ -67,7 +67,7 @@ public interface MultiResolutionImage { * {@code destImageHeight} is less than or equal to zero, infinity, * or NaN. * - * @since 1.9 + * @since 9 */ Image getResolutionVariant(double destImageWidth, double destImageHeight); @@ -78,7 +78,7 @@ public interface MultiResolutionImage { * Note that many implementations might return an unmodifiable list. *

    * @return list of resolution variants. - * @since 1.9 + * @since 9 */ public List getResolutionVariants(); } \ No newline at end of file diff --git a/jdk/src/java.desktop/share/classes/java/beans/BeanProperty.java b/jdk/src/java.desktop/share/classes/java/beans/BeanProperty.java index a997f1ea9f5..b18aae551ac 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/BeanProperty.java +++ b/jdk/src/java.desktop/share/classes/java/beans/BeanProperty.java @@ -39,7 +39,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * which does not imply the automatic analysis. * * @see BeanInfo#getPropertyDescriptors - * @since 1.9 + * @since 9 * * @author Sergey A. Malenkov */ diff --git a/jdk/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java b/jdk/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java index 6979827b960..27c3e5e57db 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java +++ b/jdk/src/java.desktop/share/classes/java/beans/IndexedPropertyDescriptor.java @@ -152,7 +152,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor { * and the {@code value} is the automatically generated property info * @param bound the flag indicating whether it is possible to treat this property as a bound property * - * @since 1.9 + * @since 9 */ IndexedPropertyDescriptor(Entry entry, boolean bound) { super(entry, bound); diff --git a/jdk/src/java.desktop/share/classes/java/beans/JavaBean.java b/jdk/src/java.desktop/share/classes/java/beans/JavaBean.java index 84efb292b14..1a6f870139a 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/JavaBean.java +++ b/jdk/src/java.desktop/share/classes/java/beans/JavaBean.java @@ -39,7 +39,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * which does not imply the automatic analysis. * * @see BeanInfo#getBeanDescriptor - * @since 1.9 + * @since 9 * * @author Sergey A. Malenkov */ diff --git a/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java b/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java index f82f7f533da..012b495724d 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java +++ b/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java @@ -150,7 +150,7 @@ public class PropertyDescriptor extends FeatureDescriptor { * and the {@code value} is the automatically generated property info * @param bound the flag indicating whether it is possible to treat this property as a bound property * - * @since 1.9 + * @since 9 */ PropertyDescriptor(Entry entry, boolean bound) { String base = entry.getKey(); diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibilityProvider.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibilityProvider.java index 001b42f15d6..59b8ab18d8d 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibilityProvider.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibilityProvider.java @@ -43,7 +43,7 @@ package javax.accessibility; * * @see java.awt.Toolkit#getDefaultToolkit * @see java.util.ServiceLoader - * @since 1.9 + * @since 9 */ public abstract class AccessibilityProvider { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html index b2d168b7661..2fc49cfec0f 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html +++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html @@ -1194,7 +1194,7 @@ The DTD for the TIFF native image metadata format is as follows: ]> -@since 1.9 +@since 9 diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java index fd0e925238b..d434acf8ab3 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java @@ -55,7 +55,7 @@ import java.util.List; *

  • * * - * @since 1.9 + * @since 9 * @see TIFF 6.0 Specification */ public class BaselineTIFFTagSet extends TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifGPSTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifGPSTagSet.java index af9334daeff..d37a1330d12 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifGPSTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifGPSTagSet.java @@ -35,7 +35,7 @@ import java.util.List; *

    The definitions of the data types referenced by the field * definitions may be found in the {@link TIFFTag TIFFTag} class. * - * @since 1.9 + * @since 9 * @see ExifTIFFTagSet */ public class ExifGPSTagSet extends TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifInteroperabilityTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifInteroperabilityTagSet.java index 11654b1d0f6..b2a52790f0b 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifInteroperabilityTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifInteroperabilityTagSet.java @@ -31,7 +31,7 @@ import java.util.List; /** * A class representing the tags found in an Exif Interoperability IFD. * - * @since 1.9 + * @since 9 * @see ExifTIFFTagSet */ public class ExifInteroperabilityTagSet extends TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifParentTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifParentTIFFTagSet.java index faa8c371156..29647711fc4 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifParentTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifParentTIFFTagSet.java @@ -34,7 +34,7 @@ import java.util.List; * TIFFImageReadParam.addAllowedTagSet} method if Exif * support is desired. * - * @since 1.9 + * @since 9 */ public class ExifParentTIFFTagSet extends TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifTIFFTagSet.java index 13bf8c2614f..5867a0ffef5 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/ExifTIFFTagSet.java @@ -39,7 +39,7 @@ import java.util.List; *

    The definitions of the data types referenced by the field * definitions may be found in the {@link TIFFTag TIFFTag} class. * - * @since 1.9 + * @since 9 */ public class ExifTIFFTagSet extends TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java index 0266e2c7fc0..fa9733cd3f0 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java @@ -31,7 +31,7 @@ import java.util.List; * A class representing the extra tags found in a * TIFF-F (RFC 2036) file. * - * @since 1.9 + * @since 9 */ public class FaxTIFFTagSet extends TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java index 74ecc36beba..c478f7c03e7 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java @@ -39,7 +39,7 @@ import java.util.List; *

    The definitions of the data types referenced by the field * definitions may be found in the {@link TIFFTag TIFFTag} class.

    * - * @since 1.9 + * @since 9 */ public class GeoTIFFTagSet extends TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java index b2299dd0786..ea13664767c 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java @@ -95,7 +95,7 @@ import com.sun.imageio.plugins.tiff.TIFFImageMetadata; * or removing TIFFFields or TIFFTagSets, it * must be synchronized externally.

    * - * @since 1.9 + * @since 9 * @see IIOMetadata * @see TIFFField * @see TIFFTag diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index e393cedb39f..7afc44520f9 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -257,7 +257,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * * * - * @since 1.9 + * @since 9 * @see TIFFDirectory * @see TIFFTag */ diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java index 8bfe0d59d3a..27f633c7cfd 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java @@ -46,7 +46,7 @@ import javax.imageio.ImageReadParam; * ExifParentTIFFTagSet, and GeoTIFFTagSet * are included. * - * @since 1.9 + * @since 9 */ public class TIFFImageReadParam extends ImageReadParam { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java index 50f06eee8a6..68542c4078d 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java @@ -40,7 +40,7 @@ import java.util.TreeMap; * tiff stream are defined in the {@link BaselineTIFFTagSet * BaselineTIFFTagSet} class. * - * @since 1.9 + * @since 9 * @see BaselineTIFFTagSet * @see TIFFField * @see TIFFTagSet diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java index 4af5d34e435..8082fba86b8 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTagSet.java @@ -44,7 +44,7 @@ import java.util.TreeSet; * name, legal data types, and mnemonic names for some or all of ts * data values. * - * @since 1.9 + * @since 9 * @see TIFFTag */ public class TIFFTagSet { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html index f13be9e1a6b..1c2153a96a3 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html @@ -46,6 +46,6 @@ specification and usage notes.

    -@since 1.9 +@since 9 diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java index b6fa1b7bd81..883e0c0cf7c 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java @@ -616,7 +616,7 @@ public abstract class JComponent extends Container implements Serializable, * Returns the look and feel delegate that renders this component. * * @return the {@code ComponentUI} object that renders this component - * @since 1.9 + * @since 9 */ @Transient public ComponentUI getUI() { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/SwingContainer.java b/jdk/src/java.desktop/share/classes/javax/swing/SwingContainer.java index bcf78f37360..08eae7f34f6 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/SwingContainer.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingContainer.java @@ -45,7 +45,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * with the {@code isContainer} attribute allow to directly specify * whether a Swing component is a container or not. * - * @since 1.9 + * @since 9 * * @author Sergey A. Malenkov */ diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java b/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java index b965ccfcbc0..815aee02244 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java @@ -3023,7 +3023,7 @@ public abstract class AbstractDocument implements Document, Serializable { /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public void lockEdit() { @@ -3032,7 +3032,7 @@ public abstract class AbstractDocument implements Document, Serializable { /** * {@inheritDoc} - * @since 1.9 + * @since 9 */ @Override public void unlockEdit() { diff --git a/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java b/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java index f0727eccf4e..e96ca888ee3 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DesktopDatatransferServiceImpl.java @@ -39,7 +39,7 @@ import java.util.function.Supplier; * {@code DesktopDatatransferService} interface. * * @author Petr Pchelko - * @since 1.9 + * @since 9 */ public class DesktopDatatransferServiceImpl implements DesktopDatatransferService { diff --git a/jdk/src/java.desktop/share/classes/sun/swing/text/UndoableEditLockSupport.java b/jdk/src/java.desktop/share/classes/sun/swing/text/UndoableEditLockSupport.java index 43440da0dc8..1e9cb47f6ce 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/text/UndoableEditLockSupport.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/text/UndoableEditLockSupport.java @@ -28,7 +28,7 @@ import javax.swing.undo.UndoableEdit; /** * UndoableEdit support for undo/redo actions synchronization - * @since 1.9 + * @since 9 */ public interface UndoableEditLockSupport extends UndoableEdit { /** diff --git a/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java b/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java index 61b0c817818..0778571d3f5 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java @@ -423,7 +423,7 @@ public class FileHandler extends StreamHandler { * @exception IllegalArgumentException if {@code limit < 0}, or {@code count < 1}. * @exception IllegalArgumentException if pattern is an empty string * - * @since 1.9 + * @since 9 * */ public FileHandler(String pattern, long limit, int count, boolean append) diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java index d1c59fc763f..81f3387be8c 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -2548,7 +2548,7 @@ public class LogManager { * caller does not have LoggingPermission("control"). * @throws NullPointerException if the listener is null. * - * @since 1.9 + * @since 9 */ public LogManager addConfigurationListener(Runnable listener) { final Runnable r = Objects.requireNonNull(listener); @@ -2575,7 +2575,7 @@ public class LogManager { * @throws SecurityException if a security manager exists and if the * caller does not have LoggingPermission("control"). * - * @since 1.9 + * @since 9 */ public void removeConfigurationListener(Runnable listener) { final Runnable key = Objects.requireNonNull(listener); diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java index a7bbc761ba7..571a792c4dc 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java @@ -138,7 +138,7 @@ public class LogRecord implements java.io.Serializable { /** * Event time. - * @since 1.9 + * @since 9 */ private Instant instant; @@ -158,7 +158,7 @@ public class LogRecord implements java.io.Serializable { * The event time instant can be reconstructed using * Instant.ofEpochSecond(millis/1000, (millis % 1000) * 1000_000 + nanoAdjustment) *

    - * Since: 1.9 + * Since: 9 * @serialField thrown Throwable The Throwable (if any) associated with log * message * @serialField loggerName String Name of the source Logger @@ -207,7 +207,7 @@ public class LogRecord implements java.io.Serializable { * The sequence property will be initialized with a new unique value. * These sequence values are allocated in increasing order within a VM. *

    - * Since JDK 1.9, the event time is represented by an {@link Instant}. + * Since JDK 9, the event time is represented by an {@link Instant}. * The instant property will be initialized to the {@linkplain * Instant#now() current instant}, using the best available * {@linkplain Clock#systemUTC() clock} on the system. @@ -505,7 +505,7 @@ public class LogRecord implements java.io.Serializable { * * @return the instant that the event occurred. * - * @since 1.9 + * @since 9 */ public Instant getInstant() { return instant; @@ -525,7 +525,7 @@ public class LogRecord implements java.io.Serializable { * @throws ArithmeticException if numeric overflow would occur while * calling {@link Instant#toEpochMilli() instant.toEpochMilli()}. * - * @since 1.9 + * @since 9 */ public void setInstant(Instant instant) { instant.toEpochMilli(); diff --git a/jdk/src/java.logging/share/classes/java/util/logging/Logger.java b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java index 077b272f3ac..3cc00d0e630 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/Logger.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/Logger.java @@ -1300,7 +1300,7 @@ public class Logger { * can be {@code null}. * @param msg The string message (or a key in the message catalog) * @param params Parameters to the message (optional, may be none). - * @since 1.9 + * @since 9 */ public void logrb(Level level, ResourceBundle bundle, String msg, Object... params) { if (!isLoggable(level)) { @@ -1417,7 +1417,7 @@ public class Logger { * can be {@code null}. * @param msg The string message (or a key in the message catalog) * @param thrown Throwable associated with the log message. - * @since 1.9 + * @since 9 */ public void logrb(Level level, ResourceBundle bundle, String msg, Throwable thrown) { diff --git a/jdk/src/java.logging/share/classes/sun/util/logging/internal/package-info.java b/jdk/src/java.logging/share/classes/sun/util/logging/internal/package-info.java index 22f45a70959..6fd293300a5 100644 --- a/jdk/src/java.logging/share/classes/sun/util/logging/internal/package-info.java +++ b/jdk/src/java.logging/share/classes/sun/util/logging/internal/package-info.java @@ -50,6 +50,6 @@ * @see sun.util.logging.PlatformLogger.Bridge * @see jdk.internal.logger * - * @since 1.9 + * @since 9 */ package sun.util.logging.internal; diff --git a/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java b/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java index 5d5515ca9ed..46f92a248e4 100644 --- a/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java +++ b/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java @@ -590,7 +590,7 @@ public class ThreadInfo { * @return {@code true} if the thread is a daemon thread, * {@code false} otherwise. * @see Thread#isDaemon - * @since 1.9 + * @since 9 */ public boolean isDaemon() { return daemon; @@ -602,7 +602,7 @@ public class ThreadInfo { * * @return The priority of the thread associated with this * {@code ThreadInfo}. - * @since 1.9 + * @since 9 */ public int getPriority() { return priority; diff --git a/jdk/src/java.management/share/classes/javax/management/ConstructorParameters.java b/jdk/src/java.management/share/classes/javax/management/ConstructorParameters.java index d3d447e2a53..7c53794293b 100644 --- a/jdk/src/java.management/share/classes/javax/management/ConstructorParameters.java +++ b/jdk/src/java.management/share/classes/javax/management/ConstructorParameters.java @@ -62,7 +62,7 @@ import static java.lang.annotation.RetentionPolicy.*; * the JMX introspection will give an absolute precedence to the latter one. *

    * - * @since 1.9 + * @since 9 */ @Documented @Target(CONSTRUCTOR) @Retention(RUNTIME) public @interface ConstructorParameters { diff --git a/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/JdkLDAP.java b/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/JdkLDAP.java index c44b9a70ed1..10895e8f000 100644 --- a/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/JdkLDAP.java +++ b/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/JdkLDAP.java @@ -34,7 +34,7 @@ import java.security.cert.CertStoreParameters; * Provider class for the JdkLDAP provider. * Supports LDAP cert store. * - * @since 1.9 + * @since 9 */ public final class JdkLDAP extends Provider { diff --git a/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java b/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java index c64175ec1c7..5d6932420cc 100644 --- a/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java +++ b/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java @@ -54,7 +54,7 @@ import sun.security.x509.X500Name; * Core implementation of a LDAP Cert Store. * @see java.security.cert.CertStore * - * @since 1.9 + * @since 9 */ final class LDAPCertStoreImpl { diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java index 3cd0c9b5055..41af8929e33 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java @@ -44,7 +44,7 @@ import javax.security.auth.DestroyFailedException; * The key material of an {@code EncryptionKey} is defined as the value * of the {@code keyValue} above. * - * @since 1.9 + * @since 9 */ public final class EncryptionKey implements SecretKey { diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java index ab079b8570b..27c2741d911 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java @@ -45,7 +45,7 @@ import java.util.Objects; * } * * - * @since 1.9 + * @since 9 */ public final class KerberosCredMessage implements Destroyable { diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ssl/Krb5KeyExchangeService.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ssl/Krb5KeyExchangeService.java index 1c9debf40ad..1f6662ddbd2 100644 --- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ssl/Krb5KeyExchangeService.java +++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ssl/Krb5KeyExchangeService.java @@ -65,7 +65,7 @@ import java.util.Set; /** * The provider for TLS_KRB_ cipher suites. * - * @since 1.9 + * @since 9 */ public class Krb5KeyExchangeService implements ClientKeyExchangeService { diff --git a/jdk/src/java.sql/share/classes/java/sql/Connection.java b/jdk/src/java.sql/share/classes/java/sql/Connection.java index 36c61c930d2..3051c835d17 100644 --- a/jdk/src/java.sql/share/classes/java/sql/Connection.java +++ b/jdk/src/java.sql/share/classes/java/sql/Connection.java @@ -1538,7 +1538,7 @@ throws SQLException; * prior to returning the {@code PooledConnection} back to the cache * * @throws SQLException if an error occurs - * @since 1.9 + * @since 9 * @see endRequest * @see javax.sql.PooledConnection */ @@ -1580,7 +1580,7 @@ throws SQLException; * prior to returning the {@code PooledConnection} back to the cache * * @throws SQLException if an error occurs - * @since 1.9 + * @since 9 * @see beginRequest * @see javax.sql.PooledConnection */ @@ -1614,7 +1614,7 @@ throws SQLException; * this method is called on a closed {@code connection}; or * the {@code timeout} value is less than 0. * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 + * @since 9 * @see ShardingKey * @see ShardingKeyBuilder */ @@ -1645,7 +1645,7 @@ throws SQLException; * this method is called on a closed {@code connection}; the {@code shardingkey} * is {@code null}; or the {@code timeout} value is less than 0. * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 + * @since 9 * @see ShardingKey * @see ShardingKeyBuilder */ @@ -1671,7 +1671,7 @@ throws SQLException; * the {@code shardingkey} is {@code null}; or * a {@code superSharedingKey} is specified without a {@code shardingKey} * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 + * @since 9 * @see ShardingKey * @see ShardingKeyBuilder */ @@ -1694,7 +1694,7 @@ throws SQLException; * this method is called on a closed {@code connection}; or the * {@code shardkingKey} is {@code null} * @throws SQLFeatureNotSupportedException if the driver does not support sharding - * @since 1.9 + * @since 9 * @see ShardingKey * @see ShardingKeyBuilder */ diff --git a/jdk/src/java.sql/share/classes/java/sql/ConnectionBuilder.java b/jdk/src/java.sql/share/classes/java/sql/ConnectionBuilder.java index 9025814a181..b9ddf1606ad 100644 --- a/jdk/src/java.sql/share/classes/java/sql/ConnectionBuilder.java +++ b/jdk/src/java.sql/share/classes/java/sql/ConnectionBuilder.java @@ -49,7 +49,7 @@ package java.sql; * .build(); * } * - * @since 1.9 + * @since 9 * */ public interface ConnectionBuilder { diff --git a/jdk/src/java.sql/share/classes/java/sql/DatabaseMetaData.java b/jdk/src/java.sql/share/classes/java/sql/DatabaseMetaData.java index 6c0e0bb782f..8d8c621506c 100644 --- a/jdk/src/java.sql/share/classes/java/sql/DatabaseMetaData.java +++ b/jdk/src/java.sql/share/classes/java/sql/DatabaseMetaData.java @@ -3694,7 +3694,7 @@ public interface DatabaseMetaData extends Wrapper { * @return {@code true} if this database supports sharding; * {@code false} otherwise * @exception SQLException if a database access error occurs - * @since 1.9 + * @since 9 */ default boolean supportsSharding() throws SQLException { return false; diff --git a/jdk/src/java.sql/share/classes/java/sql/DriverManager.java b/jdk/src/java.sql/share/classes/java/sql/DriverManager.java index 7f74c4c869b..331239e3733 100644 --- a/jdk/src/java.sql/share/classes/java/sql/DriverManager.java +++ b/jdk/src/java.sql/share/classes/java/sql/DriverManager.java @@ -449,7 +449,7 @@ public class DriverManager { * to which the current caller has access. * * @return the stream of JDBC Drivers loaded by the caller's class loader - * @since 1.9 + * @since 9 */ @CallerSensitive public static Stream drivers() { diff --git a/jdk/src/java.sql/share/classes/java/sql/ShardingKey.java b/jdk/src/java.sql/share/classes/java/sql/ShardingKey.java index 6dce0b27d52..db56bee084b 100644 --- a/jdk/src/java.sql/share/classes/java/sql/ShardingKey.java +++ b/jdk/src/java.sql/share/classes/java/sql/ShardingKey.java @@ -69,7 +69,7 @@ package java.sql; * } * * - * @since 1.9 + * @since 9 */ public interface ShardingKey { diff --git a/jdk/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java b/jdk/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java index c245ec78716..cbc4410907c 100644 --- a/jdk/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java +++ b/jdk/src/jdk.attach/share/classes/com/sun/tools/attach/AttachOperationFailedException.java @@ -35,7 +35,7 @@ import java.io.IOException; * fails in the target VM. If there is a communication error, * a regular IOException will be thrown. * - * @since 1.9 + * @since 9 */ public class AttachOperationFailedException extends IOException { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/CipherContextRef.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/CipherContextRef.java index 1ecdda7812e..ab42015e20a 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/CipherContextRef.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/CipherContextRef.java @@ -41,7 +41,7 @@ import javax.crypto.spec.IvParameterSpec; /** * Internal class for context resource clean up. * - * @since 1.9 + * @since 9 */ final class CipherContextRef extends PhantomReference implements Comparable { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java index 7d07103a289..e9abf1a73ec 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java @@ -49,7 +49,7 @@ import sun.security.util.PropertyExpander; * where can be "MessageDigest", "Cipher", etc. and * reprepresents the value that's passed into the various getInstance() calls. * - * @since 1.9 + * @since 9 */ final class Config { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java index fc7ada58e6a..c0aa5db2067 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java @@ -48,7 +48,7 @@ import sun.security.util.*; * as possible AES-GCM-ICVlen values, so we allow all 6 values. * * - * @since 1.9 + * @since 9 */ public final class GCMParameters extends AlgorithmParametersSpi { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java index af7767924a3..5699b5e734f 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java @@ -48,7 +48,7 @@ import sun.security.jca.JCAUtil; * - AES/CFB128/NOPADDING * (Support for GCM mode is inside the child class NativeGCMCipher) * - * @since 1.9 + * @since 9 */ class NativeCipher extends CipherSpi { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java index 0bea2d08eb8..4d36710ab0d 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java @@ -59,7 +59,7 @@ import javax.crypto.spec.IvParameterSpec; * - AES/CBC/PKCS5PADDING * - AES/CFB128/PKCS5PADDING * - * @since 1.9 + * @since 9 */ public class NativeCipherWithJavaPadding extends CipherSpi { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeDigest.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeDigest.java index 80397ca222f..9c0929a95b2 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeDigest.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeDigest.java @@ -36,7 +36,7 @@ import java.security.*; * MessageDigest implementation class. This class currently supports * MD5, SHA1, SHA256, SHA384, and SHA512 * - * @since 1.9 + * @since 9 */ public abstract class NativeDigest extends MessageDigestSpi implements Cloneable { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java index 10913cb3c06..ca23f877772 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java @@ -42,7 +42,7 @@ import sun.security.jca.JCAUtil; * Cipher wrapper class utilizing ucrypto APIs. This class currently supports * - AES/GCM/NoPADDING * - * @since 1.9 + * @since 9 */ class NativeGCMCipher extends NativeCipher { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java index 69409809860..a4a8866f30b 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java @@ -39,7 +39,7 @@ import java.security.spec.*; * Wrapper class for native keys needed for using ucrypto APIs. * This class currently supports native RSA private/public keys. * - * @since 1.9 + * @since 9 */ abstract class NativeKey implements Key { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java index 4b4e408e42d..a5b489ec380 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java @@ -72,7 +72,7 @@ import sun.security.util.KeyUtil; * - RSA/ECB/NOPADDING * - RSA/ECB/PKCS1PADDING * - * @since 1.9 + * @since 9 */ public class NativeRSACipher extends CipherSpi { // fields set in constructor diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java index 750cc41bc08..d92a22c61b0 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java @@ -44,7 +44,7 @@ import java.security.spec.*; * Ucrypto-private KeyFactory class for generating native keys * needed for using ucrypto APIs. * - * @since 1.9 + * @since 9 */ public final class NativeRSAKeyFactory extends KeyFactorySpi { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java index f1fe8e58c1b..6a2007ae9ef 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java @@ -59,7 +59,7 @@ import java.nio.ByteBuffer; * . SHA384withRSA * . SHA512withRSA * - * @since 1.9 + * @since 9 */ class NativeRSASignature extends SignatureSpi { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java index 8ef10f8be67..0ba6c198ed3 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java @@ -33,7 +33,7 @@ import java.security.ProviderException; * object of this class indicates that a function call to the underlying * native calls returned a value not equal to CRYPTO_SUCCESS. * - * @since 1.9 + * @since 9 */ public final class UcryptoException extends ProviderException { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java index f1597e3e4a2..cb6b4ffe597 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java @@ -30,7 +30,7 @@ import java.util.HashMap; /** * Enum for representing the ucrypto mechanisms. * - * @since 1.9 + * @since 9 */ // Check /usr/include/libsoftcrypto.h for updates public enum UcryptoMech { diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java index 1c976065697..e3595359019 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java @@ -33,7 +33,7 @@ import java.security.*; /** * OracleUcrypto provider main class. * - * @since 1.9 + * @since 9 */ public final class UcryptoProvider extends Provider { diff --git a/jdk/src/jdk.jartool/share/classes/com/sun/jarsigner/ContentSignerParameters.java b/jdk/src/jdk.jartool/share/classes/com/sun/jarsigner/ContentSignerParameters.java index e761a2c9205..a2cb8d70253 100644 --- a/jdk/src/jdk.jartool/share/classes/com/sun/jarsigner/ContentSignerParameters.java +++ b/jdk/src/jdk.jartool/share/classes/com/sun/jarsigner/ContentSignerParameters.java @@ -73,7 +73,7 @@ public interface ContentSignerParameters { * Retreives the message digest algorithm that is used to generate * the message imprint to be sent to the TSA server. * - * @since 1.9 + * @since 9 * @return The non-null string of the message digest algorithm name. */ public default String getTSADigestAlg() { diff --git a/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java b/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java index a25ff87513c..d74edd570e8 100644 --- a/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java +++ b/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java @@ -77,7 +77,7 @@ import java.util.zip.ZipOutputStream; * } * * - * @since 1.9 + * @since 9 */ public final class JarSigner { @@ -85,7 +85,7 @@ public final class JarSigner { * A mutable builder class that can create an immutable {@code JarSigner} * from various signing-related parameters. * - * @since 1.9 + * @since 9 */ public static class Builder { diff --git a/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSignerException.java b/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSignerException.java index d1b5449dbef..ded5734a852 100644 --- a/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSignerException.java +++ b/jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSignerException.java @@ -28,7 +28,7 @@ package jdk.security.jarsigner; /** * This exception is thrown when {@link JarSigner#sign} fails. * - * @since 1.9 + * @since 9 */ public class JarSignerException extends RuntimeException { diff --git a/jdk/src/jdk.management/share/classes/com/sun/management/VMOption.java b/jdk/src/jdk.management/share/classes/com/sun/management/VMOption.java index 4d9290035ef..72e2870532e 100644 --- a/jdk/src/jdk.management/share/classes/com/sun/management/VMOption.java +++ b/jdk/src/jdk.management/share/classes/com/sun/management/VMOption.java @@ -96,7 +96,7 @@ public class VMOption { ERGONOMIC, /** * The VM option was set using the attach framework. - * @since 1.9 + * @since 9 */ ATTACH_ON_DEMAND, /** diff --git a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/InquireType.java b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/InquireType.java index 5ba482dbd6e..6240f0d3ddf 100644 --- a/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/InquireType.java +++ b/jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss/InquireType.java @@ -40,7 +40,7 @@ public enum InquireType { *
  • Format: "RAW" *
  • Encoded form: the raw key bytes, not in any ASN.1 encoding * - * @deprecated as of 1.9, replaced by {@link #KRB5_GET_SESSION_KEY_EX} + * @deprecated as of 9, replaced by {@link #KRB5_GET_SESSION_KEY_EX} * which returns an instance of * {@link javax.security.auth.kerberos.EncryptionKey} * that implements the {@link javax.crypto.SecretKey} interface and @@ -53,7 +53,7 @@ public enum InquireType { * established Kerberos 5 security context. The return value is an * instance of {@link javax.security.auth.kerberos.EncryptionKey}. * - * @since 1.9 + * @since 9 */ KRB5_GET_SESSION_KEY_EX, /** @@ -83,7 +83,7 @@ public enum InquireType { * is about to send to an acceptor. The return type is an instance of * {@link javax.security.auth.kerberos.KerberosCredMessage}. * - * @since 1.9 + * @since 9 */ KRB5_GET_KRB_CRED, } diff --git a/jdk/test/lib/testlibrary/ExtendedRobot.java b/jdk/test/lib/testlibrary/ExtendedRobot.java index 1e33c7d0d0c..778cd9e6cd3 100644 --- a/jdk/test/lib/testlibrary/ExtendedRobot.java +++ b/jdk/test/lib/testlibrary/ExtendedRobot.java @@ -48,7 +48,7 @@ import java.awt.event.KeyEvent; * * * @author Dmitriy Ermashov - * @since 1.9 + * @since 9 */ public class ExtendedRobot extends Robot { From 3cc90f5cd6b7a580b2f463fe71ca1eb325505f2d Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 21 Jan 2016 09:26:13 +0000 Subject: [PATCH 104/109] 8147922: Remove sun.misc.ClassFileTransformer Reviewed-by: alanb, mchung --- .../sun/misc/ClassFileTransformer.java | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/sun/misc/ClassFileTransformer.java diff --git a/jdk/src/java.base/share/classes/sun/misc/ClassFileTransformer.java b/jdk/src/java.base/share/classes/sun/misc/ClassFileTransformer.java deleted file mode 100644 index 06a195987c8..00000000000 --- a/jdk/src/java.base/share/classes/sun/misc/ClassFileTransformer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package sun.misc; - -import java.util.ArrayList; -import java.util.List; - -/** - * This is an abstract base class originally intended to be called by - * {@code java.lang.ClassLoader} when {@code ClassFormatError} is - * thrown inside {@code defineClass()}. It is no longer hooked into - * {@code ClassLoader} and will be removed in a future release. - * - * @author Stanley Man-Kit Ho - */ - -@Deprecated -public abstract class ClassFileTransformer { - - private static final List transformers - = new ArrayList(); - - /** - * Add the class file transformer object. - * - * @param t Class file transformer instance - */ - public static void add(ClassFileTransformer t) { - synchronized (transformers) { - transformers.add(t); - } - } - - /** - * Get the array of ClassFileTransformer object. - * - * @return ClassFileTransformer object array - */ - public static ClassFileTransformer[] getTransformers() { - synchronized (transformers) { - ClassFileTransformer[] result = new ClassFileTransformer[transformers.size()]; - return transformers.toArray(result); - } - } - - - /** - * Transform a byte array from one to the other. - * - * @param b Byte array - * @param off Offset - * @param len Length of byte array - * @return Transformed byte array - */ - public abstract byte[] transform(byte[] b, int off, int len) - throws ClassFormatError; -} From 08694bb7e1ba77cc4a8eedca74211433d21539d0 Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Thu, 21 Jan 2016 09:33:23 +0000 Subject: [PATCH 105/109] 8064330: Remove SHA224 from the default support list if SunMSCAPI enabled Reviewed-by: xuelei --- .../ssl/SignatureAndHashAlgorithm.java | 83 ++++++++++--------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java index 59568562a3c..66192211198 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java @@ -166,13 +166,10 @@ final class SignatureAndHashAlgorithm { // Get supported algorithm collection from an untrusted collection static Collection getSupportedAlgorithms( - AlgorithmConstraints constraints, Collection algorithms ) { Collection supported = new ArrayList<>(); for (SignatureAndHashAlgorithm sigAlg : algorithms) { - if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && - constraints.permits(SIGNATURE_PRIMITIVE_SET, - sigAlg.algorithm, null)) { + if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { supported.add(sigAlg); } } @@ -236,42 +233,30 @@ final class SignatureAndHashAlgorithm { } static SignatureAndHashAlgorithm getPreferableAlgorithm( - Collection algorithms, - String expected, PrivateKey signingKey) { + Collection algorithms, + String expected, PrivateKey signingKey) { - int maxDigestLength = getMaxDigestLength(signingKey); - for (SignatureAndHashAlgorithm algorithm : algorithms) { - int signValue = algorithm.id & 0xFF; - if ((expected == null) || - (expected.equalsIgnoreCase("rsa") && - signValue == SignatureAlgorithm.RSA.value) || - (expected.equalsIgnoreCase("dsa") && - signValue == SignatureAlgorithm.DSA.value) || - (expected.equalsIgnoreCase("ecdsa") && - signValue == SignatureAlgorithm.ECDSA.value) || - (expected.equalsIgnoreCase("ec") && - signValue == SignatureAlgorithm.ECDSA.value)) { - - if (algorithm.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && - algorithm.hash.length <= maxDigestLength) { - - return algorithm; + if (expected == null && !algorithms.isEmpty()) { + for (SignatureAndHashAlgorithm sigAlg : algorithms) { + if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { + return sigAlg; } } + + return null; // no supported algorithm } - return null; - } + if (expected == null ) { + return null; // no expected algorithm, no supported algorithm + } - /* - * Need to check key length to match the length of hash value - */ - private static int getMaxDigestLength(PrivateKey signingKey) { + /* + * Need to check RSA key length to match the length of hash value + */ int maxDigestLength = Integer.MAX_VALUE; - - // only need to check RSA algorithm at present. if (signingKey != null && - "rsa".equalsIgnoreCase(signingKey.getAlgorithm())) { + "rsa".equalsIgnoreCase(signingKey.getAlgorithm()) && + expected.equalsIgnoreCase("rsa")) { /* * RSA keys of 512 bits have been shown to be practically * breakable, it does not make much sense to use the strong @@ -299,7 +284,25 @@ final class SignatureAndHashAlgorithm { // preferable hash algorithm. } - return maxDigestLength; + for (SignatureAndHashAlgorithm algorithm : algorithms) { + int signValue = algorithm.id & 0xFF; + if (expected.equalsIgnoreCase("rsa") && + signValue == SignatureAlgorithm.RSA.value) { + if (algorithm.hash.length <= maxDigestLength) { + return algorithm; + } + } else if ( + (expected.equalsIgnoreCase("dsa") && + signValue == SignatureAlgorithm.DSA.value) || + (expected.equalsIgnoreCase("ecdsa") && + signValue == SignatureAlgorithm.ECDSA.value) || + (expected.equalsIgnoreCase("ec") && + signValue == SignatureAlgorithm.ECDSA.value)) { + return algorithm; + } + } + + return null; } static enum HashAlgorithm { @@ -412,12 +415,14 @@ final class SignatureAndHashAlgorithm { supports(HashAlgorithm.SHA1, SignatureAlgorithm.ECDSA, "SHA1withECDSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.DSA, - "SHA224withDSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.RSA, - "SHA224withRSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.ECDSA, - "SHA224withECDSA", --p); + if (Security.getProvider("SunMSCAPI") == null) { + supports(HashAlgorithm.SHA224, SignatureAlgorithm.DSA, + "SHA224withDSA", --p); + supports(HashAlgorithm.SHA224, SignatureAlgorithm.RSA, + "SHA224withRSA", --p); + supports(HashAlgorithm.SHA224, SignatureAlgorithm.ECDSA, + "SHA224withECDSA", --p); + } supports(HashAlgorithm.SHA256, SignatureAlgorithm.DSA, "SHA256withDSA", --p); From 9ed7f823140cd2dfe979afa51a75c8a999f44ee4 Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Thu, 21 Jan 2016 10:31:45 +0000 Subject: [PATCH 106/109] 8147931: Incorrect edits for JDK-8064330 Reviewed-by: coffeys --- .../ssl/SignatureAndHashAlgorithm.java | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java index 66192211198..8445a665da3 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java @@ -166,10 +166,13 @@ final class SignatureAndHashAlgorithm { // Get supported algorithm collection from an untrusted collection static Collection getSupportedAlgorithms( + AlgorithmConstraints constraints, Collection algorithms ) { Collection supported = new ArrayList<>(); for (SignatureAndHashAlgorithm sigAlg : algorithms) { - if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { + if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && + constraints.permits(SIGNATURE_PRIMITIVE_SET, + sigAlg.algorithm, null)) { supported.add(sigAlg); } } @@ -233,30 +236,42 @@ final class SignatureAndHashAlgorithm { } static SignatureAndHashAlgorithm getPreferableAlgorithm( - Collection algorithms, - String expected, PrivateKey signingKey) { + Collection algorithms, + String expected, PrivateKey signingKey) { - if (expected == null && !algorithms.isEmpty()) { - for (SignatureAndHashAlgorithm sigAlg : algorithms) { - if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM) { - return sigAlg; + int maxDigestLength = getMaxDigestLength(signingKey); + for (SignatureAndHashAlgorithm algorithm : algorithms) { + int signValue = algorithm.id & 0xFF; + if ((expected == null) || + (expected.equalsIgnoreCase("rsa") && + signValue == SignatureAlgorithm.RSA.value) || + (expected.equalsIgnoreCase("dsa") && + signValue == SignatureAlgorithm.DSA.value) || + (expected.equalsIgnoreCase("ecdsa") && + signValue == SignatureAlgorithm.ECDSA.value) || + (expected.equalsIgnoreCase("ec") && + signValue == SignatureAlgorithm.ECDSA.value)) { + + if (algorithm.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM && + algorithm.hash.length <= maxDigestLength) { + + return algorithm; } } - - return null; // no supported algorithm } - if (expected == null ) { - return null; // no expected algorithm, no supported algorithm - } + return null; + } - /* - * Need to check RSA key length to match the length of hash value - */ + /* + * Need to check key length to match the length of hash value + */ + private static int getMaxDigestLength(PrivateKey signingKey) { int maxDigestLength = Integer.MAX_VALUE; + + // only need to check RSA algorithm at present. if (signingKey != null && - "rsa".equalsIgnoreCase(signingKey.getAlgorithm()) && - expected.equalsIgnoreCase("rsa")) { + "rsa".equalsIgnoreCase(signingKey.getAlgorithm())) { /* * RSA keys of 512 bits have been shown to be practically * breakable, it does not make much sense to use the strong @@ -284,25 +299,7 @@ final class SignatureAndHashAlgorithm { // preferable hash algorithm. } - for (SignatureAndHashAlgorithm algorithm : algorithms) { - int signValue = algorithm.id & 0xFF; - if (expected.equalsIgnoreCase("rsa") && - signValue == SignatureAlgorithm.RSA.value) { - if (algorithm.hash.length <= maxDigestLength) { - return algorithm; - } - } else if ( - (expected.equalsIgnoreCase("dsa") && - signValue == SignatureAlgorithm.DSA.value) || - (expected.equalsIgnoreCase("ecdsa") && - signValue == SignatureAlgorithm.ECDSA.value) || - (expected.equalsIgnoreCase("ec") && - signValue == SignatureAlgorithm.ECDSA.value)) { - return algorithm; - } - } - - return null; + return maxDigestLength; } static enum HashAlgorithm { From c0662e94e8f3cd1eb7219cddbcd73e27e6bf3267 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Thu, 21 Jan 2016 09:15:31 -0800 Subject: [PATCH 107/109] 8138990: Implementation of HTTP Digest authentication may be more flexible Reviewed-by: michaelm --- .../protocol/http/DigestAuthentication.java | 11 +- .../http/HttpURLConnection/DigestAuth.java | 424 ++++++++++++++++++ 2 files changed, 429 insertions(+), 6 deletions(-) create mode 100644 jdk/test/sun/net/www/http/HttpURLConnection/DigestAuth.java diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java index 51268080884..32fe64c609e 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,6 @@ import java.net.URL; import java.net.ProtocolException; import java.net.PasswordAuthentication; import java.util.Arrays; -import java.util.StringTokenizer; import java.util.Random; import sun.net.www.HeaderParser; @@ -146,9 +145,9 @@ class DigestAuthentication extends AuthenticationInfo { synchronized void setQop (String qop) { if (qop != null) { - StringTokenizer st = new StringTokenizer (qop, " "); - while (st.hasMoreTokens()) { - if (st.nextToken().equalsIgnoreCase ("auth")) { + String items[] = qop.split(","); + for (String item : items) { + if ("auth".equalsIgnoreCase(item.trim())) { serverQop = true; return; } @@ -163,7 +162,7 @@ class DigestAuthentication extends AuthenticationInfo { synchronized String getNonce () { return nonce;} synchronized void setNonce (String s) { - if (!s.equals(nonce)) { + if (nonce == null || !s.equals(nonce)) { nonce=s; NCcount = 0; redoCachedHA1 = true; diff --git a/jdk/test/sun/net/www/http/HttpURLConnection/DigestAuth.java b/jdk/test/sun/net/www/http/HttpURLConnection/DigestAuth.java new file mode 100644 index 00000000000..11d6729ae21 --- /dev/null +++ b/jdk/test/sun/net/www/http/HttpURLConnection/DigestAuth.java @@ -0,0 +1,424 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.InputStream; +import java.net.Authenticator; +import java.net.InetSocketAddress; +import java.net.PasswordAuthentication; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; + +/* + * @test + * @bug 8138990 + * @summary Tests for HTTP Digest auth + * The impl maintains a cache for auth info, + * the testcases run in a separate JVM to avoid cache hits + * @run main/othervm DigestAuth good + * @run main/othervm DigestAuth only_nonce + * @run main/othervm DigestAuth sha1 + * @run main/othervm DigestAuth no_header + * @run main/othervm DigestAuth no_nonce + * @run main/othervm DigestAuth no_qop + * @run main/othervm DigestAuth invalid_alg + * @run main/othervm DigestAuth validate_server + * @run main/othervm DigestAuth validate_server_no_qop + */ +public class DigestAuth { + + static final String LOCALHOST = "localhost"; + static final String EXPECT_FAILURE = null; + static final String EXPECT_DIGEST = "Digest"; + static final String REALM = "testrealm@host.com"; + static final String NEXT_NONCE = "40f2e879449675f288476d772627370a"; + + static final String GOOD_WWW_AUTH_HEADER = "Digest " + + "realm=\"testrealm@host.com\", " + + "qop=\"auth,auth-int\", " + + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + + "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\""; + + static final String GOOD_WWW_AUTH_HEADER_NO_QOP = "Digest " + + "realm=\"testrealm@host.com\", " + + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + + "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\""; + + static final String WWW_AUTH_HEADER_NO_NONCE = "Digest " + + "realm=\"testrealm@host.com\", " + + "qop=\"auth,auth-int\", " + + "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\""; + + static final String WWW_AUTH_HEADER_NO_QOP = "Digest " + + "realm=\"testrealm@host.com\", " + + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + + "opaque=\"5ccc069c403ebaf9f0171e9517f40e41\""; + + static final String WWW_AUTH_HEADER_ONLY_NONCE = "Digest " + + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\""; + + static final String WWW_AUTH_HEADER_SHA1 = "Digest " + + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + + "algorithm=\"SHA1\""; + + static final String WWW_AUTH_HEADER_INVALID_ALGORITHM = "Digest " + + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + + "algorithm=\"SHA123\""; + + static final String AUTH_INFO_HEADER_NO_QOP_FIRST = + "nextnonce=\"" + NEXT_NONCE + "\", " + + "rspauth=\"ee85bc4315d8b18757809f1a8b9382d8\""; + + static final String AUTH_INFO_HEADER_NO_QOP_SECOND = + "rspauth=\"12f2fa12841b3775b6054576722446b2\""; + + static final String AUTH_INFO_HEADER_WRONG_DIGEST = + "nextnonce=\"" + NEXT_NONCE + "\", " + + "rspauth=\"7327570c586207eca2afae94fc20903d\", " + + "cnonce=\"0a4f113b\", " + + "nc=00000001, " + + "qop=auth"; + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + throw new RuntimeException("No testcase specified"); + } + String testcase = args[0]; + + // start a local HTTP server + try (LocalHttpServer server = LocalHttpServer.startServer()) { + + // set authenticator + AuthenticatorImpl auth = new AuthenticatorImpl(); + Authenticator.setDefault(auth); + + String url = String.format("http://%s:%d/test/", + LOCALHOST, server.getPort()); + + boolean success = true; + switch (testcase) { + case "good": + // server returns a good WWW-Authenticate header + server.setWWWAuthHeader(GOOD_WWW_AUTH_HEADER); + success = testAuth(url, auth, EXPECT_DIGEST); + if (auth.lastRequestedPrompt == null || + !auth.lastRequestedPrompt.equals(REALM)) { + System.out.println("Unexpected realm: " + + auth.lastRequestedPrompt); + success = false; + } + break; + case "validate_server": + // enable processing Authentication-Info headers + System.setProperty("http.auth.digest.validateServer", + "true"); + + /* Server returns good WWW-Authenticate + * and Authentication-Info headers with wrong digest + */ + server.setWWWAuthHeader(GOOD_WWW_AUTH_HEADER); + server.setAuthInfoHeader(AUTH_INFO_HEADER_WRONG_DIGEST); + success = testAuth(url, auth, EXPECT_FAILURE); + if (auth.lastRequestedPrompt == null || + !auth.lastRequestedPrompt.equals(REALM)) { + System.out.println("Unexpected realm: " + + auth.lastRequestedPrompt); + success = false; + } + break; + case "validate_server_no_qop": + // enable processing Authentication-Info headers + System.setProperty("http.auth.digest.validateServer", + "true"); + + /* Server returns good both WWW-Authenticate + * and Authentication-Info headers without any qop field, + * so that client-nonce should not be taked into account, + * and connection should succeed. + */ + server.setWWWAuthHeader(GOOD_WWW_AUTH_HEADER_NO_QOP); + server.setAuthInfoHeader(AUTH_INFO_HEADER_NO_QOP_FIRST); + success = testAuth(url, auth, EXPECT_DIGEST); + if (auth.lastRequestedPrompt == null || + !auth.lastRequestedPrompt.equals(REALM)) { + System.out.println("Unexpected realm: " + + auth.lastRequestedPrompt); + success = false; + } + + // connect again and check if nextnonce was used + server.setAuthInfoHeader(AUTH_INFO_HEADER_NO_QOP_SECOND); + success &= testAuth(url, auth, EXPECT_DIGEST); + if (!NEXT_NONCE.equals(server.lastRequestedNonce)) { + System.out.println("Unexpected next nonce: " + + server.lastRequestedNonce); + success = false; + } + break; + case "only_nonce": + /* Server returns a good WWW-Authenticate header + * which contains only nonce (no realm set). + * + * Realm from WWW-Authenticate header is passed to + * authenticator which can use it as a prompt + * when it asks a user for credentials. + * + * It's fine if an HTTP client doesn't fail if no realm set, + * and delegates making a decision to authenticator/user. + */ + server.setWWWAuthHeader(WWW_AUTH_HEADER_ONLY_NONCE); + success = testAuth(url, auth, EXPECT_DIGEST); + if (auth.lastRequestedPrompt != null && + !auth.lastRequestedPrompt.trim().isEmpty()) { + System.out.println("Unexpected realm: " + + auth.lastRequestedPrompt); + success = false; + } + break; + case "sha1": + // server returns a good WWW-Authenticate header with SHA-1 + server.setWWWAuthHeader(WWW_AUTH_HEADER_SHA1); + success = testAuth(url, auth, EXPECT_DIGEST); + break; + case "no_header": + // server returns no WWW-Authenticate header + success = testAuth(url, auth, EXPECT_FAILURE); + if (auth.lastRequestedScheme != null) { + System.out.println("Unexpected scheme: " + + auth.lastRequestedScheme); + success = false; + } + break; + case "no_nonce": + // server returns a wrong WWW-Authenticate header (no nonce) + server.setWWWAuthHeader(WWW_AUTH_HEADER_NO_NONCE); + success = testAuth(url, auth, EXPECT_FAILURE); + break; + case "invalid_alg": + // server returns a wrong WWW-Authenticate header + // (invalid hash algorithm) + server.setWWWAuthHeader(WWW_AUTH_HEADER_INVALID_ALGORITHM); + success = testAuth(url, auth, EXPECT_FAILURE); + break; + case "no_qop": + // server returns a good WWW-Authenticate header + // without QOPs + server.setWWWAuthHeader(WWW_AUTH_HEADER_NO_QOP); + success = testAuth(url, auth, EXPECT_DIGEST); + break; + default: + throw new RuntimeException("Unexpected testcase: " + + testcase); + } + + if (!success) { + throw new RuntimeException("Test failed"); + } + } + + System.out.println("Test passed"); + } + + static boolean testAuth(String url, AuthenticatorImpl auth, + String expectedScheme) { + + try { + System.out.printf("Connect to %s, expected auth scheme is '%s'%n", + url, expectedScheme); + load(url); + + if (expectedScheme == null) { + System.out.println("Unexpected successful connection"); + return false; + } + + System.out.printf("Actual auth scheme is '%s'%n", + auth.lastRequestedScheme); + if (!expectedScheme.equalsIgnoreCase(auth.lastRequestedScheme)) { + System.out.println("Unexpected auth scheme"); + return false; + } + } catch (IOException e) { + if (expectedScheme != null) { + System.out.println("Unexpected exception: " + e); + e.printStackTrace(System.out); + return false; + } + System.out.println("Expected exception: " + e); + } + + return true; + } + + static void load(String url) throws IOException { + URLConnection conn = new URL(url).openConnection(); + conn.setUseCaches(false); + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(conn.getInputStream()))) { + + String line = reader.readLine(); + if (line == null) { + throw new IOException("Couldn't read response"); + } + do { + System.out.println(line); + } while ((line = reader.readLine()) != null); + } + } + + private static class AuthenticatorImpl extends Authenticator { + + private String lastRequestedScheme; + private String lastRequestedPrompt; + + @Override + public PasswordAuthentication getPasswordAuthentication() { + lastRequestedScheme = getRequestingScheme(); + lastRequestedPrompt = getRequestingPrompt(); + System.out.println("AuthenticatorImpl: requested " + + lastRequestedScheme); + + return new PasswordAuthentication("Mufasa", + "Circle Of Life".toCharArray()); + } + } + + // local HTTP server which pretends to support HTTP Digest auth + static class LocalHttpServer implements HttpHandler, AutoCloseable { + + private final HttpServer server; + private volatile String wwwAuthHeader = null; + private volatile String authInfoHeader = null; + private volatile String lastRequestedNonce; + + private LocalHttpServer(HttpServer server) { + this.server = server; + } + + void setWWWAuthHeader(String wwwAuthHeader) { + this.wwwAuthHeader = wwwAuthHeader; + } + + void setAuthInfoHeader(String authInfoHeader) { + this.authInfoHeader = authInfoHeader; + } + + static LocalHttpServer startServer() throws IOException { + HttpServer httpServer = HttpServer.create( + new InetSocketAddress(0), 0); + LocalHttpServer localHttpServer = new LocalHttpServer(httpServer); + localHttpServer.start(); + + return localHttpServer; + } + + void start() { + server.createContext("/test", this); + server.start(); + System.out.println("HttpServer: started on port " + getPort()); + } + + void stop() { + server.stop(0); + System.out.println("HttpServer: stopped"); + } + + int getPort() { + return server.getAddress().getPort(); + } + + @Override + public void handle(HttpExchange t) throws IOException { + System.out.println("HttpServer: handle connection"); + + // read a request + try (InputStream is = t.getRequestBody()) { + while (is.read() > 0); + } + + try { + List headers = t.getRequestHeaders() + .get("Authorization"); + String header = ""; + if (headers != null && !headers.isEmpty()) { + header = headers.get(0).trim().toLowerCase(); + } + if (header.startsWith("digest")) { + if (authInfoHeader != null) { + t.getResponseHeaders().add("Authentication-Info", + authInfoHeader); + } + lastRequestedNonce = findParameter(header, "nonce"); + byte[] output = "hello".getBytes(); + t.sendResponseHeaders(200, output.length); + t.getResponseBody().write(output); + System.out.println("HttpServer: return 200"); + } else { + if (wwwAuthHeader != null) { + t.getResponseHeaders().add( + "WWW-Authenticate", wwwAuthHeader); + } + byte[] output = "forbidden".getBytes(); + t.sendResponseHeaders(401, output.length); + t.getResponseBody().write(output); + System.out.println("HttpServer: return 401"); + } + } catch (IOException e) { + System.out.println("HttpServer: exception: " + e); + System.out.println("HttpServer: return 500"); + t.sendResponseHeaders(500, 0); + } finally { + t.close(); + } + } + + private static String findParameter(String header, String name) { + name = name.toLowerCase(); + if (header != null) { + String[] params = header.split("\\s"); + for (String param : params) { + param = param.trim().toLowerCase(); + if (param.startsWith(name)) { + String[] parts = param.split("="); + if (parts.length > 1) { + return parts[1] + .replaceAll("\"", "").replaceAll(",", ""); + } + } + } + } + return null; + } + + @Override + public void close() { + stop(); + } + } +} From fa2f198c1adedb19cb8c09626d3ed3b13280ce63 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 21:12:06 +0200 Subject: [PATCH 108/109] Added tag jdk-9+101 for changeset 80f67512daa1 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index b5ffdaee57d..744ce58f2fe 100644 --- a/.hgtags +++ b/.hgtags @@ -343,3 +343,4 @@ f242d4332f563648426a1b0fa02d8741beba19ef jdk9-b92 d00ad2d9049ac60815f70bff445e95df85648bd2 jdk-9+98 f9bcdce2df26678c3fe468130b535c0342c69b89 jdk-9+99 4379223f8806626852c46c52d4e7a27a584b406e jdk-9+100 +80f67512daa15cf37b4825c1c62a675d524d7c49 jdk-9+101 From 4b50f0d923f3584cace7bf316c82dcfa0455d12c Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 21 Jan 2016 09:46:03 -0800 Subject: [PATCH 109/109] Added tag jdk-9+102 for changeset 93b315c61ca3 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 20eb3f6d94f..9f1d47685fb 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -344,3 +344,4 @@ f86ee68d1107dad41a27efc34306e0e56244a12e jdk-9+98 e1a789be1535741274c9779f4d4ca3495196b5c3 jdk-9+99 3d452840f48299a36842760d17c0c8402f0e1266 jdk-9+100 5e8370fb3ed925335164afe340d1e54beab2d4d5 jdk-9+101 +6eb3c8132e489dab81adde4ce29844904ce15482 jdk-9+102