From d109f68ebd657de9ad523d6d8e634e49963c67fb Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Wed, 27 Jul 2016 02:23:16 +0000 Subject: [PATCH 001/154] 8151465: SSLSession may not return a valid chain Reviewed-by: mullan, ahgross --- .../share/classes/com/sun/net/ssl/HttpsURLConnection.java | 4 ++++ .../classes/javax/net/ssl/HandshakeCompletedEvent.java | 8 +++++++- .../share/classes/javax/net/ssl/HttpsURLConnection.java | 5 ++++- .../java.base/share/classes/javax/net/ssl/SSLSession.java | 8 +++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java b/jdk/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java index d376fc395fe..895b17ac578 100644 --- a/jdk/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java +++ b/jdk/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java @@ -69,6 +69,10 @@ class HttpsURLConnection extends HttpURLConnection /** * Returns the server's X.509 certificate chain, or null if * the server did not authenticate. + *

+ * Note: The returned value may not be a valid certificate chain + * and should not be relied on for trust decisions. + * * @return the server certificate chain */ public abstract Certificate[] getServerCertificates() diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/HandshakeCompletedEvent.java b/jdk/src/java.base/share/classes/javax/net/ssl/HandshakeCompletedEvent.java index 1317f0021f4..67e8d7548a7 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/HandshakeCompletedEvent.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/HandshakeCompletedEvent.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 @@ -120,6 +120,9 @@ public class HandshakeCompletedEvent extends EventObject * Note: This method can be used only when using certificate-based * cipher suites; using it with non-certificate-based cipher suites, * such as Kerberos, will throw an SSLPeerUnverifiedException. + *

+ * Note: The returned value may not be a valid certificate chain + * and should not be relied on for trust decisions. * * @return an ordered array of the peer certificates, * with the peer's own certificate first followed by @@ -140,6 +143,9 @@ public class HandshakeCompletedEvent extends EventObject * Note: This method can be used only when using certificate-based * cipher suites; using it with non-certificate-based cipher suites, * such as Kerberos, will throw an SSLPeerUnverifiedException. + *

+ * Note: The returned value may not be a valid certificate chain + * and should not be relied on for trust decisions. * *

Note: this method exists for compatibility with previous * releases. New applications should use diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/HttpsURLConnection.java b/jdk/src/java.base/share/classes/javax/net/ssl/HttpsURLConnection.java index 7c775321640..7d93ef274c6 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/HttpsURLConnection.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/HttpsURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, 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 @@ -104,6 +104,9 @@ class HttpsURLConnection extends HttpURLConnection * Note: This method can be used only when using certificate-based * cipher suites; using it with non-certificate-based cipher suites, * such as Kerberos, will throw an SSLPeerUnverifiedException. + *

+ * Note: The returned value may not be a valid certificate chain + * and should not be relied on for trust decisions. * * @return an ordered array of server certificates, * with the peer's own certificate first followed by diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSession.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSession.java index 2a04e159728..a355d187889 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSession.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSession.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 @@ -219,6 +219,9 @@ public interface SSLSession { * Note: This method can be used only when using certificate-based * cipher suites; using it with non-certificate-based cipher suites, * such as Kerberos, will throw an SSLPeerUnverifiedException. + *

+ * Note: The returned value may not be a valid certificate chain + * and should not be relied on for trust decisions. * * @return an ordered array of peer certificates, * with the peer's own certificate first followed by any @@ -259,6 +262,9 @@ public interface SSLSession { * Note: This method can be used only when using certificate-based * cipher suites; using it with non-certificate-based cipher suites, * such as Kerberos, will throw an SSLPeerUnverifiedException. + *

+ * Note: The returned value may not be a valid certificate chain + * and should not be relied on for trust decisions. * *

Note: this method exists for compatibility with previous * releases. New applications should use From 60cfb25bfee129e130ec1a496c38b4cfbe8913e1 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 28 Jul 2016 10:13:12 +0100 Subject: [PATCH 002/154] 8151934: Resolve class resolution Reviewed-by: alanb, skoivu --- .../classes/java/net/URLClassLoader.java | 14 ++--- .../jdk/internal/loader/URLClassPath.java | 60 +++++++++++++++---- .../jdk/internal/util/jar/JarIndex.java | 3 +- 3 files changed, 57 insertions(+), 20 deletions(-) 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 57f45027ea2..11077b4032a 100644 --- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java +++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java @@ -115,8 +115,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { if (security != null) { security.checkCreateClassLoader(); } - this.ucp = new URLClassPath(urls); this.acc = AccessController.getContext(); + this.ucp = new URLClassPath(urls, acc); } URLClassLoader(String name, URL[] urls, ClassLoader parent, @@ -127,8 +127,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { if (security != null) { security.checkCreateClassLoader(); } - this.ucp = new URLClassPath(urls); this.acc = acc; + this.ucp = new URLClassPath(urls, acc); } /** @@ -159,8 +159,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { if (security != null) { security.checkCreateClassLoader(); } - this.ucp = new URLClassPath(urls); this.acc = AccessController.getContext(); + this.ucp = new URLClassPath(urls, acc); } URLClassLoader(URL[] urls, AccessControlContext acc) { @@ -170,8 +170,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { if (security != null) { security.checkCreateClassLoader(); } - this.ucp = new URLClassPath(urls); this.acc = acc; + this.ucp = new URLClassPath(urls, acc); } /** @@ -203,8 +203,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { if (security != null) { security.checkCreateClassLoader(); } - this.ucp = new URLClassPath(urls, factory); this.acc = AccessController.getContext(); + this.ucp = new URLClassPath(urls, factory, acc); } @@ -238,8 +238,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { if (security != null) { security.checkCreateClassLoader(); } - this.ucp = new URLClassPath(urls); this.acc = AccessController.getContext(); + this.ucp = new URLClassPath(urls, acc); } /** @@ -271,8 +271,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { if (security != null) { security.checkCreateClassLoader(); } - this.ucp = new URLClassPath(urls, factory); this.acc = AccessController.getContext(); + this.ucp = new URLClassPath(urls, factory, acc); } /* A map (used as a set) to keep track of closeable local resources diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java b/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java index 695d8028068..d67c342fb0a 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java @@ -38,6 +38,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; import java.net.URLStreamHandlerFactory; +import java.security.AccessControlContext; import java.security.AccessControlException; import java.security.AccessController; import java.security.CodeSigner; @@ -83,6 +84,7 @@ public class URLClassPath { private static final String JAVA_VERSION; private static final boolean DEBUG; private static final boolean DISABLE_JAR_CHECKING; + private static final boolean DISABLE_ACC_CHECKING; static { Properties props = GetPropertyAction.privilegedGetProperties(); @@ -90,6 +92,9 @@ public class URLClassPath { DEBUG = (props.getProperty("sun.misc.URLClassPath.debug") != null); String p = props.getProperty("sun.misc.URLClassPath.disableJarChecking"); DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false; + + p = props.getProperty("jdk.net.URLClassPath.disableRestrictedPermissions"); + DISABLE_ACC_CHECKING = p != null ? p.equals("true") || p.equals("") : false; } /* The original search path of URLs. */ @@ -110,6 +115,11 @@ public class URLClassPath { /* Whether this URLClassLoader has been closed yet */ private boolean closed = false; + /* The context to be used when loading classes and resources. If non-null + * this is the context that was captured during the creation of the + * URLClassLoader. null implies no additional security restrictions. */ + private final AccessControlContext acc; + /** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL @@ -119,8 +129,12 @@ public class URLClassPath { * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs + * @param acc the context to be used when loading classes and resources, may + * be null */ - public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { + public URLClassPath(URL[] urls, + URLStreamHandlerFactory factory, + AccessControlContext acc) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } @@ -128,10 +142,22 @@ public class URLClassPath { if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } + if (DISABLE_ACC_CHECKING) + this.acc = null; + else + this.acc = acc; } + /** + * Constructs a URLClassPath with no additional security restrictions. + * Used by code that implements the class path. + */ public URLClassPath(URL[] urls) { - this(urls, null); + this(urls, null, null); + } + + public URLClassPath(URL[] urls, AccessControlContext acc) { + this(urls, null, acc); } public synchronized List closeLoaders() { @@ -356,6 +382,14 @@ public class URLClassPath { } catch (IOException e) { // Silently ignore for now... continue; + } catch (SecurityException se) { + // Always silently ignore. The context, if there is one, that + // this URLClassPath was given during construction will never + // have permission to access the URL. + if (DEBUG) { + System.err.println("Failed to access " + url + ", " + se ); + } + continue; } // Finally, add the Loader to the search path. loaders.add(loader); @@ -378,7 +412,7 @@ public class URLClassPath { && file != null && (file.indexOf("!/") == file.length() - 2)) { // extract the nested URL URL nestedUrl = new URL(file.substring(0, file.length() - 2)); - return new JarLoader(nestedUrl, jarHandler, lmap); + return new JarLoader(nestedUrl, jarHandler, lmap, acc); } else if (file != null && file.endsWith("/")) { if ("file".equals(protocol)) { return new FileLoader(url); @@ -386,10 +420,10 @@ public class URLClassPath { return new Loader(url); } } else { - return new JarLoader(url, jarHandler, lmap); + return new JarLoader(url, jarHandler, lmap, acc); } } - }); + }, acc); } catch (java.security.PrivilegedActionException pae) { throw (IOException)pae.getException(); } @@ -585,10 +619,11 @@ public class URLClassPath { */ static class JarLoader extends Loader { private JarFile jar; - private URL csu; + private final URL csu; private JarIndex index; private URLStreamHandler handler; - private HashMap lmap; + private final HashMap lmap; + private final AccessControlContext acc; private boolean closed = false; private static final JavaUtilZipFileAccess zipAccess = SharedSecrets.getJavaUtilZipFileAccess(); @@ -598,13 +633,15 @@ public class URLClassPath { * a JAR file. */ JarLoader(URL url, URLStreamHandler jarHandler, - HashMap loaderMap) + HashMap loaderMap, + AccessControlContext acc) throws IOException { super(new URL("jar", "", -1, url + "!/", jarHandler)); csu = url; handler = jarHandler; lmap = loaderMap; + this.acc = acc; ensureOpen(); } @@ -663,8 +700,7 @@ public class URLClassPath { } return null; } - } - ); + }, acc); } catch (java.security.PrivilegedActionException pae) { throw (IOException)pae.getException(); } @@ -859,9 +895,9 @@ public class URLClassPath { new PrivilegedExceptionAction<>() { public JarLoader run() throws IOException { return new JarLoader(url, handler, - lmap); + lmap, acc); } - }); + }, acc); /* this newly opened jar file has its own index, * merge it into the parent's index, taking into diff --git a/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java index 367ac31b07a..f0d14a886a5 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java +++ b/jdk/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java @@ -29,6 +29,7 @@ import java.io.*; import java.util.*; import java.util.jar.*; import java.util.zip.*; +import static sun.security.action.GetPropertyAction.privilegedGetProperty; /** * This class is used to maintain mappings from packages, classes @@ -72,7 +73,7 @@ public class JarIndex { * be added to the index. Otherwise, just the directory names are added. */ private static final boolean metaInfFilenames = - "true".equals(System.getProperty("sun.misc.JarIndex.metaInfFilenames")); + "true".equals(privilegedGetProperty("sun.misc.JarIndex.metaInfFilenames")); /** * Constructs a new, empty jar index. From 23a605ff5c0c25b126bf243b12af22fcd38f265b Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Tue, 9 Aug 2016 11:41:47 +0100 Subject: [PATCH 003/154] 8162577: Standardize logging levels Reviewed-by: mchung, rriggs, skoivu --- .../share/classes/java/util/logging/Level.java | 5 ++++- .../share/classes/java/util/logging/LogRecord.java | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.logging/share/classes/java/util/logging/Level.java b/jdk/src/java.logging/share/classes/java/util/logging/Level.java index c222a8fde25..526161bafa9 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/Level.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/Level.java @@ -692,11 +692,14 @@ public class Level implements java.io.Serializable { Level levelObject = ref.get(); if (levelObject == null) continue; Level other = ref.mirroredLevel; + Class type = levelObject.getClass(); if (l.value == other.value && (l.resourceBundleName == other.resourceBundleName || (l.resourceBundleName != null && l.resourceBundleName.equals(other.resourceBundleName)))) { - return Optional.of(levelObject); + if (type == l.getClass()) { + return Optional.of(levelObject); + } } } } 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 33b5509a566..4b88e359f7c 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, 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 @@ -619,13 +619,21 @@ public class LogRecord implements java.io.Serializable { throw new IOException("LogRecord: bad version: " + major + "." + minor); } int len = in.readInt(); - if (len == -1) { + if (len < -1) { + throw new NegativeArraySizeException(); + } else if (len == -1) { parameters = null; - } else { + } else if (len < 255) { parameters = new Object[len]; for (int i = 0; i < parameters.length; i++) { parameters[i] = in.readObject(); } + } else { + List params = new ArrayList<>(Math.min(len, 1024)); + for (int i = 0; i < len; i++) { + params.add(in.readObject()); + } + parameters = params.toArray(new Object[params.size()]); } // If necessary, try to regenerate the resource bundle. if (resourceBundleName != null) { From 8861efc7b55d05603226a22a54587a053319953c Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Fri, 12 Aug 2016 10:20:13 +0800 Subject: [PATCH 004/154] 8161743: Provide proper login context Reviewed-by: ahgross, vinnie, xuelei --- .../com/sun/security/auth/module/LdapLoginModule.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java index ff60810021b..b3743a662fd 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java @@ -418,7 +418,6 @@ public class LdapLoginModule implements LoginModule { constraints = new SearchControls(); constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); constraints.setReturningAttributes(new String[0]); //return no attrs - constraints.setReturningObjFlag(true); // to get the full DN } authzIdentity = (String)options.get(AUTHZ_IDENTITY); @@ -878,11 +877,7 @@ public class LdapLoginModule implements LoginModule { // (Use the first entry if more than one is returned) if (results.hasMore()) { SearchResult entry = results.next(); - - // %%% - use the SearchResult.getNameInNamespace method - // available in JDK 1.5 and later. - // (can remove call to constraints.setReturningObjFlag) - userDN = ((Context)entry.getObject()).getNameInNamespace(); + userDN = entry.getNameInNamespace(); if (debug) { System.out.println("\t\t[LdapLoginModule] found entry: " + From f436ae7a54a3781926f8c3c22be5f5efab6aaa29 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Fri, 12 Aug 2016 10:37:15 +0100 Subject: [PATCH 005/154] 8161228: URL objects with custom protocol handlers have port changed after deserializing Reviewed-by: chegar, rriggs, coffeys --- jdk/src/java.base/share/classes/java/net/URL.java | 3 --- 1 file changed, 3 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 145cf29d001..b029b83d7ca 100644 --- a/jdk/src/java.base/share/classes/java/net/URL.java +++ b/jdk/src/java.base/share/classes/java/net/URL.java @@ -1556,9 +1556,6 @@ public final class URL implements java.io.Serializable { path = file; } - if (port == -1) { - port = 0; - } // Set the object fields. this.protocol = protocol; this.host = host; From 5dd6d9c4ca11283c2bda7ec5ba05c52c32908e94 Mon Sep 17 00:00:00 2001 From: Harsha Wardhana B Date: Tue, 16 Aug 2016 17:05:00 +0530 Subject: [PATCH 006/154] 8158406: Limited Parameter Processing Reviewed-by: dfuchs, skoivu --- .../remote/rmi/RMIConnectionImpl.java | 67 +++++++++++++------ 1 file changed, 45 insertions(+), 22 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 c37e3e9af12..03b652a0ba7 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 @@ -347,7 +347,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { +", unwrapping parameters using classLoaderWithRepository."); values = - nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class)); + nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class,delegationSubject)); try { final Object params2[] = @@ -411,7 +411,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { values = nullIsEmpty(unwrap(params, getClassLoader(loaderName), defaultClassLoader, - Object[].class)); + Object[].class,delegationSubject)); try { final Object params2[] = @@ -522,7 +522,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); - queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); + queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject); try { final Object params[] = new Object[] { name, queryValue }; @@ -557,7 +557,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { "connectionId=" + connectionId +" unwrapping query with defaultClassLoader."); - queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); + queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject); try { final Object params[] = new Object[] { name, queryValue }; @@ -707,7 +707,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { attr = unwrap(attribute, getClassLoaderFor(name), defaultClassLoader, - Attribute.class); + Attribute.class, delegationSubject); try { final Object params[] = new Object[] { name, attr }; @@ -758,7 +758,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { unwrap(attributes, getClassLoaderFor(name), defaultClassLoader, - AttributeList.class); + AttributeList.class, delegationSubject); try { final Object params[] = new Object[] { name, attrlist }; @@ -810,7 +810,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { values = nullIsEmpty(unwrap(params, getClassLoaderFor(name), defaultClassLoader, - Object[].class)); + Object[].class, delegationSubject)); try { final Object params2[] = @@ -990,7 +990,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { filterValues[i] = unwrap(filters[i], targetCl, defaultClassLoader, - NotificationFilter.class); + NotificationFilter.class, delegationSubjects[i]); if (debug) logger.debug("addNotificationListener"+ "(ObjectName,NotificationFilter)", @@ -1058,7 +1058,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { +" unwrapping filter with target extended ClassLoader."); filterValue = - unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class); + unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject); if (debug) logger.debug("addNotificationListener"+ "(ObjectName,ObjectName,NotificationFilter,Object)", @@ -1066,7 +1066,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { +" unwrapping handback with target extended ClassLoader."); handbackValue = - unwrap(handback, targetCl, defaultClassLoader, Object.class); + unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject); try { final Object params[] = @@ -1197,7 +1197,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { +" unwrapping filter with target extended ClassLoader."); filterValue = - unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class); + unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject); if (debug) logger.debug("removeNotificationListener"+ "(ObjectName,ObjectName,NotificationFilter,Object)", @@ -1205,7 +1205,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { +" unwrapping handback with target extended ClassLoader."); handbackValue = - unwrap(handback, targetCl, defaultClassLoader, Object.class); + unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject); try { final Object params[] = @@ -1549,20 +1549,38 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { } } - private static T unwrap(final MarshalledObject mo, + private T unwrap(final MarshalledObject mo, final ClassLoader cl, - final Class wrappedClass) + final Class wrappedClass, + Subject delegationSubject) throws IOException { if (mo == null) { return null; } try { final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl)); - try { - return wrappedClass.cast(mo.get()); - } catch (ClassNotFoundException cnfe) { - throw new UnmarshalException(cnfe.toString(), cnfe); - } finally { + try{ + final AccessControlContext reqACC; + if (delegationSubject == null) + reqACC = acc; + else { + if (subject == null) { + final String msg = + "Subject delegation cannot be enabled unless " + + "an authenticated subject is put in place"; + throw new SecurityException(msg); + } + reqACC = subjectDelegator.delegatedContext( + acc, delegationSubject, removeCallerContext); + } + if(reqACC != null){ + return AccessController.doPrivileged( + (PrivilegedExceptionAction) () -> + wrappedClass.cast(mo.get()), reqACC); + }else{ + return wrappedClass.cast(mo.get()); + } + }finally{ AccessController.doPrivileged(new SetCcl(old)); } } catch (PrivilegedActionException pe) { @@ -1575,14 +1593,19 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { } logger.warning("unwrap", "Failed to unmarshall object: " + e); logger.debug("unwrap", e); + }catch (ClassNotFoundException ex) { + logger.warning("unwrap", "Failed to unmarshall object: " + ex); + logger.debug("unwrap", ex); + throw new UnmarshalException(ex.toString(), ex); } return null; } - private static T unwrap(final MarshalledObject mo, + private T unwrap(final MarshalledObject mo, final ClassLoader cl1, final ClassLoader cl2, - final Class wrappedClass) + final Class wrappedClass, + Subject delegationSubject) throws IOException { if (mo == null) { return null; @@ -1596,7 +1619,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { } } ); - return unwrap(mo, orderCL, wrappedClass); + return unwrap(mo, orderCL, wrappedClass,delegationSubject); } catch (PrivilegedActionException pe) { Exception e = extractException(pe); if (e instanceof IOException) { From 6e132741b6a1480dea4b9cfd4e8bbe1d6f0351c9 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Tue, 13 Sep 2016 00:20:17 +0000 Subject: [PATCH 007/154] 8165071: Expand TLS support Reviewed-by: jnimeh, ahgross, asmotrak --- jdk/src/java.base/share/conf/security/java.security | 9 +++++---- .../net/ssl/SSLParameters/UseCipherSuitesOrder.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index fe45e0ba06c..974dc0a839f 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -720,7 +720,7 @@ jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \ # Note: The algorithm restrictions do not apply to trust anchors or # self-signed certificates. # -# Note: This property is currently used by Oracle's JSSE implementation. +# Note: This property is currently used by the JDK Reference implementation. # It is not guaranteed to be examined and used by other implementations. # # Example: @@ -740,7 +740,7 @@ jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024, \ # During SSL/TLS security parameters negotiation, legacy algorithms will # not be negotiated unless there are no other candidates. # -# The syntax of the disabled algorithm string is described as this Java +# The syntax of the legacy algorithms string is described as this Java # BNF-style: # LegacyAlgorithms: # " LegacyAlgorithm { , LegacyAlgorithm } " @@ -776,7 +776,7 @@ jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024, \ # javax.net.ssl.SSLParameters.setAlgorithmConstraints()), # then the algorithm is completely disabled and will not be negotiated. # -# Note: This property is currently used by Oracle's JSSE implementation. +# Note: This property is currently used by the JDK Reference implementation. # It is not guaranteed to be examined and used by other implementations. # There is no guarantee the property will continue to exist or be of the # same syntax in future releases. @@ -789,7 +789,8 @@ jdk.tls.legacyAlgorithms= \ DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, \ DH_RSA_EXPORT, RSA_EXPORT, \ DH_anon, ECDH_anon, \ - RC4_128, RC4_40, DES_CBC, DES40_CBC + RC4_128, RC4_40, DES_CBC, DES40_CBC, \ + 3DES_EDE_CBC # The pre-defined default finite field Diffie-Hellman ephemeral (DHE) # parameters for Transport Layer Security (SSL/TLS/DTLS) processing. diff --git a/jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java b/jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java index 87712ae0ce8..58e387bcdad 100644 --- a/jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java +++ b/jdk/test/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.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 @@ -31,7 +31,7 @@ * @bug 7188657 * @summary There should be a way to reorder the JSSE ciphers * @run main/othervm UseCipherSuitesOrder - * TLS_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA + * TLS_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA */ import java.io.*; From 3463ee94d8ff97b130df05eb9f2ac44048567152 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Tue, 13 Sep 2016 11:59:56 +0100 Subject: [PATCH 008/154] 8164147: Improve streaming socket output Reviewed-by: chegar, igerasim --- .../classes/java/net/SocketInputStream.java | 7 +- .../classes/java/net/SocketOutputStream.java | 8 +- .../unix/native/libnet/SocketOutputStream.c | 42 ++++--- .../native/libnet/SocketOutputStream.c | 113 +++++++++--------- 4 files changed, 90 insertions(+), 80 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java index 2fb035ef7d8..2f54d344659 100644 --- a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java +++ b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -155,11 +155,12 @@ class SocketInputStream extends FileInputStream } // bounds check - if (length <= 0 || off < 0 || off + length > b.length) { + if (length <= 0 || off < 0 || length > b.length - off) { if (length == 0) { return 0; } - throw new ArrayIndexOutOfBoundsException(); + throw new ArrayIndexOutOfBoundsException("length == " + length + + " off == " + off + " buffer length == " + b.length); } boolean gotReset = false; diff --git a/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java b/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java index 4aa1e53761b..9cbe056066f 100644 --- a/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java +++ b/jdk/src/java.base/share/classes/java/net/SocketOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -97,11 +97,13 @@ class SocketOutputStream extends FileOutputStream */ private void socketWrite(byte b[], int off, int len) throws IOException { - if (len <= 0 || off < 0 || off + len > b.length) { + + if (len <= 0 || off < 0 || len > b.length - off) { if (len == 0) { return; } - throw new ArrayIndexOutOfBoundsException(); + throw new ArrayIndexOutOfBoundsException("len == " + len + + " off == " + off + " buffer length == " + b.length); } FileDescriptor fd = impl.acquireFD(); diff --git a/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c b/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c index 17afe8b8d46..ba3a907ae67 100644 --- a/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c +++ b/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c @@ -98,27 +98,31 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this, int llen = chunkLen; (*env)->GetByteArrayRegion(env, data, off, chunkLen, (jbyte *)bufP); - while(llen > 0) { - int n = NET_Send(fd, bufP + loff, llen, 0); - if (n > 0) { - llen -= n; - loff += n; - continue; + if ((*env)->ExceptionCheck(env)) { + break; + } else { + while(llen > 0) { + int n = NET_Send(fd, bufP + loff, llen, 0); + if (n > 0) { + llen -= n; + loff += n; + continue; + } + if (errno == ECONNRESET) { + JNU_ThrowByName(env, "sun/net/ConnectionResetException", + "Connection reset"); + } else { + JNU_ThrowByNameWithMessageAndLastError + (env, "java/net/SocketException", "Write failed"); + } + if (bufP != BUF) { + free(bufP); + } + return; } - if (errno == ECONNRESET) { - JNU_ThrowByName(env, "sun/net/ConnectionResetException", - "Connection reset"); - } else { - JNU_ThrowByNameWithMessageAndLastError - (env, "java/net/SocketException", "Write failed"); - } - if (bufP != BUF) { - free(bufP); - } - return; + len -= chunkLen; + off += chunkLen; } - len -= chunkLen; - off += chunkLen; } if (bufP != BUF) { diff --git a/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c b/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c index 9894cb0e596..dcb533b753e 100644 --- a/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c +++ b/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c @@ -92,66 +92,69 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this, int retry = 0; (*env)->GetByteArrayRegion(env, data, off, chunkLen, (jbyte *)bufP); - - while(llen > 0) { - int n = send(fd, bufP + loff, llen, 0); - if (n > 0) { - llen -= n; - loff += n; - continue; - } - - /* - * Due to a bug in Windows Sockets (observed on NT and Windows - * 2000) it may be necessary to retry the send. The issue is that - * on blocking sockets send/WSASend is supposed to block if there - * is insufficient buffer space available. If there are a large - * number of threads blocked on write due to congestion then it's - * possile to hit the NT/2000 bug whereby send returns WSAENOBUFS. - * The workaround we use is to retry the send. If we have a - * large buffer to send (>2k) then we retry with a maximum of - * 2k buffer. If we hit the issue with <=2k buffer then we backoff - * for 1 second and retry again. We repeat this up to a reasonable - * limit before bailing out and throwing an exception. In load - * conditions we've observed that the send will succeed after 2-3 - * attempts but this depends on network buffers associated with - * other sockets draining. - */ - if (WSAGetLastError() == WSAENOBUFS) { - if (llen > MAX_BUFFER_LEN) { - buflen = MAX_BUFFER_LEN; - chunkLen = MAX_BUFFER_LEN; - llen = MAX_BUFFER_LEN; + if ((*env)->ExceptionCheck(env)) { + break; + } else { + while(llen > 0) { + int n = send(fd, bufP + loff, llen, 0); + if (n > 0) { + llen -= n; + loff += n; continue; } - if (retry >= 30) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - "No buffer space available - exhausted attempts to queue buffer"); - if (bufP != BUF) { - free(bufP); - } - return; - } - Sleep(1000); - retry++; - continue; - } - /* - * Send failed - can be caused by close or write error. - */ - if (WSAGetLastError() == WSAENOTSOCK) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); - } else { - NET_ThrowCurrent(env, "socket write error"); + /* + * Due to a bug in Windows Sockets (observed on NT and Windows + * 2000) it may be necessary to retry the send. The issue is that + * on blocking sockets send/WSASend is supposed to block if there + * is insufficient buffer space available. If there are a large + * number of threads blocked on write due to congestion then it's + * possile to hit the NT/2000 bug whereby send returns WSAENOBUFS. + * The workaround we use is to retry the send. If we have a + * large buffer to send (>2k) then we retry with a maximum of + * 2k buffer. If we hit the issue with <=2k buffer then we backoff + * for 1 second and retry again. We repeat this up to a reasonable + * limit before bailing out and throwing an exception. In load + * conditions we've observed that the send will succeed after 2-3 + * attempts but this depends on network buffers associated with + * other sockets draining. + */ + if (WSAGetLastError() == WSAENOBUFS) { + if (llen > MAX_BUFFER_LEN) { + buflen = MAX_BUFFER_LEN; + chunkLen = MAX_BUFFER_LEN; + llen = MAX_BUFFER_LEN; + continue; + } + if (retry >= 30) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", + "No buffer space available - exhausted attempts to queue buffer"); + if (bufP != BUF) { + free(bufP); + } + return; + } + Sleep(1000); + retry++; + continue; + } + + /* + * Send failed - can be caused by close or write error. + */ + if (WSAGetLastError() == WSAENOTSOCK) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); + } else { + NET_ThrowCurrent(env, "socket write error"); + } + if (bufP != BUF) { + free(bufP); + } + return; } - if (bufP != BUF) { - free(bufP); - } - return; + len -= chunkLen; + off += chunkLen; } - len -= chunkLen; - off += chunkLen; } if (bufP != BUF) { From 452a01e1030334dd16c3c1eb3718478fbde8823c Mon Sep 17 00:00:00 2001 From: Harsha Wardhana B Date: Thu, 15 Sep 2016 13:24:24 +0530 Subject: [PATCH 009/154] 8165230: RMIConnection addNotificationListeners failing with specific inputs Reviewed-by: dfuchs, skoivu --- .../javax/management/remote/rmi/RMIConnectionImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 03b652a0ba7..fb7c00cd2d9 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -990,7 +990,7 @@ public class RMIConnectionImpl implements RMIConnection, Unreferenced { filterValues[i] = unwrap(filters[i], targetCl, defaultClassLoader, - NotificationFilter.class, delegationSubjects[i]); + NotificationFilter.class, sbjs[i]); if (debug) logger.debug("addNotificationListener"+ "(ObjectName,NotificationFilter)", From b96a819e4b70fbe29309b7caf7bc1d1424651ae8 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 27 Sep 2016 03:23:40 +0300 Subject: [PATCH 010/154] 8164143: Improve components for menu items Reviewed-by: ssadetsky, prr, ddehaven --- .../com/apple/eawt/_AppMenuBarHandler.java | 2 +- .../sun/lwawt/macosx/CCheckboxMenuItem.java | 15 ++-- .../sun/lwawt/macosx/CFRetainedResource.java | 68 ++++++++++++++++++- .../classes/sun/lwawt/macosx/CMenu.java | 44 ++++++------ .../classes/sun/lwawt/macosx/CMenuBar.java | 17 ++--- .../sun/lwawt/macosx/CMenuComponent.java | 32 ++++----- .../classes/sun/lwawt/macosx/CMenuItem.java | 35 ++++++---- .../sun/lwawt/macosx/CPlatformWindow.java | 2 +- .../classes/sun/lwawt/macosx/CPopupMenu.java | 14 ++-- .../classes/sun/lwawt/macosx/CTrayIcon.java | 7 +- .../macosx/native/libawt_lwawt/awt/CMenu.m | 15 ++-- .../macosx/native/libawt_lwawt/awt/CMenuBar.m | 19 ++---- .../native/libawt_lwawt/awt/CMenuComponent.m | 40 +---------- .../native/libawt_lwawt/awt/CMenuItem.h | 4 +- .../native/libawt_lwawt/awt/CMenuItem.m | 41 ++++------- 15 files changed, 184 insertions(+), 171 deletions(-) diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java index 027cbcf67e6..e017b32538a 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java @@ -123,7 +123,7 @@ class _AppMenuBarHandler { } // grab the pointer to the CMenuBar, and retain it in native - nativeSetDefaultMenuBar(((CMenuBar)peer).getModel()); + ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar); } void setAboutMenuItemVisible(final boolean present) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java index da53c302ad5..d21de341fb4 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,29 +26,28 @@ package sun.lwawt.macosx; import java.awt.CheckboxMenuItem; -import java.awt.EventQueue; import java.awt.event.ItemEvent; import java.awt.peer.CheckboxMenuItemPeer; import sun.awt.SunToolkit; public class CCheckboxMenuItem extends CMenuItem implements CheckboxMenuItemPeer { - boolean fAutoToggle = true; - boolean fIsIndeterminate = false; + volatile boolean fAutoToggle = true; + volatile boolean fIsIndeterminate = false; private native void nativeSetState(long modelPtr, boolean state); private native void nativeSetIsCheckbox(long modelPtr); - CCheckboxMenuItem(CheckboxMenuItem target) { + CCheckboxMenuItem(final CheckboxMenuItem target) { super(target); - nativeSetIsCheckbox(getModel()); + execute(this::nativeSetIsCheckbox); setState(target.getState()); } // MenuItemPeer implementation @Override - public void setState(boolean state) { - nativeSetState(getModel(), state); + public void setState(final boolean state) { + execute(ptr -> nativeSetState(ptr, state)); } public void handleAction(final boolean state) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java index cec76f5c897..f69ad201ef8 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java @@ -23,7 +23,6 @@ * questions. */ - package sun.lwawt.macosx; /** @@ -34,6 +33,7 @@ public class CFRetainedResource { private static native void nativeCFRelease(final long ptr, final boolean disposeOnAppKitThread); private final boolean disposeOnAppKitThread; + // TODO this pointer should be private and accessed via CFNativeAction class protected volatile long ptr; /** @@ -70,8 +70,72 @@ public class CFRetainedResource { nativeCFRelease(oldPtr, disposeOnAppKitThread); // perform outside of the synchronized block } + /** + * The interface which allows to execute some native operations with + * assumption that the native pointer will be valid till the end. + */ + public interface CFNativeAction { + + /** + * The native operation should be called from this method. + * + * @param ptr the pointer to the native data + */ + void run(long ptr); + } + + /** + * The interface which allows to execute some native operations and get a + * result with assumption that the native pointer will be valid till the + * end. + */ + interface CFNativeActionGet { + + /** + * The native operation should be called from this method. + * + * @param ptr the pointer to the native data + * @return result of the native operation + */ + long run(long ptr); + } + + /** + * This is utility method which should be used instead of the direct access + * to the {@link #ptr}, because this method guaranteed that the pointer will + * not be zero and will be valid till the end of the operation.It is highly + * recomended to not use any external lock in action. If the current + * {@link #ptr} is {@code 0} then action will be ignored. + * + * @param action The native operation + */ + public final synchronized void execute(final CFNativeAction action) { + if (ptr != 0) { + action.run(ptr); + } + } + + /** + * This is utility method which should be used instead of the direct access + * to the {@link #ptr}, because this method guaranteed that the pointer will + * not be zero and will be valid till the end of the operation. It is highly + * recomended to not use any external lock in action. If the current + * {@link #ptr} is {@code 0} then action will be ignored and {@code} is + * returned. + * + * @param action the native operation + * @return result of the native operation, usually the native pointer to + * some other data + */ + final synchronized long executeGet(final CFNativeActionGet action) { + if (ptr != 0) { + return action.run(ptr); + } + return 0; + } + @Override - protected void finalize() throws Throwable { + protected final void finalize() throws Throwable { dispose(); } } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenu.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenu.java index 9e1499b8de9..4f2fc96ad8a 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenu.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenu.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,9 @@ package sun.lwawt.macosx; -import java.awt.*; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; import java.awt.peer.MenuItemPeer; import java.awt.peer.MenuPeer; @@ -37,7 +39,7 @@ public class CMenu extends CMenuItem implements MenuPeer { // This way we avoiding invocation of the setters twice @Override - protected void initialize(MenuItem target) { + protected final void initialize(MenuItem target) { setLabel(target.getLabel()); setEnabled(target.isEnabled()); } @@ -57,52 +59,50 @@ public class CMenu extends CMenuItem implements MenuPeer { } @Override - protected long createModel() { + long createModel() { CMenuComponent parent = (CMenuComponent) LWCToolkit.targetToPeer(getTarget().getParent()); - if (parent instanceof CMenu || - parent instanceof CPopupMenu) - { - return nativeCreateSubMenu(parent.getModel()); - } else if (parent instanceof CMenuBar) { + if (parent instanceof CMenu) { + return parent.executeGet(this::nativeCreateSubMenu); + } + if (parent instanceof CMenuBar) { MenuBar parentContainer = (MenuBar)getTarget().getParent(); boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget(); int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex(); - return nativeCreateMenu(parent.getModel(), - isHelpMenu, insertionLocation); - } else { - throw new InternalError("Parent must be CMenu or CMenuBar"); + return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu, + insertionLocation)); } + throw new InternalError("Parent must be CMenu or CMenuBar"); } @Override - public void addItem(MenuItem item) { + public final void addItem(MenuItem item) { // Nothing to do here -- we added it when we created the // menu item's peer. } @Override - public void delItem(int index) { - nativeDeleteItem(getModel(), index); + public final void delItem(final int index) { + execute(ptr -> nativeDeleteItem(ptr, index)); } @Override - public void setLabel(String label) { - nativeSetMenuTitle(getModel(), label); + public final void setLabel(final String label) { + execute(ptr->nativeSetMenuTitle(ptr, label)); super.setLabel(label); } // Note that addSeparator is never called directly from java.awt.Menu, // though it is required in the MenuPeer interface. @Override - public void addSeparator() { - nativeAddSeparator(getModel()); + public final void addSeparator() { + execute(this::nativeAddSeparator); } // Used by ScreenMenuBar to get to the native menu for event handling. - public long getNativeMenu() { - return nativeGetNSMenu(getModel()); + public final long getNativeMenu() { + return executeGet(this::nativeGetNSMenu); } private native long nativeCreateMenu(long parentMenuPtr, diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.java index 7d2aa7b7beb..3dd64a97422 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.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 @@ -31,7 +31,7 @@ import java.awt.peer.MenuBarPeer; import sun.awt.AWTAccessor; -public class CMenuBar extends CMenuComponent implements MenuBarPeer { +public final class CMenuBar extends CMenuComponent implements MenuBarPeer { private int nextInsertionIndex = -1; @@ -40,14 +40,15 @@ public class CMenuBar extends CMenuComponent implements MenuBarPeer { } @Override - protected long createModel() { + long createModel() { return nativeCreateMenuBar(); } @Override - public void addHelpMenu(Menu m) { - CMenu cMenu = AWTAccessor.getMenuComponentAccessor().getPeer(m); - nativeSetHelpMenu(getModel(), cMenu.getModel()); + public void addHelpMenu(final Menu m) { + final CMenu cMenu = AWTAccessor.getMenuComponentAccessor().getPeer(m); + execute(parentPtr -> cMenu.execute( + menuPtr -> nativeSetHelpMenu(parentPtr, menuPtr))); } public int getNextInsertionIndex() { @@ -65,8 +66,8 @@ public class CMenuBar extends CMenuComponent implements MenuBarPeer { } @Override - public void delMenu(int index) { - nativeDelMenu(getModel(), index); + public void delMenu(final int index) { + execute(ptr -> nativeDelMenu(ptr, index)); } private native long nativeCreateMenuBar(); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuComponent.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuComponent.java index 2dbc923859c..6100916be3e 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuComponent.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,36 +29,32 @@ import java.awt.Font; import java.awt.MenuComponent; import java.awt.peer.MenuComponentPeer; -public abstract class CMenuComponent implements MenuComponentPeer { +abstract class CMenuComponent extends CFRetainedResource + implements MenuComponentPeer { - private MenuComponent target; - private long modelPtr; + private final MenuComponent target; - CMenuComponent(MenuComponent target) { + CMenuComponent(final MenuComponent target) { + super(0, true); this.target = target; - this.modelPtr = createModel(); + setPtr(createModel()); } - MenuComponent getTarget() { + final MenuComponent getTarget() { return target; } - public long getModel() { - return modelPtr; - } + abstract long createModel(); - protected abstract long createModel(); - - public void dispose() { + @Override + public final void dispose() { + super.dispose(); LWCToolkit.targetDisposedPeer(target, this); - nativeDispose(modelPtr); - target = null; } - private native void nativeDispose(long modelPtr); - // 1.5 peer method - public void setFont(Font f) { + @Override + public final void setFont(final Font f) { // no-op, as we don't currently support menu fonts // c.f. radar 4032912 } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java index 2fca524922b..0230c4e842f 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,16 +25,17 @@ package sun.lwawt.macosx; -import sun.awt.SunToolkit; -import sun.lwawt.LWToolkit; - -import java.awt.MenuContainer; import java.awt.MenuItem; import java.awt.MenuShortcut; -import java.awt.event.*; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; import java.awt.peer.MenuItemPeer; import java.util.concurrent.atomic.AtomicBoolean; +import sun.awt.SunToolkit; +import sun.lwawt.LWToolkit; + public class CMenuItem extends CMenuComponent implements MenuItemPeer { private final AtomicBoolean enabled = new AtomicBoolean(true); @@ -58,9 +59,9 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { } @Override - protected long createModel() { + long createModel() { CMenuComponent parent = (CMenuComponent)LWToolkit.targetToPeer(getTarget().getParent()); - return nativeCreate(parent.getModel(), isSeparator()); + return parent.executeGet(ptr->nativeCreate(ptr, isSeparator())); } public void setLabel(String label, char keyChar, int keyCode, int modifiers) { @@ -90,7 +91,12 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { keyChar = 0; } - nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask); + final String finalLabel = label; + final char finalKeyChar = keyChar; + final int finalKeyCode = keyCode; + final int finalKeyMask = keyMask; + execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, + finalKeyCode, finalKeyMask)); } @Override @@ -105,16 +111,16 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { * There isn't a need to expose this except in a instanceof because * it isn't defined in the peer api. */ - public void setImage(java.awt.Image img) { + public final void setImage(final java.awt.Image img) { CImage cimg = CImage.getCreator().createFromImage(img); - nativeSetImage(getModel(), cimg == null ? 0L : cimg.ptr); + execute(ptr -> nativeSetImage(ptr, cimg == null ? 0L : cimg.ptr)); } /** * New API for tooltips */ - public void setToolTipText(String text) { - nativeSetTooltip(getModel(), text); + public final void setToolTipText(final String text) { + execute(ptr -> nativeSetTooltip(ptr, text)); } // @Override @@ -138,7 +144,8 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { b &= ((CMenuItem) parent).isEnabled(); } if (enabled.compareAndSet(!b, b)) { - nativeSetEnabled(getModel(), b); + final boolean finalB = b; + execute(ptr->nativeSetEnabled(ptr, finalB)); } } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 38dd927c70f..102851f3b87 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -449,7 +449,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo final long nsWindowPtr = getNSWindowPtr(); CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb); if (mbPeer != null) { - nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel()); + mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr)); } else { nativeSetNSWindowMenuBar(nsWindowPtr, 0); } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPopupMenu.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPopupMenu.java index 67ddf91471a..b73f67a0f79 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPopupMenu.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPopupMenu.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 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 @@ -25,18 +25,20 @@ package sun.lwawt.macosx; -import java.awt.*; +import java.awt.Component; +import java.awt.Event; +import java.awt.Point; +import java.awt.PopupMenu; import java.awt.peer.PopupMenuPeer; -import sun.lwawt.LWWindowPeer; +final class CPopupMenu extends CMenu implements PopupMenuPeer { -public class CPopupMenu extends CMenu implements PopupMenuPeer { CPopupMenu(PopupMenu target) { super(target); } @Override - protected long createModel() { + long createModel() { return nativeCreatePopupMenu(); } @@ -50,7 +52,7 @@ public class CPopupMenu extends CMenu implements PopupMenuPeer { Point loc = origin.getLocationOnScreen(); e.x += loc.x; e.y += loc.y; - nativeShowPopupMenu(getModel(), e.x, e.y); + execute(ptr -> nativeShowPopupMenu(ptr, e.x, e.y)); } } } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java index abd092b8be9..bcbb242f949 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.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 @@ -118,7 +118,10 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { } } - return checkAndCreatePopupPeer().getModel(); + // This method is executed on Appkit, so if ptr is not zero means that, + // it is still not deallocated(even if we call NSApp postRunnableEvent) + // and sent CFRelease to the native queue + return checkAndCreatePopupPeer().ptr; } /** diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m index 43b08f09d2c..fe42ac75247 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ - (id)initWithPeer:(jobject)peer { AWT_ASSERT_APPKIT_THREAD; // Create the new NSMenu - self = [super initWithPeer:peer asSeparator:[NSNumber numberWithBool:NO]]; + self = [super initWithPeer:peer asSeparator:NO]; if (self) { fMenu = [NSMenu javaMenuWithTitle:@""]; [fMenu retain]; @@ -133,14 +133,13 @@ AWT_ASSERT_APPKIT_THREAD; CMenu * createCMenu (jobject cPeerObjGlobal) { - CMenu *aCMenu = nil; + __block CMenu *aCMenu = nil; - // We use an array here only to be able to get a return value - NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], nil]; + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - [ThreadUtilities performOnMainThread:@selector(_create_OnAppKitThread:) on:[CMenu alloc] withObject:args waitUntilDone:YES]; - - aCMenu = (CMenu *)[args objectAtIndex: 0]; + aCMenu = [[CMenu alloc] initWithPeer:cPeerObjGlobal]; + // the aCMenu is released in CMenuComponent.dispose() + }]; if (aCMenu == nil) { return 0L; diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m index 34ba099331b..2de86be755b 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -383,27 +383,20 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar (JNIEnv *env, jobject peer) { - CMenuBar *aCMenuBar = nil; + __block CMenuBar *aCMenuBar = nil; JNF_COCOA_ENTER(env); jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer); - // We use an array here only to be able to get a return value - NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], nil]; - - [ThreadUtilities performOnMainThread:@selector(_create_OnAppKitThread:) on:[CMenuBar alloc] withObject:args waitUntilDone:YES]; - - aCMenuBar = (CMenuBar *)[args objectAtIndex: 0]; + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ + aCMenuBar = [[CMenuBar alloc] initWithPeer:cPeerObjGlobal]; + // the aCMenuBar is released in CMenuComponent.dispose() + }]; if (aCMenuBar == nil) { return 0L; } - // [args release]; - - // A strange memory managment after that. - - JNF_COCOA_EXIT(env); return ptr_to_jlong(aCMenuBar); } diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m index c3bff14241c..cf093cd650c 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,45 +41,11 @@ return self; } --(void) cleanup { - // Used by subclasses -} - --(void) disposer { +- (void)dealloc { JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; JNFDeleteGlobalRef(env, fPeer); fPeer = NULL; - [self cleanup]; - [self release]; + [super dealloc]; } - -// The method is used by all subclasses, since the process of the creation -// is the same. The only exception is the CMenuItem class. -- (void) _create_OnAppKitThread: (NSMutableArray *)argValue { - jobject cPeerObjGlobal = (jobject)[[argValue objectAtIndex: 0] pointerValue]; - CMenuItem *aCMenuItem = [self initWithPeer:cPeerObjGlobal]; - [argValue removeAllObjects]; - [argValue addObject: aCMenuItem]; -} - @end - -/* - * Class: sun_lwawt_macosx_CMenuComponent - * Method: nativeDispose - * Signature: (J)V - */ -JNIEXPORT void JNICALL -Java_sun_lwawt_macosx_CMenuComponent_nativeDispose -(JNIEnv *env, jobject peer, jlong menuItemObj) -{ -JNF_COCOA_ENTER(env); - - [ThreadUtilities performOnMainThread:@selector(disposer) - on:((id)jlong_to_ptr(menuItemObj)) - withObject:nil - waitUntilDone:NO]; - -JNF_COCOA_EXIT(env); -} diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.h b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.h index 60a0565f3f6..e2c72f2e539 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.h +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 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 @@ -32,7 +32,7 @@ } // Setup -- (id) initWithPeer:(jobject)peer asSeparator: (NSNumber *) asSeparator; +- (id) initWithPeer:(jobject)peer asSeparator: (BOOL) asSeparator; - (void) setIsCheckbox; // Events diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m index bcf7893005c..c9cc97ae21e 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, 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 @@ -39,11 +39,11 @@ @implementation CMenuItem -- (id) initWithPeer:(jobject)peer asSeparator: (NSNumber *) asSeparator{ +- (id) initWithPeer:(jobject)peer asSeparator: (BOOL) asSeparator{ AWT_ASSERT_APPKIT_THREAD; self = [super initWithPeer:peer]; if (self) { - if ([asSeparator boolValue]) { + if (asSeparator) { fMenuItem = (NSMenuItem*)[NSMenuItem separatorItem]; [fMenuItem retain]; } else { @@ -204,12 +204,9 @@ }]; } -- (void)cleanup { +- (void)dealloc { [fMenuItem setAction:NULL]; [fMenuItem setTarget:nil]; -} - -- (void)dealloc { [fMenuItem release]; fMenuItem = nil; @@ -228,14 +225,6 @@ fIsCheckbox = YES; } -- (void) _createMenuItem_OnAppKitThread: (NSMutableArray *)argValue { - jobject cPeerObjGlobal = (jobject)[[argValue objectAtIndex: 0] pointerValue]; - NSNumber * asSeparator = (NSNumber *)[argValue objectAtIndex: 1]; - CMenuItem *aCMenuItem = [self initWithPeer: cPeerObjGlobal asSeparator: asSeparator]; - [argValue removeAllObjects]; - [argValue addObject: aCMenuItem]; -} - - (NSString *)description { return [NSString stringWithFormat:@"CMenuItem[ %@ ]", fMenuItem]; } @@ -397,24 +386,18 @@ Java_sun_lwawt_macosx_CMenuItem_nativeCreate (JNIEnv *env, jobject peer, jlong parentCMenuObj, jboolean isSeparator) { - CMenuItem *aCMenuItem = nil; + __block CMenuItem *aCMenuItem = nil; + BOOL asSeparator = (isSeparator == JNI_TRUE) ? YES: NO; CMenu *parentCMenu = (CMenu *)jlong_to_ptr(parentCMenuObj); JNF_COCOA_ENTER(env); jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer); - - NSMutableArray *args = nil; - - // Create a new item.... - if (isSeparator == JNI_TRUE) { - args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:YES], nil]; - } else { - args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:NO], nil]; - } - - [ThreadUtilities performOnMainThread:@selector(_createMenuItem_OnAppKitThread:) on:[CMenuItem alloc] withObject:args waitUntilDone:YES]; - - aCMenuItem = (CMenuItem *)[args objectAtIndex: 0]; + + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ + aCMenuItem = [[CMenuItem alloc] initWithPeer: cPeerObjGlobal + asSeparator: asSeparator]; + // the CMenuItem is released in CMenuComponent.dispose() + }]; if (aCMenuItem == nil) { return 0L; From 79f1e4263bf559829ca45c1ecad912198a20b9b1 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 27 Sep 2016 16:35:28 +0300 Subject: [PATCH 011/154] 8162973: Better component components Reviewed-by: ssadetsky, prr, ahgross --- .../windows/native/libawt/windows/awt_Component.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp index f2d32860e32..edd513263d9 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp @@ -99,7 +99,6 @@ BOOL AwtComponent::sm_restoreFocusAndActivation = FALSE; HWND AwtComponent::sm_focusOwner = NULL; HWND AwtComponent::sm_focusedWindow = NULL; BOOL AwtComponent::sm_bMenuLoop = FALSE; -AwtComponent* AwtComponent::sm_getComponentCache = NULL; BOOL AwtComponent::sm_inSynthesizeFocus = FALSE; /************************************************************************/ @@ -276,10 +275,6 @@ AwtComponent::~AwtComponent() * handle. */ DestroyHWnd(); - - if (sm_getComponentCache == this) { - sm_getComponentCache = NULL; - } } void AwtComponent::Dispose() @@ -352,9 +347,6 @@ AwtComponent* AwtComponent::GetComponent(HWND hWnd) { if (hWnd == AwtToolkit::GetInstance().GetHWnd()) { return NULL; } - if (sm_getComponentCache && sm_getComponentCache->GetHWnd() == hWnd) { - return sm_getComponentCache; - } // check that it's an AWT component from the same toolkit as the caller if (::IsWindow(hWnd) && @@ -362,7 +354,7 @@ AwtComponent* AwtComponent::GetComponent(HWND hWnd) { { DASSERT(WmAwtIsComponent != 0); if (::SendMessage(hWnd, WmAwtIsComponent, 0, 0L)) { - return sm_getComponentCache = GetComponentImpl(hWnd); + return GetComponentImpl(hWnd); } } return NULL; From 09a11f3b8709217dfb3a0cc263cbeeb6b1c30722 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Tue, 4 Oct 2016 17:15:49 -0400 Subject: [PATCH 012/154] 8140353: Improve signature checking Reviewed-by: xuelei, ahgross, mchung --- .../java.base/share/classes/module-info.java | 1 + .../share/conf/security/java.security | 10 ++++-- .../share/lib/security/default.policy | 2 ++ .../dsig/internal/dom/DOMSignatureMethod.java | 36 ++++++++++++++++++- .../org/jcp/xml/dsig/internal/dom/Policy.java | 18 ++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index 2fd479eb925..1f62f7e6751 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -279,6 +279,7 @@ module java.base { java.security.jgss, java.security.sasl, java.smartcardio, + java.xml.crypto, jdk.crypto.ec, jdk.crypto.token, jdk.jartool, diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index 974dc0a839f..08c6804f5e2 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -913,7 +913,7 @@ crypto.policy=crypto.policydir-tbd # Constraint {"," Constraint } # Constraint: # AlgConstraint | MaxTransformsConstraint | MaxReferencesConstraint | -# ReferenceUriSchemeConstraint | OtherConstraint +# ReferenceUriSchemeConstraint | KeySizeConstraint | OtherConstraint # AlgConstraint # "disallowAlg" Uri # MaxTransformsConstraint: @@ -922,12 +922,16 @@ crypto.policy=crypto.policydir-tbd # "maxReferences" Integer # ReferenceUriSchemeConstraint: # "disallowReferenceUriSchemes" String { String } +# KeySizeConstraint: +# "minKeySize" KeyAlg Integer # OtherConstraint: # "noDuplicateIds" | "noRetrievalMethodLoops" # # For AlgConstraint, Uri is the algorithm URI String that is not allowed. # See the XML Signature Recommendation for more information on algorithm -# URI Identifiers. If the MaxTransformsConstraint or MaxReferencesConstraint is +# URI Identifiers. For KeySizeConstraint, KeyAlg is the standard algorithm +# name of the key type (ex: "RSA"). If the MaxTransformsConstraint, +# MaxReferencesConstraint or KeySizeConstraint (for the same key type) is # specified more than once, only the last entry is enforced. # # Note: This property is currently used by the JDK Reference implementation. It @@ -941,6 +945,8 @@ jdk.xml.dsig.secureValidationPolicy=\ maxTransforms 5,\ maxReferences 30,\ disallowReferenceUriSchemes file http https,\ + minKeySize RSA 1024,\ + minKeySize DSA 1024,\ noDuplicateIds,\ noRetrievalMethodLoops diff --git a/jdk/src/java.base/share/lib/security/default.policy b/jdk/src/java.base/share/lib/security/default.policy index 0c1798fbe9b..1f445078c6b 100644 --- a/jdk/src/java.base/share/lib/security/default.policy +++ b/jdk/src/java.base/share/lib/security/default.policy @@ -81,6 +81,8 @@ grant codeBase "jrt:/java.xml.bind" { }; grant codeBase "jrt:/java.xml.crypto" { + permission java.lang.RuntimePermission + "accessClassInPackage.sun.security.util"; permission java.util.PropertyPermission "*", "read"; permission java.security.SecurityPermission "putProviderProperty.XMLDSig"; permission java.security.SecurityPermission diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java index 9e367695d61..ad80c3b49b6 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMSignatureMethod.java 1333415 2012-05-03 12:03:51Z coheigea $ @@ -41,6 +41,7 @@ import org.w3c.dom.Element; import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA; import com.sun.org.apache.xml.internal.security.utils.JavaUtils; import org.jcp.xml.dsig.internal.SignerOutputStream; +import sun.security.util.KeyUtil; /** * DOM-based abstract implementation of SignatureMethod. @@ -207,6 +208,7 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod { if (!(key instanceof PublicKey)) { throw new InvalidKeyException("key must be PublicKey"); } + checkKeySize(context, key); if (signature == null) { Provider p = (Provider)context.getProperty( "org.jcp.xml.dsig.internal.dom.SignatureProvider"); @@ -234,6 +236,37 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod { return signature.verify(s); } + /** + * If secure validation mode is enabled, checks that the key size is + * restricted. + * + * @param context the context + * @param key the key to check + * @throws XMLSignatureException if the key size is restricted + */ + private static void checkKeySize(XMLCryptoContext context, Key key) + throws XMLSignatureException { + if (Utils.secureValidation(context)) { + int size = KeyUtil.getKeySize(key); + if (size == -1) { + // key size cannot be determined, so we cannot check against + // restrictions. Note that a DSA key w/o params will be + // rejected later if the certificate chain is validated. + if (log.isLoggable(java.util.logging.Level.FINE)) { + log.log(java.util.logging.Level.FINE, "Size for " + + key.getAlgorithm() + " key cannot be determined"); + } + return; + } + if (Policy.restrictKey(key.getAlgorithm(), size)) { + throw new XMLSignatureException(key.getAlgorithm() + + " keys less than " + + Policy.minKeySize(key.getAlgorithm()) + " bits are" + + " forbidden when secure validation is enabled"); + } + } + } + byte[] sign(Key key, SignedInfo si, XMLSignContext context) throws InvalidKeyException, XMLSignatureException { @@ -244,6 +277,7 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod { if (!(key instanceof PrivateKey)) { throw new InvalidKeyException("key must be PrivateKey"); } + checkKeySize(context, key); if (signature == null) { Provider p = (Provider)context.getProperty( "org.jcp.xml.dsig.internal.dom.SignatureProvider"); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java index af9bea40876..1608ad8481e 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java @@ -31,8 +31,10 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.security.Security; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Locale; +import java.util.Map; import java.util.Set; /** @@ -46,6 +48,7 @@ public final class Policy { private static int maxTrans = Integer.MAX_VALUE; private static int maxRefs = Integer.MAX_VALUE; private static Set disallowedRefUriSchemes = new HashSet<>(); + private static Map minKeyMap = new HashMap<>(); private static boolean noDuplicateIds = false; private static boolean noRMLoops = false; @@ -101,6 +104,13 @@ public final class Policy { scheme.toLowerCase(Locale.ROOT)); } break; + case "minKeySize": + if (tokens.length != 3) { + error(entry); + } + minKeyMap.put(tokens[1], + Integer.parseUnsignedInt(tokens[2])); + break; case "noDuplicateIds": if (tokens.length != 1) { error(entry); @@ -147,6 +157,10 @@ public final class Policy { return false; } + public static boolean restrictKey(String type, int size) { + return (size < minKeyMap.getOrDefault(type, 0)); + } + public static boolean restrictDuplicateIds() { return noDuplicateIds; } @@ -171,6 +185,10 @@ public final class Policy { return Collections.unmodifiableSet(disallowedRefUriSchemes); } + public static int minKeySize(String type) { + return minKeyMap.getOrDefault(type, 0); + } + private static void error(String entry) { throw new IllegalArgumentException( "Invalid jdk.xml.dsig.secureValidationPolicy entry: " + entry); From c12cdd9a1c0f0e776b591baa98ea870cf7cac18d Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Wed, 5 Oct 2016 11:30:16 -0700 Subject: [PATCH 013/154] 8165344: Update concurrency support Reviewed-by: coffeys, robm, ahgross, chegar --- .../atomic/AtomicIntegerFieldUpdater.java | 22 +++++++++++- .../atomic/AtomicLongFieldUpdater.java | 34 +++++++++++++++++-- .../atomic/AtomicReferenceFieldUpdater.java | 22 +++++++++++- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java index 55af35b0139..1de994f06ec 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java @@ -40,6 +40,7 @@ import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.Objects; import java.util.function.IntBinaryOperator; import java.util.function.IntUnaryOperator; import jdk.internal.misc.Unsafe; @@ -411,7 +412,17 @@ public abstract class AtomicIntegerFieldUpdater { if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass; + // Access to protected field members is restricted to receivers only + // of the accessing class, or one of its subclasses, and the + // accessing class must in turn be a subclass (or package sibling) + // of the protected member's defining class. + // If the updater refers to a protected field of a declaring class + // outside the current package, the receiver argument will be + // narrowed to the type of the accessing class. + this.cclass = (Modifier.isProtected(modifiers) && + tclass.isAssignableFrom(caller) && + !isSamePackage(tclass, caller)) + ? caller : tclass; this.tclass = tclass; this.offset = U.objectFieldOffset(field); } @@ -432,6 +443,15 @@ public abstract class AtomicIntegerFieldUpdater { return false; } + /** + * Returns true if the two classes have the same class loader and + * package qualifier + */ + private static boolean isSamePackage(Class class1, Class class2) { + return class1.getClassLoader() == class2.getClassLoader() + && Objects.equals(class1.getPackageName(), class2.getPackageName()); + } + /** * Checks that target argument is instance of cclass. On * failure, throws cause. diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java index ff444676685..bd60f0bdcbb 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java @@ -40,6 +40,7 @@ import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.Objects; import java.util.function.LongBinaryOperator; import java.util.function.LongUnaryOperator; import jdk.internal.misc.Unsafe; @@ -409,7 +410,17 @@ public abstract class AtomicLongFieldUpdater { if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass; + // Access to protected field members is restricted to receivers only + // of the accessing class, or one of its subclasses, and the + // accessing class must in turn be a subclass (or package sibling) + // of the protected member's defining class. + // If the updater refers to a protected field of a declaring class + // outside the current package, the receiver argument will be + // narrowed to the type of the accessing class. + this.cclass = (Modifier.isProtected(modifiers) && + tclass.isAssignableFrom(caller) && + !isSamePackage(tclass, caller)) + ? caller : tclass; this.tclass = tclass; this.offset = U.objectFieldOffset(field); } @@ -540,7 +551,17 @@ public abstract class AtomicLongFieldUpdater { if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass; + // Access to protected field members is restricted to receivers only + // of the accessing class, or one of its subclasses, and the + // accessing class must in turn be a subclass (or package sibling) + // of the protected member's defining class. + // If the updater refers to a protected field of a declaring class + // outside the current package, the receiver argument will be + // narrowed to the type of the accessing class. + this.cclass = (Modifier.isProtected(modifiers) && + tclass.isAssignableFrom(caller) && + !isSamePackage(tclass, caller)) + ? caller : tclass; this.tclass = tclass; this.offset = U.objectFieldOffset(field); } @@ -621,4 +642,13 @@ public abstract class AtomicLongFieldUpdater { } while (acl != null); return false; } + + /** + * Returns true if the two classes have the same class loader and + * package qualifier + */ + static boolean isSamePackage(Class class1, Class class2) { + return class1.getClassLoader() == class2.getClassLoader() + && Objects.equals(class1.getPackageName(), class2.getPackageName()); + } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java index 2b75d5654ae..56f6751b9f0 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java @@ -40,6 +40,7 @@ import java.lang.reflect.Modifier; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.Objects; import java.util.function.BinaryOperator; import java.util.function.UnaryOperator; import jdk.internal.misc.Unsafe; @@ -351,7 +352,17 @@ public abstract class AtomicReferenceFieldUpdater { if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass; + // Access to protected field members is restricted to receivers only + // of the accessing class, or one of its subclasses, and the + // accessing class must in turn be a subclass (or package sibling) + // of the protected member's defining class. + // If the updater refers to a protected field of a declaring class + // outside the current package, the receiver argument will be + // narrowed to the type of the accessing class. + this.cclass = (Modifier.isProtected(modifiers) && + tclass.isAssignableFrom(caller) && + !isSamePackage(tclass, caller)) + ? caller : tclass; this.tclass = tclass; this.vclass = vclass; this.offset = U.objectFieldOffset(field); @@ -373,6 +384,15 @@ public abstract class AtomicReferenceFieldUpdater { return false; } + /** + * Returns true if the two classes have the same class loader and + * package qualifier + */ + private static boolean isSamePackage(Class class1, Class class2) { + return class1.getClassLoader() == class2.getClassLoader() + && Objects.equals(class1.getPackageName(), class2.getPackageName()); + } + /** * Checks that target argument is instance of cclass. On * failure, throws cause. From 7007b4d6f21912f4ef6e8c958ddf86ea71c3e494 Mon Sep 17 00:00:00 2001 From: Vinnie Ryan Date: Thu, 6 Oct 2016 17:33:57 +0100 Subject: [PATCH 014/154] 8158997: JNDI Protocols Switch Reviewed-by: dfuchs --- .../jndi/rmi/registry/RegistryContext.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java b/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java index 720a1ff940f..874d6872af5 100644 --- a/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java +++ b/jdk/src/jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java @@ -32,6 +32,8 @@ import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.Registry; import java.rmi.registry.LocateRegistry; +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.naming.*; import javax.naming.spi.NamingManager; @@ -52,6 +54,18 @@ public class RegistryContext implements Context, Referenceable { private int port; private static final NameParser nameParser = new AtomicNameParser(); private static final String SOCKET_FACTORY = "com.sun.jndi.rmi.factory.socket"; + /** + * Determines whether classes may be loaded from an arbitrary URL code base. + */ + static final boolean trustURLCodebase; + static { + // System property to control whether classes may be loaded from an + // arbitrary URL codebase + PrivilegedAction act = () -> System.getProperty( + "com.sun.jndi.rmi.object.trustURLCodebase", "false"); + String trust = AccessController.doPrivileged(act); + trustURLCodebase = "true".equalsIgnoreCase(trust); + } Reference reference = null; // ref used to create this context, if any @@ -460,6 +474,27 @@ public class RegistryContext implements Context, Referenceable { Object obj = (r instanceof RemoteReference) ? ((RemoteReference)r).getReference() : (Object)r; + + /* + * Classes may only be loaded from an arbitrary URL codebase when + * the system property com.sun.jndi.rmi.object.trustURLCodebase + * has been set to "true". + */ + + // Use reference if possible + Reference ref = null; + if (obj instanceof Reference) { + ref = (Reference) obj; + } else if (obj instanceof Referenceable) { + ref = ((Referenceable)(obj)).getReference(); + } + + if (ref != null && ref.getFactoryClassLocation() != null && + !trustURLCodebase) { + throw new ConfigurationException( + "The object factory is untrusted. Set the system property" + + " 'com.sun.jndi.rmi.object.trustURLCodebase' to 'true'."); + } return NamingManager.getObjectInstance(obj, name, this, environment); } catch (NamingException e) { From 698c52a1eb615d409963efae884a16f6408eea16 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 6 Oct 2016 10:31:41 -0700 Subject: [PATCH 015/154] 8166988: Improve image processing performance Reviewed-by: serb, vadim, mschoene --- .../com/sun/imageio/plugins/png/PNGImageReader.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java index 79a31fd71b0..a2d7e7ecafc 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java @@ -735,7 +735,11 @@ public class PNGImageReader extends ImageReader { parse_iCCP_chunk(chunkLength); break; case iTXt_TYPE: - parse_iTXt_chunk(chunkLength); + if (ignoreMetadata) { + stream.skipBytes(chunkLength); + } else { + parse_iTXt_chunk(chunkLength); + } break; case pHYs_TYPE: parse_pHYs_chunk(); @@ -759,7 +763,11 @@ public class PNGImageReader extends ImageReader { parse_tRNS_chunk(chunkLength); break; case zTXt_TYPE: - parse_zTXt_chunk(chunkLength); + if (ignoreMetadata) { + stream.skipBytes(chunkLength); + } else { + parse_zTXt_chunk(chunkLength); + } break; default: // Read an unknown chunk From 90e6cda73c08be29fa1fd85d16db9e1f3eaa7abe Mon Sep 17 00:00:00 2001 From: Xuelei Fan Date: Sun, 9 Oct 2016 14:38:30 +0300 Subject: [PATCH 016/154] 8166878: Connection reset during TLS handshake Reviewed-by: xuelei --- .../share/classes/sun/security/ssl/ClientHandshaker.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 1f155a6bf2a..b95de5ecde2 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 @@ -673,8 +673,11 @@ final class ClientHandshaker extends Handshaker { } else { // we wanted to resume, but the server refused // - // Invalidate the session in case of reusing next time. - session.invalidate(); + // Invalidate the session for initial handshake in case + // of reusing next time. + if (isInitialHandshake) { + session.invalidate(); + } session = null; if (!enableNewSession) { throw new SSLException("New session creation is disabled"); From e68ae2ec8e728ffaddb2bbde20bf96b86004152d Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 12 Oct 2016 12:56:35 -0400 Subject: [PATCH 017/154] 8156802: Better constraint checking Reviewed-by: dfuchs --- .../share/conf/security/java.security | 30 +++ .../classes/java/rmi/MarshalledObject.java | 39 +++- .../sun/rmi/registry/RegistryImpl.java | 115 ++++++++++- .../share/classes/sun/rmi/runtime/Log.java | 5 + .../classes/sun/rmi/transport/DGCImpl.java | 95 ++++++++- .../rmi/MarshalledObject/MOFilterTest.java | 140 +++++++++++++ .../serialFilter/RegistryFilterTest.java | 186 ++++++++++++++++++ .../serialFilter/java.security-extra1 | 9 + .../rmi/registry/serialFilter/security.policy | 4 + 9 files changed, 610 insertions(+), 13 deletions(-) create mode 100644 jdk/test/java/rmi/MarshalledObject/MOFilterTest.java create mode 100644 jdk/test/java/rmi/registry/serialFilter/RegistryFilterTest.java create mode 100644 jdk/test/java/rmi/registry/serialFilter/java.security-extra1 create mode 100644 jdk/test/java/rmi/registry/serialFilter/security.policy diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index 08c6804f5e2..61a5169322c 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -658,6 +658,36 @@ krb5.kdc.bad.policy = tryLast jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & denyAfter 2017-01-01, \ RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224 +# +# RMI Registry Serial Filter +# +# The filter pattern uses the same format as jdk.serialFilter. +# This filter can override the builtin filter if additional types need to be +# allowed or rejected from the RMI Registry. +# +# Note: This property is currently used by the JDK Reference implementation. +# It is not guaranteed to be examined and used by other implementations. +# +#sun.rmi.registry.registryFilter=pattern;pattern +# +# RMI Distributed Garbage Collector (DGC) Serial Filter +# +# The filter pattern uses the same format as jdk.serialFilter. +# This filter can override the builtin filter if additional types need to be +# allowed or rejected from the RMI DGC. +# +# Note: This property is currently used by the JDK Reference implementation. +# It is not guaranteed to be examined and used by other implementations. +# +# The builtin DGC filter can approximately be represented as the filter pattern: +# +#sun.rmi.transport.dgcFilter=\ +# java.rmi.server.ObjID;\ +# java.rmi.server.UID;\ +# java.rmi.dgc.VMID;\ +# java.rmi.dgc.Lease;\ +# maxdepth=5;maxarray=10000 + # Algorithm restrictions for signed JAR files # # In some environments, certain algorithms or key lengths may be undesirable diff --git a/jdk/src/java.rmi/share/classes/java/rmi/MarshalledObject.java b/jdk/src/java.rmi/share/classes/java/rmi/MarshalledObject.java index b5f8b73123f..7b6e4cb4a0a 100644 --- a/jdk/src/java.rmi/share/classes/java/rmi/MarshalledObject.java +++ b/jdk/src/java.rmi/share/classes/java/rmi/MarshalledObject.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 @@ -29,11 +29,15 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputFilter; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamConstants; import java.io.OutputStream; import java.io.Serializable; +import java.security.AccessController; +import java.security.PrivilegedAction; + import sun.rmi.server.MarshalInputStream; import sun.rmi.server.MarshalOutputStream; @@ -90,6 +94,9 @@ public final class MarshalledObject implements Serializable { */ private int hash; + /** Filter used when creating the instance from a stream; may be null. */ + private transient ObjectInputFilter objectInputFilter = null; + /** Indicate compatibility with 1.2 version of class. */ private static final long serialVersionUID = 8988374069173025854L; @@ -132,10 +139,26 @@ public final class MarshalledObject implements Serializable { hash = h; } + /** + * Reads in the state of the object and saves the stream's + * serialization filter to be used when the object is deserialized. + * + * @param stream the stream + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a class cannot be found + */ + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); // read in all fields + objectInputFilter = stream.getObjectInputFilter(); + } + /** * Returns a new copy of the contained marshalledobject. The internal * representation is deserialized with the semantics used for * unmarshaling parameters for RMI calls. + * If the MarshalledObject was read from an ObjectInputStream, + * the filter from that stream is used to deserialize the object. * * @return a copy of the contained object * @exception IOException if an IOException occurs while @@ -155,7 +178,7 @@ public final class MarshalledObject implements Serializable { ByteArrayInputStream lin = (locBytes == null ? null : new ByteArrayInputStream(locBytes)); MarshalledObjectInputStream in = - new MarshalledObjectInputStream(bin, lin); + new MarshalledObjectInputStream(bin, lin, objectInputFilter); @SuppressWarnings("unchecked") T obj = (T) in.readObject(); in.close(); @@ -295,11 +318,21 @@ public final class MarshalledObject implements Serializable { * null, then all annotations will be * null. */ - MarshalledObjectInputStream(InputStream objIn, InputStream locIn) + MarshalledObjectInputStream(InputStream objIn, InputStream locIn, + ObjectInputFilter filter) throws IOException { super(objIn); this.locIn = (locIn == null ? null : new ObjectInputStream(locIn)); + if (filter != null) { + AccessController.doPrivileged((PrivilegedAction) () -> { + MarshalledObjectInputStream.this.setObjectInputFilter(filter); + if (MarshalledObjectInputStream.this.locIn != null) { + MarshalledObjectInputStream.this.locIn.setObjectInputFilter(filter); + } + return null; + }); + } } /** diff --git a/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java b/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java index 03119cc9552..d45cfac685e 100644 --- a/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java +++ b/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java @@ -25,8 +25,12 @@ package sun.rmi.registry; +import java.io.ObjectInputFilter; import java.nio.file.Path; import java.nio.file.Paths; +import java.rmi.server.LogStream; +import java.security.PrivilegedAction; +import java.security.Security; import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; @@ -39,7 +43,6 @@ import java.io.IOException; import java.net.*; import java.rmi.*; import java.rmi.server.ObjID; -import java.rmi.server.RemoteServer; import java.rmi.server.ServerNotActiveException; import java.rmi.registry.Registry; import java.rmi.server.RMIClientSocketFactory; @@ -54,12 +57,12 @@ import java.security.PermissionCollection; import java.security.Permissions; import java.security.ProtectionDomain; import java.text.MessageFormat; -import sun.rmi.server.LoaderHandler; + +import sun.rmi.runtime.Log; +import sun.rmi.server.UnicastRef; import sun.rmi.server.UnicastServerRef; import sun.rmi.server.UnicastServerRef2; import sun.rmi.transport.LiveRef; -import sun.rmi.transport.ObjectTable; -import sun.rmi.transport.Target; /** * A "registry" exists on every node that allows RMI connections to @@ -90,6 +93,48 @@ public class RegistryImpl extends java.rmi.server.RemoteServer private static ResourceBundle resources = null; + /** + * Property name of the RMI Registry serial filter to augment + * the built-in list of allowed types. + * Setting the property in the {@code conf/security/java.security} file + * will enable the augmented filter. + */ + private static final String REGISTRY_FILTER_PROPNAME = "sun.rmi.registry.registryFilter"; + + /** Registry max depth of remote invocations. **/ + private static int REGISTRY_MAX_DEPTH = 5; + + /** Registry maximum array size in remote invocations. **/ + private static int REGISTRY_MAX_ARRAY_SIZE = 10000; + + /** + * The registryFilter created from the value of the {@code "sun.rmi.registry.registryFilter"} + * property. + */ + private static final ObjectInputFilter registryFilter = + AccessController.doPrivileged((PrivilegedAction)RegistryImpl::initRegistryFilter); + + /** + * Initialize the registryFilter from the security properties or system property; if any + * @return an ObjectInputFilter, or null + */ + @SuppressWarnings("deprecation") + private static ObjectInputFilter initRegistryFilter() { + ObjectInputFilter filter = null; + String props = System.getProperty(REGISTRY_FILTER_PROPNAME); + if (props == null) { + props = Security.getProperty(REGISTRY_FILTER_PROPNAME); + } + if (props != null) { + filter = ObjectInputFilter.Config.createFilter(props); + Log regLog = Log.getLog("sun.rmi.registry", "registry", -1); + if (regLog.isLoggable(Log.BRIEF)) { + regLog.log(Log.BRIEF, "registryFilter = " + filter); + } + } + return filter; + } + /** * Construct a new RegistryImpl on the specified port with the * given custom socket factory pair. @@ -105,7 +150,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer AccessController.doPrivileged(new PrivilegedExceptionAction() { public Void run() throws RemoteException { LiveRef lref = new LiveRef(id, port, csf, ssf); - setup(new UnicastServerRef2(lref)); + setup(new UnicastServerRef2(lref, RegistryImpl::registryFilter)); return null; } }, null, new SocketPermission("localhost:"+port, "listen,accept")); @@ -114,7 +159,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer } } else { LiveRef lref = new LiveRef(id, port, csf, ssf); - setup(new UnicastServerRef2(lref)); + setup(new UnicastServerRef2(lref, RegistryImpl::registryFilter)); } } @@ -130,7 +175,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer AccessController.doPrivileged(new PrivilegedExceptionAction() { public Void run() throws RemoteException { LiveRef lref = new LiveRef(id, port); - setup(new UnicastServerRef(lref)); + setup(new UnicastServerRef(lref, RegistryImpl::registryFilter)); return null; } }, null, new SocketPermission("localhost:"+port, "listen,accept")); @@ -139,7 +184,7 @@ public class RegistryImpl extends java.rmi.server.RemoteServer } } else { LiveRef lref = new LiveRef(id, port); - setup(new UnicastServerRef(lref)); + setup(new UnicastServerRef(lref, RegistryImpl::registryFilter)); } } @@ -361,6 +406,60 @@ public class RegistryImpl extends java.rmi.server.RemoteServer return paths.toArray(new URL[0]); } + /** + * ObjectInputFilter to filter Registry input objects. + * The list of acceptable classes is limited to classes normally + * stored in a registry. + * + * @param filterInfo access to the class, array length, etc. + * @return {@link ObjectInputFilter.Status#ALLOWED} if allowed, + * {@link ObjectInputFilter.Status#REJECTED} if rejected, + * otherwise {@link ObjectInputFilter.Status#UNDECIDED} + */ + private static ObjectInputFilter.Status registryFilter(ObjectInputFilter.FilterInfo filterInfo) { + if (registryFilter != null) { + ObjectInputFilter.Status status = registryFilter.checkInput(filterInfo); + if (status != ObjectInputFilter.Status.UNDECIDED) { + // The Registry filter can override the built-in white-list + return status; + } + } + + if (filterInfo.depth() > REGISTRY_MAX_DEPTH) { + return ObjectInputFilter.Status.REJECTED; + } + Class clazz = filterInfo.serialClass(); + if (clazz != null) { + if (clazz.isArray()) { + if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE) { + return ObjectInputFilter.Status.REJECTED; + } + do { + // Arrays are allowed depending on the component type + clazz = clazz.getComponentType(); + } while (clazz.isArray()); + } + if (clazz.isPrimitive()) { + // Arrays of primitives are allowed + return ObjectInputFilter.Status.ALLOWED; + } + if (String.class == clazz + || java.lang.Number.class.isAssignableFrom(clazz) + || Remote.class.isAssignableFrom(clazz) + || java.lang.reflect.Proxy.class.isAssignableFrom(clazz) + || UnicastRef.class.isAssignableFrom(clazz) + || RMIClientSocketFactory.class.isAssignableFrom(clazz) + || RMIServerSocketFactory.class.isAssignableFrom(clazz) + || java.rmi.activation.ActivationID.class.isAssignableFrom(clazz) + || java.rmi.server.UID.class.isAssignableFrom(clazz)) { + return ObjectInputFilter.Status.ALLOWED; + } else { + return ObjectInputFilter.Status.REJECTED; + } + } + return ObjectInputFilter.Status.UNDECIDED; + } + /** * Return a new RegistryImpl on the requested port and export it to serve * registry requests. A classloader is initialized from the system property diff --git a/jdk/src/java.rmi/share/classes/sun/rmi/runtime/Log.java b/jdk/src/java.rmi/share/classes/sun/rmi/runtime/Log.java index 9ba58a55539..d80d8e1f2da 100644 --- a/jdk/src/java.rmi/share/classes/sun/rmi/runtime/Log.java +++ b/jdk/src/java.rmi/share/classes/sun/rmi/runtime/Log.java @@ -232,6 +232,11 @@ public abstract class Log { } } + public String toString() { + return logger.toString() + ", level: " + logger.getLevel() + + ", name: " + logger.getName(); + } + /** * Set the output stream associated with the RMI server call * logger. diff --git a/jdk/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java b/jdk/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java index 6664a609e50..b1c9e6e8476 100644 --- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java +++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ */ package sun.rmi.transport; +import java.io.ObjectInputFilter; import java.net.SocketPermission; import java.rmi.Remote; import java.rmi.RemoteException; @@ -34,11 +35,13 @@ import java.rmi.server.LogStream; import java.rmi.server.ObjID; import java.rmi.server.RemoteServer; import java.rmi.server.ServerNotActiveException; +import java.rmi.server.UID; import java.security.AccessControlContext; import java.security.AccessController; import java.security.Permissions; import java.security.PrivilegedAction; import java.security.ProtectionDomain; +import java.security.Security; import java.util.ArrayList; import java.util.HashSet; import java.util.HashMap; @@ -99,6 +102,46 @@ final class DGCImpl implements DGC { return dgc; } + /** + * Property name of the DGC serial filter to augment + * the built-in list of allowed types. + * Setting the property in the {@code conf/security/java.security} file + * or system property will enable the augmented filter. + */ + private static final String DGC_FILTER_PROPNAME = "sun.rmi.transport.dgcFilter"; + + /** Registry max depth of remote invocations. **/ + private static int DGC_MAX_DEPTH = 5; + + /** Registry maximum array size in remote invocations. **/ + private static int DGC_MAX_ARRAY_SIZE = 10000; + + /** + * The dgcFilter created from the value of the {@code "sun.rmi.transport.dgcFilter"} + * property. + */ + private static final ObjectInputFilter dgcFilter = + AccessController.doPrivileged((PrivilegedAction)DGCImpl::initDgcFilter); + + /** + * Initialize the dgcFilter from the security properties or system property; if any + * @return an ObjectInputFilter, or null + */ + private static ObjectInputFilter initDgcFilter() { + ObjectInputFilter filter = null; + String props = System.getProperty(DGC_FILTER_PROPNAME); + if (props == null) { + props = Security.getProperty(DGC_FILTER_PROPNAME); + } + if (props != null) { + filter = ObjectInputFilter.Config.createFilter(props); + if (dgcLog.isLoggable(Log.BRIEF)) { + dgcLog.log(Log.BRIEF, "dgcFilter = " + filter); + } + } + return filter; + } + /** * Construct a new server-side remote object collector at * a particular port. Disallow construction from outside. @@ -293,7 +336,8 @@ final class DGCImpl implements DGC { dgc = new DGCImpl(); ObjID dgcID = new ObjID(ObjID.DGC_ID); LiveRef ref = new LiveRef(dgcID, 0); - UnicastServerRef disp = new UnicastServerRef(ref); + UnicastServerRef disp = new UnicastServerRef(ref, + DGCImpl::checkInput); Remote stub = Util.createProxy(DGCImpl.class, new UnicastRef(ref), true); @@ -324,6 +368,53 @@ final class DGCImpl implements DGC { }); } + /** + * ObjectInputFilter to filter DGC input objects. + * The list of acceptable classes is very short and explicit. + * The depth and array sizes are limited. + * + * @param filterInfo access to class, arrayLength, etc. + * @return {@link ObjectInputFilter.Status#ALLOWED} if allowed, + * {@link ObjectInputFilter.Status#REJECTED} if rejected, + * otherwise {@link ObjectInputFilter.Status#UNDECIDED} + */ + private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) { + if (dgcFilter != null) { + ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo); + if (status != ObjectInputFilter.Status.UNDECIDED) { + // The DGC filter can override the built-in white-list + return status; + } + } + + if (filterInfo.depth() > DGC_MAX_DEPTH) { + return ObjectInputFilter.Status.REJECTED; + } + Class clazz = filterInfo.serialClass(); + if (clazz != null) { + while (clazz.isArray()) { + if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) { + return ObjectInputFilter.Status.REJECTED; + } + // Arrays are allowed depending on the component type + clazz = clazz.getComponentType(); + } + if (clazz.isPrimitive()) { + // Arrays of primitives are allowed + return ObjectInputFilter.Status.ALLOWED; + } + return (clazz == ObjID.class || + clazz == UID.class || + clazz == VMID.class || + clazz == Lease.class) + ? ObjectInputFilter.Status.ALLOWED + : ObjectInputFilter.Status.REJECTED; + } + // Not a class, not size limited + return ObjectInputFilter.Status.UNDECIDED; + } + + private static class LeaseInfo { VMID vmid; long expiration; diff --git a/jdk/test/java/rmi/MarshalledObject/MOFilterTest.java b/jdk/test/java/rmi/MarshalledObject/MOFilterTest.java new file mode 100644 index 00000000000..c25b47467e8 --- /dev/null +++ b/jdk/test/java/rmi/MarshalledObject/MOFilterTest.java @@ -0,0 +1,140 @@ +/* + * 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.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InvalidClassException; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectInputFilter; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.rmi.MarshalledObject; +import java.util.Objects; + + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; + +/* @test + * @run testng/othervm MOFilterTest + * + * @summary Test MarshalledObject applies ObjectInputFilter + */ +@Test +public class MOFilterTest { + + /** + * Two cases are tested. + * The filter = null and a filter set to verify the calls to the filter. + * @return array objects with test parameters for each test case + */ + @DataProvider(name = "FilterCases") + public static Object[][] filterCases() { + return new Object[][] { + {true}, // run the test with the filter + {false}, // run the test without the filter + + }; + } + + /** + * Test that MarshalledObject inherits the ObjectInputFilter from + * the stream it was deserialized from. + */ + @Test(dataProvider="FilterCases") + static void delegatesToMO(boolean withFilter) { + try { + Serializable testobj = Integer.valueOf(5); + MarshalledObject mo = new MarshalledObject<>(testobj); + Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object"); + + byte[] bytes = writeObjects(mo); + + try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + ObjectInputStream ois = new ObjectInputStream(bais)) { + + CountingFilter filter1 = new CountingFilter(); + ois.setObjectInputFilter(withFilter ? filter1 : null); + MarshalledObject actualMO = (MarshalledObject)ois.readObject(); + int count = filter1.getCount(); + + actualMO.get(); + int expectedCount = withFilter ? count + 2 : count; + int actualCount = filter1.getCount(); + Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()"); + } + } catch (IOException ioe) { + Assert.fail("Unexpected IOException", ioe); + } catch (ClassNotFoundException cnf) { + Assert.fail("Deserializing", cnf); + } + } + + /** + * Write objects and return a byte array with the bytes. + * + * @param objects zero or more objects to serialize + * @return the byte array of the serialized objects + * @throws IOException if an exception occurs + */ + static byte[] writeObjects(Object... objects) throws IOException { + byte[] bytes; + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos)) { + for (Object o : objects) { + oos.writeObject(o); + } + bytes = baos.toByteArray(); + } + return bytes; + } + + + static class CountingFilter implements ObjectInputFilter { + + private int count; // count of calls to the filter + + CountingFilter() { + count = 0; + } + + int getCount() { + return count; + } + + /** + * Filter that rejects class Integer and allows others + * + * @param filterInfo access to the class, arrayLength, etc. + * @return {@code STATUS.REJECTED} + */ + public ObjectInputFilter.Status checkInput(FilterInfo filterInfo) { + count++; + return ObjectInputFilter.Status.ALLOWED; + } + } + +} diff --git a/jdk/test/java/rmi/registry/serialFilter/RegistryFilterTest.java b/jdk/test/java/rmi/registry/serialFilter/RegistryFilterTest.java new file mode 100644 index 00000000000..e29e24aea8a --- /dev/null +++ b/jdk/test/java/rmi/registry/serialFilter/RegistryFilterTest.java @@ -0,0 +1,186 @@ +/* + * 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.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.rmi.MarshalledObject; +import java.rmi.NotBoundException; +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.rmi.AlreadyBoundException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.util.Objects; +import java.security.Security; + +import org.testng.Assert; +import org.testng.TestNG; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/* + * @test + * @library /java/rmi/testlibrary + * @modules java.rmi/sun.rmi.registry + * java.rmi/sun.rmi.server + * java.rmi/sun.rmi.transport + * java.rmi/sun.rmi.transport.tcp + * @build TestLibrary + * @summary Test filters for the RMI Registry + * @run testng/othervm RegistryFilterTest + * @run testng/othervm + * -Dsun.rmi.registry.registryFilter=!java.lang.Long;!RegistryFilterTest$RejectableClass + * RegistryFilterTest + * @run testng/othervm/policy=security.policy + * -Djava.security.properties=${test.src}/java.security-extra1 + * RegistryFilterTest + */ +public class RegistryFilterTest { + private static Registry impl; + private static int port; + private static Registry registry; + + static final int REGISTRY_MAX_ARRAY = 10000; + + static final String registryFilter = + System.getProperty("sun.rmi.registry.registryFilter", + Security.getProperty("sun.rmi.registry.registryFilter")); + + @DataProvider(name = "bindAllowed") + static Object[][] bindAllowedObjects() { + Object[][] objects = { + }; + return objects; + } + + /** + * Data RMI Regiry bind test. + * - name + * - Object + * - true/false if object is blacklisted by a filter (implicit or explicit) + * @return array of test data + */ + @DataProvider(name = "bindData") + static Object[][] bindObjects() { + Object[][] data = { + { "byte[max]", new XX(new byte[REGISTRY_MAX_ARRAY]), false }, + { "String", new XX("now is the time"), false}, + { "String[]", new XX(new String[3]), false}, + { "Long[4]", new XX(new Long[4]), registryFilter != null }, + { "rej-byte[toobig]", new XX(new byte[REGISTRY_MAX_ARRAY + 1]), true }, + { "rej-MarshalledObject", createMarshalledObject(), true }, + { "rej-RejectableClass", new RejectableClass(), registryFilter != null}, + }; + return data; + } + + static XX createMarshalledObject() { + try { + return new XX(new MarshalledObject<>(null)); + } catch (IOException ioe) { + return new XX(ioe); + } + } + + @BeforeSuite + static void setupRegistry() { + try { + impl = TestLibrary.createRegistryOnEphemeralPort(); + port = TestLibrary.getRegistryPort(impl); + registry = LocateRegistry.getRegistry("localhost", port); + } catch (RemoteException ex) { + Assert.fail("initialization of registry", ex); + } + + System.out.printf("RMI Registry filter: %s%n", registryFilter); + } + + + /* + * Test registry rejects an object with the max array size + 1. + */ + @Test(dataProvider="bindData") + public void simpleBind(String name, Remote obj, boolean blacklisted) throws RemoteException, AlreadyBoundException, NotBoundException { + try { + registry.bind(name, obj); + Assert.assertFalse(blacklisted, "Registry filter did not reject (but should have) "); + registry.unbind(name); + } catch (Exception rex) { + Assert.assertTrue(blacklisted, "Registry filter should not have rejected"); + } + } + + /* + * Test registry rejects an object with a well known class + * if blacklisted in the security properties. + */ + @Test + public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException { + RejectableClass r1 = null; + try { + String name = "reject1"; + r1 = new RejectableClass(); + registry.bind(name, r1); + registry.unbind(name); + Assert.assertNull(registryFilter, "Registry filter should not have rejected"); + } catch (Exception rex) { + Assert.assertNotNull(registryFilter, "Registry filter should have rejected"); + } + } + + /** + * A simple Serializable Remote object that is passed by value. + * It and its contents are checked by the Registry serial filter. + */ + static class XX implements Serializable, Remote { + private static final long serialVersionUID = 362498820763181265L; + + final Object obj; + + XX(Object obj) { + this.obj = obj; + } + + public String toString() { + return super.toString() + "//" + Objects.toString(obj); + } + } + /** + * A simple Serializable Remote object that is passed by value. + * It and its contents are checked by the Registry serial filter. + */ + static class RejectableClass implements Serializable, Remote { + private static final long serialVersionUID = 362498820763181264L; + + RejectableClass() {} + } + +} diff --git a/jdk/test/java/rmi/registry/serialFilter/java.security-extra1 b/jdk/test/java/rmi/registry/serialFilter/java.security-extra1 new file mode 100644 index 00000000000..5c68f6fd344 --- /dev/null +++ b/jdk/test/java/rmi/registry/serialFilter/java.security-extra1 @@ -0,0 +1,9 @@ +# RMI Registry Input Serial Filter +# +# The filter pattern uses the same format as java.io.ObjectInputStream.serialFilter. +# This filter can override the builtin filter if additional types need to be +# allowed or rejected from the RMI Registry. +# +#sun.rmi.registry.registryFilter=pattern,pattern +sun.rmi.registry.registryFilter=!java.lang.Long;!RegistryFilterTest$RejectableClass + diff --git a/jdk/test/java/rmi/registry/serialFilter/security.policy b/jdk/test/java/rmi/registry/serialFilter/security.policy new file mode 100644 index 00000000000..554e9eaee47 --- /dev/null +++ b/jdk/test/java/rmi/registry/serialFilter/security.policy @@ -0,0 +1,4 @@ +grant { + permission java.security.AllPermission; +}; + From ec3a122b19a4c9fb696271195a00a0c11b8b8262 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Thu, 10 Nov 2016 15:46:40 +0000 Subject: [PATCH 018/154] 8168728: DSA signing improvments Reviewed-by: valeriep, vinnie, ahgross, asmotrak, robm --- .../classes/sun/security/provider/DSA.java | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/provider/DSA.java b/jdk/src/java.base/share/classes/sun/security/provider/DSA.java index 554b0cc1cf7..c1cc11bf4ed 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/DSA.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/DSA.java @@ -427,13 +427,49 @@ abstract class DSA extends SignatureSpi { return t5.mod(q); } - // NOTE: This following impl is defined in FIPS 186-4 AppendixB.2.1. protected BigInteger generateK(BigInteger q) { + // Implementation defined in FIPS 186-4 AppendixB.2.1. SecureRandom random = getSigningRandom(); byte[] kValue = new byte[(q.bitLength() + 7)/8 + 8]; random.nextBytes(kValue); - return new BigInteger(1, kValue).mod(q.subtract(BigInteger.ONE)).add(BigInteger.ONE); + BigInteger k = new BigInteger(1, kValue).mod( + q.subtract(BigInteger.ONE)).add(BigInteger.ONE); + + // Using an equivalent exponent of fixed length (same as q or 1 bit + // less than q) to keep the kG timing relatively constant. + // + // Note that this is an extra step on top of the approach defined in + // FIPS 186-4 AppendixB.2.1 so as to make a fixed length K. + k = k.add(q).divide(BigInteger.TWO); + + // An alternative implementation based on FIPS 186-4 AppendixB2.2 + // with fixed-length K. + // + // Please keep it here as we may need to switch to it in the future. + // + // SecureRandom random = getSigningRandom(); + // byte[] kValue = new byte[(q.bitLength() + 7)/8]; + // BigInteger d = q.subtract(BigInteger.TWO); + // BigInteger k; + // do { + // random.nextBytes(kValue); + // BigInteger c = new BigInteger(1, kValue); + // if (c.compareTo(d) <= 0) { + // k = c.add(BigInteger.ONE); + // // Using an equivalent exponent of fixed length to keep + // // the g^k timing relatively constant. + // // + // // Note that this is an extra step on top of the approach + // // defined in FIPS 186-4 AppendixB.2.2 so as to make a + // // fixed length K. + // if (k.bitLength() >= q.bitLength()) { + // break; + // } + // } + // } while (true); + + return k; } // Use the application-specified SecureRandom Object if provided. From fc58c85eb4f88a6340680d448d20ef5c55127ce5 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Thu, 10 Nov 2016 15:52:48 +0000 Subject: [PATCH 019/154] 8168724: ECDSA signing improvments Reviewed-by: valeriep, vinnie, ahgross, asmotrak, robm --- .../jdk.crypto.ec/share/native/libsunec/impl/ec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jdk/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c b/jdk/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c index dd1f9101e25..4f3cab36b8c 100644 --- a/jdk/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c +++ b/jdk/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c @@ -34,7 +34,7 @@ * Dr Vipul Gupta and * Douglas Stebila , Sun Microsystems Laboratories * - * Last Modified Date from the Original Code: Nov 2016 + * Last Modified Date from the Original Code: November 2016 *********************************************************************** */ #include "mplogic.h" @@ -714,6 +714,16 @@ ECDSA_SignDigestWithSeed(ECPrivateKey *key, SECItem *signature, goto cleanup; } + /* + * Using an equivalent exponent of fixed length (same as n or 1 bit less + * than n) to keep the kG timing relatively constant. + * + * Note that this is an extra step on top of the approach defined in + * ANSI X9.62 so as to make a fixed length K. + */ + CHECK_MPI_OK( mp_add(&k, &n, &k) ); + CHECK_MPI_OK( mp_div_2(&k, &k) ); + /* ** ANSI X9.62, Section 5.3.2, Step 2 ** From adcdf5a459fdf690476b76388912e494f2383d00 Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Thu, 17 Nov 2016 02:08:53 +0000 Subject: [PATCH 020/154] 8168714: Tighten ECDSA validation Added additional checks to DER parsing code Reviewed-by: vinnie, ahgross --- .../classes/sun/security/provider/DSA.java | 17 ++-- .../sun/security/rsa/RSASignature.java | 5 +- .../sun/security/util/DerInputBuffer.java | 7 +- .../sun/security/util/DerInputStream.java | 81 ++++++++++++++----- .../classes/sun/security/util/DerValue.java | 6 +- .../sun/security/ec/ECDSASignature.java | 18 +++-- .../sun/security/pkcs11/P11Signature.java | 36 +++++---- 7 files changed, 114 insertions(+), 56 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/provider/DSA.java b/jdk/src/java.base/share/classes/sun/security/provider/DSA.java index c1cc11bf4ed..5763e650284 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/DSA.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/DSA.java @@ -322,19 +322,20 @@ abstract class DSA extends SignatureSpi { } else { // first decode the signature. try { - DerInputStream in = new DerInputStream(signature, offset, - length); + // Enforce strict DER checking for signatures + DerInputStream in = + new DerInputStream(signature, offset, length, false); DerValue[] values = in.getSequence(2); + // check number of components in the read sequence + // and trailing data + if ((values.length != 2) || (in.available() != 0)) { + throw new IOException("Invalid encoding for signature"); + } r = values[0].getBigInteger(); s = values[1].getBigInteger(); - - // Check for trailing signature data - if (in.available() != 0) { - throw new IOException("Incorrect signature length"); - } } catch (IOException e) { - throw new SignatureException("invalid encoding for signature"); + throw new SignatureException("Invalid encoding for signature", e); } } diff --git a/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java b/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java index 43e605a1457..a426f6cd374 100644 --- a/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java +++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSASignature.java @@ -226,9 +226,10 @@ public abstract class RSASignature extends SignatureSpi { * Decode the signature data. Verify that the object identifier matches * and return the message digest. */ - public static byte[] decodeSignature(ObjectIdentifier oid, byte[] signature) + public static byte[] decodeSignature(ObjectIdentifier oid, byte[] sig) throws IOException { - DerInputStream in = new DerInputStream(signature); + // Enforce strict DER checking for signatures + DerInputStream in = new DerInputStream(sig, 0, sig.length, false); DerValue[] values = in.getSequence(2); if ((values.length != 2) || (in.available() != 0)) { throw new IOException("SEQUENCE length error"); diff --git a/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java b/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java index 26bd198741a..1e5600214bc 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java +++ b/jdk/src/java.base/share/classes/sun/security/util/DerInputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -147,6 +147,11 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { System.arraycopy(buf, pos, bytes, 0, len); skip(len); + // check to make sure no extra leading 0s for DER + if (len >= 2 && (bytes[0] == 0) && (bytes[1] >= 0)) { + throw new IOException("Invalid encoding: redundant leading 0s"); + } + if (makePositive) { return new BigInteger(1, bytes); } else { diff --git a/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java b/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java index 264bfd0e9c7..94c9085a7bc 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java +++ b/jdk/src/java.base/share/classes/sun/security/util/DerInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ public class DerInputStream { * @param data the buffer from which to create the string (CONSUMED) */ public DerInputStream(byte[] data) throws IOException { - init(data, 0, data.length); + init(data, 0, data.length, true); } /** @@ -92,23 +92,48 @@ public class DerInputStream { * starting at "offset" */ public DerInputStream(byte[] data, int offset, int len) throws IOException { - init(data, offset, len); + init(data, offset, len, true); + } + + /** + * Create a DER input stream from part of a data buffer with + * additional arg to indicate whether to allow constructed + * indefinite-length encoding. + * The buffer is not copied, it is shared. Accordingly, the + * buffer should be treated as read-only. + * + * @param data the buffer from which to create the string (CONSUMED) + * @param offset the first index of data which will + * be read as DER input in the new stream + * @param len how long a chunk of the buffer to use, + * starting at "offset" + * @param allowIndefiniteLength whether to allow constructed + * indefinite-length encoding + */ + public DerInputStream(byte[] data, int offset, int len, + boolean allowIndefiniteLength) throws IOException { + init(data, offset, len, allowIndefiniteLength); } /* * private helper routine */ - private void init(byte[] data, int offset, int len) throws IOException { + private void init(byte[] data, int offset, int len, + boolean allowIndefiniteLength) throws IOException { if ((offset+2 > data.length) || (offset+len > data.length)) { throw new IOException("Encoding bytes too short"); } // check for indefinite length encoding if (DerIndefLenConverter.isIndefinite(data[offset+1])) { - byte[] inData = new byte[len]; - System.arraycopy(data, offset, inData, 0, len); + if (!allowIndefiniteLength) { + throw new IOException("Indefinite length BER encoding found"); + } else { + byte[] inData = new byte[len]; + System.arraycopy(data, offset, inData, 0, len); - DerIndefLenConverter derIn = new DerIndefLenConverter(); - buffer = new DerInputBuffer(derIn.convert(inData)); + DerIndefLenConverter derIn = new DerIndefLenConverter(); + buffer = new DerInputBuffer(derIn.convert(inData)); + } } else buffer = new DerInputBuffer(data, offset, len); buffer.mark(Integer.MAX_VALUE); @@ -239,15 +264,19 @@ public class DerInputStream { * representation. */ length--; - int validBits = length*8 - buffer.read(); + int excessBits = buffer.read(); + if (excessBits < 0) { + throw new IOException("Unused bits of bit string invalid"); + } + int validBits = length*8 - excessBits; if (validBits < 0) { - throw new IOException("valid bits of bit string invalid"); + throw new IOException("Valid bits of bit string invalid"); } byte[] repn = new byte[length]; if ((length != 0) && (buffer.read(repn) != length)) { - throw new IOException("short read of DER bit string"); + throw new IOException("Short read of DER bit string"); } return new BitArray(validBits, repn); @@ -263,7 +292,7 @@ public class DerInputStream { int length = getDefiniteLength(buffer); byte[] retval = new byte[length]; if ((length != 0) && (buffer.read(retval) != length)) - throw new IOException("short read of DER octet string"); + throw new IOException("Short read of DER octet string"); return retval; } @@ -273,7 +302,7 @@ public class DerInputStream { */ public void getBytes(byte[] val) throws IOException { if ((val.length != 0) && (buffer.read(val) != val.length)) { - throw new IOException("short read of DER octet string"); + throw new IOException("Short read of DER octet string"); } } @@ -357,7 +386,7 @@ public class DerInputStream { DerInputStream newstr; byte lenByte = (byte)buffer.read(); - int len = getLength((lenByte & 0xff), buffer); + int len = getLength(lenByte, buffer); if (len == -1) { // indefinite length encoding found @@ -403,7 +432,7 @@ public class DerInputStream { } while (newstr.available() > 0); if (newstr.available() != 0) - throw new IOException("extra data at end of vector"); + throw new IOException("Extra data at end of vector"); /* * Now stick them into the array we're returning. @@ -494,7 +523,7 @@ public class DerInputStream { int length = getDefiniteLength(buffer); byte[] retval = new byte[length]; if ((length != 0) && (buffer.read(retval) != length)) - throw new IOException("short read of DER " + + throw new IOException("Short read of DER " + stringName + " string"); return new String(retval, enc); @@ -555,7 +584,11 @@ public class DerInputStream { */ static int getLength(int lenByte, InputStream in) throws IOException { int value, tmp; + if (lenByte == -1) { + throw new IOException("Short read of DER length"); + } + String mdName = "DerInputStream.getLength(): "; tmp = lenByte; if ((tmp & 0x080) == 0x00) { // short form, 1 byte datum value = tmp; @@ -569,17 +602,23 @@ public class DerInputStream { if (tmp == 0) return -1; if (tmp < 0 || tmp > 4) - throw new IOException("DerInputStream.getLength(): lengthTag=" - + tmp + ", " + throw new IOException(mdName + "lengthTag=" + tmp + ", " + ((tmp < 0) ? "incorrect DER encoding." : "too big.")); - for (value = 0; tmp > 0; tmp --) { + value = 0x0ff & in.read(); + tmp--; + if (value == 0) { + // DER requires length value be encoded in minimum number of bytes + throw new IOException(mdName + "Redundant length bytes found"); + } + while (tmp-- > 0) { value <<= 8; value += 0x0ff & in.read(); } if (value < 0) { - throw new IOException("DerInputStream.getLength(): " - + "Invalid length bytes"); + throw new IOException(mdName + "Invalid length bytes"); + } else if (value <= 127) { + throw new IOException(mdName + "Should use short form for length"); } } return value; diff --git a/jdk/src/java.base/share/classes/sun/security/util/DerValue.java b/jdk/src/java.base/share/classes/sun/security/util/DerValue.java index 936e2ff70b7..b47064abce9 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/DerValue.java +++ b/jdk/src/java.base/share/classes/sun/security/util/DerValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -248,7 +248,7 @@ public class DerValue { tag = (byte)in.read(); byte lenByte = (byte)in.read(); - length = DerInputStream.getLength((lenByte & 0xff), in); + length = DerInputStream.getLength(lenByte, in); if (length == -1) { // indefinite length encoding found DerInputBuffer inbuf = in.dup(); int readLen = inbuf.available(); @@ -361,7 +361,7 @@ public class DerValue { tag = (byte)in.read(); byte lenByte = (byte)in.read(); - length = DerInputStream.getLength((lenByte & 0xff), in); + length = DerInputStream.getLength(lenByte, in); if (length == -1) { // indefinite length encoding found int readLen = in.available(); int offset = 2; // for tag and length bytes diff --git a/jdk/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java b/jdk/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java index c88c191cb0c..3b743388bdb 100644 --- a/jdk/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java +++ b/jdk/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java @@ -455,18 +455,22 @@ abstract class ECDSASignature extends SignatureSpi { } // Convert the DER encoding of R and S into a concatenation of R and S - private byte[] decodeSignature(byte[] signature) throws SignatureException { + private byte[] decodeSignature(byte[] sig) throws SignatureException { try { - DerInputStream in = new DerInputStream(signature); + // Enforce strict DER checking for signatures + DerInputStream in = new DerInputStream(sig, 0, sig.length, false); DerValue[] values = in.getSequence(2); + + // check number of components in the read sequence + // and trailing data + if ((values.length != 2) || (in.available() != 0)) { + throw new IOException("Invalid encoding for signature"); + } + BigInteger r = values[0].getPositiveBigInteger(); BigInteger s = values[1].getPositiveBigInteger(); - // Check for trailing signature data - if (in.available() != 0) { - throw new IOException("Incorrect signature length"); - } // trim leading zeroes byte[] rBytes = trimZeroes(r.toByteArray()); byte[] sBytes = trimZeroes(s.toByteArray()); @@ -480,7 +484,7 @@ abstract class ECDSASignature extends SignatureSpi { return result; } catch (Exception e) { - throw new SignatureException("Could not decode signature", e); + throw new SignatureException("Invalid encoding for signature", e); } } diff --git a/jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/P11Signature.java b/jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/P11Signature.java index 43dfcd6a0b0..0260a55486d 100644 --- a/jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/P11Signature.java +++ b/jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/P11Signature.java @@ -740,17 +740,21 @@ final class P11Signature extends SignatureSpi { } } - private static byte[] asn1ToDSA(byte[] signature) throws SignatureException { + private static byte[] asn1ToDSA(byte[] sig) throws SignatureException { try { - DerInputStream in = new DerInputStream(signature); + // Enforce strict DER checking for signatures + DerInputStream in = new DerInputStream(sig, 0, sig.length, false); DerValue[] values = in.getSequence(2); + + // check number of components in the read sequence + // and trailing data + if ((values.length != 2) || (in.available() != 0)) { + throw new IOException("Invalid encoding for signature"); + } + BigInteger r = values[0].getPositiveBigInteger(); BigInteger s = values[1].getPositiveBigInteger(); - // Check for trailing signature data - if (in.available() != 0) { - throw new IOException("Incorrect signature length"); - } byte[] br = toByteArray(r, 20); byte[] bs = toByteArray(s, 20); if ((br == null) || (bs == null)) { @@ -760,21 +764,25 @@ final class P11Signature extends SignatureSpi { } catch (SignatureException e) { throw e; } catch (Exception e) { - throw new SignatureException("invalid encoding for signature", e); + throw new SignatureException("Invalid encoding for signature", e); } } - private byte[] asn1ToECDSA(byte[] signature) throws SignatureException { + private byte[] asn1ToECDSA(byte[] sig) throws SignatureException { try { - DerInputStream in = new DerInputStream(signature); + // Enforce strict DER checking for signatures + DerInputStream in = new DerInputStream(sig, 0, sig.length, false); DerValue[] values = in.getSequence(2); + + // check number of components in the read sequence + // and trailing data + if ((values.length != 2) || (in.available() != 0)) { + throw new IOException("Invalid encoding for signature"); + } + BigInteger r = values[0].getPositiveBigInteger(); BigInteger s = values[1].getPositiveBigInteger(); - // Check for trailing signature data - if (in.available() != 0) { - throw new IOException("Incorrect signature length"); - } // trim leading zeroes byte[] br = KeyUtil.trimZeroes(r.toByteArray()); byte[] bs = KeyUtil.trimZeroes(s.toByteArray()); @@ -785,7 +793,7 @@ final class P11Signature extends SignatureSpi { System.arraycopy(bs, 0, res, res.length - bs.length, bs.length); return res; } catch (Exception e) { - throw new SignatureException("invalid encoding for signature", e); + throw new SignatureException("Invalid encoding for signature", e); } } From e859125b09af27267e0850c18c9127d9a274bc2b Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Thu, 17 Nov 2016 16:59:18 +0000 Subject: [PATCH 021/154] 8167223: URL handling improvements Reviewed-by: prappo, chegar --- .../share/classes/java/net/URLStreamHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java b/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java index 30c9791cd95..8ce586bdcaa 100644 --- a/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java +++ b/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java @@ -161,9 +161,9 @@ public abstract class URLStreamHandler { (spec.charAt(start + 1) == '/')) { start += 2; i = spec.indexOf('/', start); - if (i < 0) { + if (i < 0 || i > limit) { i = spec.indexOf('?', start); - if (i < 0) + if (i < 0 || i > limit) i = limit; } @@ -171,8 +171,14 @@ public abstract class URLStreamHandler { int ind = authority.indexOf('@'); if (ind != -1) { - userInfo = authority.substring(0, ind); - host = authority.substring(ind+1); + if (ind != authority.lastIndexOf('@')) { + // more than one '@' in authority. This is not server based + userInfo = null; + host = null; + } else { + userInfo = authority.substring(0, ind); + host = authority.substring(ind+1); + } } else { userInfo = null; } From 3a41c2175c622a1cc4e8470b1fff6d51a10fe462 Mon Sep 17 00:00:00 2001 From: Anthony Scarpino Date: Thu, 17 Nov 2016 09:51:10 -0800 Subject: [PATCH 022/154] 8168705: Better ObjectIdentifier validation Reviewed-by: mullan, asmotrak, ahgross --- .../share/classes/sun/security/util/ObjectIdentifier.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java b/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java index 0e9bd41a71c..12aabe6f071 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java +++ b/jdk/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java @@ -255,7 +255,13 @@ class ObjectIdentifier implements Serializable + " (tag = " + type_id + ")" ); - encoding = new byte[in.getDefiniteLength()]; + int len = in.getDefiniteLength(); + if (len > in.available()) { + throw new IOException("ObjectIdentifier() -- length exceeds" + + "data available. Length: " + len + ", Available: " + + in.available()); + } + encoding = new byte[len]; in.getBytes(encoding); check(encoding); } From 6118a4085bf72432cf131a914e35a9a9dbde6445 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 20 Dec 2016 09:47:22 -0800 Subject: [PATCH 023/154] 8166111: [PIT] possible regression: java/awt/font/GlyphVector/TestLayoutFlags.java Reviewed-by: serb --- jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java b/jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java index f5111b2daf6..4b1806f96d7 100644 --- a/jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java +++ b/jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* @test - @bug 4328745 5090704 + @bug 4328745 5090704 8166111 @summary exercise getLayoutFlags, getGlyphCharIndex, getGlyphCharIndices */ @@ -82,7 +82,7 @@ public class TestLayoutFlags { test("latin", latinGV, GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS); test("hebrew", hebrewGV, GlyphVector.FLAG_RUN_RTL | GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS); - test("arabic", arabicGV, GlyphVector.FLAG_RUN_RTL | + test("arabic", arabicGV, GlyphVector.FLAG_COMPLEX_GLYPHS | GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS); test("hindi", hindiGV, GlyphVector.FLAG_COMPLEX_GLYPHS | GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS); From 8b371aa02b2ab8b91cf0901b1e03262a9973eff1 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 20 Dec 2016 09:52:14 -0800 Subject: [PATCH 024/154] 8130737: AffineTransformOp can't handle child raster with non-zero x-offset Reviewed-by: serb, flar --- .../libawt/awt/medialib/awt_ImagingLib.c | 14 +-- .../share/native/libmlib_image/safe_alloc.h | 4 +- .../awt/image/Raster/TestChildRasterOp.java | 99 +++++++++++++++++++ 3 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 jdk/test/java/awt/image/Raster/TestChildRasterOp.java diff --git a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c index 15c705a5fec..0a934d5fff7 100644 --- a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c +++ b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c @@ -2419,7 +2419,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, case sun_awt_image_IntegerComponentRaster_TYPE_INT_8BIT_SAMPLES: if (!((rasterP->chanOffsets[0] == 0 || SAFE_TO_ALLOC_2(rasterP->chanOffsets[0], 4)) && SAFE_TO_ALLOC_2(width, 4) && - SAFE_TO_ALLOC_3(height, rasterP->scanlineStride, 4))) + SAFE_TO_ALLOC_3(rasterP->scanlineStride, height, 4))) { return -1; } @@ -2428,7 +2428,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, if (offset < 0 || offset >= dataSize || width > rasterP->scanlineStride || - height * rasterP->scanlineStride * 4 > dataSize - offset) + ((width + (height - 1) * rasterP->scanlineStride) * 4) > dataSize - offset) { // raster data buffer is too short return -1; @@ -2446,7 +2446,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, return 0; case sun_awt_image_IntegerComponentRaster_TYPE_BYTE_SAMPLES: if (!(SAFE_TO_ALLOC_2(width, rasterP->numBands) && - SAFE_TO_ALLOC_2(height, rasterP->scanlineStride))) + SAFE_TO_ALLOC_2(rasterP->scanlineStride, height))) { return -1; } @@ -2455,7 +2455,8 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, if (offset < 0 || offset >= dataSize || width * rasterP->numBands > rasterP->scanlineStride || - height * rasterP->scanlineStride > dataSize - offset) + ((width * rasterP->numBands) + + (height - 1) * rasterP->scanlineStride) > dataSize - offset) { // raster data buffer is too short return -1; @@ -2474,7 +2475,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, case sun_awt_image_IntegerComponentRaster_TYPE_USHORT_SAMPLES: if (!((rasterP->chanOffsets[0] == 0 || SAFE_TO_ALLOC_2(rasterP->chanOffsets[0], 2)) && SAFE_TO_ALLOC_3(width, rasterP->numBands, 2) && - SAFE_TO_ALLOC_3(height, rasterP->scanlineStride, 2))) + SAFE_TO_ALLOC_3(rasterP->scanlineStride, height, 2))) { return -1; } @@ -2483,7 +2484,8 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, if (offset < 0 || offset >= dataSize || width * rasterP->numBands > rasterP->scanlineStride || - height * rasterP->scanlineStride * 2 > dataSize - offset) + (((width * rasterP->numBands) + + (height - 1) * rasterP->scanlineStride)) * 2 > dataSize - offset) { // raster data buffer is too short return -1; diff --git a/jdk/src/java.desktop/share/native/libmlib_image/safe_alloc.h b/jdk/src/java.desktop/share/native/libmlib_image/safe_alloc.h index 1ee99048e9b..2565d33ac91 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/safe_alloc.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/safe_alloc.h @@ -35,10 +35,10 @@ */ #define SAFE_TO_ALLOC_2(c, sz) \ (((c) > 0) && ((sz) > 0) && \ - ((0xffffffffu / ((juint)(c))) > ((juint)(sz)))) + ((0x7fffffff / (c)) > (sz))) #define SAFE_TO_ALLOC_3(w, h, sz) \ (((w) > 0) && ((h) > 0) && ((sz) > 0) && \ - (((0xffffffffu / ((juint)(w))) / ((juint)(h))) > ((juint)(sz)))) + (((0x7fffffff / (w)) / (h)) > (sz))) #endif // __SAFE_ALLOC_H__ diff --git a/jdk/test/java/awt/image/Raster/TestChildRasterOp.java b/jdk/test/java/awt/image/Raster/TestChildRasterOp.java new file mode 100644 index 00000000000..35ab5706816 --- /dev/null +++ b/jdk/test/java/awt/image/Raster/TestChildRasterOp.java @@ -0,0 +1,99 @@ +/* + * 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. + */ + +/** + * @bug 8130737 + * @test + * @summary test no exception rasterop for child raster with non-zero offset + */ + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.DataBufferInt; +import java.awt.image.DataBufferUShort; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; + +public class TestChildRasterOp { + + private static AffineTransform at = new AffineTransform(); + private static final AffineTransformOp rop = + new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + private static int[] offsets = {0}; + + public static void main(String[] args) { + testByteRaster(); + testShortRaster(); + testIntRaster(); + } + + private static void testByteRaster() { + WritableRaster srcRaster, dstRaster; + + byte[] pixels = + { 11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44 }; + + DataBuffer db = new DataBufferByte(pixels, pixels.length); + srcRaster = + Raster.createInterleavedRaster(db, 4, 4, 4, 1, offsets, null); + srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null); + dstRaster = rop.filter(srcRaster, null); + } + + private static void testShortRaster() { + WritableRaster srcRaster, dstRaster; + + short[] pixels = + { 11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44 }; + + DataBuffer db = new DataBufferUShort(pixels, pixels.length); + srcRaster = + Raster.createInterleavedRaster(db, 4, 4, 4, 1, offsets, null); + srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null); + dstRaster = rop.filter(srcRaster, null); + } + + private static void testIntRaster() { + WritableRaster srcRaster, dstRaster; + + int[] pixels = + { 11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44 }; + + DataBuffer db = new DataBufferInt(pixels, pixels.length); + srcRaster = + Raster.createPackedRaster(db, 4, 4, 4, offsets, null); + srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null); + dstRaster = rop.filter(srcRaster, null); + } +} From 4c934b1e6a7b729569989e3d54d38aca1c81fb12 Mon Sep 17 00:00:00 2001 From: Maksim Khramov Date: Wed, 21 Dec 2016 17:34:41 +0300 Subject: [PATCH 025/154] 8154314: [TEST_BUG] java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java Reviewed-by: ssadetsky, serb --- .../MultiResolutionDragImageTest.java | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/jdk/test/java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java b/jdk/test/java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java index bb24972c7d0..23a2ea7c717 100644 --- a/jdk/test/java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java +++ b/jdk/test/java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java @@ -22,7 +22,6 @@ */ import sun.awt.image.MultiResolutionToolkitImage; -import sun.java2d.SunGraphics2D; import javax.swing.*; import java.awt.*; @@ -37,7 +36,6 @@ import static java.awt.event.InputEvent.BUTTON1_DOWN_MASK; * @summary [macosx] Drag image of TransferHandler does not honor * MultiResolutionImage * @modules java.desktop/sun.awt.image - * java.desktop/sun.java2d * @run main MultiResolutionDragImageTest TEST_DRAG */ public class MultiResolutionDragImageTest { @@ -126,30 +124,11 @@ public class MultiResolutionDragImageTest { return Math.abs(n - m) <= 50; } - private static float getScaleFactor() { - - final Dialog dialog = new Dialog((Window) null); - dialog.setSize(100, 100); - dialog.setModal(true); - final float[] scaleFactors = new float[1]; - Panel panel = new Panel() { - - @Override - public void paint(Graphics g) { - float scaleFactor = 1; - if (g instanceof SunGraphics2D) { - scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale(); - } - scaleFactors[0] = scaleFactor; - dialog.setVisible(false); - } - }; - - dialog.add(panel); - dialog.setVisible(true); - dialog.dispose(); - - return scaleFactors[0]; + static float getScaleFactor() { + return (float) GraphicsEnvironment. + getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(). + getDefaultTransform().getScaleX(); } private static Image createMultiResolutionImage() { From 4d06c5d6fab781f27a7eeddd097bb48f0d7fa9a9 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 22 Dec 2016 12:09:34 +0300 Subject: [PATCH 026/154] 8169922: SwingMark/TextArea: 2-7% regression on Linux, Mac, Windows in 9-b143 Reviewed-by: flar, serb --- .../javax/swing/text/PasswordView.java | 23 +-- .../classes/javax/swing/text/PlainView.java | 147 ++++++++++++------ .../javax/swing/text/WrappedPlainView.java | 55 ++----- .../text/View/8156217/FPMethodCalledTest.java | 2 +- 4 files changed, 114 insertions(+), 113 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java index 7da3fa313b2..38bb0eec13e 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PasswordView.java @@ -27,10 +27,7 @@ package javax.swing.text; import sun.swing.SwingUtilities2; import java.awt.*; import java.awt.font.FontRenderContext; -import java.security.AccessController; -import java.security.PrivilegedAction; import javax.swing.JPasswordField; -import static javax.swing.text.PlainView.isFPMethodOverriden; /** * Implements a View suitable for use in JPasswordField @@ -332,22 +329,6 @@ public class PasswordView extends FieldView { static char[] ONE = new char[1]; - private final boolean drawEchoCharacterOverridden; - - { - final Class CLS = getClass(); - final Class INT = Integer.TYPE; - final Class FP = Float.TYPE; - final Class CHAR = Character.TYPE; - - drawEchoCharacterOverridden = AccessController - .doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - Class[] intTypes = {Graphics.class, INT, INT, CHAR}; - Class[] fpTypes = {Graphics2D.class, FP, FP, CHAR}; - return isFPMethodOverriden("drawEchoCharacter", CLS, intTypes, fpTypes); - } - }); - } + private final boolean drawEchoCharacterOverridden = + getFPMethodOverridden(getClass(), "drawEchoCharacter", FPMethodArgs.GNNC); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java index e04c95aecd6..4430b4e1c89 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/PlainView.java @@ -32,6 +32,8 @@ import java.security.PrivilegedAction; import java.util.Objects; import javax.swing.event.*; import java.lang.reflect.Module; +import java.lang.ref.SoftReference; +import java.util.HashMap; /** * Implements View interface for a simple multi-line text view @@ -818,10 +820,45 @@ public class PlainView extends View implements TabExpander { return w; } - static boolean isFPMethodOverriden(String method, - Class cls, - Class[] intTypes, - Class[] fpTypes) + static boolean getFPMethodOverridden(Class cls, String method, + FPMethodArgs methodArgs) { + HashMap map = null; + boolean initialized = methodsOverriddenMapRef != null + && (map = methodsOverriddenMapRef.get()) != null; + + if (!initialized) { + map = new HashMap<>(); + methodsOverriddenMapRef = new SoftReference<>(map); + } + + FPMethodItem key = new FPMethodItem(cls, method); + Boolean isFPMethodOverridden = map.get(key); + if (isFPMethodOverridden == null) { + isFPMethodOverridden = checkFPMethodOverridden(cls, method, methodArgs); + map.put(key, isFPMethodOverridden); + } + return isFPMethodOverridden; + } + + private static boolean checkFPMethodOverridden(final Class className, + final String methodName, + final FPMethodArgs methodArgs) { + + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override + public Boolean run() { + return isFPMethodOverridden(methodName, className, + methodArgs.getMethodArguments(false), + methodArgs.getMethodArguments(true)); + } + }); + } + + private static boolean isFPMethodOverridden(String method, + Class cls, + Class[] intTypes, + Class[] fpTypes) { Module thisModule = PlainView.class.getModule(); while (!thisModule.equals(cls.getModule())) { @@ -840,6 +877,57 @@ public class PlainView extends View implements TabExpander { return true; } + enum FPMethodArgs { + + IGNN, + IIGNN, + GNNII, + GNNC; + + public Class[] getMethodArguments(boolean isFPType) { + Class N = (isFPType) ? Float.TYPE : Integer.TYPE; + Class G = (isFPType) ? Graphics2D.class : Graphics.class; + switch (this) { + case IGNN: + return new Class[]{Integer.TYPE, G, N, N}; + case IIGNN: + return new Class[]{Integer.TYPE, Integer.TYPE, G, N, N}; + case GNNII: + return new Class[]{G, N, N, Integer.TYPE, Integer.TYPE}; + case GNNC: + return new Class[]{G, N, N, Character.TYPE}; + default: + throw new RuntimeException("Unknown method arguments!"); + } + } + } + + private static class FPMethodItem { + + final Class className; + final String methodName; + + public FPMethodItem(Class className, String methodName) { + this.className = className; + this.methodName = methodName; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof FPMethodItem) { + FPMethodItem that = (FPMethodItem) obj; + return this.className.equals(that.className) + && this.methodName.equals(that.methodName); + } + return false; + } + + @Override + public int hashCode() { + return 31 * methodName.hashCode() + className.hashCode(); + } + } + // --- member variables ----------------------------------------------- /** @@ -878,46 +966,13 @@ public class PlainView extends View implements TabExpander { */ int firstLineOffset; - final boolean drawLineOverridden; - final boolean drawSelectedTextOverridden; - final boolean drawUnselectedTextOverridden; - final boolean useFloatingPointAPI; - - { - final Class CLS = getClass(); - final Class INT = Integer.TYPE; - final Class FP = Float.TYPE; - - drawLineOverridden = AccessController - .doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - Class[] intTypes = {INT, Graphics.class, INT, INT}; - Class[] fpTypes = {INT, Graphics2D.class, FP, FP}; - return isFPMethodOverriden("drawLine", CLS, intTypes, fpTypes); - } - }); - - drawUnselectedTextOverridden = AccessController - .doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - Class[] intTypes = {Graphics.class, INT, INT, INT, INT}; - Class[] fpTypes = {Graphics2D.class, FP, FP, INT, INT}; - return isFPMethodOverriden("drawUnselectedText", CLS, intTypes, fpTypes); - } - }); - - drawSelectedTextOverridden = AccessController - .doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - Class[] intTypes = {Graphics.class, INT, INT, INT, INT}; - Class[] fpTypes = {Graphics2D.class, FP, FP, INT, INT}; - return isFPMethodOverriden("drawSelectedText", CLS, intTypes, fpTypes); - } - }); - - useFloatingPointAPI = drawUnselectedTextOverridden || drawSelectedTextOverridden; - } + private static SoftReference> methodsOverriddenMapRef; + final boolean drawLineOverridden = + getFPMethodOverridden(getClass(), "drawLine", FPMethodArgs.IGNN); + final boolean drawSelectedTextOverridden = + getFPMethodOverridden(getClass(), "drawSelectedText", FPMethodArgs.GNNII); + final boolean drawUnselectedTextOverridden = + getFPMethodOverridden(getClass(), "drawUnselectedText", FPMethodArgs.GNNII); + final boolean useFloatingPointAPI = + drawUnselectedTextOverridden || drawSelectedTextOverridden; } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java index dde3437adf4..7cb83f755c2 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java @@ -28,10 +28,9 @@ import java.awt.*; import java.awt.font.FontRenderContext; import java.awt.geom.Rectangle2D; import java.lang.ref.SoftReference; -import java.security.AccessController; -import java.security.PrivilegedAction; import javax.swing.event.*; -import static javax.swing.text.PlainView.isFPMethodOverriden; +import static javax.swing.text.PlainView.FPMethodArgs.*; +import static javax.swing.text.PlainView.getFPMethodOverridden; /** * View of plain text (text with only one font and color) @@ -989,46 +988,12 @@ public class WrappedPlainView extends BoxView implements TabExpander { SoftReference lineCache = null; } - private final boolean drawLineOverridden; - private final boolean drawSelectedTextOverridden; - private final boolean drawUnselectedTextOverridden; - private final boolean useFloatingPointAPI; - - { - final Class CLS = getClass(); - final Class INT = Integer.TYPE; - final Class FP = Float.TYPE; - - drawLineOverridden = AccessController - .doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - Class[] intTypes = {INT, INT, Graphics.class, INT, INT}; - Class[] fpTypes = {INT, INT, Graphics2D.class, FP, FP}; - return isFPMethodOverriden("drawLine", CLS, intTypes, fpTypes); - } - }); - - drawUnselectedTextOverridden = AccessController - .doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - Class[] intTypes = {Graphics.class, INT, INT, INT, INT}; - Class[] fpTypes = {Graphics2D.class, FP, FP, INT, INT}; - return isFPMethodOverriden("drawUnselectedText", CLS, intTypes, fpTypes); - } - }); - - drawSelectedTextOverridden = AccessController - .doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - Class[] intTypes = {Graphics.class, INT, INT, INT, INT}; - Class[] fpTypes = {Graphics2D.class, FP, FP, INT, INT}; - return isFPMethodOverriden("drawSelectedText", CLS, intTypes, fpTypes); - } - }); - - useFloatingPointAPI = drawUnselectedTextOverridden || drawSelectedTextOverridden; - } + private final boolean drawLineOverridden = + getFPMethodOverridden(getClass(), "drawLine", IIGNN); + private final boolean drawSelectedTextOverridden = + getFPMethodOverridden(getClass(), "drawSelectedText", GNNII); + private final boolean drawUnselectedTextOverridden = + getFPMethodOverridden(getClass(), "drawUnselectedText", GNNII); + private final boolean useFloatingPointAPI = + drawUnselectedTextOverridden || drawSelectedTextOverridden; } diff --git a/jdk/test/javax/swing/text/View/8156217/FPMethodCalledTest.java b/jdk/test/javax/swing/text/View/8156217/FPMethodCalledTest.java index ed9693bbb0c..5ac336133b8 100644 --- a/jdk/test/javax/swing/text/View/8156217/FPMethodCalledTest.java +++ b/jdk/test/javax/swing/text/View/8156217/FPMethodCalledTest.java @@ -42,7 +42,7 @@ import javax.swing.text.WrappedPlainView; /** * @test - * @bug 8156217 + * @bug 8156217 8169922 * @key headful * @summary Selected text is shifted on HiDPI display * @run main FPMethodCalledTest From 803735d54775b4ec5b7a4b649d99cc5f0b21f71f Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 22 Dec 2016 12:17:56 +0300 Subject: [PATCH 027/154] 8133919: [macosx] JTable grid lines are incorrectly positioned on HiDPI display Reviewed-by: serb --- .../javax/swing/plaf/basic/BasicTableUI.java | 6 +- .../JTable/8133919/DrawGridLInesTest.java | 103 ++++++++++++++++++ 2 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 jdk/test/javax/swing/JTable/8133919/DrawGridLInesTest.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java index ffa4e603950..d819a583f32 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java @@ -2018,7 +2018,7 @@ public class BasicTableUI extends TableUI int y = damagedArea.y; for (int row = rMin; row <= rMax; row++) { y += table.getRowHeight(row); - g.drawLine(damagedArea.x, y - 1, tableWidth - 1, y - 1); + SwingUtilities2.drawHLine(g, damagedArea.x, tableWidth - 1, y - 1); } } if (table.getShowVerticalLines()) { @@ -2030,14 +2030,14 @@ public class BasicTableUI extends TableUI for (int column = cMin; column <= cMax; column++) { int w = cm.getColumn(column).getWidth(); x += w; - g.drawLine(x - 1, 0, x - 1, tableHeight - 1); + SwingUtilities2.drawVLine(g, x - 1, 0, tableHeight - 1); } } else { x = damagedArea.x; for (int column = cMax; column >= cMin; column--) { int w = cm.getColumn(column).getWidth(); x += w; - g.drawLine(x - 1, 0, x - 1, tableHeight - 1); + SwingUtilities2.drawVLine(g, x - 1, 0, tableHeight - 1); } } } diff --git a/jdk/test/javax/swing/JTable/8133919/DrawGridLInesTest.java b/jdk/test/javax/swing/JTable/8133919/DrawGridLInesTest.java new file mode 100644 index 00000000000..d6ab6041c13 --- /dev/null +++ b/jdk/test/javax/swing/JTable/8133919/DrawGridLInesTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 8133919 + * @summary [macosx] JTable grid lines are incorrectly positioned on HiDPI display + * @run main DrawGridLinesTest + */ +public class DrawGridLinesTest { + + private static final int WIDTH = 300; + private static final int HEIGHT = 150; + private static final Color GRID_COLOR = Color.BLACK; + private static final Color TABLE_BACKGROUND_COLOR = Color.BLUE; + private static final Color CELL_RENDERER_BACKGROUND_COLOR = Color.YELLOW; + private static final int SCALE = 2; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(DrawGridLinesTest::checkTableGridLines); + } + + private static void checkTableGridLines() { + + TableModel dataModel = new AbstractTableModel() { + public int getColumnCount() { + return 10; + } + + public int getRowCount() { + return 10; + } + + public Object getValueAt(int row, int col) { + return " "; + } + }; + + DefaultTableCellRenderer r = new DefaultTableCellRenderer(); + r.setOpaque(true); + r.setBackground(CELL_RENDERER_BACKGROUND_COLOR); + + JTable table = new JTable(dataModel); + table.setSize(WIDTH, HEIGHT); + table.setDefaultRenderer(Object.class, r); + table.setGridColor(GRID_COLOR); + table.setShowGrid(true); + table.setShowHorizontalLines(true); + table.setShowVerticalLines(true); + table.setBackground(TABLE_BACKGROUND_COLOR); + + checkTableGridLines(table); + } + + private static void checkTableGridLines(JTable table) { + + int w = SCALE * WIDTH; + int h = SCALE * HEIGHT; + + BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g = img.createGraphics(); + g.scale(SCALE, SCALE); + table.paint(g); + g.dispose(); + + int size = Math.min(w, h); + int rgb = TABLE_BACKGROUND_COLOR.getRGB(); + + for (int i = 0; i < size; i++) { + if (img.getRGB(i, i) == rgb || img.getRGB(i, size - i - 1) == rgb) { + throw new RuntimeException("Artifacts in the table background color!"); + } + } + } +} From ba4736cba3c5ea90731a1190d99c065899cf1a22 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 22 Dec 2016 18:30:27 +0530 Subject: [PATCH 028/154] 8170349: The printed content is beyond the borders Reviewed-by: alexsch, aniyogi --- .../classes/javax/swing/TablePrintable.java | 19 +- .../javax/swing/plaf/basic/BasicTableUI.java | 20 +- .../PrintManualTest_FitWidthMultiple.java | 218 ++++++++++++++++++ 3 files changed, 251 insertions(+), 6 deletions(-) create mode 100644 jdk/test/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/TablePrintable.java b/jdk/src/java.desktop/share/classes/javax/swing/TablePrintable.java index b47f8696662..4c8eb0529ab 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/TablePrintable.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/TablePrintable.java @@ -380,6 +380,12 @@ class TablePrintable implements Printable { // print the current section of the table g2d.translate(-clip.x, -clip.y); g2d.clip(clip); + + // set a property so that BasicTableUI#paint can know JTable printMode + // is FIT_WIDTH since TablePrintable.printMode is not accessible from BasicTableUI + if (printMode == JTable.PrintMode.FIT_WIDTH) { + table.putClientProperty("Table.printMode", JTable.PrintMode.FIT_WIDTH); + } table.print(g2d); // restore the original transform and clip @@ -407,8 +413,18 @@ class TablePrintable implements Printable { for(int visrow = rMin; visrow < rMax; visrow++) { rowHeight += table.getRowHeight(visrow); } - g2d.drawRect(0, 0, visibleBounds.width, hclip.height + rowHeight); + // If PrintMode is FIT_WIDTH, then draw rect for entire column width while + // printing irrespective of how many columns are visible in console + if (printMode == JTable.PrintMode.FIT_WIDTH) { + g2d.drawRect(0, 0, clip.width, hclip.height + rowHeight); + } else { + g2d.drawRect(0, 0, visibleBounds.width, hclip.height + rowHeight); + } + // clear the property + if (printMode == JTable.PrintMode.FIT_WIDTH) { + table.putClientProperty("Table.printMode", null); + } // dispose the graphics copy g2d.dispose(); @@ -534,5 +550,4 @@ class TablePrintable implements Printable { } while (clip.width + colWidth <= pw); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java index d819a583f32..b80d7efa54a 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java @@ -1812,12 +1812,12 @@ public class BasicTableUI extends TableUI } boolean ltr = table.getComponentOrientation().isLeftToRight(); - + Point upperLeft, lowerRight; // compute the visible part of table which needs to be painted Rectangle visibleBounds = clip.intersection(bounds); - Point upperLeft = visibleBounds.getLocation(); - Point lowerRight = new Point(visibleBounds.x + visibleBounds.width - 1, - visibleBounds.y + visibleBounds.height - 1); + upperLeft = visibleBounds.getLocation(); + lowerRight = new Point(visibleBounds.x + visibleBounds.width - 1, + visibleBounds.y + visibleBounds.height - 1); int rMin = table.rowAtPoint(upperLeft); int rMax = table.rowAtPoint(lowerRight); @@ -1834,6 +1834,18 @@ public class BasicTableUI extends TableUI rMax = table.getRowCount()-1; } + // For FIT_WIDTH, all columns should be printed irrespective of + // how many columns are visible. So, we used clip which is already set to + // total col width instead of visible region + // Since JTable.PrintMode is not accessible + // from here, we aet "Table.printMode" in TablePrintable#print and + // access from here. + Object printMode = table.getClientProperty("Table.printMode"); + if ((printMode == JTable.PrintMode.FIT_WIDTH)) { + upperLeft = clip.getLocation(); + lowerRight = new Point(clip.x + clip.width - 1, + clip.y + clip.height - 1); + } int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight); int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft); // This should never happen. diff --git a/jdk/test/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java b/jdk/test/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java new file mode 100644 index 00000000000..d22d2982683 --- /dev/null +++ b/jdk/test/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java @@ -0,0 +1,218 @@ +/* + * 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 8170349 + * @summary Verify if printed content is within border and all columns are + * printed for PrintMode.FIT_WIDTH + * @run main/manual PrintManualTest_FitWidthMultiple + */ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.text.MessageFormat; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; + +public class PrintManualTest_FitWidthMultiple extends JTable implements Runnable { + + static boolean testPassed; + static JFrame fr = null; + static JFrame instructFrame = null; + private final CountDownLatch latch; + + public PrintManualTest_FitWidthMultiple(CountDownLatch latch){ + this.latch = latch; + } + + @Override + public void run() { + try { + createUIandTest(); + } catch (Exception ex) { + dispose(); + latch.countDown(); + throw new RuntimeException(ex.getMessage()); + } + } + + private void createUIandTest() throws Exception { + /*Message Format Header and Footer */ + final MessageFormat header=new MessageFormat("JTable Printing Header {0}"); + final MessageFormat footer = new MessageFormat("JTable Printing Footer {0}"); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + /* Instructions Section */ + String info = + " \nThis test case brings up JTable with more Columns and Rows \n"+ + "Press the Print Button. It Prints in PRINT_MODE_FIT_WIDTH \n" + + "It Pops up the Print Dialog. Check if Job/Print Attributes in the\n" + + "Print Dialog are configurable. Default Print out will be in Landscape \n"+ + "The Print out should have JTable Centered on the Print out with thin borders \n"+ + "Prints out with Header and Footer. \n"+ + "The JTable should have all columns printed within border"; + + instructFrame=new JFrame("PrintManualTest_NormalSingle"); + JPanel panel=new JPanel(new BorderLayout()); + JButton button1 = new JButton("Pass"); + JButton button2 = new JButton("Fail"); + button1.addActionListener((e) -> { + testPassed = true; + dispose(); + latch.countDown(); + }); + button2.addActionListener((e) -> { + testPassed = false; + dispose(); + latch.countDown(); + }); + JPanel btnpanel1 = new JPanel(); + btnpanel1.add(button1); + btnpanel1.add(button2); + panel.add(addInfo(info),BorderLayout.CENTER); + panel.add(btnpanel1, BorderLayout.SOUTH); + instructFrame.getContentPane().add(panel); + instructFrame.setBounds(600,100,350,350); + + /* Print Button */ + final JButton printButton=new JButton("Print"); + + /* Table Model */ + final TableModel datamodel=new AbstractTableModel(){ + @Override + public int getColumnCount() { return 50;} + @Override + public int getRowCount() { return 50; } + @Override + public Object getValueAt(int row, int column){ return new Integer(row*column);} + }; + + /* Constructing the JTable */ + final JTable table=new JTable(datamodel); + + /* Putting the JTable in ScrollPane and Frame Container */ + JScrollPane scrollpane=new JScrollPane(table); + fr = new JFrame("PrintManualTest_FitWidthMultiple"); + fr.getContentPane().add(scrollpane); + + /* Light Weight Panel for holding Print and other buttons */ + JPanel btnpanel=new JPanel(); + btnpanel.add(printButton); + fr.getContentPane().add(btnpanel,BorderLayout.SOUTH); + fr.setBounds(0,0,400,400); + fr.setSize(500,500); + + /* Binding the KeyStroke to Print Button Action */ + fr.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl P"), "printButton"); + fr.getRootPane().getActionMap().put("printButton", new AbstractAction(){ + @Override + public void actionPerformed(ActionEvent e){ + printButton.doClick(); + } + }); + + /* Container and Component Listeners */ + fr.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + dispose(); + if (testPassed == false) { + throw new RuntimeException(" User has not executed the test"); + } + } + }); + + final PrintRequestAttributeSet prattr=new HashPrintRequestAttributeSet(); + prattr.add(javax.print.attribute.standard.OrientationRequested.LANDSCAPE); + + printButton.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent ae){ + try{ + table.print(JTable.PrintMode.FIT_WIDTH, header,footer,true,prattr,true); + } catch(Exception e){} + } + }); + instructFrame.setVisible(true); + fr.setVisible(true); + } + }); + } + + public void dispose() { + instructFrame.dispose(); + fr.dispose(); + } + + public JScrollPane addInfo(String info) { + JTextArea jta = new JTextArea(info,8,20); + jta.setEditable(false); + jta.setLineWrap(true); + JScrollPane sp = new JScrollPane(jta); + return sp; + + } + + /* Main Method */ + + public static void main(String[] argv) throws Exception { + final CountDownLatch latch = new CountDownLatch(1); + PrintManualTest_FitWidthMultiple test = new PrintManualTest_FitWidthMultiple(latch); + Thread T1 = new Thread(test); + T1.start(); + + // wait for latch to complete + boolean ret = false; + try { + ret = latch.await(60, TimeUnit.SECONDS); + } catch (InterruptedException ie) { + throw ie; + } + if (!ret) { + test.dispose(); + throw new RuntimeException(" User has not executed the test"); + } + if (test.testPassed == false) { + throw new RuntimeException("printed contents is beyond borders"); + } + } +} From 482ad348b5a72d22aff60c60463076bfb55c1ed8 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 22 Dec 2016 18:09:58 +0300 Subject: [PATCH 029/154] 8169900: The code which use Applets should be deprecated Reviewed-by: prr --- .../classes/java/beans/AppletInitializer.java | 11 ++++----- .../share/classes/java/beans/Beans.java | 24 +++++++++++++------ .../classes/javax/swing/PopupFactory.java | 1 + .../classes/javax/swing/RepaintManager.java | 6 ++++- .../share/classes/sun/applet/AppletEvent.java | 5 ++++ .../sun/applet/AppletEventMulticaster.java | 5 ++++ .../classes/sun/applet/AppletIOException.java | 8 +++++-- .../AppletIllegalArgumentException.java | 8 +++++-- .../classes/sun/applet/AppletImageRef.java | 1 + .../classes/sun/applet/AppletListener.java | 6 ++++- .../sun/applet/AppletObjectInputStream.java | 6 ++++- .../share/classes/sun/applet/AppletPanel.java | 7 +++++- .../share/classes/sun/applet/AppletProps.java | 2 ++ .../classes/sun/applet/AppletViewer.java | 12 ++++++++-- .../sun/applet/AppletViewerFactory.java | 4 ++-- .../classes/sun/applet/AppletViewerPanel.java | 5 ++++ .../share/classes/sun/applet/Main.java | 5 ++++ .../share/classes/sun/awt/EmbeddedFrame.java | 8 +++++-- 18 files changed, 96 insertions(+), 28 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java b/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java index 50c54643209..1e2a99b357c 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java +++ b/jdk/src/java.desktop/share/classes/java/beans/AppletInitializer.java @@ -30,21 +30,20 @@ import java.applet.Applet; import java.beans.beancontext.BeanContext; /** - *

* This interface is designed to work in collusion with java.beans.Beans.instantiate. * The interface is intended to provide mechanism to allow the proper * initialization of JavaBeans that are also Applets, during their * instantiation by java.beans.Beans.instantiate(). - *

* * @see java.beans.Beans#instantiate * * @since 1.2 * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ - - -@SuppressWarnings("deprecation") +@Deprecated(since = "9") public interface AppletInitializer { /** @@ -74,7 +73,6 @@ public interface AppletInitializer { * @param bCtxt The BeanContext intended for this Applet, or * null. */ - void initialize(Applet newAppletBean, BeanContext bCtxt); /** @@ -86,6 +84,5 @@ public interface AppletInitializer { * * @param newApplet The newly instantiated JavaBean */ - void activate(Applet newApplet); } diff --git a/jdk/src/java.desktop/share/classes/java/beans/Beans.java b/jdk/src/java.desktop/share/classes/java/beans/Beans.java index 43e5c42ffd0..c8b820bb4dc 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/Beans.java +++ b/jdk/src/java.desktop/share/classes/java/beans/Beans.java @@ -97,8 +97,10 @@ public class Beans { * @exception IOException if an I/O error occurs. * @since 1.2 */ - - public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException { + @SuppressWarnings("deprecation") + public static Object instantiate(ClassLoader cls, String beanName, + BeanContext beanContext) + throws IOException, ClassNotFoundException { return Beans.instantiate(cls, beanName, beanContext, null); } @@ -153,10 +155,18 @@ public class Beans { * object could not be found. * @exception IOException if an I/O error occurs. * @since 1.2 + * + * @deprecated It is recommended to use + * {@link #instantiate(ClassLoader, String, BeanContext)}, + * because the Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ - @SuppressWarnings("deprecation") - public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer) - throws IOException, ClassNotFoundException { + @Deprecated(since = "9") + public static Object instantiate(ClassLoader cls, String beanName, + BeanContext beanContext, + AppletInitializer initializer) + throws IOException, ClassNotFoundException { InputStream ins; ObjectInputStream oins = null; @@ -501,7 +511,7 @@ class ObjectInputStreamWithLoader extends ObjectInputStream * Package private support class. This provides a default AppletContext * for beans which are applets. */ -@SuppressWarnings("deprecation") +@Deprecated(since = "9") class BeansAppletContext implements AppletContext { Applet target; Hashtable imageCache = new Hashtable<>(); @@ -586,7 +596,7 @@ class BeansAppletContext implements AppletContext { * Package private support class. This provides an AppletStub * for beans which are applets. */ -@SuppressWarnings("deprecation") +@Deprecated(since = "9") class BeansAppletStub implements AppletStub { transient boolean active; transient Applet target; diff --git a/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java b/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java index d45390709cc..4343ae15984 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/PopupFactory.java @@ -260,6 +260,7 @@ public class PopupFactory { * Obtains the appropriate Popup based on * popupType. */ + @SuppressWarnings("deprecation") private Popup getPopup(Component owner, Component contents, int ownerX, int ownerY, int popupType) { if (GraphicsEnvironment.isHeadless()) { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java b/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java index 8737b6bb760..93bae569daa 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java @@ -525,8 +525,12 @@ public class RepaintManager * @param h Height of the region to repaint * @see JApplet#repaint * @since 1.6 + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ - @SuppressWarnings("deprecation") + @Deprecated(since = "9") public void addDirtyRegion(Applet applet, int x, int y, int w, int h) { addDirtyRegion0(applet, x, y, w, h); } diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletEvent.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletEvent.java index 9b7e9c25526..6a1a5880fc8 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletEvent.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletEvent.java @@ -32,8 +32,13 @@ import java.util.EventObject; * AppletEvent class. * * @author Sunita Mani + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ @SuppressWarnings("serial") // JDK-implementation class +@Deprecated(since = "9") public class AppletEvent extends EventObject { private Object arg; diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletEventMulticaster.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletEventMulticaster.java index 6889240a1c4..31542d0665b 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletEventMulticaster.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletEventMulticaster.java @@ -36,7 +36,12 @@ import java.io.IOException; * responsible for dispatching events to them. * * @author Sunita Mani + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ +@Deprecated(since = "9") public class AppletEventMulticaster implements AppletListener { private final AppletListener a, b; diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletIOException.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletIOException.java index de435906e17..e8bd4e0bf75 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletIOException.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletIOException.java @@ -31,10 +31,14 @@ import java.io.IOException; * An applet IO exception. * * @author Koji Uno + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ @SuppressWarnings("serial") // JDK implementation class -public -class AppletIOException extends IOException { +@Deprecated(since = "9") +public class AppletIOException extends IOException { private String key = null; private Object msgobj = null; diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletIllegalArgumentException.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletIllegalArgumentException.java index 292bd957053..750d09d3113 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletIllegalArgumentException.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletIllegalArgumentException.java @@ -29,10 +29,14 @@ package sun.applet; * An applet security exception. * * @author Arthur van Hoff + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ @SuppressWarnings("serial") // JDK implementation class -public -class AppletIllegalArgumentException extends IllegalArgumentException { +@Deprecated(since = "9") +public class AppletIllegalArgumentException extends IllegalArgumentException { private String key = null; public AppletIllegalArgumentException(String key) { diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletImageRef.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletImageRef.java index e3eb5a26fb1..bdda032a8ff 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletImageRef.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletImageRef.java @@ -31,6 +31,7 @@ import java.lang.ref.SoftReference; import sun.awt.image.URLImageSource; import java.net.URL; +@Deprecated(since = "9") class AppletImageRef { private SoftReference soft = null; diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletListener.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletListener.java index 00664938251..728060326ad 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletListener.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletListener.java @@ -32,8 +32,12 @@ import java.util.EventListener; * by objects interested in AppletEvents. * * @author Sunita Mani + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ - +@Deprecated(since = "9") public interface AppletListener extends EventListener { public void appletStateChanged(AppletEvent e); } diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletObjectInputStream.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletObjectInputStream.java index 0906136bfec..689529b77e0 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletObjectInputStream.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletObjectInputStream.java @@ -34,8 +34,12 @@ import java.lang.reflect.Array; /** * This subclass of ObjectInputStream delegates loading of classes to * an existing ClassLoader. + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ - +@Deprecated(since = "9") class AppletObjectInputStream extends ObjectInputStream { private AppletClassLoader loader; 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 fc8eaac0845..221314ad04d 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java @@ -52,9 +52,14 @@ import sun.security.util.SecurityConstants; * thread group to call the applet's init(), start(), stop(), and * destroy() methods. * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. + * * @author Arthur van Hoff */ -@SuppressWarnings({"serial", "deprecation"}) // JDK implementation class +@SuppressWarnings({"serial"}) // JDK implementation class +@Deprecated(since = "9") public abstract class AppletPanel extends Panel implements AppletStub, Runnable { diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java index f78e4160209..bb30abe9897 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java @@ -36,6 +36,7 @@ import java.security.PrivilegedActionException; import sun.security.action.*; @SuppressWarnings("serial") // JDK implementation class +@Deprecated(since = "9") class AppletProps extends Frame { TextField proxyHost; @@ -197,6 +198,7 @@ class AppletProps extends Frame { /* 4066432 */ /* Dialog class to display property-related errors to user */ @SuppressWarnings("serial") // JDK implementation class +@Deprecated(since = "9") class AppletPropsErrorDialog extends Dialog { @SuppressWarnings("deprecation") public AppletPropsErrorDialog(Frame parent, String title, String message, diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java index f11804dddab..c64971b4fb0 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java @@ -43,6 +43,7 @@ import sun.awt.AppContext; * A frame to show the applet tag in. */ @SuppressWarnings("serial") // JDK-implementation class +@Deprecated(since = "9") final class TextFrame extends Frame { /** @@ -91,6 +92,7 @@ final class TextFrame extends Frame { /** * Lets us construct one using unix-style one shot behaviors. */ +@Deprecated(since = "9") final class StdAppletViewerFactory implements AppletViewerFactory { @Override @@ -116,8 +118,13 @@ final class StdAppletViewerFactory implements AppletViewerFactory { * AppletViewer Tags. * (The document named appletviewertags.html in the JDK's docs/tooldocs directory, * once the JDK docs have been installed.) + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ -@SuppressWarnings({"serial", "deprecation"}) // JDK-implementation class +@SuppressWarnings({"serial"}) // JDK-implementation class +@Deprecated(since = "9") public class AppletViewer extends Frame implements AppletContext, Printable { /** @@ -146,7 +153,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable { */ AppletViewerFactory factory; - + @Deprecated(since = "9") private final class UserActionListener implements ActionListener { @Override public void actionPerformed(ActionEvent evt) { @@ -219,6 +226,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable { } }; + @Deprecated(since = "9") class AppletEventListener implements AppletListener { final Frame frame; diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerFactory.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerFactory.java index 16b6db4679d..7cf319f6941 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerFactory.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerFactory.java @@ -33,8 +33,8 @@ import java.util.Hashtable; import java.net.URL; import java.awt.MenuBar; -public -interface AppletViewerFactory { +@Deprecated(since = "9") +public interface AppletViewerFactory { public AppletViewer createAppletViewer(int x, int y, URL doc, Hashtable atts); public MenuBar getBaseMenuBar(); diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java index c0aaf07ad03..86ef3671df0 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewerPanel.java @@ -40,7 +40,12 @@ import java.applet.*; * destroy() methods. * * @author Arthur van Hoff + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ +@Deprecated(since = "9") class AppletViewerPanel extends AppletPanel { /* Are we debugging? */ diff --git a/jdk/src/java.desktop/share/classes/sun/applet/Main.java b/jdk/src/java.desktop/share/classes/sun/applet/Main.java index 6c28c8f9d11..6f5d0c178d7 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/Main.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/Main.java @@ -39,7 +39,12 @@ import sun.net.www.ParseUtil; /** * The main entry point into AppletViewer. + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ +@Deprecated(since = "9") public class Main { /** * The file which contains all of the AppletViewer specific properties. diff --git a/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java b/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java index 38060aa55a6..704a8619591 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java @@ -496,10 +496,14 @@ public abstract class EmbeddedFrame extends Frame * Checks if the component is in an EmbeddedFrame. If so, * returns the applet found in the hierarchy or null if * not found. - * @return the parent applet or {@ null} + * @return the parent applet or {@code null} * @since 1.6 + * + * @deprecated The Applet API is deprecated. See the + * java.applet package + * documentation for further information. */ - @SuppressWarnings("deprecation") + @Deprecated(since = "9") public static Applet getAppletIfAncestorOf(Component comp) { Container parent = comp.getParent(); Applet applet = null; From 63d3e42189a700c27fc1897904f50c1dcae7dc4d Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Wed, 28 Dec 2016 12:43:57 +0300 Subject: [PATCH 030/154] 8167652: Making a frame/dialog resizeble/unresizeble shifts its position on Unity Reviewed-by: azvegint, serb --- .../classes/sun/awt/X11/XDecoratedPeer.java | 524 +++++++++--------- .../unix/classes/sun/awt/X11/XWM.java | 10 +- .../ChangeWindowResizabiltyTest.java | 52 +- 3 files changed, 304 insertions(+), 282 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java index b708fa56753..52e8e33cdcc 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java @@ -51,9 +51,9 @@ abstract class XDecoratedPeer extends XWindowPeer { boolean insets_corrected; XIconWindow iconWindow; - WindowDimensions dimensions; + volatile WindowDimensions dimensions; XContentWindow content; - Insets currentInsets; + volatile Insets currentInsets; XFocusProxyWindow focusProxy; static final Map,Insets> lastKnownInsets = Collections.synchronizedMap(new HashMap<>()); @@ -106,7 +106,7 @@ abstract class XDecoratedPeer extends XWindowPeer { // The lines that follow need to be in a postInit, so they // happen after the X window is created. - initResizability(); + setResizable(winAttr.initialResizability); XWM.requestWMExtents(getWindow()); content = XContentWindow.createContent(this); @@ -130,7 +130,12 @@ abstract class XDecoratedPeer extends XWindowPeer { public void updateMinimumSize() { super.updateMinimumSize(); - updateMinSizeHints(); + XToolkit.awtLock(); + try { + updateMinSizeHints(); + } finally { + XToolkit.awtUnlock(); + } } private void updateMinSizeHints() { @@ -193,8 +198,13 @@ abstract class XDecoratedPeer extends XWindowPeer { if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Title is " + title); } - winAttr.title = title; - updateWMName(); + XToolkit.awtLock(); + try { + winAttr.title = title; + updateWMName(); + } finally { + XToolkit.awtUnlock(); + } } protected String getWMName() { @@ -206,10 +216,10 @@ abstract class XDecoratedPeer extends XWindowPeer { } void updateWMName() { - super.updateWMName(); - String name = getWMName(); XToolkit.awtLock(); try { + super.updateWMName(); + String name = getWMName(); if (name == null || name.trim().equals("")) { name = "Java"; } @@ -304,6 +314,8 @@ abstract class XDecoratedPeer extends XWindowPeer { if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { currentInsets = new Insets(0, 0, 0, 0); wm_set_insets = null; + } else { + insets_corrected = false; } } @@ -330,7 +342,7 @@ abstract class XDecoratedPeer extends XWindowPeer { if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) { getWMSetInsets(XAtom.get(ev.get_atom())); } else { - if(!isReparented()) { + if (!isReparented()) { return; } wm_set_insets = null; @@ -377,137 +389,127 @@ abstract class XDecoratedPeer extends XWindowPeer { insLog.fine(xe.toString()); } reparent_serial = xe.get_serial(); - XToolkit.awtLock(); - try { - long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); + long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); - if (isEmbedded()) { - setReparented(true); - insets_corrected = true; + if (isEmbedded()) { + setReparented(true); + insets_corrected = true; + return; + } + if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) { + setReparented(true); + insets_corrected = true; + reshape(dimensions, SET_SIZE, false); + } else if (xe.get_parent() == root) { + configure_seen = false; + insets_corrected = false; + + /* + * We can be repareted to root for two reasons: + * . setVisible(false) + * . WM exited + */ + if (isVisible()) { /* WM exited */ + /* Work around 4775545 */ + XWM.getWM().unshadeKludge(this); + insLog.fine("- WM exited"); + } else { + insLog.fine(" - reparent due to hide"); + } + } else { /* reparented to WM frame, figure out our insets */ + setReparented(true); + insets_corrected = false; + if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { return; } - Component t = target; - if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) { - setReparented(true); - insets_corrected = true; - reshape(dimensions, SET_SIZE, false); - } else if (xe.get_parent() == root) { - configure_seen = false; - insets_corrected = false; - /* - * We can be repareted to root for two reasons: - * . setVisible(false) - * . WM exited - */ - if (isVisible()) { /* WM exited */ - /* Work around 4775545 */ - XWM.getWM().unshadeKludge(this); - insLog.fine("- WM exited"); - } else { - insLog.fine(" - reparent due to hide"); + // Check if we have insets provided by the WM + Insets correctWM = getWMSetInsets(null); + if (correctWM != null) { + if (insLog.isLoggable(PlatformLogger.Level.FINER)) { + insLog.finer("wm-provided insets {0}", correctWM); } - } else { /* reparented to WM frame, figure out our insets */ - setReparented(true); - insets_corrected = false; - if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { + // If these insets are equal to our current insets - no actions are necessary + Insets dimInsets = dimensions.getInsets(); + if (correctWM.equals(dimInsets)) { + insLog.finer("Insets are the same as estimated - no additional reshapes necessary"); + no_reparent_artifacts = true; + insets_corrected = true; + applyGuessedInsets(); return; } - - // Check if we have insets provided by the WM - Insets correctWM = getWMSetInsets(null); - if (correctWM != null) { - if (insLog.isLoggable(PlatformLogger.Level.FINER)) { - insLog.finer("wm-provided insets {0}", correctWM); - } - // If these insets are equal to our current insets - no actions are necessary - Insets dimInsets = dimensions.getInsets(); - if (correctWM.equals(dimInsets)) { - insLog.finer("Insets are the same as estimated - no additional reshapes necessary"); - no_reparent_artifacts = true; - insets_corrected = true; - applyGuessedInsets(); - return; - } - } else { - correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent()); - if (correctWM != null) { - correctWM = copyAndScaleDown(correctWM); - } - - if (insLog.isLoggable(PlatformLogger.Level.FINER)) { - if (correctWM != null) { - insLog.finer("correctWM {0}", correctWM); - } else { - insLog.finer("correctWM insets are not available, waiting for configureNotify"); - } - } - } - - if (correctWM != null) { - handleCorrectInsets(correctWM); - } - } - } finally { - XToolkit.awtUnlock(); - } - } - - protected void handleCorrectInsets(Insets correctWM) { - XToolkit.awtLock(); - try { - /* - * Ok, now see if we need adjust window size because - * initial insets were wrong (most likely they were). - */ - Insets correction = difference(correctWM, currentInsets); - if (insLog.isLoggable(PlatformLogger.Level.FINEST)) { - insLog.finest("Corrention {0}", correction); - } - if (!isNull(correction)) { - currentInsets = copy(correctWM); - applyGuessedInsets(); - - //Fix for 6318109: PIT: Min Size is not honored properly when a - //smaller size is specified in setSize(), XToolkit - //update minimum size hints - updateMinSizeHints(); - } - if (insLog.isLoggable(PlatformLogger.Level.FINER)) { - insLog.finer("Dimensions before reparent: " + dimensions); - } - - dimensions.setInsets(getRealInsets()); - insets_corrected = true; - - if (isMaximized()) { - return; - } - - /* - * If this window has been sized by a pack() we need - * to keep the interior geometry intact. Since pack() - * computed width and height with wrong insets, we - * must adjust the target dimensions appropriately. - */ - if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) { - reshape(dimensions, SET_BOUNDS, false); } else { - reshape(dimensions, SET_SIZE, false); + correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent()); + if (correctWM != null) { + correctWM = copyAndScaleDown(correctWM); + } + + if (insLog.isLoggable(PlatformLogger.Level.FINER)) { + if (correctWM != null) { + insLog.finer("correctWM {0}", correctWM); + } else { + insLog.finer("correctWM insets are not available, waiting for configureNotify"); + } + } + } + + if (correctWM != null) { + handleCorrectInsets(correctWM); } - } finally { - XToolkit.awtUnlock(); } } - public void handleMoved(WindowDimensions dims) { + private void handleCorrectInsets(Insets correctWM) { + /* + * Ok, now see if we need adjust window size because + * initial insets were wrong (most likely they were). + */ + Insets correction = difference(correctWM, currentInsets); + if (insLog.isLoggable(PlatformLogger.Level.FINEST)) { + insLog.finest("Corrention {0}", correction); + } + if (!isNull(correction)) { + currentInsets = copy(correctWM); + applyGuessedInsets(); + + //Fix for 6318109: PIT: Min Size is not honored properly when a + //smaller size is specified in setSize(), XToolkit + //update minimum size hints + updateMinSizeHints(); + } + if (insLog.isLoggable(PlatformLogger.Level.FINER)) { + insLog.finer("Dimensions before reparent: " + dimensions); + } + WindowDimensions newDimensions = new WindowDimensions(dimensions); + newDimensions.setInsets(getRealInsets()); + dimensions = newDimensions; + insets_corrected = true; + + if (isMaximized()) { + return; + } + + /* + * If this window has been sized by a pack() we need + * to keep the interior geometry intact. Since pack() + * computed width and height with wrong insets, we + * must adjust the target dimensions appropriately. + */ + if ((getHints().get_flags() & (XUtilConstants.USPosition | XUtilConstants.PPosition)) != 0) { + reshape(dimensions, SET_BOUNDS, false); + } else { + reshape(dimensions, SET_SIZE, false); + } + } + + void handleMoved(WindowDimensions dims) { Point loc = dims.getLocation(); AWTAccessor.getComponentAccessor().setLocation(target, loc.x, loc.y); postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED)); } - protected Insets guessInsets() { + private Insets guessInsets() { if (isEmbedded() || isTargetUndecorated()) { return new Insets(0, 0, 0, 0); } else { @@ -532,16 +534,7 @@ abstract class XDecoratedPeer extends XWindowPeer { currentInsets = copy(guessed); } - public void revalidate() { - XToolkit.executeOnEventHandlerThread(target, new Runnable() { - public void run() { - target.invalidate(); - target.validate(); - } - }); - } - - Insets getRealInsets() { + private Insets getRealInsets() { if (isNull(currentInsets)) { applyGuessedInsets(); } @@ -578,7 +571,7 @@ abstract class XDecoratedPeer extends XWindowPeer { // Coordinates are that of the target // Called only on Toolkit thread - public void reshape(WindowDimensions newDimensions, int op, + private void reshape(WindowDimensions newDimensions, int op, boolean userReshape) { if (insLog.isLoggable(PlatformLogger.Level.FINE)) { @@ -599,81 +592,75 @@ abstract class XDecoratedPeer extends XWindowPeer { } newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet()); } - XToolkit.awtLock(); - try { - if (!isReparented() || !isVisible()) { - if (insLog.isLoggable(PlatformLogger.Level.FINE)) { - insLog.fine("- not reparented({0}) or not visible({1}), default reshape", - Boolean.valueOf(isReparented()), Boolean.valueOf(visible)); - } - - // Fix for 6323293. - // This actually is needed to preserve compatibility with previous releases - - // some of licensees are expecting componentMoved event on invisible one while - // its location changes. - Point oldLocation = getLocation(); - - Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target), - AWTAccessor.getComponentAccessor().getY(target)); - - if (!newLocation.equals(oldLocation)) { - handleMoved(newDimensions); - } - - dimensions = new WindowDimensions(newDimensions); - updateSizeHints(dimensions); - Rectangle client = dimensions.getClientRect(); - checkShellRect(client); - setShellBounds(client); - if (content != null && - !content.getSize().equals(newDimensions.getSize())) - { - reconfigureContentWindow(newDimensions); - } - return; + if (!isReparented() || !isVisible()) { + if (insLog.isLoggable(PlatformLogger.Level.FINE)) { + insLog.fine("- not reparented({0}) or not visible({1}), default reshape", + Boolean.valueOf(isReparented()), Boolean.valueOf(visible)); } - int wm = XWM.getWMID(); - updateChildrenSizes(); - applyGuessedInsets(); + // Fix for 6323293. + // This actually is needed to preserve compatibility with previous releases - + // some of licensees are expecting componentMoved event on invisible one while + // its location changes. + Point oldLocation = getLocation(); - Rectangle shellRect = newDimensions.getClientRect(); + Point newLocation = new Point(AWTAccessor.getComponentAccessor().getX(target), + AWTAccessor.getComponentAccessor().getY(target)); - if (gravityBug()) { - Insets in = newDimensions.getInsets(); - shellRect.translate(in.left, in.top); + if (!newLocation.equals(oldLocation)) { + handleMoved(newDimensions); } - if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) { - shellRect.setLocation(0, 0); + dimensions = new WindowDimensions(newDimensions); + updateSizeHints(dimensions); + Rectangle client = dimensions.getClientRect(); + checkShellRect(client); + setShellBounds(client); + if (content != null && + !content.getSize().equals(newDimensions.getSize())) + { + reconfigureContentWindow(newDimensions); } - - checkShellRectSize(shellRect); - if (!isEmbedded()) { - checkShellRectPos(shellRect); - } - - op = op & ~NO_EMBEDDED_CHECK; - - if (op == SET_LOCATION) { - setShellPosition(shellRect); - } else if (isResizable()) { - if (op == SET_BOUNDS) { - setShellBounds(shellRect); - } else { - setShellSize(shellRect); - } - } else { - XWM.setShellNotResizable(this, newDimensions, shellRect, true); - if (op == SET_BOUNDS) { - setShellPosition(shellRect); - } - } - - reconfigureContentWindow(newDimensions); - } finally { - XToolkit.awtUnlock(); + return; } + + updateChildrenSizes(); + applyGuessedInsets(); + + Rectangle shellRect = newDimensions.getClientRect(); + + if (gravityBug()) { + Insets in = newDimensions.getInsets(); + shellRect.translate(in.left, in.top); + } + + if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) { + shellRect.setLocation(0, 0); + } + + checkShellRectSize(shellRect); + if (!isEmbedded()) { + checkShellRectPos(shellRect); + } + + op = op & ~NO_EMBEDDED_CHECK; + + if (op == SET_LOCATION) { + setShellPosition(shellRect); + } else if (isResizable()) { + if (op == SET_BOUNDS) { + setShellBounds(shellRect); + } else { + setShellSize(shellRect); + } + } else { + XWM.setShellNotResizable(this, newDimensions, shellRect, true); + if (op == SET_BOUNDS) { + setShellPosition(shellRect); + } + } + + reconfigureContentWindow(newDimensions); } /** @@ -682,8 +669,6 @@ abstract class XDecoratedPeer extends XWindowPeer { private void reshape(int x, int y, int width, int height, int operation, boolean userReshape) { - Rectangle newRec; - boolean setClient = false; WindowDimensions dims = new WindowDimensions(dimensions); switch (operation & (~NO_EMBEDDED_CHECK)) { case SET_LOCATION: @@ -726,7 +711,12 @@ abstract class XDecoratedPeer extends XWindowPeer { */ public void setBounds(int x, int y, int width, int height, int op) { // TODO: Rewrite with WindowDimensions - reshape(x, y, width, height, op, true); + XToolkit.awtLock(); + try { + reshape(x, y, width, height, op, true); + } finally { + XToolkit.awtUnlock(); + } validateSurface(); } @@ -861,81 +851,74 @@ abstract class XDecoratedPeer extends XWindowPeer { checkShellRectPos(shellRect); } - public void setShellBounds(Rectangle rec) { + private void setShellBounds(Rectangle rec) { if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine("Setting shell bounds on " + this + " to " + rec); } - XToolkit.awtLock(); - try { - updateSizeHints(rec.x, rec.y, rec.width, rec.height); - XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getShell(), - scaleUp(rec.x), scaleUp(rec.y), - scaleUp(rec.width), scaleUp(rec.height)); - } - finally { - XToolkit.awtUnlock(); - } + updateSizeHints(rec.x, rec.y, rec.width, rec.height); + XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getShell(), + scaleUp(rec.x), scaleUp(rec.y), + scaleUp(rec.width), scaleUp(rec.height)); } - public void setShellSize(Rectangle rec) { + + private void setShellSize(Rectangle rec) { if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine("Setting shell size on " + this + " to " + rec); } - XToolkit.awtLock(); - try { - updateSizeHints(rec.x, rec.y, rec.width, rec.height); - XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), - scaleUp(rec.width), scaleUp(rec.height)); - } - finally { - XToolkit.awtUnlock(); - } + updateSizeHints(rec.x, rec.y, rec.width, rec.height); + XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), + scaleUp(rec.width), scaleUp(rec.height)); } - public void setShellPosition(Rectangle rec) { + + private void setShellPosition(Rectangle rec) { if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine("Setting shell position on " + this + " to " + rec); } - XToolkit.awtLock(); - try { - updateSizeHints(rec.x, rec.y, rec.width, rec.height); - XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), - scaleUp(rec.x), scaleUp(rec.y)); - } - finally { - XToolkit.awtUnlock(); - } + updateSizeHints(rec.x, rec.y, rec.width, rec.height); + XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), + scaleUp(rec.x), scaleUp(rec.y)); } - void initResizability() { - setResizable(winAttr.initialResizability); - } public void setResizable(boolean resizable) { - int fs = winAttr.functions; - if (!isResizable() && resizable) { - resetWMSetInsets(); - if (!isEmbedded()) { - setReparented(false); + XToolkit.awtLock(); + try { + int fs = winAttr.functions; + if (!isResizable() && resizable) { + resetWMSetInsets(); + if (!isEmbedded()) { + setReparented(false); + } + winAttr.isResizable = resizable; + if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { + fs &= ~(MWMConstants.MWM_FUNC_RESIZE + | MWMConstants.MWM_FUNC_MAXIMIZE); + } else { + fs |= (MWMConstants.MWM_FUNC_RESIZE + | MWMConstants.MWM_FUNC_MAXIMIZE); + } + winAttr.functions = fs; + XWM.setShellResizable(this); + } else if (isResizable() && !resizable) { + resetWMSetInsets(); + if (!isEmbedded()) { + setReparented(false); + } + winAttr.isResizable = resizable; + if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { + fs |= (MWMConstants.MWM_FUNC_RESIZE + | MWMConstants.MWM_FUNC_MAXIMIZE); + } else { + fs &= ~(MWMConstants.MWM_FUNC_RESIZE + | MWMConstants.MWM_FUNC_MAXIMIZE); + } + winAttr.functions = fs; + XWM.setShellNotResizable(this, dimensions, + XWM.getWMID() == XWM.UNITY_COMPIZ_WM && configure_seen ? + dimensions.getScreenBounds() : + dimensions.getBounds(), false); } - winAttr.isResizable = resizable; - if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { - fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); - } else { - fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); - } - winAttr.functions = fs; - XWM.setShellResizable(this); - } else if (isResizable() && !resizable) { - resetWMSetInsets(); - if (!isEmbedded()) { - setReparented(false); - } - winAttr.isResizable = resizable; - if ((fs & MWMConstants.MWM_FUNC_ALL) != 0) { - fs |= (MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); - } else { - fs &= ~(MWMConstants.MWM_FUNC_RESIZE | MWMConstants.MWM_FUNC_MAXIMIZE); - } - winAttr.functions = fs; - XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false); + } finally { + XToolkit.awtUnlock(); } } @@ -990,17 +973,16 @@ abstract class XDecoratedPeer extends XWindowPeer { try { if (configure_seen) { return toGlobal(0,0); - } else { - Point location = target.getLocation(); - if (insLog.isLoggable(PlatformLogger.Level.FINE)) { - insLog.fine("getLocationOnScreen {0} not reparented: {1} ", - this, location); - } - return location; } } finally { XToolkit.awtUnlock(); } + Point location = target.getLocation(); + if (insLog.isLoggable(PlatformLogger.Level.FINE)) { + insLog.fine("getLocationOnScreen {0} not reparented: {1} ", + this, location); + } + return location; } @@ -1134,7 +1116,7 @@ abstract class XDecoratedPeer extends XWindowPeer { return focusProxy; } - public void handleQuit() { + private void handleQuit() { postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING)); } diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java index 52771620736..974888986ef 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java @@ -1029,8 +1029,14 @@ final class XWM } XToolkit.awtLock(); try { - Rectangle shellBounds = window.getShellBounds(); - shellBounds.translate(-window.currentInsets.left, -window.currentInsets.top); + Rectangle shellBounds; + if (getWMID() != UNITY_COMPIZ_WM) { + shellBounds = window.getShellBounds(); + shellBounds.translate(-window.currentInsets.left, + -window.currentInsets.top); + } else { + shellBounds = window.getDimensions().getScreenBounds(); + } window.updateSizeHints(window.getDimensions()); requestWMExtents(window.getWindow()); XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), diff --git a/jdk/test/java/awt/Window/ChangeWindowResizabilty/ChangeWindowResizabiltyTest.java b/jdk/test/java/awt/Window/ChangeWindowResizabilty/ChangeWindowResizabiltyTest.java index f2e0e95273e..d7ef91778b0 100644 --- a/jdk/test/java/awt/Window/ChangeWindowResizabilty/ChangeWindowResizabiltyTest.java +++ b/jdk/test/java/awt/Window/ChangeWindowResizabilty/ChangeWindowResizabiltyTest.java @@ -23,7 +23,7 @@ /* @test @key headful - @bug 8166897 + @bug 8166897 8167652 @summary Some font overlap in the Optionpane dialog. @run main ChangeWindowResizabiltyTest */ @@ -34,41 +34,75 @@ import java.awt.Dimension; import java.awt.Frame; import java.awt.Panel; import java.awt.Robot; +import java.awt.Point; public class ChangeWindowResizabiltyTest { public static void main(String[] args) throws Exception { Robot robot = new Robot(); for(int i = 0; i < 10; i++) { Dialog dialog = new Dialog((Frame) null); + dialog.setLocation(100, 100); Component panel = new Panel(); panel.setPreferredSize(new Dimension(200, 100)); dialog.add(panel); dialog.pack(); dialog.setVisible(true); + robot.waitForIdle(); + robot.delay(200); + + Point frameLoc = dialog.getLocationOnScreen(); + Point contentLoc = panel.getLocationOnScreen(); + + System.out.println("Decor location " + frameLoc); + System.out.println("Content location " + contentLoc); dialog.setResizable(false); robot.waitForIdle(); robot.delay(200); - System.out.println(panel.getLocationOnScreen()); - System.out.println(dialog.getLocationOnScreen()); + Point l = dialog.getLocationOnScreen(); + if (!l.equals(frameLoc)) { + dialog.dispose(); + throw new RuntimeException("Decorated frame location moved " + + "after setResizable(false)" + l); + } + + l = panel.getLocationOnScreen(); + if (!l.equals(contentLoc)) { + dialog.dispose(); + throw new RuntimeException("Content location moved after " + + "setResizable(false)" + l); + } + if (panel.getLocationOnScreen().y < - dialog.getLocationOnScreen().y + dialog.getInsets().top) { + dialog.getLocationOnScreen().y + dialog.getInsets().top) { dialog.dispose(); throw new RuntimeException( - "Wrong content position after setResizable(false)"); + "Wrong content position after setResizable(false)"); } dialog.setResizable(true); robot.waitForIdle(); robot.delay(200); - System.out.println(panel.getLocationOnScreen()); - System.out.println(dialog.getLocationOnScreen()); + + l = dialog.getLocationOnScreen(); + if (!l.equals(frameLoc)) { + dialog.dispose(); + throw new RuntimeException("Decorated frame location moved " + + "after setResizable(true)" + l); + } + + l = panel.getLocationOnScreen(); + if (!l.equals(contentLoc)) { + dialog.dispose(); + throw new RuntimeException("Content location moved after " + + "setResizable(true)" + l); + } if (panel.getLocationOnScreen().y < - dialog.getLocationOnScreen().y + dialog.getInsets().top) { + dialog.getLocationOnScreen().y + dialog.getInsets().top) { dialog.dispose(); throw new RuntimeException( - "Wrong content position after setResizable(true)"); + "Wrong content position after setResizable(true)"); } dialog.dispose(); From c828c703a9666f7b29805c39f119bda61e037693 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 28 Dec 2016 17:11:32 +0300 Subject: [PATCH 031/154] 8140266: Performance loss between jdk8 and jdk9 on Maskfill Reviewed-by: prr, erikj, lbourges --- jdk/make/lib/Awt2dLibraries.gmk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 670434669af..cf5ad157129 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -222,6 +222,8 @@ endif # applies to debug builds. ifeq ($(TOOLCHAIN_TYPE), gcc) BUILD_LIBAWT_debug_mem.c_CFLAGS := -w + # This option improves performance of MaskFill in Java2D by 20% for some gcc + LIBAWT_CFLAGS += -fgcse-after-reload endif $(eval $(call SetupNativeCompilation,BUILD_LIBAWT, \ From 0a07e55fa4188bcfe7fc578525cc7fa1f3cdd835 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Wed, 28 Dec 2016 21:33:15 +0300 Subject: [PATCH 032/154] 8171949: [macosx] AWT_ZoomFrame Automated tests fail with error: The bitwise mask Frame.ICONIFIED is not setwhen the frame is in ICONIFIED state Reviewed-by: ssadetsky, serb --- .../sun/lwawt/macosx/CPlatformWindow.java | 39 ++++++- .../native/libawt_lwawt/awt/AWTWindow.m | 8 ++ .../NormalToIconifiedTest.java | 105 ++++++++++++++++++ 3 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/awt/Frame/NormalToIconified/NormalToIconifiedTest.java diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index d0c8275dc7c..38dd927c70f 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -231,6 +231,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo private boolean isFullScreenAnimationOn; private volatile boolean isInFullScreen; + private volatile boolean isIconifyAnimationActive; private Window target; private LWWindowPeer peer; @@ -997,6 +998,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo if (peer != null) { peer.notifyIconify(iconify); } + if (iconify) { + isIconifyAnimationActive = false; + } } private void deliverZoom(final boolean isZoomed) { @@ -1071,6 +1075,17 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo return true; } + private boolean isIconified() { + boolean isIconified = false; + if (target instanceof Frame) { + int state = ((Frame)target).getExtendedState(); + if ((state & Frame.ICONIFIED) != 0) { + isIconified = true; + } + } + return isIconifyAnimationActive || isIconified; + } + private boolean isOneOfOwnersOrSelf(CPlatformWindow window) { while (window != null) { if (this == window) { @@ -1094,11 +1109,14 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // the windows are ordered above their nearest owner; ancestors of the window, // which is going to become 'main window', are placed above their siblings. CPlatformWindow rootOwner = getRootOwner(); - if (rootOwner.isVisible()) { + if (rootOwner.isVisible() && !rootOwner.isIconified()) { CWrapper.NSWindow.orderFront(rootOwner.getNSWindowPtr()); } - final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor(); - orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target)); + // Do not order child windows of iconified owner. + if (!rootOwner.isIconified()) { + final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor(); + orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target)); + } } private void orderAboveSiblingsImpl(Window[] windows) { @@ -1109,10 +1127,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // Go through the list of windows and perform ordering. for (Window w : windows) { + boolean iconified = false; final Object p = componentAccessor.getPeer(w); if (p instanceof LWWindowPeer) { CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow(); - if (pw != null && pw.isVisible()) { + iconified = isIconified(); + if (pw != null && pw.isVisible() && !iconified) { // If the window is one of ancestors of 'main window' or is going to become main by itself, // the window should be ordered above its siblings; otherwise the window is just ordered // above its nearest parent. @@ -1125,10 +1145,13 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo pw.applyWindowLevel(w); } } - // Retrieve the child windows for each window from the list and store them for future use. + // Retrieve the child windows for each window from the list except iconified ones + // and store them for future use. // Note: we collect data about child windows even for invisible owners, since they may have // visible children. - childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w))); + if (!iconified) { + childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w))); + } } // If some windows, which have just been ordered, have any child windows, let's start new iteration // and order these child windows. @@ -1149,6 +1172,10 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // NATIVE CALLBACKS // ---------------------------------------------------------------------- + private void windowWillMiniaturize() { + isIconifyAnimationActive = true; + } + private void windowDidBecomeMain() { if (checkBlockingAndOrder()) return; // If it's not blocked, make sure it's above its siblings diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index ca983d031c1..4927949e18d 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -639,6 +639,14 @@ AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD; self.isMinimizing = YES; + + JNIEnv *env = [ThreadUtilities getJNIEnv]; + jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; + if (platformWindow != NULL) { + static JNF_MEMBER_CACHE(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V"); + JNFCallVoidMethod(env, platformWindow, jm_windowWillMiniaturize); + (*env)->DeleteLocalRef(env, platformWindow); + } // Excplicitly make myself a key window to avoid possible // negative visual effects during iconify operation [self.nsWindow makeKeyAndOrderFront:self.nsWindow]; diff --git a/jdk/test/java/awt/Frame/NormalToIconified/NormalToIconifiedTest.java b/jdk/test/java/awt/Frame/NormalToIconified/NormalToIconifiedTest.java new file mode 100644 index 00000000000..ca4c592ed1d --- /dev/null +++ b/jdk/test/java/awt/Frame/NormalToIconified/NormalToIconifiedTest.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. + * + * 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 8171949 + * @summary Tests that bitwise mask is set and state listener is notified during state transition. + * @author Dmitry Markov + * @library ../../regtesthelpers + * @build Util + * @run main NormalToIconifiedTest + */ + +import java.awt.Frame; +import java.awt.Robot; +import java.awt.event.WindowEvent; +import java.awt.event.WindowStateListener; +import java.util.concurrent.atomic.AtomicBoolean; + +import test.java.awt.regtesthelpers.Util; + +public class NormalToIconifiedTest { + private static final AtomicBoolean listenerNotified = new AtomicBoolean(false); + + public static void main(String[] args) { + Robot robot = Util.createRobot(); + + Frame testFrame = new Frame("Test Frame"); + testFrame.setSize(200, 200); + testFrame.addWindowStateListener(new WindowStateListener() { + @Override + public void windowStateChanged(WindowEvent e) { + listenerNotified.set(true); + synchronized (listenerNotified) { + listenerNotified.notifyAll(); + } + } + }); + testFrame.setVisible(true); + + Frame mainFrame = new Frame("Main Frame"); + mainFrame.setSize(200, 200); + mainFrame.setLocationRelativeTo(null); + mainFrame.setVisible(true); + + Util.waitForIdle(robot); + + try { + Util.clickOnComp(mainFrame, robot); + Util.waitForIdle(robot); + + // NORMAL -> ICONIFIED + listenerNotified.set(false); + testFrame.setExtendedState(Frame.ICONIFIED); + Util.waitForIdle(robot); + + Util.waitForCondition(listenerNotified, 2000); + if (!listenerNotified.get()) { + throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" + + "ICONIFIED transition"); + } + if (testFrame.getExtendedState() != Frame.ICONIFIED) { + throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state"); + } + + // ICONIFIED -> NORMAL + listenerNotified.set(false); + testFrame.setExtendedState(Frame.NORMAL); + Util.waitForIdle(robot); + + Util.waitForCondition(listenerNotified, 2000); + if (!listenerNotified.get()) { + throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" + + "NORMAL transition"); + } + if (testFrame.getExtendedState() != Frame.NORMAL) { + throw new RuntimeException("Test FAILED! Frame is not in NORMAL state"); + } + } finally { + testFrame.dispose(); + mainFrame.dispose(); + } + } +} + From 6d8af8ad7ececf2dcefb4f89c0a4e66c8da746f5 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Thu, 29 Dec 2016 19:47:39 +0300 Subject: [PATCH 033/154] 8171952: [macosx] AWT_Modality/Automated/ModalExclusion/NoExclusion/ModelessDialog test fails as DummyButton on Dialog did not gain focus when clicked Reviewed-by: ssadetsky, serb --- .../native/libawt_lwawt/awt/AWTWindow.m | 35 +++++++++- .../ObscuredFrame/ObscuredFrameTest.java | 70 +++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index 4927949e18d..03829b3dc1a 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -327,10 +327,43 @@ AWT_ASSERT_APPKIT_THREAD; return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]]; } +// Retrieves the list of possible window layers (levels) ++ (NSArray*) getWindowLayers { + static NSArray *windowLayers; + static dispatch_once_t token; + + // Initialize the list of possible window layers + dispatch_once(&token, ^{ + // The layers are ordered from front to back, (i.e. the toppest one is the first) + windowLayers = [NSArray arrayWithObjects: + [NSNumber numberWithInt:CGWindowLevelForKey(kCGPopUpMenuWindowLevelKey)], + [NSNumber numberWithInt:CGWindowLevelForKey(kCGFloatingWindowLevelKey)], + [NSNumber numberWithInt:CGWindowLevelForKey(kCGNormalWindowLevelKey)], + nil + ]; + [windowLayers retain]; + }); + return windowLayers; +} + // returns id for the topmost window under mouse + (NSInteger) getTopmostWindowUnderMouseID { NSInteger result = -1; + NSArray *windowLayers = [AWTWindow getWindowLayers]; + // Looking for the window under mouse starting from the toppest layer + for (NSNumber *layer in windowLayers) { + result = [AWTWindow getTopmostWindowUnderMouseIDImpl:[layer integerValue]]; + if (result != -1) { + break; + } + } + return result; +} + ++ (NSInteger) getTopmostWindowUnderMouseIDImpl:(NSInteger)windowLayer { + NSInteger result = -1; + NSRect screenRect = [[NSScreen mainScreen] frame]; NSPoint nsMouseLocation = [NSEvent mouseLocation]; CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y); @@ -339,7 +372,7 @@ AWT_ASSERT_APPKIT_THREAD; for (NSDictionary *window in windows) { NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue]; - if (layer == 0) { + if (layer == windowLayer) { CGRect rect; CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect); if (CGRectContainsPoint(rect, cgMouseLocation)) { diff --git a/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java b/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java new file mode 100644 index 00000000000..eb20f189a7e --- /dev/null +++ b/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java @@ -0,0 +1,70 @@ +/* + * 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 8171952 + * @summary Tests that getMousePosition() returns null for obscured component. + * @author Dmitry Markov + * @library ../../regtesthelpers + * @build Util + * @run main ObscuredFrameTest + */ + +import java.awt.*; + +import test.java.awt.regtesthelpers.Util; + +public class ObscuredFrameTest { + public static void main(String[] args) { + Robot robot = Util.createRobot(); + + Frame frame = new Frame("Obscured Frame"); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + Button button = new Button("Button"); + frame.add(button); + + Dialog dialog = new Dialog(frame, "Visible Dialog", false); + dialog.setSize(200, 200); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + + frame.setVisible(true); + + Util.waitForIdle(robot); + + Util.pointOnComp(button, robot); + Util.waitForIdle(robot); + + try { + if (button.getMousePosition() != null) { + throw new RuntimeException("Test Failed! Mouse position is not null for obscured component."); + } + } finally { + frame.dispose(); + dialog.dispose(); + } + } +} + From 3f949228a64297a6ef87f9f73488ec22a6eeb9e7 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Mon, 2 Jan 2017 15:09:52 +0530 Subject: [PATCH 034/154] 8170579: The "Banner page" checkbox is disabled Reviewed-by: prr, pnarayanan --- .../java/awt/print/PrinterJob/BannerTest.java | 20 +++++++++++++------ .../TestCheckSystemDefaultBannerOption.java | 10 ++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/awt/print/PrinterJob/BannerTest.java b/jdk/test/java/awt/print/PrinterJob/BannerTest.java index 85f3329a36c..bbc190408c6 100644 --- a/jdk/test/java/awt/print/PrinterJob/BannerTest.java +++ b/jdk/test/java/awt/print/PrinterJob/BannerTest.java @@ -22,7 +22,7 @@ */ /* * @test - * @bug 6575247 + * @bug 6575247 8170579 * @summary Verifies if Banner page is printed * @requires (os.family == "linux" | os.family == "solaris") * @run main/manual BannerTest @@ -39,6 +39,9 @@ import static java.awt.print.Printable.NO_SUCH_PAGE; import static java.awt.print.Printable.PAGE_EXISTS; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; +import javax.print.PrintService; +import javax.print.attribute.standard.JobSheets; +import javax.print.attribute.standard.SheetCollate; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; @@ -50,8 +53,18 @@ public class BannerTest implements Printable { private static Thread mainThread; private static boolean testPassed; private static boolean testGeneratedInterrupt; + private static volatile PrinterJob job; public static void main(String[] args) throws Exception { + job = PrinterJob.getPrinterJob(); + PrintService prtSrv = job.getPrintService(); + if (job.getPrintService() == null) { + System.out.println("No printers. Test cannot continue"); + return; + } + if (!prtSrv.isAttributeCategorySupported(JobSheets.class)) { + return; + } SwingUtilities.invokeAndWait(() -> { doTest(BannerTest::printTest); }); @@ -69,11 +82,6 @@ public class BannerTest implements Printable { } private static void printTest() { - PrinterJob job = PrinterJob.getPrinterJob(); - if (job.getPrintService() == null) { - System.out.println("No printers. Test cannot continue"); - return; - } job.setPrintable(new BannerTest()); if(job.printDialog()) { try { diff --git a/jdk/test/java/awt/print/PrinterJob/TestCheckSystemDefaultBannerOption.java b/jdk/test/java/awt/print/PrinterJob/TestCheckSystemDefaultBannerOption.java index b8e43196c20..f337422112e 100644 --- a/jdk/test/java/awt/print/PrinterJob/TestCheckSystemDefaultBannerOption.java +++ b/jdk/test/java/awt/print/PrinterJob/TestCheckSystemDefaultBannerOption.java @@ -22,7 +22,7 @@ */ /* * @test - * @bug 8165947 + * @bug 8165947 8170579 * @summary Verifies System default banner page option is honoured by jdk * @requires (os.family == "linux" | os.family == "solaris") * @run main/manual TestCheckSystemDefaultBannerOption @@ -38,6 +38,7 @@ import static java.awt.print.Printable.NO_SUCH_PAGE; import static java.awt.print.Printable.PAGE_EXISTS; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; +import javax.print.PrintService; import javax.print.attribute.standard.JobSheets; import javax.swing.JButton; import javax.swing.JDialog; @@ -56,10 +57,15 @@ public class TestCheckSystemDefaultBannerOption implements Printable { public static void main (String[] args) throws Exception { job = PrinterJob.getPrinterJob(); - if (job.getPrintService() == null) { + PrintService prtSrv = job.getPrintService(); + if (prtSrv == null) { System.out.println("No printers. Test cannot continue"); return; } + // do not run the test if JobSheet category is not supported + if (!prtSrv.isAttributeCategorySupported(JobSheets.class)) { + return; + } // check system default banner option and let user know what to expect JobSheets js = (JobSheets)job.getPrintService(). getDefaultAttributeValue(JobSheets.class); From 7c0476db0ad4eb4cbd44dd12707f752a4ae96b79 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 3 Jan 2017 11:43:07 -0800 Subject: [PATCH 035/154] 8171845: The bold font doesn't change when switch "Dialog","Serif" and "Monospaced" Reviewed-by: serb --- jdk/make/data/fontconfig/solaris.fontconfig.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/make/data/fontconfig/solaris.fontconfig.properties b/jdk/make/data/fontconfig/solaris.fontconfig.properties index bbd68b5024d..03f61e7709d 100644 --- a/jdk/make/data/fontconfig/solaris.fontconfig.properties +++ b/jdk/make/data/fontconfig/solaris.fontconfig.properties @@ -436,15 +436,15 @@ sequence.fallback=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin filename.-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arial.ttf filename.-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/ariali.ttf -filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialb.ttf +filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialbd.ttf filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialbi.ttf filename.-monotype-courier_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cour.ttf filename.-monotype-courier_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/couri.ttf -filename.-monotype-courier_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courb.ttf +filename.-monotype-courier_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courbd.ttf filename.-monotype-courier_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courbi.ttf filename.-monotype-times_new_roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/times.ttf filename.-monotype-times_new_roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesi.ttf -filename.-monotype-times_new_roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesb.ttf +filename.-monotype-times_new_roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesbd.ttf filename.-monotype-times_new_roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesbi.ttf filename.-monotype-angsana_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsa.ttf From 95ffeea1a303861464cd9f18698676f5f8d7ce20 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 3 Jan 2017 14:15:15 -0800 Subject: [PATCH 036/154] 8172153: Create workaround for failure to use ICC profile contained in a TIFF field Work around errors due to using an embedded ICC profile from the metadata Reviewed-by: prr --- .../imageio/plugins/tiff/TIFFImageReader.java | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java index 3ccc3cd9233..8f95e5502f6 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -730,18 +730,47 @@ public class TIFFImageReader extends ImageReader { // to use it if the data layout is component type. if (iccProfileField != null && itsRaw.getColorModel() instanceof ComponentColorModel) { - // Create a ColorSpace from the profile. - byte[] iccProfileValue = iccProfileField.getAsBytes(); - ICC_Profile iccProfile - = ICC_Profile.getInstance(iccProfileValue); - ICC_ColorSpace iccColorSpace - = new ICC_ColorSpace(iccProfile); - // Get the raw sample and color information. ColorModel cmRaw = itsRaw.getColorModel(); ColorSpace csRaw = cmRaw.getColorSpace(); SampleModel smRaw = itsRaw.getSampleModel(); + ColorSpace iccColorSpace = null; + try { + // Create a ColorSpace from the profile. + byte[] iccProfileValue = iccProfileField.getAsBytes(); + ICC_Profile iccProfile + = ICC_Profile.getInstance(iccProfileValue); + iccColorSpace = new ICC_ColorSpace(iccProfile); + + // Workaround for JDK-8145241: test a conversion and fall + // back to a standard ColorSpace if it fails. This + // workaround could be removed if JDK-8145241 is fixed. + float[] rgb = + iccColorSpace.toRGB(new float[] {1.0F, 1.0F, 1.0F}); + } catch (Exception iccProfileException) { + processWarningOccurred("Superseding bad ICC profile: " + + iccProfileException.getMessage()); + + if (iccColorSpace != null) { + switch (iccColorSpace.getType()) { + case ColorSpace.TYPE_GRAY: + iccColorSpace = + ColorSpace.getInstance(ColorSpace.CS_GRAY); + break; + case ColorSpace.TYPE_RGB: + iccColorSpace = + ColorSpace.getInstance(ColorSpace.CS_sRGB); + break; + default: + iccColorSpace = csRaw; + break; + } + } else { + iccColorSpace = csRaw; + } + } + // Get the number of samples per pixel and the number // of color components. int numBands = smRaw.getNumBands(); From 1f91d8a2d6fd149b7f912eef593de787187c0116 Mon Sep 17 00:00:00 2001 From: Prem Balakrishnan Date: Fri, 6 Jan 2017 15:31:19 +0530 Subject: [PATCH 037/154] 8172009: [TEST_BUG] increase timeout in java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java Reviewed-by: aghaisas, psadhukhan --- .../PaintSetEnabledDeadlock.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java index 12a290e5dfe..63a382b18cb 100644 --- a/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java +++ b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java @@ -24,16 +24,28 @@ /* * @test * @key headful - * @bug 7108598 + * @bug 7108598 8172009 * @summary Container.paint/KeyboardFocusManager.clearMostRecentFocusOwner methods deadlock * @library ../../regtesthelpers * @author Oleg Pekhovskiy * @build Util - * @run main/timeout=20 PaintSetEnabledDeadlock + * @run main PaintSetEnabledDeadlock */ -import java.awt.*; -import java.awt.event.*; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import test.java.awt.regtesthelpers.Util; public class PaintSetEnabledDeadlock extends Frame { From 98f2f0743f18aa085ba3e1a6f928bf3ea5061546 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 6 Jan 2017 16:50:50 +0530 Subject: [PATCH 038/154] 8170352: The collate option is not checked Reviewed-by: prr, yan --- .../unix/classes/sun/print/IPPPrintService.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java b/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java index 9f351b0ab66..4d1832801c6 100644 --- a/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java +++ b/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java @@ -1053,15 +1053,8 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { // of setting it, it is a safe assumption to just always // include SheetCollate as supported attribute. - /* - In Linux, we use Postscript for rendering but Linux still - has issues in propagating Postscript-embedded setpagedevice - setting like collation. Therefore, we temporarily exclude - Linux. - */ - if (!PrintServiceLookupProvider.isLinux()) { - catList.add(SheetCollate.class); - } + catList.add(SheetCollate.class); + } // With the assumption that Chromaticity is equivalent to From 869f5bbd91235b3fb48deddff3aba8b6f753e9d6 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 9 Jan 2017 16:44:45 +0100 Subject: [PATCH 039/154] 8172411: -XDnoModules must be removed Reviewed-by: jjg --- .../share/classes/com/sun/tools/javac/code/Symtab.java | 5 +---- .../share/classes/com/sun/tools/javac/comp/Resolve.java | 8 +------- .../classes/com/sun/tools/javac/main/JavaCompiler.java | 2 +- .../javac/processing/JavacProcessingEnvironment.java | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index f76205b8c95..f3fdb5d3486 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -61,7 +61,6 @@ import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Names; -import com.sun.tools.javac.util.Options; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.Kind.*; @@ -469,9 +468,7 @@ public class Symtab { scope.enter(errSymbol); Source source = Source.instance(context); - Options options = Options.instance(context); - boolean noModules = options.isSet("noModules"); - if (source.allowModules() && !noModules) { + if (source.allowModules()) { java_base = enterModule(names.java_base); //avoid completing java.base during the Symtab initialization java_base.completer = Completer.NULL_COMPLETER; 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 f68f0fa5986..9d7a59b2476 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 @@ -98,8 +98,6 @@ public class Resolve { private final boolean compactMethodDiags; final EnumSet verboseResolutionMode; - private final boolean checkModuleAccess; - WriteableScope polymorphicSignatureScope; protected Resolve(Context context) { @@ -135,10 +133,6 @@ public class Resolve { inapplicableMethodException = new InapplicableMethodException(diags); allowModules = source.allowModules(); - - // The following is required, for now, to support building - // Swing beaninfo via javadoc. - checkModuleAccess = !options.isSet("noModules"); } /** error symbols, which are returned when resolution fails @@ -322,7 +316,7 @@ public class Resolve { break; case PUBLIC: isAccessible = true; - if (allowModules && checkModuleAccess) { + if (allowModules) { ModuleSymbol currModule = env.toplevel.modle; currModule.complete(); PackageSymbol p = c.packge(); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java index ec68764c882..9bfbbfdd571 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -681,7 +681,7 @@ public class JavaCompiler { if (sep == -1) { msym = modules.getDefaultModule(); typeName = name; - } else if (source.allowModules() && !options.isSet("noModules")) { + } else if (source.allowModules()) { Name modName = names.fromString(name.substring(0, sep)); msym = moduleFinder.findModule(modName); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index f6760de482a..e3321892fbe 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -230,7 +230,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea chk = Check.instance(context); initProcessorLoader(); - allowModules = source.allowModules() && options.isUnset("noModules"); + allowModules = source.allowModules(); } public void setProcessors(Iterable processors) { From f9b57bfbedd775b223eb28b4cede89868a766392 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Mon, 9 Jan 2017 13:50:45 -0800 Subject: [PATCH 040/154] 8172255: JShell API: ExecutionControl/LoaderDelegate: Remove unused/unimplemented setClassPath Reviewed-by: jlahoda --- .../jshell/execution/DefaultLoaderDelegate.java | 6 ------ .../jshell/execution/DirectExecutionControl.java | 6 ------ .../execution/ExecutionControlForwarder.java | 6 ------ .../jdk/jshell/execution/LoaderDelegate.java | 10 ---------- .../classes/jdk/jshell/execution/RemoteCodes.java | 4 ---- .../execution/StreamingExecutionControl.java | 15 --------------- .../classes/jdk/jshell/spi/ExecutionControl.java | 10 ---------- langtools/test/jdk/jshell/KullaTesting.java | 4 ---- 8 files changed, 61 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java index e784f0dc348..b1713020a12 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java @@ -114,12 +114,6 @@ class DefaultLoaderDelegate implements LoaderDelegate { } } - @Override - public void setClasspath(String path) - throws EngineTerminationException, InternalException { - throw new NotImplementedException("setClasspath: Not supported yet."); - } - @Override public Class findClass(String name) throws ClassNotFoundException { Class klass = klasses.get(name); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java index 0a708954694..4ac77ee4d35 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java @@ -131,12 +131,6 @@ public class DirectExecutionControl implements ExecutionControl { loaderDelegate.addToClasspath(cp); } - @Override - public void setClasspath(String path) - throws EngineTerminationException, InternalException { - loaderDelegate.setClasspath(path); - } - /** * {@inheritDoc} *

diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/ExecutionControlForwarder.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/ExecutionControlForwarder.java index 9811828c985..b1a11dd44af 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/ExecutionControlForwarder.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/ExecutionControlForwarder.java @@ -147,12 +147,6 @@ class ExecutionControlForwarder { ec.addToClasspath(cp); return writeSuccess(); } - case CMD_SET_CLASSPATH: { - // Set the claspath - String cp = in.readUTF(); - ec.setClasspath(cp); - return writeSuccess(); - } case CMD_STOP: { // Stop the current execution try { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java index 062ad44acab..b1d7e33a32f 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java @@ -59,16 +59,6 @@ public interface LoaderDelegate { void addToClasspath(String path) throws EngineTerminationException, InternalException; - /** - * Sets the execution class path to the specified path. - * - * @param path the path to add - * @throws EngineTerminationException the execution engine has terminated - * @throws InternalException an internal problem occurred - */ - void setClasspath(String path) - throws EngineTerminationException, InternalException; - /** * Finds the class with the specified binary name. * diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteCodes.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteCodes.java index a7ecad37689..c841adb253b 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteCodes.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteCodes.java @@ -65,10 +65,6 @@ class RemoteCodes { * Add to the class-path. */ static final String CMD_ADD_CLASSPATH = "CMD_ADD_CLASSPATH"; - /** - * Set the class-path. - */ - static final String CMD_SET_CLASSPATH = "CMD_SET_CLASSPATH"; /** * Stop an invoke. */ diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java index f3495f1213a..60552894212 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java @@ -136,21 +136,6 @@ public class StreamingExecutionControl implements ExecutionControl { } } - @Override - public void setClasspath(String path) - throws EngineTerminationException, InternalException { - try { - // Send the classpath addition command to the remote agent. - writeCommand(CMD_SET_CLASSPATH); - out.writeUTF(path); - out.flush(); - // Retrieve and report results from the remote agent. - readAndReportClassSimpleResult(); - } catch (IOException ex) { - throw new EngineTerminationException("Exception writing remote set classpath: " + ex); - } - } - @Override public void stop() throws EngineTerminationException, InternalException { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java index 7760cbc398c..a054f99c108 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java @@ -117,16 +117,6 @@ public interface ExecutionControl extends AutoCloseable { void addToClasspath(String path) throws EngineTerminationException, InternalException; - /** - * Sets the execution class path to the specified path. - * - * @param path the path to add - * @throws EngineTerminationException the execution engine has terminated - * @throws InternalException an internal problem occurred - */ - void setClasspath(String path) - throws EngineTerminationException, InternalException; - /** * Interrupts a running invoke. * diff --git a/langtools/test/jdk/jshell/KullaTesting.java b/langtools/test/jdk/jshell/KullaTesting.java index 9edc256f510..1197d0399a0 100644 --- a/langtools/test/jdk/jshell/KullaTesting.java +++ b/langtools/test/jdk/jshell/KullaTesting.java @@ -99,7 +99,6 @@ public class KullaTesting { private Map idToSnippet = new LinkedHashMap<>(); private Set allSnippets = new LinkedHashSet<>(); - private List classpath; static { JShell js = JShell.create(); @@ -159,7 +158,6 @@ public class KullaTesting { } public void addToClasspath(String path) { - classpath.add(path); getState().addToClasspath(path); } @@ -200,7 +198,6 @@ public class KullaTesting { state = builder.build(); allSnippets = new LinkedHashSet<>(); idToSnippet = new LinkedHashMap<>(); - classpath = new ArrayList<>(); } @AfterMethod @@ -210,7 +207,6 @@ public class KullaTesting { analysis = null; allSnippets = null; idToSnippet = null; - classpath = null; } public ClassLoader createAndRunFromModule(String moduleName, Path modPath) { From bee65032d41b0ffc431039f37f8ae3473ccabe29 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 9 Jan 2017 16:20:48 -0800 Subject: [PATCH 041/154] 8172458: Make javax.lang.model javadoc HTML 5 compliant Reviewed-by: jjg --- .../javax/annotation/processing/Processor.java | 10 +++++----- .../lang/model/element/AnnotationValueVisitor.java | 2 +- .../javax/lang/model/element/ElementVisitor.java | 2 +- .../classes/javax/lang/model/type/TypeVisitor.java | 2 +- .../classes/javax/lang/model/type/WildcardType.java | 4 ++-- .../javax/lang/model/util/ElementKindVisitor6.java | 8 ++++---- .../javax/lang/model/util/ElementKindVisitor7.java | 8 ++++---- .../javax/lang/model/util/ElementKindVisitor8.java | 8 ++++---- .../javax/lang/model/util/ElementKindVisitor9.java | 8 ++++---- .../javax/lang/model/util/ElementScanner6.java | 12 ++++++------ .../javax/lang/model/util/ElementScanner7.java | 12 ++++++------ .../javax/lang/model/util/ElementScanner8.java | 12 ++++++------ .../javax/lang/model/util/ElementScanner9.java | 12 ++++++------ .../javax/lang/model/util/TypeKindVisitor6.java | 8 ++++---- .../javax/lang/model/util/TypeKindVisitor7.java | 8 ++++---- .../javax/lang/model/util/TypeKindVisitor8.java | 8 ++++---- .../javax/lang/model/util/TypeKindVisitor9.java | 8 ++++---- 17 files changed, 66 insertions(+), 66 deletions(-) diff --git a/langtools/src/java.compiler/share/classes/javax/annotation/processing/Processor.java b/langtools/src/java.compiler/share/classes/javax/annotation/processing/Processor.java index f6afca8d0ea..9eae468d4ef 100644 --- a/langtools/src/java.compiler/share/classes/javax/annotation/processing/Processor.java +++ b/langtools/src/java.compiler/share/classes/javax/annotation/processing/Processor.java @@ -243,9 +243,9 @@ public interface Processor { * Returns the names of the annotation types supported by this * processor. An element of the result may be the canonical * (fully qualified) name of a supported annotation type. - * Alternately it may be of the form "name.*" + * Alternately it may be of the form "name.*" * representing the set of all annotation types with canonical - * names beginning with "name.". + * names beginning with "name.". * * In either of those cases, the name of the annotation type can * be optionally preceded by a module name followed by a {@code @@ -267,13 +267,13 @@ public interface Processor { *

*
SupportedAnnotationTypeString: *
ModulePrefixopt TypeName DotStaropt - *
* + *
* * *
ModulePrefix: - *
TypeName / + *
TypeName / * *
DotStar: - *
. * + *
. * *
* * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java b/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java index 6d01d0f1734..37d55d5ca80 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java @@ -41,7 +41,7 @@ import javax.lang.model.type.TypeMirror; * implementing this interface are used to operate on a value when the * type of that value is unknown at compile time. When a visitor is * passed to a value's {@link AnnotationValue#accept accept} method, - * the visitXYZ method applicable to that value is + * the visitXYZ method applicable to that value is * invoked. * *

Classes implementing this interface may or may not throw a diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java index a06a5c2396a..27125a5c515 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java @@ -32,7 +32,7 @@ import javax.lang.model.util.*; * pattern. Classes implementing this interface are used to operate * on an element when the kind of element is unknown at compile time. * When a visitor is passed to an element's {@link Element#accept - * accept} method, the visitXYZ method most applicable + * accept} method, the visitXYZ method most applicable * to that element is invoked. * *

Classes implementing this interface may or may not throw a diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java b/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java index f51d843d60e..7e6026d0914 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java @@ -32,7 +32,7 @@ import javax.lang.model.element.*; * visitor design pattern. Classes implementing this * interface are used to operate on a type when the kind of * type is unknown at compile time. When a visitor is passed to a - * type's {@link TypeMirror#accept accept} method, the visitXYZ + * type's {@link TypeMirror#accept accept} method, the visitXYZ * method most applicable to that type is invoked. * *

Classes implementing this interface may or may not throw a diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/type/WildcardType.java b/langtools/src/java.compiler/share/classes/javax/lang/model/type/WildcardType.java index 3f941a1f82a..859cdfc6c0a 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/type/WildcardType.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/type/WildcardType.java @@ -28,11 +28,11 @@ package javax.lang.model.type; /** * Represents a wildcard type argument. - * Examples include:


+ * Examples include:    

  *   ?
  *   ? extends Number
  *   ? super T
- * 
+ *
* *

A wildcard may have its upper bound explicitly set by an * {@code extends} clause, its lower bound explicitly set by a diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java index ec188e794de..730e5287349 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java @@ -36,10 +36,10 @@ import javax.lang.model.SourceVersion; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java index 66874151fbd..f62c272e635 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_7 RELEASE_7} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java index 3af0257eefa..57daa2b38dc 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java @@ -34,10 +34,10 @@ import javax.lang.model.SourceVersion; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_8 RELEASE_8} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java index eb1a303e3ee..3e1fea46ce0 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java @@ -34,10 +34,10 @@ import javax.lang.model.SourceVersion; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_9 RELEASE_9} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java index 3d7b7dd40a9..372253192e0 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6} - * source version. The visitXYZ methods in this + * source version. The visitXYZ methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXYZ methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXYZ method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXYZ. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXYZ at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXYZ, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java index d99583f1b7a..b3590689c5b 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} - * source version. The visitXYZ methods in this + * source version. The visitXYZ methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXYZ methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXYZ method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXYZ. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXYZ at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXYZ, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java index 517a4f30b4f..25f00a011a8 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} - * source version. The visitXYZ methods in this + * source version. The visitXYZ methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXYZ methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXYZ method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXYZ. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXYZ at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXYZ, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java index c7419c8921d..08269399713 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9} - * source version. The visitXYZ methods in this + * source version. The visitXYZ methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXYZ methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXYZ method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXYZ. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXYZ at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXYZ, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java index 5ff4097e288..e32166f63db 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_6 * RELEASE_6} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java index c560914734a..9fb9594976a 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java @@ -34,10 +34,10 @@ import javax.lang.model.SourceVersion; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_7 * RELEASE_7} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java index c6e8387f0a7..064652a8aef 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_8 * RELEASE_8} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java index 299969b39b3..7e635fb37d0 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_9 * RELEASE_9} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * From cea33151ed5f8486686fcb8408f7db0fdf511d23 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Mon, 9 Jan 2017 18:04:16 -0800 Subject: [PATCH 042/154] 8171981: JShell: Fails compilation: new Object().getClass().getSuperclass() Reviewed-by: mcimadamore --- .../jshell/debug/InternalDebugControl.java | 5 + .../jdk/internal/jshell/tool/JShellTool.java | 7 +- .../share/classes/jdk/jshell/Eval.java | 14 +- .../jdk/jshell/ExpressionToTypeInfo.java | 216 ++++++++++++++ .../jdk/jshell/SourceCodeAnalysisImpl.java | 40 +-- .../share/classes/jdk/jshell/TaskFactory.java | 2 +- .../classes/jdk/jshell/TreeDissector.java | 58 +--- .../share/classes/jdk/jshell/TypePrinter.java | 48 +--- .../share/classes/jdk/jshell/Unit.java | 3 + .../classes/jdk/jshell/VarTypePrinter.java | 267 ++++++++++++++++++ langtools/test/jdk/jshell/TypeNameTest.java | 222 ++++++++++++--- langtools/test/jdk/jshell/VariablesTest.java | 16 -- 12 files changed, 707 insertions(+), 191 deletions(-) create mode 100644 langtools/src/jdk.jshell/share/classes/jdk/jshell/ExpressionToTypeInfo.java create mode 100644 langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java index 4f759c7632c..8aa204240d0 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java @@ -68,6 +68,11 @@ public class InternalDebugControl { */ public static final int DBG_EVNT = 0b0010000; + /** + * Event debugging. + */ + public static final int DBG_WRAP = 0b0100000; + private static Map debugMap = null; /** 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 1d55473db48..6b05457e456 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 @@ -119,6 +119,7 @@ import static jdk.internal.jshell.debug.InternalDebugControl.DBG_DEP; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_FMGR; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN; +import static jdk.internal.jshell.debug.InternalDebugControl.DBG_WRAP; import static jdk.internal.jshell.tool.ContinuousCompletionProvider.STARTSWITH_MATCHER; /** @@ -1919,9 +1920,13 @@ public class JShellTool implements MessageHandler { flags |= DBG_EVNT; fluff("Event debugging on"); break; + case 'w': + flags |= DBG_WRAP; + fluff("Wrap debugging on"); + break; default: hard("Unknown debugging option: %c", ch); - fluff("Use: 0 r g f c d"); + fluff("Use: 0 r g f c d e w"); return false; } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java index a033b9fd757..de259506ac4 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java @@ -49,6 +49,7 @@ import java.io.StringWriter; import java.io.Writer; import java.util.LinkedHashSet; import java.util.Set; +import jdk.jshell.ExpressionToTypeInfo.ExpressionInfo; import jdk.jshell.Key.ErroneousKey; import jdk.jshell.Key.MethodKey; import jdk.jshell.Key.TypeDeclKey; @@ -58,7 +59,6 @@ import jdk.jshell.TaskFactory.AnalyzeTask; import jdk.jshell.TaskFactory.BaseTask; import jdk.jshell.TaskFactory.CompileTask; import jdk.jshell.TaskFactory.ParseTask; -import jdk.jshell.TreeDissector.ExpressionInfo; import jdk.jshell.Wrap.Range; import jdk.jshell.Snippet.Status; import jdk.jshell.spi.ExecutionControl.ClassBytecodes; @@ -296,7 +296,7 @@ class Eval { private List processExpression(String userSource, String compileSource) { String name = null; - ExpressionInfo ei = typeOfExpression(compileSource); + ExpressionInfo ei = ExpressionToTypeInfo.expressionInfo(compileSource, state); ExpressionTree assignVar; Wrap guts; Snippet snip; @@ -499,16 +499,6 @@ class Eval { return singletonList(snip); } - private ExpressionInfo typeOfExpression(String expression) { - Wrap guts = Wrap.methodReturnWrap(expression); - TaskFactory.AnalyzeTask at = trialCompile(guts); - if (!at.hasErrors() && at.firstCuTree() != null) { - return TreeDissector.createByFirstClass(at) - .typeOfReturnStatement(at, state); - } - return null; - } - /** * Should a temp var wrap the expression. TODO make this user configurable. * diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExpressionToTypeInfo.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExpressionToTypeInfo.java new file mode 100644 index 00000000000..f33c37133a6 --- /dev/null +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExpressionToTypeInfo.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jshell; + +import com.sun.source.tree.ReturnTree; +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.ConditionalExpressionTree; +import com.sun.source.tree.ExpressionTree; +import com.sun.source.tree.MethodTree; +import com.sun.source.tree.Tree; +import com.sun.source.util.TreePath; +import com.sun.source.util.TreePathScanner; +import com.sun.tools.javac.code.Symtab; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.Types; +import jdk.jshell.TaskFactory.AnalyzeTask; + +/** + * Compute information about an expression string, particularly its type name. + */ +class ExpressionToTypeInfo { + + private static final String OBJECT_TYPE_NAME = "Object"; + + final AnalyzeTask at; + final CompilationUnitTree cu; + final JShell state; + final Symtab syms; + final Types types; + + private ExpressionToTypeInfo(AnalyzeTask at, CompilationUnitTree cu, JShell state) { + this.at = at; + this.cu = cu; + this.state = state; + this.syms = Symtab.instance(at.context); + this.types = Types.instance(at.context); + } + + public static class ExpressionInfo { + ExpressionTree tree; + String typeName; + boolean isNonVoid; + } + + // return mechanism and other general structure from TreePath.getPath() + private static class Result extends Error { + + static final long serialVersionUID = -5942088234594905629L; + final TreePath expressionPath; + + Result(TreePath path) { + this.expressionPath = path; + } + } + + private static class PathFinder extends TreePathScanner { + + // Optimize out imports etc + @Override + public TreePath visitCompilationUnit(CompilationUnitTree node, Boolean isTargetContext) { + return scan(node.getTypeDecls(), isTargetContext); + } + + // Only care about members + @Override + public TreePath visitClass(ClassTree node, Boolean isTargetContext) { + return scan(node.getMembers(), isTargetContext); + } + + // Only want the doit method where the code is + @Override + public TreePath visitMethod(MethodTree node, Boolean isTargetContext) { + if (Util.isDoIt(node.getName())) { + return scan(node.getBody(), true); + } else { + return null; + } + } + + @Override + public TreePath visitReturn(ReturnTree node, Boolean isTargetContext) { + ExpressionTree tree = node.getExpression(); + TreePath tp = new TreePath(getCurrentPath(), tree); + if (isTargetContext) { + throw new Result(tp); + } else { + return null; + } + } + } + + private Type pathToType(TreePath tp) { + return (Type) at.trees().getTypeMirror(tp); + } + + private Type pathToType(TreePath tp, Tree tree) { + if (tree instanceof ConditionalExpressionTree) { + // Conditionals always wind up as Object -- this corrects + ConditionalExpressionTree cet = (ConditionalExpressionTree) tree; + Type tmt = pathToType(new TreePath(tp, cet.getTrueExpression())); + Type tmf = pathToType(new TreePath(tp, cet.getFalseExpression())); + if (!tmt.isPrimitive() && !tmf.isPrimitive()) { + Type lub = types.lub(tmt, tmf); + // System.err.printf("cond ? %s : %s -- lub = %s\n", + // varTypeName(tmt), varTypeName(tmf), varTypeName(lub)); + return lub; + } + } + return pathToType(tp); + } + + /** + * Entry method: get expression info + * @param code the expression as a string + * @param state a JShell instance + * @return type information + */ + public static ExpressionInfo expressionInfo(String code, JShell state) { + if (code == null || code.isEmpty()) { + return null; + } + try { + OuterWrap codeWrap = state.outerMap.wrapInTrialClass(Wrap.methodReturnWrap(code)); + AnalyzeTask at = state.taskFactory.new AnalyzeTask(codeWrap); + CompilationUnitTree cu = at.firstCuTree(); + if (at.hasErrors() || cu == null) { + return null; + } + return new ExpressionToTypeInfo(at, cu, state).typeOfExpression(); + } catch (Exception ex) { + return null; + } + } + + private ExpressionInfo typeOfExpression() { + return treeToInfo(findExpressionPath()); + } + + private TreePath findExpressionPath() { + try { + new PathFinder().scan(new TreePath(cu), false); + } catch (Result result) { + return result.expressionPath; + } + return null; + } + + private ExpressionInfo treeToInfo(TreePath tp) { + if (tp != null) { + Tree tree = tp.getLeaf(); + if (tree instanceof ExpressionTree) { + ExpressionInfo ei = new ExpressionInfo(); + ei.tree = (ExpressionTree) tree; + Type type = pathToType(tp, tree); + if (type != null) { + switch (type.getKind()) { + case VOID: + case NONE: + case ERROR: + case OTHER: + break; + case NULL: + ei.isNonVoid = true; + ei.typeName = OBJECT_TYPE_NAME; + break; + default: { + ei.isNonVoid = true; + ei.typeName = varTypeName(type); + if (ei.typeName == null) { + ei.typeName = OBJECT_TYPE_NAME; + } + break; + } + } + } + return ei; + } + } + return null; + } + + private String varTypeName(Type type) { + try { + TypePrinter tp = new VarTypePrinter(at.messages(), + state.maps::fullClassNameAndPackageToClass, syms, types); + return tp.toString(type); + } catch (Exception ex) { + return null; + } + } + +} diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index 7241b1383dc..2ebc424b151 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -105,7 +105,6 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import static java.util.stream.Collectors.collectingAndThen; -import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toCollection; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; @@ -128,6 +127,7 @@ import javax.lang.model.util.Types; import javax.tools.JavaFileManager.Location; import javax.tools.StandardLocation; +import jdk.jshell.ExpressionToTypeInfo.ExpressionInfo; import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME; import static jdk.jshell.SourceCodeAnalysis.Completeness.DEFINITELY_INCOMPLETE; import static jdk.jshell.TreeDissector.printType; @@ -1430,47 +1430,17 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { @Override public String analyzeType(String code, int cursor) { - code = code.substring(0, cursor); - CompletionInfo completionInfo = analyzeCompletion(code); - if (!completionInfo.completeness().isComplete()) - return null; - if (completionInfo.completeness() == Completeness.COMPLETE_WITH_SEMI) { - code += ";"; - } - - OuterWrap codeWrap; switch (guessKind(code)) { case IMPORT: case METHOD: case CLASS: case ENUM: case INTERFACE: case ANNOTATION_TYPE: case VARIABLE: return null; default: - codeWrap = proc.outerMap.wrapInTrialClass(Wrap.methodWrap(code)); break; } - AnalyzeTask at = proc.taskFactory.new AnalyzeTask(codeWrap); - SourcePositions sp = at.trees().getSourcePositions(); - CompilationUnitTree topLevel = at.firstCuTree(); - int pos = codeWrap.snippetIndexToWrapIndex(code.length()); - TreePath tp = pathFor(topLevel, sp, pos); - while (ExpressionTree.class.isAssignableFrom(tp.getParentPath().getLeaf().getKind().asInterface()) && - tp.getParentPath().getLeaf().getKind() != Kind.ERRONEOUS && - tp.getParentPath().getParentPath() != null) - tp = tp.getParentPath(); - TypeMirror type = at.trees().getTypeMirror(tp); - - if (type == null) - return null; - - switch (type.getKind()) { - case ERROR: case NONE: case OTHER: - case PACKAGE: case VOID: - return null; //not usable - case NULL: - type = at.getElements().getTypeElement("java.lang.Object").asType(); - break; - } - - return TreeDissector.printType(at, proc, type); + ExpressionInfo ei = ExpressionToTypeInfo.expressionInfo(code, proc); + return (ei == null || !ei.isNonVoid) + ? null + : ei.typeName; } @Override 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 fc5282122e8..6b2d441eb74 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java @@ -321,7 +321,7 @@ class TaskFactory { final JavacTaskImpl task; private DiagList diags = null; private final SourceHandler sourceHandler; - private final Context context = new Context(); + final Context context = new Context(); private Types types; private JavacMessages messages; private Trees trees; diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDissector.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDissector.java index c9fd4cedc59..b177bf2db02 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDissector.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDissector.java @@ -28,14 +28,11 @@ package jdk.jshell; import com.sun.source.tree.ClassTree; import com.sun.source.tree.CompilationUnitTree; -import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.MethodTree; -import com.sun.source.tree.ReturnTree; import com.sun.source.tree.StatementTree; import com.sun.source.tree.Tree; import com.sun.source.tree.VariableTree; import com.sun.source.util.SourcePositions; -import com.sun.source.util.TreePath; import com.sun.source.util.Trees; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.MethodType; @@ -47,7 +44,6 @@ import jdk.jshell.TaskFactory.AnalyzeTask; import jdk.jshell.Wrap.Range; import java.util.List; -import java.util.Locale; import java.util.function.Predicate; import java.util.stream.Stream; @@ -61,16 +57,6 @@ import jdk.jshell.Util.Pair; class TreeDissector { - private static final String OBJECT_TYPE = "Object"; - - static class ExpressionInfo { - - boolean isNonVoid; - String typeName; - ExpressionTree tree; - String signature; - } - private final TaskFactory.BaseTask bt; private final ClassTree targetClass; private final CompilationUnitTree targetCompilationUnit; @@ -219,41 +205,6 @@ class TreeDissector { return null; } - - ExpressionInfo typeOfReturnStatement(AnalyzeTask at, JShell state) { - ExpressionInfo ei = new ExpressionInfo(); - Tree unitTree = firstStatement(); - if (unitTree instanceof ReturnTree) { - ei.tree = ((ReturnTree) unitTree).getExpression(); - if (ei.tree != null) { - TreePath viPath = trees().getPath(targetCompilationUnit, ei.tree); - if (viPath != null) { - TypeMirror tm = trees().getTypeMirror(viPath); - if (tm != null) { - ei.typeName = printType(at, state, tm); - switch (tm.getKind()) { - case VOID: - case NONE: - case ERROR: - case OTHER: - break; - case NULL: - ei.isNonVoid = true; - ei.typeName = OBJECT_TYPE; - break; - default: { - ei.isNonVoid = true; - break; - - } - } - } - } - } - } - return ei; - } - String typeOfMethod(MethodSnippet msn) { Tree unitTree = method(msn); if (unitTree instanceof JCMethodDecl) { @@ -274,8 +225,13 @@ class TreeDissector { public static String printType(AnalyzeTask at, JShell state, TypeMirror type) { Type typeImpl = (Type) type; - TypePrinter tp = new TypePrinter(at.messages(), state.maps::fullClassNameAndPackageToClass, typeImpl); - return tp.visit(typeImpl, Locale.getDefault()); + try { + TypePrinter tp = new TypePrinter(at.messages(), + state.maps::fullClassNameAndPackageToClass); + return tp.toString(typeImpl); + } catch (Exception ex) { + return null; + } } /** diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypePrinter.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypePrinter.java index e35fe5e7d7b..b5ae176fbf5 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypePrinter.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypePrinter.java @@ -22,7 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package jdk.jshell; import static com.sun.tools.javac.code.Flags.COMPOUND; @@ -41,17 +40,21 @@ import java.util.function.BinaryOperator; * Print types in source form. */ class TypePrinter extends Printer { + private static final String OBJECT = "Object"; private final JavacMessages messages; private final BinaryOperator fullClassNameAndPackageToClass; - private boolean useWildCard = false; - TypePrinter(JavacMessages messages, BinaryOperator fullClassNameAndPackageToClass, Type typeToPrint) { + TypePrinter(JavacMessages messages, BinaryOperator fullClassNameAndPackageToClass) { this.messages = messages; this.fullClassNameAndPackageToClass = fullClassNameAndPackageToClass; } + String toString(Type t) { + return visit(t, Locale.getDefault()); + } + @Override protected String localize(Locale locale, String key, Object... args) { return messages.getLocalizedString(locale, key, args); @@ -67,18 +70,6 @@ class TypePrinter extends Printer { return visit(t.wildcard, locale); } - @Override - public String visitWildcardType(Type.WildcardType wt, Locale locale) { - if (useWildCard) { // at TypeArgument(ex: List) - return super.visitWildcardType(wt, locale); - } else { // at TopLevelType(ex: ? extends List, ? extends Number[][]) - Type extendsBound = wt.getExtendsBound(); - return extendsBound == null - ? OBJECT - : visit(extendsBound, locale); - } - } - @Override public String visitType(Type t, Locale locale) { String s = (t.tsym == null || t.tsym.name == null) @@ -87,20 +78,9 @@ class TypePrinter extends Printer { return s; } - @Override - public String visitClassType(ClassType ct, Locale locale) { - boolean prevUseWildCard = useWildCard; - try { - useWildCard = true; - return super.visitClassType(ct, locale); - } finally { - useWildCard = prevUseWildCard; - } - } - /** - * Converts a class name into a (possibly localized) string. Anonymous - * inner classes get converted into a localized string. + * Converts a class name into a (possibly localized) string. Anonymous inner + * classes get converted into a localized string. * * @param t the type of the class whose name is to be rendered * @param longform if set, the class' fullname is displayed - if unset the @@ -112,21 +92,13 @@ class TypePrinter extends Printer { protected String className(ClassType t, boolean longform, Locale locale) { Symbol sym = t.tsym; if (sym.name.length() == 0 && (sym.flags() & COMPOUND) != 0) { - /*** - StringBuilder s = new StringBuilder(visit(t.supertype_field, locale)); - for (List is = t.interfaces_field; is.nonEmpty(); is = is.tail) { - s.append('&'); - s.append(visit(is.head, locale)); - } - return s.toString(); - ***/ return OBJECT; } else if (sym.name.length() == 0) { // Anonymous String s; ClassType norm = (ClassType) t.tsym.type; if (norm == null) { - s = "object"; + s = OBJECT; } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { s = visit(norm.interfaces_field.head, locale); } else { @@ -160,7 +132,7 @@ class TypePrinter extends Printer { @Override public String visitPackageSymbol(PackageSymbol s, Locale locale) { return s.isUnnamed() - ? "" // Unnamed package + ? "" // Unnamed package : s.fullname.toString(); } 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 c56db661ed2..555598ca9b4 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java @@ -46,6 +46,7 @@ import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN; +import static jdk.internal.jshell.debug.InternalDebugControl.DBG_WRAP; import static jdk.jshell.Snippet.Status.OVERWRITTEN; import static jdk.jshell.Snippet.Status.RECOVERABLE_DEFINED; import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED; @@ -180,6 +181,8 @@ final class Unit { .collect(toList()); // Set the outer wrap for this snippet si.setOuterWrap(state.outerMap.wrapInClass(except, plus, snippets, wraps)); + state.debug(DBG_WRAP, "++setWrap() %s\n%s\n", + si, si.outerWrap().wrapped()); } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java new file mode 100644 index 00000000000..ba98a4015ca --- /dev/null +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jshell; + +import java.util.HashSet; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.Type.ClassType; +import com.sun.tools.javac.util.JavacMessages; +import java.util.Locale; +import java.util.Set; +import java.util.function.BinaryOperator; +import com.sun.tools.javac.code.BoundKind; +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.code.Symtab; +import com.sun.tools.javac.code.Type.CapturedType; +import com.sun.tools.javac.code.Type.TypeMapping; +import com.sun.tools.javac.code.Type.TypeVar; +import com.sun.tools.javac.code.Type.WildcardType; +import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.code.Types.SimpleVisitor; +import com.sun.tools.javac.util.List; +import static com.sun.tools.javac.code.BoundKind.EXTENDS; +import static com.sun.tools.javac.code.BoundKind.SUPER; +import static com.sun.tools.javac.code.BoundKind.UNBOUND; +import static com.sun.tools.javac.code.Type.ArrayType; +import static com.sun.tools.javac.code.TypeTag.BOT; +import static com.sun.tools.javac.code.TypeTag.WILDCARD; + +/** + * Print variable types in source form. + * TypeProjection and CaptureScanner are copied from Types in the JEP-286 + * Sandbox by Maurizio. The checks for Non-Denotable in TypePrinter are + * cribbed from denotableChecker of the same source. + * + * @author Maurizio Cimadamore + * @author Robert Field + */ +class VarTypePrinter extends TypePrinter { + private static final String WILD = "?"; + + private final Symtab syms; + private final Types types; + + VarTypePrinter(JavacMessages messages, BinaryOperator fullClassNameAndPackageToClass, + Symtab syms, Types types) { + super(messages, fullClassNameAndPackageToClass); + this.syms = syms; + this.types = types; + } + + @Override + String toString(Type t) { + return super.toString(upward(t)); + } + + @Override + public String visitTypeVar(TypeVar t, Locale locale) { + /* Any type variable mentioned in the inferred type must have been declared as a type parameter + (i.e cannot have been produced by inference (18.4)) + */ + // and beyond that, there are no global type vars, so if there are any + // type variables left, they need to be eliminated + return WILD; // Non-denotable + } + + @Override + public String visitCapturedType(CapturedType t, Locale locale) { + /* Any type variable mentioned in the inferred type must have been declared as a type parameter + (i.e cannot have been produced by capture conversion (5.1.10)) + */ + return WILD; // Non-denotable + } + + public Type upward(Type t) { + List captures = captures(t); + return upward(t, captures); + } + + /************* Following from JEP-286 Types.java ***********/ + + public Type upward(Type t, List vars) { + return t.map(new TypeProjection(vars), true); + } + + public List captures(Type t) { + CaptureScanner cs = new CaptureScanner(); + Set captures = new HashSet<>(); + cs.visit(t, captures); + return List.from(captures); + } + + class CaptureScanner extends SimpleVisitor> { + + @Override + public Void visitType(Type t, Set types) { + return null; + } + + @Override + public Void visitClassType(ClassType t, Set seen) { + if (t.isCompound()) { + types.directSupertypes(t).forEach(s -> visit(s, seen)); + } else { + t.allparams().forEach(ta -> visit(ta, seen)); + } + return null; + } + + @Override + public Void visitArrayType(ArrayType t, Set seen) { + return visit(t.elemtype, seen); + } + + @Override + public Void visitWildcardType(WildcardType t, Set seen) { + visit(t.type, seen); + return null; + } + + @Override + public Void visitTypeVar(TypeVar t, Set seen) { + if ((t.tsym.flags() & Flags.SYNTHETIC) != 0 && seen.add(t)) { + visit(t.getUpperBound(), seen); + } + return null; + } + + @Override + public Void visitCapturedType(CapturedType t, Set seen) { + if (seen.add(t)) { + visit(t.getUpperBound(), seen); + visit(t.getLowerBound(), seen); + } + return null; + } + } + + class TypeProjection extends TypeMapping { + + List vars; + Set seen = new HashSet<>(); + + public TypeProjection(List vars) { + this.vars = vars; + } + + @Override + public Type visitClassType(ClassType t, Boolean upward) { + if (upward && !t.isCompound() && t.tsym.name.isEmpty()) { + //lift anonymous class type to first supertype (class or interface) + return types.directSupertypes(t).last(); + } else if (t.isCompound()) { + List components = types.directSupertypes(t); + List components1 = components.map(c -> c.map(this, upward)); + if (components == components1) return t; + else return types.makeIntersectionType(components1); + } else { + Type outer = t.getEnclosingType(); + Type outer1 = visit(outer, upward); + List typarams = t.getTypeArguments(); + List typarams1 = typarams.stream() + .map(ta -> mapTypeArgument(ta, upward)) + .collect(List.collector()); + if (typarams1.stream().anyMatch(ta -> ta.hasTag(BOT))) { + //not defined + return syms.botType; + } + if (outer1 == outer && typarams1 == typarams) return t; + else return new ClassType(outer1, typarams1, t.tsym, t.getMetadata()) { + @Override + protected boolean needsStripping() { + return true; + } + }; + } + } + + protected Type makeWildcard(Type upper, Type lower) { + BoundKind bk; + Type bound; + if (upper.hasTag(BOT)) { + upper = syms.objectType; + } + boolean isUpperObject = types.isSameType(upper, syms.objectType); + if (!lower.hasTag(BOT) && isUpperObject) { + bound = lower; + bk = SUPER; + } else { + bound = upper; + bk = isUpperObject ? UNBOUND : EXTENDS; + } + return new WildcardType(bound, bk, syms.boundClass); + } + + @Override + public Type visitTypeVar(TypeVar t, Boolean upward) { + if (vars.contains(t)) { + try { + if (seen.add(t)) { + return (upward ? + t.getUpperBound() : + (t.getLowerBound() == null) ? + syms.botType : + t.getLowerBound()) + .map(this, upward); + } else { + //cycle + return syms.objectType; + } + } finally { + seen.remove(t); + } + } else { + return t; + } + } + + @Override + public Type visitWildcardType(WildcardType wt, Boolean upward) { + if (upward) { + return wt.isExtendsBound() ? + wt.type.map(this, upward) : + syms.objectType; + } else { + return wt.isSuperBound() ? + wt.type.map(this, upward) : + syms.botType; + } + } + + private Type mapTypeArgument(Type t, boolean upward) { + if (!t.containsAny(vars)) { + return t; + } else if (!t.hasTag(WILDCARD) && !upward) { + //not defined + return syms.botType; + } else { + Type upper = t.map(this, upward); + Type lower = t.map(this, !upward); + return makeWildcard(upper, lower); + } + } + } +} diff --git a/langtools/test/jdk/jshell/TypeNameTest.java b/langtools/test/jdk/jshell/TypeNameTest.java index 4f1b9cef418..41205322c03 100644 --- a/langtools/test/jdk/jshell/TypeNameTest.java +++ b/langtools/test/jdk/jshell/TypeNameTest.java @@ -23,81 +23,229 @@ /* * @test - * @bug 8144903 + * @bug 8144903 8171981 * @summary Tests for determining the type from the expression * @build KullaTesting TestingInputStream * @run testng TypeNameTest */ -import jdk.jshell.Snippet; -import jdk.jshell.VarSnippet; import org.testng.annotations.Test; -import static jdk.jshell.Snippet.Status.VALID; import static org.testng.Assert.assertEquals; @Test public class TypeNameTest extends KullaTesting { - public void testReplClassName() { - assertEval("class C {}"); - VarSnippet sn = (VarSnippet) varKey(assertEval("new C();")); - assertEquals(sn.typeName(), "C"); + + private void assertType(String expr, String type) { + assertEquals(varKey(assertEval(expr)).typeName(), type); + assertInferredType(expr, type); + } + + public void testTypeInference() { + assertEval("import java.util.List;"); + assertEval("import java.util.ArrayList;"); + assertEval("import java.util.Arrays;"); + + assertType("new Object().getClass().getSuperclass() ", "Class"); + assertType("new ArrayList().getClass().getSuperclass()", "Class"); + assertType("new ArrayList().getClass()", "Class"); + assertType("ArrayList.class", "Class"); + assertType("ArrayList.class.getSuperclass()", "Class"); + + assertEval("class D { D getS() { return null; } }"); + assertEval("D d = new D();"); + assertType("d.getS()", "D"); + assertType("null", "Object"); + assertType("Class.forName( \"java.util.ArrayList\" )", "Class"); + assertType("new ArrayList() {}", "ArrayList"); + assertType("new ArrayList().stream()", "java.util.stream.Stream"); + assertType("Arrays.asList( 1, 2, 3)", "List"); + assertType("new ArrayList().getClass().getClass()", "Class"); + + assertEval("interface A {}"); + assertEval("interface I {}"); + assertEval("interface J extends A, I {}"); + assertEval("interface K extends A, I {}"); + assertEval("class P {}"); + assertType("(P) null", "P"); + } + + public void testConditionals() { + assertEval("import java.util.List;"); + assertEval("import java.util.ArrayList;"); + assertEval("import java.util.Arrays;"); + + assertEval("CharSequence cs = \"hi\";"); + assertEval("String st = \"low\";"); + assertEval("boolean b;"); + assertType("b? cs : st", "CharSequence"); + + assertEval("List l1 = Arrays.asList(\"hi\");"); + assertEval("List l2 = Arrays.asList(\"po\");"); + assertType("b? l1.get(0) : l2.get(0)", "String"); + + assertEval("class X {}"); + assertEval("class B extends X {}"); + assertEval("class C extends X {}"); + assertType("b? new B() : new C()", "X"); + } + + public void testJEP286NonDenotable() { + assertEval("import java.util.List;"); + assertEval("import java.util.Arrays;"); + assertEval("import java.util.Iterator;"); + + assertEval("List extString() { return Arrays.asList( \"hi\", \"low\" ); }"); + assertEval("List supString() { return Arrays.asList( \"hi\", \"low\" ); }"); + assertEval("List unbString() { return Arrays.asList( \"hi\", \"low\" ); }"); + assertEval("List[] extStringArr() {" + + " @SuppressWarnings(\"unchecked\") " + + "List[] a = new List[1]; a[0] = Arrays.asList(\"hi\"); return a; }"); + assertEval("List[] supStringArr() {" + + " @SuppressWarnings(\"unchecked\") " + + "List[] a = new List[1]; a[0] = Arrays.asList(\"hi\"); return a; }"); + assertEval("List[] unbStringArr() {" + + " @SuppressWarnings(\"unchecked\") " + + "List[] a = new List[1]; a[0] = Arrays.asList(\"hi\"); return a; }"); + assertEval("Iterable> extStringIter() {" + + "return Arrays.asList( Arrays.asList( \"hi\" ) ); }"); + assertEval("Iterable> supStringIter() {" + + "return Arrays.asList( Arrays.asList( \"hi\" ) ); }"); + assertEval("Iterable> unbStringIter() {" + + "return Arrays.asList( Arrays.asList( \"hi\" ) ); }"); + assertType("extString()", "List"); + assertType("extString().get(0)", "String"); + assertType("supString()", "List"); + assertType("supString().get(0)", "Object"); + assertType("unbString()", "List"); + assertType("unbString().get(0)", "Object"); + assertType("supStringArr()", "List[]"); + assertType("supStringArr()[0]", "List"); + assertType("supStringArr()[0].get(0)", "Object"); + assertType("unbStringArr()", "List[]"); + assertType("unbStringArr()[0]", "List"); + assertType("unbStringArr()[0].get(0)", "Object"); + assertType("extStringIter()", "Iterable>"); + assertType("extStringIter().iterator()", "Iterator>"); + assertType("extStringIter().iterator().next()", "List"); + assertType("extStringIter().iterator().next().get(0)", "String"); + assertType("supStringIter()", "Iterable>"); + assertType("supStringIter().iterator()", "Iterator>"); + assertType("supStringIter().iterator().next()", "List"); + assertType("supStringIter().iterator().next().get(0)", "Object"); + assertType("unbStringIter()", "Iterable>"); + assertType("unbStringIter().iterator()", "Iterator>"); + assertType("unbStringIter().iterator().next()", "List"); + assertType("unbStringIter().iterator().next().get(0)", "Object"); + } + + public void testJEP286NonDenotable2() { + assertEval("import java.util.List;"); + assertEval("import java.util.Arrays;"); + assertEval("import java.lang.reflect.Array;"); + + assertEval("> List extFbound() {" + + "return Arrays.asList( (Z)null ); }"); + assertEval("> List supFbound() {" + + "return Arrays.asList( (Z)null ); }"); + assertEval("> List[] extFboundArr() {" + + "@SuppressWarnings(\"unchecked\")" + + "List[] a = new List[1]; a[0] = Arrays.asList( (Z)null ); return a; }"); + assertEval("> List[] supFboundArr() {" + + "@SuppressWarnings(\"unchecked\")" + + "List[] a = new List[1]; a[0] = Arrays.asList( (Z)null ); return a; }"); + assertEval("> Iterable> extFboundIter() {" + + "return Arrays.asList( Arrays.asList( (Z)null ) ); }"); + assertEval("> Iterable> supFboundIter() {" + + "return Arrays.asList( Arrays.asList( (Z)null ) ); }"); + assertEval(" List listOf(Z z) { return Arrays.asList( z ); }"); + assertEval(" Z[] arrayOf(Z z) {" + + "@SuppressWarnings(\"unchecked\")" + + "final Z[] a = (Z[]) Array.newInstance(z.getClass(), 1); a[0] = z; return a; }"); + assertType("extFbound()", "List>"); + assertType("extFbound().get(0)", "Comparable"); + assertType("supFbound()", "List"); + assertType("supFbound().get(0)", "Object"); + assertType("extFboundArr()", "List>[]"); + assertType("extFboundArr()[0]", "List>"); + assertType("extFboundArr()[0].get(0)", "Comparable"); + assertType("supFboundArr()", "List[]"); + assertType("supFboundArr()[0]", "List"); + assertType("supFboundArr()[0].get(0)", "Object"); + assertType("extFboundIter()", "Iterable>>"); + assertType("extFboundIter().iterator()", "java.util.Iterator>>"); + assertType("extFboundIter().iterator().next()", "List>"); + assertType("extFboundIter().iterator().next().get(0)", "Comparable"); + assertType("supFboundIter()", "Iterable>"); + assertType("supFboundIter().iterator()", "java.util.Iterator>"); + assertType("supFboundIter().iterator().next()", "List"); + assertType("supFboundIter().iterator().next().get(0)", "Object"); + assertType("listOf(23)", "List"); + assertType("listOf(true)", "List"); + assertType("listOf(true).get(0)", "Boolean"); + assertType("arrayOf(99)", "Integer[]"); + assertType("arrayOf(99)[0]", "Integer"); + + assertEval(" Z choose(Z z1, Z z2) { return z1; }"); + assertType("choose(1, 1L);", "Object"); + } + + public void testVariableTypeName() { + assertType("\"x\"", "String"); + + assertType("java.util.regex.Pattern.compile(\"x\")", "java.util.regex.Pattern"); + assertEval("import java.util.regex.*;"); + assertType("java.util.regex.Pattern.compile(\"x\")", "Pattern"); + + assertType("new java.util.ArrayList()", "java.util.ArrayList"); + assertEval("import java.util.ArrayList;"); + assertType("new java.util.ArrayList()", "ArrayList"); + + assertType("java.util.Locale.Category.FORMAT", "java.util.Locale.Category"); + assertEval("import static java.util.Locale.Category;"); + assertType("java.util.Locale.Category.FORMAT", "Category"); } public void testReplNestedClassName() { assertEval("class D { static class E {} }"); - VarSnippet sn = (VarSnippet) varKey(assertEval("new D.E();")); - assertEquals(sn.typeName(), "D.E"); + assertType("new D.E();", "D.E"); } public void testAnonymousClassName() { assertEval("class C {}"); - VarSnippet sn = (VarSnippet) varKey(assertEval("new C() { int x; };")); - assertEquals(sn.typeName(), "C"); + assertType("new C();", "C"); + assertType("new C() { int x; };", "C"); } public void testCapturedTypeName() { - VarSnippet sn = (VarSnippet) varKey(assertEval("\"\".getClass();")); - assertEquals(sn.typeName(), "Class"); - } - - public void testArrayTypeOfCapturedTypeName() { - VarSnippet sn = (VarSnippet) varKey(assertEval("\"\".getClass().getEnumConstants();")); - assertEquals(sn.typeName(), "String[]"); + assertType("\"\".getClass();", "Class"); + assertType("\"\".getClass().getEnumConstants();", "String[]"); } public void testJavaLang() { - VarSnippet sn = (VarSnippet) varKey(assertEval("\"\";")); - assertEquals(sn.typeName(), "String"); + assertType("\"\";", "String"); } public void testNotOverEagerPackageEating() { - VarSnippet sn = (VarSnippet) varKey(assertEval("\"\".getClass().getDeclaredMethod(\"hashCode\");")); - assertEquals(sn.typeName(), "java.lang.reflect.Method"); + assertType("\"\".getClass().getDeclaredMethod(\"hashCode\");", "java.lang.reflect.Method"); } public void testBounds() { assertEval("java.util.List list1 = java.util.Arrays.asList(\"\");"); - VarSnippet sn1 = (VarSnippet) varKey(assertEval("list1.iterator().next()")); - assertEquals(sn1.typeName(), "String"); + assertType("list1.iterator().next()", "String"); assertEval("java.util.List list2 = java.util.Arrays.asList(\"\");"); - VarSnippet sn2 = (VarSnippet) varKey(assertEval("list2.iterator().next()")); - assertEquals(sn2.typeName(), "Object"); + assertType("list2.iterator().next()", "Object"); assertEval("java.util.List list3 = java.util.Arrays.asList(\"\");"); - VarSnippet sn3 = (VarSnippet) varKey(assertEval("list3.iterator().next()")); - assertEquals(sn3.typeName(), "Object"); + assertType("list3.iterator().next()", "Object"); assertEval("class Test1 { public X get() { return null; } }"); - Snippet x = varKey(assertEval("Test1 test1 = new Test1<>();")); - VarSnippet sn4 = (VarSnippet) varKey(assertEval("test1.get()")); - assertEquals(sn4.typeName(), "Object"); + assertEval("Test1 test1 = new Test1<>();"); + assertType("test1.get()", "CharSequence"); assertEval("class Test2 { public X get() { return null; } }"); assertEval("Test2 test2 = new Test2<>();"); - VarSnippet sn5 = (VarSnippet) varKey(assertEval("test2.get()")); - assertEquals(sn5.typeName(), "Object"); - assertEval("class Test3 { T[][] get() { return null; } }", added(VALID)); + assertType("test2.get()", "Object"); + assertEval("class Test3 { T[][] get() { return null; } }"); assertEval("Test3 test3 = new Test3<>();"); - VarSnippet sn6 = (VarSnippet) varKey(assertEval("test3.get()")); - assertEquals(sn6.typeName(), "String[][]"); + assertType("test3.get()", "String[][]"); } } diff --git a/langtools/test/jdk/jshell/VariablesTest.java b/langtools/test/jdk/jshell/VariablesTest.java index 94b26a7b8ba..de5fc1fb973 100644 --- a/langtools/test/jdk/jshell/VariablesTest.java +++ b/langtools/test/jdk/jshell/VariablesTest.java @@ -337,20 +337,4 @@ public class VariablesTest extends KullaTesting { assertEquals(unr.get(0), "class undefined"); assertVariables(variable("undefined", "d")); } - - public void variableTypeName() { - assertEquals(varKey(assertEval("\"x\"")).typeName(), "String"); - - assertEquals(varKey(assertEval("java.util.regex.Pattern.compile(\"x\")")).typeName(), "java.util.regex.Pattern"); - assertEval("import java.util.regex.*;", added(VALID)); - assertEquals(varKey(assertEval("java.util.regex.Pattern.compile(\"x\")")).typeName(), "Pattern"); - - assertEquals(varKey(assertEval("new java.util.ArrayList()")).typeName(), "java.util.ArrayList"); - assertEval("import java.util.ArrayList;", added(VALID)); - assertEquals(varKey(assertEval("new java.util.ArrayList()")).typeName(), "ArrayList"); - - assertEquals(varKey(assertEval("java.util.Locale.Category.FORMAT")).typeName(), "java.util.Locale.Category"); - assertEval("import static java.util.Locale.Category;", added(VALID)); - assertEquals(varKey(assertEval("java.util.Locale.Category.FORMAT")).typeName(), "Category"); - } } From fd12ea2d58d80d29da850bb54b6f28de1561aeac Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 10 Jan 2017 10:17:47 +0100 Subject: [PATCH 043/154] 8171385: jshell tool: unresponsive to ctrl-C in input wait on Windows Ensuring stop is sent using the proper channel depending on the current state of the StopDetectingInputStream. Reviewed-by: rfield --- .../jshell/tool/StopDetectingInputStream.java | 6 +++- .../test/jdk/jshell/StopExecutionTest.java | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java index 9a103c63d99..578f5cf6893 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java @@ -66,7 +66,7 @@ public final class StopDetectingInputStream extends InputStream { if ((read = input.read()) == (-1)) { break; } - if (read == 3 && currentState == State.BUFFER) { + if (read == 3 && getState() == State.BUFFER) { stop.run(); } else { write(read); @@ -141,6 +141,10 @@ public final class StopDetectingInputStream extends InputStream { } } + private synchronized State getState() { + return state; + } + private synchronized State waitInputNeeded() { while (state == State.WAIT) { try { diff --git a/langtools/test/jdk/jshell/StopExecutionTest.java b/langtools/test/jdk/jshell/StopExecutionTest.java index a4e04d58298..389794d35d2 100644 --- a/langtools/test/jdk/jshell/StopExecutionTest.java +++ b/langtools/test/jdk/jshell/StopExecutionTest.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8171385 * @summary Test JShell#stop * @modules jdk.jshell/jdk.internal.jshell.tool * @build KullaTesting TestingInputStream @@ -30,9 +31,13 @@ */ import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.function.Consumer; import jdk.internal.jshell.tool.StopDetectingInputStream; import jdk.internal.jshell.tool.StopDetectingInputStream.State; @@ -128,4 +133,31 @@ public class StopExecutionTest extends KullaTesting { } } + public void testStopDetectingInputBufferWaitStop() throws Exception { + Runnable shouldNotHappenRun = + () -> { throw new AssertionError("Should not happen."); }; + Consumer shouldNotHappenExc = + exc -> { throw new AssertionError("Should not happen.", exc); }; + StopDetectingInputStream sd = new StopDetectingInputStream(shouldNotHappenRun, shouldNotHappenExc); + CountDownLatch reading = new CountDownLatch(1); + PipedInputStream is = new PipedInputStream() { + @Override + public int read() throws IOException { + reading.countDown(); + return super.read(); + } + }; + PipedOutputStream os = new PipedOutputStream(is); + + sd.setInputStream(is); + sd.setState(State.BUFFER); + reading.await(); + sd.setState(State.WAIT); + os.write(3); + int value = sd.read(); + + if (value != 3) { + throw new AssertionError(); + } + } } From 500900fb466b6c8f1a8843f43cec261ba6f2565b Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 10 Jan 2017 11:23:59 +0100 Subject: [PATCH 044/154] 8172241: Cleanup mistakes in jib publish support change Reviewed-by: tbell --- common/autoconf/spec.gmk.in | 13 +++++++++++++ common/conf/jib-profiles.js | 16 +++++++++++----- make/Bundles.gmk | 35 ++++++++++++++++++++++++++++++++++- make/Images.gmk | 4 ---- make/Main.gmk | 20 +++++++++++++++----- 5 files changed, 73 insertions(+), 15 deletions(-) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index a15b9f462fe..baccc4ffc0d 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -778,11 +778,18 @@ OS_VERSION_MICRO:=@OS_VERSION_MICRO@ # Images directory definitions JDK_IMAGE_SUBDIR:=jdk JRE_IMAGE_SUBDIR:=jre +JRE_COMPACT1_IMAGE_SUBDIR := jre-compact1 +JRE_COMPACT2_IMAGE_SUBDIR := jre-compact2 +JRE_COMPACT3_IMAGE_SUBDIR := jre-compact3 # Colon left out to be able to override output dir for bootcycle-images JDK_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR) JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR) +JRE_COMPACT1_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT1_IMAGE_SUBDIR) +JRE_COMPACT2_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT2_IMAGE_SUBDIR) +JRE_COMPACT3_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(JRE_COMPACT3_IMAGE_SUBDIR) + # Test image, as above TEST_IMAGE_SUBDIR:=test TEST_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(TEST_IMAGE_SUBDIR) @@ -818,6 +825,12 @@ else ifneq ($(DEBUG_LEVEL), release) endif JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz JRE_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz +JRE_COMPACT1_BUNDLE_NAME := \ + jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact1_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz +JRE_COMPACT2_BUNDLE_NAME := \ + jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact2_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz +JRE_COMPACT3_BUNDLE_NAME := \ + jre-$(VERSION_SHORT)+$(VERSION_BUILD)-compact3_$(OPENJDK_TARGET_BUNDLE_PLATFORM)_bin$(DEBUG_PART).tar.gz JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz JRE_SYMBOLS_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz ifeq ($(OPENJDK_TARGET_OS), windows) diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index af883b892b5..c6c04d756a5 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -501,7 +501,7 @@ var getJibProfilesProfiles = function (input, common, data) { // extra default target. var openOnlyProfilesExtra = { "linux-x86-open": { - default_make_targets: "profiles", + default_make_targets: "profiles-bundles", configure_args: "--with-jvm-variants=client,server" } }; @@ -587,6 +587,7 @@ var getJibProfilesProfiles = function (input, common, data) { ], work_dir: input.get("src.full", "install_path") + "/test", environment: { + "JT_JAVA": common.boot_jdk_home, "PRODUCT_HOME": input.get(testedProfile + ".jdk", "home_path"), "TEST_IMAGE_DIR": input.get(testedProfile + ".test", "home_path"), "TEST_OUTPUT_DIR": input.src_top_dir @@ -710,10 +711,15 @@ var getJibProfilesProfiles = function (input, common, data) { local: "bundles/\\(jdk.*bin.tar.gz\\)", remote: "bundles/openjdk/GPL/profile/linux-x86/\\1", }, - jre: { - local: "bundles/\\(jre.*[0-9]_linux-x86_bin.tar.gz\\)", + jdk_symbols: { + local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)", remote: "bundles/openjdk/GPL/profile/linux-x86/\\1", - },/* The build does not create these + }, + jre: { + // This regexp needs to not match the compact* files below + local: "bundles/\\(jre.*[+][0-9]\\{1,\\}_linux-x86_bin.tar.gz\\)", + remote: "bundles/openjdk/GPL/profile/linux-x86/\\1", + }, jre_compact1: { local: "bundles/\\(jre.*-compact1_linux-x86_bin.tar.gz\\)", remote: "bundles/openjdk/GPL/profile/linux-x86/\\1", @@ -725,7 +731,7 @@ var getJibProfilesProfiles = function (input, common, data) { jre_compact3: { local: "bundles/\\(jre.*-compact3_linux-x86_bin.tar.gz\\)", remote: "bundles/openjdk/GPL/profile/linux-x86/\\1", - },*/ + }, } }, diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 8b1a704ea6d..8c1d4e4f594 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -152,6 +152,9 @@ else JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR) JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER) JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER) + JRE_COMPACT1_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact1 + JRE_COMPACT2_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact2 + JRE_COMPACT3_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact3 ifneq ($(DEBUG_LEVEL), release) JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) @@ -281,6 +284,35 @@ endif ################################################################################ +ifneq ($(filter profiles-bundles, $(MAKECMDGOALS)), ) + ifeq ($(OPENJDK_TARGET_OS), macosx) + $(error Creating compact profiles bundles on macosx is unsupported) + endif + + define GenerateCompactProfilesBundles + ALL_JRE_COMPACT$1_FILES := $$(call CacheFind, $$(JRE_COMPACT$1_IMAGE_DIR)) + + JRE_COMPACT$1_BUNDLE_FILES := $$(filter-out \ + $$(SYMBOLS_EXCLUDE_PATTERN), \ + $$(ALL_JRE_COMPACT$1_FILES)) + + $$(eval $$(call SetupBundleFile, BUILD_JRE_COMPACT$1_BUNDLE, \ + BUNDLE_NAME := $$(JRE_COMPACT$1_BUNDLE_NAME), \ + FILES := $$(JRE_COMPACT$1_BUNDLE_FILES), \ + BASE_DIRS := $$(JRE_COMPACT$1_IMAGE_DIR), \ + SUBDIR := $$(JRE_COMPACT$1_BUNDLE_SUBDIR), \ + )) + + PROFILES_TARGETS += $$(BUILD_JRE_COMPACT$1_BUNDLE) + endef + + $(eval $(call GenerateCompactProfilesBundles,1)) + $(eval $(call GenerateCompactProfilesBundles,2)) + $(eval $(call GenerateCompactProfilesBundles,3)) +endif + +################################################################################ + ifneq ($(filter test-bundles, $(MAKECMDGOALS)), ) TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR)) @@ -316,7 +348,8 @@ $(eval $(call IncludeCustomExtension, , Bundles.gmk)) ################################################################################ product-bundles: $(PRODUCT_TARGETS) +profiles-bundles: $(PROFILES_TARGETS) test-bundles: $(TEST_TARGETS) docs-bundles: $(DOCS_TARGETS) -.PHONY: all default product-bundles test-bundles docs-bundles +.PHONY: all default product-bundles profiles-bundles test-bundles docs-bundles diff --git a/make/Images.gmk b/make/Images.gmk index 1806b9e8696..f2c469f0404 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -147,10 +147,6 @@ $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ --output $(JRE_IMAGE_DIR) $(TOUCH) $@ -JRE_COMPACT1_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact1 -JRE_COMPACT2_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact2 -JRE_COMPACT3_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact3 - $(JRE_COMPACT1_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ $(call DependOnVariable, JRE_COMPACT1_MODULES_LIST) $(BASE_RELEASE_FILE) diff --git a/make/Main.gmk b/make/Main.gmk index 14add7f2046..a94e8ca60b1 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -342,7 +342,7 @@ jre-image: symbols-image: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk symbols) -profiles: +profiles-image: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles) mac-bundles-jdk: @@ -356,7 +356,7 @@ exploded-image-optimize: ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \ zip-source jrtfs-jar jdk-image jre-image \ - symbols-image profiles mac-bundles-jdk \ + symbols-image profiles-image mac-bundles-jdk \ release-file exploded-image-optimize ################################################################################ @@ -510,13 +510,16 @@ ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \ product-bundles: +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles) +profiles-bundles: + +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk profiles-bundles) + test-bundles: +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles) docs-bundles: +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles) -ALL_TARGETS += product-bundles test-bundles docs-bundles +ALL_TARGETS += product-bundles profiles-bundles test-bundles docs-bundles ################################################################################ # Install targets @@ -734,7 +737,7 @@ else jre-image: jmods release-file symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS) - profiles: jmods release-file + profiles-image: jmods release-file mac-bundles-jdk: jdk-image jre-image @@ -793,6 +796,8 @@ else product-bundles: product-images + profiles-bundles: profiles-images + test-bundles: test-image docs-bundles: docs-image @@ -878,6 +883,9 @@ product-images: jdk-image jre-image symbols-image exploded-image # an image until this can be cleaned up properly. product-images: zip-security +# Declare these for backwards compatiblity and convenience. +profiles profiles-images: profiles-image + # The module summary cannot be run when: # * Cross compiling and building a partial BUILDJDK for the build host # * An external buildjdk has been supplied since it may not match the @@ -909,7 +917,9 @@ ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-gensrc gensrc gendata \ copy java rmic libs launchers jmods \ jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples \ exploded-image-base exploded-image \ - create-buildjdk mac-bundles product-images docs-image test-image all-images \ + create-buildjdk mac-bundles product-images \ + profiles profiles-images \ + docs-image test-image all-images \ all-bundles ################################################################################ From 35cbb54ae90a849e3a8d57a080e5217e2d9a34ab Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 10 Jan 2017 11:28:25 +0100 Subject: [PATCH 045/154] 8171932: unresolved macro in javadoc command Reviewed-by: tbell --- make/Javadoc.gmk | 2 +- make/common/MakeBase.gmk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 362352d5b03..00e2db34abd 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -86,7 +86,7 @@ else DRAFT_WINDOW_TITLE_MARKER := $(SPACE)[build $(VERSION_BUILD)] endif EARLYACCESS_TOP := \ -

Please note that the specifications \ diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 681b6d5fb6a..6996ff3712c 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -435,7 +435,7 @@ define NamedParamsMacroTemplate Too many named arguments to macro, please update MAX_PARAMS in MakeBase.gmk)) # Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix $(foreach i,$(PARAM_SEQUENCE), $(if $(strip $($i)),\ - $(strip $1)_$(strip $(call DoubleDollar, $($i))))$(NEWLINE)) + $(strip $1)_$(strip $(call EscapeHash, $(call DoubleDollar, $($i))))$(NEWLINE))) # Debug print all named parameter names and values $(if $(findstring $(LOG_LEVEL),debug trace), \ $(info $0 $(strip $1) $(foreach i,$(PARAM_SEQUENCE), \ From ad37b8fb0f83b5558f424982fd76ab67bf9767c0 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 10 Jan 2017 11:31:31 +0100 Subject: [PATCH 046/154] 8170862: VarDeps breaks when a file with overridden CFLAGS has the same name as the library Reviewed-by: tbell --- make/common/NativeCompilation.gmk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 2d5a39a4589..4b0ce04f1c6 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -288,8 +288,7 @@ define add_native_source $$($1_$(notdir $2)_OPTIMIZATION)), ) $1_$2_VARDEPS := $$($1_$(notdir $2)_CFLAGS) $$($1_$(notdir $2)_CXXFLAGS) \ $$($1_$(notdir $2)_OPT_CFLAGS) $$($1_$(notdir $2)_OPT_CXXFLAGS) - $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \ - $$(patsubst %$(OBJ_SUFFIX),%.vardeps,$$($1_$2_OBJ))) + $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, $$($1_$2_OBJ).vardeps) endif $$($1_$2_OBJ) : $2 $$($1_COMPILE_VARDEPS_FILE) $$($1_$2_VARDEPS_FILE) | $$($1_BUILD_INFO) From b8bdb56985837968a2a04d276e8905294f657e93 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 10 Jan 2017 13:53:44 +0100 Subject: [PATCH 047/154] 8172414: jshell not working in exploded JDK build Using Class.getResourceAsStream instead of a direct reference to JRT. Reviewed-by: rfield, sundar --- .../classes/jdk/internal/jshell/tool/JShellTool.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 6b05457e456..4d80149d421 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 @@ -218,7 +218,7 @@ public class JShellTool implements MessageHandler { static final String DEFAULT_STARTUP_NAME = "DEFAULT"; static final Pattern BUILTIN_FILE_PATTERN = Pattern.compile("\\w+"); - static final String BUILTIN_FILE_PATH_FORMAT = "jrt:/jdk.jshell/jdk/jshell/tool/resources/%s.jsh"; + static final String BUILTIN_FILE_PATH_FORMAT = "/jdk/jshell/tool/resources/%s.jsh"; // match anything followed by whitespace private static final Pattern OPTION_PRE_PATTERN = @@ -2426,9 +2426,11 @@ public class JShellTool implements MessageHandler { String readResource(String name) throws IOException { // Attempt to find the file as a resource String spec = String.format(BUILTIN_FILE_PATH_FORMAT, name); - URL url = new URL(spec); - BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); - return reader.lines().collect(Collectors.joining("\n")); + + try (InputStream in = JShellTool.class.getResourceAsStream(spec); + BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { + return reader.lines().collect(Collectors.joining("\n")); + } } // retrieve the default startup string From 63348f62cff28856b9b2d5e9d98ea944fb57b688 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 10 Jan 2017 18:50:53 +0530 Subject: [PATCH 048/154] 8172493: Nashorn FX example 3-4 using load for fx: scripts fails to run with latest jdk9 ea build Reviewed-by: hannesw, jlaskey --- .../classes/jdk/nashorn/internal/runtime/resources/fx/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js index 7cfed22f57c..366470d787c 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js @@ -108,7 +108,7 @@ function LOAD_FX_CLASSES(global, module) { } }); - Files.walkFileTree(rootDirectories[0], new JRTFSWalker()); + Files.walkFileTree(rootDirectories.toArray()[0], new JRTFSWalker()); })(); LOAD_FX_CLASSES(this, "javafx.base"); From d8842ee65e3b387f398f7dfd3a60cfbe1ede5c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Tue, 10 Jan 2017 15:27:14 +0100 Subject: [PATCH 049/154] 8170781: PropertyMapIterator throws NoSuchElementException on last element Reviewed-by: sundar, attila --- .../nashorn/internal/runtime/PropertyMap.java | 2 +- .../runtime/test/PropertyMapTest.java | 65 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 nashorn/test/src/jdk/nashorn/internal/runtime/test/PropertyMapTest.java diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java index 575e6415f3c..55f2e78db72 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java @@ -1032,7 +1032,7 @@ public class PropertyMap implements Iterable, Serializable { } final Object key = property.getKey(); - property = iter.next(); + property = iter.hasNext() ? iter.next() : null; skipNotEnumerable(); return key; diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/test/PropertyMapTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/PropertyMapTest.java new file mode 100644 index 00000000000..d9bdb837862 --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/PropertyMapTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.runtime.test; + +import java.util.Iterator; +import jdk.nashorn.internal.runtime.PropertyMap; +import jdk.nashorn.internal.runtime.ScriptObject; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Tests for PropertyMap functionality + * + * @test + * @modules jdk.scripting.nashorn/jdk.nashorn.internal.runtime + * @run testng jdk.nashorn.internal.runtime.test.PropertyMapTest + */ +@SuppressWarnings("javadoc") +public class PropertyMapTest { + + @Test + public void propertyMapIteratorTest() { + final ScriptObject scriptObject = new ScriptObject(PropertyMap.newMap()) {}; + Assert.assertFalse(scriptObject.getMap().iterator().hasNext()); + + scriptObject.set("a", "a", 0); + scriptObject.set("b", 3, 0); + // 3 is a valid array key not stored in property map + scriptObject.set(3, 1, 0); + scriptObject.set(6.5, 1.3, 0); + final Iterator iterator = scriptObject.getMap().iterator(); + + Assert.assertTrue(iterator.hasNext()); + Assert.assertEquals(iterator.next(), "a"); + Assert.assertTrue(iterator.hasNext()); + Assert.assertEquals(iterator.next(), "b"); + Assert.assertTrue(iterator.hasNext()); + Assert.assertEquals(iterator.next(), "6.5"); + Assert.assertFalse(iterator.hasNext()); + } + +} From 446836d83118eb24ceb1a2108e855baf720cc246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Tue, 10 Jan 2017 17:52:29 +0100 Subject: [PATCH 050/154] 8166187: Regression: NPE during reparse when using persistent code cache and optimistic types Reviewed-by: jlaskey, attila --- .../RecompilableScriptFunctionData.java | 27 +- .../runtime/test/CodeStoreAndPathTest.java | 329 +++++++++++++++++- 2 files changed, 347 insertions(+), 9 deletions(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java index d59b20aaa94..e294f8c6917 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -28,6 +28,8 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.lookup.Lookup.MH; import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -100,7 +102,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp * reparsed from source, or a soft reference to a {@code FunctionNode} for other functions (it is safe * to be cleared as they can be reparsed). */ - private volatile Object cachedAst; + private volatile transient Object cachedAst; /** Token of this function within the source. */ private final long token; @@ -289,6 +291,9 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp if (this.source == null && this.installer == null) { this.source = src; this.installer = inst; + for (final RecompilableScriptFunctionData nested : nestedFunctions.values()) { + nested.initTransients(src, inst); + } } else if (this.source != src || !this.installer.isCompatibleWith(inst)) { // Existing values must be same as those passed as parameters throw new IllegalArgumentException(); @@ -424,7 +429,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp } else if (lCachedAst instanceof SerializedAst) { final SerializedAst serializedAst = (SerializedAst)lCachedAst; // Even so, are we also softly caching the AST? - final FunctionNode cachedFn = serializedAst.cachedAst.get(); + final FunctionNode cachedFn = serializedAst.cachedAst == null ? null : serializedAst.cachedAst.get(); if (cachedFn != null) { // Yes we are - this is fast return cloneSymbols(cachedFn); @@ -492,9 +497,11 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp * we're using this tuple instead to also keep a deserialized AST around in memory to cut down on * deserialization costs. */ - private static class SerializedAst { + private static class SerializedAst implements Serializable { private final byte[] serializedAst; - private volatile Reference cachedAst; + private volatile transient Reference cachedAst; + + private static final long serialVersionUID = 1L; SerializedAst(final FunctionNode fn, final Reference cachedAst) { this.serializedAst = AstSerializer.serialize(fn); @@ -1038,8 +1045,20 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp return true; } + private void writeObject(final ObjectOutputStream out) throws IOException { + final Object localCachedAst = cachedAst; + out.defaultWriteObject(); + // We need to persist SerializedAst for split functions as they can't reparse the source code. + if (localCachedAst instanceof SerializedAst) { + out.writeObject(localCachedAst); + } else { + out.writeObject(null); + } + } + private void readObject(final java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); + cachedAst = in.readObject(); createLogger(); } diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java index 4b8944099a9..4167967c7c8 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java @@ -47,7 +47,7 @@ import org.testng.annotations.Test; @SuppressWarnings("javadoc") public class CodeStoreAndPathTest { - final String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; " + final static String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; " + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; " + "var x4 = 'Hello Script'; var x5 = 'Hello Script';" + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; " @@ -69,7 +69,7 @@ public class CodeStoreAndPathTest { + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';" + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; " + "var x10 = 'Hello Script';}"; - final String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; " + final static String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; " + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; " + "var x4 = 'Hello Script'; var x5 = 'Hello Script';" + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; " @@ -92,9 +92,306 @@ public class CodeStoreAndPathTest { + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; " + "var x10 = 'Hello Script';}"; // Script size < Default minimum size for storing a compiled script class - final String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; "; - final String codeCache = "build/nashorn_code_cache"; - final String oldUserDir = System.getProperty("user.dir"); + final static String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; "; + final static String nestedFunctions = "\n" + + "(function outer() { \n" + + " var map = null; \n" + + " (function inner() { \n" + + " var object; \n" + + " if (map === null) { \n" + + " map = (function() { \n" + + " var HashMap = Java.type('java.util.HashMap'); \n" + + " map = new HashMap(); \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " return map; \n" + + " }()); \n" + + " } \n" + + " object = {}; \n" + + " return object; \n" + + " })(); \n" + + "}()); "; + final static String longNestedFunctions = "\n" + + "(function outer() { \n" + + " var map = null; \n" + + " (function inner() { \n" + + " var object; \n" + + " var HashMap = Java.type('java.util.HashMap'); \n" + + " map = new HashMap(); \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address';\n" + + " map.name = 'name'; \n" + + " map.id = 1234;\n" + + " map.basePath = 'basePath'; \n" + + " map.extensionPath = 'extension';\n" + + " map.address = 'address'; \n" + + " object = {}; \n" + + " return object; \n" + + " })(); \n" + + "}()); "; + final static String codeCache = "build/nashorn_code_cache"; + final static String oldUserDir = System.getProperty("user.dir"); private static final String[] ENGINE_OPTIONS_OPT = new String[]{"--persistent-code-cache", "--optimistic-types=true"}; private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"}; @@ -166,6 +463,28 @@ public class CodeStoreAndPathTest { checkCompiledScripts(stream, 4); } + @Test + public void testNestedFunctionStore() throws ScriptException, IOException { + System.setProperty("nashorn.persistent.code.cache", codeCache); + final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(nestedFunctions); + } + + @Test + public void testSplitFunctionStore() throws ScriptException, IOException { + System.setProperty("nashorn.persistent.code.cache", codeCache); + System.setProperty("nashorn.compiler.splitter.threshold", "500"); + final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions); + factory.getScriptEngine(ENGINE_OPTIONS_OPT).eval(longNestedFunctions); + System.getProperties().remove("nashorn.compiler.splitter.threshold"); + } + private static Path getCodeCachePath(final boolean optimistic) { final String codeCache = System.getProperty("nashorn.persistent.code.cache"); final Path codeCachePath = FileSystems.getDefault().getPath(codeCache).toAbsolutePath(); From 247b26d50897f89ecd9cf19928aeb26d3858cda6 Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Tue, 10 Jan 2017 22:15:54 +0300 Subject: [PATCH 051/154] 8159058: SAXParseException when sending soap message Reviewed-by: lancea --- .../messaging/saaj/soap/impl/DetailImpl.java | 30 +- .../messaging/saaj/soap/impl/ElementImpl.java | 33 +- .../saaj/util/stax/SaajStaxWriter.java | 310 ++++++++++++++--- .../ws/api/message/saaj/SaajStaxWriter.java | 314 +++++++++++++++--- 4 files changed, 555 insertions(+), 132 deletions(-) diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java index 047d3be90b3..36291b975b5 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,13 +47,13 @@ public abstract class DetailImpl extends FaultElementImpl implements Detail { public DetailEntry addDetailEntry(Name name) throws SOAPException { DetailEntry entry = createDetailEntry(name); addNode(entry); - return (DetailEntry) circumventBug5034339(entry); + return entry; } public DetailEntry addDetailEntry(QName qname) throws SOAPException { DetailEntry entry = createDetailEntry(qname); addNode(entry); - return (DetailEntry) circumventBug5034339(entry); + return entry; } protected SOAPElement addElement(Name name) throws SOAPException { @@ -119,28 +119,4 @@ public abstract class DetailImpl extends FaultElementImpl implements Detail { return true; } - //overriding this method since the only two uses of this method - // are in ElementImpl and DetailImpl - //whereas the original base impl does the correct job for calls to it inside ElementImpl - // But it would not work for DetailImpl. - protected SOAPElement circumventBug5034339(SOAPElement element) { - - Name elementName = element.getElementName(); - if (!isNamespaceQualified(elementName)) { - String prefix = elementName.getPrefix(); - String defaultNamespace = getNamespaceURI(prefix); - if (defaultNamespace != null) { - Name newElementName = - NameImpl.create( - elementName.getLocalName(), - elementName.getPrefix(), - defaultNamespace); - SOAPElement newElement = createDetailEntry(newElementName); - replaceChild(newElement, element); - return newElement; - } - } - return element; - } - } diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java index 5189dd802bd..10070cc7aa6 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,8 +127,11 @@ public class ElementImpl } public SOAPElement addChildElement(String localName) throws SOAPException { - return (SOAPElement) addChildElement( - NameImpl.createFromUnqualifiedName(localName)); + String nsUri = getNamespaceURI(""); + Name name = (nsUri == null || nsUri.isEmpty()) + ? NameImpl.createFromUnqualifiedName(localName) + : NameImpl.createFromQualifiedName(localName, nsUri); + return addChildElement(name); } public SOAPElement addChildElement(String localName, String prefix) @@ -372,13 +375,13 @@ public class ElementImpl protected SOAPElement addElement(Name name) throws SOAPException { SOAPElement newElement = createElement(name); addNode(newElement); - return circumventBug5034339(newElement); + return newElement; } protected SOAPElement addElement(QName name) throws SOAPException { SOAPElement newElement = createElement(name); addNode(newElement); - return circumventBug5034339(newElement); + return newElement; } protected SOAPElement createElement(Name name) { @@ -1226,26 +1229,6 @@ public class ElementImpl return !"".equals(name.getNamespaceURI()); } - protected SOAPElement circumventBug5034339(SOAPElement element) { - - Name elementName = element.getElementName(); - if (!isNamespaceQualified(elementName)) { - String prefix = elementName.getPrefix(); - String defaultNamespace = getNamespaceURI(prefix); - if (defaultNamespace != null) { - Name newElementName = - NameImpl.create( - elementName.getLocalName(), - elementName.getPrefix(), - defaultNamespace); - SOAPElement newElement = createElement(newElementName); - replaceChild(newElement, element); - return newElement; - } - } - return element; - } - //TODO: This is a temporary SAAJ workaround for optimizing XWS // should be removed once the corresponding JAXP bug is fixed // It appears the bug will be fixed in JAXP 1.4 (not by Appserver 9 timeframe) diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java index 7166afd1e1c..a53cb79a7a1 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,10 @@ package com.sun.xml.internal.messaging.saaj.util.stax; -import java.util.Arrays; import java.util.Iterator; +import java.util.Arrays; +import java.util.List; +import java.util.LinkedList; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; @@ -42,6 +44,17 @@ import org.w3c.dom.Node; /** * SaajStaxWriter builds a SAAJ SOAPMessage by using XMLStreamWriter interface. * + *

+ * Defers creation of SOAPElement until all the aspects of the name of the element are known. + * In some cases, the namespace uri is indicated only by the {@link #writeNamespace(String, String)} call. + * After opening an element ({@code writeStartElement}, {@code writeEmptyElement} methods), all attributes + * and namespace assignments are retained within {@link DeferredElement} object ({@code deferredElement} field). + * As soon as any other method than {@code writeAttribute}, {@code writeNamespace}, {@code writeDefaultNamespace} + * or {@code setNamespace} is called, the contents of {@code deferredElement} is transformed into new SOAPElement + * (which is appropriately inserted into the SOAPMessage under construction). + * This mechanism is necessary to fix JDK-8159058 issue. + *

+ * * @author shih-chang.chen@oracle.com */ public class SaajStaxWriter implements XMLStreamWriter { @@ -49,6 +62,7 @@ public class SaajStaxWriter implements XMLStreamWriter { protected SOAPMessage soap; protected String envURI; protected SOAPElement currentElement; + protected DeferredElement deferredElement; static final protected String Envelope = "Envelope"; static final protected String Header = "Header"; @@ -58,6 +72,7 @@ public class SaajStaxWriter implements XMLStreamWriter { public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException { soap = msg; this.envURI = uri; + this.deferredElement = new DeferredElement(); } public SOAPMessage getSOAPMessage() { @@ -70,11 +85,8 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeStartElement(final String localName) throws XMLStreamException { - try { - currentElement = currentElement.addChildElement(localName); - } catch (SOAPException e) { - throw new XMLStreamException(e); - } + currentElement = deferredElement.flushTo(currentElement); + deferredElement.setLocalName(localName); } @Override @@ -84,8 +96,10 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeStartElement(final String prefix, final String ln, final String ns) throws XMLStreamException { - try { - if (envURI.equals(ns)) { + currentElement = deferredElement.flushTo(currentElement); + + if (envURI.equals(ns)) { + try { if (Envelope.equals(ln)) { currentElement = getEnvelope(); fixPrefix(prefix); @@ -99,13 +113,16 @@ public class SaajStaxWriter implements XMLStreamWriter { fixPrefix(prefix); return; } + } catch (SOAPException e) { + throw new XMLStreamException(e); } - currentElement = (prefix == null) ? - currentElement.addChildElement(new QName(ns, ln)) : - currentElement.addChildElement(ln, prefix, ns); - } catch (SOAPException e) { - throw new XMLStreamException(e); + } + + deferredElement.setLocalName(ln); + deferredElement.setNamespaceUri(ns); + deferredElement.setPrefix(prefix); + } private void fixPrefix(final String prfx) throws XMLStreamException { @@ -136,11 +153,13 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeEndElement() throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); if (currentElement != null) currentElement = currentElement.getParentElement(); } @Override public void writeEndDocument() throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); } @Override @@ -158,19 +177,14 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException { - try { - if (ns == null) { - if (prefix == null && xmlns.equals(ln)) { - currentElement.addNamespaceDeclaration("", value); - } else { - currentElement.setAttributeNS("", ln, value); - } + if (ns == null && prefix == null && xmlns.equals(ln)) { + writeNamespace("", value); + } else { + if (deferredElement.isInitialized()) { + deferredElement.addAttribute(prefix, ns, ln, value); } else { - QName name = (prefix == null) ? new QName(ns, ln) : new QName(ns, ln, prefix); - currentElement.addAttribute(name, value); + addAttibuteToElement(currentElement, prefix, ns, ln, value); } - } catch (SOAPException e) { - throw new XMLStreamException(e); } } @@ -181,16 +195,16 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeNamespace(String prefix, final String uri) throws XMLStreamException { - // make prefix default if null or "xmlns" (according to javadoc) - if (prefix == null || "xmlns".equals(prefix)) { - prefix = ""; - } - - try { - currentElement.addNamespaceDeclaration(prefix, uri); - } catch (SOAPException e) { - throw new XMLStreamException(e); + String thePrefix = prefix == null || "xmlns".equals(prefix) ? "" : prefix; + if (deferredElement.isInitialized()) { + deferredElement.addNamespaceDeclaration(thePrefix, uri); + } else { + try { + currentElement.addNamespaceDeclaration(thePrefix, uri); + } catch (SOAPException e) { + throw new XMLStreamException(e); + } } } @@ -201,35 +215,40 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeComment(final String data) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Comment c = soap.getSOAPPart().createComment(data); currentElement.appendChild(c); } @Override public void writeProcessingInstruction(final String target) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createProcessingInstruction(target, ""); currentElement.appendChild(n); } @Override public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createProcessingInstruction(target, data); currentElement.appendChild(n); } @Override public void writeCData(final String data) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createCDATASection(data); currentElement.appendChild(n); } @Override public void writeDTD(final String dtd) throws XMLStreamException { - //TODO ... Don't do anything here + currentElement = deferredElement.flushTo(currentElement); } @Override public void writeEntityRef(final String name) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createEntityReference(name); currentElement.appendChild(n); } @@ -257,6 +276,7 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeCharacters(final String text) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); try { currentElement.addTextNode(text); } catch (SOAPException e) { @@ -266,6 +286,7 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeCharacters(final char[] text, final int start, final int len) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); char[] chr = (start == 0 && len == text.length) ? text : Arrays.copyOfRange(text, start, start + len); try { currentElement.addTextNode(new String(chr)); @@ -281,10 +302,16 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void setPrefix(final String prefix, final String uri) throws XMLStreamException { - try { - this.currentElement.addNamespaceDeclaration(prefix, uri); - } catch (SOAPException e) { - throw new XMLStreamException(e); + // TODO: this in fact is not what would be expected from XMLStreamWriter + // (e.g. XMLStreamWriter for writing to output stream does not write anything as result of + // this method, it just rememebers that given prefix is associated with the given uri + // for the scope; to actually declare the prefix assignment in the resulting XML, one + // needs to call writeNamespace(...) method + // Kept for backwards compatibility reasons - this might be worth of further investigation. + if (deferredElement.isInitialized()) { + deferredElement.addNamespaceDeclaration(prefix, uri); + } else { + throw new XMLStreamException("Namespace not associated with any element"); } } @@ -331,4 +358,209 @@ public class SaajStaxWriter implements XMLStreamWriter { } }; } + + static void addAttibuteToElement(SOAPElement element, String prefix, String ns, String ln, String value) + throws XMLStreamException { + try { + if (ns == null) { + element.setAttributeNS("", ln, value); + } else { + QName name = prefix == null ? new QName(ns, ln) : new QName(ns, ln, prefix); + element.addAttribute(name, value); + } + } catch (SOAPException e) { + throw new XMLStreamException(e); + } + } + + /** + * Holds details of element that needs to be deferred in order to manage namespace assignments correctly. + * + *

+ * An instance of can be set with all the aspects of the element name (local name, prefix, namespace uri). + * Attributes and namespace declarations (special case of attribute) can be added. + * Namespace declarations are handled so that the element namespace is updated if it is implied by the namespace + * declaration and the namespace was not set to non-{@code null} value previously. + *

+ * + *

+ * The state of this object can be {@link #flushTo(SOAPElement) flushed} to SOAPElement - new SOAPElement will + * be added a child element; the new element will have exactly the shape as represented by the state of this + * object. Note that the {@link #flushTo(SOAPElement)} method does nothing + * (and returns the argument immediately) if the state of this object is not initialized + * (i.e. local name is null). + *

+ * + * @author ondrej.cerny@oracle.com + */ + static class DeferredElement { + private String prefix; + private String localName; + private String namespaceUri; + private final List namespaceDeclarations; + private final List attributeDeclarations; + + DeferredElement() { + this.namespaceDeclarations = new LinkedList(); + this.attributeDeclarations = new LinkedList(); + reset(); + } + + + /** + * Set prefix of the element. + * @param prefix namespace prefix + */ + public void setPrefix(final String prefix) { + this.prefix = prefix; + } + + /** + * Set local name of the element. + * + *

+ * This method initializes the element. + *

+ * + * @param localName local name {@code not null} + */ + public void setLocalName(final String localName) { + if (localName == null) { + throw new IllegalArgumentException("localName can not be null"); + } + this.localName = localName; + } + + /** + * Set namespace uri. + * + * @param namespaceUri namespace uri + */ + public void setNamespaceUri(final String namespaceUri) { + this.namespaceUri = namespaceUri; + } + + /** + * Adds namespace prefix assignment to the element. + * + * @param prefix prefix (not {@code null}) + * @param namespaceUri namespace uri + */ + public void addNamespaceDeclaration(final String prefix, final String namespaceUri) { + if (null == this.namespaceUri && null != namespaceUri && prefix.equals(emptyIfNull(this.prefix))) { + this.namespaceUri = namespaceUri; + } + this.namespaceDeclarations.add(new NamespaceDeclaration(prefix, namespaceUri)); + } + + /** + * Adds attribute to the element. + * @param prefix prefix + * @param ns namespace + * @param ln local name + * @param value value + */ + public void addAttribute(final String prefix, final String ns, final String ln, final String value) { + if (ns == null && prefix == null && xmlns.equals(ln)) { + this.addNamespaceDeclaration(prefix, value); + } else { + this.attributeDeclarations.add(new AttributeDeclaration(prefix, ns, ln, value)); + } + } + + /** + * Flushes state of this element to the {@code target} element. + * + *

+ * If this element is initialized then it is added with all the namespace declarations and attributes + * to the {@code target} element as a child. The state of this element is reset to uninitialized. + * The newly added element object is returned. + *

+ *

+ * If this element is not initialized then the {@code target} is returned immediately, nothing else is done. + *

+ * + * @param target target element + * @return {@code target} or new element + * @throws XMLStreamException on error + */ + public SOAPElement flushTo(final SOAPElement target) throws XMLStreamException { + try { + if (this.localName != null) { + // add the element appropriately (based on namespace declaration) + final SOAPElement newElement; + if (this.namespaceUri == null) { + // add element with inherited scope + newElement = target.addChildElement(this.localName); + } else if (prefix == null) { + newElement = target.addChildElement(new QName(this.namespaceUri, this.localName)); + } else { + newElement = target.addChildElement(this.localName, this.prefix, this.namespaceUri); + } + // add namespace declarations + for (NamespaceDeclaration namespace : this.namespaceDeclarations) { + target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri); + } + // add attribute declarations + for (AttributeDeclaration attribute : this.attributeDeclarations) { + addAttibuteToElement(newElement, + attribute.prefix, attribute.namespaceUri, attribute.localName, attribute.value); + } + // reset state + this.reset(); + + return newElement; + } else { + return target; + } + // else after reset state -> not initialized + } catch (SOAPException e) { + throw new XMLStreamException(e); + } + } + + /** + * Is the element initialized? + * @return boolean indicating whether it was initialized after last flush + */ + public boolean isInitialized() { + return this.localName != null; + } + + private void reset() { + this.localName = null; + this.prefix = null; + this.namespaceUri = null; + this.namespaceDeclarations.clear(); + this.attributeDeclarations.clear(); + } + + private static String emptyIfNull(String s) { + return s == null ? "" : s; + } + } + + static class NamespaceDeclaration { + final String prefix; + final String namespaceUri; + + NamespaceDeclaration(String prefix, String namespaceUri) { + this.prefix = prefix; + this.namespaceUri = namespaceUri; + } + } + + static class AttributeDeclaration { + final String prefix; + final String namespaceUri; + final String localName; + final String value; + + AttributeDeclaration(String prefix, String namespaceUri, String localName, String value) { + this.prefix = prefix; + this.namespaceUri = namespaceUri; + this.localName = localName; + this.value = value; + } + } } diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java index 9b743e20c59..37a42e75c53 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,10 @@ package com.sun.xml.internal.ws.api.message.saaj; -import java.util.Arrays; import java.util.Iterator; +import java.util.Arrays; +import java.util.List; +import java.util.LinkedList; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; @@ -42,6 +44,17 @@ import org.w3c.dom.Node; /** * SaajStaxWriter builds a SAAJ SOAPMessage by using XMLStreamWriter interface. * + *

+ * Defers creation of SOAPElement until all the aspects of the name of the element are known. + * In some cases, the namespace uri is indicated only by the {@link #writeNamespace(String, String)} call. + * After opening an element ({@code writeStartElement}, {@code writeEmptyElement} methods), all attributes + * and namespace assignments are retained within {@link DeferredElement} object ({@code deferredElement} field). + * As soon as any other method than {@code writeAttribute}, {@code writeNamespace}, {@code writeDefaultNamespace} + * or {@code setNamespace} is called, the contents of {@code deferredElement} is transformed into new SOAPElement + * (which is appropriately inserted into the SOAPMessage under construction). + * This mechanism is necessary to fix JDK-8159058 issue. + *

+ * * @author shih-chang.chen@oracle.com */ public class SaajStaxWriter implements XMLStreamWriter { @@ -49,6 +62,7 @@ public class SaajStaxWriter implements XMLStreamWriter { protected SOAPMessage soap; protected String envURI; protected SOAPElement currentElement; + protected DeferredElement deferredElement; static final protected String Envelope = "Envelope"; static final protected String Header = "Header"; @@ -58,6 +72,7 @@ public class SaajStaxWriter implements XMLStreamWriter { public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException { soap = msg; this.envURI = uri; + this.deferredElement = new DeferredElement(); } public SOAPMessage getSOAPMessage() { @@ -70,11 +85,8 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeStartElement(final String localName) throws XMLStreamException { - try { - currentElement = currentElement.addChildElement(localName); - } catch (SOAPException e) { - throw new XMLStreamException(e); - } + currentElement = deferredElement.flushTo(currentElement); + deferredElement.setLocalName(localName); } @Override @@ -84,8 +96,10 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeStartElement(final String prefix, final String ln, final String ns) throws XMLStreamException { - try { - if (envURI.equals(ns)) { + currentElement = deferredElement.flushTo(currentElement); + + if (envURI.equals(ns)) { + try { if (Envelope.equals(ln)) { currentElement = getEnvelope(); fixPrefix(prefix); @@ -99,13 +113,16 @@ public class SaajStaxWriter implements XMLStreamWriter { fixPrefix(prefix); return; } + } catch (SOAPException e) { + throw new XMLStreamException(e); } - currentElement = (prefix == null) ? - currentElement.addChildElement(new QName(ns, ln)) : - currentElement.addChildElement(ln, prefix, ns); - } catch (SOAPException e) { - throw new XMLStreamException(e); + } + + deferredElement.setLocalName(ln); + deferredElement.setNamespaceUri(ns); + deferredElement.setPrefix(prefix); + } private void fixPrefix(final String prfx) throws XMLStreamException { @@ -136,11 +153,13 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeEndElement() throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); if (currentElement != null) currentElement = currentElement.getParentElement(); } @Override public void writeEndDocument() throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); } @Override @@ -158,19 +177,14 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException { - try { - if (ns == null) { - if (prefix == null && xmlns.equals(ln)) { - currentElement.addNamespaceDeclaration("", value); - } else { - currentElement.setAttributeNS("", ln, value); - } + if (ns == null && prefix == null && xmlns.equals(ln)) { + writeNamespace("", value); + } else { + if (deferredElement.isInitialized()) { + deferredElement.addAttribute(prefix, ns, ln, value); } else { - QName name = (prefix == null) ? new QName(ns, ln) : new QName(ns, ln, prefix); - currentElement.addAttribute(name, value); + addAttibuteToElement(currentElement, prefix, ns, ln, value); } - } catch (SOAPException e) { - throw new XMLStreamException(e); } } @@ -181,16 +195,16 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeNamespace(String prefix, final String uri) throws XMLStreamException { - // make prefix default if null or "xmlns" (according to javadoc) - if (prefix == null || "xmlns".equals(prefix)) { - prefix = ""; - } - - try { - currentElement.addNamespaceDeclaration(prefix, uri); - } catch (SOAPException e) { - throw new XMLStreamException(e); + String thePrefix = prefix == null || "xmlns".equals(prefix) ? "" : prefix; + if (deferredElement.isInitialized()) { + deferredElement.addNamespaceDeclaration(thePrefix, uri); + } else { + try { + currentElement.addNamespaceDeclaration(thePrefix, uri); + } catch (SOAPException e) { + throw new XMLStreamException(e); + } } } @@ -201,35 +215,40 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeComment(final String data) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Comment c = soap.getSOAPPart().createComment(data); currentElement.appendChild(c); } @Override public void writeProcessingInstruction(final String target) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createProcessingInstruction(target, ""); currentElement.appendChild(n); } @Override public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createProcessingInstruction(target, data); currentElement.appendChild(n); } @Override public void writeCData(final String data) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createCDATASection(data); currentElement.appendChild(n); } @Override public void writeDTD(final String dtd) throws XMLStreamException { - //TODO ... Don't do anything here + currentElement = deferredElement.flushTo(currentElement); } @Override public void writeEntityRef(final String name) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); Node n = soap.getSOAPPart().createEntityReference(name); currentElement.appendChild(n); } @@ -257,6 +276,7 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeCharacters(final String text) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); try { currentElement.addTextNode(text); } catch (SOAPException e) { @@ -266,6 +286,7 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void writeCharacters(final char[] text, final int start, final int len) throws XMLStreamException { + currentElement = deferredElement.flushTo(currentElement); char[] chr = (start == 0 && len == text.length) ? text : Arrays.copyOfRange(text, start, start + len); try { currentElement.addTextNode(new String(chr)); @@ -281,10 +302,16 @@ public class SaajStaxWriter implements XMLStreamWriter { @Override public void setPrefix(final String prefix, final String uri) throws XMLStreamException { - try { - this.currentElement.addNamespaceDeclaration(prefix, uri); - } catch (SOAPException e) { - throw new XMLStreamException(e); + // TODO: this in fact is not what would be expected from XMLStreamWriter + // (e.g. XMLStreamWriter for writing to output stream does not write anything as result of + // this method, it just rememebers that given prefix is associated with the given uri + // for the scope; to actually declare the prefix assignment in the resulting XML, one + // needs to call writeNamespace(...) method + // Kept for backwards compatibility reasons - this might be worth of further investigation. + if (deferredElement.isInitialized()) { + deferredElement.addNamespaceDeclaration(prefix, uri); + } else { + throw new XMLStreamException("Namespace not associated with any element"); } } @@ -315,12 +342,12 @@ public class SaajStaxWriter implements XMLStreamWriter { return currentElement.lookupPrefix(namespaceURI); } public Iterator getPrefixes(final String namespaceURI) { - return new Iterator() { + return new Iterator() { String prefix = getPrefix(namespaceURI); public boolean hasNext() { return (prefix != null); } - public Object next() { + public String next() { if (!hasNext()) throw new java.util.NoSuchElementException(); String next = prefix; prefix = null; @@ -331,4 +358,209 @@ public class SaajStaxWriter implements XMLStreamWriter { } }; } + + static void addAttibuteToElement(SOAPElement element, String prefix, String ns, String ln, String value) + throws XMLStreamException { + try { + if (ns == null) { + element.setAttributeNS("", ln, value); + } else { + QName name = prefix == null ? new QName(ns, ln) : new QName(ns, ln, prefix); + element.addAttribute(name, value); + } + } catch (SOAPException e) { + throw new XMLStreamException(e); + } + } + + /** + * Holds details of element that needs to be deferred in order to manage namespace assignments correctly. + * + *

+ * An instance of can be set with all the aspects of the element name (local name, prefix, namespace uri). + * Attributes and namespace declarations (special case of attribute) can be added. + * Namespace declarations are handled so that the element namespace is updated if it is implied by the namespace + * declaration and the namespace was not set to non-{@code null} value previously. + *

+ * + *

+ * The state of this object can be {@link #flushTo(SOAPElement) flushed} to SOAPElement - new SOAPElement will + * be added a child element; the new element will have exactly the shape as represented by the state of this + * object. Note that the {@link #flushTo(SOAPElement)} method does nothing + * (and returns the argument immediately) if the state of this object is not initialized + * (i.e. local name is null). + *

+ * + * @author ondrej.cerny@oracle.com + */ + static class DeferredElement { + private String prefix; + private String localName; + private String namespaceUri; + private final List namespaceDeclarations; + private final List attributeDeclarations; + + DeferredElement() { + this.namespaceDeclarations = new LinkedList(); + this.attributeDeclarations = new LinkedList(); + reset(); + } + + + /** + * Set prefix of the element. + * @param prefix namespace prefix + */ + public void setPrefix(final String prefix) { + this.prefix = prefix; + } + + /** + * Set local name of the element. + * + *

+ * This method initializes the element. + *

+ * + * @param localName local name {@code not null} + */ + public void setLocalName(final String localName) { + if (localName == null) { + throw new IllegalArgumentException("localName can not be null"); + } + this.localName = localName; + } + + /** + * Set namespace uri. + * + * @param namespaceUri namespace uri + */ + public void setNamespaceUri(final String namespaceUri) { + this.namespaceUri = namespaceUri; + } + + /** + * Adds namespace prefix assignment to the element. + * + * @param prefix prefix (not {@code null}) + * @param namespaceUri namespace uri + */ + public void addNamespaceDeclaration(final String prefix, final String namespaceUri) { + if (null == this.namespaceUri && null != namespaceUri && prefix.equals(emptyIfNull(this.prefix))) { + this.namespaceUri = namespaceUri; + } + this.namespaceDeclarations.add(new NamespaceDeclaration(prefix, namespaceUri)); + } + + /** + * Adds attribute to the element. + * @param prefix prefix + * @param ns namespace + * @param ln local name + * @param value value + */ + public void addAttribute(final String prefix, final String ns, final String ln, final String value) { + if (ns == null && prefix == null && xmlns.equals(ln)) { + this.addNamespaceDeclaration(prefix, value); + } else { + this.attributeDeclarations.add(new AttributeDeclaration(prefix, ns, ln, value)); + } + } + + /** + * Flushes state of this element to the {@code target} element. + * + *

+ * If this element is initialized then it is added with all the namespace declarations and attributes + * to the {@code target} element as a child. The state of this element is reset to uninitialized. + * The newly added element object is returned. + *

+ *

+ * If this element is not initialized then the {@code target} is returned immediately, nothing else is done. + *

+ * + * @param target target element + * @return {@code target} or new element + * @throws XMLStreamException on error + */ + public SOAPElement flushTo(final SOAPElement target) throws XMLStreamException { + try { + if (this.localName != null) { + // add the element appropriately (based on namespace declaration) + final SOAPElement newElement; + if (this.namespaceUri == null) { + // add element with inherited scope + newElement = target.addChildElement(this.localName); + } else if (prefix == null) { + newElement = target.addChildElement(new QName(this.namespaceUri, this.localName)); + } else { + newElement = target.addChildElement(this.localName, this.prefix, this.namespaceUri); + } + // add namespace declarations + for (NamespaceDeclaration namespace : this.namespaceDeclarations) { + target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri); + } + // add attribute declarations + for (AttributeDeclaration attribute : this.attributeDeclarations) { + addAttibuteToElement(newElement, + attribute.prefix, attribute.namespaceUri, attribute.localName, attribute.value); + } + // reset state + this.reset(); + + return newElement; + } else { + return target; + } + // else after reset state -> not initialized + } catch (SOAPException e) { + throw new XMLStreamException(e); + } + } + + /** + * Is the element initialized? + * @return boolean indicating whether it was initialized after last flush + */ + public boolean isInitialized() { + return this.localName != null; + } + + private void reset() { + this.localName = null; + this.prefix = null; + this.namespaceUri = null; + this.namespaceDeclarations.clear(); + this.attributeDeclarations.clear(); + } + + private static String emptyIfNull(String s) { + return s == null ? "" : s; + } + } + + static class NamespaceDeclaration { + final String prefix; + final String namespaceUri; + + NamespaceDeclaration(String prefix, String namespaceUri) { + this.prefix = prefix; + this.namespaceUri = namespaceUri; + } + } + + static class AttributeDeclaration { + final String prefix; + final String namespaceUri; + final String localName; + final String value; + + AttributeDeclaration(String prefix, String namespaceUri, String localName, String value) { + this.prefix = prefix; + this.namespaceUri = namespaceUri; + this.localName = localName; + this.value = value; + } + } } From 6c4a68975039d28ac0f775d10889afa7b5f5a3db Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Tue, 10 Jan 2017 11:31:59 -0800 Subject: [PATCH 052/154] 8171332: NPE in MembersPhase.finishClass Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/TypeEnter.java | 3 ++- .../test/tools/javac/T8171332/Buggy.java | 24 +++++++++++++++++++ .../test/tools/javac/T8171332/Processor.java | 21 ++++++++++++++++ .../test/tools/javac/T8171332/Processor.out | 3 +++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/T8171332/Buggy.java create mode 100644 langtools/test/tools/javac/T8171332/Processor.java create mode 100644 langtools/test/tools/javac/T8171332/Processor.out diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java index 53ba2984b7e..e4b07dde33b 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -938,6 +938,7 @@ public class TypeEnter implements Completer { */ void finishClass(JCClassDecl tree, Env env) { if ((tree.mods.flags & Flags.ENUM) != 0 && + !tree.sym.type.hasTag(ERROR) && (types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) { addEnumMembers(tree, env); } diff --git a/langtools/test/tools/javac/T8171332/Buggy.java b/langtools/test/tools/javac/T8171332/Buggy.java new file mode 100644 index 00000000000..229a3894c74 --- /dev/null +++ b/langtools/test/tools/javac/T8171332/Buggy.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +@Deprecated enum Buggy implements Buggy {} diff --git a/langtools/test/tools/javac/T8171332/Processor.java b/langtools/test/tools/javac/T8171332/Processor.java new file mode 100644 index 00000000000..d4b8046c834 --- /dev/null +++ b/langtools/test/tools/javac/T8171332/Processor.java @@ -0,0 +1,21 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8171332 + * @summary 8171332: NPE in MembersPhase.finishClass + * @modules java.compiler + * jdk.compiler + * @build Processor + * @compile/fail/ref=Processor.out -XDrawDiagnostics -processor Processor Buggy.java + */ + +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.element.TypeElement; + +@SupportedAnnotationTypes("*") +public class Processor extends AbstractProcessor { + @Override + public boolean process(Set set, RoundEnvironment roundEnvironment) { + return false; + } +} diff --git a/langtools/test/tools/javac/T8171332/Processor.out b/langtools/test/tools/javac/T8171332/Processor.out new file mode 100644 index 00000000000..ca27516c7d1 --- /dev/null +++ b/langtools/test/tools/javac/T8171332/Processor.out @@ -0,0 +1,3 @@ +Buggy.java:24:35: compiler.err.intf.expected.here +Buggy.java:24:13: compiler.err.cyclic.inheritance: Buggy +2 errors From c2d9172419338a667e581751eacf9e4dcdb06d78 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 11 Jan 2017 10:59:57 +0100 Subject: [PATCH 053/154] 8169197: Improve error reporting for compiling against unexported package When a type cannot be found, look into other modules, search for possible viable types, and report them conveniently to the user. Reviewed-by: mcimadamore, jjg --- .../com/sun/tools/javac/code/Symbol.java | 1 + .../com/sun/tools/javac/comp/Attr.java | 2 +- .../com/sun/tools/javac/comp/Modules.java | 1 + .../com/sun/tools/javac/comp/Resolve.java | 232 +++++++- .../com/sun/tools/javac/comp/TypeEnter.java | 2 +- .../tools/javac/resources/compiler.properties | 78 ++- .../test/tools/javac/T5003235/T5003235a.java | 2 +- .../test/tools/javac/T5003235/T5003235a.out | 16 +- .../test/tools/javac/T5003235/T5003235b.java | 2 +- .../test/tools/javac/T5003235/T5003235b.out | 16 +- langtools/test/tools/javac/diags/Example.java | 46 +- .../test/tools/javac/diags/RunExamples.java | 4 +- .../tools/javac/diags/examples.not-yet.txt | 7 +- ...NotDefAccessClassIntfCantAccessReason.java | 25 + .../modulesourcepath/apia/api1/Api.java | 28 + .../modulesourcepath/apia/module-info.java | 26 + .../modulesourcepath/apib/api2/Api.java | 28 + .../modulesourcepath/apib/module-info.java | 27 + .../modulesourcepath/impl/impl/Impl.java | 30 + .../modulesourcepath/impl/module-info.java | 26 + ...NotDefAccessClassIntfCantAccessReason.java | 27 + .../modulesourcepath/apia/api1/Api.java | 28 + .../modulesourcepath/apia/module-info.java | 26 + .../modulesourcepath/apib/api2/Api.java | 28 + .../modulesourcepath/apib/module-info.java | 27 + .../modulesourcepath/impl/impl/Impl.java | 30 + .../modulesourcepath/impl/module-info.java | 26 + .../NotDefAccessDoesNotRead.java | 25 + .../modulesourcepath/api/api/Api.java} | 5 +- .../modulesourcepath/api/module-info.java} | 6 +- .../modulesourcepath/impl/impl/Impl.java | 28 + .../modulesourcepath/impl/module-info.java | 25 + .../NotDefAccessDoesNotReadFromUnnamed.java | 29 + .../modulepath/api/api/Api.java | 27 + .../modulepath/api/module-info.java | 26 + .../NotDefAccessDoesNotReadUnnamed.java | 26 + .../classpath/api/Api.java | 28 + .../auxiliary/auxiliary/Auxiliary.java | 28 + .../auxiliary/module-info.java | 26 + .../modulesourcepath/impl/impl/Impl.java | 30 + .../modulesourcepath/impl/module-info.java | 26 + .../NotDefAccessNotExported.java} | 3 +- .../modulesourcepath/api/api/Api.java | 27 + .../modulesourcepath/api}/module-info.java | 3 +- .../modulesourcepath/impl/impl/Impl.java | 28 + .../modulesourcepath/impl/module-info.java | 26 + .../NotDefAccessNotExportedFromUnnamed.java | 30 + .../modulepath/api/api/Api.java | 27 + .../modulepath/api}/module-info.java | 3 +- .../NotDefAccessNotExportedToModule.java | 25 + .../modulesourcepath/api/api/Api.java | 27 + .../modulesourcepath/api/module-info.java | 26 + .../modulesourcepath/impl/impl/Impl.java | 28 + .../modulesourcepath/impl/module-info.java | 26 + .../modulesourcepath/other/module-info.java | 26 + ...fAccessNotExportedToModuleFromUnnamed.java | 30 + .../modulepath/api/api/Api.java | 27 + .../modulepath/api/module-info.java | 26 + .../modulepath/other/module-info.java | 26 + .../tools/javac/modules/AddLimitMods.java | 4 +- .../tools/javac/modules/AddReadsTest.java | 2 +- .../tools/javac/modules/AutomaticModules.java | 6 +- .../modules/ConvenientAccessErrorsTest.java | 515 ++++++++++++++++++ .../test/tools/javac/modules/EdgeCases.java | 2 +- .../test/tools/javac/modules/GraphsTest.java | 14 +- .../tools/javac/modules/LimitModulesTest.java | 2 +- .../tools/javac/modules/OpenModulesTest.java | 4 +- .../javac/modules/PackageMultipleModules.java | 4 +- .../javac/modules/RequiresStaticTest.java | 18 +- .../javac/modules/RequiresTransitiveTest.java | 14 +- .../test/tools/javac/modules/ResolveTest.java | 8 +- .../test/tools/javac/modules/UsesTest.java | 4 +- .../test/tools/javac/modules/XModuleTest.java | 2 +- 73 files changed, 2004 insertions(+), 135 deletions(-) create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/NotDefAccessClassIntfCantAccessReason.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/api1/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/api2/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/impl/Impl.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/NotDefAccessClassIntfCantAccessReason.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/api1/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/api2/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/impl/Impl.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/NotDefAccessDoesNotRead.java rename langtools/test/tools/javac/diags/examples/{NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/p2/C2.java => NotDefAccessDoesNotRead/modulesourcepath/api/api/Api.java} (95%) rename langtools/test/tools/javac/diags/examples/{NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/p1/C1.java => NotDefAccessDoesNotRead/modulesourcepath/api/module-info.java} (97%) create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/impl/Impl.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/NotDefAccessDoesNotReadFromUnnamed.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/api/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/NotDefAccessDoesNotReadUnnamed.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/classpath/api/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/auxiliary/Auxiliary.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/impl/Impl.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/module-info.java rename langtools/test/tools/javac/diags/examples/{NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java => NotDefAccessNotExported/NotDefAccessNotExported.java} (92%) create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/api/Api.java rename langtools/test/tools/javac/diags/examples/{NotDefAccessClassPackageCantAccess/modulesourcepath/m1x => NotDefAccessNotExported/modulesourcepath/api}/module-info.java (98%) create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/impl/Impl.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/NotDefAccessNotExportedFromUnnamed.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/api/Api.java rename langtools/test/tools/javac/diags/examples/{NotDefAccessClassPackageCantAccess/modulesourcepath/m2x => NotDefAccessNotExportedFromUnnamed/modulepath/api}/module-info.java (98%) create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/NotDefAccessNotExportedToModule.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/api/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/impl/Impl.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/other/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/NotDefAccessNotExportedToModuleFromUnnamed.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/api/Api.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/module-info.java create mode 100644 langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/other/module-info.java create mode 100644 langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index a1a9c8f8f6e..046d333ad80 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -921,6 +921,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { public PackageSymbol unnamedPackage; public Map visiblePackages; + public Set readModules; public List enclosedPackages = List.nil(); public Completer usesProvidesCompleter = Completer.NULL_COMPLETER; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 9d3344c5b97..07f7975c1c3 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -353,7 +353,7 @@ public class Attr extends JCTree.Visitor { @Override @DefinedBy(Api.COMPILER_TREE) public Symbol visitMemberSelect(MemberSelectTree node, Env env) { Symbol site = visit(node.getExpression(), env); - if (site.kind == ERR || site.kind == ABSENT_TYP) + if (site.kind == ERR || site.kind == ABSENT_TYP || site.kind == HIDDEN) return site; Name name = (Name)node.getIdentifier(); if (site.kind == PCK) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index f5a30ebaa5d..3add15e8909 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -1327,6 +1327,7 @@ public class Modules extends JCTree.Visitor { initAddExports(); msym.visiblePackages = new LinkedHashMap<>(); + msym.readModules = new HashSet<>(readable); Map seen = new HashMap<>(); 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 9d7a59b2476..dfb28eca2cd 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 @@ -54,14 +54,19 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; +import java.util.function.BiFunction; import java.util.function.BiPredicate; +import java.util.function.Predicate; import java.util.stream.Stream; import javax.lang.model.element.ElementVisitor; +import com.sun.tools.javac.code.Directive.ExportsDirective; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Flags.STATIC; @@ -69,6 +74,8 @@ import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*; +import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.Fragments; import static com.sun.tools.javac.tree.JCTree.Tag.*; /** Helper class for name resolution, used mostly by the attribution phase. @@ -89,6 +96,7 @@ public class Resolve { Check chk; Infer infer; ClassFinder finder; + ModuleFinder moduleFinder; Types types; JCDiagnostic.Factory diags; public final boolean allowMethodHandles; @@ -116,6 +124,7 @@ public class Resolve { chk = Check.instance(context); infer = Infer.instance(context); finder = ClassFinder.instance(context); + moduleFinder = ModuleFinder.instance(context); types = Types.instance(context); diags = JCDiagnostic.Factory.instance(context); Source source = Source.instance(context); @@ -315,7 +324,6 @@ public class Resolve { isAccessible = true; break; case PUBLIC: - isAccessible = true; if (allowModules) { ModuleSymbol currModule = env.toplevel.modle; currModule.complete(); @@ -491,7 +499,7 @@ public class Resolve { public Void visitClassType(ClassType t, Env env) { visit(t.getTypeArguments(), env); if (!isAccessible(env, t, true)) { - accessBase(new AccessError(t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true); + accessBase(new AccessError(env, null, t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true); } return null; } @@ -1965,7 +1973,7 @@ public class Resolve { Symbol loadClass(Env env, Name name) { try { ClassSymbol c = finder.loadClass(env.toplevel.modle, name); - return isAccessible(env, c) ? c : new AccessError(c); + return isAccessible(env, c) ? c : new AccessError(env, null, c); } catch (ClassFinder.BadClassFile err) { throw err; } catch (CompletionFailure ex) { @@ -1983,20 +1991,29 @@ public class Resolve { Symbol loadClass(Env env, Name name); } - private RecoveryLoadClass recoveryLoadClass = (env, name) -> { - //even if a class cannot be found in the current module and packages in modules it depends on that - //are exported for any or this module, the class may exist internally in some of these modules, - //or may exist in a module on which this module does not depend. Provide better diagnostic in - //such cases by looking for the class in any module: - for (ModuleSymbol ms : syms.getAllModules()) { - //do not load currently unloaded classes, to avoid too eager completion of random things in other modules: - ClassSymbol clazz = syms.getClass(ms, name); + private RecoveryLoadClass recoveryLoadClass = new RecoveryLoadClass() { + @Override + public Symbol loadClass(Env env, Name name) { + if (allowModules) { + Scope importScope = env.toplevel.namedImportScope; + Symbol existing = importScope.findFirst(Convert.shortName(name), + sym -> sym.kind == TYP && sym.flatName() == name); - if (clazz != null) { - return new AccessError(clazz); + if (existing != null) { + return new InvisibleSymbolError(env, true, existing); + } + + return lookupInvisibleSymbol(env, name, syms::getClass, (ms, n) -> { + try { + return finder.loadClass(ms, n); + } catch (CompletionFailure cf) { + //ignore + return null; + } + }, sym -> sym.kind == Kind.TYP, false, typeNotFound); } + return null; } - return null; }; public RecoveryLoadClass setRecoveryLoadClass(RecoveryLoadClass recovery) { @@ -2005,6 +2022,84 @@ public class Resolve { return prev; } + Symbol lookupPackage(Env env, Name name) { + PackageSymbol pack = syms.lookupPackage(env.toplevel.modle, name); + + if (allowModules && isImportOnDemand(env, name)) { + pack.complete(); + if (!pack.exists()) { + Name nameAndDot = name.append('.', names.empty); + boolean prefixOfKnown = + env.toplevel.modle.visiblePackages.values() + .stream() + .anyMatch(p -> p.fullname.startsWith(nameAndDot)); + + return lookupInvisibleSymbol(env, name, syms::getPackage, syms::enterPackage, sym -> { + sym.complete(); + return sym.exists(); + }, prefixOfKnown, pack); + } + } + + return pack; + } + + private boolean isImportOnDemand(Env env, Name name) { + if (!env.tree.hasTag(IMPORT)) + return false; + + JCTree qualid = ((JCImport) env.tree).qualid; + + if (!qualid.hasTag(SELECT)) + return false; + + if (TreeInfo.name(qualid) != names.asterisk) + return false; + + return TreeInfo.fullName(((JCFieldAccess) qualid).selected) == name; + } + + private Symbol lookupInvisibleSymbol(Env env, + Name name, + BiFunction get, + BiFunction load, + Predicate validate, + boolean suppressError, + Symbol defaultResult) { + //even if a class/package cannot be found in the current module and among packages in modules + //it depends on that are exported for any or this module, the class/package may exist internally + //in some of these modules, or may exist in a module on which this module does not depend. + //Provide better diagnostic in such cases by looking for the class in any module: + Set recoverableModules = new HashSet<>(syms.getAllModules()); + + recoverableModules.remove(env.toplevel.modle); + + for (ModuleSymbol ms : recoverableModules) { + Symbol sym = get.apply(ms, name); + + //avoid overly eager completing classes from source-based modules, as those + //may not be completable with the current compiler settings: + if (sym == null && (ms.sourceLocation == null)) { + if (ms.classLocation == null) { + ms = moduleFinder.findModule(ms); + } + + if (ms.kind != ERR) { + sym = load.apply(ms, name); + } + } + + if (sym == null) + continue; + + if (validate.test(sym)) { + return new InvisibleSymbolError(env, suppressError, sym); + } + } + + return defaultResult; + } + /** * Find a type declared in a scope (not inherited). Return null * if none is found. @@ -2205,7 +2300,7 @@ public class Resolve { } if (kind.contains(KindSelector.PCK)) - return syms.lookupPackage(env.toplevel.modle, name); + return lookupPackage(env, name); else return bestSoFar; } @@ -2219,11 +2314,6 @@ public class Resolve { Name name, KindSelector kind) { Name fullname = TypeSymbol.formFullName(name, pck); Symbol bestSoFar = typeNotFound; - PackageSymbol pack = null; - if (kind.contains(KindSelector.PCK)) { - pack = syms.lookupPackage(env.toplevel.modle, fullname); - if (pack.exists()) return pack; - } if (kind.contains(KindSelector.TYP)) { Symbol sym = loadClass(env, fullname); if (sym.exists()) { @@ -2232,7 +2322,10 @@ public class Resolve { } else bestSoFar = bestOf(bestSoFar, sym); } - return (pack != null) ? pack : bestSoFar; + if (kind.contains(KindSelector.PCK)) { + return lookupPackage(env, fullname); + } + return bestSoFar; } /** Find an identifier among the members of a given type `site'. @@ -3941,10 +4034,6 @@ public class Resolve { private Env env; private Type site; - AccessError(Symbol sym) { - this(null, null, sym); - } - AccessError(Env env, Type site, Symbol sym) { super(HIDDEN, sym, "access error"); this.env = env; @@ -3977,7 +4066,14 @@ public class Resolve { if (sym.owner.kind == PCK) { return diags.create(dkind, log.currentSource(), pos, "not.def.access.package.cant.access", - sym, sym.location()); + sym, sym.location(), inaccessiblePackageReason(env, sym.packge())); + } else if ( sym.packge() != syms.rootPackage + && sym.packge().modle != env.toplevel.modle + && !isAccessible(env, sym.outermostClass())) { + return diags.create(dkind, log.currentSource(), + pos, "not.def.access.class.intf.cant.access.reason", + sym, sym.location(), sym.location().packge(), + inaccessiblePackageReason(env, sym.packge())); } else { return diags.create(dkind, log.currentSource(), pos, "not.def.access.class.intf.cant.access", @@ -4009,6 +4105,90 @@ public class Resolve { } } + class InvisibleSymbolError extends InvalidSymbolError { + + private final Env env; + private final boolean suppressError; + + InvisibleSymbolError(Env env, boolean suppressError, Symbol sym) { + super(HIDDEN, sym, "invisible class error"); + this.env = env; + this.suppressError = suppressError; + this.name = sym.name; + } + + @Override + JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind, + DiagnosticPosition pos, + Symbol location, + Type site, + Name name, + List argtypes, + List typeargtypes) { + if (suppressError) + return null; + + if (sym.kind == PCK) { + JCDiagnostic details = inaccessiblePackageReason(env, sym.packge()); + return diags.create(dkind, log.currentSource(), + pos, "package.not.visible", sym, details); + } + + JCDiagnostic details = inaccessiblePackageReason(env, sym.packge()); + + if (pos.getTree() != null && pos.getTree().hasTag(SELECT) && sym.owner.kind == PCK) { + pos = ((JCFieldAccess) pos.getTree()).selected.pos(); + + return diags.create(dkind, log.currentSource(), + pos, "package.not.visible", sym.packge(), details); + } + + return diags.create(dkind, log.currentSource(), + pos, "not.def.access.package.cant.access", sym, sym.packge(), details); + } + } + + JCDiagnostic inaccessiblePackageReason(Env env, PackageSymbol sym) { + //no dependency: + if (!env.toplevel.modle.readModules.contains(sym.modle)) { + //does not read: + if (sym.modle != syms.unnamedModule) { + if (env.toplevel.modle != syms.unnamedModule) { + return diags.fragment(Fragments.NotDefAccessDoesNotRead(env.toplevel.modle, + sym, + sym.modle)); + } else { + return diags.fragment(Fragments.NotDefAccessDoesNotReadFromUnnamed(sym, + sym.modle)); + } + } else { + return diags.fragment(Fragments.NotDefAccessDoesNotReadUnnamed(sym, + env.toplevel.modle)); + } + } else { + if (sym.packge().modle.exports.stream().anyMatch(e -> e.packge == sym)) { + //not exported to this module: + if (env.toplevel.modle != syms.unnamedModule) { + return diags.fragment(Fragments.NotDefAccessNotExportedToModule(sym, + sym.modle, + env.toplevel.modle)); + } else { + return diags.fragment(Fragments.NotDefAccessNotExportedToModuleFromUnnamed(sym, + sym.modle)); + } + } else { + //not exported: + if (env.toplevel.modle != syms.unnamedModule) { + return diags.fragment(Fragments.NotDefAccessNotExported(sym, + sym.modle)); + } else { + return diags.fragment(Fragments.NotDefAccessNotExportedFromUnnamed(sym, + sym.modle)); + } + } + } + } + /** * InvalidSymbolError error class indicating that an instance member * has erroneously been accessed from a static context. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java index e4b07dde33b..edff639c7a1 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java @@ -410,7 +410,7 @@ public class TypeEnter implements Completer { importNamedStatic(tree, p, name, localEnv); chk.checkCanonical(imp.selected); } else { - TypeSymbol c = attribImportType(imp, localEnv).tsym; + TypeSymbol c = attribImportType(imp, localEnv).getOriginalType().tsym; chk.checkCanonical(imp); importNamed(tree.pos(), c, env, tree); } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 3357e2b871c..3e3e88195ae 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -823,17 +823,87 @@ compiler.err.no.match.entry=\ compiler.err.not.annotation.type=\ {0} is not an annotation type -# 0: symbol, 1: symbol +# 0: symbol, 1: symbol, 2: message segment compiler.err.not.def.access.package.cant.access=\ - {0} is not visible because package {1} is not visible + {0} is not visible\n\ + ({2}) + +# 0: symbol, 1: symbol, 2: message segment +compiler.misc.not.def.access.package.cant.access=\ + {0} is not visible\n\ + ({2}) + +# 0: symbol, 1: message segment +compiler.err.package.not.visible=\ + package {0} is not visible\n\ + ({1}) + +# 0: symbol, 1: message segment +compiler.misc.package.not.visible=\ + package {0} is not visible\n\ + ({1}) + +# {0} - current module +# {1} - package in which the invisible class is declared +# {2} - module in which {1} is declared +# 0: symbol, 1: symbol, 2: symbol +compiler.misc.not.def.access.does.not.read=\ + package {1} is declared in module {2}, but module {0} does not read it + +# {0} - package in which the invisible class is declared +# {1} - module in which {0} is declared +# 0: symbol, 1: symbol +compiler.misc.not.def.access.does.not.read.from.unnamed=\ + package {0} is declared in module {1}, which is not in the module graph + +# {0} - package in which the invisible class is declared +# {1} - current module +# 0: symbol, 1: symbol +compiler.misc.not.def.access.does.not.read.unnamed=\ + package {0} is declared in the unnamed module, but module {0} does not read it + +# {0} - package in which the invisible class is declared +# {1} - module in which {0} is declared +# 0: symbol, 1: symbol +compiler.misc.not.def.access.not.exported=\ + package {0} is declared in module {1}, which does not export it + +# {0} - package in which the invisible class is declared +# {1} - module in which {0} is declared +# 0: symbol, 1: symbol +compiler.misc.not.def.access.not.exported.from.unnamed=\ + package {0} is declared in module {1}, which does not export it + +# {0} - package in which the invisible class is declared +# {1} - module in which {0} is declared +# {2} - current module +# 0: symbol, 1: symbol, 2: symbol +compiler.misc.not.def.access.not.exported.to.module=\ + package {0} is declared in module {1}, which does not export it to module {2} + +# {0} - package in which the invisible class is declared +# {1} - module in which {0} is declared +# 0: symbol, 1: symbol +compiler.misc.not.def.access.not.exported.to.module.from.unnamed=\ + package {0} is declared in module {1}, which does not export it to the unnamed module # 0: symbol, 1: symbol compiler.err.not.def.access.class.intf.cant.access=\ - {0} in {1} is defined in an inaccessible class or interface + {1}.{0} is defined in an inaccessible class or interface # 0: symbol, 1: symbol compiler.misc.not.def.access.class.intf.cant.access=\ - {0} in {1} is defined in an inaccessible class or interface + {1}.{0} is defined in an inaccessible class or interface + +# 0: symbol, 1: symbol, 2: symbol, 3: message segment +compiler.err.not.def.access.class.intf.cant.access.reason=\ + {1}.{0} in package {2} is not accessible\n\ + ({3}) + +# 0: symbol, 1: symbol, 2: symbol, 3: message segment +compiler.misc.not.def.access.class.intf.cant.access.reason=\ + {1}.{0} in package {2} is not accessible\n\ + ({3}) # 0: symbol, 1: list of type, 2: type compiler.misc.cant.access.inner.cls.constr=\ diff --git a/langtools/test/tools/javac/T5003235/T5003235a.java b/langtools/test/tools/javac/T5003235/T5003235a.java index 1eea9628b3b..3a14d960f5d 100644 --- a/langtools/test/tools/javac/T5003235/T5003235a.java +++ b/langtools/test/tools/javac/T5003235/T5003235a.java @@ -3,7 +3,7 @@ * @bug 5003235 * @summary Private inner class accessible from subclasses * @author Peter von der Ah\u00e9 - * @compile/fail/ref=T5003235a.out --diags:layout=%b:%l:%_%m T5003235a.java + * @compile/fail/ref=T5003235a.out -XDrawDiagnostics T5003235a.java */ class Super { diff --git a/langtools/test/tools/javac/T5003235/T5003235a.out b/langtools/test/tools/javac/T5003235/T5003235a.out index 397f24972db..cd0c309e882 100644 --- a/langtools/test/tools/javac/T5003235/T5003235a.out +++ b/langtools/test/tools/javac/T5003235/T5003235a.out @@ -1,13 +1,5 @@ -T5003235a.java:21: defaultM() in Super.Inner is defined in an inaccessible class or interface - i.defaultM(); - ^ -T5003235a.java:22: protectedM() in Super.Inner is defined in an inaccessible class or interface - i.protectedM(); - ^ -T5003235a.java:23: publicM() in Super.Inner is defined in an inaccessible class or interface - i.publicM(); - ^ -T5003235a.java:24: privateM() in Super.Inner is defined in an inaccessible class or interface - i.privateM(); - ^ +T5003235a.java:21:10: compiler.err.not.def.access.class.intf.cant.access: defaultM(), Super.Inner +T5003235a.java:22:10: compiler.err.not.def.access.class.intf.cant.access: protectedM(), Super.Inner +T5003235a.java:23:10: compiler.err.not.def.access.class.intf.cant.access: publicM(), Super.Inner +T5003235a.java:24:10: compiler.err.not.def.access.class.intf.cant.access: privateM(), Super.Inner 4 errors diff --git a/langtools/test/tools/javac/T5003235/T5003235b.java b/langtools/test/tools/javac/T5003235/T5003235b.java index 629e077dba5..7787a267712 100644 --- a/langtools/test/tools/javac/T5003235/T5003235b.java +++ b/langtools/test/tools/javac/T5003235/T5003235b.java @@ -3,7 +3,7 @@ * @bug 5003235 * @summary Accessibility of private inner class * @author Peter von der Ah\u00e9 - * @compile/fail/ref=T5003235b.out --diags:layout=%b:%l:%_%m T5003235b.java + * @compile/fail/ref=T5003235b.out -XDrawDiagnostics T5003235b.java */ class Outer { diff --git a/langtools/test/tools/javac/T5003235/T5003235b.out b/langtools/test/tools/javac/T5003235/T5003235b.out index be2d9ebe00f..80822d0c7f1 100644 --- a/langtools/test/tools/javac/T5003235/T5003235b.out +++ b/langtools/test/tools/javac/T5003235/T5003235b.out @@ -1,13 +1,5 @@ -T5003235b.java:28: k in Outer.Inner is defined in an inaccessible class or interface - System.out.println("Value of k: " + outer.inner.k); - ^ -T5003235b.java:29: l in Outer.Inner is defined in an inaccessible class or interface - System.out.println("Value of l: " + outer.inner.l); - ^ -T5003235b.java:30: m in Outer.Inner is defined in an inaccessible class or interface - System.out.println("Value of m: " + outer.inner.m); - ^ -T5003235b.java:31: n in Outer.Inner is defined in an inaccessible class or interface - System.out.println("Value of n: " + outer.inner.n); - ^ +T5003235b.java:28:56: compiler.err.not.def.access.class.intf.cant.access: k, Outer.Inner +T5003235b.java:29:56: compiler.err.not.def.access.class.intf.cant.access: l, Outer.Inner +T5003235b.java:30:56: compiler.err.not.def.access.class.intf.cant.access: m, Outer.Inner +T5003235b.java:31:56: compiler.err.not.def.access.class.intf.cant.access: n, Outer.Inner 4 errors diff --git a/langtools/test/tools/javac/diags/Example.java b/langtools/test/tools/javac/diags/Example.java index 8ffe263878a..56f765e114e 100644 --- a/langtools/test/tools/javac/diags/Example.java +++ b/langtools/test/tools/javac/diags/Example.java @@ -61,9 +61,10 @@ class Example implements Comparable { declaredKeys = new TreeSet(); srcFiles = new ArrayList(); procFiles = new ArrayList(); - supportFiles = new ArrayList(); srcPathFiles = new ArrayList(); moduleSourcePathFiles = new ArrayList(); + modulePathFiles = new ArrayList(); + classPathFiles = new ArrayList(); additionalFiles = new ArrayList(); findFiles(file, srcFiles); @@ -89,10 +90,13 @@ class Example implements Comparable { } else if (files == srcFiles && c.getName().equals("additional")) { additionalFilesDir = c; findFiles(c, additionalFiles); - } else if (files == srcFiles && c.getName().equals("support")) - findFiles(c, supportFiles); - else + } else if (files == srcFiles && c.getName().equals("modulepath")) { + findFiles(c, modulePathFiles); + } else if (files == srcFiles && c.getName().equals("classpath")) { + findFiles(c, classPathFiles); + } else { findFiles(c, files); + } } } else if (f.isFile()) { if (f.getName().endsWith(".java")) { @@ -194,23 +198,32 @@ class Example implements Comparable { */ private void run(PrintWriter out, Set keys, boolean raw, boolean verbose) throws IOException { - ClassLoader loader = getClass().getClassLoader(); - if (supportFiles.size() > 0) { - File supportDir = new File(tempDir, "support"); - supportDir.mkdirs(); - clean(supportDir); - List sOpts = Arrays.asList("-d", supportDir.getPath()); - new Jsr199Compiler(verbose).run(null, null, false, sOpts, procFiles); - URLClassLoader ucl = - new URLClassLoader(new URL[] { supportDir.toURI().toURL() }, loader); - loader = ucl; + List opts = new ArrayList(); + if (!modulePathFiles.isEmpty()) { + File modulepathDir = new File(tempDir, "modulepath"); + modulepathDir.mkdirs(); + clean(modulepathDir); + List sOpts = Arrays.asList("-d", modulepathDir.getPath(), + "--module-source-path", new File(file, "modulepath").getAbsolutePath()); + new Jsr199Compiler(verbose).run(null, null, false, sOpts, modulePathFiles); + opts.add("--module-path"); + opts.add(modulepathDir.getAbsolutePath()); + } + + if (!classPathFiles.isEmpty()) { + File classpathDir = new File(tempDir, "classpath"); + classpathDir.mkdirs(); + clean(classpathDir); + List sOpts = Arrays.asList("-d", classpathDir.getPath()); + new Jsr199Compiler(verbose).run(null, null, false, sOpts, classPathFiles); + opts.add("--class-path"); + opts.add(classpathDir.getAbsolutePath()); } File classesDir = new File(tempDir, "classes"); classesDir.mkdirs(); clean(classesDir); - List opts = new ArrayList(); opts.add("-d"); opts.add(classesDir.getPath()); if (options != null) @@ -327,8 +340,9 @@ class Example implements Comparable { File additionalFilesDir; List srcPathFiles; List moduleSourcePathFiles; + List modulePathFiles; + List classPathFiles; List additionalFiles; - List supportFiles; File infoFile; private List runOpts; private List options; diff --git a/langtools/test/tools/javac/diags/RunExamples.java b/langtools/test/tools/javac/diags/RunExamples.java index d0c7516d0fe..3993afa30a6 100644 --- a/langtools/test/tools/javac/diags/RunExamples.java +++ b/langtools/test/tools/javac/diags/RunExamples.java @@ -239,8 +239,10 @@ public class RunExamples { srcFiles.remove(e.infoFile); showFiles(e, srcFiles); showFiles(e, e.srcPathFiles); + showFiles(e, e.moduleSourcePathFiles); + showFiles(e, e.modulePathFiles); + showFiles(e, e.classPathFiles); showFiles(e, e.procFiles); - showFiles(e, e.supportFiles); } run(e); } diff --git a/langtools/test/tools/javac/diags/examples.not-yet.txt b/langtools/test/tools/javac/diags/examples.not-yet.txt index 1e8000c2d15..ba3a1682adf 100644 --- a/langtools/test/tools/javac/diags/examples.not-yet.txt +++ b/langtools/test/tools/javac/diags/examples.not-yet.txt @@ -20,11 +20,13 @@ compiler.err.limit.pool.in.class # UNUSED? compiler.err.limit.stack # Code compiler.err.limit.string # Gen compiler.err.limit.string.overflow # JavaCompiler +compiler.err.module.non.zero.opens # bad class file compiler.err.name.reserved.for.internal.use # UNUSED compiler.err.no.annotation.member compiler.err.no.encl.instance.of.type.in.scope # cannot occur; always followed by assert false; compiler.err.no.match.entry # UNUSED? compiler.err.not.annotation.type # cannot occur given preceding checkType +compiler.err.not.def.access.package.cant.access compiler.err.proc.bad.config.file # JavacProcessingEnvironment compiler.err.proc.cant.access # completion failure compiler.err.proc.cant.access.1 # completion failure, no stack trace @@ -69,10 +71,11 @@ compiler.misc.kindname.type.variable.bound compiler.misc.kindname.value compiler.misc.incompatible.eq.lower.bounds # cannot happen? compiler.misc.module.name.mismatch +compiler.misc.module.non.zero.opens # bad class file compiler.misc.no.unique.minimal.instance.exists compiler.misc.no.unique.maximal.instance.exists # cannot happen? -compiler.err.module.non.zero.opens # bad class file -compiler.misc.module.non.zero.opens # bad class file +compiler.misc.not.def.access.package.cant.access +compiler.misc.package.not.visible compiler.misc.resume.abort # prompt for a response compiler.misc.source.unavailable # DiagnosticSource compiler.misc.token.bad-symbol diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/NotDefAccessClassIntfCantAccessReason.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/NotDefAccessClassIntfCantAccessReason.java new file mode 100644 index 00000000000..b5a0f36f506 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/NotDefAccessClassIntfCantAccessReason.java @@ -0,0 +1,25 @@ +/* + * 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. + */ + +//key: compiler.err.not.def.access.class.intf.cant.access.reason +//key: compiler.misc.not.def.access.does.not.read diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/api1/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/api1/Api.java new file mode 100644 index 00000000000..9bc49e0f9da --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/api1/Api.java @@ -0,0 +1,28 @@ +/* + * 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 api1; + +public class Api { + public static void test() {} +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/module-info.java new file mode 100644 index 00000000000..8196affb251 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apia/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module apia { + exports api1; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/api2/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/api2/Api.java new file mode 100644 index 00000000000..24b60819633 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/api2/Api.java @@ -0,0 +1,28 @@ +/* + * 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 api2; + +public class Api { + public static api1.Api get() { return null; } +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/module-info.java new file mode 100644 index 00000000000..d11793f46c6 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/apib/module-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +module apib { + requires apia; + exports api2; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/impl/Impl.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/impl/Impl.java new file mode 100644 index 00000000000..26361dcd61c --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/impl/Impl.java @@ -0,0 +1,30 @@ +/* + * 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 impl; + +public class Impl { + void test() { + api2.Api.get().test(); + } +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/module-info.java new file mode 100644 index 00000000000..85348d2105a --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReason/modulesourcepath/impl/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module impl { + requires apib; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/NotDefAccessClassIntfCantAccessReason.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/NotDefAccessClassIntfCantAccessReason.java new file mode 100644 index 00000000000..3b638c7dded --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/NotDefAccessClassIntfCantAccessReason.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// key: compiler.err.prob.found.req +// key: compiler.misc.invalid.mref +// key: compiler.misc.not.def.access.class.intf.cant.access.reason +// key: compiler.misc.not.def.access.does.not.read diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/api1/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/api1/Api.java new file mode 100644 index 00000000000..9bc49e0f9da --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/api1/Api.java @@ -0,0 +1,28 @@ +/* + * 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 api1; + +public class Api { + public static void test() {} +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/module-info.java new file mode 100644 index 00000000000..8196affb251 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apia/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module apia { + exports api1; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/api2/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/api2/Api.java new file mode 100644 index 00000000000..24b60819633 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/api2/Api.java @@ -0,0 +1,28 @@ +/* + * 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 api2; + +public class Api { + public static api1.Api get() { return null; } +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/module-info.java new file mode 100644 index 00000000000..d11793f46c6 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/apib/module-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +module apib { + requires apia; + exports api2; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/impl/Impl.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/impl/Impl.java new file mode 100644 index 00000000000..c4045e412a7 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/impl/Impl.java @@ -0,0 +1,30 @@ +/* + * 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 impl; + +public class Impl { + void test(api2.Api a2) { + Runnable r = a2.get() :: test; + } +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/module-info.java new file mode 100644 index 00000000000..85348d2105a --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessReasonFragment/modulesourcepath/impl/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module impl { + requires apib; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/NotDefAccessDoesNotRead.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/NotDefAccessDoesNotRead.java new file mode 100644 index 00000000000..9292485361a --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/NotDefAccessDoesNotRead.java @@ -0,0 +1,25 @@ +/* + * 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. + */ + +//key: compiler.err.package.not.visible +//key: compiler.misc.not.def.access.does.not.read diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/p2/C2.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/api/Api.java similarity index 95% rename from langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/p2/C2.java rename to langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/api/Api.java index 0f9bf2104d4..bd4c4637359 100644 --- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/p2/C2.java +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/api/Api.java @@ -21,8 +21,7 @@ * questions. */ -package p2; +package api; -public class C2 { - p1.C1 c1; +public class Api { } diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/p1/C1.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/module-info.java similarity index 97% rename from langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/p1/C1.java rename to langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/module-info.java index 08db623ec1f..17a593ebf66 100644 --- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/p1/C1.java +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/api/module-info.java @@ -21,6 +21,6 @@ * questions. */ -package p1; - -public class C1 {} +module api { + exports api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/impl/Impl.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/impl/Impl.java new file mode 100644 index 00000000000..d1df04ecb29 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/impl/Impl.java @@ -0,0 +1,28 @@ +/* + * 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 impl; + +public class Impl { + api.Api api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/module-info.java new file mode 100644 index 00000000000..5b48c53ae4c --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotRead/modulesourcepath/impl/module-info.java @@ -0,0 +1,25 @@ +/* + * 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. + */ + +module impl { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/NotDefAccessDoesNotReadFromUnnamed.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/NotDefAccessDoesNotReadFromUnnamed.java new file mode 100644 index 00000000000..24fbbce6bf9 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/NotDefAccessDoesNotReadFromUnnamed.java @@ -0,0 +1,29 @@ +/* + * 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. + */ + +//key: compiler.err.package.not.visible +//key: compiler.misc.not.def.access.does.not.read.from.unnamed + +public class NotDefAccessDoesNotReadFromUnnamed { + api.Api api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/api/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/api/Api.java new file mode 100644 index 00000000000..bd4c4637359 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/api/Api.java @@ -0,0 +1,27 @@ +/* + * 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 api; + +public class Api { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/module-info.java new file mode 100644 index 00000000000..17a593ebf66 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadFromUnnamed/modulepath/api/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module api { + exports api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/NotDefAccessDoesNotReadUnnamed.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/NotDefAccessDoesNotReadUnnamed.java new file mode 100644 index 00000000000..d0eed7c8517 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/NotDefAccessDoesNotReadUnnamed.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +//key: compiler.err.not.def.access.class.intf.cant.access.reason +//key: compiler.misc.not.def.access.does.not.read.unnamed +//options: --add-reads=auxiliary=ALL-UNNAMED diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/classpath/api/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/classpath/api/Api.java new file mode 100644 index 00000000000..441efd02e50 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/classpath/api/Api.java @@ -0,0 +1,28 @@ +/* + * 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 api; + +public class Api { + public void test() {} +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/auxiliary/Auxiliary.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/auxiliary/Auxiliary.java new file mode 100644 index 00000000000..6a9984ef450 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/auxiliary/Auxiliary.java @@ -0,0 +1,28 @@ +/* + * 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 auxiliary; + +public class Auxiliary { + public static api.Api get() { return null; } +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/module-info.java new file mode 100644 index 00000000000..b49fe061a82 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/auxiliary/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module auxiliary { + exports auxiliary; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/impl/Impl.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/impl/Impl.java new file mode 100644 index 00000000000..d65d3a9b760 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/impl/Impl.java @@ -0,0 +1,30 @@ +/* + * 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 impl; + +public class Impl { + { + auxiliary.Auxiliary.get().test(); + } +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/module-info.java new file mode 100644 index 00000000000..324108d1843 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessDoesNotReadUnnamed/modulesourcepath/impl/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module impl { + requires auxiliary; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/NotDefAccessNotExported.java similarity index 92% rename from langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java rename to langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/NotDefAccessNotExported.java index e40cbd30a7e..b023dd068a7 100644 --- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/NotDefAccessClassPackageCantAccess.java +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/NotDefAccessNotExported.java @@ -21,4 +21,5 @@ * questions. */ -// key: compiler.err.not.def.access.package.cant.access +//key: compiler.err.package.not.visible +//key: compiler.misc.not.def.access.not.exported diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/api/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/api/Api.java new file mode 100644 index 00000000000..bd4c4637359 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/api/Api.java @@ -0,0 +1,27 @@ +/* + * 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 api; + +public class Api { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/module-info.java similarity index 98% rename from langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/module-info.java rename to langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/module-info.java index d2438b08c8c..097b0dcc836 100644 --- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m1x/module-info.java +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/api/module-info.java @@ -21,4 +21,5 @@ * questions. */ -module m1x {} +module api { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/impl/Impl.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/impl/Impl.java new file mode 100644 index 00000000000..d1df04ecb29 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/impl/Impl.java @@ -0,0 +1,28 @@ +/* + * 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 impl; + +public class Impl { + api.Api api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/module-info.java new file mode 100644 index 00000000000..9dab8038cae --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExported/modulesourcepath/impl/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module impl { + requires api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/NotDefAccessNotExportedFromUnnamed.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/NotDefAccessNotExportedFromUnnamed.java new file mode 100644 index 00000000000..239f5bf4774 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/NotDefAccessNotExportedFromUnnamed.java @@ -0,0 +1,30 @@ +/* + * 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. + */ + +//key: compiler.err.package.not.visible +//key: compiler.misc.not.def.access.not.exported.from.unnamed +//options: --add-modules api + +public class NotDefAccessNotExportedFromUnnamed { + api.Api api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/api/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/api/Api.java new file mode 100644 index 00000000000..bd4c4637359 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/api/Api.java @@ -0,0 +1,27 @@ +/* + * 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 api; + +public class Api { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/module-info.java similarity index 98% rename from langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/module-info.java rename to langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/module-info.java index 47ee1b7b662..097b0dcc836 100644 --- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassPackageCantAccess/modulesourcepath/m2x/module-info.java +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedFromUnnamed/modulepath/api/module-info.java @@ -21,4 +21,5 @@ * questions. */ -module m2x {} +module api { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/NotDefAccessNotExportedToModule.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/NotDefAccessNotExportedToModule.java new file mode 100644 index 00000000000..e6502694c90 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/NotDefAccessNotExportedToModule.java @@ -0,0 +1,25 @@ +/* + * 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. + */ + +//key: compiler.err.package.not.visible +//key: compiler.misc.not.def.access.not.exported.to.module diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/api/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/api/Api.java new file mode 100644 index 00000000000..bd4c4637359 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/api/Api.java @@ -0,0 +1,27 @@ +/* + * 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 api; + +public class Api { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/module-info.java new file mode 100644 index 00000000000..48a0ae34978 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/api/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module api { + exports api to other; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/impl/Impl.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/impl/Impl.java new file mode 100644 index 00000000000..d1df04ecb29 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/impl/Impl.java @@ -0,0 +1,28 @@ +/* + * 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 impl; + +public class Impl { + api.Api api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/module-info.java new file mode 100644 index 00000000000..9dab8038cae --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/impl/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module impl { + requires api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/other/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/other/module-info.java new file mode 100644 index 00000000000..6df5dc24514 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModule/modulesourcepath/other/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module other { + requires api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/NotDefAccessNotExportedToModuleFromUnnamed.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/NotDefAccessNotExportedToModuleFromUnnamed.java new file mode 100644 index 00000000000..6082f4b2541 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/NotDefAccessNotExportedToModuleFromUnnamed.java @@ -0,0 +1,30 @@ +/* + * 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. + */ + +//key: compiler.err.package.not.visible +//key: compiler.misc.not.def.access.not.exported.to.module.from.unnamed +//options: --add-modules api + +public class NotDefAccessNotExportedToModuleFromUnnamed { + api.Api api; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/api/Api.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/api/Api.java new file mode 100644 index 00000000000..bd4c4637359 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/api/Api.java @@ -0,0 +1,27 @@ +/* + * 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 api; + +public class Api { +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/module-info.java new file mode 100644 index 00000000000..48a0ae34978 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/api/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module api { + exports api to other; +} diff --git a/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/other/module-info.java b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/other/module-info.java new file mode 100644 index 00000000000..6df5dc24514 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/NotDefAccessNotExportedToModuleFromUnnamed/modulepath/other/module-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +module other { + requires api; +} diff --git a/langtools/test/tools/javac/modules/AddLimitMods.java b/langtools/test/tools/javac/modules/AddLimitMods.java index c66aad962cf..9d7a2e541b4 100644 --- a/langtools/test/tools/javac/modules/AddLimitMods.java +++ b/langtools/test/tools/javac/modules/AddLimitMods.java @@ -217,8 +217,8 @@ public class AddLimitMods extends ModuleTestBase { private static final List> variants = Arrays.asList( new SimpleEntry(new String[] {}, - "Test.java:2:18: compiler.err.doesnt.exist: javax.annotation\n" - + "Test.java:5:19: compiler.err.doesnt.exist: javax.xml.bind\n" + "Test.java:2:7: compiler.err.package.not.visible: javax.annotation, (compiler.misc.not.def.access.does.not.read.from.unnamed: javax.annotation, java.annotations.common)\n" + + "Test.java:5:14: compiler.err.package.not.visible: javax.xml.bind, (compiler.misc.not.def.access.does.not.read.from.unnamed: javax.xml.bind, java.xml.bind)\n" + "2 errors\n"), new SimpleEntry(new String[] {"--add-modules", "java.annotations.common,java.xml.bind"}, null), diff --git a/langtools/test/tools/javac/modules/AddReadsTest.java b/langtools/test/tools/javac/modules/AddReadsTest.java index f19bad4b6a0..d03cda631e1 100644 --- a/langtools/test/tools/javac/modules/AddReadsTest.java +++ b/langtools/test/tools/javac/modules/AddReadsTest.java @@ -81,7 +81,7 @@ public class AddReadsTest extends ModuleTestBase { .getOutput(Task.OutputKind.DIRECT); checkOutputContains(log, - "Test.java:1:44: compiler.err.not.def.access.package.cant.access: api.Api, api"); + "Test.java:1:41: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)"); //test add dependencies: new JavacTask(tb) diff --git a/langtools/test/tools/javac/modules/AutomaticModules.java b/langtools/test/tools/javac/modules/AutomaticModules.java index 3a40c907db1..fa7524d1786 100644 --- a/langtools/test/tools/javac/modules/AutomaticModules.java +++ b/langtools/test/tools/javac/modules/AutomaticModules.java @@ -283,7 +283,7 @@ public class AutomaticModules extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("Impl.java:1:62: compiler.err.not.def.access.package.cant.access: m2x.M2, m2x", + List expected = Arrays.asList("Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)", "1 error"); if (!expected.equals(log)) { @@ -300,8 +300,8 @@ public class AutomaticModules extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - expected = Arrays.asList("Impl.java:1:51: compiler.err.doesnt.exist: apiB", - "Impl.java:1:62: compiler.err.not.def.access.package.cant.access: m2x.M2, m2x", + expected = Arrays.asList("Impl.java:1:47: compiler.err.package.not.visible: apiB, (compiler.misc.not.def.access.does.not.read: m1x, apiB, automaticB)", + "Impl.java:1:59: compiler.err.package.not.visible: m2x, (compiler.misc.not.def.access.does.not.read: m1x, m2x, m2x)", "2 errors"); if (!expected.equals(log)) { diff --git a/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java b/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java new file mode 100644 index 00000000000..fe81bf9dacf --- /dev/null +++ b/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java @@ -0,0 +1,515 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Check convenient errors are produced for inaccessible classes. + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase + * @run main ConvenientAccessErrorsTest + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; + +import toolbox.JarTask; +import toolbox.JavacTask; +import toolbox.Task; + +public class ConvenientAccessErrorsTest extends ModuleTestBase { + + public static void main(String... args) throws Exception { + new ConvenientAccessErrorsTest().runTests(); + } + + @Test + public void testNoDep(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { exports api; }", + "package api; public class Api { public void call() { } }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { }", + "package test; public class Test { api.Api api; }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testNotExported(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { exports api; }", + "package api; public class Api { }", + "package impl; public class Impl { }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }", + "package test; public class Test { impl.Impl api; }"); + Path src_m3 = src.resolve("m3x"); + tb.writeJavaFiles(src_m3, + "module m3x { requires m1x; }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:35: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported: impl, m1x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + + tb.writeJavaFiles(src_m1, + "module m1x { exports api; exports impl to m3x;}"); + + log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "Test.java:1:35: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported.to.module: impl, m1x, m2x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testInaccessibleInExported(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { exports api; }", + "package api; class Api { }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }", + "package test; public class Test { api.Api api; }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:38: compiler.err.not.def.public.cant.access: api.Api, api", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + +// @Test + public void testInaccessibleUnnamedModule(Path base) throws Exception { + Path jar = prepareTestJar(base, "package api; class Api { public static class Foo {} }"); + + Path moduleSrc = base.resolve("module-src"); + Path m1x = moduleSrc.resolve("m1x"); + + Path classes = base.resolve("classes"); + + Files.createDirectories(classes); + + tb.writeJavaFiles(m1x, + "module m1x { }", + "package test; public class Test { api.Api api; api.Api.Foo api; }"); + + List log = new JavacTask(tb) + .options("-classpath", jar.toString(), + "-XDrawDiagnostics") + .outdir(classes) + .files(findJavaFiles(moduleSrc)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:38: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", + "Test.java:1:51: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", + "2 errors"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testIndirectReferenceToUnnamedModule(Path base) throws Exception { + Path jar = prepareTestJar(base, "package api; public class Api { public void test() {} }"); + + Path moduleSrc = base.resolve("module-src"); + Path m1x = moduleSrc.resolve("m1x"); + Path auxiliary = moduleSrc.resolve("auxiliary"); + + Path classes = base.resolve("classes"); + + Files.createDirectories(classes); + + tb.writeJavaFiles(m1x, + "module m1x { requires auxiliary; }", + "package test; public class Test { { auxiliary.Auxiliary.get().test(); } }"); + + tb.writeJavaFiles(auxiliary, + "module auxiliary { exports auxiliary; }", + "package auxiliary; public class Auxiliary { public static api.Api get() { return null; } }"); + + List log = new JavacTask(tb) + .options("-classpath", jar.toString(), + "-XDrawDiagnostics", + "--add-reads", "auxiliary=ALL-UNNAMED", + "--module-source-path", moduleSrc.toString()) + .outdir(classes) + .files(findJavaFiles(moduleSrc)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:62: compiler.err.not.def.access.class.intf.cant.access.reason: test(), api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + private Path prepareTestJar(Path base, String code) throws Exception { + Path legacySrc = base.resolve("legacy-src"); + tb.writeJavaFiles(legacySrc, code); + Path legacyClasses = base.resolve("legacy-classes"); + Files.createDirectories(legacyClasses); + + String log = new JavacTask(tb) + .options() + .outdir(legacyClasses) + .files(findJavaFiles(legacySrc)) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!log.isEmpty()) { + throw new Exception("unexpected output: " + log); + } + + Path lib = base.resolve("lib"); + + Files.createDirectories(lib); + + Path jar = lib.resolve("test-api-1.0.jar"); + + new JarTask(tb, jar) + .baseDir(legacyClasses) + .files("api/Api.class") + .run(); + + return jar; + } + + @Test + public void testUnnamedModuleAccess(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { exports api to m2x; }", + "package api; class Api { }", + "package impl; class Impl { }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }"); + Path modulepath = base.resolve("modulepath"); + tb.createDirectories(modulepath); + + new JavacTask(tb) + .options("--module-source-path", src.toString()) + .outdir(modulepath) + .files(findJavaFiles(src)) + .run() + .writeAll(); + + Path unnamedSrc = base.resolve("unnamedSrc"); + tb.writeJavaFiles(unnamedSrc, + "public class Test { api.Api api; impl.Impl impl; }"); + Path unnamedClasses = base.resolve("unnamed-classes"); + Files.createDirectories(unnamedClasses); + + List log = new JavacTask(tb) + .options("--module-path", modulepath.toString(), + "-XDrawDiagnostics") + .outdir(unnamedClasses) + .files(findJavaFiles(unnamedSrc)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:21: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, m1x)", + "Test.java:1:34: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.does.not.read.from.unnamed: impl, m1x)", + "2 errors" + ); + + if (!expected.equals(log)) { + throw new Exception("unexpected output: " + log); + } + + log = new JavacTask(tb) + .options("--module-path", modulepath.toString(), + "--add-modules", "m1x", + "-XDrawDiagnostics") + .outdir(unnamedClasses) + .files(findJavaFiles(unnamedSrc)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "Test.java:1:21: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported.to.module.from.unnamed: api, m1x)", + "Test.java:1:34: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported.from.unnamed: impl, m1x)", + "2 errors" + ); + + if (!expected.equals(log)) { + throw new Exception("unexpected output: " + log); + } + } + + @Test + public void testInImport(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { }", + "package api; public class Api { public String test() { return null; } }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }", + "package test; import api.Api; public class Test { Api api; { api.test().length(); } }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testInImportOnDemand(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { }", + "package api; public class Api { public String test() { return null; } }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }", + "package test; import api.*; public class Test { Api api; { api.test().length(); } }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)", + "Test.java:1:49: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.not.exported: api, m1x)", + "2 errors"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testUnusedImportOnDemand1(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "package test; import javax.annotation.*; public class Test { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--add-modules", "java.compiler") + .outdir(classes) + .files(findJavaFiles(src)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList(""); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testUnusedImportOnDemand2(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { }", + "package api; public class Api { }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }", + "package test; import api.*; public class Test { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testClassPackageConflict(Path base) throws Exception { + Path libSrc = base.resolve("libSrc"); + tb.writeJavaFiles(libSrc, + "package test.desktop; public class Any { }"); + Path libClasses = base.resolve("libClasses"); + tb.createDirectories(libClasses); + + new JavacTask(tb) + .outdir(libClasses) + .files(findJavaFiles(libSrc)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "package test; public class desktop { public static class Action { } }", + "package use; import test.desktop.*; public class Use { test.desktop.Action a; }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics") + .classpath(libClasses) + .outdir(classes) + .files(findJavaFiles(src)) + .run() + .writeAll(); + } + + @Test + public void testClassPackageConflictInUnnamed(Path base) throws Exception { + Path libSrc = base.resolve("libSrc"); + tb.writeJavaFiles(libSrc, + "package desktop; public class Any { }"); + Path libClasses = base.resolve("libClasses"); + tb.createDirectories(libClasses); + + new JavacTask(tb) + .outdir(libClasses) + .files(findJavaFiles(libSrc)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "public class desktop { public static class Action { } }", + "import desktop.*; public class Use { desktop.Action a; }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics") + .classpath(libClasses) + .outdir(classes) + .files(findJavaFiles(src)) + .run() + .writeAll(); + } + +} diff --git a/langtools/test/tools/javac/modules/EdgeCases.java b/langtools/test/tools/javac/modules/EdgeCases.java index 0bbc6046a06..7c1dd6f1142 100644 --- a/langtools/test/tools/javac/modules/EdgeCases.java +++ b/langtools/test/tools/javac/modules/EdgeCases.java @@ -178,7 +178,7 @@ public class EdgeCases extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("Test.java:1:52: compiler.err.not.def.access.class.intf.cant.access: call(), api1.Api1") || + if (!log.contains("Test.java:1:52: compiler.err.not.def.access.class.intf.cant.access.reason: call(), api1.Api1, api1, (compiler.misc.not.def.access.does.not.read: m3x, api1, m1x)") || !log.contains("Test.java:1:76: compiler.err.not.def.access.class.intf.cant.access: toString(), java.lang.Object")) throw new Exception("expected output not found"); } diff --git a/langtools/test/tools/javac/modules/GraphsTest.java b/langtools/test/tools/javac/modules/GraphsTest.java index e26a859c5df..60aa2ab111f 100644 --- a/langtools/test/tools/javac/modules/GraphsTest.java +++ b/langtools/test/tools/javac/modules/GraphsTest.java @@ -134,9 +134,9 @@ public class GraphsTest extends ModuleTestBase { .getOutputLines(Task.OutputKind.DIRECT); List expected = Arrays.asList( - "Negative.java:1:43: compiler.err.doesnt.exist: closedO", - "Negative.java:1:56: compiler.err.doesnt.exist: closedN", - "Negative.java:1:69: compiler.err.doesnt.exist: closedL"); + "Negative.java:1:36: compiler.err.package.not.visible: closedO, (compiler.misc.not.def.access.not.exported: closedO, O)", + "Negative.java:1:49: compiler.err.package.not.visible: closedN, (compiler.misc.not.def.access.not.exported: closedN, N)", + "Negative.java:1:62: compiler.err.package.not.visible: closedL, (compiler.misc.not.def.access.not.exported: closedL, L)"); if (!log.containsAll(expected)) { throw new Exception("Expected output not found"); } @@ -153,9 +153,9 @@ public class GraphsTest extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); expected = Arrays.asList( - "Negative.java:1:43: compiler.err.not.def.access.package.cant.access: closedO.O, closedO", - "Negative.java:1:56: compiler.err.not.def.access.package.cant.access: closedN.N, closedN", - "Negative.java:1:69: compiler.err.not.def.access.package.cant.access: closedL.L, closedL"); + "Negative.java:1:36: compiler.err.package.not.visible: closedO, (compiler.misc.not.def.access.not.exported: closedO, O)", + "Negative.java:1:49: compiler.err.package.not.visible: closedN, (compiler.misc.not.def.access.not.exported: closedN, N)", + "Negative.java:1:62: compiler.err.package.not.visible: closedL, (compiler.misc.not.def.access.not.exported: closedL, L)"); if (!out.containsAll(expected)) { throw new Exception("Expected output not found"); } @@ -201,7 +201,7 @@ public class GraphsTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - String expected = "A.java:1:35: compiler.err.not.def.access.package.cant.access: pack.Clazz, pack"; + String expected = "A.java:1:31: compiler.err.package.not.visible: pack, (compiler.misc.not.def.access.not.exported.to.module: pack, N, L)"; if (!log.contains(expected)) { throw new Exception("Expected output not found"); } diff --git a/langtools/test/tools/javac/modules/LimitModulesTest.java b/langtools/test/tools/javac/modules/LimitModulesTest.java index 0ea6872813b..55a01455583 100644 --- a/langtools/test/tools/javac/modules/LimitModulesTest.java +++ b/langtools/test/tools/javac/modules/LimitModulesTest.java @@ -180,7 +180,7 @@ public class LimitModulesTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("C.java:1:41: compiler.err.doesnt.exist: com.sun.tools.javac")) + if (!log.contains("C.java:1:35: compiler.err.package.not.visible: com.sun.tools.javac, (compiler.misc.not.def.access.does.not.read.from.unnamed: com.sun.tools.javac, jdk.compiler)")) throw new Exception("expected output not found"); } } diff --git a/langtools/test/tools/javac/modules/OpenModulesTest.java b/langtools/test/tools/javac/modules/OpenModulesTest.java index 52ec90b8a82..0a4109d3c4c 100644 --- a/langtools/test/tools/javac/modules/OpenModulesTest.java +++ b/langtools/test/tools/javac/modules/OpenModulesTest.java @@ -117,7 +117,7 @@ public class OpenModulesTest extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected2 = Arrays.asList("Test.java:1:53: compiler.err.doesnt.exist: api2", + List expected2 = Arrays.asList("Test.java:1:49: compiler.err.package.not.visible: api2, (compiler.misc.not.def.access.not.exported: api2, m1x)", "1 error"); if (!Objects.equals(log2, expected2)) throw new Exception("expected output not found: " + log2); @@ -180,7 +180,7 @@ public class OpenModulesTest extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected2 = Arrays.asList("Test.java:1:53: compiler.err.doesnt.exist: api2", + List expected2 = Arrays.asList("Test.java:1:49: compiler.err.package.not.visible: api2, (compiler.misc.not.def.access.not.exported: api2, m1x)", "1 error"); if (!Objects.equals(log2, expected2)) throw new Exception("expected output not found: " + log2); diff --git a/langtools/test/tools/javac/modules/PackageMultipleModules.java b/langtools/test/tools/javac/modules/PackageMultipleModules.java index 28899c69c51..d96d0657832 100644 --- a/langtools/test/tools/javac/modules/PackageMultipleModules.java +++ b/langtools/test/tools/javac/modules/PackageMultipleModules.java @@ -70,8 +70,8 @@ public class PackageMultipleModules extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("A.java:1:26: compiler.err.not.def.access.package.cant.access: test.B, test", - "B.java:1:26: compiler.err.not.def.access.package.cant.access: test.A, test", + List expected = Arrays.asList("A.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m1x, test, m2x)", + "B.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m2x, test, m1x)", "2 errors"); if (!log.equals(expected)) throw new Exception("expected output not found"); diff --git a/langtools/test/tools/javac/modules/RequiresStaticTest.java b/langtools/test/tools/javac/modules/RequiresStaticTest.java index 83affcfc4d3..98f9436c480 100644 --- a/langtools/test/tools/javac/modules/RequiresStaticTest.java +++ b/langtools/test/tools/javac/modules/RequiresStaticTest.java @@ -88,7 +88,7 @@ public class RequiresStaticTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("Test.java:1:27: compiler.err.doesnt.exist: com.sun.source.tree")) + if (!log.contains("Test.java:1:22: compiler.err.package.not.visible: com.sun.source.tree, (compiler.misc.not.def.access.does.not.read: m, com.sun.source.tree, jdk.compiler)")) throw new Exception("expected output not found"); } @@ -124,18 +124,10 @@ public class RequiresStaticTest extends ModuleTestBase { .getOutput(Task.OutputKind.DIRECT); String[] expect = { - "C1.java:5:10: compiler.err.not.def.access.package.cant.access: p5.C5, p5", - "C1.java:5:24: compiler.err.not.def.access.package.cant.access: p6.C6, p6", - "C1.java:5:38: compiler.err.not.def.access.package.cant.access: p7.C7, p7", - "C1.java:5:52: compiler.err.not.def.access.package.cant.access: p8.C8, p8", - "C1.java:8:1: compiler.err.cant.resolve.location: kindname.class, C5, , , " - + "(compiler.misc.location: kindname.class, p1.C1, null)", - "C1.java:8:8: compiler.err.cant.resolve.location: kindname.class, C6, , , " - + "(compiler.misc.location: kindname.class, p1.C1, null)", - "C1.java:8:15: compiler.err.cant.resolve.location: kindname.class, C7, , , " - + "(compiler.misc.location: kindname.class, p1.C1, null)", - "C1.java:8:22: compiler.err.cant.resolve.location: kindname.class, C8, , , " - + "(compiler.misc.location: kindname.class, p1.C1, null)" + "C1.java:5:8: compiler.err.package.not.visible: p5, (compiler.misc.not.def.access.does.not.read: m1x, p5, m5x)", + "C1.java:5:22: compiler.err.package.not.visible: p6, (compiler.misc.not.def.access.does.not.read: m1x, p6, m6x)", + "C1.java:5:36: compiler.err.package.not.visible: p7, (compiler.misc.not.def.access.does.not.read: m1x, p7, m7x)", + "C1.java:5:50: compiler.err.package.not.visible: p8, (compiler.misc.not.def.access.does.not.read: m1x, p8, m8x)" }; for (String e: expect) { diff --git a/langtools/test/tools/javac/modules/RequiresTransitiveTest.java b/langtools/test/tools/javac/modules/RequiresTransitiveTest.java index ac2d3694b20..778249aed28 100644 --- a/langtools/test/tools/javac/modules/RequiresTransitiveTest.java +++ b/langtools/test/tools/javac/modules/RequiresTransitiveTest.java @@ -85,7 +85,7 @@ public class RequiresTransitiveTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("Test.java:1:27: compiler.err.doesnt.exist: com.sun.source.tree")) + if (!log.contains("Test.java:1:22: compiler.err.package.not.visible: com.sun.source.tree, (compiler.misc.not.def.access.does.not.read: m, com.sun.source.tree, jdk.compiler)")) throw new Exception("expected output not found"); } @@ -121,15 +121,9 @@ public class RequiresTransitiveTest extends ModuleTestBase { .getOutput(Task.OutputKind.DIRECT); String[] expect = { - "C1.java:5:10: compiler.err.not.def.access.package.cant.access: p5.C5, p5", - "C1.java:5:24: compiler.err.not.def.access.package.cant.access: p6.C6, p6", - "C1.java:5:38: compiler.err.not.def.access.package.cant.access: p7.C7, p7", - "C1.java:8:1: compiler.err.cant.resolve.location: kindname.class, C5, , , " - + "(compiler.misc.location: kindname.class, p1.C1, null)", - "C1.java:8:8: compiler.err.cant.resolve.location: kindname.class, C6, , , " - + "(compiler.misc.location: kindname.class, p1.C1, null)", - "C1.java:8:15: compiler.err.cant.resolve.location: kindname.class, C7, , , " - + "(compiler.misc.location: kindname.class, p1.C1, null)" + "C1.java:5:8: compiler.err.package.not.visible: p5, (compiler.misc.not.def.access.does.not.read: m1x, p5, m5x)", + "C1.java:5:22: compiler.err.package.not.visible: p6, (compiler.misc.not.def.access.does.not.read: m1x, p6, m6x)", + "C1.java:5:36: compiler.err.package.not.visible: p7, (compiler.misc.not.def.access.does.not.read: m1x, p7, m7x)" }; for (String e: expect) { diff --git a/langtools/test/tools/javac/modules/ResolveTest.java b/langtools/test/tools/javac/modules/ResolveTest.java index 79f664595d5..d9ee07e0bb4 100644 --- a/langtools/test/tools/javac/modules/ResolveTest.java +++ b/langtools/test/tools/javac/modules/ResolveTest.java @@ -99,7 +99,7 @@ public class ResolveTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1")) + if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.does.not.read: m2x, p1, m1x)")) throw new Exception("expected output not found"); } @@ -123,7 +123,7 @@ public class ResolveTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1")) + if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.not.exported: p1, m1x)")) throw new Exception("expected output not found"); } @@ -149,7 +149,7 @@ public class ResolveTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1")) + if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.not.exported.to.module: p1, m1x, m2x)")) throw new Exception("expected output not found"); } @@ -173,7 +173,7 @@ public class ResolveTest extends ModuleTestBase { .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("C2.java:1:33: compiler.err.not.def.access.package.cant.access: p1.C1, p1")) + if (!log.contains("C2.java:1:31: compiler.err.package.not.visible: p1, (compiler.misc.not.def.access.does.not.read: m2x, p1, m1x)")) throw new Exception("expected output not found"); } diff --git a/langtools/test/tools/javac/modules/UsesTest.java b/langtools/test/tools/javac/modules/UsesTest.java index 0d9f9a283ae..01ecfae68fc 100644 --- a/langtools/test/tools/javac/modules/UsesTest.java +++ b/langtools/test/tools/javac/modules/UsesTest.java @@ -262,7 +262,7 @@ public class UsesTest extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("module-info.java:1:34: compiler.err.not.def.access.package.cant.access: p.C, p", + List expected = Arrays.asList("module-info.java:1:33: compiler.err.package.not.visible: p, (compiler.misc.not.def.access.not.exported: p, m1x)", "1 error"); if (!output.containsAll(expected)) { throw new Exception("Expected output not found"); @@ -286,7 +286,7 @@ public class UsesTest extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("module-info.java:1:34: compiler.err.not.def.access.package.cant.access: p.C, p", + List expected = Arrays.asList("module-info.java:1:33: compiler.err.package.not.visible: p, (compiler.misc.not.def.access.not.exported: p, m1x)", "1 error"); if (!output.containsAll(expected)) { throw new Exception("Expected output not found"); diff --git a/langtools/test/tools/javac/modules/XModuleTest.java b/langtools/test/tools/javac/modules/XModuleTest.java index e8ef7ddc2b3..2ddeacbb7ef 100644 --- a/langtools/test/tools/javac/modules/XModuleTest.java +++ b/langtools/test/tools/javac/modules/XModuleTest.java @@ -288,7 +288,7 @@ public class XModuleTest extends ModuleTestBase { .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("A.java:1:36: compiler.err.doesnt.exist: pkg2", + List expected = Arrays.asList("A.java:1:32: compiler.err.package.not.visible: pkg2, (compiler.misc.not.def.access.does.not.read: m1, pkg2, m2)", "1 error"); if (!expected.equals(log)) From 6bc5a7b275faa3870a6ba531427c97df51260dff Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 11 Jan 2017 13:00:05 +0100 Subject: [PATCH 054/154] 8171409: Create a smoother configure experience on macosx Reviewed-by: erikj --- common/autoconf/basics.m4 | 4 +- common/autoconf/generated-configure.sh | 404 ++++++++++++++++++++++++- common/autoconf/help.m4 | 17 +- common/autoconf/jdk-options.m4 | 6 +- common/autoconf/lib-freetype.m4 | 6 +- 5 files changed, 420 insertions(+), 17 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 9d5789e37ca..89b91b0e8e0 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -1011,6 +1011,8 @@ AC_DEFUN([BASIC_CHECK_TAR], # Test which kind of tar was found if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then TAR_TYPE="gnu" + elif test "x$($TAR --version | $GREP "bsdtar")" != "x"; then + TAR_TYPE="bsd" elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then TAR_TYPE="bsd" elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index ad551b650c9..fc3c0cb5aed 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3564,7 +3564,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Include these first... # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -4122,7 +4122,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -4237,6 +4237,17 @@ yum_help() { esac } +brew_help() { + case $1 in + openjdk) + PKGHANDLER_COMMAND="brew cask install java" ;; + freetype) + PKGHANDLER_COMMAND="brew install freetype" ;; + ccache) + PKGHANDLER_COMMAND="brew install ccache" ;; + esac +} + port_help() { PKGHANDLER_COMMAND="" } @@ -4362,7 +4373,7 @@ VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -4667,7 +4678,7 @@ VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -5167,7 +5178,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=1483542685 +DATE_WHEN_GENERATED=1484135958 ############################################################################### # @@ -17544,7 +17555,7 @@ $as_echo "$as_me: The path of OUTPUT_ROOT, which resolves as \"$path\", is inval # Must be done before we can call HELP_MSG_MISSING_DEPENDENCY. - for ac_prog in apt-get yum port pkgutil pkgadd + for ac_prog in apt-get yum brew port pkgutil pkgadd do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -21209,6 +21220,8 @@ $as_echo "yes" >&6; } # Test which kind of tar was found if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then TAR_TYPE="gnu" + elif test "x$($TAR --version | $GREP "bsdtar")" != "x"; then + TAR_TYPE="bsd" elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then TAR_TYPE="bsd" elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then @@ -24359,15 +24372,13 @@ if test "${enable_keep_packaged_modules+set}" = set; then : fi - if test "x$enable_keep_packaged_modules" = "xyes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if packaged modules are kept" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if packaged modules are kept" >&5 $as_echo_n "checking if packaged modules are kept... " >&6; } + if test "x$enable_keep_packaged_modules" = "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } JLINK_KEEP_PACKAGED_MODULES=true elif test "x$enable_keep_packaged_modules" = "xno"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if packaged modules are kept" >&5 -$as_echo_n "checking if packaged modules are kept... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } JLINK_KEEP_PACKAGED_MODULES=false @@ -24376,6 +24387,8 @@ $as_echo "no" >&6; } $as_echo "yes (default)" >&6; } JLINK_KEEP_PACKAGED_MODULES=true else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } as_fn_error $? "--enable-keep-packaged-modules accepts no argument" "$LINENO" 5 fi @@ -29942,6 +29955,8 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -33235,6 +33250,8 @@ done apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -34534,6 +34551,8 @@ done apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -48601,6 +48620,8 @@ $as_echo "$as_me: Failed to compile stdio.h. This likely implies missing compile apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -48762,6 +48783,8 @@ $as_echo "$as_me: The tested number of bits in the target ($TESTED_TARGET_CPU_BI apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -52844,6 +52867,8 @@ $as_echo "no, missing dependencies" >&6; } apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -56649,6 +56674,8 @@ fi apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -56721,6 +56748,8 @@ done apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -56864,6 +56893,8 @@ done apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -60683,6 +60714,345 @@ $as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&6;} fi + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + POTENTIAL_FREETYPE_LIB_PATH="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a unix platform. Hooray! :) + path="$POTENTIAL_FREETYPE_LIB_PATH" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + if test -d "$path"; then + POTENTIAL_FREETYPE_LIB_PATH="`cd "$path"; $THEPWDCMD -L`" + else + dir="`$DIRNAME "$path"`" + base="`$BASENAME "$path"`" + POTENTIAL_FREETYPE_LIB_PATH="`cd "$dir"; $THEPWDCMD -L`/$base" + fi + fi + fi + + + FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype includes" >&5 +$as_echo_n "checking for freetype includes... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_INCLUDE_PATH" >&5 +$as_echo "$FREETYPE_INCLUDE_PATH" >&6; } + FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype libraries" >&5 +$as_echo_n "checking for freetype libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_LIB_PATH" >&5 +$as_echo "$FREETYPE_LIB_PATH" >&6; } + fi + + fi + if test "x$FOUND_FREETYPE" != xyes; then + FREETYPE_BASE_DIR="$SYSROOT/usr/local" + + POTENTIAL_FREETYPE_INCLUDE_PATH="$FREETYPE_BASE_DIR/include" + POTENTIAL_FREETYPE_LIB_PATH="$FREETYPE_BASE_DIR/lib" + METHOD="well-known location" + + # Let's start with an optimistic view of the world :-) + FOUND_FREETYPE=yes + + # First look for the canonical freetype main include file ft2build.h. + if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then + # Oh no! Let's try in the freetype2 directory. This is needed at least at Mac OS X Yosemite. + POTENTIAL_FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH/freetype2" + if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then + # Fail. + FOUND_FREETYPE=no + fi + fi + + if test "x$FOUND_FREETYPE" = xyes; then + # Include file found, let's continue the sanity check. + { $as_echo "$as_me:${as_lineno-$LINENO}: Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD" >&5 +$as_echo "$as_me: Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD" >&6;} + + # Reset to default value + FREETYPE_BASE_NAME=freetype + FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}" + if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then + if test "x$OPENJDK_TARGET_OS" = xmacosx \ + && test -s "$POTENTIAL_FREETYPE_LIB_PATH/${LIBRARY_PREFIX}freetype.6${SHARED_LIBRARY_SUFFIX}"; then + # On Mac OS X Yosemite, the symlink from libfreetype.dylib to libfreetype.6.dylib disappeared. Check + # for the .6 version explicitly. + FREETYPE_BASE_NAME=freetype.6 + FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}" + { $as_echo "$as_me:${as_lineno-$LINENO}: Compensating for missing symlink by using version 6 explicitly" >&5 +$as_echo "$as_me: Compensating for missing symlink by using version 6 explicitly" >&6;} + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location." >&5 +$as_echo "$as_me: Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location." >&6;} + FOUND_FREETYPE=no + fi + else + if test "x$OPENJDK_TARGET_OS" = xwindows; then + # On Windows, we will need both .lib and .dll file. + if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location." >&5 +$as_echo "$as_me: Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location." >&6;} + FOUND_FREETYPE=no + fi + elif test "x$OPENJDK_TARGET_OS" = xsolaris \ + && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then + # Found lib in isa dir, use that instead. + POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead" >&5 +$as_echo "$as_me: Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead" >&6;} + fi + fi + fi + + if test "x$FOUND_FREETYPE" = xyes; then + + # Only process if variable expands to non-empty + + if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$POTENTIAL_FREETYPE_INCLUDE_PATH" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of POTENTIAL_FREETYPE_INCLUDE_PATH" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-style (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + POTENTIAL_FREETYPE_INCLUDE_PATH="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$POTENTIAL_FREETYPE_INCLUDE_PATH" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + POTENTIAL_FREETYPE_INCLUDE_PATH="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a unix platform. Hooray! :) + path="$POTENTIAL_FREETYPE_INCLUDE_PATH" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + if test -d "$path"; then + POTENTIAL_FREETYPE_INCLUDE_PATH="`cd "$path"; $THEPWDCMD -L`" + else + dir="`$DIRNAME "$path"`" + base="`$BASENAME "$path"`" + POTENTIAL_FREETYPE_INCLUDE_PATH="`cd "$dir"; $THEPWDCMD -L`/$base" + fi + fi + fi + + + # Only process if variable expands to non-empty + + if test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$POTENTIAL_FREETYPE_LIB_PATH" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of POTENTIAL_FREETYPE_LIB_PATH" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-style (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + POTENTIAL_FREETYPE_LIB_PATH="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$POTENTIAL_FREETYPE_LIB_PATH" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + windows_path="$new_path" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then unix_path=`$CYGPATH -u "$windows_path"` @@ -62122,6 +62492,8 @@ $as_echo "$FREETYPE_LIB_PATH" >&6; } apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -62477,6 +62849,8 @@ $as_echo "$as_me: Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREE apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -62682,6 +63056,8 @@ done apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -62870,6 +63246,8 @@ done apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -62949,6 +63327,8 @@ $as_echo "$LIBFFI_WORKS" >&6; } apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -64058,6 +64438,8 @@ done apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -64142,6 +64524,8 @@ $as_echo "$LIBELF_WORKS" >&6; } apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) diff --git a/common/autoconf/help.m4 b/common/autoconf/help.m4 index 76824e54787..1a313e62236 100644 --- a/common/autoconf/help.m4 +++ b/common/autoconf/help.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ AC_DEFUN_ONCE([HELP_SETUP_DEPENDENCY_HELP], [ - AC_CHECK_PROGS(PKGHANDLER, apt-get yum port pkgutil pkgadd) + AC_CHECK_PROGS(PKGHANDLER, apt-get yum brew port pkgutil pkgadd) ]) AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY], @@ -46,6 +46,8 @@ AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY], apt_help $MISSING_DEPENDENCY ;; yum) yum_help $MISSING_DEPENDENCY ;; + brew) + brew_help $MISSING_DEPENDENCY ;; port) port_help $MISSING_DEPENDENCY ;; pkgutil) @@ -147,6 +149,17 @@ yum_help() { esac } +brew_help() { + case $1 in + openjdk) + PKGHANDLER_COMMAND="brew cask install java" ;; + freetype) + PKGHANDLER_COMMAND="brew install freetype" ;; + ccache) + PKGHANDLER_COMMAND="brew install ccache" ;; + esac +} + port_help() { PKGHANDLER_COMMAND="" } diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 7b6b1f5fae2..2c21000845b 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -382,18 +382,18 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS], AC_ARG_ENABLE([keep-packaged-modules], [AS_HELP_STRING([--disable-keep-packaged-modules], [Do not keep packaged modules in jdk image @<:@enable@:>@])]) + AC_MSG_CHECKING([if packaged modules are kept]) if test "x$enable_keep_packaged_modules" = "xyes"; then - AC_MSG_CHECKING([if packaged modules are kept]) AC_MSG_RESULT([yes]) JLINK_KEEP_PACKAGED_MODULES=true elif test "x$enable_keep_packaged_modules" = "xno"; then - AC_MSG_CHECKING([if packaged modules are kept]) AC_MSG_RESULT([no]) JLINK_KEEP_PACKAGED_MODULES=false elif test "x$enable_keep_packaged_modules" = "x"; then AC_MSG_RESULT([yes (default)]) JLINK_KEEP_PACKAGED_MODULES=true else + AC_MSG_RESULT([error]) AC_MSG_ERROR([--enable-keep-packaged-modules accepts no argument]) fi diff --git a/common/autoconf/lib-freetype.m4 b/common/autoconf/lib-freetype.m4 index 99d84a28a7d..e7790caa64b 100644 --- a/common/autoconf/lib-freetype.m4 +++ b/common/autoconf/lib-freetype.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -348,6 +348,10 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], FREETYPE_BASE_DIR="$SYSROOT/usr/X11" LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location]) fi + if test "x$FOUND_FREETYPE" != xyes; then + FREETYPE_BASE_DIR="$SYSROOT/usr/local" + LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location]) + fi if test "x$OPENJDK_TARGET_OS" = xmacosx; then if test "x$FOUND_FREETYPE" != xyes; then From a9a05f2affacd441a698c48fd97cfaeff072a081 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 11 Jan 2017 10:29:24 -0800 Subject: [PATCH 055/154] 8171325: NPE in Check.clearLocalClassNameIndexes Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Check.java | 8 ++++--- .../NPEClearingLocalClassNameIndexesTest.java | 21 +++++++++++++++++++ .../NPEClearingLocalClassNameIndexesTest.out | 6 ++++++ 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.java create mode 100644 langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.out diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index bf195d7b70a..b300770cd05 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -436,8 +436,10 @@ public class Check { } void clearLocalClassNameIndexes(ClassSymbol c) { - localClassNameIndexes.remove(new Pair<>( - c.owner.enclClass().flatname, c.name)); + if (c.owner != null && c.owner.kind != NIL) { + localClassNameIndexes.remove(new Pair<>( + c.owner.enclClass().flatname, c.name)); + } } public void newRound() { diff --git a/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.java b/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.java new file mode 100644 index 00000000000..8fb0c3df652 --- /dev/null +++ b/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8171325 + * @summary NPE in Check.clearLocalClassNameIndexes + * @compile/fail/ref=NPEClearingLocalClassNameIndexesTest.out -XDrawDiagnostics NPEClearingLocalClassNameIndexesTest.java + */ + +import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; + +public class NPEClearingLocalClassNameIndexesTest { + void f(List t) {} + C g(C u, Function v) { return null; } + D g(Supplier w) { return null; } + + public void test() { + f(g((String) null, task -> g(new NoSuch() {}))); + f(g((String) null, task -> g(new NoSuch() {}))); + } +} diff --git a/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.out b/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.out new file mode 100644 index 00000000000..809d0c25961 --- /dev/null +++ b/langtools/test/tools/javac/T8171325/NPEClearingLocalClassNameIndexesTest.out @@ -0,0 +1,6 @@ +NPEClearingLocalClassNameIndexesTest.java:18:9: compiler.err.cant.apply.symbol: kindname.method, f, java.util.List, java.lang.String, kindname.class, NPEClearingLocalClassNameIndexesTest, (compiler.misc.incompatible.upper.lower.bounds: C, java.lang.Object,java.util.List, java.lang.String) +NPEClearingLocalClassNameIndexesTest.java:18:42: compiler.err.cant.resolve.location: kindname.class, NoSuch, , , (compiler.misc.location: kindname.class, NPEClearingLocalClassNameIndexesTest, null) +NPEClearingLocalClassNameIndexesTest.java:19:9: compiler.err.cant.apply.symbol: kindname.method, f, java.util.List, java.lang.String, kindname.class, NPEClearingLocalClassNameIndexesTest, (compiler.misc.incompatible.upper.lower.bounds: C, java.lang.Object,java.util.List, java.lang.String) +NPEClearingLocalClassNameIndexesTest.java:19:42: compiler.err.cant.resolve.location: kindname.class, NoSuch, , , (compiler.misc.location: kindname.class, NPEClearingLocalClassNameIndexesTest, null) +NPEClearingLocalClassNameIndexesTest.java:19:49: compiler.err.type.found.req: int, (compiler.misc.type.req.ref) +5 errors From 96c8382650c830691e2a8bc5e29de9edacb24324 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Wed, 11 Jan 2017 11:09:04 -0800 Subject: [PATCH 056/154] 8172530: JShell: TypeProjection .stream().map(...).collect(...) must be replaced with .map(...) Reviewed-by: mcimadamore --- .../jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java index ba98a4015ca..239152e19d6 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarTypePrinter.java @@ -181,9 +181,7 @@ class VarTypePrinter extends TypePrinter { Type outer = t.getEnclosingType(); Type outer1 = visit(outer, upward); List typarams = t.getTypeArguments(); - List typarams1 = typarams.stream() - .map(ta -> mapTypeArgument(ta, upward)) - .collect(List.collector()); + List typarams1 = typarams.map(ta -> mapTypeArgument(ta, upward)); if (typarams1.stream().anyMatch(ta -> ta.hasTag(BOT))) { //not defined return syms.botType; From 083e723812c5194c87103c486423d77c6742f163 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 11 Jan 2017 13:06:04 -0800 Subject: [PATCH 057/154] 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar Reviewed-by: rriggs, dfuchs, lancea, alanb --- .../classes/javax/xml/catalog/AltCatalog.java | 6 +- .../classes/javax/xml/catalog/BaseEntry.java | 39 +-- .../classes/javax/xml/catalog/Catalog.java | 10 +- .../javax/xml/catalog/CatalogFeatures.java | 73 ++--- .../javax/xml/catalog/CatalogImpl.java | 71 ++--- .../javax/xml/catalog/CatalogManager.java | 55 ++-- .../javax/xml/catalog/CatalogMessages.java | 15 +- .../xml/catalog/CatalogMessages.properties | 2 + .../javax/xml/catalog/CatalogReader.java | 25 +- .../javax/xml/catalog/CatalogResolver.java | 10 +- .../xml/catalog/CatalogResolverImpl.java | 8 +- .../classes/javax/xml/catalog/GroupEntry.java | 15 +- .../classes/javax/xml/catalog/UriEntry.java | 6 +- .../share/classes/javax/xml/catalog/Util.java | 227 +++++++++----- .../catalog/SpecifyCatalogTest.java | 6 +- .../functional/catalog/catalogFiles/dummy.xml | 1 + .../jaxp/libs/catalog/CatalogTestUtils.java | 15 +- .../xml/jaxp/libs/jaxp/library/JarUtils.java | 141 +++++++++ .../libs/jaxp/library/SimpleHttpServer.java | 177 +++++++++++ .../unittest/catalog/CatalogAccessTest.java | 76 +++++ .../catalog/CatalogFileInputTest.java | 282 ++++++++++++++++++ .../catalog/CatalogInvalidPathTest.java | 66 ---- .../unittest/catalog/CatalogSupportBase.java | 44 ++- .../jaxp/unittest/catalog/CatalogTest.java | 134 +++++---- .../unittest/catalog/jar/META-INF/MANIFEST.MF | 3 + .../catalog/jar/META-INF/catalog/ws-addr.xsd | 137 +++++++++ .../catalog/jar/META-INF/jax-ws-catalog.xml | 4 + 27 files changed, 1226 insertions(+), 422 deletions(-) create mode 100644 jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/dummy.xml create mode 100644 jaxp/test/javax/xml/jaxp/libs/jaxp/library/JarUtils.java create mode 100644 jaxp/test/javax/xml/jaxp/libs/jaxp/library/SimpleHttpServer.java create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogAccessTest.java create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogFileInputTest.java delete mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogInvalidPathTest.java create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/MANIFEST.MF create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/catalog/ws-addr.xsd create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/jax-ws-catalog.xml diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/AltCatalog.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/AltCatalog.java index 3bb99efec67..07e9ee1fd77 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/AltCatalog.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/AltCatalog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ class AltCatalog extends BaseEntry { } /** - * Returns the catalog attribute as an URI String. + * Returns the catalog attribute as a URI String. * @return The value of the catalog attribute */ String getCatalogId() { @@ -66,7 +66,7 @@ class AltCatalog extends BaseEntry { } /** - * Returns the catalog attribute as an URI. + * Returns the catalog attribute as a URI. * @return The value of the catalog attribute */ URI getCatalogURI() { diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java index 943b9f23264..3d5718d661d 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ package javax.xml.catalog; import java.net.MalformedURLException; import java.net.URL; import java.util.Objects; +import static javax.xml.catalog.CatalogMessages.ERR_INVALID_ARGUMENT; /** * Represents a general Catalog entry. @@ -210,13 +211,12 @@ abstract class BaseEntry { * @param arg The name of the argument * @param uri The URI to be verified * @return The URI created from the specified uri - * @throws IllegalArgumentException if the specified uri is null, - * or an URL can not be created based on the specified base and uri + * @throws NullPointerException if the specified uri is null + * @throws IllegalArgumentException if a URL can not be created based on + * the specified base and uri */ URL verifyURI(String arg, URL base, String uri) { - if (uri == null) { - CatalogMessages.reportIAE(new Object[]{uri, arg}, null); - } + CatalogMessages.reportNPEOnNull(arg, uri); URL url = null; uri = Normalizer.normalizeURI(uri); @@ -228,32 +228,9 @@ abstract class BaseEntry { url = new URL(uri); } } catch (MalformedURLException e) { - CatalogMessages.reportIAE(new Object[]{uri, arg}, e); + CatalogMessages.reportIAE(ERR_INVALID_ARGUMENT, + new Object[]{uri, arg}, e); } return url; } - - /** - * Construct an absolute URI from a relative one, using the current base - * URI. - * - * @param sysid The (possibly relative) system identifier - * @return The system identifier made absolute with respect to the current - * {@link #base}. - */ - protected String makeAbsolute(String sysid) { - URL local = null; - - sysid = Util.fixSlashes(sysid); - /** - * try { local = new URL(base, sysid); } catch (MalformedURLException e) - * { catalogManager.debug.message(1, "Malformed URL on system - * identifier", sysid); } - */ - if (local != null) { - return local.toString(); - } else { - return sysid; - } - } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java index 16f70ad7581..fcefd012666 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ import java.util.stream.Stream; *
    *
  • Locate the external resources with a public or system identifier; *
  • - *
  • Locate an alternate URI reference with an URI. + *
  • Locate an alternate URI reference with a URI. *
  • *
*

@@ -84,7 +84,7 @@ public interface Catalog { * * @param systemId the system identifier of the entity to be matched * - * @return an URI string if a mapping is found, or null otherwise + * @return a URI string if a mapping is found, or null otherwise */ public String matchSystem(String systemId); @@ -108,7 +108,7 @@ public interface Catalog { * * @param publicId the public identifier of the entity to be matched * @see CatalogFeatures.Feature - * @return an URI string if a mapping is found, or null otherwise + * @return a URI string if a mapping is found, or null otherwise */ public String matchPublic(String publicId); @@ -134,7 +134,7 @@ public interface Catalog { * * @param uri the URI reference of the entity to be matched * - * @return an URI string if a mapping is found, or null otherwise + * @return a URI string if a mapping is found, or null otherwise */ public String matchURI(String uri); diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java index e448e47ae5c..01d0b533055 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,14 +56,14 @@ import jdk.xml.internal.SecuritySupport; * * * FILES - * A semicolon-delimited list of catalog files. Relative file paths are - * considered relative to ${user.dir}. + * A semicolon-delimited list of URIs to locate the catalog files. + * The URIs must be absolute and have a URL protocol handler for the URI scheme. * * javax.xml.catalog.files * javax.xml.catalog.files * javax.xml.catalog.files * String - * File paths + * URIs * * Reads the first catalog as the current catalog; Loads others if no match * is found in the current catalog including delegate catalogs if any. @@ -170,7 +170,7 @@ import jdk.xml.internal.SecuritySupport; * Properties set through the Catalog API override those that may have been set * by system properties and/or in {@code jaxp.properties}. In case of multiple * interfaces, the latest in a procedure shall take preference. For - * {@link Feature#FILES}, this means that the path(s) specified through the methods + * {@link Feature#FILES}, this means that the URI(s) specified through the methods * of the {@link CatalogManager} will override any that may have been entered * through the {@link Builder}. * @@ -188,7 +188,7 @@ import jdk.xml.internal.SecuritySupport; * in the following sample code: *

{@code
                 CatalogFeatures f = CatalogFeatures.builder()
-                        .with(Feature.FILES, "catalog.xml")
+                        .with(Feature.FILES, "file:///etc/xml/catalog")
                         .with(Feature.PREFER, "public")
                         .with(Feature.DEFER, "true")
                         .with(Feature.RESOLVE, "ignore")
@@ -202,14 +202,14 @@ import jdk.xml.internal.SecuritySupport;
  * Schema Validation ({@link javax.xml.validation}), and XML Transformation
  * ({@link javax.xml.transform}). The features described above can be set through JAXP
  * factories or processors that define a setProperty or setAttribute interface.
- * For example, the following code snippet sets a path to a catalog file on a SAX
+ * For example, the following code snippet sets a URI to a catalog file on a SAX
  * parser through the {@code javax.xml.catalog.files} property:
  * 

*

{@code
  *      SAXParserFactory spf = SAXParserFactory.newInstance();
  *      spf.setFeature(XMLConstants.USE_CATALOG, true); [1]
  *      SAXParser parser = spf.newSAXParser();
- *      parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "catalog.xml");
+ *      parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "file:///etc/xml/catalog");
  * }
*

* [1] Note that this statement is not required since the default value of @@ -275,7 +275,7 @@ import jdk.xml.internal.SecuritySupport; The following XInclude element: - can be resolved using an uri entry: + can be resolved using a URI entry: or @@ -291,7 +291,7 @@ import jdk.xml.internal.SecuritySupport; - can be resolved using an uri entry: + can be resolved using a URI entry: or @@ -308,7 +308,7 @@ import jdk.xml.internal.SecuritySupport; The following include element: - can be resolved using an uri entry: + can be resolved using a URI entry: or @@ -323,7 +323,7 @@ import jdk.xml.internal.SecuritySupport; The following include element: - can be resolved using an uri entry: + can be resolved using a URI entry: or @@ -338,7 +338,7 @@ import jdk.xml.internal.SecuritySupport; The document in the following element: - can be resolved using an uri entry: + can be resolved using a URI entry: or @@ -559,7 +559,7 @@ public class CatalogFeatures { values = new String[Feature.values().length]; states = new State[Feature.values().length]; for (Feature cf : Feature.values()) { - setProperty(cf.ordinal(), State.DEFAULT, cf.defaultValue()); + setProperty(cf, State.DEFAULT, cf.defaultValue()); } //read system properties or jaxp.properties readSystemProperties(); @@ -571,52 +571,27 @@ public class CatalogFeatures { */ private void setProperties(Builder builder) { builder.values.entrySet().stream().forEach((entry) -> { - setProperty(entry.getKey().ordinal(), State.APIPROPERTY, entry.getValue()); + setProperty(entry.getKey(), State.APIPROPERTY, entry.getValue()); }); } /** - * Sets the value of a property by its index, updates only if it shall override. + * Sets the value of a property, updates only if it shall override. * * @param index the index of the property * @param state the state of the property * @param value the value of the property * @throws IllegalArgumentException if the value is invalid */ - private void setProperty(int index, State state, String value) { + private void setProperty(Feature feature, State state, String value) { + int index = feature.ordinal(); if (value != null && value.length() != 0) { - if (index == Feature.PREFER.ordinal()) { - if (!value.equals(PREFER_SYSTEM) && !value.equals(PREFER_PUBLIC)) { - CatalogMessages.reportIAE(new Object[]{value, Feature.PREFER.name()}, null); - } - } else if (index == Feature.DEFER.ordinal()) { - if (!value.equals(DEFER_TRUE) && !value.equals(DEFER_FALSE)) { - CatalogMessages.reportIAE(new Object[]{value, Feature.DEFER.name()}, null); - } - } else if (index == Feature.RESOLVE.ordinal()) { - if (!value.equals(RESOLVE_STRICT) && !value.equals(RESOLVE_CONTINUE) - && !value.equals(RESOLVE_IGNORE)) { - CatalogMessages.reportIAE(new Object[]{value, Feature.RESOLVE.name()}, null); - } - } else if (index == Feature.FILES.ordinal()) { - try { - String[] catalogFile = value.split(";[ ]*"); - for (String temp : catalogFile) { - if (Util.verifyAndGetURI(temp, null) == null) { - CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, null); - } - } - }catch (MalformedURLException | URISyntaxException | IllegalArgumentException ex) { - CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, ex); - } + if (state != State.APIPROPERTY) { + Util.validateFeatureInput(feature, value); } if (states[index] == null || state.compareTo(states[index]) >= 0) { values[index] = value; states[index] = state; } - } else { - if (state == State.SYSTEMPROPERTY || state == State.JAXPDOTPROPERTIES) { - CatalogMessages.reportIAE(new Object[]{value, Feature.values()[index].name()}, null); - } } } @@ -639,13 +614,13 @@ public class CatalogFeatures { if (cf.hasSystemProperty()) { String value = SecuritySupport.getSystemProperty(sysPropertyName); if (value != null && !value.equals("")) { - setProperty(cf.ordinal(), State.SYSTEMPROPERTY, value); + setProperty(cf, State.SYSTEMPROPERTY, value); return true; } value = SecuritySupport.readJAXPProperty(sysPropertyName); if (value != null && !value.equals("")) { - setProperty(cf.ordinal(), State.JAXPDOTPROPERTIES, value); + setProperty(cf, State.JAXPDOTPROPERTIES, value); return true; } } @@ -685,9 +660,7 @@ public class CatalogFeatures { * property */ public Builder with(Feature feature, String value) { - if (value == null || value.length() == 0) { - CatalogMessages.reportIAE(new Object[]{value, feature.name()}, null); - } + Util.validateFeatureInput(feature, value); values.put(feature, value); return this; } 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 6630424c15a..cbf77e5c9c0 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ class CatalogImpl extends GroupEntry implements Catalog { /* A list of catalog entry files from the input, excluding the current catalog. - Paths in the List are normalized. + URIs in the List are verified during input validation or property retrieval. */ List inputFiles; @@ -86,43 +86,44 @@ class CatalogImpl extends GroupEntry implements Catalog { SAXParser parser; /** - * Construct a Catalog with specified path. + * Construct a Catalog with specified URI. * - * @param file The path to a catalog file. + * @param uris the uri(s) to one or more catalogs * @throws CatalogException If an error happens while parsing the specified * catalog file. */ - public CatalogImpl(CatalogFeatures f, String... file) throws CatalogException { - this(null, f, file); + public CatalogImpl(CatalogFeatures f, URI... uris) throws CatalogException { + this(null, f, uris); } /** - * Construct a Catalog with specified path. + * Construct a Catalog with specified URI. * * @param parent The parent catalog - * @param file The path to a catalog file. + * @param uris the uri(s) to one or more catalogs * @throws CatalogException If an error happens while parsing the specified * catalog file. */ - public CatalogImpl(CatalogImpl parent, CatalogFeatures f, String... file) throws CatalogException { + public CatalogImpl(CatalogImpl parent, CatalogFeatures f, URI... uris) throws CatalogException { super(CatalogEntryType.CATALOG, parent); if (f == null) { throw new NullPointerException( formatMessage(CatalogMessages.ERR_NULL_ARGUMENT, new Object[]{"CatalogFeatures"})); } - if (file.length > 0) { - CatalogMessages.reportNPEOnNull("The path to the catalog file", file[0]); - } - init(f); //Path of catalog files - String[] catalogFile = file; - if (level == 0 && file.length == 0) { + String[] catalogFile = null; + if (level == 0 && uris.length == 0) { String files = features.get(Feature.FILES); if (files != null) { - catalogFile = files.split(";[ ]*"); + catalogFile = files.split(";"); + } + } else { + catalogFile = new String[uris.length]; + for (int i=0; i { - getCatalog(getSystemId(file)); + inputFiles.stream().forEach((uri) -> { + getCatalog(URI.create(uri)); }); } } @@ -454,12 +432,11 @@ class CatalogImpl extends GroupEntry implements Catalog { } CatalogImpl c = null; - String path = uri.toASCIIString(); if (verifyCatalogFile(uri)) { - c = getLoadedCatalog(path); + c = getLoadedCatalog(uri.toASCIIString()); if (c == null) { - c = new CatalogImpl(this, features, path); + c = new CatalogImpl(this, features, uri); c.load(); } } 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 7dd1e9cf873..f8ce697b266 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ */ package javax.xml.catalog; +import java.net.URI; /** * The Catalog Manager manages the creation of XML Catalogs and Catalog Resolvers. @@ -39,30 +40,36 @@ public final class CatalogManager { /** * Creates a {@code Catalog} object using the specified feature settings and - * path to one or more catalog files. + * uri(s) 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 {@code uris} is empty, system property {@code javax.xml.catalog.files}, + * as defined in {@link CatalogFeatures}, will be read to locate the initial + * list of catalog files. *

- * If more than one catalog files are specified through the paths argument or + * If multiple catalog files are specified through the {@code uris} 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. + * XML Catalogs, OASIS Standard V1.1, if a catalog entry is invalid, it + * is ignored. In case all entries are invalid, the resulting Catalog object + * will contain no Catalog elements. Any matching operation using the Catalog + * will return null. * * @param features the catalog features - * @param paths path(s) to one or more catalogs. + * @param uris uri(s) to one or more catalogs. * * @return an instance of a {@code Catalog} + * @throws IllegalArgumentException if either the URIs are not absolute + * or do not have a URL protocol handler for the URI scheme * @throws CatalogException If an error occurs while parsing the catalog + * @throws SecurityException if access to the resource is denied by the security manager */ - public static Catalog catalog(CatalogFeatures features, String... paths) { - CatalogImpl catalog = new CatalogImpl(features, paths); + public static Catalog catalog(CatalogFeatures features, URI... uris) { + Util.validateUrisSyntax(uris); + CatalogImpl catalog = new CatalogImpl(features, uris); catalog.load(); return catalog; } @@ -80,30 +87,36 @@ public final class CatalogManager { /** * Creates an instance of a {@code CatalogResolver} using the specified feature - * settings and path to one or more catalog files. + * settings and uri(s) 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 {@code uris} is empty, system property {@code javax.xml.catalog.files}, + * as defined in {@link CatalogFeatures}, will be read to locate the initial + * list of catalog files. *

- * If more than one catalog files are specified through the paths argument or + * If multiple catalog files are specified through the {@code uris} 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. + * XML Catalogs, OASIS Standard V1.1, if a catalog entry is invalid, it + * is ignored. In case all entries are invalid, the resulting CatalogResolver + * object will contain no valid catalog. Any resolution operation using the + * resolver therefore will return as no mapping is found. See {@link CatalogResolver} + * for the behavior when no mapping is found. * * @param features the catalog features - * @param paths the path(s) to one or more catalogs + * @param uris the uri(s) to one or more catalogs * * @return an instance of a {@code CatalogResolver} + * @throws IllegalArgumentException if either the URIs are not absolute + * or do not have a URL protocol handler for the URI scheme * @throws CatalogException If an error occurs while parsing the catalog + * @throws SecurityException if access to the resource is denied by the security manager */ - public static CatalogResolver catalogResolver(CatalogFeatures features, String... paths) { - Catalog catalog = catalog(features, paths); + public static CatalogResolver catalogResolver(CatalogFeatures features, URI... uris) { + Catalog catalog = catalog(features, uris); return new CatalogResolverImpl(catalog); } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java index 97a0cd57cc7..6a6996fa686 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,10 +24,11 @@ */ package javax.xml.catalog; -import jdk.xml.internal.SecuritySupport; +import java.net.URI; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; +import jdk.xml.internal.SecuritySupport; /** * Catalog Error messages @@ -38,6 +39,8 @@ final class CatalogMessages { public static final String ERR_INVALID_CATALOG = "InvalidCatalog"; public static final String ERR_INVALID_ENTRY_TYPE = "InvalidEntryType"; + public static final String ERR_URI_NOTABSOLUTE = "UriNotAbsolute"; + public static final String ERR_URI_NOTVALIDURL = "UriNotValidUrl"; public static final String ERR_INVALID_ARGUMENT = "InvalidArgument"; public static final String ERR_NULL_ARGUMENT = "NullArgument"; public static final String ERR_CIRCULAR_REFERENCE = "CircularReference"; @@ -120,7 +123,7 @@ final class CatalogMessages { * @param name the name of the argument * @param value the value of the argument */ - static void reportNPEOnNull(String name, String value) { + static void reportNPEOnNull(String name, Object value) { if (value == null) { throw new NullPointerException( formatMessage(ERR_NULL_ARGUMENT, new Object[]{name})); @@ -132,9 +135,9 @@ final class CatalogMessages { * @param arguments the arguments for formating the error message * @param cause the cause if any */ - static void reportIAE(Object[] arguments, Throwable cause) { + static void reportIAE(String key, Object[] arguments, Throwable cause) { throw new IllegalArgumentException( - formatMessage(ERR_INVALID_ARGUMENT, arguments), cause); + formatMessage(key, arguments), cause); } /** @@ -174,7 +177,7 @@ final class CatalogMessages { /** * Returns sanitized URI. - * @param uri an URI to be sanitized + * @param uri a URI to be sanitized */ static String sanitize(String uri) { if (uri == null) { diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties index 69341fdbd84..a1133ca9da5 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.properties @@ -31,6 +31,8 @@ InvalidEntryType = The entry type ''{0}'' is not valid. CircularReference = Circular reference is not allowed: ''{0}''. #errors +UriNotAbsolute = The specified URI ''{0}'' is not absolute. +UriNotValidUrl = The specified URI ''{0}'' is not a valid URL. InvalidArgument = The specified argument ''{0}'' (case sensitive) for ''{1}'' is not valid. NullArgument = The argument ''{0}'' can not be null. InvalidPath = The path ''{0}'' is invalid. diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java index 5f08c54cc12..64b2ea85071 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,6 @@ package javax.xml.catalog; import java.io.StringReader; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.nio.file.Paths; import javax.xml.catalog.BaseEntry.CatalogEntryType; import javax.xml.parsers.SAXParser; import javax.xml.transform.Source; @@ -94,25 +90,6 @@ class CatalogReader extends DefaultHandler implements EntityResolver, URIResolve this.parser = parser; } - /** - * Returns when the specified path is valid. - * @param path a path - * @return true if the path is valid, false otherwise - */ - boolean isValidPath(String path) { - boolean valid = true; - try { - Path p = Paths.get(new URI(path)); - if (!p.toFile().exists()) { - valid = false; - } - } catch (URISyntaxException ex) { - valid = false; - } - - return valid; - } - @Override public void startElement(String namespaceURI, String localName, diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java index ecf506f5cab..fe1b6f2177d 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ import org.xml.sax.InputSource; * {@link javax.xml.stream.XMLResolver} and {@link org.w3c.dom.ls.LSResourceResolver} * however, make no such distinction. * In consistent with the existing Java API, this CatalogResolver recognizes a - * system identifier as an URI and will search both {@code system} and {@code uri} + * system identifier as a URI and will search both {@code system} and {@code uri} * entries in a catalog in order to find a matching entry. *

* The search is started in the current catalog. If a match is found, @@ -137,9 +137,9 @@ public interface CatalogResolver extends EntityResolver, XMLResolver, * with the specified {@code href} attribute. The {@code href} attribute will * be used literally, with no attempt to be made absolute to the {@code base}. *

- * If the value is an URN, the {@code href} attribute is recognized as a + * If the value is a URN, the {@code href} attribute is recognized as a * {@code publicId}, and used to search {@code public} entries. - * If the value is an URI, it is taken as a {@code systemId}, and used to + * If the value is a URI, it is taken as a {@code systemId}, and used to * search both {@code system} and {@code uri} entries. * * @@ -219,7 +219,7 @@ public interface CatalogResolver extends EntityResolver, XMLResolver, * @param publicId the public identifier of the external entity being * referenced, or {@code null} if no public identifier was * supplied or if the resource is not an entity. - * @param systemId the system identifier, an URI reference of the + * @param systemId the system identifier, a URI reference of the * external resource being referenced * @param baseUri the absolute base URI, not used by the CatalogResolver * diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java index fe6223d9324..0977479ca9d 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ final class CatalogResolverImpl implements CatalogResolver { systemId = Normalizer.normalizeURI(Util.getNotNullOrEmpty(systemId)); publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId))); - //check whether systemId is an urn + //check whether systemId is a urn if (systemId != null && systemId.startsWith(Util.URN)) { systemId = Normalizer.decodeURN(systemId); if (publicId != null && !publicId.equals(systemId)) { @@ -123,7 +123,7 @@ final class CatalogResolverImpl implements CatalogResolver { return null; } - //check whether uri is an urn + //check whether uri is a urn if (uri != null && uri.startsWith(Util.URN)) { String publicId = Normalizer.decodeURN(uri); if (publicId != null) { @@ -131,7 +131,7 @@ final class CatalogResolverImpl implements CatalogResolver { } } - //if no match with a public id, continue search for an URI + //if no match with a public id, continue search for a URI if (result == null) { //remove fragment if any. int hashPos = uri.indexOf("#"); diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java index e04f8cdb363..b0dd80c733f 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,6 @@ package javax.xml.catalog; import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -217,7 +215,7 @@ class GroupEntry extends BaseEntry { * @param systemId The system identifier of the external entity being * referenced. * - * @return An URI string if a mapping is found, or null otherwise. + * @return a URI string if a mapping is found, or null otherwise. */ public String matchSystem(String systemId) { systemEntrySearched = true; @@ -285,7 +283,7 @@ class GroupEntry extends BaseEntry { * @param publicId The public identifier of the external entity being * referenced. * - * @return An URI string if a mapping is found, or null otherwise. + * @return a URI string if a mapping is found, or null otherwise. */ public String matchPublic(String publicId) { /* @@ -329,7 +327,7 @@ class GroupEntry extends BaseEntry { * * @param uri The URI reference of a resource. * - * @return An URI string if a mapping is found, or null otherwise. + * @return a URI string if a mapping is found, or null otherwise. */ public String matchURI(String uri) { String match = null; @@ -455,7 +453,7 @@ class GroupEntry extends BaseEntry { delegateCatalog = getLoadedCatalog(catalogId); if (delegateCatalog == null) { if (verifyCatalogFile(catalogURI)) { - delegateCatalog = new CatalogImpl(catalog, features, catalogId); + delegateCatalog = new CatalogImpl(catalog, features, catalogURI); delegateCatalog.load(); delegateCatalogs.put(catalogId, delegateCatalog); } @@ -504,7 +502,8 @@ class GroupEntry extends BaseEntry { } //Ignore it if it doesn't exist - if (!Files.exists(Paths.get(catalogURI))) { + if (Util.isFileUri(catalogURI) && + !Util.isFileUriExist(catalogURI, false)) { return false; } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java index 0c1aa295c9c..9f5b4987008 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ package javax.xml.catalog; import java.net.URL; /** - * Represents an uriEntry entry. + * Represents a uri entry. * * @since 9 */ @@ -36,7 +36,7 @@ final class UriEntry extends BaseEntry { URL uri; /** - * Construct a group entry. + * Construct a uri entry. * @param name The name attribute. * @param uri The uri attribute. */ diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java index f2b00a21ee6..bec119f1143 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,20 @@ package javax.xml.catalog; import java.io.File; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Iterator; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import static javax.xml.catalog.CatalogFeatures.DEFER_FALSE; +import static javax.xml.catalog.CatalogFeatures.DEFER_TRUE; +import javax.xml.catalog.CatalogFeatures.Feature; +import static javax.xml.catalog.CatalogFeatures.PREFER_PUBLIC; +import static javax.xml.catalog.CatalogFeatures.PREFER_SYSTEM; +import static javax.xml.catalog.CatalogFeatures.RESOLVE_CONTINUE; +import static javax.xml.catalog.CatalogFeatures.RESOLVE_IGNORE; +import static javax.xml.catalog.CatalogFeatures.RESOLVE_STRICT; import jdk.xml.internal.SecuritySupport; /** @@ -39,22 +46,25 @@ import jdk.xml.internal.SecuritySupport; * @since 9 */ class Util { + final static String URN = "urn:publicid:"; final static String PUBLICID_PREFIX = "-//"; final static String PUBLICID_PREFIX_ALT = "+//"; + final static String SCHEME_FILE = "file"; + final static String SCHEME_JAR = "jar"; + final static String SCHEME_JARFILE = "jar:file:"; /** * Finds an entry in the catalog that matches with the publicId or systemId. * - * The resolution follows the following rules determined by the prefer setting: + * The resolution follows the following rules determined by the prefer + * setting: * - * prefer "system": attempts to resolve with a system entry; - * attempts to resolve with a public entry when only - * publicId is specified. + * prefer "system": attempts to resolve with a system entry; attempts to + * resolve with a public entry when only publicId is specified. * - * prefer "public": attempts to resolve with a system entry; - * attempts to resolve with a public entry if no matching - * system entry is found. + * prefer "public": attempts to resolve with a system entry; attempts to + * resolve with a public entry if no matching system entry is found. * * If no match is found, continue searching uri entries * @@ -70,9 +80,9 @@ class Util { catalog.reset(); if (systemId != null) { /* - If a system identifier is specified, it is used no matter how - prefer is set. - */ + If a system identifier is specified, it is used no matter how + prefer is set. + */ resolvedSystemId = catalog.matchSystem(systemId); } @@ -91,7 +101,7 @@ class Util { if (resolvedSystemId == null) { Iterator iter = catalog.catalogs().iterator(); while (iter.hasNext()) { - resolvedSystemId = resolve((CatalogImpl)iter.next(), publicId, systemId); + resolvedSystemId = resolve((CatalogImpl) iter.next(), publicId, systemId); if (resolvedSystemId != null) { break; } @@ -102,73 +112,112 @@ class Util { return resolvedSystemId; } - /** - * Resolves the specified file path to an absolute systemId. If it is - * relative, it shall be resolved using the base or user.dir property if - * base is not specified. - * - * @param file The specified file path - * @param baseURI the base URI - * @return The URI - * @throws CatalogException if the specified file path can not be converted - * to a system id - */ - static URI verifyAndGetURI(String file, URL baseURI) - throws MalformedURLException, URISyntaxException, IllegalArgumentException { - URL filepath; - URI temp; - if (file != null && file.length() > 0) { - File f = new File(file); - - if (baseURI != null && !f.isAbsolute()) { - filepath = new URL(baseURI, fixSlashes(file)); - temp = filepath.toURI(); - } else { - temp = resolveURI(file); - } - //Paths.get may throw IllegalArgumentException - Path path = Paths.get(temp); - if (path.toFile().isFile()) { - return temp; - } + static void validateUrisSyntax(URI... uris) { + for (URI uri : uris) { + validateUriSyntax(uri); + } + } + + static void validateUrisSyntax(String... uris) { + for (String uri : uris) { + validateUriSyntax(URI.create(uri)); } - return null; } /** - * Resolves the specified uri. If the uri is relative, makes it absolute by - * the user.dir directory. + * Validate that the URI must be absolute and a valid URL. * - * @param uri The specified URI. - * @return The resolved URI + * Note that this method does not verify the existence of the resource. The + * Catalog standard requires that such resources be ignored. + * + * @param uri + * @throws IllegalArgumentException if the uri is not absolute and a valid + * URL */ - static URI resolveURI(String uri) throws MalformedURLException { - if (uri == null) { - uri = ""; + static void validateUriSyntax(URI uri) { + CatalogMessages.reportNPEOnNull("URI input", uri); + + if (!uri.isAbsolute()) { + CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTABSOLUTE, + new Object[]{uri}, null); } - URI temp = null; try { - URL url = new URL(uri); - temp = url.toURI(); - } catch (MalformedURLException | URISyntaxException mue) { - File file = new File(uri); - temp = file.toURI(); + // check if the scheme was valid + uri.toURL(); + } catch (MalformedURLException ex) { + CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL, + new Object[]{uri}, null); } - return temp; + // verify the resource exists where possible + if (isFileUri(uri)) { + if (!isFileUriExist(uri, false)) { + CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL, + new Object[]{uri}, null); + } + } } /** - * Replace backslashes with forward slashes. (URLs always use forward - * slashes.) + * Checks whether the URI is a file URI, including JAR file. * - * @param sysid The input system identifier. - * @return The same system identifier with backslashes turned into forward - * slashes. + * @param uri the specified URI. + * @return true if it is a file or JAR file URI, false otherwise */ - static String fixSlashes(String sysid) { - return sysid.replace('\\', '/'); + static boolean isFileUri(URI uri) { + if (SCHEME_FILE.equals(uri.getScheme()) + || SCHEME_JAR.equals(uri.getScheme())) { + return true; + } + return false; + } + + /** + * Verifies whether the file resource exists. + * + * @param uri the URI to locate the resource + * @param openJarFile a flag to indicate whether a JAR file should be + * opened. This operation may be expensive. + * @return true if the resource exists, false otherwise. + */ + static boolean isFileUriExist(URI uri, boolean openJarFile) { + if (uri != null && uri.isAbsolute()) { + if (null != uri.getScheme()) { + switch (uri.getScheme()) { + case SCHEME_FILE: + String path = uri.getPath(); + File f1 = new File(path); + if (f1.isFile()) { + return true; + } + break; + case SCHEME_JAR: + String tempUri = uri.toString(); + int pos = tempUri.indexOf("!"); + if (pos < 0) { + return false; + } + if (openJarFile) { + String jarFile = tempUri.substring(SCHEME_JARFILE.length(), pos); + String entryName = tempUri.substring(pos + 2); + try { + JarFile jf = new JarFile(jarFile); + JarEntry je = jf.getJarEntry(entryName); + if (je != null) { + return true; + } + } catch (IOException ex) { + return false; + } + } else { + return true; + } + break; + } + } + } + return false; } /** @@ -187,11 +236,12 @@ class Util { } /** - * Checks whether the specified string is null or empty, returns the original - * string with leading and trailing spaces removed if not. + * Checks whether the specified string is null or empty, returns the + * original string with leading and trailing spaces removed if not. + * * @param test the string to be tested - * @return the original string with leading and trailing spaces removed, - * or null if it is null or empty + * @return the original string with leading and trailing spaces removed, or + * null if it is null or empty * */ static String getNotNullOrEmpty(String test) { @@ -206,4 +256,39 @@ class Util { } } } + + /** + * Validates the input for features. + * + * @param f the feature + * @param value the value + * @throws IllegalArgumentException if the value is invalid for the feature + */ + static void validateFeatureInput(Feature f, String value) { + CatalogMessages.reportNPEOnNull(f.name(), value); + if (value.length() == 0) { + CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT, + new Object[]{value, f.name()}, null); + } + + if (f == Feature.PREFER) { + if (!value.equals(PREFER_SYSTEM) && !value.equals(PREFER_PUBLIC)) { + CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT, + new Object[]{value, Feature.PREFER.name()}, null); + } + } else if (f == Feature.DEFER) { + if (!value.equals(DEFER_TRUE) && !value.equals(DEFER_FALSE)) { + CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT, + new Object[]{value, Feature.DEFER.name()}, null); + } + } else if (f == Feature.RESOLVE) { + if (!value.equals(RESOLVE_STRICT) && !value.equals(RESOLVE_CONTINUE) + && !value.equals(RESOLVE_IGNORE)) { + CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT, + new Object[]{value, Feature.RESOLVE.name()}, null); + } + } else if (f == Feature.FILES) { + Util.validateUrisSyntax(value.split(";")); + } + } } diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java index 47506989742..e81a84b020b 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,7 @@ public class SpecifyCatalogTest { @Test public void specifyCatalogViaSysProps() { setSystemProperty(FEATURE_FILES, - getCatalogPath("specifyCatalog-sysProps.xml")); + getCatalogPath("specifyCatalog-sysProps.xml").toASCIIString()); checkResolutionOnEntityResolver(catalogResolver((String[]) null), "http://local/base/dtd/docSysPropsSys.dtd"); @@ -107,6 +107,6 @@ public class SpecifyCatalogTest { } private static CatalogFeatures createFeature(String catalogName) { - return builder().with(FILES, getCatalogPath(catalogName)).build(); + return builder().with(FILES, getCatalogPath(catalogName).toASCIIString()).build(); } } diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/dummy.xml b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/dummy.xml new file mode 100644 index 00000000000..f6fed01ba5a --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/dummy.xml @@ -0,0 +1 @@ + diff --git a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java index 01d45ff591b..36f4e239fa8 100644 --- a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java +++ b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,17 +25,16 @@ package catalog; import java.io.File; import java.io.IOException; +import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; - import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; - import jaxp.library.JAXPTestUtilities; /* @@ -115,20 +114,20 @@ final class CatalogTestUtils { } // Gets the paths of the specified catalogs. - private static String[] getCatalogPaths(String... catalogNames) { + private static URI[] getCatalogPaths(String... catalogNames) { return catalogNames == null ? null : Stream.of(catalogNames).map( catalogName -> getCatalogPath(catalogName)).collect( - Collectors.toList()).toArray(new String[0]); + Collectors.toList()).toArray(new URI[0]); } // Gets the paths of the specified catalogs. - static String getCatalogPath(String catalogName) { + static URI getCatalogPath(String catalogName) { return catalogName == null ? null - : JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles") - + catalogName; + : Paths.get(JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles") + + catalogName).toUri(); } /* ********** jaxp.properties ********** */ diff --git a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JarUtils.java b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JarUtils.java new file mode 100644 index 00000000000..bc579a352fe --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JarUtils.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 jaxp.library; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * This class consists exclusively of static utility methods that are useful + * for creating and manipulating JAR files. + */ + +public final class JarUtils { + private JarUtils() { } + + /** + * Creates a JAR file. + * + * Equivalent to {@code jar cfm -C

file...} + * + * The input files are resolved against the given directory. Any input + * files that are directories are processed recursively. + */ + public static void createJarFile(Path jarfile, Manifest man, Path dir, Path... file) + throws IOException + { + // create the target directory + Path parent = jarfile.getParent(); + if (parent != null) + Files.createDirectories(parent); + + List entries = new ArrayList<>(); + for (Path entry : file) { + Files.find(dir.resolve(entry), Integer.MAX_VALUE, + (p, attrs) -> attrs.isRegularFile()) + .map(e -> dir.relativize(e)) + .forEach(entries::add); + } + + try (OutputStream out = Files.newOutputStream(jarfile); + JarOutputStream jos = new JarOutputStream(out)) + { + if (man != null) { + JarEntry je = new JarEntry(JarFile.MANIFEST_NAME); + jos.putNextEntry(je); + man.write(jos); + jos.closeEntry(); + } + + for (Path entry : entries) { + String name = toJarEntryName(entry); + jos.putNextEntry(new JarEntry(name)); + Files.copy(dir.resolve(entry), jos); + jos.closeEntry(); + } + } + } + + /** + * Creates a JAR file. + * + * Equivalent to {@code jar cf -C file...} + * + * The input files are resolved against the given directory. Any input + * files that are directories are processed recursively. + */ + public static void createJarFile(Path jarfile, Path dir, Path... file) + throws IOException + { + createJarFile(jarfile, null, dir, file); + } + + /** + * Creates a JAR file. + * + * Equivalent to {@code jar cf -C file...} + * + * The input files are resolved against the given directory. Any input + * files that are directories are processed recursively. + */ + public static void createJarFile(Path jarfile, Path dir, String... input) + throws IOException + { + Path[] paths = Stream.of(input).map(Paths::get).toArray(Path[]::new); + createJarFile(jarfile, dir, paths); + } + + /** + * Creates a JAR file from the contents of a directory. + * + * Equivalent to {@code jar cf -C .} + */ + public static void createJarFile(Path jarfile, Path dir) throws IOException { + createJarFile(jarfile, dir, Paths.get(".")); + } + + /** + * Map a file path to the equivalent name in a JAR file + */ + private static String toJarEntryName(Path file) { + Path normalized = file.normalize(); + return normalized.subpath(0, normalized.getNameCount()) // drop root + .toString() + .replace(File.separatorChar, '/'); + } +} diff --git a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/SimpleHttpServer.java b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/SimpleHttpServer.java new file mode 100644 index 00000000000..290697d81c9 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/SimpleHttpServer.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 jaxp.library; + +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpContext; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.URI; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * A simple HTTP Server + */ +public class SimpleHttpServer { + HttpServer _httpserver; + ExecutorService _executor; + + String _address; + + String _context, _docroot; + int _port; + + public SimpleHttpServer(String context, String docroot) { + //let the system pick up an ephemeral port in a bind operation + this(0, context, docroot); + } + + public SimpleHttpServer(int port, String context, String docroot) { + _port = port; + _context = context; + _docroot = docroot; + } + + public void start() { + MyHttpHandler handler = new MyHttpHandler(_docroot); + InetSocketAddress addr = new InetSocketAddress(_port); + try { + _httpserver = HttpServer.create(addr, 0); + } catch (IOException ex) { + throw new RuntimeException("cannot create httpserver", ex); + } + + //TestHandler is mapped to /test + HttpContext ctx = _httpserver.createContext(_context, handler); + + _executor = Executors.newCachedThreadPool(); + _httpserver.setExecutor(_executor); + _httpserver.start(); + + _address = "http://localhost:" + _httpserver.getAddress().getPort(); + } + + public void stop() { + _httpserver.stop(2); + _executor.shutdown(); + } + + public String getAddress() { + return _address; + } + + static class MyHttpHandler implements HttpHandler { + + String _docroot; + + public MyHttpHandler(String docroot) { + _docroot = docroot; + } + + public void handle(HttpExchange t) + throws IOException { + InputStream is = t.getRequestBody(); + Headers map = t.getRequestHeaders(); + Headers rmap = t.getResponseHeaders(); + OutputStream os = t.getResponseBody(); + URI uri = t.getRequestURI(); + String path = uri.getPath(); + + + while (is.read() != -1) ; + is.close(); + + File f = new File(_docroot, path); + if (!f.exists()) { + notfound(t, path); + return; + } + + String method = t.getRequestMethod(); + if (method.equals("HEAD")) { + rmap.set("Content-Length", Long.toString(f.length())); + t.sendResponseHeaders(200, -1); + t.close(); + } else if (!method.equals("GET")) { + t.sendResponseHeaders(405, -1); + t.close(); + return; + } + + if (path.endsWith(".html") || path.endsWith(".htm")) { + rmap.set("Content-Type", "text/html"); + } else { + rmap.set("Content-Type", "text/plain"); + } + + t.sendResponseHeaders (200, f.length()); + + FileInputStream fis = new FileInputStream(f); + int count = 0; + try { + byte[] buf = new byte[16 * 1024]; + int len; + while ((len = fis.read(buf)) != -1) { + os.write(buf, 0, len); + count += len; + } + } catch (IOException e) { + e.printStackTrace(); + } + fis.close(); + os.close(); + } + + void moved(HttpExchange t) throws IOException { + Headers req = t.getRequestHeaders(); + Headers map = t.getResponseHeaders(); + URI uri = t.getRequestURI(); + String host = req.getFirst("Host"); + String location = "http://" + host + uri.getPath() + "/"; + map.set("Content-Type", "text/html"); + map.set("Location", location); + t.sendResponseHeaders(301, -1); + t.close(); + } + + void notfound(HttpExchange t, String p) throws IOException { + t.getResponseHeaders().set("Content-Type", "text/html"); + t.sendResponseHeaders(404, 0); + OutputStream os = t.getResponseBody(); + String s = "

File not found

"; + s = s + p + "

"; + os.write(s.getBytes()); + os.close(); + t.close(); + } + } + +} diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogAccessTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogAccessTest.java new file mode 100644 index 00000000000..d2e7edee6f0 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogAccessTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 catalog; + +import java.net.URI; +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogManager; +import javax.xml.catalog.CatalogResolver; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; +import static jaxp.library.JAXPTestUtilities.tryRunWithAllPerm; + +/* + * @test + * @bug 8171243 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @run testng/othervm -DrunSecMngr=true catalog.CatalogAccessTest + * @summary the Catalog API grants no privilege to external resources. This test + * verifies that SecurityException will be thrown if access to resources is denied + * by the security manager. + */ +@Listeners({jaxp.library.BasePolicy.class}) +public class CatalogAccessTest { + static final CatalogFeatures FEATURES = CatalogFeatures.builder(). + with(CatalogFeatures.Feature.PREFER, "system").build(); + + /* + * Verifies that the SecurityException is thrown if access to the resource is + * denied by the security manager. + */ + @Test(dataProvider = "accessTest", expectedExceptions = SecurityException.class) + public void testSecurity(String cfile, String sysId, String pubId) throws Exception { + CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, URI.create(cfile)); + InputSource is = cr.resolveEntity(pubId, sysId); + Assert.fail("Failed to throw SecurityException"); + } + + /* + DataProvider: used for SecurityException testing + Data columns: + catalog uri, systemId, publicId + */ + @DataProvider(name = "accessTest") + Object[][] getDataForAccessTest() throws Exception { + String systemId = "http://www.sys00test.com/rewrite.dtd"; + String publicId = "PUB-404"; + String urlFile = tryRunWithAllPerm(() -> + getClass().getResource("rewriteSystem_id.xml").toExternalForm()); + return new Object[][]{ + {urlFile, systemId, publicId} + }; + } +} diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogFileInputTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogFileInputTest.java new file mode 100644 index 00000000000..44d52295bd7 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogFileInputTest.java @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 catalog; + +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import static java.nio.file.StandardOpenOption.APPEND; +import static java.nio.file.StandardOpenOption.CREATE; +import javax.xml.catalog.Catalog; +import javax.xml.catalog.CatalogException; +import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogManager; +import javax.xml.catalog.CatalogResolver; +import static jaxp.library.JAXPTestUtilities.getSystemProperty; +import jaxp.library.JarUtils; +import jaxp.library.SimpleHttpServer; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; + +/* + * @test + * @bug 8151154 8171243 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @run testng/othervm catalog.CatalogFileInputTest + * @summary Verifies that the Catalog API accepts valid URIs only; + Verifies that the CatalogFeatures' builder throws + * IllegalArgumentException on invalid file inputs. + * This test was splitted from CatalogTest.java due to + * JDK-8168968, it has to only run without SecurityManager + * because an ACE will be thrown for invalid path. + */ +@Listeners({jaxp.library.FilePolicy.class, jaxp.library.NetAccessPolicy.class}) +public class CatalogFileInputTest extends CatalogSupportBase { + + static final CatalogFeatures FEATURES = CatalogFeatures.builder(). + with(CatalogFeatures.Feature.PREFER, "system").build(); + static String USER_DIR = getSystemProperty("user.dir"); + static String CLS_DIR = getSystemProperty("test.classes"); + static String SRC_DIR = System.getProperty("test.src"); + static String JAR_CONTENT = "META-INF"; + final static String SCHEME_JARFILE = "jar:"; + static final String REMOTE_FILE_LOCATION = "/jar/META-INF"; + static final String DOCROOT = SRC_DIR; + static final String TESTCONTEXT = REMOTE_FILE_LOCATION; //mapped to local file path + SimpleHttpServer _httpserver; + String _remoteFilePath; + + /* + * Initializing fields + */ + @BeforeClass + public void setUpClass() throws Exception { + super.setUp(); + + // set up HttpServer + _httpserver = new SimpleHttpServer(TESTCONTEXT, DOCROOT); + _httpserver.start(); + _remoteFilePath = _httpserver.getAddress() + REMOTE_FILE_LOCATION; + + } + + @AfterClass + protected void tearDown() throws Exception { + if (_httpserver != null) { + _httpserver.stop(); + } + } + + /* + * Verifies that the Catalog can be created with file system paths including JAR + * and http URL, and used to resolve a systemId as expected. + */ + @Test(dataProvider = "acceptedURI") + public void testMatch(String uri, String sysId, String pubId, + String expectedId, String msg) throws Exception { + CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, URI.create(uri)); + InputSource is = cr.resolveEntity(pubId, sysId); + Assert.assertNotNull(is, msg); + Assert.assertEquals(expectedId, is.getSystemId(), msg); + } + + @Test(dataProvider = "invalidCatalog") + public void testEmptyCatalog(String uri, String publicId, String msg) { + Catalog c = CatalogManager.catalog(FEATURES, uri != null? URI.create(uri) : null); + Assert.assertNull(c.matchSystem(publicId), msg); + } + + @Test(dataProvider = "invalidCatalog", expectedExceptions = CatalogException.class) + public void testCatalogResolverWEmptyCatalog(String uri, String publicId, String msg) { + CatalogResolver cr = CatalogManager.catalogResolver( + CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, "strict").build(), + uri != null? URI.create(uri) : null); + InputSource is = cr.resolveEntity(publicId, ""); + } + + @Test(dataProvider = "invalidCatalog") + public void testCatalogResolverWEmptyCatalog1(String uri, String publicId, String msg) { + CatalogResolver cr = CatalogManager.catalogResolver( + CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, "continue").build(), + uri != null? URI.create(uri) : null); + Assert.assertNull(cr.resolveEntity(publicId, ""), msg); + } + + @Test(dataProvider = "invalidInput", expectedExceptions = IllegalArgumentException.class) + public void testFileInput(String file) { + CatalogFeatures features = CatalogFeatures.builder() + .with(CatalogFeatures.Feature.FILES, file) + .build(); + } + + @Test(dataProvider = "invalidInput", expectedExceptions = IllegalArgumentException.class) + public void testInvalidUri(String file) { + CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, file != null? URI.create(file) : null); + } + + @Test(dataProvider = "invalidInput", expectedExceptions = IllegalArgumentException.class) + public void testInvalidUri1(String file) { + Catalog c = CatalogManager.catalog(FEATURES, file != null? URI.create(file) : null); + System.err.println("Catalog =" + c); + } + + + @Test(expectedExceptions = NullPointerException.class) + public void testNullFileInput() { + CatalogFeatures features = CatalogFeatures.builder() + .with(CatalogFeatures.Feature.FILES, null) + .build(); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullUri() { + URI uri = null; + CatalogResolver cr = CatalogManager.catalogResolver(FEATURES, uri); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullUri1() { + URI uri = null; + Catalog c = CatalogManager.catalog(FEATURES, uri); + } + + String systemId = "http://www.sys00test.com/rewrite.dtd"; + String publicId = "PUB-404"; + String expected = "http://www.groupxmlbase.com/dtds/rewrite.dtd"; + String errMsg = "Relative rewriteSystem with xml:base at group level failed"; + + /* + DataProvider: used to verify CatalogResolver's resolveEntity function. + Data columns: + catalog, systemId, publicId, expectedUri, msg + */ + @DataProvider(name = "acceptedURI") + Object[][] getData() throws Exception { + String filename = "rewriteSystem_id.xml"; + String urlFile = getClass().getResource(filename).toExternalForm(); + String urlHttp = _remoteFilePath + "/jax-ws-catalog.xml"; + String remoteXSD = _remoteFilePath + "/catalog/ws-addr.xsd"; + File file = new File(CLS_DIR + "/JDK8171243.jar!/META-INF/jax-ws-catalog.xml"); + String jarPath = SCHEME_JARFILE + file.toURI().toString(); + String xsd = jarPath.substring(0, jarPath.lastIndexOf("/")) + "/catalog/ws-addr.xsd"; + + // create JAR file + try { + JarUtils.createJarFile(Paths.get(CLS_DIR + "/JDK8171243.jar"), + Paths.get(SRC_DIR + "/jar"), JAR_CONTENT); + } catch (IOException ex) { + Assert.fail("Failed to create JAR: " + ex.getMessage()); + } + + return new Object[][]{ + // URL + {urlFile, systemId, publicId, expected, errMsg}, + {urlHttp, "http://www.w3.org/2006/03/addressing/ws-addr.xsd", "", remoteXSD, "http test failed."}, + // JAR file + {jarPath, "http://www.w3.org/2006/03/addressing/ws-addr.xsd", "", xsd, "jar file test failed."}, + }; + } + + /* + * DataProvider: invalid catalog result in empty catalog + * Note: the difference from invalidInput is that invalidInput is syntactically + * rejected with an IAE. + */ + @DataProvider(name = "invalidCatalog") + public Object[][] getInvalidCatalog() throws Exception { + String catalogUri = getClass().getResource("catalog_invalid.xml").toExternalForm(); + return new Object[][]{ + {catalogUri, "-//W3C//DTD XHTML 1.0 Strict//EN", + "The catalog is invalid, attempting to match the public entry shall return null."} + }; + } + + /* + * DataProvider: a list of invalid inputs, expects IAE + * Note: exclude null since NPE would have been expected + */ + @DataProvider(name = "invalidInput") + public Object[][] getFiles() throws Exception { + String filename = "rewriteSystem_id.xml"; + copyFile(Paths.get(SRC_DIR + "/" + filename), Paths.get(filename)); + String absolutePath = getClass().getResource(filename).getFile(); + + return new Object[][]{ + {""}, + {"file:a/b\\c"}, + {"file:/../../.."}, + {"c:/te:t"}, + {"c:/te?t"}, + {"c/te*t"}, + {"in|valid.txt"}, + {"shema:invalid.txt"}, + // relative file path + {filename}, + // absolute file path + {absolutePath} + }; + } + + /* + DataProvider: a list of invalid inputs + */ + @DataProvider(name = "nullTest") + public Object[][] getNull() throws Exception { + + return new Object[][]{ + {null}, + }; + } + + void copyFile(Path src, Path target) throws Exception { + + try (InputStream in = Files.newInputStream(src); + BufferedReader reader + = new BufferedReader(new InputStreamReader(in)); + OutputStream out = new BufferedOutputStream( + Files.newOutputStream(target, CREATE, APPEND)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out))) { + String line = null; + while ((line = reader.readLine()) != null) { + bw.write(line); + } + } catch (IOException x) { + throw new Exception(x.getMessage()); + } + } +} diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogInvalidPathTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogInvalidPathTest.java deleted file mode 100644 index e8da1d0c3f4..00000000000 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogInvalidPathTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 catalog; - -import javax.xml.catalog.CatalogFeatures; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/* - * @test - * @bug 8151154 - * @run testng/othervm catalog.CatalogInvalidPathTest - * @summary Verifies that the CatalogFeatures' builder throws - * IllegalArgumentException on invalid file inputs. - * This test was splitted from CatalogTest.java due to - * JDK-8168968, it has to only run without SecurityManager - * because an ACE will be thrown for invalid path. - */ -public class CatalogInvalidPathTest { - /* - DataProvider: for testing the verification of file paths by - the CatalogFeatures builder - */ - @DataProvider(name = "invalidPaths") - public Object[][] getFiles() { - return new Object[][]{ - {null}, - {""}, - {"file:a/b\\c"}, - {"file:/../../.."}, - {"c:/te:t"}, - {"c:/te?t"}, - {"c/te*t"}, - {"in|valid.txt"}, - {"shema:invalid.txt"}, - }; - } - - @Test(dataProvider = "invalidPaths", expectedExceptions = IllegalArgumentException.class) - public void testFileInput(String file) { - CatalogFeatures features = CatalogFeatures.builder() - .with(CatalogFeatures.Feature.FILES, file) - .build(); - } -} diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java index 236e5cda0dc..0f603014c88 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,13 @@ import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.nio.file.Paths; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; import javax.xml.XMLConstants; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogResolver; @@ -133,8 +140,8 @@ public class CatalogSupportBase { dtd_system = filepath + "system.dtd"; dtd_systemResolved = ""; - xml_catalog = filepath + "CatalogSupport.xml"; - xml_bogus_catalog = filepath + "CatalogSupport_bogus.xml"; + xml_catalog = Paths.get(filepath + "CatalogSupport.xml").toUri().toASCIIString(); + xml_bogus_catalog = Paths.get(filepath + "CatalogSupport_bogus.xml").toUri().toASCIIString(); xml_xInclude = "\n" + " 0) { result = c.matchPublic(publicId); @@ -430,8 +434,9 @@ public class CatalogTest extends CatalogSupportBase { * system entry is found. */ @Test(dataProvider = "resolveWithPrefer") - public void resolveWithPrefer(String prefer, String cfile, String publicId, String systemId, String expected) { - String catalogFile = getClass().getResource(cfile).getFile(); + public void resolveWithPrefer(String prefer, String cfile, String publicId, + String systemId, String expected) throws Exception { + URI catalogFile = getClass().getResource(cfile).toURI(); CatalogFeatures f = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).with(CatalogFeatures.Feature.RESOLVE, "ignore").build(); CatalogResolver catalogResolver = CatalogManager.catalogResolver(f, catalogFile); String result = catalogResolver.resolveEntity(publicId, systemId).getSystemId(); @@ -445,8 +450,8 @@ public class CatalogTest extends CatalogSupportBase { * be loaded is determined by the defer attribute. */ @Test(dataProvider = "invalidAltCatalogs", expectedExceptions = CatalogException.class) - public void testDeferAltCatalogs(String file) { - String catalogFile = getClass().getResource(file).getFile(); + public void testDeferAltCatalogs(String file) throws Exception { + URI catalogFile = getClass().getResource(file).toURI(); CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "true").build(); /* Since the defer attribute is set to false in the specified catalog file, @@ -462,8 +467,8 @@ public class CatalogTest extends CatalogSupportBase { * PREFER from Features API taking precedence over catalog file */ @Test - public void testJDK8146237() { - String catalogFile = getClass().getResource("JDK8146237_catalog.xml").getFile(); + public void testJDK8146237() throws Exception { + URI catalogFile = getClass().getResource("JDK8146237_catalog.xml").toURI(); try { CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, "system").build(); @@ -482,8 +487,8 @@ public class CatalogTest extends CatalogSupportBase { Verifies that the resulting systemId does not contain duplicate slashes */ @Test - public void testRewriteSystem() { - String catalog = getClass().getResource("rewriteCatalog.xml").getFile(); + public void testRewriteSystem() throws Exception { + URI catalog = getClass().getResource("rewriteCatalog.xml").toURI(); try { CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); @@ -500,8 +505,8 @@ public class CatalogTest extends CatalogSupportBase { Verifies that the resulting systemId does not contain duplicate slashes */ @Test - public void testRewriteUri() { - String catalog = getClass().getResource("rewriteCatalog.xml").getFile(); + public void testRewriteUri() throws Exception { + URI catalog = getClass().getResource("rewriteCatalog.xml").toURI(); try { @@ -519,18 +524,18 @@ public class CatalogTest extends CatalogSupportBase { */ @Test(expectedExceptions = NullPointerException.class) public void testFeatureNull() { - CatalogResolver resolver = CatalogManager.catalogResolver(null, ""); + CatalogResolver resolver = CatalogManager.catalogResolver(null, null); } /* @bug 8144966 - Verifies that passing null as the path will result in a NPE. + Verifies that passing null as the URI will result in a NPE. */ @Test(expectedExceptions = NullPointerException.class) public void testPathNull() { - String path = null; - CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), path); + URI uri = null; + CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), uri); } /* @@ -540,10 +545,11 @@ public class CatalogTest extends CatalogSupportBase { that matches the expected value. */ @Test(dataProvider = "catalog") - public void testCatalogResolver(String test, String expected, String catalogFile, String xml, SAXParser saxParser) { - String catalog = null; + public void testCatalogResolver(String test, String expected, String catalogFile, + String xml, SAXParser saxParser) throws Exception { + URI catalog = null; if (catalogFile != null) { - catalog = getClass().getResource(catalogFile).getFile(); + catalog = getClass().getResource(catalogFile).toURI(); } String url = getClass().getResource(xml).getFile(); try { @@ -565,8 +571,8 @@ public class CatalogTest extends CatalogSupportBase { catalog is provided, the resolver will throw an exception by default. */ @Test - public void testInvalidCatalog() { - String catalog = getClass().getResource("catalog_invalid.xml").getFile(); + public void testInvalidCatalog() throws Exception { + URI catalog = getClass().getResource("catalog_invalid.xml").toURI(); String test = "testInvalidCatalog"; try { @@ -590,7 +596,7 @@ public class CatalogTest extends CatalogSupportBase { */ @Test public void testIgnoreInvalidCatalog() { - String catalog = getClass().getResource("catalog_invalid.xml").getFile(); + String catalog = getClass().getResource("catalog_invalid.xml").toExternalForm(); CatalogFeatures f = CatalogFeatures.builder() .with(Feature.FILES, catalog) .with(Feature.PREFER, "public") @@ -600,7 +606,7 @@ public class CatalogTest extends CatalogSupportBase { String test = "testInvalidCatalog"; try { - CatalogResolver resolver = CatalogManager.catalogResolver(f, ""); + CatalogResolver resolver = CatalogManager.catalogResolver(f); String actualSystemId = resolver.resolveEntity(null, "http://remote/xml/dtd/sys/alice/docAlice.dtd").getSystemId(); System.out.println("testIgnoreInvalidCatalog: expected [null]"); System.out.println("testIgnoreInvalidCatalog: expected [null]"); diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/MANIFEST.MF b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..81f87a7e492 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Created-By: 9-ea (Oracle Corporation) + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/catalog/ws-addr.xsd b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/catalog/ws-addr.xsd new file mode 100644 index 00000000000..47362edbe22 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/catalog/ws-addr.xsd @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/jax-ws-catalog.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/jax-ws-catalog.xml new file mode 100644 index 00000000000..9de01d468e8 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/jar/META-INF/jax-ws-catalog.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 7481e63f4ea0fb5e578c57b1db10cc6654993920 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 11 Jan 2017 13:08:45 -0800 Subject: [PATCH 058/154] 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar Reviewed-by: rriggs, dfuchs, lancea, alanb --- .../com/sun/xml/internal/ws/util/xml/XmlUtil.java | 13 +++++++------ .../classes/com/sun/tools/internal/xjc/Options.java | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java index 09eaa938b46..d84fa5e7d11 100644 --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java +++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.lang.reflect.Method; +import java.net.URI; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; @@ -332,13 +333,13 @@ public class XmlUtil { * (com.sun.org.apache.xml.internal) for modular runtime. */ private static EntityResolver createCatalogResolver(ArrayList urls) throws Exception { - // Prepare array of catalog paths - String[] paths = urls.stream() - .map(u -> u.toExternalForm()) - .toArray(c -> new String[c]); + // Prepare array of catalog URIs + URI[] uris = urls.stream() + .map(u -> URI.create(u.toExternalForm())) + .toArray(URI[]::new); //Create CatalogResolver with new JDK9+ API - return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, paths); + return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, uris); } // Cache CatalogFeatures instance for future usages. diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java index bce8f27cbc2..10c1bda5157 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -777,13 +777,13 @@ public class Options * Adds a new catalog file. */ public void addCatalog(File catalogFile) throws IOException { - String newUrl = catalogFile.getPath(); + URI newUrl = catalogFile.toURI(); if (!catalogUrls.contains(newUrl)) { catalogUrls.add(newUrl); } try { entityResolver = CatalogManager.catalogResolver(catalogFeatures, - catalogUrls.toArray(new String[0])); + catalogUrls.stream().toArray(URI[]::new)); } catch (Exception ex) { entityResolver = null; } @@ -791,7 +791,7 @@ public class Options // Since javax.xml.catalog is unmodifiable we need to track catalog // URLs added and create new catalog each time addCatalog is called - private final ArrayList catalogUrls = new ArrayList(); + private final ArrayList catalogUrls = new ArrayList<>(); // Cache CatalogFeatures instance for future usages. // Resolve feature is set to "continue" value for backward compatibility. From 700685ceafca967a5317fedbb40459a87fb5647f Mon Sep 17 00:00:00 2001 From: Prem Balakrishnan Date: Thu, 12 Jan 2017 12:21:47 +0530 Subject: [PATCH 059/154] 8172559: [PIT][TEST_BUG] Move @test to be 1st annotation in java/awt/image/Raster/TestChildRasterOp.java Reviewed-by: aghaisas, psadhukhan --- jdk/test/java/awt/image/Raster/TestChildRasterOp.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/awt/image/Raster/TestChildRasterOp.java b/jdk/test/java/awt/image/Raster/TestChildRasterOp.java index 35ab5706816..e56429af6a9 100644 --- a/jdk/test/java/awt/image/Raster/TestChildRasterOp.java +++ b/jdk/test/java/awt/image/Raster/TestChildRasterOp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,8 +22,8 @@ */ /** - * @bug 8130737 * @test + * @bug 8130737 8172559 * @summary test no exception rasterop for child raster with non-zero offset */ From 9be23d7e0f00f16beb34f674b74be1ccb061ef04 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 12 Jan 2017 10:08:16 +0100 Subject: [PATCH 060/154] 8172562: Changing log level on Javadoc causes total rebuild Reviewed-by: erikj, tbell --- make/Javadoc.gmk | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 00e2db34abd..e785f68b1d1 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -1,4 +1,4 @@ -# Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -235,10 +235,6 @@ define SetupJavadocGenerationBody $1_OPTIONS += --add-modules $$(call CommaList, $$($1_MODULES)) - ifneq ($$(LOG_LEVEL), trace) - $1_OPTIONS += -quiet - endif - ifneq ($$($1_DISABLED_DOCLINT), ) # Create a string like ",-syntax,-html" $1_DOCLINT_EXCEPTIONS := ,$$(call CommaList, $$(addprefix -, $$($1_DISABLED_DOCLINT))) @@ -292,6 +288,13 @@ define SetupJavadocGenerationBody $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ $$(SUPPORT_OUTPUTDIR)/docs/$1.vardeps) + # Do not store debug level options in VARDEPS. + ifneq ($$(LOG_LEVEL), trace) + $1_OPTIONS += -quiet + else + $1_OPTIONS += -verbose + endif + $1_PACKAGE_DEPS := $$(call CacheFind, $$(wildcard $$(foreach p, \ $$(subst .,/,$$(strip $$($1_PACKAGES))), \ $$(addsuffix /$$p, $$(wildcard $$(JAVADOC_SOURCE_DIRS)))))) From 3205047fa1a10ae58aa900f0b4c1a28b6cb2012c Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 12 Jan 2017 10:30:27 +0100 Subject: [PATCH 061/154] 8172702: Remove left-over OPENJDK_TARGET_CPU_JLI_CFLAGS Reviewed-by: erikj --- common/autoconf/buildjdk-spec.gmk.in | 1 - 1 file changed, 1 deletion(-) diff --git a/common/autoconf/buildjdk-spec.gmk.in b/common/autoconf/buildjdk-spec.gmk.in index d6abc423239..dbb4fcb1e6d 100644 --- a/common/autoconf/buildjdk-spec.gmk.in +++ b/common/autoconf/buildjdk-spec.gmk.in @@ -68,7 +68,6 @@ LDFLAGS_JDKLIB := @OPENJDK_BUILD_LDFLAGS_JDKLIB@ CFLAGS_JDKEXE := @OPENJDK_BUILD_CFLAGS_JDKEXE@ CXXFLAGS_JDKEXE := @OPENJDK_BUILD_CXXFLAGS_JDKEXE@ LDFLAGS_JDKEXE := @OPENJDK_BUILD_LDFLAGS_JDKEXE@ -OPENJDK_TARGET_CPU_JLI_CFLAGS := @OPENJDK_BUILD_CPU_JLI_CFLAGS@ JVM_CFLAGS := @OPENJDK_BUILD_JVM_CFLAGS@ JVM_LDFLAGS := @OPENJDK_BUILD_JVM_LDFLAGS@ From 186fec9a8a6aeb739ebecd2233c25fe119e039f6 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 12 Jan 2017 11:41:51 +0000 Subject: [PATCH 062/154] 8168149: Examine the behavior of jmod command-line options - repeating vs last one wins Reviewed-by: mchung --- .../classes/jdk/tools/jmod/JmodTask.java | 129 ++++++++++-------- jdk/test/tools/jmod/JmodTest.java | 72 +++++++++- 2 files changed, 145 insertions(+), 56 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java index beb70184f18..4a8839ee16a 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java @@ -1088,34 +1088,58 @@ public class JmodTask { } } - static class ClassPathConverter implements ValueConverter { - static final ValueConverter INSTANCE = new ClassPathConverter(); + /** + * An abstract converter that given a string representing a list of paths, + * separated by the File.pathSeparator, returns a List of java.nio.Path's. + * Specific subclasses should do whatever validation is required on the + * individual path elements, if any. + */ + static abstract class AbstractPathConverter implements ValueConverter> { + @Override + public List convert(String value) { + List paths = new ArrayList<>(); + String[] pathElements = value.split(File.pathSeparator); + for (String pathElement : pathElements) { + paths.add(toPath(pathElement)); + } + return paths; + } + + @SuppressWarnings("unchecked") + @Override + public Class> valueType() { + return (Class>)(Object)List.class; + } + + @Override public String valuePattern() { return "path"; } + + abstract Path toPath(String path); + } + + static class ClassPathConverter extends AbstractPathConverter { + static final ValueConverter> INSTANCE = new ClassPathConverter(); @Override - public Path convert(String value) { + public Path toPath(String value) { try { Path path = CWD.resolve(value); if (Files.notExists(path)) throw new CommandException("err.path.not.found", path); - if (! (Files.isDirectory(path) || - (Files.isRegularFile(path) && path.toString().endsWith(".jar")))) + if (!(Files.isDirectory(path) || + (Files.isRegularFile(path) && path.toString().endsWith(".jar")))) throw new CommandException("err.invalid.class.path.entry", path); return path; } catch (InvalidPathException x) { throw new CommandException("err.path.not.valid", value); } } - - @Override public Class valueType() { return Path.class; } - - @Override public String valuePattern() { return "path"; } } - static class DirPathConverter implements ValueConverter { - static final ValueConverter INSTANCE = new DirPathConverter(); + static class DirPathConverter extends AbstractPathConverter { + static final ValueConverter> INSTANCE = new DirPathConverter(); @Override - public Path convert(String value) { + public Path toPath(String value) { try { Path path = CWD.resolve(value); if (Files.notExists(path)) @@ -1127,10 +1151,6 @@ public class JmodTask { throw new CommandException("err.path.not.valid", value); } } - - @Override public Class valueType() { return Path.class; } - - @Override public String valuePattern() { return "path"; } } static class ExtractDirPathConverter implements ValueConverter { @@ -1142,12 +1162,6 @@ public class JmodTask { if (Files.exists(path)) { if (!Files.isDirectory(path)) throw new CommandException("err.cannot.create.dir", path); - } else { - try { - Files.createDirectories(path); - } catch (IOException ioe) { - throw new CommandException("err.cannot.create.dir", path); - } } return path; } catch (InvalidPathException x) { @@ -1316,22 +1330,19 @@ public class JmodTask { options = new Options(); parser.formatHelpWith(new JmodHelpFormatter(options)); - OptionSpec classPath + OptionSpec> classPath = parser.accepts("class-path", getMessage("main.opt.class-path")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(ClassPathConverter.INSTANCE); - OptionSpec cmds + OptionSpec> cmds = parser.accepts("cmds", getMessage("main.opt.cmds")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); - OptionSpec config + OptionSpec> config = parser.accepts("config", getMessage("main.opt.config")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); OptionSpec dir @@ -1359,22 +1370,19 @@ public class JmodTask { OptionSpec helpExtra = parser.accepts("help-extra", getMessage("main.opt.help-extra")); - OptionSpec headerFiles + OptionSpec> headerFiles = parser.accepts("header-files", getMessage("main.opt.header-files")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); - OptionSpec libs + OptionSpec> libs = parser.accepts("libs", getMessage("main.opt.libs")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); - OptionSpec legalNotices + OptionSpec> legalNotices = parser.accepts("legal-notices", getMessage("main.opt.legal-notices")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); @@ -1383,17 +1391,15 @@ public class JmodTask { .withRequiredArg() .describedAs(getMessage("main.opt.main-class.arg")); - OptionSpec manPages + OptionSpec> manPages = parser.accepts("man-pages", getMessage("main.opt.man-pages")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); - OptionSpec modulePath + OptionSpec> modulePath = parser.acceptsAll(Set.of("p", "module-path"), getMessage("main.opt.module-path")) .withRequiredArg() - .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); OptionSpec moduleVersion @@ -1452,48 +1458,48 @@ public class JmodTask { } if (opts.has(classPath)) - options.classpath = opts.valuesOf(classPath); + options.classpath = getLastElement(opts.valuesOf(classPath)); if (opts.has(cmds)) - options.cmds = opts.valuesOf(cmds); + options.cmds = getLastElement(opts.valuesOf(cmds)); if (opts.has(config)) - options.configs = opts.valuesOf(config); + options.configs = getLastElement(opts.valuesOf(config)); if (opts.has(dir)) - options.extractDir = opts.valueOf(dir); + options.extractDir = getLastElement(opts.valuesOf(dir)); if (opts.has(dryrun)) options.dryrun = true; if (opts.has(excludes)) - options.excludes = opts.valuesOf(excludes); + options.excludes = opts.valuesOf(excludes); // excludes is repeatable if (opts.has(libs)) - options.libs = opts.valuesOf(libs); + options.libs = getLastElement(opts.valuesOf(libs)); if (opts.has(headerFiles)) - options.headerFiles = opts.valuesOf(headerFiles); + options.headerFiles = getLastElement(opts.valuesOf(headerFiles)); if (opts.has(manPages)) - options.manPages = opts.valuesOf(manPages); + options.manPages = getLastElement(opts.valuesOf(manPages)); if (opts.has(legalNotices)) - options.legalNotices = opts.valuesOf(legalNotices); + options.legalNotices = getLastElement(opts.valuesOf(legalNotices)); if (opts.has(modulePath)) { - Path[] dirs = opts.valuesOf(modulePath).toArray(new Path[0]); + Path[] dirs = getLastElement(opts.valuesOf(modulePath)).toArray(new Path[0]); options.moduleFinder = new ModulePath(Runtime.version(), true, dirs); } if (opts.has(moduleVersion)) - options.moduleVersion = opts.valueOf(moduleVersion); + options.moduleVersion = getLastElement(opts.valuesOf(moduleVersion)); if (opts.has(mainClass)) - options.mainClass = opts.valueOf(mainClass); + options.mainClass = getLastElement(opts.valuesOf(mainClass)); if (opts.has(osName)) - options.osName = opts.valueOf(osName); + options.osName = getLastElement(opts.valuesOf(osName)); if (opts.has(osArch)) - options.osArch = opts.valueOf(osArch); + options.osArch = getLastElement(opts.valuesOf(osArch)); if (opts.has(osVersion)) - options.osVersion = opts.valueOf(osVersion); + options.osVersion = getLastElement(opts.valuesOf(osVersion)); if (opts.has(warnIfResolved)) - options.moduleResolution = opts.valueOf(warnIfResolved); + options.moduleResolution = getLastElement(opts.valuesOf(warnIfResolved)); if (opts.has(doNotResolveByDefault)) { if (options.moduleResolution == null) options.moduleResolution = ModuleResolution.empty(); options.moduleResolution = options.moduleResolution.withDoNotResolveByDefault(); } if (opts.has(hashModules)) { - options.modulesToHash = opts.valueOf(hashModules); + options.modulesToHash = getLastElement(opts.valuesOf(hashModules)); // if storing hashes then the module path is required if (options.moduleFinder == null) throw new CommandException("err.modulepath.must.be.specified") @@ -1531,6 +1537,13 @@ public class JmodTask { throw new CommandException("err.classpath.must.be.specified").showUsage(true); if (options.mainClass != null && !isValidJavaIdentifier(options.mainClass)) throw new CommandException("err.invalid.main-class", options.mainClass); + if (options.mode.equals(Mode.EXTRACT) && options.extractDir != null) { + try { + Files.createDirectories(options.extractDir); + } catch (IOException ioe) { + throw new CommandException("err.cannot.create.dir", options.extractDir); + } + } } catch (OptionException e) { throw new CommandException(e.getMessage()); } @@ -1558,6 +1571,12 @@ public class JmodTask { return true; } + static E getLastElement(List list) { + if (list.size() == 0) + throw new InternalError("Unexpected 0 list size"); + return list.get(list.size() - 1); + } + private void reportError(String message) { out.println(getMessage("error.prefix") + " " + message); } diff --git a/jdk/test/tools/jmod/JmodTest.java b/jdk/test/tools/jmod/JmodTest.java index 4a6a1c51479..8ed6343696d 100644 --- a/jdk/test/tools/jmod/JmodTest.java +++ b/jdk/test/tools/jmod/JmodTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8142968 8166568 8166286 8170618 + * @bug 8142968 8166568 8166286 8170618 8168149 * @summary Basic test for jmod * @library /lib/testlibrary * @modules jdk.compiler @@ -458,6 +458,76 @@ public class JmodTest { ); } + @Test + public void testLastOneWins() throws IOException { + Path workDir = Paths.get("lastOneWins"); + if (Files.exists(workDir)) + FileUtils.deleteFileTreeWithRetry(workDir); + Files.createDirectory(workDir); + Path jmod = MODS_DIR.resolve("lastOneWins.jmod"); + FileUtils.deleteFileIfExistsWithRetry(jmod); + Path cp = EXPLODED_DIR.resolve("foo").resolve("classes"); + Path bp = EXPLODED_DIR.resolve("foo").resolve("bin"); + Path lp = EXPLODED_DIR.resolve("foo").resolve("lib"); + Path cf = EXPLODED_DIR.resolve("foo").resolve("conf"); + + Path shouldNotBeAdded = workDir.resolve("shouldNotBeAdded"); + Files.createDirectory(shouldNotBeAdded); + Files.write(shouldNotBeAdded.resolve("aFile"), "hello".getBytes(UTF_8)); + + // Pairs of options. For options with required arguments the last one + // should win ( first should be effectively ignored, but may still be + // validated ). + jmod("create", + "--conf", shouldNotBeAdded.toString(), + "--conf", cf.toString(), + "--cmds", shouldNotBeAdded.toString(), + "--cmds", bp.toString(), + "--libs", shouldNotBeAdded.toString(), + "--libs", lp.toString(), + "--class-path", shouldNotBeAdded.toString(), + "--class-path", cp.toString(), + "--main-class", "does.NotExist", + "--main-class", "jdk.test.foo.Foo", + "--module-version", "00001", + "--module-version", "5.4.3", + "--do-not-resolve-by-default", + "--do-not-resolve-by-default", + "--warn-if-resolved=incubating", + "--warn-if-resolved=deprecated", + MODS_DIR.resolve("lastOneWins.jmod").toString()) + .assertSuccess() + .resultChecker(r -> { + ModuleDescriptor md = getModuleDescriptor(jmod); + Optional omc = md.mainClass(); + assertTrue(omc.isPresent()); + assertEquals(omc.get(), "jdk.test.foo.Foo"); + Optional ov = md.version(); + assertTrue(ov.isPresent()); + assertEquals(ov.get().toString(), "5.4.3"); + + try (Stream s1 = findFiles(lp).map(p -> LIBS_PREFIX + p); + Stream s2 = findFiles(cp).map(p -> CLASSES_PREFIX + p); + Stream s3 = findFiles(bp).map(p -> CMDS_PREFIX + p); + Stream s4 = findFiles(cf).map(p -> CONFIGS_PREFIX + p)) { + Set expectedFilenames = Stream.concat(Stream.concat(s1,s2), + Stream.concat(s3, s4)) + .collect(toSet()); + assertJmodContent(jmod, expectedFilenames); + } + }); + + jmod("extract", + "--dir", "blah", + "--dir", "lastOneWinsExtractDir", + jmod.toString()) + .assertSuccess() + .resultChecker(r -> { + assertTrue(Files.exists(Paths.get("lastOneWinsExtractDir"))); + assertTrue(Files.notExists(Paths.get("blah"))); + }); + } + @Test public void testPackagesAttribute() throws IOException { Path jmod = MODS_DIR.resolve("foo.jmod"); From a004b7fb9e6750af8c65365b32741906e17378ac Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 12 Jan 2017 13:38:27 +0100 Subject: [PATCH 063/154] 8166365: Small immutable collections should provide optimized implementations when possible Reviewed-by: smarks, psandoz, attila --- .../share/classes/java/util/Collections.java | 20 +- .../java/util/ImmutableCollections.java | 193 +++++++++++++++--- .../classes/java/util/KeyValueHolder.java | 6 +- .../share/classes/java/util/List.java | 5 +- .../share/classes/java/util/Map.java | 5 +- .../share/classes/java/util/Set.java | 5 +- .../java/util/Collection/SetFactories.java | 15 +- jdk/test/java/util/Map/MapFactories.java | 21 +- 8 files changed, 228 insertions(+), 42 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/Collections.java b/jdk/src/java.base/share/classes/java/util/Collections.java index 7119fff3e89..02d656cb574 100644 --- a/jdk/src/java.base/share/classes/java/util/Collections.java +++ b/jdk/src/java.base/share/classes/java/util/Collections.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -4354,6 +4354,11 @@ public class Collections { private Object readResolve() { return EMPTY_SET; } + + @Override + public int hashCode() { + return 0; + } } /** @@ -4786,6 +4791,10 @@ public class Collections { public boolean removeIf(Predicate filter) { throw new UnsupportedOperationException(); } + @Override + public int hashCode() { + return Objects.hashCode(element); + } } /** @@ -4848,6 +4857,10 @@ public class Collections { public Spliterator spliterator() { return singletonSpliterator(element); } + @Override + public int hashCode() { + return Objects.hashCode(element); + } } /** @@ -4970,6 +4983,11 @@ public class Collections { BiFunction remappingFunction) { throw new UnsupportedOperationException(); } + + @Override + public int hashCode() { + return Objects.hashCode(k) ^ Objects.hashCode(v); + } } // Miscellaneous diff --git a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java index 26a03e0dae6..2bc0cc1b5d9 100644 --- a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java +++ b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.UnaryOperator; +import jdk.internal.vm.annotation.Stable; /** * Container class for immutable collections. Not part of the public API. @@ -105,6 +106,11 @@ class ImmutableCollections { return null; // but the compiler doesn't know this } + @Override + public Iterator iterator() { + return Collections.emptyIterator(); + } + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { throw new InvalidObjectException("not serial proxy"); } @@ -112,9 +118,26 @@ class ImmutableCollections { private Object writeReplace() { return new CollSer(CollSer.IMM_LIST); } + + @Override + public boolean contains(Object o) { + Objects.requireNonNull(o); + return false; + } + + @Override + public boolean containsAll(Collection o) { + return o.isEmpty(); // implicit nullcheck of o + } + + @Override + public int hashCode() { + return 1; + } } static final class List1 extends AbstractImmutableList { + @Stable private final E e0; List1(E e0) { @@ -129,7 +152,6 @@ class ImmutableCollections { @Override public E get(int index) { Objects.checkIndex(index, 1); - // assert index == 0 return e0; } @@ -140,10 +162,22 @@ class ImmutableCollections { private Object writeReplace() { return new CollSer(CollSer.IMM_LIST, e0); } + + @Override + public boolean contains(Object o) { + return o.equals(e0); // implicit nullcheck of o + } + + @Override + public int hashCode() { + return 31 + e0.hashCode(); + } } static final class List2 extends AbstractImmutableList { + @Stable private final E e0; + @Stable private final E e1; List2(E e0, E e1) { @@ -166,6 +200,17 @@ class ImmutableCollections { } } + @Override + public boolean contains(Object o) { + return o.equals(e0) || o.equals(e1); // implicit nullcheck of o + } + + @Override + public int hashCode() { + int hash = 31 + e0.hashCode(); + return 31 * hash + e1.hashCode(); + } + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { throw new InvalidObjectException("not serial proxy"); } @@ -176,6 +221,7 @@ class ImmutableCollections { } static final class ListN extends AbstractImmutableList { + @Stable private final E[] elements; @SafeVarargs @@ -200,6 +246,25 @@ class ImmutableCollections { return elements[index]; } + @Override + public boolean contains(Object o) { + for (E e : elements) { + if (o.equals(e)) { // implicit nullcheck of o + return true; + } + } + return false; + } + + @Override + public int hashCode() { + int hash = 1; + for (E e : elements) { + hash = 31 * hash + e.hashCode(); + } + return hash; + } + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { throw new InvalidObjectException("not serial proxy"); } @@ -238,7 +303,13 @@ class ImmutableCollections { @Override public boolean contains(Object o) { - return super.contains(Objects.requireNonNull(o)); + Objects.requireNonNull(o); + return false; + } + + @Override + public boolean containsAll(Collection o) { + return o.isEmpty(); // implicit nullcheck of o } @Override @@ -253,9 +324,15 @@ class ImmutableCollections { private Object writeReplace() { return new CollSer(CollSer.IMM_SET); } + + @Override + public int hashCode() { + return 0; + } } static final class Set1 extends AbstractImmutableSet { + @Stable private final E e0; Set1(E e0) { @@ -269,7 +346,7 @@ class ImmutableCollections { @Override public boolean contains(Object o) { - return super.contains(Objects.requireNonNull(o)); + return o.equals(e0); // implicit nullcheck of o } @Override @@ -284,17 +361,21 @@ class ImmutableCollections { private Object writeReplace() { return new CollSer(CollSer.IMM_SET, e0); } + + @Override + public int hashCode() { + return e0.hashCode(); + } } static final class Set2 extends AbstractImmutableSet { - private final E e0; - private final E e1; + @Stable + final E e0; + @Stable + final E e1; Set2(E e0, E e1) { - Objects.requireNonNull(e0); - Objects.requireNonNull(e1); - - if (e0.equals(e1)) { + if (e0.equals(Objects.requireNonNull(e1))) { // implicit nullcheck of e0 throw new IllegalArgumentException("duplicate element: " + e0); } @@ -314,7 +395,12 @@ class ImmutableCollections { @Override public boolean contains(Object o) { - return super.contains(Objects.requireNonNull(o)); + return o.equals(e0) || o.equals(e1); // implicit nullcheck of o + } + + @Override + public int hashCode() { + return e0.hashCode() + e1.hashCode(); } @Override @@ -358,8 +444,10 @@ class ImmutableCollections { * @param the element type */ static final class SetN extends AbstractImmutableSet { - private final E[] elements; - private final int size; + @Stable + final E[] elements; + @Stable + final int size; @SafeVarargs @SuppressWarnings("unchecked") @@ -368,8 +456,8 @@ class ImmutableCollections { elements = (E[])new Object[EXPAND_FACTOR * input.length]; for (int i = 0; i < input.length; i++) { - E e = Objects.requireNonNull(input[i]); - int idx = probe(e); + E e = input[i]; + int idx = probe(e); // implicit nullcheck of e if (idx >= 0) { throw new IllegalArgumentException("duplicate element: " + e); } else { @@ -385,8 +473,7 @@ class ImmutableCollections { @Override public boolean contains(Object o) { - Objects.requireNonNull(o); - return probe(o) >= 0; + return probe(o) >= 0; // implicit nullcheck of o } @Override @@ -414,8 +501,21 @@ class ImmutableCollections { }; } + @Override + public int hashCode() { + int h = 0; + for (E e : elements) { + if (e != null) { + h += e.hashCode(); + } + } + return h; + } + // returns index at which element is present; or if absent, - // (-i - 1) where i is location where element should be inserted + // (-i - 1) where i is location where element should be inserted. + // Callers are relying on this method to perform an implicit nullcheck + // of pe private int probe(Object pe) { int idx = Math.floorMod(pe.hashCode() ^ SALT, elements.length); while (true) { @@ -481,12 +581,14 @@ class ImmutableCollections { @Override public boolean containsKey(Object o) { - return super.containsKey(Objects.requireNonNull(o)); + Objects.requireNonNull(o); + return false; } @Override public boolean containsValue(Object o) { - return super.containsValue(Objects.requireNonNull(o)); + Objects.requireNonNull(o); + return false; } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { @@ -496,10 +598,17 @@ class ImmutableCollections { private Object writeReplace() { return new CollSer(CollSer.IMM_MAP); } + + @Override + public int hashCode() { + return 0; + } } static final class Map1 extends AbstractImmutableMap { + @Stable private final K k0; + @Stable private final V v0; Map1(K k0, V v0) { @@ -514,12 +623,12 @@ class ImmutableCollections { @Override public boolean containsKey(Object o) { - return super.containsKey(Objects.requireNonNull(o)); + return o.equals(k0); // implicit nullcheck of o } @Override public boolean containsValue(Object o) { - return super.containsValue(Objects.requireNonNull(o)); + return o.equals(v0); // implicit nullcheck of o } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { @@ -529,6 +638,11 @@ class ImmutableCollections { private Object writeReplace() { return new CollSer(CollSer.IMM_MAP, k0, v0); } + + @Override + public int hashCode() { + return k0.hashCode() ^ v0.hashCode(); + } } /** @@ -541,12 +655,13 @@ class ImmutableCollections { * @param the value type */ static final class MapN extends AbstractImmutableMap { - private final Object[] table; // pairs of key, value - private final int size; // number of pairs + @Stable + final Object[] table; // pairs of key, value + @Stable + final int size; // number of pairs MapN(Object... input) { - Objects.requireNonNull(input); - if ((input.length & 1) != 0) { + if ((input.length & 1) != 0) { // implicit nullcheck of input throw new InternalError("length is odd"); } size = input.length >> 1; @@ -573,12 +688,30 @@ class ImmutableCollections { @Override public boolean containsKey(Object o) { - return probe(Objects.requireNonNull(o)) >= 0; + return probe(o) >= 0; // implicit nullcheck of o } @Override public boolean containsValue(Object o) { - return super.containsValue(Objects.requireNonNull(o)); + for (int i = 1; i < table.length; i += 2) { + Object v = table[i]; + if (v != null && o.equals(v)) { // implicit nullcheck of o + return true; + } + } + return false; + } + + @Override + public int hashCode() { + int hash = 0; + for (int i = 0; i < table.length; i += 2) { + Object k = table[i]; + if (k != null) { + hash += k.hashCode() ^ table[i + 1].hashCode(); + } + } + return hash; } @Override @@ -638,7 +771,9 @@ class ImmutableCollections { } // returns index at which the probe key is present; or if absent, - // (-i - 1) where i is location where element should be inserted + // (-i - 1) where i is location where element should be inserted. + // Callers are relying on this method to perform an implicit nullcheck + // of pk. private int probe(Object pk) { int idx = Math.floorMod(pk.hashCode() ^ SALT, table.length >> 1) << 1; while (true) { diff --git a/jdk/src/java.base/share/classes/java/util/KeyValueHolder.java b/jdk/src/java.base/share/classes/java/util/KeyValueHolder.java index 96ca0753ac6..3b7250ee6aa 100644 --- a/jdk/src/java.base/share/classes/java/util/KeyValueHolder.java +++ b/jdk/src/java.base/share/classes/java/util/KeyValueHolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package java.util; +import jdk.internal.vm.annotation.Stable; + /** * An immutable container for a key and a value, suitable for use * in creating and populating {@code Map} instances. @@ -48,7 +50,9 @@ package java.util; * @since 9 */ final class KeyValueHolder implements Map.Entry { + @Stable final K key; + @Stable final V value; KeyValueHolder(K k, V v) { diff --git a/jdk/src/java.base/share/classes/java/util/List.java b/jdk/src/java.base/share/classes/java/util/List.java index 0f14c298805..dda514b313f 100644 --- a/jdk/src/java.base/share/classes/java/util/List.java +++ b/jdk/src/java.base/share/classes/java/util/List.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1027,8 +1027,7 @@ public interface List extends Collection { @SafeVarargs @SuppressWarnings("varargs") static List of(E... elements) { - Objects.requireNonNull(elements); - switch (elements.length) { + switch (elements.length) { // implicit null check of elements case 0: return ImmutableCollections.List0.instance(); case 1: diff --git a/jdk/src/java.base/share/classes/java/util/Map.java b/jdk/src/java.base/share/classes/java/util/Map.java index b41e90dc866..153b86b8084 100644 --- a/jdk/src/java.base/share/classes/java/util/Map.java +++ b/jdk/src/java.base/share/classes/java/util/Map.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1602,8 +1602,7 @@ public interface Map { @SafeVarargs @SuppressWarnings("varargs") static Map ofEntries(Entry... entries) { - Objects.requireNonNull(entries); - if (entries.length == 0) { + if (entries.length == 0) { // implicit null check of entries return ImmutableCollections.Map0.instance(); } else if (entries.length == 1) { return new ImmutableCollections.Map1<>(entries[0].getKey(), diff --git a/jdk/src/java.base/share/classes/java/util/Set.java b/jdk/src/java.base/share/classes/java/util/Set.java index 08ef3297161..2dd9060f7df 100644 --- a/jdk/src/java.base/share/classes/java/util/Set.java +++ b/jdk/src/java.base/share/classes/java/util/Set.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -689,8 +689,7 @@ public interface Set extends Collection { @SafeVarargs @SuppressWarnings("varargs") static Set of(E... elements) { - Objects.requireNonNull(elements); - switch (elements.length) { + switch (elements.length) { // implicit null check of elements case 0: return ImmutableCollections.Set0.instance(); case 1: diff --git a/jdk/test/java/util/Collection/SetFactories.java b/jdk/test/java/util/Collection/SetFactories.java index aabeaa344a7..25a884501e0 100644 --- a/jdk/test/java/util/Collection/SetFactories.java +++ b/jdk/test/java/util/Collection/SetFactories.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,6 +103,8 @@ public class SetFactories { hashSetOf("a", "b", "c", "d", "e", "f", "g", "h", "i")), a( Set.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"), hashSetOf("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")), + a( Set.of("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"), + Set.of("j", "i", "h", "g", "f", "e", "d", "c", "b", "a")), a( Set.of(stringArray), hashSetOf(stringArray)) ).iterator(); @@ -183,6 +185,17 @@ public class SetFactories { Set set = Set.of(array); } + @Test(dataProvider="all") + public void hashCodeEqual(Set act, Set exp) { + assertEquals(act.hashCode(), exp.hashCode()); + } + + @Test(dataProvider="all") + public void containsAll(Set act, Set exp) { + assertTrue(act.containsAll(exp)); + assertTrue(exp.containsAll(act)); + } + @Test(expectedExceptions=NullPointerException.class) public void nullDisallowed1() { Set.of((String)null); // force one-arg overload diff --git a/jdk/test/java/util/Map/MapFactories.java b/jdk/test/java/util/Map/MapFactories.java index b8ff0c9f3f2..7495aa386c3 100644 --- a/jdk/test/java/util/Map/MapFactories.java +++ b/jdk/test/java/util/Map/MapFactories.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,6 +103,8 @@ public class MapFactories { a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h"), genMap(8)), a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i"), genMap(9)), a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j"), genMap(10)), + a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j"), + Map.of(4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j", 0, "a", 1, "b", 2, "c", 3, "d")), a(Map.ofEntries(genEntries(MAX_ENTRIES)), genMap(MAX_ENTRIES)) ).iterator(); } @@ -135,6 +137,18 @@ public class MapFactories { assertEquals(act, exp); } + @Test(dataProvider="all") + public void containsAllKeys(Map act, Map exp) { + assertTrue(act.keySet().containsAll(exp.keySet())); + assertTrue(exp.keySet().containsAll(act.keySet())); + } + + @Test(dataProvider="all") + public void containsAllValues(Map act, Map exp) { + assertTrue(act.values().containsAll(exp.values())); + assertTrue(exp.values().containsAll(act.values())); + } + @Test(expectedExceptions=IllegalArgumentException.class) public void dupKeysDisallowed2() { Map map = Map.of(0, "a", 0, "b"); @@ -192,6 +206,11 @@ public class MapFactories { Map map = Map.ofEntries(entries); } + @Test(dataProvider="all") + public void hashCodeEquals(Map act, Map exp) { + assertEquals(act.hashCode(), exp.hashCode()); + } + @Test(expectedExceptions=NullPointerException.class) public void nullKeyDisallowed1() { Map map = Map.of(null, "a"); From 2f0c7dee31f5066c0eaebb30568f4b2738a9a4f4 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Thu, 12 Jan 2017 14:26:57 +0100 Subject: [PATCH 064/154] 8172709: Upgrade to jtreg 4.2 b05 Reviewed-by: erikj, chegar --- common/conf/jib-profiles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index c6c04d756a5..dcbb3639cd0 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -870,7 +870,7 @@ var getJibProfilesDependencies = function (input, common) { jtreg: { server: "javare", revision: "4.2", - build_number: "b04", + build_number: "b05", checksum_file: "MD5_VALUES", file: "jtreg_bin-4.2.zip", environment_name: "JT_HOME", From 0b013b987f669e167f9d1500fbd16c33a9f59a16 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 12 Jan 2017 14:38:02 +0100 Subject: [PATCH 065/154] 8172712: configure should check that grep handles empty pattern correctly Reviewed-by: ihse --- common/autoconf/basics.m4 | 24 +++++++++++++++++++++++ common/autoconf/generated-configure.sh | 27 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 89b91b0e8e0..17c03533dd7 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -1040,12 +1040,36 @@ AC_DEFUN([BASIC_CHECK_TAR], AC_SUBST(TAR_SUPPORTS_TRANSFORM) ]) +AC_DEFUN([BASIC_CHECK_GREP], +[ + # Test that grep supports -Fx with a list of pattern which includes null pattern. + # This is a problem for the grep resident on AIX. + AC_MSG_CHECKING([that grep ($GREP) -Fx handles empty lines in the pattern list correctly]) + # Multiple subsequent spaces.. + STACK_SPACES='aaa bbb ccc' + # ..converted to subsequent newlines, causes STACK_LIST to be a list with some empty + # patterns in it. + STACK_LIST=${STACK_SPACES// /$'\n'} + NEEDLE_SPACES='ccc bbb aaa' + NEEDLE_LIST=${NEEDLE_SPACES// /$'\n'} + RESULT="$($GREP -Fvx "$STACK_LIST" <<< "$NEEDLE_LIST")" + if test "x$RESULT" == "x"; then + AC_MSG_RESULT([yes]) + else + if test "x$OPENJDK_TARGET_OS" = "xaix"; then + ADDINFO="Please make sure you use GNU grep, usually found at /opt/freeware/bin." + fi + AC_MSG_ERROR([grep does not handle -Fx correctly. ${ADDINFO}]) + fi +]) + AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], [ BASIC_CHECK_GNU_MAKE BASIC_CHECK_FIND_DELETE BASIC_CHECK_TAR + BASIC_CHECK_GREP # These tools might not be installed by default, # need hint on how to install them. diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index fc3c0cb5aed..fb03dcc3108 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3731,6 +3731,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + # Check if build directory is on local disk. If not possible to determine, # we prefer to claim it's local. # Argument 1: directory to test @@ -5178,7 +5180,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=1484135958 +DATE_WHEN_GENERATED=1484228046 ############################################################################### # @@ -21251,6 +21253,29 @@ $as_echo "$TAR_TYPE" >&6; } + # Test that grep supports -Fx with a list of pattern which includes null pattern. + # This is a problem for the grep resident on AIX. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking that grep ($GREP) -Fx handles empty lines in the pattern list correctly" >&5 +$as_echo_n "checking that grep ($GREP) -Fx handles empty lines in the pattern list correctly... " >&6; } + # Multiple subsequent spaces.. + STACK_SPACES='aaa bbb ccc' + # ..converted to subsequent newlines, causes STACK_LIST to be a list with some empty + # patterns in it. + STACK_LIST=${STACK_SPACES// /$'\n'} + NEEDLE_SPACES='ccc bbb aaa' + NEEDLE_LIST=${NEEDLE_SPACES// /$'\n'} + RESULT="$($GREP -Fvx "$STACK_LIST" <<< "$NEEDLE_LIST")" + if test "x$RESULT" == "x"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + if test "x$OPENJDK_TARGET_OS" = "xaix"; then + ADDINFO="Please make sure you use GNU grep, usually found at /opt/freeware/bin." + fi + as_fn_error $? "grep does not handle -Fx correctly. ${ADDINFO}" "$LINENO" 5 + fi + + # These tools might not be installed by default, # need hint on how to install them. From 04da970a8481733020fb4f961966005b75a6920e Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 12 Jan 2017 14:47:38 +0100 Subject: [PATCH 066/154] 8172577: Builds for OS X after build 149 does not include Java Mission Control.app Reviewed-by: tbell, ihse --- make/Bundles.gmk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 8c1d4e4f594..1791818abc7 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -77,9 +77,8 @@ define SetupBundleFileBody $$(call MakeDir, $$(@D)) ifneq ($$($1_SPECIAL_INCLUDES), ) $$(foreach i, $$($1_SPECIAL_INCLUDES), \ - $$(foreach d, $$d, \ - ($(CD) $$d && $(FIND) $$i \ - >> $(SUPPORT_OUTPUTDIR)/bundles/_$1_files ) ; )) + $$(foreach d, $$($1_BASE_DIRS), \ + ($(CD) $$d && $(FIND) $$i >> $$($1_$$d_LIST_FILE)) ; )) endif ifeq ($$($1_SUBDIR)-$$($1_TYPE)-$$($1_UNZIP_DEBUGINFO), .-zip-false) # If no subdir is specified, zip can be done directly from BASE_DIRS. From abddf32a62c57fb99750db8ce8c2b84b0cb20a23 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 12 Jan 2017 15:37:46 +0100 Subject: [PATCH 067/154] 8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed( Guarding against noType returned from ErrorType.getOriginalType. Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/TypeEnter.java | 4 +- .../modules/ConvenientAccessErrorsTest.java | 81 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java index edff639c7a1..6f619c35441 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java @@ -410,7 +410,9 @@ public class TypeEnter implements Completer { importNamedStatic(tree, p, name, localEnv); chk.checkCanonical(imp.selected); } else { - TypeSymbol c = attribImportType(imp, localEnv).getOriginalType().tsym; + Type importedType = attribImportType(imp, localEnv); + Type originalType = importedType.getOriginalType(); + TypeSymbol c = originalType.hasTag(CLASS) ? originalType.tsym : importedType.tsym; chk.checkCanonical(imp); importNamed(tree.pos(), c, env, tree); } diff --git a/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java b/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java index fe81bf9dacf..66728a98b89 100644 --- a/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java +++ b/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8169197 8172668 * @summary Check convenient errors are produced for inaccessible classes. * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -512,4 +513,84 @@ public class ConvenientAccessErrorsTest extends ModuleTestBase { .writeAll(); } + @Test + public void testUnresolvableInImport(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { }", + "package api; import can.not.resolve; public class Api { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Api.java:1:28: compiler.err.doesnt.exist: can.not", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testMissingKnownClass(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { exports api; }", + "package api; public class Base { }", + "package api; public class Sub extends Base { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + Path m1xClasses = classes.resolve("m1x"); + tb.createDirectories(m1xClasses); + + new JavacTask(tb) + .options("-XDrawDiagnostics") + .outdir(m1xClasses) + .files(findJavaFiles(src_m1)) + .run(Task.Expect.SUCCESS) + .writeAll(); + + Files.delete(m1xClasses.resolve("api").resolve("Base.class")); + + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }", + "package test;\n" + + "import api.Sub;\n" + + "import api.Base;\n" + + "public class Test {\n" + + " Sub a2;\n" + + " Base a;\n" + + "}\n"); + Path m2xClasses = classes.resolve("m2x"); + tb.createDirectories(m2xClasses); + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-path", classes.toString(), + "-XDdev") + .outdir(m2xClasses) + .files(findJavaFiles(src_m2)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:3:11: compiler.err.cant.resolve.location: kindname.class, Base, , , (compiler.misc.location: kindname.package, api, null)", + "Test.java:6:5: compiler.err.cant.resolve.location: kindname.class, Base, , , (compiler.misc.location: kindname.class, test.Test, null)", + "2 errors"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + } From d7ca564a5839ac772cb62d474cc798de8962cf00 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 12 Jan 2017 17:07:49 +0100 Subject: [PATCH 068/154] 8172720: Collections.SingletonList::hashCode not spec-compliant Reviewed-by: chegar --- jdk/src/java.base/share/classes/java/util/Collections.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/util/Collections.java b/jdk/src/java.base/share/classes/java/util/Collections.java index 02d656cb574..22b4557ae2f 100644 --- a/jdk/src/java.base/share/classes/java/util/Collections.java +++ b/jdk/src/java.base/share/classes/java/util/Collections.java @@ -4859,7 +4859,7 @@ public class Collections { } @Override public int hashCode() { - return Objects.hashCode(element); + return 31 + Objects.hashCode(element); } } From a709f5c3efd86d980541632a0894dcd202d7f74d Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Thu, 12 Jan 2017 09:04:16 -0800 Subject: [PATCH 069/154] 8172213: Remove unused and partially implemented JavacElements#getSourcePosition methods Reviewed-by: jjg --- .../sun/tools/javac/model/JavacElements.java | 37 +-------- .../javac/model/JavacSourcePosition.java | 75 ------------------- 2 files changed, 1 insertion(+), 111 deletions(-) delete mode 100644 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacSourcePosition.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java index c30ab765f5e..24e48c04a25 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -222,41 +222,6 @@ public class JavacElements implements Elements { } } - public JavacSourcePosition getSourcePosition(Element e) { - Pair treeTop = getTreeAndTopLevel(e); - if (treeTop == null) - return null; - JCTree tree = treeTop.fst; - JCCompilationUnit toplevel = treeTop.snd; - JavaFileObject sourcefile = toplevel.sourcefile; - if (sourcefile == null) - return null; - return new JavacSourcePosition(sourcefile, tree.pos, toplevel.lineMap); - } - - public JavacSourcePosition getSourcePosition(Element e, AnnotationMirror a) { - Pair treeTop = getTreeAndTopLevel(e); - if (treeTop == null) - return null; - JCTree tree = treeTop.fst; - JCCompilationUnit toplevel = treeTop.snd; - JavaFileObject sourcefile = toplevel.sourcefile; - if (sourcefile == null) - return null; - - JCTree annoTree = matchAnnoToTree(a, e, tree); - if (annoTree == null) - return null; - return new JavacSourcePosition(sourcefile, annoTree.pos, - toplevel.lineMap); - } - - public JavacSourcePosition getSourcePosition(Element e, AnnotationMirror a, - AnnotationValue v) { - // TODO: better accuracy in getSourcePosition(... AnnotationValue) - return getSourcePosition(e, a); - } - /** * Returns the tree for an annotation given the annotated element * and the element's own tree. Returns null if the tree cannot be found. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacSourcePosition.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacSourcePosition.java deleted file mode 100644 index 3cc14752686..00000000000 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacSourcePosition.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javac.model; - -import javax.tools.JavaFileObject; -import com.sun.tools.javac.util.Position; - -/** - * Implementation of model API SourcePosition based on javac internal state. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice.

- */ -class JavacSourcePosition { - - final JavaFileObject sourcefile; - final int pos; - final Position.LineMap lineMap; - - JavacSourcePosition(JavaFileObject sourcefile, - int pos, - Position.LineMap lineMap) { - this.sourcefile = sourcefile; - this.pos = pos; - this.lineMap = (pos != Position.NOPOS) ? lineMap : null; - } - - public JavaFileObject getFile() { - return sourcefile; - } - - public int getOffset() { - return pos; // makes use of fact that Position.NOPOS == -1 - } - - public int getLine() { - return (lineMap != null) ? lineMap.getLineNumber(pos) : -1; - } - - public int getColumn() { - return (lineMap != null) ? lineMap.getColumnNumber(pos) : -1; - } - - public String toString() { - int line = getLine(); - return (line > 0) - ? sourcefile + ":" + line - : sourcefile.toString(); - } -} From c89c526762d5e76d655efe36d9dfe3e5b97986aa Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Thu, 12 Jan 2017 18:02:48 +0000 Subject: [PATCH 070/154] 8163449: Allow per protocol setting for URLConnection defaultUseCaches Reviewed-by: chegar, dfuchs --- .../share/classes/java/net/URLConnection.java | 65 ++++++++++++++++-- .../URLConnection/SetDefaultUseCaches.java | 67 +++++++++++++++++++ 2 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/net/URLConnection/SetDefaultUseCaches.java diff --git a/jdk/src/java.base/share/classes/java/net/URLConnection.java b/jdk/src/java.base/share/classes/java/net/URLConnection.java index 7a125faf145..e2ed0cfcbdd 100644 --- a/jdk/src/java.base/share/classes/java/net/URLConnection.java +++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java @@ -30,8 +30,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.security.PrivilegedAction; import java.util.Hashtable; +import java.util.concurrent.ConcurrentHashMap; import java.util.Date; import java.util.Iterator; +import java.util.Locale; import java.util.Objects; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; @@ -231,7 +233,7 @@ public abstract class URLConnection { */ protected boolean allowUserInteraction = defaultAllowUserInteraction; - private static boolean defaultUseCaches = true; + private static volatile boolean defaultUseCaches = true; /** * If {@code true}, the protocol is allowed to use caching @@ -243,12 +245,18 @@ public abstract class URLConnection { *

* Its default value is the value given in the last invocation of the * {@code setDefaultUseCaches} method. + *

+ * The default setting may be overridden per protocol with + * {@link #setDefaultUseCaches(String,boolean)}. * * @see java.net.URLConnection#setUseCaches(boolean) * @see java.net.URLConnection#getUseCaches() * @see java.net.URLConnection#setDefaultUseCaches(boolean) */ - protected boolean useCaches = defaultUseCaches; + protected boolean useCaches; + + private static final ConcurrentHashMap defaultCaching = + new ConcurrentHashMap<>(); /** * Some protocols support skipping the fetching of the object unless @@ -460,6 +468,11 @@ public abstract class URLConnection { */ protected URLConnection(URL url) { this.url = url; + if (url == null) { + this.useCaches = defaultUseCaches; + } else { + this.useCaches = getDefaultUseCaches(url.getProtocol()); + } } /** @@ -981,7 +994,8 @@ public abstract class URLConnection { * is true, the connection is allowed to use whatever caches it can. * If false, caches are to be ignored. * The default value comes from DefaultUseCaches, which defaults to - * true. + * true. A default value can also be set per-protocol using + * {@link #setDefaultUseCaches(String,boolean)}. * * @param usecaches a {@code boolean} indicating whether * or not to allow caching @@ -1032,9 +1046,10 @@ public abstract class URLConnection { * Returns the default value of a {@code URLConnection}'s * {@code useCaches} flag. *

- * Ths default is "sticky", being a part of the static state of all + * This default is "sticky", being a part of the static state of all * URLConnections. This flag applies to the next, and all following - * URLConnections that are created. + * URLConnections that are created. This default value can be over-ridden + * per protocol using {@link #setDefaultUseCaches(String,boolean)} * * @return the default value of a {@code URLConnection}'s * {@code useCaches} flag. @@ -1046,7 +1061,8 @@ public abstract class URLConnection { /** * Sets the default value of the {@code useCaches} field to the - * specified value. + * specified value. This default value can be over-ridden + * per protocol using {@link #setDefaultUseCaches(String,boolean)} * * @param defaultusecaches the new value. * @see #getDefaultUseCaches() @@ -1055,6 +1071,43 @@ public abstract class URLConnection { defaultUseCaches = defaultusecaches; } + /** + * Sets the default value of the {@code useCaches} field for the named + * protocol to the given value. This value overrides any default setting + * set by {@link #setDefaultUseCaches(boolean)} for the given protocol. + * Successive calls to this method change the setting and affect the + * default value for all future connections of that protocol. The protocol + * name is case insensitive. + * + * @param protocol the protocol to set the default for + * @param defaultVal whether caching is enabled by default for the given protocol + * @since 9 + */ + public static void setDefaultUseCaches(String protocol, boolean defaultVal) { + protocol = protocol.toLowerCase(Locale.US); + defaultCaching.put(protocol, defaultVal); + } + + /** + * Returns the default value of the {@code useCaches} flag for the given protocol. If + * {@link #setDefaultUseCaches(String,boolean)} was called for the given protocol, + * then that value is returned. Otherwise, if {@link #setDefaultUseCaches(boolean)} + * was called, then that value is returned. If neither method was called, + * the return value is {@code true}. The protocol name is case insensitive. + * + * @param protocol the protocol whose defaultUseCaches setting is required + * @return the default value of the {@code useCaches} flag for the given protocol. + * @since 9 + */ + public static boolean getDefaultUseCaches(String protocol) { + Boolean protoDefault = defaultCaching.get(protocol.toLowerCase(Locale.US)); + if (protoDefault != null) { + return protoDefault.booleanValue(); + } else { + return defaultUseCaches; + } + } + /** * Sets the general request property. If a property with the key already * exists, overwrite its value with the new value. diff --git a/jdk/test/java/net/URLConnection/SetDefaultUseCaches.java b/jdk/test/java/net/URLConnection/SetDefaultUseCaches.java new file mode 100644 index 00000000000..2c12889d23d --- /dev/null +++ b/jdk/test/java/net/URLConnection/SetDefaultUseCaches.java @@ -0,0 +1,67 @@ +/* + * 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 8163449 + * @summary Allow per protocol setting for URLConnection defaultUseCaches + * @run main/othervm SetDefaultUseCaches + */ + +import java.net.*; +import java.io.*; + +public class SetDefaultUseCaches { + static void testAssert(boolean value, boolean comparator) { + if (value != comparator) { + System.err.println("Expected " + comparator + " Got " + value); + throw new RuntimeException("Test failed:"); + } else + System.err.println("OK"); + } + + public static void main(String s[]) throws Exception { + URL url = new URL("http://www.foo.com/"); + URL url1 = new URL("file:///a/b.txt"); + + // check default default is true + URLConnection urlc = url.openConnection(); + testAssert(urlc.getDefaultUseCaches(), true); + + // set default for http to false and check + URLConnection.setDefaultUseCaches("HTTP", false); + + urlc = url.openConnection(); + testAssert(urlc.getDefaultUseCaches(), true); + testAssert(urlc.getUseCaches(), false); + testAssert(URLConnection.getDefaultUseCaches("http"), false); + + URLConnection urlc1 = url1.openConnection(); + testAssert(urlc1.getDefaultUseCaches(), true); + + // set default default to false and check other values the same + urlc.setDefaultUseCaches(false); + urlc1.setDefaultUseCaches("fiLe", true); + testAssert(urlc1.getDefaultUseCaches(), false); + testAssert(URLConnection.getDefaultUseCaches("fiLE"), true); + } +} From 6ec0f2129e036d866a7c54d3eb0a7870225b7a87 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Thu, 12 Jan 2017 10:10:32 -0800 Subject: [PATCH 071/154] 8030950: TEST_BUG: java/rmi/registry/classPathCodebase/ClassPathCodebase.java failing intermittently Reviewed-by: rriggs --- .../classPathCodebase/ClassPathCodebase.java | 41 +++++++------------ .../registry.security.policy | 18 ++++++++ .../classPathCodebase/security.policy | 8 +++- 3 files changed, 39 insertions(+), 28 deletions(-) create mode 100644 jdk/test/java/rmi/registry/classPathCodebase/registry.security.policy diff --git a/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java b/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java index d83340bb8b0..f0acc02bcc6 100644 --- a/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java +++ b/jdk/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp - * @build TestLibrary Dummy + * @build TestLibrary Dummy RegistryVM RMIRegistryRunner * @run main/othervm/policy=security.policy * -Djava.rmi.server.useCodebaseOnly=false ClassPathCodebase */ @@ -48,8 +48,9 @@ import java.util.Arrays; public class ClassPathCodebase { - /** wait 10 seconds for the registry process to be ready to call */ - private final static long REGISTRY_WAIT = 15000; + /** wait dozens of seconds for the registry process to be ready to call */ + private static final long REGISTRY_WAIT = + (long)(10000 * TestLibrary.getTimeoutFactor()); private final static String dummyClassName = "Dummy"; @@ -64,7 +65,7 @@ public class ClassPathCodebase { TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); - Process rmiregistry = null; + RegistryVM rmiregistry = null; try { /* @@ -82,27 +83,13 @@ public class ClassPathCodebase { * Spawn an rmiregistry in the "import" codebase directory. */ File rmiregistryDir = - new File(System.getProperty("user.dir", "."), importCodebase); - - String rmiregistryCommand = - System.getProperty("java.home") + File.separator + - "bin" + File.separator + "rmiregistry"; - - int port = TestLibrary.getUnusedRandomPort(); - String cmdarray[] = new String[] { - rmiregistryCommand, - "-J-Denv.class.path=.", - "-J-Djava.rmi.server.codebase=" + exportCodebaseURL, - Integer.toString(port) }; - - System.err.println("\nCommand used to spawn rmiregistry process:"); - System.err.println("\t" + Arrays.asList(cmdarray).toString()); - - rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir); - - // pipe rmiregistry output to our output, for debugging failures - StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err); - StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err); + new File(System.getProperty("user.dir", "."), importCodebase); + rmiregistry = RegistryVM.createRegistryVMWithRunner("RMIRegistryRunner", + " -Denv.class.path=." + + " -Djava.rmi.server.codebase=" + exportCodebaseURL + + " -Duser.dir=" + rmiregistryDir.getAbsolutePath()); + rmiregistry.start(); + int port = rmiregistry.getPort(); /* * Wait for the registry to initialize and be ready to call. @@ -174,7 +161,7 @@ public class ClassPathCodebase { throw new RuntimeException("TEST FAILED: " + e.toString()); } finally { if (rmiregistry != null) { - rmiregistry.destroy(); + rmiregistry.cleanup(); } } } diff --git a/jdk/test/java/rmi/registry/classPathCodebase/registry.security.policy b/jdk/test/java/rmi/registry/classPathCodebase/registry.security.policy new file mode 100644 index 00000000000..291fb8e9f88 --- /dev/null +++ b/jdk/test/java/rmi/registry/classPathCodebase/registry.security.policy @@ -0,0 +1,18 @@ +/* + * security policy used by the registry process started by RegistryVM. + */ + +grant { + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry"; + permission java.util.PropertyPermission "env.class.path", "read"; + permission java.io.FilePermission ".", "read"; + permission java.util.PropertyPermission "user.dir", "read"; + permission java.lang.RuntimePermission "createClassLoader"; + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.io.FilePermission ".-Djava.rmi.server.codebase=file", "read"; + permission java.io.FilePermission ".${/}-", "read"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp"; + permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept"; +}; diff --git a/jdk/test/java/rmi/registry/classPathCodebase/security.policy b/jdk/test/java/rmi/registry/classPathCodebase/security.policy index e45924702f2..743e8f1355e 100644 --- a/jdk/test/java/rmi/registry/classPathCodebase/security.policy +++ b/jdk/test/java/rmi/registry/classPathCodebase/security.policy @@ -18,6 +18,12 @@ grant { // test needs to use java to exec an rmiregistry permission java.io.FilePermission "${java.home}${/}bin${/}-", "execute"; - // test needs to communicate with this its registry + // test needs to communicate with its registry permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; + + permission java.util.PropertyPermission "java.security.policy", "read"; + permission java.util.PropertyPermission "java.security.manager", "read"; + + // used by TestLibrary to determine extra commandline properties + permission java.io.FilePermission "..${/}..${/}test.props", "read"; }; From c22c7101355ae696b74d19ec27316dddced579fe Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Thu, 12 Jan 2017 22:01:15 +0300 Subject: [PATCH 072/154] 8171909: [PIT] on Windows, failure of java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java Reviewed-by: yan, serb --- .../awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java index 6db02253f42..6f0a6317f1b 100644 --- a/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java +++ b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8169589 + * @bug 8169589 8171909 * @summary Activating a dialog puts to back another dialog owned by the same frame * @author Dmitry Markov * @library ../../regtesthelpers @@ -68,7 +68,7 @@ public class DialogAboveFrameTest { int y = point.y + (int)(dialog1.getHeight() * 0.9); try { - if (!robot.getPixelColor(x, y).equals(dialog1.getBackground())) { + if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) { throw new RuntimeException("Test FAILED: Dialog is behind the frame"); } } finally { From e8524e46ea65df0a622091283805f9e1b752b962 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 12 Jan 2017 11:58:01 -0800 Subject: [PATCH 073/154] 8172558: [PIT][TEST_BUG] Bad filename for javax/swing/JTable/8133919/DrawGridLinesTest.java Reviewed-by: yan, alexsch --- .../8133919/{DrawGridLInesTest.java => DrawGridLinesTest.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jdk/test/javax/swing/JTable/8133919/{DrawGridLInesTest.java => DrawGridLinesTest.java} (100%) diff --git a/jdk/test/javax/swing/JTable/8133919/DrawGridLInesTest.java b/jdk/test/javax/swing/JTable/8133919/DrawGridLinesTest.java similarity index 100% rename from jdk/test/javax/swing/JTable/8133919/DrawGridLInesTest.java rename to jdk/test/javax/swing/JTable/8133919/DrawGridLinesTest.java From ad08bcc8afa114109df77dcec59c00a58045b73f Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:15 +0000 Subject: [PATCH 074/154] Added tag jdk-9+152 for changeset 7bf4468cdbc4 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 5e9f2c1b877..56e00db59ee 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -394,3 +394,4 @@ a22e2671d88f6b22a4aa82e3966986542ed2a381 jdk-9+146 b119012d1c2ab2570fe8718633840d0c1f1f441d jdk-9+149 6234069ff9789f7582e1faa32cb6283cbd1a5a2d jdk-9+150 71a766d4c18041a7f833ee22823125b02e1a7f1e jdk-9+151 +ef056360ddf3977d7d2ddbeb456a4d612d19ea05 jdk-9+152 From aea4929010ddd2e5475fa707bae0b5fb966fbbc7 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:16 +0000 Subject: [PATCH 075/154] Added tag jdk-9+152 for changeset 84da697836d6 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index c41ae6d0faa..f83cfd06fef 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -554,3 +554,4 @@ a82cb5350cad96a0b4de496afebe3ded89f27efa jdk-9+146 30e1996bd55da36183434f24ed964adebf9ca71e jdk-9+149 98fe046473c90204cbc9b34c512b9fc10dfb8479 jdk-9+150 2a2ac7d9f52c8cb2b80077e515b5840b947e640c jdk-9+151 +31f1d26c60df7b2e516a4f84160d76ba017d4e09 jdk-9+152 From b8ea96b46f2fcebf42f91cabf539c291655e0193 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:16 +0000 Subject: [PATCH 076/154] Added tag jdk-9+152 for changeset aa067a69215c --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 340cac95c4d..73926ce02dd 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -394,3 +394,4 @@ f95cc86b6ac22ec1ade5d4f825dc7782adeea228 jdk-9+148 00b19338e505690abe93d5995ed74a473d969c2c jdk-9+149 9205e980062a5c4530b51021c6e274025f4ccbdf jdk-9+150 77f827f5bbad3ef795664bc675f72d98d156b9f8 jdk-9+151 +ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152 From d78deb60ae189eed7d1b4cf85f7386cbb5e2904c Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:17 +0000 Subject: [PATCH 077/154] Added tag jdk-9+152 for changeset 88349d40f4e5 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 26ce3b439e7..14b31ffc1ad 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -397,3 +397,4 @@ c8c9c334743caf8155c9809b6b4ac315d3a66476 jdk-9+148 72554d319b474b3636c7d02fe3c110254d111b1a jdk-9+149 77e4e30d9d111272cd4a45a2203e8f570d40b12e jdk-9+150 c48b4d4768b1c2b8fe5d1a844ca13732e5dfbe2a jdk-9+151 +6f8fb1cf7e5f61c40dcc3654f9a623c505f6de1f jdk-9+152 From 40e013c72dd392fff5b9e1eb66a583232ce07640 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:17 +0000 Subject: [PATCH 078/154] Added tag jdk-9+152 for changeset a0b82e2bd8fd --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 0f4ff1ca773..c476846b6a9 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -394,3 +394,4 @@ c45db75bfe8bc20bb80b4a009ae3f69c9cd2d885 jdk-9+148 5978df8bfa3894f2b3d07b7256f25f78dffb1f9c jdk-9+149 f85154af719f99a3b4d81b67a8b4c18a650d10f9 jdk-9+150 13c6906bfc861d99dc35a19c80b7a99f0b0ac58d jdk-9+151 +7e3da313b1746578da648155e37dd8526e83153d jdk-9+152 From 0d660499b6ce22caa53baa6c4d54262c00aa655b Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:17 +0000 Subject: [PATCH 079/154] Added tag jdk-9+152 for changeset 36edf207e84c --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 0b80fe4f688..f1e4cc0eb8c 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -394,3 +394,4 @@ c41140100bf1e5c10c7b8f3bde91c16eff7485f5 jdk-9+147 5a846396a24c7aff01d6a8feaa7afc0a6369f04d jdk-9+149 71e198ef3839045e829a879af1d709be16ab0f88 jdk-9+150 d27bab22ff62823902d93d1d35ca397cfd50d059 jdk-9+151 +a20f2cf90762673e1bc4980fd6597e70a2578045 jdk-9+152 From 6cabc219e0a8f0b5b16574a45d225c54ea9df6b3 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:19 +0000 Subject: [PATCH 080/154] Added tag jdk-9+152 for changeset 7b8b8750a78e --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 49e6afa967e..a9baa97862f 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -394,3 +394,4 @@ cb9e896265ef45295fdd09986dee76624e4d41e4 jdk-9+145 4d4cd7cd731c1952d7330ea5bcfda8bd26820fa5 jdk-9+149 e5a42ddaf633fde14b983f740ae0e7e490741fd1 jdk-9+150 4f348bd05341581df84ff1510d5b3a9b5b488367 jdk-9+151 +5b6f12de6f9167a582fa2c6ac54e69c591b09e68 jdk-9+152 From bba282ab69e3f90e8f67158d7afd5690e1d2b76f Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 12 Jan 2017 23:41:19 +0000 Subject: [PATCH 081/154] Added tag jdk-9+152 for changeset f609c7e798f6 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index f35efaa4ca0..285e632fd15 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -385,3 +385,4 @@ a7f21ee6ed30695a6de14e74035d2857a754f62b jdk-9+144 c281306d33d83c92e0d870ace385d5f99678d7e7 jdk-9+149 ace1d994bca775d6545a4c874ae73d1dfc9ec18b jdk-9+150 2a0437036a64853334e538044eb68d2df70075fa jdk-9+151 +ddc52e72757086a75a54371e8e7f56a3f89f1e55 jdk-9+152 From 5fc51d4ecd054cd93c6bbd4ef4d94884102633b4 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Thu, 12 Jan 2017 15:59:28 -0800 Subject: [PATCH 082/154] 8171528: Crash in Annotate with duplicate package-info declarations Reviewed-by: jjg --- .../classes/com/sun/tools/javac/comp/Annotate.java | 12 ++++++++++-- .../T8171528/DuplicatedAnnotatedPackagesTest.java | 6 ++++++ .../T8171528/DuplicatedAnnotatedPackagesTest.out | 4 ++++ .../test/tools/javac/T8171528/pkg1/package-info.java | 2 ++ .../test/tools/javac/T8171528/pkg2/package-info.java | 2 ++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.java create mode 100644 langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.out create mode 100644 langtools/test/tools/javac/T8171528/pkg1/package-info.java create mode 100644 langtools/test/tools/javac/T8171528/pkg2/package-info.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java index 93c5884633f..72c832f9a36 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,7 @@ import java.util.*; import static com.sun.tools.javac.code.Flags.SYNTHETIC; import static com.sun.tools.javac.code.Kinds.Kind.MDL; import static com.sun.tools.javac.code.Kinds.Kind.MTH; +import static com.sun.tools.javac.code.Kinds.Kind.PCK; import static com.sun.tools.javac.code.Kinds.Kind.VAR; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.ARRAY; @@ -228,7 +229,14 @@ public class Annotate { s.resetAnnotations(); // mark Annotations as incomplete for now normal(() -> { - Assert.check(s.annotationsPendingCompletion()); + // Packages are unusual, in that they are the only type of declaration that can legally appear + // more than once in a compilation, and in all cases refer to the same underlying symbol. + // This means they are the only kind of declaration that syntactically may have multiple sets + // of annotations, each on a different package declaration, even though that is ultimately + // forbidden by JLS 8 section 7.4. + // The corollary here is that all of the annotations on a package symbol may have already + // been handled, meaning that the set of annotations pending completion is now empty. + Assert.check(s.kind == PCK || s.annotationsPendingCompletion()); JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); DiagnosticPosition prevLintPos = deferPos != null diff --git a/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.java b/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.java new file mode 100644 index 00000000000..b3c37ed349f --- /dev/null +++ b/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.java @@ -0,0 +1,6 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8171528 + * @summary Crash in Annotate with duplicate package-info declarations + * @compile/fail/ref=DuplicatedAnnotatedPackagesTest.out -XDrawDiagnostics pkg1/package-info.java pkg2/package-info.java + */ diff --git a/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.out b/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.out new file mode 100644 index 00000000000..cdfe50c8bbe --- /dev/null +++ b/langtools/test/tools/javac/T8171528/DuplicatedAnnotatedPackagesTest.out @@ -0,0 +1,4 @@ +package-info.java:2:9: compiler.warn.pkg-info.already.seen: test +package-info.java:1:1: compiler.err.already.annotated: kindname.package, test +1 error +1 warning diff --git a/langtools/test/tools/javac/T8171528/pkg1/package-info.java b/langtools/test/tools/javac/T8171528/pkg1/package-info.java new file mode 100644 index 00000000000..5ff93a776a7 --- /dev/null +++ b/langtools/test/tools/javac/T8171528/pkg1/package-info.java @@ -0,0 +1,2 @@ +@Deprecated +package test; diff --git a/langtools/test/tools/javac/T8171528/pkg2/package-info.java b/langtools/test/tools/javac/T8171528/pkg2/package-info.java new file mode 100644 index 00000000000..5ff93a776a7 --- /dev/null +++ b/langtools/test/tools/javac/T8171528/pkg2/package-info.java @@ -0,0 +1,2 @@ +@Deprecated +package test; From cb9f76175c61478fcd24e340a943a8c0c6103202 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Thu, 12 Jan 2017 16:41:08 -0800 Subject: [PATCH 083/154] 8172432: jar cleanup/update for module and mrm jar 8171830: jar tool should validate if any exported or open package is missing Reviewed-by: mchung, psandoz, chegar --- .../sun/tools/jar/GNUStyleOptions.java | 43 +- .../share/classes/sun/tools/jar/Main.java | 808 ++++++------------ .../classes/sun/tools/jar/Validator.java | 252 +++++- .../sun/tools/jar/resources/jar.properties | 37 +- .../sun/tools/jar/resources/jar_de.properties | 14 +- .../sun/tools/jar/resources/jar_es.properties | 14 +- .../sun/tools/jar/resources/jar_fr.properties | 14 +- .../sun/tools/jar/resources/jar_it.properties | 14 +- .../sun/tools/jar/resources/jar_ja.properties | 14 +- .../sun/tools/jar/resources/jar_ko.properties | 14 +- .../tools/jar/resources/jar_pt_BR.properties | 14 +- .../sun/tools/jar/resources/jar_sv.properties | 14 +- .../tools/jar/resources/jar_zh_CN.properties | 14 +- .../tools/jar/resources/jar_zh_TW.properties | 14 +- .../{ConcealedPackage.java => Basic.java} | 139 ++- jdk/test/tools/jar/modularJar/Basic.java | 29 +- .../tools/jar/modularJar/src/foobar/Bar.java | 28 + .../tools/jar/modularJar/src/foobar/Foo.java | 28 + .../modularJar/src/foobar/module-info.java | 29 + jdk/test/tools/jar/multiRelease/Basic1.java | 21 +- 20 files changed, 859 insertions(+), 695 deletions(-) rename jdk/test/tools/jar/mmrjar/{ConcealedPackage.java => Basic.java} (70%) create mode 100644 jdk/test/tools/jar/modularJar/src/foobar/Bar.java create mode 100644 jdk/test/tools/jar/modularJar/src/foobar/Foo.java create mode 100644 jdk/test/tools/jar/modularJar/src/foobar/module-info.java diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java index 1b5d48a6b4a..a98e0eed289 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java @@ -169,9 +169,9 @@ class GNUStyleOptions { new Option(true, OptionType.CREATE_UPDATE, "--warn-if-resolved") { void process(Main jartool, String opt, String arg) throws BadArgs { ModuleResolution mres = ModuleResolution.empty(); - if (jartool.moduleResolution.doNotResolveByDefault()) + if (jartool.moduleResolution.doNotResolveByDefault()) { mres.withDoNotResolveByDefault(); - + } if (arg.equals("deprecated")) { jartool.moduleResolution = mres.withDeprecated(); } else if (arg.equals("deprecated-for-removal")) { @@ -201,26 +201,27 @@ class GNUStyleOptions { // Other options new Option(true, true, OptionType.OTHER, "--help", "-h") { void process(Main jartool, String opt, String arg) throws BadArgs { - if (arg == null) { - jartool.info = Main.Info.HELP; - return; + if (jartool.info == null) { + if (arg == null) { + jartool.info = GNUStyleOptions::printHelp; // Main.Info.HELP; + return; + } + if (!arg.equals("compat")) + throw new BadArgs("error.illegal.option", arg).showUsage(true); + // jartool.info = Main.Info.COMPAT_HELP; + jartool.info = GNUStyleOptions::printCompatHelp; } - - if (!arg.equals("compat")) - throw new BadArgs("error.illegal.option", arg).showUsage(true); - - jartool.info = Main.Info.COMPAT_HELP; } }, new Option(false, OptionType.OTHER, "--help-extra") { void process(Main jartool, String opt, String arg) throws BadArgs { - jartool.info = Main.Info.HELP_EXTRA; + jartool.info = GNUStyleOptions::printHelpExtra; } }, new Option(false, OptionType.OTHER, "--version") { void process(Main jartool, String opt, String arg) { if (jartool.info == null) - jartool.info = Main.Info.VERSION; + jartool.info = GNUStyleOptions::printVersion; } } }; @@ -279,14 +280,14 @@ class GNUStyleOptions { static int parseOptions(Main jartool, String[] args) throws BadArgs { int count = 0; if (args.length == 0) { - jartool.info = Main.Info.USAGE_TRYHELP; + jartool.info = GNUStyleOptions::printUsageTryHelp; // never be here return 0; } // process options for (; count < args.length; count++) { - if (args[count].charAt(0) != '-' || args[count].equals("-C") - || args[count].equals("--release")) + if (args[count].charAt(0) != '-' || args[count].equals("-C") || + args[count].equals("--release")) break; String name = args[count]; @@ -322,15 +323,15 @@ class GNUStyleOptions { throw new BadArgs("error.unrecognized.option", name).showUsage(true); } - static void printHelp(PrintWriter out) { - printHelp(out, false); - } - static void printHelpExtra(PrintWriter out) { - printHelp(out, true); + printHelp0(out, true); } - private static void printHelp(PrintWriter out, boolean printExtra) { + static void printHelp(PrintWriter out) { + printHelp0(out, false); + } + + private static void printHelp0(PrintWriter out, boolean printExtra) { out.format("%s%n", Main.getMsg("main.help.preopt")); for (OptionType type : OptionType.values()) { boolean typeHeadingWritten = false; diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java index 8e0fc0160de..cd9317e85a4 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ package sun.tools.jar; import java.io.*; import java.lang.module.Configuration; +import java.lang.module.InvalidModuleDescriptorException; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor.Exports; import java.lang.module.ModuleDescriptor.Provides; @@ -47,6 +48,7 @@ import java.nio.file.StandardCopyOption; import java.util.*; import java.util.function.Consumer; import java.util.function.Function; +import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -74,58 +76,24 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; * (Java Archive) file format. The JAR format is based on the ZIP file * format, with optional meta-information stored in a MANIFEST entry. */ -public -class Main { +public class Main { String program; PrintWriter out, err; String fname, mname, ename; String zname = ""; String rootjar = null; - Set concealedPackages = new HashSet<>(); // used by Validator private static final int BASE_VERSION = 0; - class Entry { - final String basename; - final String entryname; + private static class Entry { + final String name; final File file; final boolean isDir; - Entry(File file, String basename, String entryname) { + Entry(File file, String name, boolean isDir) { this.file = file; - this.isDir = file.isDirectory(); - this.basename = basename; - this.entryname = entryname; - } - - Entry(int version, File file) { - this.file = file; - String path = file.getPath(); - if (file.isDirectory()) { - isDir = true; - path = path.endsWith(File.separator) ? path : - path + File.separator; - } else { - isDir = false; - } - EntryName en = new EntryName(path, version); - basename = en.baseName; - entryname = en.entryName; - } - - /** - * Returns a new Entry that trims the versions directory. - * - * This entry should be a valid entry matching the given version. - */ - Entry toVersionedEntry(int version) { - assert isValidVersionedEntry(this, version); - - if (version == BASE_VERSION) - return this; - - EntryName en = new EntryName(trimVersionsDir(basename, version), version); - return new Entry(this.file, en.baseName, en.entryName); + this.isDir = isDir; + this.name = name; } @Override @@ -141,32 +109,6 @@ class Main { } } - class EntryName { - final String baseName; - final String entryName; - - EntryName(String name, int version) { - name = name.replace(File.separatorChar, '/'); - String matchPath = ""; - for (String path : pathsMap.get(version)) { - if (name.startsWith(path) - && (path.length() > matchPath.length())) { - matchPath = path; - } - } - name = safeName(name.substring(matchPath.length())); - // the old implementaton doesn't remove - // "./" if it was led by "/" (?) - if (name.startsWith("./")) { - name = name.substring(2); - } - baseName = name; - entryName = (version > BASE_VERSION) - ? VERSIONS_DIR + version + "/" + baseName - : baseName; - } - } - // An entryName(path)->Entry map generated during "expand", it helps to // decide whether or not an existing entry in a jar file needs to be // replaced, during the "update" operation. @@ -175,11 +117,8 @@ class Main { // All entries need to be added/updated. Set entries = new LinkedHashSet<>(); - // All packages. - Set packages = new HashSet<>(); - // All actual entries added, or existing, in the jar file ( excl manifest - // and module-info.class ). Populated during create or update. - Set jarEntries = new HashSet<>(); + // module-info.class entries need to be added/updated. + Map moduleInfos = new HashMap<>(); // A paths Set for each version, where each Set contains directories // specified by the "-C" operation. @@ -208,19 +147,7 @@ class Main { boolean cflag, uflag, xflag, tflag, vflag, flag0, Mflag, iflag, nflag, pflag, dflag; /* To support additional GNU Style informational options */ - enum Info { - HELP(GNUStyleOptions::printHelp), - HELP_EXTRA(GNUStyleOptions::printHelpExtra), - COMPAT_HELP(GNUStyleOptions::printCompatHelp), - USAGE_TRYHELP(GNUStyleOptions::printUsageTryHelp), - VERSION(GNUStyleOptions::printVersion); - - private Consumer printFunction; - Info(Consumer f) { this.printFunction = f; } - void print(PrintWriter out) { printFunction.accept(out); } - }; - Info info; - + Consumer info; /* Modular jar related options */ Version moduleVersion; @@ -228,8 +155,7 @@ class Main { ModuleResolution moduleResolution = ModuleResolution.empty(); ModuleFinder moduleFinder = ModuleFinder.of(); - private static final String MODULE_INFO = "module-info.class"; - + static final String MODULE_INFO = "module-info.class"; static final String MANIFEST_DIR = "META-INF/"; static final String VERSIONS_DIR = MANIFEST_DIR + "versions/"; static final String VERSION = "1.0"; @@ -324,7 +250,6 @@ class Main { } } } - if (cflag) { Manifest manifest = null; if (!Mflag) { @@ -347,72 +272,60 @@ class Main { addMultiRelease(manifest); } } - - Map moduleInfoPaths = new HashMap<>(); - for (int version : filesMap.keySet()) { - String[] files = filesMap.get(version); - expand(null, files, false, moduleInfoPaths, version); - } - - Map moduleInfos = new LinkedHashMap<>(); - if (!moduleInfoPaths.isEmpty()) { - if (!checkModuleInfos(moduleInfoPaths)) - return false; - - // root module-info first - byte[] b = readModuleInfo(moduleInfoPaths.get(MODULE_INFO)); - moduleInfos.put(MODULE_INFO, b); - for (Map.Entry e : moduleInfoPaths.entrySet()) - moduleInfos.putIfAbsent(e.getKey(), readModuleInfo(e.getValue())); - - if (!addExtendedModuleAttributes(moduleInfos)) - return false; + expand(); + if (!moduleInfos.isEmpty()) { + // All actual file entries (excl manifest and module-info.class) + Set jentries = new HashSet<>(); + // all packages if it's a class or resource + Set packages = new HashSet<>(); + entries.stream() + .filter(e -> !e.isDir) + .forEach( e -> { + addPackageIfNamed(packages, e.name); + jentries.add(e.name); + }); + addExtendedModuleAttributes(moduleInfos, packages); // Basic consistency checks for modular jars. - if (!checkServices(moduleInfos.get(MODULE_INFO))) + if (!checkModuleInfo(moduleInfos.get(MODULE_INFO), jentries)) return false; } else if (moduleVersion != null || modulesToHash != null) { error(getMsg("error.module.options.without.info")); return false; } - if (vflag && fname == null) { // Disable verbose output so that it does not appear // on stdout along with file data // error("Warning: -v option ignored"); vflag = false; } - final String tmpbase = (fname == null) ? "tmpjar" : fname.substring(fname.indexOf(File.separatorChar) + 1); + File tmpfile = createTemporaryFile(tmpbase, ".jar"); - try (OutputStream out = new FileOutputStream(tmpfile)) { - create(new BufferedOutputStream(out, 4096), manifest, moduleInfos); + create(new BufferedOutputStream(out, 4096), manifest); } - if (nflag) { File packFile = createTemporaryFile(tmpbase, ".pack"); try { Packer packer = Pack200.newPacker(); Map p = packer.properties(); p.put(Packer.EFFORT, "1"); // Minimal effort to conserve CPU - try ( - JarFile jarFile = new JarFile(tmpfile.getCanonicalPath()); - OutputStream pack = new FileOutputStream(packFile) - ) { + try (JarFile jarFile = new JarFile(tmpfile.getCanonicalPath()); + OutputStream pack = new FileOutputStream(packFile)) + { packer.pack(jarFile, pack); } if (tmpfile.exists()) { tmpfile.delete(); } tmpfile = createTemporaryFile(tmpbase, ".jar"); - try ( - OutputStream out = new FileOutputStream(tmpfile); - JarOutputStream jos = new JarOutputStream(out) - ) { + try (OutputStream out = new FileOutputStream(tmpfile); + JarOutputStream jos = new JarOutputStream(out)) + { Unpacker unpacker = Pack200.newUnpacker(); unpacker.unpack(packFile, jos); } @@ -420,9 +333,7 @@ class Main { Files.deleteIfExists(packFile.toPath()); } } - validateAndClose(tmpfile); - } else if (uflag) { File inputFile = null, tmpFile = null; if (fname != null) { @@ -432,39 +343,20 @@ class Main { vflag = false; tmpFile = createTemporaryFile("tmpjar", ".jar"); } - - Map moduleInfoPaths = new HashMap<>(); - for (int version : filesMap.keySet()) { - String[] files = filesMap.get(version); - expand(null, files, true, moduleInfoPaths, version); - } - - Map moduleInfos = new HashMap<>(); - for (Map.Entry e : moduleInfoPaths.entrySet()) - moduleInfos.put(e.getKey(), readModuleInfo(e.getValue())); - - try ( - FileInputStream in = (fname != null) ? new FileInputStream(inputFile) - : new FileInputStream(FileDescriptor.in); - FileOutputStream out = new FileOutputStream(tmpFile); - InputStream manifest = (!Mflag && (mname != null)) ? - (new FileInputStream(mname)) : null; + expand(); + try (FileInputStream in = (fname != null) ? new FileInputStream(inputFile) + : new FileInputStream(FileDescriptor.in); + FileOutputStream out = new FileOutputStream(tmpFile); + InputStream manifest = (!Mflag && (mname != null)) ? + (new FileInputStream(mname)) : null; ) { - boolean updateOk = update(in, new BufferedOutputStream(out), - manifest, moduleInfos, null); - if (ok) { - ok = updateOk; - } + boolean updateOk = update(in, new BufferedOutputStream(out), + manifest, moduleInfos, null); + if (ok) { + ok = updateOk; + } } - - // Consistency checks for modular jars. - if (!moduleInfos.isEmpty()) { - if(!checkServices(moduleInfos.get(MODULE_INFO))) - return false; - } - validateAndClose(tmpFile); - } else if (tflag) { replaceFSC(filesMap); // For the "list table contents" action, access using the @@ -542,12 +434,15 @@ class Main { private void validateAndClose(File tmpfile) throws IOException { if (ok && isMultiRelease) { - ok = validate(tmpfile.getCanonicalPath()); - if (!ok) { - error(formatMsg("error.validator.jarfile.invalid", fname)); + try { + ok = Validator.validate(this, tmpfile); + if (!ok) { + error(formatMsg("error.validator.jarfile.invalid", fname)); + } + } catch (IOException e) { + error(formatMsg2("error.validator.jarfile.exception", fname, e.getMessage())); } } - Path path = tmpfile.toPath(); try { if (ok) { @@ -572,78 +467,9 @@ class Main { Stream filesToEntryNames(Map.Entry fileEntries) { int version = fileEntries.getKey(); + Set cpaths = pathsMap.get(version); return Stream.of(fileEntries.getValue()) - .map(f -> (new EntryName(f, version)).entryName); - } - - // sort base entries before versioned entries, and sort entry classes with - // nested classes so that the top level class appears before the associated - // nested class - private Comparator entryComparator = (je1, je2) -> { - String s1 = je1.getName(); - String s2 = je2.getName(); - if (s1.equals(s2)) return 0; - boolean b1 = s1.startsWith(VERSIONS_DIR); - boolean b2 = s2.startsWith(VERSIONS_DIR); - if (b1 && !b2) return 1; - if (!b1 && b2) return -1; - int n = 0; // starting char for String compare - if (b1 && b2) { - // normally strings would be sorted so "10" goes before "9", but - // version number strings need to be sorted numerically - n = VERSIONS_DIR.length(); // skip the common prefix - int i1 = s1.indexOf('/', n); - int i2 = s1.indexOf('/', n); - if (i1 == -1) throw new InvalidJarException(s1); - if (i2 == -1) throw new InvalidJarException(s2); - // shorter version numbers go first - if (i1 != i2) return i1 - i2; - // otherwise, handle equal length numbers below - } - int l1 = s1.length(); - int l2 = s2.length(); - int lim = Math.min(l1, l2); - for (int k = n; k < lim; k++) { - char c1 = s1.charAt(k); - char c2 = s2.charAt(k); - if (c1 != c2) { - // change natural ordering so '.' comes before '$' - // i.e. top level classes come before nested classes - if (c1 == '$' && c2 == '.') return 1; - if (c1 == '.' && c2 == '$') return -1; - return c1 - c2; - } - } - return l1 - l2; - }; - - private boolean validate(String fname) { - boolean valid; - - try (JarFile jf = new JarFile(fname)) { - Validator validator = new Validator(this, jf); - jf.stream() - .filter(e -> !e.isDirectory()) - .filter(e -> !e.getName().equals(MANIFEST_NAME)) - .filter(e -> !e.getName().endsWith(MODULE_INFO)) - .sorted(entryComparator) - .forEachOrdered(validator); - valid = validator.isValid(); - } catch (IOException e) { - error(formatMsg2("error.validator.jarfile.exception", fname, e.getMessage())); - valid = false; - } catch (InvalidJarException e) { - error(formatMsg("error.validator.bad.entry.name", e.getMessage())); - valid = false; - } - return valid; - } - - private static class InvalidJarException extends RuntimeException { - private static final long serialVersionUID = -3642329147299217726L; - InvalidJarException(String msg) { - super(msg); - } + .map(f -> toVersionedName(toEntryName(f, cpaths, false), version)); } /** @@ -668,20 +494,22 @@ class Main { // Note: flags.length == 2 can be treated as the short version of // the GNU option since the there cannot be any other options, // excluding -C, as per the old way. - if (flags.startsWith("--") - || (flags.startsWith("-") && flags.length() == 2)) { + if (flags.startsWith("--") || + (flags.startsWith("-") && flags.length() == 2)) { try { count = GNUStyleOptions.parseOptions(this, args); } catch (GNUStyleOptions.BadArgs x) { if (info == null) { - error(x.getMessage()); - if (x.showUsage) - Info.USAGE_TRYHELP.print(err); + if (x.showUsage) { + usageError(x.getMessage()); + } else { + error(x.getMessage()); + } return false; } } if (info != null) { - info.print(out); + info.accept(out); return true; } } else { @@ -851,19 +679,55 @@ class Main { * Add the package of the given resource name if it's a .class * or a resource in a named package. */ - boolean addPackageIfNamed(String name) { + void addPackageIfNamed(Set packages, String name) { if (name.startsWith(VERSIONS_DIR)) { - throw new InternalError(name); + // trim the version dir prefix + int i0 = VERSIONS_DIR.length(); + int i = name.indexOf('/', i0); + if (i <= 0) { + warn(formatMsg("warn.release.unexpected.versioned.entry", name)); + return; + } + while (i0 < i) { + char c = name.charAt(i0); + if (c < '0' || c > '9') { + warn(formatMsg("warn.release.unexpected.versioned.entry", name)); + return; + } + i0++; + } + name = name.substring(i + 1, name.length()); } - String pn = toPackageName(name); // add if this is a class or resource in a package if (Checks.isJavaIdentifier(pn)) { packages.add(pn); - return true; } + } - return false; + private String toEntryName(String name, Set cpaths, boolean isDir) { + name = name.replace(File.separatorChar, '/'); + if (isDir) { + name = name.endsWith("/") ? name : name + "/"; + } + String matchPath = ""; + for (String path : cpaths) { + if (name.startsWith(path) && path.length() > matchPath.length()) { + matchPath = path; + } + } + name = safeName(name.substring(matchPath.length())); + // the old implementaton doesn't remove + // "./" if it was led by "/" (?) + if (name.startsWith("./")) { + name = name.substring(2); + } + return name; + } + + private static String toVersionedName(String name, int version) { + return version > BASE_VERSION + ? VERSIONS_DIR + version + "/" + name : name; } private static String toPackageName(String path) { @@ -875,57 +739,23 @@ class Main { } } - /* - * Returns true if the given entry is a valid entry of the given version. - */ - private boolean isValidVersionedEntry(Entry entry, int version) { - String name = entry.basename; - if (name.startsWith(VERSIONS_DIR) && version != BASE_VERSION) { - int i = name.indexOf('/', VERSIONS_DIR.length()); - // name == -1 -> not a versioned directory, something else - if (i == -1) - return false; - try { - String v = name.substring(VERSIONS_DIR.length(), i); - return Integer.valueOf(v) == version; - } catch (NumberFormatException x) { - return false; - } + private void expand() throws IOException { + for (int version : filesMap.keySet()) { + String[] files = filesMap.get(version); + expand(null, files, pathsMap.get(version), version); } - return true; - } - - /* - * Trim META-INF/versions/$version/ from the given name if the - * given name is a versioned entry of the given version; or - * of any version if the given version is BASE_VERSION - */ - private String trimVersionsDir(String name, int version) { - if (name.startsWith(VERSIONS_DIR)) { - int i = name.indexOf('/', VERSIONS_DIR.length()); - if (i >= 0) { - try { - String v = name.substring(VERSIONS_DIR.length(), i); - if (version == BASE_VERSION || Integer.valueOf(v) == version) { - return name.substring(i + 1, name.length()); - } - } catch (NumberFormatException x) {} - } - throw new InternalError("unexpected versioned entry: " + - name + " version " + version); - } - return name; } /** * Expands list of files to process into full list of all files that * can be found by recursively descending directories. + * + * @param dir parent directory + * @param file s list of files to expand + * @param cpaths set of directories specified by -C option for the files + * @throws IOException if an I/O error occurs */ - void expand(File dir, - String[] files, - boolean isUpdate, - Map moduleInfoPaths, - int version) + private void expand(File dir, String[] files, Set cpaths, int version) throws IOException { if (files == null) @@ -938,47 +768,48 @@ class Main { else f = new File(dir, files[i]); - Entry e = new Entry(version, f); - String entryName = e.entryname; - Entry entry = e; - if (e.basename.startsWith(VERSIONS_DIR) && isValidVersionedEntry(e, version)) { - entry = e.toVersionedEntry(version); + boolean isDir = f.isDirectory(); + String name = toEntryName(f.getPath(), cpaths, isDir); + + if (version != BASE_VERSION) { + if (name.startsWith(VERSIONS_DIR)) { + // the entry starts with VERSIONS_DIR and version != BASE_VERSION, + // which means the "[dirs|files]" in --release v [dirs|files] + // includes VERSIONS_DIR-ed entries --> warning and skip (?) + error(formatMsg2("error.release.unexpected.versioned.entry", + name, String.valueOf(version))); + ok = false; + return; + } + name = toVersionedName(name, version); } + if (f.isFile()) { - if (entryName.endsWith(MODULE_INFO)) { - moduleInfoPaths.put(entryName, f.toPath()); - if (isUpdate) - entryMap.put(entryName, entry); - } else if (isValidVersionedEntry(entry, version)) { - if (entries.add(entry)) { - jarEntries.add(entryName); - // add the package if it's a class or resource - addPackageIfNamed(trimVersionsDir(entry.basename, version)); - if (isUpdate) - entryMap.put(entryName, entry); - } - } else { - error(formatMsg2("error.release.unexpected.versioned.entry", - entry.basename, String.valueOf(version))); - ok = false; + Entry e = new Entry(f, name, false); + if (isModuleInfoEntry(name)) { + moduleInfos.putIfAbsent(name, Files.readAllBytes(f.toPath())); + if (uflag) + entryMap.put(name, e); + } else if (entries.add(e)) { + if (uflag) + entryMap.put(name, e); } - } else if (f.isDirectory()) { - if (isValidVersionedEntry(entry, version)) { - if (entries.add(entry)) { - if (isUpdate) { - entryMap.put(entryName, entry); - } + } else if (isDir) { + Entry e = new Entry(f, name, true); + if (entries.add(e)) { + // utilize entryMap for the duplicate dir check even in + // case of cflag == true. + // dir name confilict/duplicate could happen with -C option. + // just remove the last "e" from the "entries" (zos will fail + // with "duplicated" entries), but continue expanding the + // sub tree + if (entryMap.containsKey(name)) { + entries.remove(e); + } else { + entryMap.put(name, e); } - } else if (entry.basename.equals(VERSIONS_DIR)) { - if (vflag) { - output(formatMsg("out.ignore.entry", entry.basename)); - } - } else { - error(formatMsg2("error.release.unexpected.versioned.entry", - entry.basename, String.valueOf(version))); - ok = false; + expand(f, f.list(), cpaths, version); } - expand(f, f.list(), isUpdate, moduleInfoPaths, version); } else { error(formatMsg("error.nosuch.fileordir", String.valueOf(f))); ok = false; @@ -989,52 +820,36 @@ class Main { /** * Creates a new JAR file. */ - void create(OutputStream out, Manifest manifest, Map moduleInfos) - throws IOException + void create(OutputStream out, Manifest manifest) throws IOException { - ZipOutputStream zos = new JarOutputStream(out); - if (flag0) { - zos.setMethod(ZipOutputStream.STORED); - } - // TODO: check module-info attributes against manifest ?? - if (manifest != null) { - if (vflag) { - output(getMsg("out.added.manifest")); - } - ZipEntry e = new ZipEntry(MANIFEST_DIR); - e.setTime(System.currentTimeMillis()); - e.setSize(0); - e.setCrc(0); - zos.putNextEntry(e); - e = new ZipEntry(MANIFEST_NAME); - e.setTime(System.currentTimeMillis()); + try (ZipOutputStream zos = new JarOutputStream(out)) { if (flag0) { - crc32Manifest(e, manifest); + zos.setMethod(ZipOutputStream.STORED); } - zos.putNextEntry(e); - manifest.write(zos); - zos.closeEntry(); - } - for (Map.Entry mi : moduleInfos.entrySet()) { - String entryName = mi.getKey(); - byte[] miBytes = mi.getValue(); - if (vflag) { - output(formatMsg("out.added.module-info", entryName)); + // TODO: check module-info attributes against manifest ?? + if (manifest != null) { + if (vflag) { + output(getMsg("out.added.manifest")); + } + ZipEntry e = new ZipEntry(MANIFEST_DIR); + e.setTime(System.currentTimeMillis()); + e.setSize(0); + e.setCrc(0); + zos.putNextEntry(e); + e = new ZipEntry(MANIFEST_NAME); + e.setTime(System.currentTimeMillis()); + if (flag0) { + crc32Manifest(e, manifest); + } + zos.putNextEntry(e); + manifest.write(zos); + zos.closeEntry(); } - ZipEntry e = new ZipEntry(mi.getKey()); - e.setTime(System.currentTimeMillis()); - if (flag0) { - crc32ModuleInfo(e, miBytes); + updateModuleInfo(moduleInfos, zos); + for (Entry entry : entries) { + addFile(zos, entry); } - zos.putNextEntry(e); - ByteArrayInputStream in = new ByteArrayInputStream(miBytes); - in.transferTo(zos); - zos.closeEntry(); } - for (Entry entry : entries) { - addFile(zos, entry); - } - zos.close(); } private char toUpperCaseASCII(char c) { @@ -1061,30 +876,6 @@ class Main { return true; } - /** - * Returns true of the given module-info's are located in acceptable - * locations. Otherwise, outputs an appropriate message and returns false. - */ - private boolean checkModuleInfos(Map moduleInfos) { - // there must always be, at least, a root module-info - if (!moduleInfos.containsKey(MODULE_INFO)) { - error(getMsg("error.versioned.info.without.root")); - return false; - } - - // module-info can only appear in the root, or a versioned section - Optional other = moduleInfos.keySet().stream() - .filter(x -> !x.equals(MODULE_INFO)) - .filter(x -> !x.startsWith(VERSIONS_DIR)) - .findFirst(); - - if (other.isPresent()) { - error(formatMsg("error.unexpected.module-info", other.get())); - return false; - } - return true; - } - /** * Updates an existing jar file. */ @@ -1099,6 +890,10 @@ class Main { boolean foundManifest = false; boolean updateOk = true; + // All actual entries added/updated/existing, in the jar file (excl manifest + // and module-info.class ). + Set jentries = new HashSet<>(); + if (jarIndex != null) { addIndex(jarIndex, zos); } @@ -1108,7 +903,7 @@ class Main { String name = e.getName(); boolean isManifestEntry = equalsIgnoreCase(name, MANIFEST_NAME); - boolean isModuleInfoEntry = name.endsWith(MODULE_INFO); + boolean isModuleInfoEntry = isModuleInfoEntry(name); if ((jarIndex != null && equalsIgnoreCase(name, INDEX_NAME)) || (Mflag && isManifestEntry)) { @@ -1127,7 +922,6 @@ class Main { return false; } } - // Update the manifest. Manifest old = new Manifest(zis); if (newManifest != null) { @@ -1137,7 +931,7 @@ class Main { return false; } } else if (moduleInfos != null && isModuleInfoEntry) { - moduleInfos.putIfAbsent(name, readModuleInfo(zis)); + moduleInfos.putIfAbsent(name, zis.readAllBytes()); } else { boolean isDir = e.isDirectory(); if (!entryMap.containsKey(name)) { // copy the old stuff @@ -1160,11 +954,8 @@ class Main { entries.remove(ent); isDir = ent.isDir; } - - jarEntries.add(name); if (!isDir) { - // add the package if it's a class or resource - addPackageIfNamed(trimVersionsDir(name, BASE_VERSION)); + jentries.add(name); } } } @@ -1172,6 +963,9 @@ class Main { // add the remaining new files for (Entry entry : entries) { addFile(zos, entry); + if (!entry.isDir) { + jentries.add(entry.name); + } } if (!foundManifest) { if (newManifest != null) { @@ -1188,35 +982,24 @@ class Main { } } } - - if (moduleInfos != null && !moduleInfos.isEmpty()) { - if (!checkModuleInfos(moduleInfos)) + if (updateOk) { + if (moduleInfos != null && !moduleInfos.isEmpty()) { + Set pkgs = new HashSet<>(); + jentries.forEach( je -> addPackageIfNamed(pkgs, je)); + addExtendedModuleAttributes(moduleInfos, pkgs); + updateOk = checkModuleInfo(moduleInfos.get(MODULE_INFO), jentries); + updateModuleInfo(moduleInfos, zos); + // TODO: check manifest main classes, etc + } else if (moduleVersion != null || modulesToHash != null) { + error(getMsg("error.module.options.without.info")); updateOk = false; - - if (updateOk) { - if (!addExtendedModuleAttributes(moduleInfos)) - updateOk = false; } - - // TODO: check manifest main classes, etc - - if (updateOk) { - for (Map.Entry mi : moduleInfos.entrySet()) { - if (!updateModuleInfo(mi.getValue(), zos, mi.getKey())) - updateOk = false; - } - } - } else if (moduleVersion != null || modulesToHash != null) { - error(getMsg("error.module.options.without.info")); - updateOk = false; } - zis.close(); zos.close(); return updateOk; } - private void addIndex(JarIndex index, ZipOutputStream zos) throws IOException { @@ -1232,20 +1015,25 @@ class Main { zos.closeEntry(); } - private boolean updateModuleInfo(byte[] moduleInfoBytes, ZipOutputStream zos, String entryName) + private void updateModuleInfo(Map moduleInfos, ZipOutputStream zos) throws IOException { - ZipEntry e = new ZipEntry(entryName); - e.setTime(System.currentTimeMillis()); - if (flag0) { - crc32ModuleInfo(e, moduleInfoBytes); + String fmt = uflag ? "out.update.module-info": "out.added.module-info"; + for (Map.Entry mi : moduleInfos.entrySet()) { + String name = mi.getKey(); + byte[] bytes = mi.getValue(); + ZipEntry e = new ZipEntry(name); + e.setTime(System.currentTimeMillis()); + if (flag0) { + crc32ModuleInfo(e, bytes); + } + zos.putNextEntry(e); + zos.write(bytes); + zos.closeEntry(); + if (vflag) { + output(formatMsg(fmt, name)); + } } - zos.putNextEntry(e); - zos.write(moduleInfoBytes); - if (vflag) { - output(formatMsg("out.update.module-info", entryName)); - } - return true; } private boolean updateManifest(Manifest m, ZipOutputStream zos) @@ -1358,11 +1146,9 @@ class Main { * Adds a new file entry to the ZIP output stream. */ void addFile(ZipOutputStream zos, Entry entry) throws IOException { - // skip the generation of directory entries for META-INF/versions/*/ - if (entry.basename.isEmpty()) return; File file = entry.file; - String name = entry.entryname; + String name = entry.name; boolean isDir = entry.isDir; if (name.equals("") || name.equals(".") || name.equals(zname)) { @@ -1444,11 +1230,8 @@ class Main { * @throws IOException if an I/O error occurs */ private void copy(File from, OutputStream to) throws IOException { - InputStream in = new FileInputStream(from); - try { + try (InputStream in = new FileInputStream(from)) { copy(in, to); - } finally { - in.close(); } } @@ -1461,11 +1244,8 @@ class Main { * @throws IOException if an I/O error occurs */ private void copy(InputStream from, File to) throws IOException { - OutputStream out = new FileOutputStream(to); - try { + try (OutputStream out = new FileOutputStream(to)) { copy(from, out); - } finally { - out.close(); } } @@ -1825,7 +1605,7 @@ class Main { */ void usageError(String s) { err.println(s); - Info.USAGE_TRYHELP.print(err); + err.println(getMsg("main.usage.summary.try")); } /** @@ -1934,16 +1714,6 @@ class Main { return tmpfile; } - private static byte[] readModuleInfo(InputStream zis) throws IOException { - return zis.readAllBytes(); - } - - private static byte[] readModuleInfo(Path path) throws IOException { - try (InputStream is = Files.newInputStream(path)) { - return is.readAllBytes(); - } - } - // Modular jar support static String toString(Collection c, @@ -1951,7 +1721,6 @@ class Main { CharSequence suffix ) { if (c.isEmpty()) return ""; - return c.stream().map(e -> e.toString()) .collect(joining(", ", prefix, suffix)); } @@ -2045,136 +1814,84 @@ class Main { md.osVersion().ifPresent(v -> sb.append("\n operating-system-version " + v)); - if (hashes != null) { - hashes.names().stream().sorted().forEach( - mod -> sb.append("\n hashes ").append(mod).append(" ") - .append(hashes.algorithm()).append(" ") - .append(toHex(hashes.hashFor(mod)))); + if (hashes != null) { + hashes.names().stream().sorted().forEach( + mod -> sb.append("\n hashes ").append(mod).append(" ") + .append(hashes.algorithm()).append(" ") + .append(toHex(hashes.hashFor(mod)))); } output(sb.toString()); } private static String toHex(byte[] ba) { - StringBuilder sb = new StringBuilder(ba.length); + StringBuilder sb = new StringBuilder(ba.length << 1); for (byte b: ba) { sb.append(String.format("%02x", b & 0xff)); } return sb.toString(); } - private static String toBinaryName(String classname) { + static String toBinaryName(String classname) { return (classname.replace('.', '/')) + ".class"; } - /* A module must have the implementation class of the services it 'provides'. */ - private boolean checkServices(byte[] moduleInfoBytes) + private boolean checkModuleInfo(byte[] moduleInfoBytes, Set entries) throws IOException { - ModuleDescriptor md = ModuleDescriptor.read(ByteBuffer.wrap(moduleInfoBytes)); - Set missing = md.provides() - .stream() - .map(Provides::providers) - .flatMap(List::stream) - .filter(p -> !jarEntries.contains(toBinaryName(p))) - .collect(Collectors.toSet()); - if (missing.size() > 0) { - missing.stream().forEach(s -> fatalError(formatMsg("error.missing.provider", s))); - return false; + boolean ok = true; + if (moduleInfoBytes != null) { // no root module-info.class if null + try { + // ModuleDescriptor.read() checks open/exported pkgs vs packages + ModuleDescriptor md = ModuleDescriptor.read(ByteBuffer.wrap(moduleInfoBytes)); + // A module must have the implementation class of the services it 'provides'. + if (md.provides().stream().map(Provides::providers).flatMap(List::stream) + .filter(p -> !entries.contains(toBinaryName(p))) + .peek(p -> fatalError(formatMsg("error.missing.provider", p))) + .count() != 0) { + ok = false; + } + } catch (InvalidModuleDescriptorException x) { + fatalError(x.getMessage()); + ok = false; + } } - return true; + return ok; } /** * Adds extended modules attributes to the given module-info's. The given * Map values are updated in-place. Returns false if an error occurs. */ - private boolean addExtendedModuleAttributes(Map moduleInfos) + private void addExtendedModuleAttributes(Map moduleInfos, + Set packages) throws IOException { - assert !moduleInfos.isEmpty() && moduleInfos.get(MODULE_INFO) != null; - - ByteBuffer bb = ByteBuffer.wrap(moduleInfos.get(MODULE_INFO)); - ModuleDescriptor rd = ModuleDescriptor.read(bb); - - concealedPackages = findConcealedPackages(rd); - for (Map.Entry e: moduleInfos.entrySet()) { - ModuleDescriptor vd = ModuleDescriptor.read(ByteBuffer.wrap(e.getValue())); - if (!(isValidVersionedDescriptor(vd, rd))) - return false; - e.setValue(extendedInfoBytes(rd, vd, e.getValue(), packages)); + ModuleDescriptor md = ModuleDescriptor.read(ByteBuffer.wrap(e.getValue())); + e.setValue(extendedInfoBytes(md, e.getValue(), packages)); } - return true; } - private Set findConcealedPackages(ModuleDescriptor md) { - Objects.requireNonNull(md); - Set concealed = new HashSet<>(packages); - md.exports().stream().map(Exports::source).forEach(concealed::remove); - md.opens().stream().map(Opens::source).forEach(concealed::remove); - return concealed; - } - - private static boolean isPlatformModule(String name) { - return name.startsWith("java.") || name.startsWith("jdk."); - } - - /** - * Tells whether or not the given versioned module descriptor's attributes - * are valid when compared against the given root module descriptor. - * - * A versioned module descriptor must be identical to the root module - * descriptor, with two exceptions: - * - A versioned descriptor can have different non-public `requires` - * clauses of platform ( `java.*` and `jdk.*` ) modules, and - * - A versioned descriptor can have different `uses` clauses, even of - * service types defined outside of the platform modules. - */ - private boolean isValidVersionedDescriptor(ModuleDescriptor vd, - ModuleDescriptor rd) - throws IOException - { - if (!rd.name().equals(vd.name())) { - fatalError(getMsg("error.versioned.info.name.notequal")); - return false; - } - if (!rd.requires().equals(vd.requires())) { - Set rootRequires = rd.requires(); - for (Requires r : vd.requires()) { - if (rootRequires.contains(r)) { - continue; - } else if (r.modifiers().contains(Requires.Modifier.TRANSITIVE)) { - fatalError(getMsg("error.versioned.info.requires.transitive")); - return false; - } else if (!isPlatformModule(r.name())) { - fatalError(getMsg("error.versioned.info.requires.added")); - return false; - } - } - for (Requires r : rootRequires) { - Set mdRequires = vd.requires(); - if (mdRequires.contains(r)) { - continue; - } else if (!isPlatformModule(r.name())) { - fatalError(getMsg("error.versioned.info.requires.dropped")); + static boolean isModuleInfoEntry(String name) { + // root or versioned module-info.class + if (name.endsWith(MODULE_INFO)) { + int end = name.length() - MODULE_INFO.length(); + if (end == 0) + return true; + if (name.startsWith(VERSIONS_DIR)) { + int off = VERSIONS_DIR.length(); + if (off == end) // meta-inf/versions/module-info.class return false; + while (off < end - 1) { + char c = name.charAt(off++); + if (c < '0' || c > '9') + return false; } + return name.charAt(off) == '/'; } } - if (!rd.exports().equals(vd.exports())) { - fatalError(getMsg("error.versioned.info.exports.notequal")); - return false; - } - if (!rd.opens().equals(vd.opens())) { - fatalError(getMsg("error.versioned.info.opens.notequal")); - return false; - } - if (!rd.provides().equals(vd.provides())) { - fatalError(getMsg("error.versioned.info.provides.notequal")); - return false; - } - return true; + return false; } /** @@ -2185,8 +1902,7 @@ class Main { * then the corresponding class file attributes are added to the * module-info here. */ - private byte[] extendedInfoBytes(ModuleDescriptor rootDescriptor, - ModuleDescriptor md, + private byte[] extendedInfoBytes(ModuleDescriptor md, byte[] miBytes, Set packages) throws IOException @@ -2201,14 +1917,10 @@ class Main { // --main-class if (ename != null) extender.mainClass(ename); - else if (rootDescriptor.mainClass().isPresent()) - extender.mainClass(rootDescriptor.mainClass().get()); // --module-version if (moduleVersion != null) extender.version(moduleVersion); - else if (rootDescriptor.version().isPresent()) - extender.version(rootDescriptor.version().get()); // --hash-modules if (modulesToHash != null) { diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java index c3307e05613..bce128dd499 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,33 +25,121 @@ package sun.tools.jar; +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.lang.module.InvalidModuleDescriptorException; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleDescriptor.Exports; +import java.lang.module.InvalidModuleDescriptorException; +import java.lang.module.ModuleDescriptor.Opens; +import java.lang.module.ModuleDescriptor.Provides; +import java.lang.module.ModuleDescriptor.Requires; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Consumer; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.zip.ZipEntry; -final class Validator implements Consumer { +import static java.util.jar.JarFile.MANIFEST_NAME; +import static sun.tools.jar.Main.VERSIONS_DIR; +import static sun.tools.jar.Main.MODULE_INFO; +import static sun.tools.jar.Main.getMsg; +import static sun.tools.jar.Main.formatMsg; +import static sun.tools.jar.Main.formatMsg2; +import static sun.tools.jar.Main.toBinaryName; +import static sun.tools.jar.Main.isModuleInfoEntry; + +final class Validator { private final static boolean DEBUG = Boolean.getBoolean("jar.debug"); private final Map fps = new HashMap<>(); - private final int vdlen = Main.VERSIONS_DIR.length(); + private static final int vdlen = VERSIONS_DIR.length(); private final Main main; private final JarFile jf; private int oldVersion = -1; private String currentTopLevelName; private boolean isValid = true; + private Set concealedPkgs; + private ModuleDescriptor md; - Validator(Main main, JarFile jf) { + private Validator(Main main, JarFile jf) { this.main = main; this.jf = jf; + loadModuleDescriptor(); } - boolean isValid() { - return isValid; + static boolean validate(Main main, File f) throws IOException { + return new Validator(main, new JarFile(f)).validate(); } + private boolean validate() { + try { + jf.stream() + .filter(e -> !e.isDirectory() && + !e.getName().equals(MANIFEST_NAME)) + .sorted(entryComparator) + .forEachOrdered(e -> validate(e)); + return isValid; + } catch (InvalidJarException e) { + error(formatMsg("error.validator.bad.entry.name", e.getMessage())); + } + return false; + } + + private static class InvalidJarException extends RuntimeException { + private static final long serialVersionUID = -3642329147299217726L; + InvalidJarException(String msg) { + super(msg); + } + } + + // sort base entries before versioned entries, and sort entry classes with + // nested classes so that the top level class appears before the associated + // nested class + private static Comparator entryComparator = (je1, je2) -> { + String s1 = je1.getName(); + String s2 = je2.getName(); + if (s1.equals(s2)) return 0; + boolean b1 = s1.startsWith(VERSIONS_DIR); + boolean b2 = s2.startsWith(VERSIONS_DIR); + if (b1 && !b2) return 1; + if (!b1 && b2) return -1; + int n = 0; // starting char for String compare + if (b1 && b2) { + // normally strings would be sorted so "10" goes before "9", but + // version number strings need to be sorted numerically + n = VERSIONS_DIR.length(); // skip the common prefix + int i1 = s1.indexOf('/', n); + int i2 = s1.indexOf('/', n); + if (i1 == -1) throw new InvalidJarException(s1); + if (i2 == -1) throw new InvalidJarException(s2); + // shorter version numbers go first + if (i1 != i2) return i1 - i2; + // otherwise, handle equal length numbers below + } + int l1 = s1.length(); + int l2 = s2.length(); + int lim = Math.min(l1, l2); + for (int k = n; k < lim; k++) { + char c1 = s1.charAt(k); + char c2 = s2.charAt(k); + if (c1 != c2) { + // change natural ordering so '.' comes before '$' + // i.e. top level classes come before nested classes + if (c1 == '$' && c2 == '.') return 1; + if (c1 == '.' && c2 == '$') return -1; + return c1 - c2; + } + } + return l1 - l2; + }; + /* * Validator has state and assumes entries provided to accept are ordered * from base entries first and then through the versioned entries in @@ -59,7 +147,7 @@ final class Validator implements Consumer { * classes must be ordered so that the top level class is before the associated * nested class(es). */ - public void accept(JarEntry je) { + public void validate(JarEntry je) { String entryName = je.getName(); // directories are always accepted @@ -68,13 +156,20 @@ final class Validator implements Consumer { return; } + // validate the versioned module-info + if (isModuleInfoEntry(entryName)) { + if (entryName.length() != MODULE_INFO.length()) + checkModuleDescriptor(je); + return; + } + // figure out the version and basename from the JarEntry int version; String basename; - if (entryName.startsWith(Main.VERSIONS_DIR)) { + if (entryName.startsWith(VERSIONS_DIR)) { int n = entryName.indexOf("/", vdlen); if (n == -1) { - main.error(Main.formatMsg("error.validator.version.notnumber", entryName)); + error(formatMsg("error.validator.version.notnumber", entryName)); isValid = false; return; } @@ -82,12 +177,12 @@ final class Validator implements Consumer { try { version = Integer.parseInt(v); } catch (NumberFormatException x) { - main.error(Main.formatMsg("error.validator.version.notnumber", entryName)); + error(formatMsg("error.validator.version.notnumber", entryName)); isValid = false; return; } if (n == entryName.length()) { - main.error(Main.formatMsg("error.validator.entryname.tooshort", entryName)); + error(formatMsg("error.validator.entryname.tooshort", entryName)); isValid = false; return; } @@ -108,7 +203,7 @@ final class Validator implements Consumer { try (InputStream is = jf.getInputStream(je)) { fp = new FingerPrint(basename, is.readAllBytes()); } catch (IOException x) { - main.error(x.getMessage()); + error(x.getMessage()); isValid = false; return; } @@ -123,7 +218,7 @@ final class Validator implements Consumer { fps.put(internalName, fp); return; } - main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName)); + error(formatMsg("error.validator.isolated.nested.class", entryName)); isValid = false; return; } @@ -153,11 +248,11 @@ final class Validator implements Consumer { } if (fp.isPublicClass()) { if (!isConcealed(internalName)) { - main.error(Main.formatMsg("error.validator.new.public.class", entryName)); + error(Main.formatMsg("error.validator.new.public.class", entryName)); isValid = false; return; } - main.warn(Main.formatMsg("warn.validator.concealed.public.class", entryName)); + warn(formatMsg("warn.validator.concealed.public.class", entryName)); debug("%s is a public class entry in a concealed package", entryName); } debug("%s is a non-public class entry", entryName); @@ -173,7 +268,7 @@ final class Validator implements Consumer { // are the two classes/resources identical? if (fp.isIdentical(matchFp)) { - main.warn(Main.formatMsg("warn.validator.identical.entry", entryName)); + warn(formatMsg("warn.validator.identical.entry", entryName)); return; // it's okay, just takes up room } debug("sha1 not equal -- different bytes"); @@ -188,12 +283,12 @@ final class Validator implements Consumer { } debug("%s is a class entry", entryName); if (!fp.isCompatibleVersion(matchFp)) { - main.error(Main.formatMsg("error.validator.incompatible.class.version", entryName)); + error(formatMsg("error.validator.incompatible.class.version", entryName)); isValid = false; return; } if (!fp.isSameAPI(matchFp)) { - main.error(Main.formatMsg("error.validator.different.api", entryName)); + error(formatMsg("error.validator.different.api", entryName)); isValid = false; return; } @@ -208,17 +303,118 @@ final class Validator implements Consumer { } debug("%s is a resource", entryName); - main.warn(Main.formatMsg("warn.validator.resources.with.same.name", entryName)); + warn(formatMsg("warn.validator.resources.with.same.name", entryName)); fps.put(internalName, fp); return; } + private void loadModuleDescriptor() { + ZipEntry je = jf.getEntry(MODULE_INFO); + if (je != null) { + try (InputStream jis = jf.getInputStream(je)) { + md = ModuleDescriptor.read(jis); + concealedPkgs = new HashSet<>(md.packages()); + md.exports().stream().map(Exports::source).forEach(concealedPkgs::remove); + md.opens().stream().map(Opens::source).forEach(concealedPkgs::remove); + return; + } catch (Exception x) { + error(x.getMessage() + " : " + je.getName()); + this.isValid = false; + } + } + md = null; + concealedPkgs = Collections.emptySet(); + } + + private static boolean isPlatformModule(String name) { + return name.startsWith("java.") || name.startsWith("jdk."); + } + + /** + * Checks whether or not the given versioned module descriptor's attributes + * are valid when compared against the root module descriptor. + * + * A versioned module descriptor must be identical to the root module + * descriptor, with two exceptions: + * - A versioned descriptor can have different non-public `requires` + * clauses of platform ( `java.*` and `jdk.*` ) modules, and + * - A versioned descriptor can have different `uses` clauses, even of + * service types defined outside of the platform modules. + */ + private void checkModuleDescriptor(JarEntry je) { + try (InputStream is = jf.getInputStream(je)) { + ModuleDescriptor root = this.md; + ModuleDescriptor md = null; + try { + md = ModuleDescriptor.read(is); + } catch (InvalidModuleDescriptorException x) { + error(x.getMessage()); + isValid = false; + return; + } + if (root == null) { + this.md = md; + } else { + if (!root.name().equals(md.name())) { + error(getMsg("error.versioned.info.name.notequal")); + isValid = false; + } + if (!root.requires().equals(md.requires())) { + Set rootRequires = root.requires(); + for (Requires r : md.requires()) { + if (rootRequires.contains(r)) + continue; + if (r.modifiers().contains(Requires.Modifier.TRANSITIVE)) { + error(getMsg("error.versioned.info.requires.transitive")); + isValid = false; + } else if (!isPlatformModule(r.name())) { + error(getMsg("error.versioned.info.requires.added")); + isValid = false; + } + } + for (Requires r : rootRequires) { + Set mdRequires = md.requires(); + if (mdRequires.contains(r)) + continue; + if (!isPlatformModule(r.name())) { + error(getMsg("error.versioned.info.requires.dropped")); + isValid = false; + } + } + } + if (!root.exports().equals(md.exports())) { + error(getMsg("error.versioned.info.exports.notequal")); + isValid = false; + } + if (!root.opens().equals(md.opens())) { + error(getMsg("error.versioned.info.opens.notequal")); + isValid = false; + } + if (!root.provides().equals(md.provides())) { + error(getMsg("error.versioned.info.provides.notequal")); + isValid = false; + } + if (!root.mainClass().equals(md.mainClass())) { + error(formatMsg("error.validator.info.manclass.notequal", je.getName())); + isValid = false; + } + if (!root.version().equals(md.version())) { + error(formatMsg("error.validator.info.version.notequal", je.getName())); + isValid = false; + } + } + } catch (IOException x) { + error(x.getMessage()); + isValid = false; + } + } + private boolean checkInternalName(String entryName, String basename, String internalName) { String className = className(basename); if (internalName.equals(className)) { return true; } - main.error(Main.formatMsg2("error.validator.names.mismatch", + error(formatMsg2("error.validator.names.mismatch", entryName, internalName.replace("/", "."))); return false; } @@ -231,7 +427,7 @@ final class Validator implements Consumer { return true; } debug("top level class was not accepted"); - main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName)); + error(formatMsg("error.validator.isolated.nested.class", entryName)); return false; } @@ -240,16 +436,24 @@ final class Validator implements Consumer { } private boolean isConcealed(String internalName) { - if (main.concealedPackages.isEmpty()) { + if (concealedPkgs.isEmpty()) { return false; } int idx = internalName.lastIndexOf('/'); String pkgName = idx != -1 ? internalName.substring(0, idx).replace('/', '.') : ""; - return main.concealedPackages.contains(pkgName); + return concealedPkgs.contains(pkgName); } private void debug(String fmt, Object... args) { if (DEBUG) System.err.format(fmt, args); } -} + private void error(String msg) { + main.error(msg); + } + + private void warn(String msg) { + main.warn(msg); + } + +} diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties index c575f3b3c00..a2e6b5ff94f 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties @@ -66,23 +66,6 @@ error.unexpected.module-info=\ Unexpected module descriptor {0} error.module.descriptor.not.found=\ Module descriptor not found -error.versioned.info.without.root=\ - module-info.class found in a versioned directory without module-info.class \ - in the root -error.versioned.info.name.notequal=\ - module-info.class in a versioned directory contains incorrect name -error.versioned.info.requires.transitive=\ - module-info.class in a versioned directory contains additional "requires transitive" -error.versioned.info.requires.added=\ - module-info.class in a versioned directory contains additional "requires" -error.versioned.info.requires.dropped=\ - module-info.class in a versioned directory contains missing "requires" -error.versioned.info.exports.notequal=\ - module-info.class in a versioned directory contains different "exports" -error.versioned.info.opens.notequal=\ - module-info.class in a versioned directory contains different "opens" -error.versioned.info.provides.notequal=\ - module-info.class in a versioned directory contains different "provides" error.invalid.versioned.module.attribute=\ Invalid module descriptor attribute {0} error.missing.provider=\ @@ -113,6 +96,24 @@ error.validator.different.api=\ entry: {0}, contains a class with different api from earlier version error.validator.names.mismatch=\ entry: {0}, contains a class with internal name {1}, names do not match +error.validator.info.name.notequal=\ + module-info.class in a versioned directory contains incorrect name +error.validator.info.requires.transitive=\ + module-info.class in a versioned directory contains additional "requires transitive" +error.validator.info.requires.added=\ + module-info.class in a versioned directory contains additional "requires" +error.validator.info.requires.dropped=\ + module-info.class in a versioned directory contains missing "requires" +error.validator.info.exports.notequal=\ + module-info.class in a versioned directory contains different "exports" +error.validator.info.opens.notequal=\ + module-info.class in a versioned directory contains different "opens" +error.validator.info.provides.notequal=\ + module-info.class in a versioned directory contains different "provides" +error.validator.info.version.notequal=\ + {0}: module-info.class in a versioned directory contains different "version" +error.validator.info.manclass.notequal=\ + {0}: module-info.class in a versioned directory contains different "main-class" warn.validator.identical.entry=\ Warning: entry {0} contains a class that\n\ is identical to an entry already in the jar @@ -122,6 +123,8 @@ warn.validator.concealed.public.class=\ Warning: entry {0} is a public class\n\ in a concealed package, placing this jar on the class path will result\n\ in incompatible public interfaces +warn.release.unexpected.versioned.entry=\ + unexpected versioned entry {0} out.added.manifest=\ added manifest out.added.module-info=\ diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_de.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_de.properties index a44436f27de..a8892cbf2ca 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_de.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_de.properties @@ -42,13 +42,13 @@ error.hash.dep=Abh\u00E4ngigkeiten bei Hashing-Modul {0}. Modul {1} kann nicht i error.module.options.without.info=--module-version oder --hash-modules ohne module-info.class error.unexpected.module-info=Unerwarteter Moduldeskriptor {0} error.module.descriptor.not.found=Moduldeskriptor nicht gefunden -error.versioned.info.without.root=module-info.class in einem versionierten Verzeichnis gefunden, in der Root ist module-info.class jedoch nicht vorhanden -error.versioned.info.name.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt falschen Namen -error.versioned.info.requires.public=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires public" -error.versioned.info.requires.added=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires" -error.versioned.info.requires.dropped=module-info.class in einem versionierten Verzeichnis enth\u00E4lt fehlenden "requires" -error.versioned.info.exports.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "exports" -error.versioned.info.provides.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "provides" +error.validator.info.without.root=module-info.class in einem versionierten Verzeichnis gefunden, in der Root ist module-info.class jedoch nicht vorhanden +error.validator.info.name.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt falschen Namen +error.validator.info.requires.public=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires public" +error.validator.info.requires.added=module-info.class in einem versionierten Verzeichnis enth\u00E4lt zus\u00E4tzlichen "requires" +error.validator.info.requires.dropped=module-info.class in einem versionierten Verzeichnis enth\u00E4lt fehlenden "requires" +error.validator.info.exports.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "exports" +error.validator.info.provides.notequal=module-info.class in einem versionierten Verzeichnis enth\u00E4lt unterschiedliche "provides" error.invalid.versioned.module.attribute=Ung\u00FCltiges Moduldeskriptorattribut {0} error.missing.provider=Serviceprovider nicht gefunden: {0} error.release.value.notnumber=Release {0} nicht g\u00FCltig diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_es.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_es.properties index b38c4fc64af..30f4e7ef2cc 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_es.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_es.properties @@ -42,13 +42,13 @@ error.hash.dep=Aplicando hash a las dependencias del m\u00F3dulo {0}, no se ha e error.module.options.without.info=Uno de --module-version o -hash-modules sin module-info.class error.unexpected.module-info=Descriptor de m\u00F3dulo inesperado {0} error.module.descriptor.not.found=No se ha encontrado el descriptor de m\u00F3dulo -error.versioned.info.without.root=Se ha encontrado module-info.class en un directorio con versi\u00F3n sin module-info.class en la ra\u00EDz -error.versioned.info.name.notequal=module-info.class en un directorio con versi\u00F3n contiene un nombre incorrecto -error.versioned.info.requires.public=module-info.class en un directorio con versiones contiene "requires public" adicionales -error.versioned.info.requires.added=module-info.class en un directorio con versi\u00F3n contiene "requires" adicionales -error.versioned.info.requires.dropped=module-info.class en un directorio con versiones contiene "requires" que faltan -error.versioned.info.exports.notequal=module-info.class en un directorio con versiones contiene "exports" diferentes -error.versioned.info.provides.notequal=module-info.class en un directorio con versiones contiene "provides" diferentes +error.validator.info.without.root=Se ha encontrado module-info.class en un directorio con versi\u00F3n sin module-info.class en la ra\u00EDz +error.validator.info.name.notequal=module-info.class en un directorio con versi\u00F3n contiene un nombre incorrecto +error.validator.info.requires.public=module-info.class en un directorio con versiones contiene "requires public" adicionales +error.validator.info.requires.added=module-info.class en un directorio con versi\u00F3n contiene "requires" adicionales +error.validator.info.requires.dropped=module-info.class en un directorio con versiones contiene "requires" que faltan +error.validator.info.exports.notequal=module-info.class en un directorio con versiones contiene "exports" diferentes +error.validator.info.provides.notequal=module-info.class en un directorio con versiones contiene "provides" diferentes error.invalid.versioned.module.attribute=Atributo de descriptor de m\u00F3dulo no v\u00E1lido {0} error.missing.provider=No se ha encontrado el proveedor de servicios: {0} error.release.value.notnumber=versi\u00F3n {0} no v\u00E1lida diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_fr.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_fr.properties index a1232a9d39e..5ef67437434 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_fr.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_fr.properties @@ -42,13 +42,13 @@ error.hash.dep=Hachage des d\u00E9pendances du module {0}, module {1} introuvabl error.module.options.without.info=Une des options --module-version ou --hash-modules sans module-info.class error.unexpected.module-info=Descripteur de module {0} inattendu error.module.descriptor.not.found=Descripteur de module introuvable -error.versioned.info.without.root=module-info.class a \u00E9t\u00E9 d\u00E9tect\u00E9 dans un r\u00E9pertoire avec num\u00E9ro de version sans module-info.class dans la racine -error.versioned.info.name.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient un nom incorrect -error.versioned.info.requires.public=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires public" suppl\u00E9mentaires -error.versioned.info.requires.added=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" suppl\u00E9mentaires -error.versioned.info.requires.dropped=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" manquants -error.versioned.info.exports.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "exports" diff\u00E9rents -error.versioned.info.provides.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "provides" diff\u00E9rents +error.validator.info.without.root=module-info.class a \u00E9t\u00E9 d\u00E9tect\u00E9 dans un r\u00E9pertoire avec num\u00E9ro de version sans module-info.class dans la racine +error.validator.info.name.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient un nom incorrect +error.validator.info.requires.public=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires public" suppl\u00E9mentaires +error.validator.info.requires.added=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" suppl\u00E9mentaires +error.validator.info.requires.dropped=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "requires" manquants +error.validator.info.exports.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "exports" diff\u00E9rents +error.validator.info.provides.notequal=module-info.class dans un r\u00E9pertoire avec num\u00E9ro de version contient des mots-cl\u00E9s "provides" diff\u00E9rents error.invalid.versioned.module.attribute=Attribut de descripteur de module non valide {0} error.missing.provider=Fournisseur de services introuvable : {0} error.release.value.notnumber=version {0} non valide diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_it.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_it.properties index bdc9a7463db..00925b80190 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_it.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_it.properties @@ -42,13 +42,13 @@ error.hash.dep={0} dipendenze del modulo di hashing. Impossibile trovare il modu error.module.options.without.info=Una delle opzioni --module-version o --hash-modules non contiene module-info.class error.unexpected.module-info=Descrittore di modulo {0} imprevisto error.module.descriptor.not.found=Descrittore di modulo non trovato -error.versioned.info.without.root=module-info.class trovato in una directory con controllo delle versioni senza module-info.class nella radice -error.versioned.info.name.notequal=module-info.class in una directory con controllo delle versioni contiene un nome errato -error.versioned.info.requires.public=module-info.class in una directory con controllo delle versioni contiene valori "requires public" aggiuntivi -error.versioned.info.requires.added=module-info.class in una directory con controllo delle versioni contiene valori "requires" aggiuntivi -error.versioned.info.requires.dropped=module-info.class in una directory con controllo delle versioni contiene valori "requires" mancanti -error.versioned.info.exports.notequal=module-info.class in una directory con controllo delle versioni contiene "exports" differenti -error.versioned.info.provides.notequal=module-info.class in una directory con controllo delle versioni contiene valori "provides" differenti +error.validator.info.without.root=module-info.class trovato in una directory con controllo delle versioni senza module-info.class nella radice +error.validator.info.name.notequal=module-info.class in una directory con controllo delle versioni contiene un nome errato +error.validator.info.requires.public=module-info.class in una directory con controllo delle versioni contiene valori "requires public" aggiuntivi +error.validator.info.requires.added=module-info.class in una directory con controllo delle versioni contiene valori "requires" aggiuntivi +error.validator.info.requires.dropped=module-info.class in una directory con controllo delle versioni contiene valori "requires" mancanti +error.validator.info.exports.notequal=module-info.class in una directory con controllo delle versioni contiene "exports" differenti +error.validator.info.provides.notequal=module-info.class in una directory con controllo delle versioni contiene valori "provides" differenti error.invalid.versioned.module.attribute=Attributo descrittore del modulo {0} non valido. error.missing.provider=Provider di servizi non trovato: {0} error.release.value.notnumber=release {0} non valida diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ja.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ja.properties index 3176103e417..c974444fc8a 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ja.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ja.properties @@ -42,13 +42,13 @@ error.hash.dep=\u30E2\u30B8\u30E5\u30FC\u30EB{0}\u4F9D\u5B58\u6027\u306E\u30CF\u error.module.options.without.info=--module-version\u307E\u305F\u306F--hash-modules\u306E\u3044\u305A\u308C\u304B\u3067module-info.class\u304C\u3042\u308A\u307E\u305B\u3093 error.unexpected.module-info=\u4E88\u671F\u3057\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF{0} error.module.descriptor.not.found=\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 -error.versioned.info.without.root=module-info.class\u304C\u3001\u30EB\u30FC\u30C8\u306Bmodule-info.class\u306E\u306A\u3044\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u898B\u3064\u304B\u308A\u307E\u3057\u305F -error.versioned.info.name.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B63\u3057\u304F\u306A\u3044\u540D\u524D\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 -error.versioned.info.requires.public=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires public"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 -error.versioned.info.requires.added=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 -error.versioned.info.requires.dropped=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B20\u843D\u3057\u3066\u3044\u308B"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 -error.versioned.info.exports.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"exports"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 -error.versioned.info.provides.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"provides"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 +error.validator.info.without.root=module-info.class\u304C\u3001\u30EB\u30FC\u30C8\u306Bmodule-info.class\u306E\u306A\u3044\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u898B\u3064\u304B\u308A\u307E\u3057\u305F +error.validator.info.name.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B63\u3057\u304F\u306A\u3044\u540D\u524D\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 +error.validator.info.requires.public=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires public"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 +error.validator.info.requires.added=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u8FFD\u52A0\u306E"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 +error.validator.info.requires.dropped=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u6B20\u843D\u3057\u3066\u3044\u308B"requires"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 +error.validator.info.exports.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"exports"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 +error.validator.info.provides.notequal=\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0\u3055\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306Emodule-info.class\u306B\u7570\u306A\u308B"provides"\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059 error.invalid.versioned.module.attribute=\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u5C5E\u6027{0}\u304C\u7121\u52B9\u3067\u3059 error.missing.provider=\u30B5\u30FC\u30D3\u30B9\u30FB\u30D7\u30ED\u30D0\u30A4\u30C0\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} error.release.value.notnumber=\u30EA\u30EA\u30FC\u30B9{0}\u306F\u6709\u52B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093 diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ko.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ko.properties index 8525975414d..8d1f3c019df 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ko.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_ko.properties @@ -42,13 +42,13 @@ error.hash.dep=\uBAA8\uB4C8 {0} \uC885\uC18D\uC131\uC744 \uD574\uC2DC\uD558\uB29 error.module.options.without.info=module-info.class \uC5C6\uC774 --module-version \uB610\uB294 --hash-modules \uC911 \uD558\uB098 error.unexpected.module-info=\uC608\uC0C1\uCE58 \uC54A\uC740 \uBAA8\uB4C8 \uAE30\uC220\uC790 {0} error.module.descriptor.not.found=\uBAA8\uB4C8 \uAE30\uC220\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C -error.versioned.info.without.root=\uB8E8\uD2B8\uC5D0\uC11C module-info.class \uC5C6\uC774 \uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C module-info.class\uAC00 \uBC1C\uACAC\uB428 -error.versioned.info.name.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uC798\uBABB\uB41C \uC774\uB984\uC774 \uD3EC\uD568\uB428 -error.versioned.info.requires.public=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires public" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 -error.versioned.info.requires.added=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 -error.versioned.info.requires.dropped=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB204\uB77D\uB41C "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 -error.versioned.info.exports.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "exports" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 -error.versioned.info.provides.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "provides" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 +error.validator.info.without.root=\uB8E8\uD2B8\uC5D0\uC11C module-info.class \uC5C6\uC774 \uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C module-info.class\uAC00 \uBC1C\uACAC\uB428 +error.validator.info.name.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uC798\uBABB\uB41C \uC774\uB984\uC774 \uD3EC\uD568\uB428 +error.validator.info.requires.public=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires public" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 +error.validator.info.requires.added=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uCD94\uAC00 "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 +error.validator.info.requires.dropped=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB204\uB77D\uB41C "requires" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 +error.validator.info.exports.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "exports" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 +error.validator.info.provides.notequal=\uBC84\uC804 \uC9C0\uC815\uB41C \uB514\uB809\uD1A0\uB9AC\uC758 module-info.class\uC5D0 \uB2E4\uB978 "provides" \uD56D\uBAA9\uC774 \uD3EC\uD568\uB428 error.invalid.versioned.module.attribute=\uBD80\uC801\uD569\uD55C \uBAA8\uB4C8 \uAE30\uC220\uC790 \uC18D\uC131 {0} error.missing.provider=\uC11C\uBE44\uC2A4 \uC81C\uACF5\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0} error.release.value.notnumber=\uB9B4\uB9AC\uC2A4 {0}\uC774(\uAC00) \uBD80\uC801\uD569\uD568 diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_pt_BR.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_pt_BR.properties index 61483975ed1..647ad8de3ee 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_pt_BR.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_pt_BR.properties @@ -42,13 +42,13 @@ error.hash.dep=M\u00F3dulo de hashing com {0} depend\u00EAncias. N\u00E3o \u00E9 error.module.options.without.info=Um dentre --module-version ou --hash-modules est\u00E1 sem module-info.class error.unexpected.module-info=Descritor de m\u00F3dulo inesperado {0} error.module.descriptor.not.found=Descritor de m\u00F3dulo n\u00E3o encontrado -error.versioned.info.without.root=module-info.class encontrado em um diret\u00F3rio com controle de vers\u00E3o sem module-info.class na raiz -error.versioned.info.name.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m nome incorreto -error.versioned.info.requires.public=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires public" adicional -error.versioned.info.requires.added=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires" adicional -error.versioned.info.requires.dropped=module-info.class em um diret\u00F3rio com controle de vers\u00E3o falta "requires" -error.versioned.info.exports.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "exports" diferente -error.versioned.info.provides.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "provides" diferente +error.validator.info.without.root=module-info.class encontrado em um diret\u00F3rio com controle de vers\u00E3o sem module-info.class na raiz +error.validator.info.name.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m nome incorreto +error.validator.info.requires.public=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires public" adicional +error.validator.info.requires.added=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "requires" adicional +error.validator.info.requires.dropped=module-info.class em um diret\u00F3rio com controle de vers\u00E3o falta "requires" +error.validator.info.exports.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "exports" diferente +error.validator.info.provides.notequal=module-info.class em um diret\u00F3rio com controle de vers\u00E3o cont\u00E9m "provides" diferente error.invalid.versioned.module.attribute=Atributo {0} de descritor de m\u00F3dulo inv\u00E1lido error.missing.provider=Prestador de servi\u00E7os n\u00E3o encontrado: {0} error.release.value.notnumber=release {0} n\u00E3o v\u00E1lida diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_sv.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_sv.properties index 2cd286c9dd1..f73650e5f86 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_sv.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_sv.properties @@ -42,13 +42,13 @@ error.hash.dep={0}-beroenden f\u00F6r hashningsmodulen, kan inte hitta modulen { error.module.options.without.info=--module-version eller --hash-modules utan module-info.class error.unexpected.module-info=Ov\u00E4ntad moduldeskriptor, {0} error.module.descriptor.not.found=Moduldeskriptorn hittades inte -error.versioned.info.without.root=module-info.class hittades i en versionshanterad katalog utan module-info.class i roten -error.versioned.info.name.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller ett felaktigt namn -error.versioned.info.requires.public=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires public" -error.versioned.info.requires.added=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires" -error.versioned.info.requires.dropped=module-info.class i en versionshanterad katalog inneh\u00E5ller saknade "requires" -error.versioned.info.exports.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "exports" -error.versioned.info.provides.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "provides" +error.validator.info.without.root=module-info.class hittades i en versionshanterad katalog utan module-info.class i roten +error.validator.info.name.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller ett felaktigt namn +error.validator.info.requires.public=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires public" +error.validator.info.requires.added=module-info.class i en versionshanterad katalog inneh\u00E5ller fler "requires" +error.validator.info.requires.dropped=module-info.class i en versionshanterad katalog inneh\u00E5ller saknade "requires" +error.validator.info.exports.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "exports" +error.validator.info.provides.notequal=module-info.class i en versionshanterad katalog inneh\u00E5ller olika "provides" error.invalid.versioned.module.attribute=Ogiltigt attribut f\u00F6r moduldeskriptor, {0} error.missing.provider=Tj\u00E4nsteleverant\u00F6ren hittades inte: {0} error.release.value.notnumber=utg\u00E5va {0} \u00E4r inte giltig diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_CN.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_CN.properties index ea48aa290f6..71407c54707 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_CN.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_CN.properties @@ -42,13 +42,13 @@ error.hash.dep=\u6B63\u5728\u5BF9\u6A21\u5757 {0} \u7684\u88AB\u4F9D\u8D56\u5BF9 error.module.options.without.info=--module-version \u6216 --hash-modules \u4E4B\u4E00\u6CA1\u6709 module-info.class error.unexpected.module-info=\u610F\u5916\u7684\u6A21\u5757\u63CF\u8FF0\u7B26 {0} error.module.descriptor.not.found=\u627E\u4E0D\u5230\u6A21\u5757\u63CF\u8FF0\u7B26 -error.versioned.info.without.root=\u5728\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u627E\u5230\u4E86 module-info.class, \u4F46\u6839\u4E2D\u6CA1\u6709 module-info.class -error.versioned.info.name.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u786E\u7684\u540D\u79F0 -error.versioned.info.requires.public=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires public" -error.versioned.info.requires.added=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires" -error.versioned.info.requires.dropped=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u7F3A\u5C11\u7684 "requires" -error.versioned.info.exports.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports" -error.versioned.info.provides.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides" +error.validator.info.without.root=\u5728\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u627E\u5230\u4E86 module-info.class, \u4F46\u6839\u4E2D\u6CA1\u6709 module-info.class +error.validator.info.name.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u786E\u7684\u540D\u79F0 +error.validator.info.requires.public=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires public" +error.validator.info.requires.added=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u989D\u5916\u7684 "requires" +error.validator.info.requires.dropped=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u7F3A\u5C11\u7684 "requires" +error.validator.info.exports.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports" +error.validator.info.provides.notequal=\u7248\u672C\u5316\u76EE\u5F55\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides" error.invalid.versioned.module.attribute=\u65E0\u6548\u7684\u6A21\u5757\u63CF\u8FF0\u7B26\u5C5E\u6027 {0} error.missing.provider=\u672A\u627E\u5230\u670D\u52A1\u63D0\u4F9B\u65B9: {0} error.release.value.notnumber=\u53D1\u884C\u7248 {0} \u65E0\u6548 diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_TW.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_TW.properties index 431790f3295..3c209bb6432 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_TW.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar_zh_TW.properties @@ -42,13 +42,13 @@ error.hash.dep=\u96DC\u6E4A\u6A21\u7D44 {0} \u76F8\u4F9D\u6027\uFF0C\u5728\u6A21 error.module.options.without.info=--module-version \u6216 --hash-modules \u5176\u4E2D\u4E00\u500B\u6C92\u6709 module-info.class error.unexpected.module-info=\u672A\u9810\u671F\u7684\u6A21\u7D44\u63CF\u8FF0\u5340 {0} error.module.descriptor.not.found=\u627E\u4E0D\u5230\u6A21\u7D44\u63CF\u8FF0\u5340 -error.versioned.info.without.root=\u5728\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u767C\u73FE module-info.class\uFF0C\u4F46\u662F\u6839\u4E2D\u6C92\u6709 module-info.class -error.versioned.info.name.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u78BA\u7684\u540D\u7A31 -error.versioned.info.requires.public=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires public" -error.versioned.info.requires.added=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires" -error.versioned.info.requires.dropped=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u907A\u6F0F\u7684 "requires" -error.versioned.info.exports.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports" -error.versioned.info.provides.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides" +error.validator.info.without.root=\u5728\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u767C\u73FE module-info.class\uFF0C\u4F46\u662F\u6839\u4E2D\u6C92\u6709 module-info.class +error.validator.info.name.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u6B63\u78BA\u7684\u540D\u7A31 +error.validator.info.requires.public=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires public" +error.validator.info.requires.added=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u984D\u5916\u7684 "requires" +error.validator.info.requires.dropped=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u907A\u6F0F\u7684 "requires" +error.validator.info.exports.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "exports" +error.validator.info.provides.notequal=\u5DF2\u555F\u52D5\u591A\u7248\u672C\u529F\u80FD\u76EE\u9304\u4E2D\u7684 module-info.class \u5305\u542B\u4E0D\u540C\u7684 "provides" error.invalid.versioned.module.attribute=\u6A21\u7D44\u63CF\u8FF0\u5340\u5C6C\u6027 {0} \u7121\u6548 error.missing.provider=\u627E\u4E0D\u5230\u670D\u52D9\u63D0\u4F9B\u8005: {0} error.release.value.notnumber=\u7248\u672C {0} \u7121\u6548 diff --git a/jdk/test/tools/jar/mmrjar/ConcealedPackage.java b/jdk/test/tools/jar/mmrjar/Basic.java similarity index 70% rename from jdk/test/tools/jar/mmrjar/ConcealedPackage.java rename to jdk/test/tools/jar/mmrjar/Basic.java index fce5344acbf..6b0ad843641 100644 --- a/jdk/test/tools/jar/mmrjar/ConcealedPackage.java +++ b/jdk/test/tools/jar/mmrjar/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,36 +23,43 @@ /* * @test - * @bug 8146486 + * @bug 8146486 8172432 * @summary Fail to create a MR modular JAR with a versioned entry in * base-versioned empty package - * @modules jdk.compiler + * @modules java.base/jdk.internal.module + * jdk.compiler * jdk.jartool * @library /lib/testlibrary * @build jdk.testlibrary.FileUtils - * @run testng ConcealedPackage + * @run testng Basic */ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.UncheckedIOException; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleDescriptor.Version; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; +import java.util.Optional; import java.util.Set; import java.util.spi.ToolProvider; import java.util.stream.Collectors; import java.util.stream.Stream; +import java.util.zip.ZipFile; +import jdk.internal.module.ModuleInfoExtender; import jdk.testlibrary.FileUtils; -public class ConcealedPackage { +public class Basic { private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") .orElseThrow(() -> new RuntimeException("jar tool not found")); private static final ToolProvider JAVAC_TOOL = ToolProvider.findFirst("javac") @@ -65,7 +72,7 @@ public class ConcealedPackage { private final ByteArrayOutputStream errbytes = new ByteArrayOutputStream(); private final PrintStream err = new PrintStream(errbytes, true); - public ConcealedPackage() throws IOException { + public Basic() throws IOException { testsrc = Paths.get(System.getProperty("test.src")); userdir = Paths.get(System.getProperty("user.dir", ".")); @@ -205,6 +212,7 @@ public class ConcealedPackage { "META-INF/versions/9/module-info.class", "p/", "p/Hi.class", + "META-INF/versions/9/", "META-INF/versions/9/p/", "META-INF/versions/9/p/Hi.class", "META-INF/versions/9/p/internal/", @@ -247,6 +255,7 @@ public class ConcealedPackage { "META-INF/MANIFEST.MF", "p/", "p/Hi.class", + "META-INF/versions/9/", "META-INF/versions/9/p/", "META-INF/versions/9/p/Hi.class", "META-INF/versions/9/p/internal/", @@ -277,10 +286,12 @@ public class ConcealedPackage { "META-INF/MANIFEST.MF", "p/", "p/Hi.class", + "META-INF/versions/9/", "META-INF/versions/9/p/", "META-INF/versions/9/p/Hi.class", "META-INF/versions/9/p/internal/", "META-INF/versions/9/p/internal/Bar.class", + "META-INF/versions/10/", "META-INF/versions/10/p/", "META-INF/versions/10/p/internal/", "META-INF/versions/10/p/internal/bar/", @@ -302,6 +313,116 @@ public class ConcealedPackage { Assert.assertEquals(actual, expected); } + // root and versioned module-info entries have different main-class, version + // attributes + @Test + public void test6() throws IOException { + // create a directory for this tests special files + Files.createDirectory(Paths.get("test6")); + Files.createDirectory(Paths.get("test6-v9")); + + // compile the classes directory + Path src = testsrc.resolve("src").resolve("classes"); + Path dst = Paths.get("test6"); + javac(src, dst); + + byte[] mdBytes = Files.readAllBytes(Paths.get("module-info.class")); + + ModuleInfoExtender mie = ModuleInfoExtender.newExtender( + new ByteArrayInputStream(mdBytes)); + + mie.mainClass("foo.main"); + mie.version(Version.parse("1.0")); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + mie.write(baos); + Files.write(Paths.get("test6", "module-info.class"), baos.toByteArray()); + Files.write(Paths.get("test6-v9", "module-info.class"), baos.toByteArray()); + + int rc = jar("--create --file mmr.jar -C test6 . --release 9 -C test6-v9 ."); + Assert.assertEquals(rc, 0); + + + // different main-class + mie = ModuleInfoExtender.newExtender(new ByteArrayInputStream(mdBytes)); + mie.mainClass("foo.main2"); + mie.version(Version.parse("1.0")); + baos.reset(); + mie.write(baos); + Files.write(Paths.get("test6-v9", "module-info.class"), baos.toByteArray()); + + rc = jar("--create --file mmr.jar -C test6 . --release 9 -C test6-v9 ."); + Assert.assertEquals(rc, 1); + + Assert.assertTrue(Message.CONTAINS_DIFFERENT_MAINCLASS.match( + new String(errbytes.toByteArray()), + "META-INF/versions/9/module-info.class")); + + // different version + mie = ModuleInfoExtender.newExtender(new ByteArrayInputStream(mdBytes)); + mie.mainClass("foo.main"); + mie.version(Version.parse("2.0")); + baos.reset(); + mie.write(baos); + Files.write(Paths.get("test6-v9", "module-info.class"), baos.toByteArray()); + + rc = jar("--create --file mmr.jar -C test6 . --release 9 -C test6-v9 ."); + Assert.assertEquals(rc, 1); + + Assert.assertTrue(Message.CONTAINS_DIFFERENT_VERSION.match( + new String(errbytes.toByteArray()), + "META-INF/versions/9/module-info.class")); + + } + + // versioned mmr without root module-info.class + @Test + public void test7() throws IOException { + // create a directory for this tests special files + Files.createDirectory(Paths.get("test7")); + Files.createDirectory(Paths.get("test7-v9")); + Files.createDirectory(Paths.get("test7-v10")); + + // compile the classes directory + Path src = testsrc.resolve("src").resolve("classes"); + Path dst = Paths.get("test7"); + javac(src, dst); + + // move module-info.class to v9 later use + Files.copy(Paths.get("module-info.class"), + Paths.get("test7-v9", "module-info.class")); + + Files.copy(Paths.get("test7-v9", "module-info.class"), + Paths.get("test7-v10", "module-info.class")); + + int rc = jar("--create --file mmr.jar --main-class=foo.main -C test7 . --release 9 -C test7-v9 . --release 10 -C test7-v10 ."); + +System.out.println("-----------------------"); +System.out.println( new String(errbytes.toByteArray())); + + + Assert.assertEquals(rc, 0); + + + jar("-tf mmr.jar"); + +System.out.println("-----------------------"); +System.out.println( new String(outbytes.toByteArray())); + + Optional exp = Optional.of("foo.main"); + try (ZipFile zf = new ZipFile("mmr.jar")) { + Assert.assertTrue(zf.getEntry("module-info.class") == null); + + ModuleDescriptor md = ModuleDescriptor.read( + zf.getInputStream(zf.getEntry("META-INF/versions/9/module-info.class"))); + Assert.assertEquals(md.mainClass(), exp); + + md = ModuleDescriptor.read( + zf.getInputStream(zf.getEntry("META-INF/versions/10/module-info.class"))); + Assert.assertEquals(md.mainClass(), exp); + } + } + private static Set lines(ByteArrayOutputStream baos) { String s = new String(baos.toByteArray()); return Arrays.stream(s.split("\\R")) @@ -311,6 +432,12 @@ public class ConcealedPackage { } static enum Message { + CONTAINS_DIFFERENT_MAINCLASS( + ": module-info.class in a versioned directory contains different \"main-class\"" + ), + CONTAINS_DIFFERENT_VERSION( + ": module-info.class in a versioned directory contains different \"version\"" + ), NOT_FOUND_IN_BASE_ENTRY( ", contains a new public class not found in base entries" ), diff --git a/jdk/test/tools/jar/modularJar/Basic.java b/jdk/test/tools/jar/modularJar/Basic.java index df38b6cc584..8a9d44132fc 100644 --- a/jdk/test/tools/jar/modularJar/Basic.java +++ b/jdk/test/tools/jar/modularJar/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ import static java.lang.System.out; /* * @test - * @bug 8167328 + * @bug 8167328 8171830 * @library /lib/testlibrary * @modules jdk.compiler * jdk.jartool @@ -241,6 +241,11 @@ public class Basic { java(mp, FOO.moduleName + "/" + FOO.mainClass) .assertSuccess() +.resultChecker(r -> { + System.out.println("==================================="); + System.out.println(r.output); + System.out.println("==================================="); +}) .resultChecker(r -> assertModuleData(r, FOO)); try (InputStream fis = Files.newInputStream(modularJar); JarInputStream jis = new JarInputStream(fis)) { @@ -417,6 +422,7 @@ public class Basic { jar("--update", "--file=" + modularJar.toString(), "--main-class=" + FOO.mainClass, + "--module-version=" + FOO.version, "-m", mrjarDir.resolve("META-INF/MANIFEST.MF").toRealPath().toString(), "-C", mrjarDir.toString(), "META-INF/versions/9/module-info.class") .assertSuccess(); @@ -733,6 +739,25 @@ public class Basic { .assertSuccess(); } + @Test + public void exportCreateWithMissingPkg() throws IOException { + + Path foobar = TEST_SRC.resolve("src").resolve("foobar"); + Path dst = Files.createDirectories(MODULE_CLASSES.resolve("foobar")); + javac(dst, null, sourceList(foobar)); + + Path mp = Paths.get("exportWithMissingPkg"); + createTestDir(mp); + Path modClasses = dst; + Path modularJar = mp.resolve("foofoo.jar"); + + jar("--create", + "--file=" + modularJar.toString(), + "-C", modClasses.toString(), "module-info.class", + "-C", modClasses.toString(), "jdk/test/foo/Foo.class") + .assertFailure(); + } + @Test public void printModuleDescriptorFoo() throws IOException { Path mp = Paths.get("printModuleDescriptorFoo"); diff --git a/jdk/test/tools/jar/modularJar/src/foobar/Bar.java b/jdk/test/tools/jar/modularJar/src/foobar/Bar.java new file mode 100644 index 00000000000..9d6aa0b7b65 --- /dev/null +++ b/jdk/test/tools/jar/modularJar/src/foobar/Bar.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.bar; + +public class Bar { + public static void main(String[] args) {} +} diff --git a/jdk/test/tools/jar/modularJar/src/foobar/Foo.java b/jdk/test/tools/jar/modularJar/src/foobar/Foo.java new file mode 100644 index 00000000000..5b185409bf7 --- /dev/null +++ b/jdk/test/tools/jar/modularJar/src/foobar/Foo.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.foo; + +public class Foo { + public static void main(String[] args) {} +} diff --git a/jdk/test/tools/jar/modularJar/src/foobar/module-info.java b/jdk/test/tools/jar/modularJar/src/foobar/module-info.java new file mode 100644 index 00000000000..9465c135f3c --- /dev/null +++ b/jdk/test/tools/jar/modularJar/src/foobar/module-info.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +module foo { + exports jdk.test.foo; + exports jdk.test.bar; + opens jdk.test.foo; + opens jdk.test.bar; +} diff --git a/jdk/test/tools/jar/multiRelease/Basic1.java b/jdk/test/tools/jar/multiRelease/Basic1.java index 792b128d3bd..8c3788085ee 100644 --- a/jdk/test/tools/jar/multiRelease/Basic1.java +++ b/jdk/test/tools/jar/multiRelease/Basic1.java @@ -62,15 +62,20 @@ public class Basic1 { Path source = Paths.get(src, "data", test, "base", "version"); javac(classes, source.resolve("Main.java"), source.resolve("Version.java")); - Path v9 = Paths.get("v9").resolve("META-INF").resolve("versions").resolve("9"); + Path v9 = Paths.get("v9"); Files.createDirectories(v9); source = Paths.get(src, "data", test, "v9", "version"); javac(v9, source.resolve("Version.java")); - Path v10 = Paths.get("v10").resolve("META-INF").resolve("versions").resolve("10"); + Path v10 = Paths.get("v10"); Files.createDirectories(v10); source = Paths.get(src, "data", test, "v10", "version"); javac(v10, source.resolve("Version.java")); + + Path v10_1 = Paths.get("v10_1").resolve("META-INF").resolve("versions").resolve("v10"); + Files.createDirectories(v10_1); + source = Paths.get(src, "data", test, "v10", "version"); + javac(v10_1, source.resolve("Version.java")); } @Test @@ -95,28 +100,30 @@ public class Basic1 { new String[] {"classes", "base", "version", "Version.class"}, "META-INF/versions/9/version/Version.class", - new String[] {"v9", "META-INF", "versions", "9", "version", "Version.class"}, + new String[] {"v9", "version", "Version.class"}, "META-INF/versions/10/version/Version.class", - new String[] {"v10", "META-INF", "versions", "10", "version", "Version.class"} + new String[] {"v10", "version", "Version.class"} ); compare(jarfile, names); } + @Test public void testFail() throws IOException { String jarfile = "test.jar"; Path classes = Paths.get("classes"); - Path v9 = Paths.get("v9"); - Path v10 = Paths.get("v10"); + Path v10 = Paths.get("v10_1"); jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", - "--release", "9", "-C", v10.toString(), ".") + "--release", "10", "-C", v10.toString(), ".") .assertFailure() .outputContains("unexpected versioned entry META-INF/versions/"); } + + private void checkMultiRelease(String jarFile, boolean expected) throws IOException { try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ, JarFile.runtimeVersion())) { From 58a825f1b04992338dd1da4de25e50b454d4c4ec Mon Sep 17 00:00:00 2001 From: Amanda Jiang Date: Thu, 12 Jan 2017 17:10:41 -0800 Subject: [PATCH 084/154] 8171423: Relocate /test/lib/security/SecurityTools.java Reviewed-by: weijun, xuelei --- jdk/test/lib/security/SecurityTools.java | 122 ------------------ .../sun/security/tools/keytool/PrintSSL.java | 8 +- .../sun/security/tools/keytool/ReadJar.java | 7 +- 3 files changed, 8 insertions(+), 129 deletions(-) delete mode 100644 jdk/test/lib/security/SecurityTools.java diff --git a/jdk/test/lib/security/SecurityTools.java b/jdk/test/lib/security/SecurityTools.java deleted file mode 100644 index 601aa8a999c..00000000000 --- a/jdk/test/lib/security/SecurityTools.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; -import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; - -public class SecurityTools { - - public static final String NO_ALIAS = null; - - // keytool - - public static OutputAnalyzer keytool(List options) - throws Throwable { - - JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("keytool") - .addVMArg("-Duser.language=en") - .addVMArg("-Duser.country=US"); - for (String option : options) { - if (option.startsWith("-J")) { - launcher.addVMArg(option.substring(2)); - } else { - launcher.addToolArg(option); - } - } - return ProcessTools.executeCommand(launcher.getCommand()); - } - - public static OutputAnalyzer keytool(String options) throws Throwable { - return keytool(options.split("\\s+")); - } - - public static OutputAnalyzer keytool(String... options) throws Throwable { - return keytool(List.of(options)); - } - - // jarsigner - - public static OutputAnalyzer jarsigner(String jar, String alias, - List options) throws Throwable { - JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner") - .addVMArg("-Duser.language=en") - .addVMArg("-Duser.country=US"); - for (String option : options) { - if (option.startsWith("-J")) { - launcher.addVMArg(option.substring(2)); - } else { - launcher.addToolArg(option); - } - } - launcher.addToolArg(jar); - if (alias != null) { - launcher.addToolArg(alias); - } - return ProcessTools.executeCommand(launcher.getCommand()); - } - - public static OutputAnalyzer jarsigner(String jar, String alias, - String options) throws Throwable { - - return jarsigner(jar, alias, options.split("\\s+")); - } - - public static OutputAnalyzer jarsigner(String jar, String alias, - String... options) throws Throwable { - - return jarsigner(jar, alias, List.of(options)); - } - - public static OutputAnalyzer sign(String jar, String alias, String... options) - throws Throwable { - - return jarsigner(jar, alias, - mergeOptions("-J-Djava.security.egd=file:/dev/./urandom", options)); - } - - public static OutputAnalyzer verify(String jar, String... options) - throws Throwable { - - return jarsigner(jar, NO_ALIAS, mergeOptions("-verify", options)); - } - - // helper methods - - private static List mergeOptions( - String firstOption, String... secondPart) { - - return mergeOptions(List.of(firstOption), secondPart); - } - - private static List mergeOptions( - List firstPart, String... secondPart) { - - List options = new ArrayList<>(firstPart); - Collections.addAll(options, secondPart); - return options; - } -} diff --git a/jdk/test/sun/security/tools/keytool/PrintSSL.java b/jdk/test/sun/security/tools/keytool/PrintSSL.java index 2e600fcd0e5..2f4a4ff8b59 100644 --- a/jdk/test/sun/security/tools/keytool/PrintSSL.java +++ b/jdk/test/sun/security/tools/keytool/PrintSSL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,7 @@ * @test * @bug 6480981 8160624 * @summary keytool should be able to import certificates from remote SSL server - * @library /lib/security - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm PrintSSL */ @@ -36,7 +35,8 @@ import java.nio.file.Paths; import java.util.concurrent.CountDownLatch; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocket; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.OutputAnalyzer; public class PrintSSL { diff --git a/jdk/test/sun/security/tools/keytool/ReadJar.java b/jdk/test/sun/security/tools/keytool/ReadJar.java index 9e6739cc68b..5400db17e31 100644 --- a/jdk/test/sun/security/tools/keytool/ReadJar.java +++ b/jdk/test/sun/security/tools/keytool/ReadJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,14 +25,15 @@ * @test * @bug 6890872 8168882 * @summary keytool -printcert to recognize signed jar files - * @library /lib/security + * @library /test/lib * @library /lib/testlibrary */ import java.nio.file.Files; import java.nio.file.Paths; +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.OutputAnalyzer; import jdk.testlibrary.JarUtils; -import jdk.testlibrary.OutputAnalyzer; public class ReadJar { From 49fb7e0721435b3c1842ab85b819194500e74465 Mon Sep 17 00:00:00 2001 From: Amanda Jiang Date: Thu, 12 Jan 2017 17:15:26 -0800 Subject: [PATCH 085/154] 8171423: Relocate /test/lib/security/SecurityTools.java Reviewed-by: weijun, xuelei --- test/lib/jdk/test/lib/SecurityTools.java | 124 +++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 test/lib/jdk/test/lib/SecurityTools.java diff --git a/test/lib/jdk/test/lib/SecurityTools.java b/test/lib/jdk/test/lib/SecurityTools.java new file mode 100644 index 00000000000..37dd1104f74 --- /dev/null +++ b/test/lib/jdk/test/lib/SecurityTools.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class SecurityTools { + + public static final String NO_ALIAS = null; + + // keytool + + public static OutputAnalyzer keytool(List options) + throws Throwable { + + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("keytool") + .addVMArg("-Duser.language=en") + .addVMArg("-Duser.country=US"); + for (String option : options) { + if (option.startsWith("-J")) { + launcher.addVMArg(option.substring(2)); + } else { + launcher.addToolArg(option); + } + } + return ProcessTools.executeCommand(launcher.getCommand()); + } + + public static OutputAnalyzer keytool(String options) throws Throwable { + return keytool(options.split("\\s+")); + } + + public static OutputAnalyzer keytool(String... options) throws Throwable { + return keytool(List.of(options)); + } + + // jarsigner + + public static OutputAnalyzer jarsigner(String jar, String alias, + List options) throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner") + .addVMArg("-Duser.language=en") + .addVMArg("-Duser.country=US"); + for (String option : options) { + if (option.startsWith("-J")) { + launcher.addVMArg(option.substring(2)); + } else { + launcher.addToolArg(option); + } + } + launcher.addToolArg(jar); + if (alias != null) { + launcher.addToolArg(alias); + } + return ProcessTools.executeCommand(launcher.getCommand()); + } + + public static OutputAnalyzer jarsigner(String jar, String alias, + String options) throws Throwable { + + return jarsigner(jar, alias, options.split("\\s+")); + } + + public static OutputAnalyzer jarsigner(String jar, String alias, + String... options) throws Throwable { + + return jarsigner(jar, alias, List.of(options)); + } + + public static OutputAnalyzer sign(String jar, String alias, String... options) + throws Throwable { + + return jarsigner(jar, alias, + mergeOptions("-J-Djava.security.egd=file:/dev/./urandom", options)); + } + + public static OutputAnalyzer verify(String jar, String... options) + throws Throwable { + + return jarsigner(jar, NO_ALIAS, mergeOptions("-verify", options)); + } + + // helper methods + + private static List mergeOptions( + String firstOption, String... secondPart) { + + return mergeOptions(List.of(firstOption), secondPart); + } + + private static List mergeOptions( + List firstPart, String... secondPart) { + + List options = new ArrayList<>(firstPart); + Collections.addAll(options, secondPart); + return options; + } +} + From 3f70732b40f5ce479aad64f73f2208a44237ece4 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Thu, 12 Jan 2017 22:44:13 -0800 Subject: [PATCH 086/154] 8172761: Test change in tools/jar/InputFilesTest.java for JDK-8172432 is missing Reviewed-by: mchung --- jdk/test/tools/jar/InputFilesTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/tools/jar/InputFilesTest.java b/jdk/test/tools/jar/InputFilesTest.java index ac5b3b29f94..280cad57a58 100644 --- a/jdk/test/tools/jar/InputFilesTest.java +++ b/jdk/test/tools/jar/InputFilesTest.java @@ -102,6 +102,7 @@ public class InputFilesTest { "META-INF/MANIFEST.MF" + nl + "testfile1" + nl + "testfile2" + nl + + "META-INF/versions/9/" + nl + "META-INF/versions/9/testfile3" + nl + "META-INF/versions/9/testfile4" + nl; rm("test.jar test1 test2 test3 test4"); From c4dd83d1016bb0ed03e7bde7b2084bc2ccd0d8b1 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Thu, 12 Jan 2017 22:55:33 -0800 Subject: [PATCH 087/154] 8172432: jar cleanup/update for module and mrm jar Reviewed-by: mchung, psandoz, chegar --- make/CompileJavaModules.gmk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 678618ec3f0..c794b30b714 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -383,6 +383,10 @@ jdk.javadoc_COPY := .xml .css .js .png ################################################################################ +jdk.jartool_ADD_JAVAC_FLAGS := -XDstringConcat=inline + +################################################################################ + jdk.rmic_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS jdk.rmic_CLEAN := .properties From c9ebba358d483900e677ba576bb21d37897f6f9e Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 13 Jan 2017 01:07:50 -0800 Subject: [PATCH 088/154] 8172767: a bulk of tests failed with FileSystemException on Windows Reviewed-by: chegar --- jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java | 4 ++-- .../jdk.jartool/share/classes/sun/tools/jar/Validator.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java index cd9317e85a4..10e9d10f029 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java @@ -434,8 +434,8 @@ public class Main { private void validateAndClose(File tmpfile) throws IOException { if (ok && isMultiRelease) { - try { - ok = Validator.validate(this, tmpfile); + try (JarFile jf = new JarFile(tmpfile)) { + ok = Validator.validate(this, jf); if (!ok) { error(formatMsg("error.validator.jarfile.invalid", fname)); } diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java index bce128dd499..a5283b0c26a 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java @@ -74,8 +74,8 @@ final class Validator { loadModuleDescriptor(); } - static boolean validate(Main main, File f) throws IOException { - return new Validator(main, new JarFile(f)).validate(); + static boolean validate(Main main, JarFile jf) throws IOException { + return new Validator(main, jf).validate(); } private boolean validate() { From dddd58b278e3e3010a39f60c3073b01989bc3039 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 13 Jan 2017 13:12:21 +0100 Subject: [PATCH 089/154] 8170544: Fix code scan findings in libnet Reviewed-by: goetz, chegar --- .../java.base/share/native/libnet/net_util.c | 77 +++++---- .../java.base/share/native/libnet/net_util.h | 41 +++-- .../unix/native/libnet/Inet6AddressImpl.c | 3 +- .../unix/native/libnet/NetworkInterface.c | 6 +- .../native/libnet/PlainDatagramSocketImpl.c | 123 +++++++------- .../unix/native/libnet/PlainSocketImpl.c | 43 ++--- .../unix/native/libnet/net_util_md.c | 150 +++++++----------- .../unix/native/libnet/net_util_md.h | 55 +++---- .../native/libnio/ch/DatagramChannelImpl.c | 12 +- .../unix/native/libnio/ch/InheritedChannel.c | 4 +- jdk/src/java.base/unix/native/libnio/ch/Net.c | 14 +- .../libnio/ch/ServerSocketChannelImpl.c | 2 +- .../libnet/DualStackPlainDatagramSocketImpl.c | 53 +++---- .../native/libnet/DualStackPlainSocketImpl.c | 28 ++-- .../libnet/TwoStacksPlainDatagramSocketImpl.c | 108 ++++++------- .../native/libnet/TwoStacksPlainSocketImpl.c | 59 +++---- .../windows/native/libnet/net_util_md.c | 130 +++++++-------- .../windows/native/libnet/net_util_md.h | 2 +- .../native/libnio/ch/DatagramChannelImpl.c | 31 ++-- .../java.base/windows/native/libnio/ch/Net.c | 30 ++-- .../libnio/ch/ServerSocketChannelImpl.c | 4 +- .../ch/WindowsAsynchronousSocketChannelImpl.c | 17 +- .../unix/native/libsctp/SctpChannelImpl.c | 10 +- .../jdk.sctp/unix/native/libsctp/SctpNet.c | 78 ++++----- 24 files changed, 499 insertions(+), 581 deletions(-) diff --git a/jdk/src/java.base/share/native/libnet/net_util.c b/jdk/src/java.base/share/native/libnet/net_util.c index 02bf588ddc9..f6cbb353200 100644 --- a/jdk/src/java.base/share/native/libnet/net_util.c +++ b/jdk/src/java.base/share/native/libnet/net_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,10 +64,10 @@ DEF_JNI_OnLoad(JavaVM *vm, void *reserved) preferIPv4Stack = (*env)->CallStaticBooleanMethod(env, iCls, mid, s); /* - Since we have initialized and loaded the Socket library we will - check now to whether we have IPv6 on this platform and if the - supporting socket APIs are available - */ + * Since we have initialized and loaded the socket library we will + * check now whether we have IPv6 on this platform and if the + * supporting socket APIs are available + */ IPv6_available = IPv6_supported() & (!preferIPv4Stack); /* check if SO_REUSEPORT is supported on this platform */ @@ -120,16 +120,16 @@ jboolean setInet6Address_scopeifname(JNIEnv *env, jobject iaObj, jobject scopeif return JNI_TRUE; } -int getInet6Address_scopeid_set(JNIEnv *env, jobject iaObj) { +jboolean getInet6Address_scopeid_set(JNIEnv *env, jobject iaObj) { jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); - CHECK_NULL_RETURN(holder, -1); + CHECK_NULL_RETURN(holder, JNI_FALSE); return (*env)->GetBooleanField(env, holder, ia6_scopeidsetID); } -int getInet6Address_scopeid(JNIEnv *env, jobject iaObj) { +unsigned int getInet6Address_scopeid(JNIEnv *env, jobject iaObj) { jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); - CHECK_NULL_RETURN(holder, -1); - return (*env)->GetIntField(env, holder, ia6_scopeidID); + CHECK_NULL_RETURN(holder, 0); + return (unsigned int)(*env)->GetIntField(env, holder, ia6_scopeidID); } jboolean setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) { @@ -201,11 +201,10 @@ jobject getInetAddress_hostName(JNIEnv *env, jobject iaObj) { } JNIEXPORT jobject JNICALL -NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { +NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port) { jobject iaObj; - if (him->sa_family == AF_INET6) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - jbyte *caddr = (jbyte *)&(him6->sin6_addr); + if (sa->sa.sa_family == AF_INET6) { + jbyte *caddr = (jbyte *)&sa->sa6.sin6_addr; if (NET_IsIPv4Mapped(caddr)) { int address; iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); @@ -214,42 +213,35 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { setInetAddress_addr(env, iaObj, address); setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4); } else { - jint scope; jboolean ret; iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); CHECK_NULL_RETURN(iaObj, NULL); - ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr)); + ret = setInet6Address_ipaddress(env, iaObj, (char *)&sa->sa6.sin6_addr); if (ret == JNI_FALSE) return NULL; setInetAddress_family(env, iaObj, java_net_InetAddress_IPv6); - scope = getScopeID(him); - setInet6Address_scopeid(env, iaObj, scope); + setInet6Address_scopeid(env, iaObj, sa->sa6.sin6_scope_id); } - *port = ntohs(him6->sin6_port); + *port = ntohs(sa->sa6.sin6_port); } else { - struct sockaddr_in *him4 = (struct sockaddr_in *)him; iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4); - setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr)); - *port = ntohs(him4->sin_port); + setInetAddress_addr(env, iaObj, ntohl(sa->sa4.sin_addr.s_addr)); + *port = ntohs(sa->sa4.sin_port); } return iaObj; } -JNIEXPORT jint JNICALL -NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj) +JNIEXPORT jboolean JNICALL +NET_SockaddrEqualsInetAddress(JNIEnv *env, SOCKETADDRESS *sa, jobject iaObj) { - jint family = AF_INET; - - family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ? - AF_INET : AF_INET6; - if (him->sa_family == AF_INET6) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - jbyte *caddrNew = (jbyte *)&(him6->sin6_addr); + jint family = getInetAddress_family(env, iaObj) == + java_net_InetAddress_IPv4 ? AF_INET : AF_INET6; + if (sa->sa.sa_family == AF_INET6) { + jbyte *caddrNew = (jbyte *)&sa->sa6.sin6_addr; if (NET_IsIPv4Mapped(caddrNew)) { - int addrNew; - int addrCur; + int addrNew, addrCur; if (family == AF_INET6) { return JNI_FALSE; } @@ -262,26 +254,24 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj) } } else { jbyte caddrCur[16]; - int scope; - if (family == AF_INET) { return JNI_FALSE; } - scope = getInet6Address_scopeid(env, iaObj); getInet6Address_ipaddress(env, iaObj, (char *)caddrCur); - if (NET_IsEqual(caddrNew, caddrCur) && cmpScopeID(scope, him)) { + if (NET_IsEqual(caddrNew, caddrCur) && + sa->sa6.sin6_scope_id == getInet6Address_scopeid(env, iaObj)) + { return JNI_TRUE; } else { return JNI_FALSE; } } } else { - struct sockaddr_in *him4 = (struct sockaddr_in *)him; int addrNew, addrCur; if (family != AF_INET) { return JNI_FALSE; } - addrNew = ntohl(him4->sin_addr.s_addr); + addrNew = ntohl(sa->sa4.sin_addr.s_addr); addrCur = getInetAddress_addr(env, iaObj); if (addrNew == addrCur) { return JNI_TRUE; @@ -291,6 +281,15 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj) } } +JNIEXPORT jint JNICALL +NET_GetPortFromSockaddr(SOCKETADDRESS *sa) { + if (sa->sa.sa_family == AF_INET6) { + return ntohs(sa->sa6.sin6_port); + } else { + return ntohs(sa->sa4.sin_port); + } +} + unsigned short in_cksum(unsigned short *addr, int len) { int nleft = len; diff --git a/jdk/src/java.base/share/native/libnet/net_util.h b/jdk/src/java.base/share/native/libnet/net_util.h index c625d60c27f..1acaff9bec3 100644 --- a/jdk/src/java.base/share/native/libnet/net_util.h +++ b/jdk/src/java.base/share/native/libnet/net_util.h @@ -63,8 +63,8 @@ JNIEXPORT void JNICALL initInetAddressIDs(JNIEnv *env); */ extern jobject getInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj); extern jboolean setInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj, jobject scopeifname); -extern int getInet6Address_scopeid_set(JNIEnv *env, jobject ia6Obj); -extern int getInet6Address_scopeid(JNIEnv *env, jobject ia6Obj); +extern jboolean getInet6Address_scopeid_set(JNIEnv *env, jobject ia6Obj); +extern unsigned int getInet6Address_scopeid(JNIEnv *env, jobject ia6Obj); extern jboolean setInet6Address_scopeid(JNIEnv *env, jobject ia6Obj, int scopeid); extern jboolean getInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *dest); extern jboolean setInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *address); @@ -132,24 +132,41 @@ JNIEXPORT jint JNICALL ipv6_available(); JNIEXPORT jint JNICALL reuseport_available(); +/** + * This function will fill a SOCKETADDRESS structure from an InetAddress + * object. + * + * The parameter 'sa' must point to valid storage of size + * 'sizeof(SOCKETADDRESS)'. + * + * The parameter 'len' is a pointer to an int and is used for returning + * the actual sockaddr length, e.g. 'sizeof(struct sockaddr_in)' or + * 'sizeof(struct sockaddr_in6)'. + * + * If the type of the InetAddress object is IPv6, the function will fill a + * sockaddr_in6 structure. IPv6 must be available in that case, otherwise an + * exception is thrown. + * In the case of an IPv4 InetAddress, when IPv6 is available and + * v4MappedAddress is TRUE, this method will fill a sockaddr_in6 structure + * containing an IPv4 mapped IPv6 address. Otherwise a sockaddr_in + * structure will be filled. + */ JNIEXPORT int JNICALL NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, - struct sockaddr *him, int *len, + SOCKETADDRESS *sa, int *len, jboolean v4MappedAddress); JNIEXPORT jobject JNICALL -NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port); +NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port); void platformInit(); void parseExclusiveBindProperty(JNIEnv *env); -void NET_SetTrafficClass(struct sockaddr *him, int trafficClass); +JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(SOCKETADDRESS *sa); -JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(struct sockaddr *him); - -JNIEXPORT jint JNICALL -NET_SockaddrEqualsInetAddress(JNIEnv *env,struct sockaddr *him, jobject iaObj); +JNIEXPORT jboolean JNICALL +NET_SockaddrEqualsInetAddress(JNIEnv *env, SOCKETADDRESS *sa, jobject iaObj); int NET_IsIPv4Mapped(jbyte* caddr); @@ -172,7 +189,7 @@ JNIEXPORT int JNICALL NET_SetSockOpt(int fd, int level, int opt, const void *arg, int len); JNIEXPORT int JNICALL -NET_Bind(int fd, struct sockaddr *him, int len); +NET_Bind(int fd, SOCKETADDRESS *sa, int len); JNIEXPORT int JNICALL NET_MapSocketOption(jint cmd, int *level, int *optname); @@ -183,10 +200,6 @@ NET_MapSocketOptionV6(jint cmd, int *level, int *optname); JNIEXPORT jint JNICALL NET_EnableFastTcpLoopback(int fd); -int getScopeID(struct sockaddr *); - -int cmpScopeID(unsigned int, struct sockaddr *); - unsigned short in_cksum(unsigned short *addr, int len); jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout); diff --git a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c index f4b961d943b..15f984ebd34 100644 --- a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c +++ b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c @@ -211,7 +211,8 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6) { int port; int index = (family == AF_INET) ? i++ : j++; - jobject o = NET_SockaddrToInetAddress(env, iter->ifa_addr, &port); + jobject o = NET_SockaddrToInetAddress(env, + (SOCKETADDRESS *)iter->ifa_addr, &port); if (!o) { freeifaddrs(ifa); if (!(*env)->ExceptionCheck(env)) diff --git a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c index 80571100666..88c27955ac8 100644 --- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c +++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -791,7 +791,7 @@ static netif *enumInterfaces(JNIEnv *env) { int sock; sock = openSocket(env, AF_INET); - if (sock < 0 && (*env)->ExceptionOccurred(env)) { + if (sock < 0) { return NULL; } @@ -809,7 +809,7 @@ static netif *enumInterfaces(JNIEnv *env) { // so we have to call ipv6_available() if (ipv6_available()) { sock = openSocket(env, AF_INET6); - if (sock < 0 && (*env)->ExceptionOccurred(env)) { + if (sock < 0) { freeif(ifs); return NULL; } diff --git a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c index a7fddecedd5..12357330ffe 100644 --- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c +++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c @@ -99,7 +99,7 @@ static jobject createInteger(JNIEnv *env, int i) { CHECK_NULL_RETURN(i_class, NULL); } - return ( (*env)->NewObject(env, i_class, i_ctrID, i) ); + return (*env)->NewObject(env, i_class, i_ctrID, i); } /* @@ -118,10 +118,9 @@ static jobject createBoolean(JNIEnv *env, int b) { CHECK_NULL_RETURN(b_class, NULL); } - return( (*env)->NewObject(env, b_class, b_ctrID, (jboolean)(b!=0)) ); + return (*env)->NewObject(env, b_class, b_ctrID, (jboolean)(b != 0)); } - /* * Returns the fd for a PlainDatagramSocketImpl or -1 * if closed. @@ -134,7 +133,6 @@ static int getFD(JNIEnv *env, jobject this) { return (*env)->GetIntField(env, fdObj, IO_fd_fdID); } - /* * Class: java_net_PlainDatagramSocketImpl * Method: init @@ -166,7 +164,6 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { initInetAddressIDs(env); JNU_CHECK_EXCEPTION(env); Java_java_net_NetworkInterface_init(env, 0); - } /* @@ -176,13 +173,13 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { */ JNIEXPORT void JNICALL Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, - jint localport, jobject iaObj) { + jint localport, jobject iaObj) { /* fdObj is the FileDescriptor field on this */ jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); /* fd is an int field on fdObj */ int fd; int len = 0; - SOCKETADDRESS him; + SOCKETADDRESS sa; socklen_t slen = sizeof(SOCKETADDRESS); if (IS_NULL(fdObj)) { @@ -199,12 +196,13 @@ Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, } /* bind */ - if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa, &len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, iaObj, localport, &sa, &len, + JNI_TRUE) != 0) { return; } - setDefaultScopeID(env, &him.sa); + setDefaultScopeID(env, &sa.sa); - if (NET_Bind(fd, &him.sa, len) < 0) { + if (NET_Bind(fd, &sa, len) < 0) { if (errno == EADDRINUSE || errno == EADDRNOTAVAIL || errno == EPERM || errno == EACCES) { NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException", @@ -221,13 +219,13 @@ Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, /* Now that we're a connected socket, let's extract the port number * that the system chose for us and store it in the Socket object. */ - if (getsockname(fd, &him.sa, &slen) == -1) { + if (getsockname(fd, &sa.sa, &slen) == -1) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error getting socket name"); return; } - localport = NET_GetPortFromSockaddr(&him.sa); + localport = NET_GetPortFromSockaddr(&sa); (*env)->SetIntField(env, this, pdsi_localPortID, localport); } else { @@ -263,7 +261,8 @@ Java_java_net_PlainDatagramSocketImpl_connect0(JNIEnv *env, jobject this, return; } - if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr.sa, &len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr, &len, + JNI_TRUE) != 0) { return; } @@ -290,6 +289,9 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin #if defined(__linux__) || defined(_ALLBSD_SOURCE) SOCKETADDRESS addr; socklen_t len; +#if defined(__linux__) + int localPort = 0; +#endif #endif if (IS_NULL(fdObj)) { @@ -298,32 +300,31 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); #if defined(__linux__) || defined(_ALLBSD_SOURCE) - memset(&addr, 0, sizeof(addr)); - if (ipv6_available()) { - addr.sa6.sin6_family = AF_UNSPEC; - len = sizeof(struct sockaddr_in6); + memset(&addr, 0, sizeof(addr)); + if (ipv6_available()) { + addr.sa6.sin6_family = AF_UNSPEC; + len = sizeof(struct sockaddr_in6); + } else { + addr.sa4.sin_family = AF_UNSPEC; + len = sizeof(struct sockaddr_in); + } + NET_Connect(fd, &addr.sa, len); + +#if defined(__linux__) + if (getsockname(fd, &addr.sa, &len) == -1) + return; + + localPort = NET_GetPortFromSockaddr(&addr); + if (localPort == 0) { + localPort = (*env)->GetIntField(env, this, pdsi_localPortID); + if (addr.sa.sa_family == AF_INET6) { + addr.sa6.sin6_port = htons(localPort); } else { - addr.sa4.sin_family = AF_UNSPEC; - len = sizeof(struct sockaddr_in); + addr.sa4.sin_port = htons(localPort); } - NET_Connect(fd, &addr.sa, len); -#ifdef __linux__ - int localPort = 0; - if (getsockname(fd, &addr.sa, &len) == -1) - return; - - localPort = NET_GetPortFromSockaddr(&addr.sa); - if (localPort == 0) { - localPort = (*env)->GetIntField(env, this, pdsi_localPortID); - if (addr.sa.sa_family == AF_INET6) { - addr.sa6.sin6_port = htons(localPort); - } else { - addr.sa4.sin_port = htons(localPort); - } - - NET_Bind(fd, &addr.sa, len); - } + NET_Bind(fd, &addr, len); + } #endif #else @@ -355,8 +356,9 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this, /* The fdObj'fd */ jint fd; - SOCKETADDRESS rmtaddr, *rmtaddrP = &rmtaddr; - int len; + SOCKETADDRESS rmtaddr; + struct sockaddr *rmtaddrP = 0; + int len = 0; if (IS_NULL(fdObj)) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", @@ -382,15 +384,14 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this, packetBufferOffset = (*env)->GetIntField(env, packet, dp_offsetID); packetBufferLen = (*env)->GetIntField(env, packet, dp_lengthID); - if (connected) { - /* arg to NET_Sendto () null in this case */ - len = 0; - rmtaddrP = 0; - } else { + // arg to NET_Sendto() null, if connected + if (!connected) { packetPort = (*env)->GetIntField(env, packet, dp_portID); - if (NET_InetAddressToSockaddr(env, packetAddress, packetPort, &rmtaddr.sa, &len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, packetAddress, packetPort, &rmtaddr, + &len, JNI_TRUE) != 0) { return; } + rmtaddrP = &rmtaddr.sa; } setDefaultScopeID(env, &rmtaddr.sa); @@ -427,7 +428,7 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this, (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen, (jbyte *)fullPacket); if (trafficClass != 0 && ipv6_available()) { - NET_SetTrafficClass(&rmtaddr.sa, trafficClass); + NET_SetTrafficClass(&rmtaddr, trafficClass); } /* @@ -437,8 +438,7 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this, * ECONNREFUSED indicating that an ICMP port unreachable has * received. */ - ret = NET_SendTo(fd, fullPacket, packetBufferLen, 0, - (struct sockaddr *)rmtaddrP, len); + ret = NET_SendTo(fd, fullPacket, packetBufferLen, 0, rmtaddrP, len); if (ret < 0) { if (errno == ECONNREFUSED) { @@ -510,7 +510,7 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this, #ifdef __solaris__ if (errno == ECONNREFUSED) { int orig_errno = errno; - (void) recv(fd, buf, 1, 0); + recv(fd, buf, 1, 0); errno = orig_errno; } #endif @@ -528,7 +528,7 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this, return 0; } - iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port); + iaObj = NET_SockaddrToInetAddress(env, &rmtaddr, &port); family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ? AF_INET : AF_INET6; if (family == AF_INET) { /* this API can't handle IPV6 addresses */ @@ -676,18 +676,18 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this, */ packetAddress = (*env)->GetObjectField(env, packet, dp_addressID); if (packetAddress != NULL) { - if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr.sa, packetAddress)) { + if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr, packetAddress)) { /* force a new InetAddress to be created */ packetAddress = NULL; } } if (packetAddress == NULL) { - packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port); + packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port); /* stuff the new Inetaddress in the packet */ (*env)->SetObjectField(env, packet, dp_addressID, packetAddress); } else { /* only get the new port number */ - port = NET_GetPortFromSockaddr(&rmtaddr.sa); + port = NET_GetPortFromSockaddr(&rmtaddr); } /* and fill in the data, remote address/port and such */ (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n, @@ -857,18 +857,19 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this, */ packetAddress = (*env)->GetObjectField(env, packet, dp_addressID); if (packetAddress != NULL) { - if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr.sa, packetAddress)) { + if (!NET_SockaddrEqualsInetAddress(env, &rmtaddr, + packetAddress)) { /* force a new InetAddress to be created */ packetAddress = NULL; } } if (packetAddress == NULL) { - packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port); + packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port); /* stuff the new Inetaddress in the packet */ (*env)->SetObjectField(env, packet, dp_addressID, packetAddress); } else { /* only get the new port number */ - port = NET_GetPortFromSockaddr(&rmtaddr.sa); + port = NET_GetPortFromSockaddr(&rmtaddr); } /* and fill in the data, remote address/port and such */ (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n, @@ -1040,6 +1041,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val /* * We need an ipv4 address here */ + in.s_addr = 0; for (i = 0; i < len; i++) { addr = (*env)->GetObjectArrayElement(env, addrArray, i); if (getInetAddress_family(env, addr) == java_net_InetAddress_IPv4) { @@ -1049,7 +1051,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val } if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, - (const char*)&in, sizeof(in)) < 0) { + (const char *)&in, sizeof(in)) < 0) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error setting socket option"); } @@ -1670,17 +1672,17 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption */ if (opt == java_net_SocketOptions_SO_BINDADDR) { /* find out local IP address */ - SOCKETADDRESS him; + SOCKETADDRESS sa; socklen_t len = sizeof(SOCKETADDRESS); int port; jobject iaObj; - if (getsockname(fd, &him.sa, &len) == -1) { + if (getsockname(fd, &sa.sa, &len) == -1) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error getting socket name"); return NULL; } - iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port); + iaObj = NET_SockaddrToInetAddress(env, &sa, &port); return iaObj; } @@ -1969,6 +1971,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this, mname.imr_multiaddr.s_addr = htonl(getInetAddress_addr(env, iaObj)); #ifdef __linux__ mname.imr_address.s_addr = htonl(getInetAddress_addr(env, addr)); + mname.imr_ifindex = 0; #else mname.imr_interface.s_addr = htonl(getInetAddress_addr(env, addr)); #endif @@ -2023,7 +2026,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this, #ifdef __linux__ mname.imr_address.s_addr = in.s_addr; - + mname.imr_ifindex = 0; #else mname.imr_interface.s_addr = in.s_addr; #endif diff --git a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c index b5af3466ada..1985085abb4 100644 --- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c +++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c @@ -244,7 +244,7 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this, /* fd is an int field on iaObj */ jint fd; - SOCKETADDRESS him; + SOCKETADDRESS sa; /* The result of the connection */ int connect_rv = -1; @@ -260,17 +260,18 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this, } /* connect */ - if (NET_InetAddressToSockaddr(env, iaObj, port, &him.sa, &len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, &len, + JNI_TRUE) != 0) { return; } - setDefaultScopeID(env, &him.sa); + setDefaultScopeID(env, &sa.sa); if (trafficClass != 0 && ipv6_available()) { - NET_SetTrafficClass(&him.sa, trafficClass); + NET_SetTrafficClass(&sa, trafficClass); } if (timeout <= 0) { - connect_rv = NET_Connect(fd, &him.sa, len); + connect_rv = NET_Connect(fd, &sa.sa, len); #ifdef __solaris__ if (connect_rv == -1 && errno == EINPROGRESS ) { @@ -319,7 +320,7 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this, SET_NONBLOCKING(fd); /* no need to use NET_Connect as non-blocking */ - connect_rv = connect(fd, &him.sa, len); + connect_rv = connect(fd, &sa.sa, len); /* connection not established immediately */ if (connect_rv != 0) { @@ -467,11 +468,11 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this, * that the system chose for us and store it in the Socket object. */ socklen_t slen = sizeof(SOCKETADDRESS); - if (getsockname(fd, &him.sa, &slen) == -1) { + if (getsockname(fd, &sa.sa, &slen) == -1) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error getting socket name"); } else { - localport = NET_GetPortFromSockaddr(&him.sa); + localport = NET_GetPortFromSockaddr(&sa); (*env)->SetIntField(env, this, psi_localportID, localport); } } @@ -490,8 +491,8 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this, jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID); /* fd is an int field on fdObj */ int fd; - int len; - SOCKETADDRESS him; + int len = 0; + SOCKETADDRESS sa; if (IS_NULL(fdObj)) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", @@ -506,13 +507,13 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this, } /* bind */ - if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa, + if (NET_InetAddressToSockaddr(env, iaObj, localport, &sa, &len, JNI_TRUE) != 0) { return; } - setDefaultScopeID(env, &him.sa); + setDefaultScopeID(env, &sa.sa); - if (NET_Bind(fd, &him.sa, len) < 0) { + if (NET_Bind(fd, &sa, len) < 0) { if (errno == EADDRINUSE || errno == EADDRNOTAVAIL || errno == EPERM || errno == EACCES) { NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException", @@ -533,12 +534,12 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this, /* Now that we're a connected socket, let's extract the port number * that the system chose for us and store it in the Socket object. */ - if (getsockname(fd, &him.sa, &slen) == -1) { + if (getsockname(fd, &sa.sa, &slen) == -1) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error getting socket name"); return; } - localport = NET_GetPortFromSockaddr(&him.sa); + localport = NET_GetPortFromSockaddr(&sa); (*env)->SetIntField(env, this, psi_localportID, localport); } else { (*env)->SetIntField(env, this, psi_localportID, localport); @@ -606,7 +607,7 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this, /* accepted fd */ jint newfd; - SOCKETADDRESS him; + SOCKETADDRESS sa; socklen_t slen = sizeof(SOCKETADDRESS); if (IS_NULL(fdObj)) { @@ -661,7 +662,7 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this, return; } - newfd = NET_Accept(fd, &him.sa, &slen); + newfd = NET_Accept(fd, &sa.sa, &slen); /* connection accepted */ if (newfd >= 0) { @@ -709,7 +710,7 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this, /* * fill up the remote peer port and address in the new socket structure. */ - socketAddressObj = NET_SockaddrToInetAddress(env, &him.sa, &port); + socketAddressObj = NET_SockaddrToInetAddress(env, &sa, &port); if (socketAddressObj == NULL) { /* should be pending exception */ close(newfd); @@ -944,19 +945,19 @@ Java_java_net_PlainSocketImpl_socketGetOption * SO_BINDADDR isn't a socket option */ if (cmd == java_net_SocketOptions_SO_BINDADDR) { - SOCKETADDRESS him; + SOCKETADDRESS sa; socklen_t len = sizeof(SOCKETADDRESS); int port; jobject iaObj; jclass iaCntrClass; jfieldID iaFieldID; - if (getsockname(fd, &him.sa, &len) < 0) { + if (getsockname(fd, &sa.sa, &len) < 0) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error getting socket name"); return -1; } - iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port); + iaObj = NET_SockaddrToInetAddress(env, &sa, &port); CHECK_NULL_RETURN(iaObj, -1); iaCntrClass = (*env)->GetObjectClass(env, iaContainerObj); diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.c b/jdk/src/java.base/unix/native/libnet/net_util_md.c index ee518088277..744fc2f6298 100644 --- a/jdk/src/java.base/unix/native/libnet/net_util_md.c +++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c @@ -234,29 +234,6 @@ int kernelIsV24 () { } return kernelV24; } - -int getScopeID (struct sockaddr *him) { - struct sockaddr_in6 *hext = (struct sockaddr_in6 *)him; - return hext->sin6_scope_id; -} - -int cmpScopeID (unsigned int scope, struct sockaddr *him) { - struct sockaddr_in6 *hext = (struct sockaddr_in6 *)him; - return hext->sin6_scope_id == scope; -} - -#else - -int getScopeID (struct sockaddr *him) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - return him6->sin6_scope_id; -} - -int cmpScopeID (unsigned int scope, struct sockaddr *him) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - return him6->sin6_scope_id == scope; -} - #endif void @@ -775,30 +752,32 @@ NET_EnableFastTcpLoopback(int fd) { return 0; } -/* In the case of an IPv4 Inetaddress this method will return an - * IPv4 mapped address where IPv6 is available and v4MappedAddress is TRUE. - * Otherwise it will return a sockaddr_in structure for an IPv4 InetAddress. -*/ +/** + * See net_util.h for documentation + */ JNIEXPORT int JNICALL -NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him, - int *len, jboolean v4MappedAddress) { - jint family; - family = getInetAddress_family(env, iaObj); - /* needs work. 1. family 2. clean up him6 etc deallocate memory */ - if (ipv6_available() && !(family == java_net_InetAddress_IPv4 && - v4MappedAddress == JNI_FALSE)) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; +NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, + SOCKETADDRESS *sa, int *len, + jboolean v4MappedAddress) +{ + jint family = getInetAddress_family(env, iaObj); + memset((char *)sa, 0, sizeof(SOCKETADDRESS)); + + if (ipv6_available() && + !(family == java_net_InetAddress_IPv4 && + v4MappedAddress == JNI_FALSE)) + { jbyte caddr[16]; jint address; if (family == java_net_InetAddress_IPv4) { // convert to IPv4-mapped address - memset((char *) caddr, 0, 16); + memset((char *)caddr, 0, 16); address = getInetAddress_addr(env, iaObj); if (address == INADDR_ANY) { /* we would always prefer IPv6 wildcard address - caddr[10] = 0xff; - caddr[11] = 0xff; */ + * caddr[10] = 0xff; + * caddr[11] = 0xff; */ } else { caddr[10] = 0xff; caddr[11] = 0xff; @@ -810,22 +789,19 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr } else { getInet6Address_ipaddress(env, iaObj, (char *)caddr); } - memset((char *)him6, 0, sizeof(struct sockaddr_in6)); - him6->sin6_port = htons(port); - memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) ); - him6->sin6_family = AF_INET6; - *len = sizeof(struct sockaddr_in6); - -#if defined(_ALLBSD_SOURCE) -// XXXBSD: should we do something with scope id here ? see below linux comment -/* MMM: Come back to this! */ -#endif + sa->sa6.sin6_port = htons(port); + memcpy((void *)&sa->sa6.sin6_addr, caddr, sizeof(struct in6_addr)); + sa->sa6.sin6_family = AF_INET6; + if (len != NULL) { + *len = sizeof(struct sockaddr_in6); + } +#ifdef __linux__ /* * On Linux if we are connecting to a link-local address * we need to specify the interface in the scope_id (2.4 kernel only) * - * If the scope was cached the we use the cached value. If not cached but + * If the scope was cached then we use the cached value. If not cached but * specified in the Inet6Address we use that, but we first check if the * address needs to be routed via the loopback interface. In this case, * we override the specified value with that of the loopback interface. @@ -833,9 +809,8 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr * we try to determine a value from the routing table. In all these * cases the used value is cached for further use. */ -#ifdef __linux__ - if (IN6_IS_ADDR_LINKLOCAL(&(him6->sin6_addr))) { - int cached_scope_id = 0, scope_id = 0; + if (IN6_IS_ADDR_LINKLOCAL(&sa->sa6.sin6_addr)) { + unsigned int cached_scope_id = 0, scope_id = 0; if (ia6_cachedscopeidID) { cached_scope_id = (int)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID); @@ -850,7 +825,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr /* check user-specified value for loopback case * that needs to be overridden */ - if (kernelIsV24() && needsLoopbackRoute (&him6->sin6_addr)) { + if (kernelIsV24() && needsLoopbackRoute(&sa->sa6.sin6_addr)) { cached_scope_id = lo_scope_id; (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id); } @@ -860,11 +835,11 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr * try determine the appropriate interface. */ if (kernelIsV24()) { - cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr)); + cached_scope_id = getDefaultIPv6Interface(&sa->sa6.sin6_addr); } else { - cached_scope_id = getLocalScopeID((char *)&(him6->sin6_addr)); + cached_scope_id = getLocalScopeID((char *)&(sa->sa6.sin6_addr)); if (cached_scope_id == 0) { - cached_scope_id = getDefaultIPv6Interface(&(him6->sin6_addr)); + cached_scope_id = getDefaultIPv6Interface(&sa->sa6.sin6_addr); } } (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id); @@ -876,53 +851,37 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr * If we have a scope_id use the extended form * of sockaddr_in6. */ - - struct sockaddr_in6 *him6 = - (struct sockaddr_in6 *)him; - him6->sin6_scope_id = cached_scope_id != 0 ? - cached_scope_id : scope_id; - *len = sizeof(struct sockaddr_in6); + sa->sa6.sin6_scope_id = cached_scope_id == 0 ? scope_id : cached_scope_id; } #else - /* handle scope_id for solaris */ - + /* handle scope_id */ if (family != java_net_InetAddress_IPv4) { if (ia6_scopeidID) { - him6->sin6_scope_id = getInet6Address_scopeid(env, iaObj); + sa->sa6.sin6_scope_id = getInet6Address_scopeid(env, iaObj); } } #endif } else { - struct sockaddr_in *him4 = (struct sockaddr_in *)him; jint address; - if (family == java_net_InetAddress_IPv6) { + if (family != java_net_InetAddress_IPv4) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable"); return -1; } - memset((char *)him4, 0, sizeof(struct sockaddr_in)); address = getInetAddress_addr(env, iaObj); - him4->sin_port = htons((short) port); - him4->sin_addr.s_addr = htonl(address); - him4->sin_family = AF_INET; - *len = sizeof(struct sockaddr_in); + sa->sa4.sin_port = htons(port); + sa->sa4.sin_addr.s_addr = htonl(address); + sa->sa4.sin_family = AF_INET; + if (len != NULL) { + *len = sizeof(struct sockaddr_in); + } } return 0; } void -NET_SetTrafficClass(struct sockaddr *him, int trafficClass) { - if (him->sa_family == AF_INET6) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - him6->sin6_flowinfo = htonl((trafficClass & 0xff) << 20); - } -} - -JNIEXPORT jint JNICALL -NET_GetPortFromSockaddr(struct sockaddr *him) { - if (him->sa_family == AF_INET6) { - return ntohs(((struct sockaddr_in6*)him)->sin6_port); - } else { - return ntohs(((struct sockaddr_in*)him)->sin_port); +NET_SetTrafficClass(SOCKETADDRESS *sa, int trafficClass) { + if (sa->sa.sa_family == AF_INET6) { + sa->sa6.sin6_flowinfo = htonl((trafficClass & 0xff) << 20); } } @@ -1488,7 +1447,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, * */ int -NET_Bind(int fd, struct sockaddr *him, int len) +NET_Bind(int fd, SOCKETADDRESS *sa, int len) { #if defined(__solaris__) int level = -1; @@ -1503,9 +1462,8 @@ NET_Bind(int fd, struct sockaddr *him, int len) * ## When IPv6 is enabled this will be an IPv4-mapped * ## with family set to AF_INET6 */ - if (him->sa_family == AF_INET) { - struct sockaddr_in *sa = (struct sockaddr_in *)him; - if ((ntohl(sa->sin_addr.s_addr) & 0x7f0000ff) == 0x7f0000ff) { + if (sa->sa.sa_family == AF_INET) { + if ((ntohl(sa->sa4.sin_addr.s_addr) & 0x7f0000ff) == 0x7f0000ff) { errno = EADDRNOTAVAIL; return -1; } @@ -1524,8 +1482,9 @@ NET_Bind(int fd, struct sockaddr *him, int len) */ alen = sizeof(arg); - if (useExclBind || getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - (char *)&arg, &alen) == 0) { + if (useExclBind || + getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&arg, &alen) == 0) + { if (useExclBind || arg == 0) { /* * SO_REUSEADDR is disabled or sun.net.useExclusiveBind @@ -1533,8 +1492,8 @@ NET_Bind(int fd, struct sockaddr *him, int len) * UDP_EXCLBIND */ alen = sizeof(arg); - if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg, - &alen) == 0) { + if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg, &alen) == 0) + { if (arg == SOCK_STREAM) { level = IPPROTO_TCP; exclbind = TCP_EXCLBIND; @@ -1545,14 +1504,13 @@ NET_Bind(int fd, struct sockaddr *him, int len) } arg = 1; - setsockopt(fd, level, exclbind, (char *)&arg, - sizeof(arg)); + setsockopt(fd, level, exclbind, (char *)&arg, sizeof(arg)); } } #endif - rv = bind(fd, him, len); + rv = bind(fd, &sa->sa, len); #if defined(__solaris__) if (rv < 0) { diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.h b/jdk/src/java.base/unix/native/libnet/net_util_md.h index 48503d2efbe..15e08c48ae9 100644 --- a/jdk/src/java.base/unix/native/libnet/net_util_md.h +++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h @@ -30,32 +30,6 @@ #include #include -int NET_Timeout(int s, long timeout); -int NET_Timeout0(int s, long timeout, long currentTime); -int NET_Read(int s, void* buf, size_t len); -int NET_NonBlockingRead(int s, void* buf, size_t len); -int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime); -long NET_GetCurrentTime(); -int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, - struct sockaddr *from, socklen_t *fromlen); -int NET_ReadV(int s, const struct iovec * vector, int count); -int NET_Send(int s, void *msg, int len, unsigned int flags); -int NET_SendTo(int s, const void *msg, int len, unsigned int - flags, const struct sockaddr *to, int tolen); -int NET_Writev(int s, const struct iovec * vector, int count); -int NET_Connect(int s, struct sockaddr *addr, int addrlen); -int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int NET_SocketClose(int s); -int NET_Dup2(int oldfd, int newfd); -int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout); -int NET_SocketAvailable(int s, jint *pbytes); - -void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env, - const char* hostname, - int gai_error); -void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name, - const char *defaultDetail); - /************************************************************************ * Macros and constants */ @@ -91,9 +65,36 @@ typedef union { } SOCKETADDRESS; /************************************************************************ - * Utilities + * Functions */ +int NET_Timeout(int s, long timeout); +int NET_Timeout0(int s, long timeout, long currentTime); +int NET_Read(int s, void* buf, size_t len); +int NET_NonBlockingRead(int s, void* buf, size_t len); +int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime); +long NET_GetCurrentTime(); +int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, + struct sockaddr *from, socklen_t *fromlen); +int NET_ReadV(int s, const struct iovec * vector, int count); +int NET_Send(int s, void *msg, int len, unsigned int flags); +int NET_SendTo(int s, const void *msg, int len, unsigned int + flags, const struct sockaddr *to, int tolen); +int NET_Writev(int s, const struct iovec * vector, int count); +int NET_Connect(int s, struct sockaddr *addr, int addrlen); +int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen); +int NET_SocketClose(int s); +int NET_Dup2(int oldfd, int newfd); +int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout); +int NET_SocketAvailable(int s, jint *pbytes); + +void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env, + const char* hostname, + int gai_error); +void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name, + const char *defaultDetail); +void NET_SetTrafficClass(SOCKETADDRESS *sa, int trafficClass); + #ifdef __linux__ int kernelIsV24(); int getDefaultIPv6Interface(struct in6_addr *target_addr); diff --git a/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c b/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c index 9159d3bc38d..ef512a1a1f9 100644 --- a/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c +++ b/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c @@ -181,11 +181,11 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, */ senderAddr = (*env)->GetObjectField(env, this, dci_senderAddrID); if (senderAddr != NULL) { - if (!NET_SockaddrEqualsInetAddress(env, &sa.sa, senderAddr)) { + if (!NET_SockaddrEqualsInetAddress(env, &sa, senderAddr)) { senderAddr = NULL; } else { jint port = (*env)->GetIntField(env, this, dci_senderPortID); - if (port != NET_GetPortFromSockaddr(&sa.sa)) { + if (port != NET_GetPortFromSockaddr(&sa)) { senderAddr = NULL; } } @@ -193,7 +193,7 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, if (senderAddr == NULL) { jobject isa = NULL; int port = 0; - jobject ia = NET_SockaddrToInetAddress(env, &sa.sa, &port); + jobject ia = NET_SockaddrToInetAddress(env, &sa, &port); if (ia != NULL) { isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port); } @@ -201,7 +201,7 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, (*env)->SetObjectField(env, this, dci_senderAddrID, ia); (*env)->SetIntField(env, this, dci_senderPortID, - NET_GetPortFromSockaddr(&sa.sa)); + NET_GetPortFromSockaddr(&sa)); (*env)->SetObjectField(env, this, dci_senderID, isa); } return n; @@ -215,14 +215,14 @@ Java_sun_nio_ch_DatagramChannelImpl_send0(JNIEnv *env, jobject this, jint fd = fdval(env, fdo); void *buf = (void *)jlong_to_ptr(address); SOCKETADDRESS sa; - int sa_len = sizeof(SOCKETADDRESS); + int sa_len = 0; jint n = 0; if (len > MAX_PACKET_LEN) { len = MAX_PACKET_LEN; } - if (NET_InetAddressToSockaddr(env, destAddress, destPort, &sa.sa, + if (NET_InetAddressToSockaddr(env, destAddress, destPort, &sa, &sa_len, preferIPv6) != 0) { return IOS_THROWN; } diff --git a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c index 72eae0d606e..37ed11a8937 100644 --- a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c +++ b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c @@ -64,7 +64,7 @@ Java_sun_nio_ch_InheritedChannel_peerAddress0(JNIEnv *env, jclass cla, jint fd) if (getpeername(fd, &sa.sa, &len) == 0) { if (matchFamily(&sa.sa)) { - remote_ia = NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port); + remote_ia = NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port); } } @@ -81,7 +81,7 @@ Java_sun_nio_ch_InheritedChannel_peerPort0(JNIEnv *env, jclass cla, jint fd) if (getpeername(fd, &sa.sa, &len) == 0) { if (matchFamily(&sa.sa)) { - NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port); + NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port); } } diff --git a/jdk/src/java.base/unix/native/libnio/ch/Net.c b/jdk/src/java.base/unix/native/libnio/ch/Net.c index 33d08fbd808..dd9aedccdfa 100644 --- a/jdk/src/java.base/unix/native/libnio/ch/Net.c +++ b/jdk/src/java.base/unix/native/libnio/ch/Net.c @@ -274,15 +274,15 @@ Java_sun_nio_ch_Net_bind0(JNIEnv *env, jclass clazz, jobject fdo, jboolean prefe jboolean useExclBind, jobject iao, int port) { SOCKETADDRESS sa; - int sa_len = sizeof(SOCKETADDRESS); + int sa_len = 0; int rv = 0; - if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa, &sa_len, + if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, preferIPv6) != 0) { return; } - rv = NET_Bind(fdval(env, fdo), &sa.sa, sa_len); + rv = NET_Bind(fdval(env, fdo), &sa, sa_len); if (rv != 0) { handleSocketError(env, errno); } @@ -300,10 +300,10 @@ Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6, jobject fdo, jobject iao, jint port) { SOCKETADDRESS sa; - int sa_len = sizeof(SOCKETADDRESS); + int sa_len = 0; int rv; - if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa, &sa_len, + if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, preferIPv6) != 0) { return IOS_THROWN; } @@ -349,7 +349,7 @@ Java_sun_nio_ch_Net_localPort(JNIEnv *env, jclass clazz, jobject fdo) return -1; #endif /* _ALLBSD_SOURCE */ } - return NET_GetPortFromSockaddr(&sa.sa); + return NET_GetPortFromSockaddr(&sa); } JNIEXPORT jobject JNICALL @@ -382,7 +382,7 @@ Java_sun_nio_ch_Net_localInetAddress(JNIEnv *env, jclass clazz, jobject fdo) return NULL; #endif /* _ALLBSD_SOURCE */ } - return NET_SockaddrToInetAddress(env, &sa.sa, &port); + return NET_SockaddrToInetAddress(env, &sa, &port); } JNIEXPORT jint JNICALL diff --git a/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c b/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c index 915b70c0c59..f9f6e8f3cc8 100644 --- a/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c +++ b/jdk/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c @@ -112,7 +112,7 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this, } (*env)->SetIntField(env, newfdo, fd_fdID, newfd); - remote_ia = NET_SockaddrToInetAddress(env, &sa.sa, (int *)&remote_port); + remote_ia = NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port); CHECK_NULL_RETURN(remote_ia, IOS_THROWN); isa = (*env)->NewObject(env, isa_class, isa_ctorID, remote_ia, remote_port); CHECK_NULL_RETURN(isa, IOS_THROWN); diff --git a/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c index d834ef9bf11..90f3c1f7318 100644 --- a/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c @@ -53,7 +53,7 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jint fd) break; } if (recvfrom(fd, buf, 1, MSG_PEEK, - (struct sockaddr *)&rmtaddr, &addrlen) != SOCKET_ERROR) { + &rmtaddr.sa, &addrlen) != SOCKET_ERROR) { break; } if (WSAGetLastError() != WSAECONNRESET) { @@ -61,7 +61,7 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jint fd) break; } - recvfrom(fd, buf, 1, 0, (struct sockaddr *)&rmtaddr, &addrlen); + recvfrom(fd, buf, 1, 0, &rmtaddr.sa, &addrlen); got_icmp = JNI_TRUE; } @@ -134,14 +134,13 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketCrea JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketBind (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port, jboolean exclBind) { SOCKETADDRESS sa; - int rv; - int sa_len = sizeof(sa); + int rv, sa_len = 0; - if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa, + if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, &sa_len, JNI_TRUE) != 0) { return; } - rv = NET_WinBind(fd, (struct sockaddr *)&sa, sa_len, exclBind); + rv = NET_WinBind(fd, &sa, sa_len, exclBind); if (rv == SOCKET_ERROR) { if (WSAGetLastError() == WSAEACCES) { @@ -159,17 +158,15 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketBind JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketConnect (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port) { SOCKETADDRESS sa; - int rv; - int sa_len = sizeof(sa); + int rv, sa_len = 0, t = TRUE; DWORD x1, x2; /* ignored result codes */ - int t = TRUE; - if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa, + if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, &sa_len, JNI_TRUE) != 0) { return; } - rv = connect(fd, (struct sockaddr *)&sa, sa_len); + rv = connect(fd, &sa.sa, sa_len); if (rv == SOCKET_ERROR) { NET_ThrowNew(env, WSAGetLastError(), "connect"); return; @@ -192,7 +189,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketDisc int t = FALSE; memset(&sa, 0, sa_len); - connect(fd, (struct sockaddr *)&sa, sa_len); + connect(fd, &sa.sa, sa_len); /* see comment in socketCreate */ WSAIoctl(fd, SIO_UDP_CONNRESET, &t, sizeof(t), &x1, sizeof(x1), &x2, 0, 0); @@ -219,7 +216,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketLoca SOCKETADDRESS sa; int len = sizeof(sa); - if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) { + if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) { NET_ThrowNew(env, WSAGetLastError(), "getsockname"); return -1; } @@ -238,12 +235,12 @@ JNIEXPORT jobject JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketL jobject iaObj; int port; - if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) { + if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) { NET_ThrowNew(env, WSAGetLastError(), "Error getting socket name"); return NULL; } - iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); + iaObj = NET_SockaddrToInetAddress(env, &sa, &port); return iaObj; } @@ -316,7 +313,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketRece /* receive the packet */ rv = recvfrom(fd, fullPacket, packetBufferLen, flags, - (struct sockaddr *)&sa, &sa_len); + &sa.sa, &sa_len); if (rv == SOCKET_ERROR && (WSAGetLastError() == WSAECONNRESET)) { /* An icmp port unreachable - we must receive this as Windows @@ -383,15 +380,13 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketRece */ packetAddress = (*env)->GetObjectField(env, dpObj, dp_addressID); if (packetAddress != NULL) { - if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&sa, - packetAddress)) { + if (!NET_SockaddrEqualsInetAddress(env, &sa, packetAddress)) { /* force a new InetAddress to be created */ packetAddress = NULL; } } if (packetAddress == NULL) { - packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, - &port); + packetAddress = NET_SockaddrToInetAddress(env, &sa, &port); if (packetAddress != NULL) { /* stuff the new Inetaddress into the packet */ (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress); @@ -422,20 +417,18 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSend (JNIEnv *env, jclass clazz, jint fd, jbyteArray data, jint offset, jint length, jobject iaObj, jint port, jboolean connected) { SOCKETADDRESS sa; - int sa_len = sizeof(sa); - SOCKETADDRESS *sap = &sa; + int rv, sa_len = 0; + struct sockaddr *sap = 0; char BUF[MAX_BUFFER_LEN]; char *fullPacket; - int rv; - if (connected) { - sap = 0; /* arg to sendto () null in this case */ - sa_len = 0; - } else { - if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa, - &sa_len, JNI_TRUE) != 0) { + // if already connected, sap arg to sendto() is null + if (!connected) { + if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, + &sa_len, JNI_TRUE) != 0) { return; } + sap = &sa.sa; } if (length > MAX_BUFFER_LEN) { @@ -456,7 +449,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSend (*env)->GetByteArrayRegion(env, data, offset, length, (jbyte *)fullPacket); - rv = sendto(fd, fullPacket, length, 0, (struct sockaddr *)sap, sa_len); + rv = sendto(fd, fullPacket, length, 0, sap, sa_len); if (rv == SOCKET_ERROR) { if (rv == -1) { NET_ThrowNew(env, WSAGetLastError(), "Datagram send failed"); diff --git a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c index 39178408823..f5a310148ae 100644 --- a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c @@ -89,15 +89,14 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_bind0 jboolean exclBind) { SOCKETADDRESS sa; - int rv; - int sa_len = sizeof(sa); + int rv, sa_len = 0; - if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa, - &sa_len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, + &sa_len, JNI_TRUE) != 0) { return; } - rv = NET_WinBind(fd, (struct sockaddr *)&sa, sa_len, exclBind); + rv = NET_WinBind(fd, &sa, sa_len, exclBind); if (rv == SOCKET_ERROR) NET_ThrowNew(env, WSAGetLastError(), "NET_Bind"); @@ -111,15 +110,14 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_bind0 JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_connect0 (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port) { SOCKETADDRESS sa; - int rv; - int sa_len = sizeof(sa); + int rv, sa_len = 0; - if (NET_InetAddressToSockaddr(env, iaObj, port, (struct sockaddr *)&sa, - &sa_len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, + &sa_len, JNI_TRUE) != 0) { return -1; } - rv = connect(fd, (struct sockaddr *)&sa, sa_len); + rv = connect(fd, &sa.sa, sa_len); if (rv == SOCKET_ERROR) { int err = WSAGetLastError(); if (err == WSAEWOULDBLOCK) { @@ -217,7 +215,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_localPort0 SOCKETADDRESS sa; int len = sizeof(sa); - if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) { + if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) { if (WSAGetLastError() == WSAENOTSOCK) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); @@ -243,11 +241,11 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_localAddress jclass iaContainerClass; jfieldID iaFieldID; - if (getsockname(fd, (struct sockaddr *)&sa, &len) == SOCKET_ERROR) { + if (getsockname(fd, &sa.sa, &len) == SOCKET_ERROR) { NET_ThrowNew(env, WSAGetLastError(), "Error getting socket name"); return; } - iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); + iaObj = NET_SockaddrToInetAddress(env, &sa, &port); CHECK_NULL(iaObj); iaContainerClass = (*env)->GetObjectClass(env, iaContainerObj); @@ -283,7 +281,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_accept0 int len = sizeof(sa); memset((char *)&sa, 0, len); - newfd = accept(fd, (struct sockaddr *)&sa, &len); + newfd = accept(fd, &sa.sa, &len); if (newfd == INVALID_SOCKET) { if (WSAGetLastError() == -2) { @@ -298,7 +296,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_accept0 SetHandleInformation((HANDLE)(UINT_PTR)newfd, HANDLE_FLAG_INHERIT, 0); - ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); + ia = NET_SockaddrToInetAddress(env, &sa, &port); isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port); (*env)->SetObjectArrayElement(env, isaa, 0, isa); diff --git a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c index d382267742c..46cc779d402 100644 --- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c @@ -420,18 +420,13 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, jboolean exclBind) { jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID); - - int fd, fd1 = -1, family; int ipv6_supported = ipv6_available(); - + int fd, fd1 = -1, lcladdrlen = 0; SOCKETADDRESS lcladdr; - int lcladdrlen = sizeof(SOCKETADDRESS); - int address; - memset((char *)&lcladdr, 0, sizeof(lcladdr)); - - family = getInetAddress_family(env, addressObj); - if (family == java_net_InetAddress_IPv6 && !ipv6_supported) { + if (getInetAddress_family(env, addressObj) == java_net_InetAddress_IPv6 && + !ipv6_supported) + { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family not supported"); return; @@ -446,14 +441,13 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, fd1 = (*env)->GetIntField(env, fd1Obj, IO_fd_fdID); } } + if (IS_NULL(addressObj)) { JNU_ThrowNullPointerException(env, "argument address"); return; - } else { - address = getInetAddress_addr(env, addressObj); } - if (NET_InetAddressToSockaddr(env, addressObj, port, &lcladdr.sa, + if (NET_InetAddressToSockaddr(env, addressObj, port, &lcladdr, &lcladdrlen, JNI_FALSE) != 0) { return; } @@ -493,7 +487,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, return; } } else { - if (NET_WinBind(fd, &lcladdr.sa, lcladdrlen, exclBind) == -1) { + if (NET_WinBind(fd, &lcladdr, lcladdrlen, exclBind) == -1) { if (WSAGetLastError() == WSAEACCES) { WSASetLastError(WSAEADDRINUSE); } @@ -507,7 +501,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, NET_ThrowCurrent(env, "getsockname"); return; } - port = ntohs((u_short) GET_PORT (&lcladdr)); + port = ntohs((u_short)GET_PORT(&lcladdr)); } (*env)->SetIntField(env, this, pdsi_localPortID, port); } @@ -520,27 +514,25 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, */ JNIEXPORT void JNICALL -Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0(JNIEnv *env, jobject this, - jobject address, jint port) { - /* The object's field */ +Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0 + (JNIEnv *env, jobject this, jobject address, jint port) +{ jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID); - /* The fdObj'fd */ - jint fd=-1, fd1=-1, fdc; - /* The packetAddress address, family and port */ - jint addr, family; + jint fd = -1, fd1 = -1, fdc, family; SOCKETADDRESS rmtaddr; - int rmtaddrlen; - int ipv6_supported = ipv6_available(); + int rmtaddrlen = 0; if (IS_NULL(fdObj) && IS_NULL(fd1Obj)) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); return; } + if (!IS_NULL(fdObj)) { fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); } + if (!IS_NULL(fd1Obj)) { fd1 = (*env)->GetIntField(env, fd1Obj, IO_fd_fdID); } @@ -550,10 +542,8 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0(JNIEnv *env, jobject thi return; } - addr = getInetAddress_addr(env, address); - family = getInetAddress_family(env, address); - if (family == java_net_InetAddress_IPv6 && !ipv6_supported) { + if (family == java_net_InetAddress_IPv6 && !ipv6_available()) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family not supported"); return; @@ -572,12 +562,12 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0(JNIEnv *env, jobject thi res = WSAIoctl(fdc,SIO_UDP_CONNRESET,&t,sizeof(t),&x1,sizeof(x1),&x2,0,0); } - if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr.sa, + if (NET_InetAddressToSockaddr(env, address, port, &rmtaddr, &rmtaddrlen, JNI_FALSE) != 0) { return; } - if (connect(fdc, &rmtaddr.sa, sizeof(rmtaddr)) == -1) { + if (connect(fdc, &rmtaddr.sa, rmtaddrlen) == -1) { NET_ThrowCurrent(env, "connect"); return; } @@ -631,9 +621,9 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject * Signature: (Ljava/net/DatagramPacket;)V */ JNIEXPORT void JNICALL -Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this, - jobject packet) { - +Java_java_net_TwoStacksPlainDatagramSocketImpl_send + (JNIEnv *env, jobject this, jobject packet) +{ char BUF[MAX_BUFFER_LEN]; char *fullPacket; jobject fdObj; @@ -647,11 +637,10 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this, jbyteArray packetBuffer; jboolean connected; - SOCKETADDRESS rmtaddr, *addrp = &rmtaddr; + SOCKETADDRESS rmtaddr; + struct sockaddr *addrp = 0; int addrlen = 0; - memset((char *)&rmtaddr, 0, sizeof(rmtaddr)); - if (IS_NULL(packet)) { JNU_ThrowNullPointerException(env, "null packet"); return; @@ -696,14 +685,13 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this, packetBufferLen = MAX_PACKET_LEN; } - if (connected) { - addrp = 0; /* arg to sendto () null in this case */ - addrlen = 0; - } else { - if (NET_InetAddressToSockaddr(env, iaObj, packetPort, &rmtaddr.sa, + // sockaddr arg to sendto() is null if already connected + if (!connected) { + if (NET_InetAddressToSockaddr(env, iaObj, packetPort, &rmtaddr, &addrlen, JNI_FALSE) != 0) { return; } + addrp = &rmtaddr.sa; } if (packetBufferLen > MAX_BUFFER_LEN) { @@ -753,11 +741,12 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this, fullPacket = &(BUF[0]); } - (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, packetBufferLen, - (jbyte *)fullPacket); - if (sendto(fd, fullPacket, packetBufferLen, 0, - (struct sockaddr *)addrp, addrlen) == SOCKET_ERROR) { - NET_ThrowCurrent(env, "Datagram send failed"); + (*env)->GetByteArrayRegion(env, packetBuffer, packetBufferOffset, + packetBufferLen, (jbyte *)fullPacket); + if (sendto(fd, fullPacket, packetBufferLen, 0, addrp, + addrlen) == SOCKET_ERROR) + { + NET_ThrowCurrent(env, "Datagram send failed"); } if (packetBufferLen > MAX_BUFFER_LEN) { @@ -1147,14 +1136,14 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi */ packetAddress = (*env)->GetObjectField(env, packet, dp_addressID); if (packetAddress != NULL) { - if (!NET_SockaddrEqualsInetAddress(env, &remote_addr.sa, + if (!NET_SockaddrEqualsInetAddress(env, &remote_addr, packetAddress)) { /* force a new InetAddress to be created */ packetAddress = NULL; } } if (packetAddress == NULL) { - packetAddress = NET_SockaddrToInetAddress(env, &remote_addr.sa, + packetAddress = NET_SockaddrToInetAddress(env, &remote_addr, &port); /* stuff the new Inetaddress in the packet */ (*env)->SetObjectField(env, packet, dp_addressID, packetAddress); @@ -1431,20 +1420,21 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi * can't update any existing InetAddress because it is immutable */ packetAddress = (*env)->GetObjectField(env, packet, dp_addressID); - if (packetAddress != NULL) { - if (!NET_SockaddrEqualsInetAddress(env, &remote_addr.sa, packetAddress)) { + if (!NET_SockaddrEqualsInetAddress(env, &remote_addr, + packetAddress)) { /* force a new InetAddress to be created */ packetAddress = NULL; } } if (packetAddress == NULL) { - packetAddress = NET_SockaddrToInetAddress(env, &remote_addr.sa, &port); + packetAddress = NET_SockaddrToInetAddress(env, &remote_addr, + &port); /* stuff the new Inetaddress in the packet */ (*env)->SetObjectField(env, packet, dp_addressID, packetAddress); } else { /* only get the new port number */ - port = NET_GetPortFromSockaddr(&remote_addr.sa); + port = NET_GetPortFromSockaddr(&remote_addr); } /* populate the packet */ (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n, @@ -1528,7 +1518,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_datagramSocketClose(JNIEnv *env, jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID); int ipv6_supported = ipv6_available(); - int fd=-1, fd1=-1; + int fd = -1, fd1 = -1; if (IS_NULL(fdObj) && (!ipv6_supported || IS_NULL(fd1Obj))) { return; @@ -1799,7 +1789,7 @@ JNIEXPORT void JNICALL Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption (JNIEnv *env,jobject this, jint opt,jobject value) { - int fd=-1, fd1=-1; + int fd = -1, fd1 = -1; int levelv4 = 0, levelv6 = 0, optnamev4 = 0, optnamev6 = 0, optlen = 0; union { int i; @@ -2167,7 +2157,7 @@ JNIEXPORT jobject JNICALL Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption (JNIEnv *env, jobject this, jint opt) { - int fd=-1, fd1=-1; + int fd = -1, fd1 = -1; int level, optname, optlen; union { int i; @@ -2255,7 +2245,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress (JNIEnv *env, jobject this, jint family) { int fd = -1, fd1 = -1; - SOCKETADDRESS him; + SOCKETADDRESS sa; int len = 0; int port; jobject iaObj; @@ -2288,12 +2278,12 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress return NULL; } - if (getsockname(fd, &him.sa, &len) == -1) { + if (getsockname(fd, &sa.sa, &len) == -1) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error getting socket name"); return NULL; } - iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port); + iaObj = NET_SockaddrToInetAddress(env, &sa, &port); return iaObj; } @@ -2430,7 +2420,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this, int len, family; int ipv6_supported = ipv6_available(); - int cmd ; + int cmd; memset((char *)&in, 0, sizeof(in)); memset((char *)&name, 0, sizeof(name)); @@ -2452,7 +2442,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this, return; } - if (NET_InetAddressToSockaddr(env, iaObj, 0, &name.sa, &len, JNI_FALSE) != 0) { + if (NET_InetAddressToSockaddr(env, iaObj, 0, &name, &len, JNI_FALSE) != 0) { return; } @@ -2473,7 +2463,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this, return; } if (IS_NULL(niObj)) { - len = sizeof (in); + len = sizeof(in); if (NET_GetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_IF, (char *)&in, &len) < 0) { NET_ThrowCurrent(env, "get IP_MULTICAST_IF failed"); diff --git a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c index f8f1063c904..0df5be632dd 100644 --- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c @@ -175,8 +175,8 @@ Java_java_net_TwoStacksPlainSocketImpl_socketCreate(JNIEnv *env, jobject this, */ JNIEXPORT void JNICALL Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this, - jobject iaObj, jint port, - jint timeout) + jobject iaObj, jint port, + jint timeout) { jint localport = (*env)->GetIntField(env, this, psi_localportID); @@ -193,11 +193,11 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this, jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID); jobject fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID); - SOCKETADDRESS him; + SOCKETADDRESS sa; /* The result of the connection */ int connect_res; - memset((char *)&him, 0, sizeof(him)); + memset((char *)&sa, 0, sizeof(sa)); if (!IS_NULL(fdObj)) { fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); @@ -212,11 +212,12 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this, return; } - if (NET_InetAddressToSockaddr(env, iaObj, port, &him.sa, &len, JNI_FALSE) != 0) { - return; + if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, &len, + JNI_FALSE) != 0) { + return; } - family = him.sa.sa_family; + family = sa.sa.sa_family; if (family == AF_INET6) { if (!ipv6_supported) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", @@ -248,7 +249,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this, (*env)->SetObjectField(env, this, psi_fd1ID, NULL); if (timeout <= 0) { - connect_res = connect(fd, &him.sa, sizeof(SOCKETADDRESS)); + connect_res = connect(fd, &sa.sa, sizeof(SOCKETADDRESS)); if (connect_res == SOCKET_ERROR) { connect_res = WSAGetLastError(); } @@ -261,7 +262,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this, ioctlsocket(fd, FIONBIO, &optval); /* initiate the connect */ - connect_res = connect(fd, &him.sa, sizeof(SOCKETADDRESS)); + connect_res = connect(fd, &sa.sa, sizeof(SOCKETADDRESS)); if (connect_res == SOCKET_ERROR) { if (WSAGetLastError() != WSAEWOULDBLOCK) { connect_res = WSAGetLastError(); @@ -362,7 +363,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this, */ u_short port; int len = sizeof(SOCKETADDRESS); - if (getsockname(fd, &him.sa, &len) == -1) { + if (getsockname(fd, &sa.sa, &len) == -1) { if (WSAGetLastError() == WSAENOTSOCK) { JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); @@ -371,7 +372,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this, } return; } - port = ntohs((u_short)GET_PORT(&him)); + port = ntohs((u_short)GET_PORT(&sa)); (*env)->SetIntField(env, this, psi_localportID, (int) port); } } @@ -396,7 +397,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this, int family; int rv; - SOCKETADDRESS him; + SOCKETADDRESS sa; fdObj = (*env)->GetObjectField(env, this, psi_fdID); fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID); @@ -424,13 +425,13 @@ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this, return; } - if (NET_InetAddressToSockaddr(env, iaObj, localport, &him.sa, &len, + if (NET_InetAddressToSockaddr(env, iaObj, localport, &sa, &len, JNI_FALSE) != 0) { return; } if (ipv6_supported) { struct ipv6bind v6bind; - v6bind.addr = &him; + v6bind.addr = &sa.sa; v6bind.ipv4_fd = fd; v6bind.ipv6_fd = fd1; rv = NET_BindV6(&v6bind, exclBind); @@ -462,7 +463,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this, (*env)->SetObjectField(env, this, psi_fd1ID, NULL); } } else { - rv = NET_WinBind(fd, &him.sa, len, exclBind); + rv = NET_WinBind(fd, &sa, len, exclBind); } if (rv == -1) { @@ -481,11 +482,11 @@ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this, int len = sizeof(SOCKETADDRESS); u_short port; - if (getsockname(him.sa.sa_family == AF_INET ? fd: fd1, &him.sa, &len) == -1) { + if (getsockname(sa.sa.sa_family == AF_INET ? fd : fd1, &sa.sa, &len) == -1) { NET_ThrowCurrent(env, "getsockname in plain socketBind"); return; } - port = ntohs((u_short) GET_PORT (&him)); + port = ntohs((u_short) GET_PORT (&sa)); (*env)->SetIntField(env, this, psi_localportID, (int)port); } else { @@ -529,7 +530,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketListen JNU_ThrowNullPointerException(env, "socket address"); return; } - if (NET_InetAddressToSockaddr(env, address, 0, &addr.sa, &addrlen, + if (NET_InetAddressToSockaddr(env, address, 0, &addr, &addrlen, JNI_FALSE) != 0) { return; } @@ -585,7 +586,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this, /* the fd int field on fdObj */ jint fd=-1, fd1=-1; - SOCKETADDRESS him; + SOCKETADDRESS sa; jint len; if (IS_NULL(fdObj) && IS_NULL(fd1Obj)) { @@ -676,7 +677,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this, } } } - fd = accept(fd, &him.sa, &len); + fd = accept(fd, &sa.sa, &len); if (fd < 0) { /* REMIND: SOCKET CLOSED PROBLEM */ if (fd == -2) { @@ -691,7 +692,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this, SetHandleInformation((HANDLE)(UINT_PTR)fd, HANDLE_FLAG_INHERIT, 0); (*env)->SetIntField(env, socketFdObj, IO_fd_fdID, fd); - if (him.sa.sa_family == AF_INET) { + if (sa.sa.sa_family == AF_INET) { if (inet4Cls == NULL) { jclass c = (*env)->FindClass(env, "java/net/Inet4Address"); if (c != NULL) { @@ -717,7 +718,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this, return; } - setInetAddress_addr(env, socketAddressObj, ntohl(him.sa4.sin_addr.s_addr)); + setInetAddress_addr(env, socketAddressObj, ntohl(sa.sa4.sin_addr.s_addr)); setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv4); (*env)->SetObjectField(env, socket, psi_addressID, socketAddressObj); } else { @@ -743,14 +744,14 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this, NET_SocketClose(fd); return; } - setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.sa6.sin6_addr); + setInet6Address_ipaddress(env, socketAddressObj, (char *)&sa.sa6.sin6_addr); setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv6); - setInet6Address_scopeid(env, socketAddressObj, him.sa6.sin6_scope_id); + setInet6Address_scopeid(env, socketAddressObj, sa.sa6.sin6_scope_id); } /* fields common to AF_INET and AF_INET6 */ - port = ntohs ((u_short) GET_PORT (&him)); + port = ntohs ((u_short)GET_PORT(&sa)); (*env)->SetIntField(env, socket, psi_portID, (int)port); port = (*env)->GetIntField(env, this, psi_localportID); (*env)->SetIntField(env, socket, psi_localportID, port); @@ -1025,14 +1026,14 @@ Java_java_net_TwoStacksPlainSocketImpl_socketGetOption * SO_BINDADDR isn't a socket option */ if (opt == java_net_SocketOptions_SO_BINDADDR) { - SOCKETADDRESS him; + SOCKETADDRESS sa; int len = sizeof(SOCKETADDRESS); int port; jobject iaObj; jclass iaCntrClass; jfieldID iaFieldID; - memset((char *)&him, 0, len); + memset((char *)&sa, 0, len); if (fd == -1) { /* must be an IPV6 only socket. Case where both sockets are != -1 @@ -1041,12 +1042,12 @@ Java_java_net_TwoStacksPlainSocketImpl_socketGetOption fd = getFD1 (env, this); } - if (getsockname(fd, &him.sa, &len) < 0) { + if (getsockname(fd, &sa.sa, &len) < 0) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Error getting socket name"); return -1; } - iaObj = NET_SockaddrToInetAddress(env, &him.sa, &port); + iaObj = NET_SockaddrToInetAddress(env, &sa, &port); CHECK_NULL_RETURN(iaObj, -1); iaCntrClass = (*env)->GetObjectClass(env, iaContainerObj); diff --git a/jdk/src/java.base/windows/native/libnet/net_util_md.c b/jdk/src/java.base/windows/native/libnet/net_util_md.c index e0bd5681e33..e9ad96f37ac 100644 --- a/jdk/src/java.base/windows/native/libnet/net_util_md.c +++ b/jdk/src/java.base/windows/native/libnet/net_util_md.c @@ -488,10 +488,10 @@ void setExclusiveBind(int fd) { * Should be only called by the wrapper method NET_WinBind */ JNIEXPORT int JNICALL -NET_Bind(int s, struct sockaddr *him, int len) +NET_Bind(int s, SOCKETADDRESS *sa, int len) { int rv = 0; - rv = bind(s, him, len); + rv = bind(s, &sa->sa, len); if (rv == SOCKET_ERROR) { /* @@ -511,11 +511,11 @@ NET_Bind(int s, struct sockaddr *him, int len) * if required, and then calls NET_BIND */ JNIEXPORT int JNICALL -NET_WinBind(int s, struct sockaddr *him, int len, jboolean exclBind) +NET_WinBind(int s, SOCKETADDRESS *sa, int len, jboolean exclBind) { if (exclBind == JNI_TRUE) setExclusiveBind(s); - return NET_Bind(s, him, len); + return NET_Bind(s, sa, len); } JNIEXPORT int JNICALL @@ -677,8 +677,8 @@ NET_BindV6(struct ipv6bind *b, jboolean exclBind) { if (family == AF_INET && (b->addr->sa4.sin_addr.s_addr != INADDR_ANY)) { /* bind to v4 only */ int ret; - ret = NET_WinBind((int)b->ipv4_fd, (struct sockaddr *)b->addr, - sizeof(SOCKETADDRESS), exclBind); + ret = NET_WinBind((int)b->ipv4_fd, b->addr, + sizeof(SOCKETADDRESS), exclBind); if (ret == SOCKET_ERROR) { CLOSE_SOCKETS_AND_RETURN; } @@ -689,7 +689,7 @@ NET_BindV6(struct ipv6bind *b, jboolean exclBind) { if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->sa6.sin6_addr))) { /* bind to v6 only */ int ret; - ret = NET_WinBind((int)b->ipv6_fd, (struct sockaddr *)b->addr, + ret = NET_WinBind((int)b->ipv6_fd, b->addr, sizeof(SOCKETADDRESS), exclBind); if (ret == SOCKET_ERROR) { CLOSE_SOCKETS_AND_RETURN; @@ -719,7 +719,7 @@ NET_BindV6(struct ipv6bind *b, jboolean exclBind) { oaddr.sa4.sin_addr.s_addr = INADDR_ANY; } - rv = NET_WinBind(fd, (struct sockaddr *)b->addr, sizeof(SOCKETADDRESS), exclBind); + rv = NET_WinBind(fd, b->addr, sizeof(SOCKETADDRESS), exclBind); if (rv == SOCKET_ERROR) { CLOSE_SOCKETS_AND_RETURN; } @@ -731,7 +731,7 @@ NET_BindV6(struct ipv6bind *b, jboolean exclBind) { } bound_port = GET_PORT (b->addr); SET_PORT (&oaddr, bound_port); - if ((rv = NET_WinBind(ofd, &oaddr.sa, + if ((rv = NET_WinBind(ofd, &oaddr, sizeof(SOCKETADDRESS), exclBind)) == SOCKET_ERROR) { int retries; int sotype, arglen=sizeof(sotype); @@ -768,7 +768,7 @@ NET_BindV6(struct ipv6bind *b, jboolean exclBind) { /* bind random port on first socket */ SET_PORT (&oaddr, 0); - rv = NET_WinBind(ofd, &oaddr.sa, sizeof(SOCKETADDRESS), exclBind); + rv = NET_WinBind(ofd, &oaddr, sizeof(SOCKETADDRESS), exclBind); if (rv == SOCKET_ERROR) { CLOSE_SOCKETS_AND_RETURN; } @@ -784,8 +784,7 @@ NET_BindV6(struct ipv6bind *b, jboolean exclBind) { } bound_port = GET_PORT (&oaddr); SET_PORT (b->addr, bound_port); - rv = NET_WinBind(fd, (struct sockaddr *)b->addr, - sizeof(SOCKETADDRESS), exclBind); + rv = NET_WinBind(fd, b->addr, sizeof(SOCKETADDRESS), exclBind); if (rv != SOCKET_ERROR) { if (family == AF_INET) { @@ -853,31 +852,33 @@ NET_EnableFastTcpLoopback(int fd) { return result == SOCKET_ERROR ? WSAGetLastError() : 0; } -/* If address types is IPv6, then IPv6 must be available. Otherwise - * no address can be generated. In the case of an IPv4 Inetaddress this - * method will return an IPv4 mapped address where IPv6 is available and - * v4MappedAddress is TRUE. Otherwise it will return a sockaddr_in - * structure for an IPv4 InetAddress. -*/ +/** + * See net_util.h for documentation + */ JNIEXPORT int JNICALL -NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him, - int *len, jboolean v4MappedAddress) { - jint family, iafam; - iafam = getInetAddress_family(env, iaObj); - family = (iafam == java_net_InetAddress_IPv4)? AF_INET : AF_INET6; - if (ipv6_available() && !(family == AF_INET && v4MappedAddress == JNI_FALSE)) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - jbyte caddr[16]; - jint address, scopeid = 0; - jint cached_scope_id = 0; +NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, + SOCKETADDRESS *sa, int *len, + jboolean v4MappedAddress) +{ + jint family = getInetAddress_family(env, iaObj); + memset((char *)sa, 0, sizeof(SOCKETADDRESS)); - if (family == AF_INET) { /* will convert to IPv4-mapped address */ - memset((char *) caddr, 0, 16); + if (ipv6_available() && + !(family == java_net_InetAddress_IPv4 && + v4MappedAddress == JNI_FALSE)) + { + jbyte caddr[16]; + jint address; + unsigned int scopeid = 0, cached_scope_id = 0; + + if (family == java_net_InetAddress_IPv4) { + // convert to IPv4-mapped address + memset((char *)caddr, 0, 16); address = getInetAddress_addr(env, iaObj); if (address == INADDR_ANY) { /* we would always prefer IPv6 wildcard address - caddr[10] = 0xff; - caddr[11] = 0xff; */ + * caddr[10] = 0xff; + * caddr[11] = 0xff; */ } else { caddr[10] = 0xff; caddr[11] = 0xff; @@ -889,46 +890,39 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr } else { getInet6Address_ipaddress(env, iaObj, (char *)caddr); scopeid = getInet6Address_scopeid(env, iaObj); - cached_scope_id = (jint)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID); + cached_scope_id = (unsigned int)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID); } - - memset((char *)him6, 0, sizeof(struct sockaddr_in6)); - him6->sin6_port = (u_short) htons((u_short)port); - memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) ); - him6->sin6_family = AF_INET6; - if ((family == AF_INET6) && IN6_IS_ADDR_LINKLOCAL( &(him6->sin6_addr) ) - && (!scopeid && !cached_scope_id)) { - cached_scope_id = getDefaultIPv6Interface(env, him6); + sa->sa6.sin6_port = (u_short)htons((u_short)port); + memcpy((void *)&sa->sa6.sin6_addr, caddr, sizeof(struct in6_addr)); + sa->sa6.sin6_family = AF_INET6; + if ((family == java_net_InetAddress_IPv6) && + IN6_IS_ADDR_LINKLOCAL(&sa->sa6.sin6_addr) && + (!scopeid && !cached_scope_id)) + { + cached_scope_id = getDefaultIPv6Interface(env, &sa->sa6); (*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id); } - him6->sin6_scope_id = scopeid != 0 ? scopeid : cached_scope_id; - *len = sizeof(struct sockaddr_in6) ; - } else { - struct sockaddr_in *him4 = (struct sockaddr_in *)him; - jint address; - if (family != AF_INET) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable"); - return -1; + sa->sa6.sin6_scope_id = scopeid == 0 ? cached_scope_id : scopeid; + if (len != NULL) { + *len = sizeof(struct sockaddr_in6); + } + } else { + jint address; + if (family != java_net_InetAddress_IPv4) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable"); + return -1; } - memset((char *)him4, 0, sizeof(struct sockaddr_in)); address = getInetAddress_addr(env, iaObj); - him4->sin_port = htons((short) port); - him4->sin_addr.s_addr = (u_long) htonl(address); - him4->sin_family = AF_INET; - *len = sizeof(struct sockaddr_in); + sa->sa4.sin_port = htons((short)port); + sa->sa4.sin_addr.s_addr = (u_long)htonl(address); + sa->sa4.sin_family = AF_INET; + if (len != NULL) { + *len = sizeof(struct sockaddr_in); + } } return 0; } -JNIEXPORT jint JNICALL -NET_GetPortFromSockaddr(struct sockaddr *him) { - if (him->sa_family == AF_INET6) { - return ntohs(((struct sockaddr_in6 *)him)->sin6_port); - } else { - return ntohs(((struct sockaddr_in *)him)->sin_port); - } -} - int NET_IsIPv4Mapped(jbyte* caddr) { int i; @@ -961,16 +955,6 @@ NET_IsEqual(jbyte* caddr1, jbyte* caddr2) { return 1; } -int getScopeID(struct sockaddr *him) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - return him6->sin6_scope_id; -} - -int cmpScopeID(unsigned int scope, struct sockaddr *him) { - struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him; - return him6->sin6_scope_id == scope; -} - /** * Wrapper for select/poll with timeout on a single file descriptor. * diff --git a/jdk/src/java.base/windows/native/libnet/net_util_md.h b/jdk/src/java.base/windows/native/libnet/net_util_md.h index 96c122b33c5..26a9e38022a 100644 --- a/jdk/src/java.base/windows/native/libnet/net_util_md.h +++ b/jdk/src/java.base/windows/native/libnet/net_util_md.h @@ -121,7 +121,7 @@ JNIEXPORT int JNICALL NET_Timeout2(int fd, int fd1, long timeout, int *fdret); JNIEXPORT int JNICALL NET_BindV6(struct ipv6bind *b, jboolean exclBind); -JNIEXPORT int JNICALL NET_WinBind(int s, struct sockaddr *him, int len, +JNIEXPORT int JNICALL NET_WinBind(int s, SOCKETADDRESS *sa, int len, jboolean exclBind); /* XP versions of the native routines */ diff --git a/jdk/src/java.base/windows/native/libnio/ch/DatagramChannelImpl.c b/jdk/src/java.base/windows/native/libnio/ch/DatagramChannelImpl.c index ecc96a1d8bb..0355c88ff79 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/DatagramChannelImpl.c +++ b/jdk/src/java.base/windows/native/libnio/ch/DatagramChannelImpl.c @@ -96,7 +96,7 @@ jboolean purgeOutstandingICMP(JNIEnv *env, jclass clazz, jint fd) break; } if (recvfrom(fd, buf, 1, MSG_PEEK, - (struct sockaddr *)&sa, &addrlen) != SOCKET_ERROR) { + &sa.sa, &addrlen) != SOCKET_ERROR) { break; } if (WSAGetLastError() != WSAECONNRESET) { @@ -104,7 +104,7 @@ jboolean purgeOutstandingICMP(JNIEnv *env, jclass clazz, jint fd) break; } - recvfrom(fd, buf, 1, 0, (struct sockaddr *)&sa, &addrlen); + recvfrom(fd, buf, 1, 0, &sa.sa, &addrlen); got_icmp = JNI_TRUE; } @@ -122,7 +122,7 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jobject this, memset(&sa, 0, sa_len); - rv = connect((SOCKET)fd, (struct sockaddr *)&sa, sa_len); + rv = connect((SOCKET)fd, &sa.sa, sa_len); if (rv == SOCKET_ERROR) { handleSocketError(env, WSAGetLastError()); } else { @@ -153,7 +153,7 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, (char *)buf, len, 0, - (struct sockaddr *)&sa, + &sa.sa, &sa_len); if (n == SOCKET_ERROR) { @@ -182,12 +182,11 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, */ senderAddr = (*env)->GetObjectField(env, this, dci_senderAddrID); if (senderAddr != NULL) { - if (!NET_SockaddrEqualsInetAddress(env, (struct sockaddr *)&sa, - senderAddr)) { + if (!NET_SockaddrEqualsInetAddress(env, &sa, senderAddr)) { senderAddr = NULL; } else { jint port = (*env)->GetIntField(env, this, dci_senderPortID); - if (port != NET_GetPortFromSockaddr((struct sockaddr *)&sa)) { + if (port != NET_GetPortFromSockaddr(&sa)) { senderAddr = NULL; } } @@ -195,7 +194,7 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, if (senderAddr == NULL) { jobject isa = NULL; int port; - jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); + jobject ia = NET_SockaddrToInetAddress(env, &sa, &port); if (ia != NULL) { isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port); } @@ -204,7 +203,7 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, // update cachedSenderInetAddress/cachedSenderPort (*env)->SetObjectField(env, this, dci_senderAddrID, ia); (*env)->SetIntField(env, this, dci_senderPortID, - NET_GetPortFromSockaddr((struct sockaddr *)&sa)); + NET_GetPortFromSockaddr(&sa)); (*env)->SetObjectField(env, this, dci_senderID, isa); } return n; @@ -219,21 +218,15 @@ Java_sun_nio_ch_DatagramChannelImpl_send0(JNIEnv *env, jobject this, jint fd = fdval(env, fdo); void *buf = (void *)jlong_to_ptr(address); SOCKETADDRESS sa; - int sa_len; + int sa_len = 0; jint rv = 0; - if (NET_InetAddressToSockaddr(env, destAddress, destPort, - (struct sockaddr *)&sa, - &sa_len, preferIPv6) != 0) { + if (NET_InetAddressToSockaddr(env, destAddress, destPort, &sa, + &sa_len, preferIPv6) != 0) { return IOS_THROWN; } - rv = sendto((SOCKET)fd, - buf, - len, - 0, - (struct sockaddr *)&sa, - sa_len); + rv = sendto((SOCKET)fd, buf, len, 0, &sa.sa, sa_len); if (rv == SOCKET_ERROR) { int theErr = (jint)WSAGetLastError(); if (theErr == WSAEWOULDBLOCK) { diff --git a/jdk/src/java.base/windows/native/libnio/ch/Net.c b/jdk/src/java.base/windows/native/libnio/ch/Net.c index c7702006d27..cae8ef03bf8 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/Net.c +++ b/jdk/src/java.base/windows/native/libnio/ch/Net.c @@ -168,13 +168,13 @@ Java_sun_nio_ch_Net_bind0(JNIEnv *env, jclass clazz, jobject fdo, jboolean prefe { SOCKETADDRESS sa; int rv; - int sa_len; + int sa_len = 0; - if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) { - return; + if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, preferIPv6) != 0) { + return; } - rv = NET_WinBind(fdval(env, fdo), (struct sockaddr *)&sa, sa_len, isExclBind); + rv = NET_WinBind(fdval(env, fdo), &sa, sa_len, isExclBind); if (rv == SOCKET_ERROR) NET_ThrowNew(env, WSAGetLastError(), "bind"); } @@ -194,14 +194,14 @@ Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6, job { SOCKETADDRESS sa; int rv; - int sa_len; + int sa_len = 0; SOCKET s = (SOCKET)fdval(env, fdo); - if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) { + if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, preferIPv6) != 0) { return IOS_THROWN; } - rv = connect(s, (struct sockaddr *)&sa, sa_len); + rv = connect(s, &sa.sa, sa_len); if (rv != 0) { int err = WSAGetLastError(); if (err == WSAEINPROGRESS || err == WSAEWOULDBLOCK) { @@ -226,7 +226,7 @@ Java_sun_nio_ch_Net_localPort(JNIEnv *env, jclass clazz, jobject fdo) SOCKETADDRESS sa; int sa_len = sizeof(sa); - if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { + if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) { int error = WSAGetLastError(); if (error == WSAEINVAL) { return 0; @@ -234,7 +234,7 @@ Java_sun_nio_ch_Net_localPort(JNIEnv *env, jclass clazz, jobject fdo) NET_ThrowNew(env, error, "getsockname"); return IOS_THROWN; } - return NET_GetPortFromSockaddr((struct sockaddr *)&sa); + return NET_GetPortFromSockaddr(&sa); } JNIEXPORT jobject JNICALL @@ -244,11 +244,11 @@ Java_sun_nio_ch_Net_localInetAddress(JNIEnv *env, jclass clazz, jobject fdo) int sa_len = sizeof(sa); int port; - if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { + if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) { NET_ThrowNew(env, WSAGetLastError(), "getsockname"); return NULL; } - return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); + return NET_SockaddrToInetAddress(env, &sa, &port); } JNIEXPORT jint JNICALL @@ -257,7 +257,7 @@ Java_sun_nio_ch_Net_remotePort(JNIEnv *env, jclass clazz, jobject fdo) SOCKETADDRESS sa; int sa_len = sizeof(sa); - if (getpeername(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { + if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) < 0) { int error = WSAGetLastError(); if (error == WSAEINVAL) { return 0; @@ -265,7 +265,7 @@ Java_sun_nio_ch_Net_remotePort(JNIEnv *env, jclass clazz, jobject fdo) NET_ThrowNew(env, error, "getsockname"); return IOS_THROWN; } - return NET_GetPortFromSockaddr((struct sockaddr *)&sa); + return NET_GetPortFromSockaddr(&sa); } JNIEXPORT jobject JNICALL @@ -275,11 +275,11 @@ Java_sun_nio_ch_Net_remoteInetAddress(JNIEnv *env, jclass clazz, jobject fdo) int sa_len = sizeof(sa); int port; - if (getpeername(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { + if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) < 0) { NET_ThrowNew(env, WSAGetLastError(), "getsockname"); return NULL; } - return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); + return NET_SockaddrToInetAddress(env, &sa, &port); } JNIEXPORT jint JNICALL diff --git a/jdk/src/java.base/windows/native/libnio/ch/ServerSocketChannelImpl.c b/jdk/src/java.base/windows/native/libnio/ch/ServerSocketChannelImpl.c index 8cd94eadaa9..83469c463c1 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/ServerSocketChannelImpl.c +++ b/jdk/src/java.base/windows/native/libnio/ch/ServerSocketChannelImpl.c @@ -95,7 +95,7 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this, int addrlen = sizeof(sa); memset((char *)&sa, 0, sizeof(sa)); - newfd = (jint)accept(ssfd, (struct sockaddr *)&sa, &addrlen); + newfd = (jint)accept(ssfd, &sa.sa, &addrlen); if (newfd == INVALID_SOCKET) { int theErr = (jint)WSAGetLastError(); if (theErr == WSAEWOULDBLOCK) { @@ -107,7 +107,7 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this, SetHandleInformation((HANDLE)(UINT_PTR)newfd, HANDLE_FLAG_INHERIT, 0); (*env)->SetIntField(env, newfdo, fd_fdID, newfd); - remote_ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, (int *)&remote_port); + remote_ia = NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port); CHECK_NULL_RETURN(remote_ia, IOS_THROWN); isa = (*env)->NewObject(env, isa_class, isa_ctorID, remote_ia, remote_port); diff --git a/jdk/src/java.base/windows/native/libnio/ch/WindowsAsynchronousSocketChannelImpl.c b/jdk/src/java.base/windows/native/libnio/ch/WindowsAsynchronousSocketChannelImpl.c index b78f443937b..40b8d8ba8dc 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/WindowsAsynchronousSocketChannelImpl.c +++ b/jdk/src/java.base/windows/native/libnio/ch/WindowsAsynchronousSocketChannelImpl.c @@ -88,26 +88,21 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_WindowsAsynchronousSocketChannelImpl_connect0(JNIEnv* env, jclass this, jlong socket, jboolean preferIPv6, jobject iao, jint port, jlong ov) { - SOCKET s = (SOCKET) jlong_to_ptr(socket); - OVERLAPPED* lpOverlapped = (OVERLAPPED*) jlong_to_ptr(ov); + SOCKET s = (SOCKET)jlong_to_ptr(socket); + OVERLAPPED *lpOverlapped = (OVERLAPPED *)jlong_to_ptr(ov); SOCKETADDRESS sa; - int sa_len; + int sa_len = 0; BOOL res; - if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) { + if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, + preferIPv6) != 0) { return IOS_THROWN; } ZeroMemory((PVOID)lpOverlapped, sizeof(OVERLAPPED)); - res = (*ConnectEx_func)(s, - (struct sockaddr *)&sa, - sa_len, - NULL, - 0, - NULL, - lpOverlapped); + res = (*ConnectEx_func)(s, &sa.sa, sa_len, NULL, 0, NULL, lpOverlapped); if (res == 0) { int error = GetLastError(); if (error == ERROR_IO_PENDING) { diff --git a/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c b/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c index ad4dfd1791e..6afa1fd6030 100644 --- a/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c +++ b/jdk/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c @@ -418,7 +418,6 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj, jlong address, jint length, jboolean peek) { SOCKETADDRESS sa; - int sa_len = sizeof(SOCKETADDRESS); ssize_t rv = 0; jlong *addr = jlong_to_ptr(address); struct iovec iov[1]; @@ -429,7 +428,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 /* Set up the msghdr structure for receiving */ memset(msg, 0, sizeof (*msg)); msg->msg_name = &sa; - msg->msg_namelen = sa_len; + msg->msg_namelen = sizeof(sa); iov->iov_base = addr; iov->iov_len = length; msg->msg_iov = iov; @@ -538,7 +537,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_send0 jobject targetAddress, jint targetPort, jint assocId, jint streamNumber, jboolean unordered, jint ppid) { SOCKETADDRESS sa; - int sa_len = sizeof(SOCKETADDRESS); + int sa_len = 0; ssize_t rv = 0; jlong *addr = jlong_to_ptr(address); struct iovec iov[1]; @@ -555,13 +554,12 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_send0 * Association already existing, assocId != -1, targetAddress = preferred addr */ if (targetAddress != NULL /*&& assocId <= 0*/) { - if (NET_InetAddressToSockaddr(env, targetAddress, targetPort, &sa.sa, + if (NET_InetAddressToSockaddr(env, targetAddress, targetPort, &sa, &sa_len, JNI_TRUE) != 0) { return IOS_THROWN; } } else { - memset(&sa, '\x0', sa_len); - sa_len = 0; + memset(&sa, '\x0', sizeof(sa)); } /* Set up the msghdr structure for sending */ diff --git a/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c b/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c index 3490a82004f..30a8df5d5e4 100644 --- a/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c +++ b/jdk/src/jdk.sctp/unix/native/libsctp/SctpNet.c @@ -211,22 +211,22 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_bindx (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port, jint addrsLength, jboolean add, jboolean preferIPv6) { SOCKETADDRESS *sap, *tmpSap; - int i, sa_len = sizeof(SOCKETADDRESS); + int i; jobject ia; if (addrsLength < 1) return; - if ((sap = calloc(addrsLength, sa_len)) == NULL) { - JNU_ThrowOutOfMemoryError(env, "heap allocation failure"); + if ((sap = calloc(addrsLength, sizeof(SOCKETADDRESS))) == NULL) { + JNU_ThrowOutOfMemoryError(env, "heap allocation failure"); return; } tmpSap = sap; for (i = 0; i < addrsLength; i++) { ia = (*env)->GetObjectArrayElement(env, addrs, i); - if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap, - &sa_len, preferIPv6) != 0) { + if (NET_InetAddressToSockaddr(env, ia, port, tmpSap, NULL, + preferIPv6) != 0) { free(sap); return; } @@ -262,11 +262,11 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpNet_connect0 (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) { SOCKETADDRESS sa; - int sa_len = sizeof(SOCKETADDRESS); + int sa_len = 0; int rv; - if (NET_InetAddressToSockaddr(env, iao, port, &sa.sa, - &sa_len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, iao, port, &sa, &sa_len, + JNI_TRUE) != 0) { return IOS_THROWN; } @@ -311,8 +311,7 @@ Java_sun_nio_ch_sctp_SctpNet_preClose0 } } -void initializeISA - (JNIEnv* env) { +void initializeISA(JNIEnv* env) { if (isaCls == 0) { jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress"); CHECK_NULL(c); @@ -325,8 +324,7 @@ void initializeISA } } -jobject SockAddrToInetSocketAddress - (JNIEnv *env, struct sockaddr* sap) { +jobject SockAddrToInetSocketAddress(JNIEnv *env, SOCKETADDRESS *sap) { int port = 0; jobject ia = NET_SockaddrToInetAddress(env, sap, &port); @@ -347,9 +345,9 @@ jobject SockAddrToInetSocketAddress * Signature: (I)[Ljava/net/SocketAddress; */ JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0 - (JNIEnv *env, jclass klass, jint fd) { + (JNIEnv *env, jclass klass, jint fd) +{ void *addr_buf, *laddr; - struct sockaddr* sap; int i, addrCount; jobjectArray isaa; @@ -377,38 +375,35 @@ JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0 } laddr = addr_buf; - for (i=0; iNewObject(env, isaCls, isaCtrID, ia, port); if (isa == NULL) break; (*env)->SetObjectArrayElement(env, isaa, i, isa); - if (sap->sa_family == AF_INET) - addr_buf = ((struct sockaddr_in*)addr_buf) + 1; + if (((struct sockaddr *)addr_buf)->sa_family == AF_INET) + addr_buf = ((struct sockaddr_in *)addr_buf) + 1; else - addr_buf = ((struct sockaddr_in6*)addr_buf) + 1; + addr_buf = ((struct sockaddr_in6 *)addr_buf) + 1; } nio_sctp_freeladdrs(laddr); return isaa; } -jobjectArray getRemoteAddresses - (JNIEnv *env, jint fd, sctp_assoc_t id) { +jobjectArray getRemoteAddresses(JNIEnv *env, jint fd, sctp_assoc_t id) { void *addr_buf, *paddr; - struct sockaddr* sap; int i, addrCount; jobjectArray isaa; #if __solaris__ if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) { #else /* __linux__ */ - if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) { + if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr **)&addr_buf)) == -1) { #endif handleSocketError(env, errno); return NULL; @@ -429,25 +424,23 @@ jobjectArray getRemoteAddresses } paddr = addr_buf; - for (i=0; iNewObject(env, isaCls, isaCtrID, ia, port); if (isa == NULL) break; (*env)->SetObjectArrayElement(env, isaa, i, isa); - if (sap->sa_family == AF_INET) - addr_buf = ((struct sockaddr_in*)addr_buf) + 1; + if (((struct sockaddr *)addr_buf)->sa_family == AF_INET) + addr_buf = ((struct sockaddr_in *)addr_buf) + 1; else - addr_buf = ((struct sockaddr_in6*)addr_buf) + 1; + addr_buf = ((struct sockaddr_in6 *)addr_buf) + 1; } nio_sctp_freepaddrs(paddr); - return isaa; } @@ -579,7 +572,6 @@ JNIEXPORT jobject JNICALL Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0 (JNIEnv *env, jclass klass, jint fd, jint assocId) { struct sctp_setprim prim; unsigned int prim_len = sizeof(prim); - struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr; prim.ssp_assoc_id = assocId; @@ -589,7 +581,7 @@ JNIEXPORT jobject JNICALL Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0 return NULL; } - return SockAddrToInetSocketAddress(env, sap); + return SockAddrToInetSocketAddress(env, (SOCKETADDRESS *)&prim.ssp_addr); } /* @@ -600,11 +592,10 @@ JNIEXPORT jobject JNICALL Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0 JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0 (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) { struct sctp_setprim prim; - struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr; - int sap_len = sizeof(sap); - if (NET_InetAddressToSockaddr(env, iaObj, port, sap, - &sap_len, JNI_TRUE) != 0) { + if (NET_InetAddressToSockaddr(env, iaObj, port, + (SOCKETADDRESS *)&prim.ssp_addr, + NULL, JNI_TRUE) != 0) { return; } @@ -625,18 +616,17 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0 (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port, jboolean preferIPv6) { struct sctp_setpeerprim prim; - struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr; - int sap_len = sizeof(sap); - if (NET_InetAddressToSockaddr(env, iaObj, port, sap, - &sap_len, preferIPv6) != 0) { + if (NET_InetAddressToSockaddr(env, iaObj, port, + (SOCKETADDRESS *)&prim.sspp_addr, + NULL, preferIPv6) != 0) { return; } prim.sspp_assoc_id = assocId; if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim, - sizeof(prim)) < 0) { + sizeof(prim)) < 0) { JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "sun.nio.ch.SctpNet.setPeerPrimAddrOption0"); } From 9f862797e4b34d2e615d2f4012388bde4a7903f1 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Fri, 13 Jan 2017 17:45:32 +0000 Subject: [PATCH 090/154] 8172253: SetIfModifiedSince.java test fails with http return code 404 Reviewed-by: chegar, dfuchs --- jdk/test/sun/net/www/protocol/http/SetIfModifiedSince.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/sun/net/www/protocol/http/SetIfModifiedSince.java b/jdk/test/sun/net/www/protocol/http/SetIfModifiedSince.java index 4d9db3cd22f..df6045cd302 100644 --- a/jdk/test/sun/net/www/protocol/http/SetIfModifiedSince.java +++ b/jdk/test/sun/net/www/protocol/http/SetIfModifiedSince.java @@ -22,7 +22,7 @@ */ /* @test - @bug 4213164 + @bug 4213164 8172253 @summary setIfModifiedSince mehtod in HttpURLConnection sometimes fails */ import java.util.*; @@ -88,7 +88,7 @@ public class SetIfModifiedSince implements Runnable { //url = new URL(args[0]); url = new URL("http://localhost:" + String.valueOf(port) + "/anything"); - con = (HttpURLConnection)url.openConnection(); + con = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY); con.setIfModifiedSince(date.getTime()); con.connect(); From 922f392c825944f21ab031941b62f949e96f8c3e Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Fri, 13 Jan 2017 12:35:53 -0800 Subject: [PATCH 091/154] 8172221: Directorate of Time has been superseded Reviewed-by: lancea --- jdk/src/java.base/share/classes/java/util/Date.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/Date.java b/jdk/src/java.base/share/classes/java/util/Date.java index bb9494766bd..312a74b6033 100644 --- a/jdk/src/java.base/share/classes/java/util/Date.java +++ b/jdk/src/java.base/share/classes/java/util/Date.java @@ -82,17 +82,19 @@ import sun.util.calendar.ZoneInfo; * well; for example, the time scale used by the satellite-based * global positioning system (GPS) is synchronized to UTC but is * not adjusted for leap seconds. An interesting source of - * further information is the U.S. Naval Observatory, particularly - * the Directorate of Time at: + * further information is the United States Naval Observatory (USNO): *

- *     http://www.usno.navy.mil
+ *     http://www.usno.navy.mil/USNO
  * 
*

- * and their definitions of "Systems of Time" at: + * and the material regarding "Systems of Time" at: *

  *     http://www.usno.navy.mil/USNO/time/master-clock/systems-of-time
  * 
*

+ * which has descriptions of various different time systems including + * UT, UT1, and UTC. + *

* In all methods of class {@code Date} that accept or return * year, month, date, hours, minutes, and seconds values, the * following representations are used: From eeb1e36d49853f43c4167d48a542e127e66cc7bc Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 13 Jan 2017 13:31:16 -0800 Subject: [PATCH 092/154] 8152272: Unable to create temporary file using createTempFile method if System.getProperty(file.separator) is used Normalize the name component of the temporary file path Reviewed-by: rriggs --- jdk/src/java.base/share/classes/java/io/File.java | 5 ++++- jdk/test/java/io/File/createTempFile/Patterns.java | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/io/File.java b/jdk/src/java.base/share/classes/java/io/File.java index 1598694ef2f..0bbaf4d5d0b 100644 --- a/jdk/src/java.base/share/classes/java/io/File.java +++ b/jdk/src/java.base/share/classes/java/io/File.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1962,6 +1962,9 @@ public class File name = sb.toString(); } + // Normalize the path component + name = fs.normalize(name); + File f = new File(dir, name); if (!name.equals(f.getName()) || f.isInvalid()) { if (System.getSecurityManager() != null) diff --git a/jdk/test/java/io/File/createTempFile/Patterns.java b/jdk/test/java/io/File/createTempFile/Patterns.java index 0169a5e4b9c..2a899f65101 100644 --- a/jdk/test/java/io/File/createTempFile/Patterns.java +++ b/jdk/test/java/io/File/createTempFile/Patterns.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - @bug 4152178 + @bug 4152178 8152272 @summary Check various temp-file prefix/suffix cases */ import java.io.File; @@ -66,6 +66,7 @@ public class Patterns { cky("xxx", ""); cky("xxx", "y"); cky("xxx", ".y"); + cky("xyz", "Directory" + System.getProperty("file.separator")); } } From cf65663c4d962f8a508a4fdac8a6263912af75c8 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Fri, 13 Jan 2017 14:54:04 -0800 Subject: [PATCH 093/154] 7146543: TEST_BUG: java/rmi/registry/readTest/readTest.sh failing intermittently with port in use Reviewed-by: rriggs --- jdk/test/ProblemList.txt | 4 +- .../rmi/registry/readTest/CodebaseTest.java | 90 ++++++++++++ .../{readTest.java => RegistryLookup.java} | 41 +++--- .../java/rmi/registry/readTest/readTest.sh | 137 ------------------ .../readTest/registry.security.policy | 12 ++ 5 files changed, 125 insertions(+), 159 deletions(-) create mode 100644 jdk/test/java/rmi/registry/readTest/CodebaseTest.java rename jdk/test/java/rmi/registry/readTest/{readTest.java => RegistryLookup.java} (64%) delete mode 100644 jdk/test/java/rmi/registry/readTest/readTest.sh create mode 100644 jdk/test/java/rmi/registry/readTest/registry.security.policy diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 6230a3cd1f6..335323c89d2 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -1,6 +1,6 @@ ########################################################################### # -# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -203,8 +203,6 @@ java/rmi/activation/Activatable/extLoadedImpl/ext.sh 8062724 generic- sun/rmi/rmic/newrmic/equivalence/run.sh 8145980 generic-all -java/rmi/registry/readTest/readTest.sh 7146543 generic-all - ############################################################################ # jdk_security diff --git a/jdk/test/java/rmi/registry/readTest/CodebaseTest.java b/jdk/test/java/rmi/registry/readTest/CodebaseTest.java new file mode 100644 index 00000000000..453dfe75e22 --- /dev/null +++ b/jdk/test/java/rmi/registry/readTest/CodebaseTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 7102369 7094468 7100592 + * @modules java.rmi/sun.rmi.registry + * java.rmi/sun.rmi.server + * java.rmi/sun.rmi.transport + * java.rmi/sun.rmi.transport.tcp + * @library ../../testlibrary + * @build TestLibrary RMIRegistryRunner RegistryVM JavaVM testPkg.* RegistryLookup + * @summary remove java.rmi.server.codebase property parsing from registyimpl + * @run main/othervm CodebaseTest +*/ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.rmi.registry.Registry; +import java.rmi.registry.LocateRegistry; +import java.rmi.RemoteException; +import java.rmi.server.UnicastRemoteObject; + +public class CodebaseTest { + + public static void main(String args[]) throws Exception { + RegistryVM rmiregistry = null; + JavaVM client = null; + try { + File src = new File(System.getProperty("test.classes", "."), "testPkg"); + File dest = new File(System.getProperty("user.dir", "."), "testPkg"); + Files.move(src.toPath(), dest.toPath(), + StandardCopyOption.REPLACE_EXISTING); + + File rmiregistryDir = + new File(System.getProperty("user.dir", "."), "rmi_tmp"); + rmiregistryDir.mkdirs(); + rmiregistry = RegistryVM.createRegistryVMWithRunner( + "RMIRegistryRunner", + " -Djava.rmi.server.useCodebaseOnly=false" + + " -Duser.dir=" + rmiregistryDir.getAbsolutePath()); + rmiregistry.start(); + int port = rmiregistry.getPort(); + + File srcReadTest = new File(System.getProperty("test.classes", "."), + "RegistryLookup.class"); + File destReadTest = new File(System.getProperty("user.dir", "."), + "RegistryLookup.class"); + Files.move(srcReadTest.toPath(), destReadTest.toPath(), + StandardCopyOption.REPLACE_EXISTING); + + File codebase = new File(System.getProperty("user.dir", ".")); + client = new JavaVM("RegistryLookup", + " -Djava.rmi.server.codebase=" + codebase.toURI().toURL() + + " -cp ." + File.pathSeparator + System.getProperty("test.class.path"), + Integer.toString(port)); + int exit = client.execute(); + if (exit == RegistryLookup.EXIT_FAIL) { + throw new RuntimeException("Test Fails"); + } + } finally { + if (rmiregistry != null) { + rmiregistry.cleanup(); + } + if (client != null) { + client.cleanup(); + } + } + } +} diff --git a/jdk/test/java/rmi/registry/readTest/readTest.java b/jdk/test/java/rmi/registry/readTest/RegistryLookup.java similarity index 64% rename from jdk/test/java/rmi/registry/readTest/readTest.java rename to jdk/test/java/rmi/registry/readTest/RegistryLookup.java index 95cd9c0a6ed..6bb6ae76438 100644 --- a/jdk/test/java/rmi/registry/readTest/readTest.java +++ b/jdk/test/java/rmi/registry/readTest/RegistryLookup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,34 +26,37 @@ import java.rmi.registry.LocateRegistry; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; -public class readTest { +public class RegistryLookup { + public static final int EXIT_FAIL = 1; public static void main(String args[]) throws Exception { + Registry registry = null; + int exit = 0; try { - testPkg.Server obj = new testPkg.Server(); - testPkg.Hello stub = (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0); - // Bind the remote object's stub in the registry - Registry registry = - LocateRegistry.getRegistry(TestLibrary.READTEST_REGISTRY_PORT); - registry.bind("Hello", stub); + int port = Integer.valueOf(args[0]); + testPkg.Server obj = new testPkg.Server(); + testPkg.Hello stub = + (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0); + // Bind the remote object's stub in the registry + registry = LocateRegistry.getRegistry(port); + registry.bind("Hello", stub); System.err.println("Server ready"); - // now, let's test client - testPkg.Client client = - new testPkg.Client(TestLibrary.READTEST_REGISTRY_PORT); + testPkg.Client client = new testPkg.Client(port); String testStubReturn = client.testStub(); if(!testStubReturn.equals(obj.hello)) { - throw new RuntimeException("Test Fails : unexpected string from stub call"); - } else { - System.out.println("Test passed"); + throw new RuntimeException("Test Fails : " + + "unexpected string from stub call"); } registry.unbind("Hello"); - - } catch (Exception e) { - System.err.println("Server exception: " + e.toString()); - e.printStackTrace(); + System.out.println("Test passed"); + } catch (Exception ex) { + exit = EXIT_FAIL; + ex.printStackTrace(); } - + // need to exit explicitly, and parent process uses exit value + // to tell if the test passed. + System.exit(exit); } } diff --git a/jdk/test/java/rmi/registry/readTest/readTest.sh b/jdk/test/java/rmi/registry/readTest/readTest.sh deleted file mode 100644 index 8e4a8339cd7..00000000000 --- a/jdk/test/java/rmi/registry/readTest/readTest.sh +++ /dev/null @@ -1,137 +0,0 @@ -# -# Copyright (c) 2011, 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. -# -# 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 7102369 7094468 7100592 -# @modules java.rmi/sun.rmi.registry -# java.rmi/sun.rmi.server -# java.rmi/sun.rmi.transport -# java.rmi/sun.rmi.transport.tcp -# @library ../../testlibrary -# @build TestLibrary -# @summary remove java.rmi.server.codebase property parsing from registyimpl -# @run shell readTest.sh -# @key intermittent - -OS=`uname -s` -VER=`uname -r` -ARGS="" -REGARGS="" - -case "$OS" in - SunOS | Linux | Darwin | AIX ) - PS=":" - FS="/" - CHMOD="${FS}bin${FS}chmod" - FILEURL="file:" - ;; - Windows* ) - PS=";" - FS="\\" - CHMOD="chmod" - FILEURL="file:/" - if [ "$VER" -eq "5" ]; then - ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000" - REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000" - fi - ;; - CYGWIN* ) - PS=";" - FS="/" - CHMOD="chmod" - FILEURL="file:/" - if [ "$VER" -eq "5" ]; then - ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000" - REGARGS="-J-Djdk.net.ephemeralPortRange.low=1024 -J-Djdk.net.ephemeralPortRange.high=65000" - fi - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TEST_CLASSPATH=.$PS${TESTCLASSPATH:-$TESTCLASSES} -cp -r ${TESTSRC}${FS}* . -${CHMOD} -R u+w * -${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} testPkg${FS}*java -${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -cp $TEST_CLASSPATH readTest.java - -mkdir rmi_tmp -RMIREG_OUT=rmi.out -#start rmiregistry without any local classes on classpath -cd rmi_tmp -# NOTE: This RMI Registry port must match TestLibrary.READTEST_REGISTRY_PORT -${TESTJAVA}${FS}bin${FS}rmiregistry ${REGARGS} -J-Djava.rmi.server.useCodebaseOnly=false \ - ${TESTTOOLVMOPTS} 60005 > ..${FS}${RMIREG_OUT} 2>&1 & -RMIREG_PID=$! -# allow some time to start -sleep 3 -cd .. - -case "$OS" in - CYGWIN* ) - CODEBASE=`cygpath -w $PWD` - ;; - * ) - CODEBASE=`pwd` - ;; -esac -# trailing / after code base is important for rmi codebase property. -TESTVMOPTS="${TESTVMOPTS} \ - --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED \ - --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED \ - --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED \ - --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH ${ARGS} -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 & -TEST_PID=$! -#bulk of testcase - let it run for a while -sleep 5 - -#we're done, kill processes first -kill -9 ${RMIREG_PID} ${TEST_PID} -sleep 3 - -echo "Test output : " - -cat OUT.TXT -echo "==============" -echo "rmiregistry output : " -cat ${RMIREG_OUT} -echo "==============" - -grep "Server ready" OUT.TXT -result1=$? -grep "Test passed" OUT.TXT -result2=$? - -if [ $result1 -eq 0 -a $result2 -eq 0 ] -then - echo "Passed" - exitCode=0; -else - echo "Failed" - exitCode=1 -fi -rm -rf OUT.TXT ${RMIREG_OUT} rmi_tmp -exit ${exitCode} diff --git a/jdk/test/java/rmi/registry/readTest/registry.security.policy b/jdk/test/java/rmi/registry/readTest/registry.security.policy new file mode 100644 index 00000000000..d1aef0cb9fa --- /dev/null +++ b/jdk/test/java/rmi/registry/readTest/registry.security.policy @@ -0,0 +1,12 @@ +grant { + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry"; + permission java.util.PropertyPermission "env.class.path", "read"; + permission java.io.FilePermission ".", "read"; + permission java.util.PropertyPermission "user.dir", "read"; + permission java.lang.RuntimePermission "createClassLoader"; + permission java.lang.RuntimePermission "setContextClassLoader"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp"; + permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept"; +}; From 9d3f1e001a3aede652a667ed8a8597ca1d3b4512 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 13 Jan 2017 14:58:21 -0800 Subject: [PATCH 094/154] 8153250: java.io.File does not handle Windows paths of the form "D:" (no path) correctly When resolving a child to a parent, do not insert a file separator for Windows directory-relative paths Reviewed-by: rriggs --- .../classes/java/io/WinNTFileSystem.java | 9 +- jdk/test/java/io/File/WinDirRelative.java | 96 +++++++++++++++++++ 2 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/io/File/WinDirRelative.java diff --git a/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java index e6b13bba7b1..9cd515075fa 100644 --- a/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java +++ b/jdk/src/java.base/windows/classes/java/io/WinNTFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -233,11 +233,14 @@ class WinNTFileSystem extends FileSystem { int childStart = 0; int parentEnd = pn; + boolean isDirectoryRelative = + pn == 2 && isLetter(parent.charAt(0)) && parent.charAt(1) == ':'; + if ((cn > 1) && (c.charAt(0) == slash)) { if (c.charAt(1) == slash) { /* Drop prefix when child is a UNC pathname */ childStart = 2; - } else { + } else if (!isDirectoryRelative) { /* Drop prefix when child is drive-relative */ childStart = 1; @@ -254,7 +257,7 @@ class WinNTFileSystem extends FileSystem { int strlen = parentEnd + cn - childStart; char[] theChars = null; - if (child.charAt(childStart) == slash) { + if (child.charAt(childStart) == slash || isDirectoryRelative) { theChars = new char[strlen]; parent.getChars(0, parentEnd, theChars, 0); child.getChars(childStart, cn, theChars, parentEnd); diff --git a/jdk/test/java/io/File/WinDirRelative.java b/jdk/test/java/io/File/WinDirRelative.java new file mode 100644 index 00000000000..60847dd0de6 --- /dev/null +++ b/jdk/test/java/io/File/WinDirRelative.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8153250 + * @summary Tests that files are correctly listed for a directory-relative path + * @requires (os.family == "windows") + */ +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class WinDirRelative { + private static final char COLON = ':'; + private static final String BASENAME = "TestFile_"; + private static final String EXTENSION = ".txt"; + private static final int NUM_FILES = 10; + + private static boolean isLetter(char c) { + return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')); + } + + public static void main(String[] args) throws Throwable { + // Get the working directory which is also the default + // directory for the current drive. + String userDir = System.getProperty("user.dir"); + + // Test only if a leading drive letter is found + if (isLetter(userDir.charAt(0)) && userDir.charAt(1) == COLON) { + // Create some empty files + List filenames = new ArrayList(NUM_FILES); + for (int i = 0; i < NUM_FILES; i++) { + String filename = BASENAME + i + EXTENSION; + filenames.add(filename); + File f = new File(filename); + f.createNewFile(); + f.deleteOnExit(); + System.out.printf("Created %s (%s)%n", filename, + f.getAbsolutePath()); + } + + // List files and verify that the ones with recognized names exist. + String prefix = userDir.substring(0, 2); + File p = new File(prefix); + int failures = 0; + int successes = 0; + for (File f : p.listFiles()) { + if (f.getName().toString().startsWith(BASENAME)) { + if (!f.exists()) { + System.err.printf("%s (%s) does not exist%n", f, + f.getAbsolutePath()); + failures++; + } else { + successes++; + } + } + } + + // Fail if there was an existence test failure or if not + // enough of the created files were found + boolean testFailed = false; + if (failures > 0) { + System.err.println("Existence check failed"); + testFailed = true; + } + if (successes != NUM_FILES) { + System.err.println("Count check failed"); + testFailed = true; + } + if (testFailed) { + throw new RuntimeException("Test failed"); + } + } + } +} From ee0491d2108ce4644e78bb8017e52bb68df8105c Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 13 Jan 2017 15:48:12 -0800 Subject: [PATCH 095/154] 8172474: javac should enable doclint checking for HTML 5 Reviewed-by: jlahoda --- .../com/sun/tools/javac/main/Arguments.java | 8 +- .../com/sun/tools/javac/main/Option.java | 8 +- .../tools/javac/resources/javac.properties | 5 +- .../javac/doclint/DocLintFormatTest.java | 105 ++++++++++++++++++ 4 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javac/doclint/DocLintFormatTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java index cd47fde15aa..ba96d875153 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -818,13 +818,17 @@ public class Arguments { return List.nil(); String checkPackages = options.get(Option.XDOCLINT_PACKAGE); - if (checkPackages != null) { for (String s : checkPackages.split("\\s+")) { doclintOpts.add(DocLint.XCHECK_PACKAGE + s); } } + String format = options.get(Option.DOCLINT_FORMAT); + if (format != null) { + doclintOpts.add(DocLint.XHTML_VERSION_PREFIX + format); + } + // standard doclet normally generates H1, H2, // so for now, allow user comments to assume that doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2"); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java index 052bf48de9e..1c27b8087f2 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -154,6 +154,8 @@ public enum Option { } }, + DOCLINT_FORMAT("--doclint-format", "opt.doclint.format", EXTENDED, BASIC, ONEOF, "html4", "html5"), + // -nowarn is retained for command-line backward compatibility NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) { @Override @@ -1216,10 +1218,12 @@ public enum Option { sb.append(name); if (argsNameKey == null) { if (choices != null) { + if (!name.endsWith(":")) + sb.append(" "); String sep = "{"; for (String choice : choices) { sb.append(sep); - sb.append(choices); + sb.append(choice); sep = ","; } sb.append("}"); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties index 2a461a3e600..7a637a48d20 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -263,6 +263,9 @@ javac.opt.Xdoclint.package.desc=\ expands to all sub-packages of the given package. Each can be prefixed\n\ with '-' to disable checks for the specified package or packages. +javac.opt.doclint.format=\ + Specify the format for documentation comments + javac.opt.Xstdout=\ Redirect standard output javac.opt.X=\ diff --git a/langtools/test/tools/javac/doclint/DocLintFormatTest.java b/langtools/test/tools/javac/doclint/DocLintFormatTest.java new file mode 100644 index 00000000000..230dbefc83e --- /dev/null +++ b/langtools/test/tools/javac/doclint/DocLintFormatTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8172474 + * @summary javac should enable doclint checking for HTML 5 + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run main DocLintFormatTest + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.ToolBox; + +public class DocLintFormatTest { + public static void main(String... args) throws Exception { + new DocLintFormatTest().run(); + } + + private ToolBox tb = new ToolBox(); + private Path src = Paths.get("src"); + private Path classes = Paths.get("classes"); + + void run() throws Exception { + Files.createDirectories(classes); + + tb.writeJavaFiles(src, + // 1 2 + //2345678901234567890 + "/** This is an HTML 4 comment. */ public class Test4 { }", + "/** This is an HTML 5 comment. */ public class Test5 { }" + ); + + test(src.resolve("Test4.java"), "html4"); + test(src.resolve("Test4.java"), "html5", + "Test4.java:1:16: compiler.err.proc.messager: tag not supported in the generated HTML version: tt"); + test(src.resolve("Test5.java"), "html4", + "Test5.java:1:16: compiler.err.proc.messager: tag not supported in the generated HTML version: mark"); + test(src.resolve("Test5.java"), "html5"); + + if (errors > 0) { + throw new Exception(errors + " errors occurred"); + } + } + + void test(Path file, String format, String... expect) { + System.err.println("Test: " + format + " " + file); + List output = new JavacTask(tb) + .outdir(classes) + .options("-XDrawDiagnostics", "-Xdoclint", "--doclint-format", format) + .files(file) + .run(expect.length == 0 ? Task.Expect.SUCCESS : Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + if (expect.length == 0) { + if (!(output.size() == 1 && output.get(0).isEmpty())) { + error("All output unexpected."); + } + } else { + for (String e : expect) { + if (!output.contains(e)) { + error("expected output not found: " + e); + } + } + } + } + + void error(String message) { + System.err.println("Error: " + message); + errors++; + } + + private int errors = 0; +} + From cde454bda330d287c4e70d0256260b74b01249d1 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Fri, 13 Jan 2017 18:29:21 -0800 Subject: [PATCH 096/154] 8172678: JShell Tests: Disable CompletionSuggestionTest.testBrokenClassFile2() Reviewed-by: jlahoda --- langtools/test/jdk/jshell/CompletionSuggestionTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/test/jdk/jshell/CompletionSuggestionTest.java b/langtools/test/jdk/jshell/CompletionSuggestionTest.java index 6b068bc1234..7873e438496 100644 --- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java +++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java @@ -673,6 +673,7 @@ public class CompletionSuggestionTest extends KullaTesting { keepParameterNames.set(getAnalysis(), new String[0]); } + @Test(enabled = false) //TODO 8171829 public void testBrokenClassFile2() throws IOException { Path broken = outDir.resolve("broken"); compiler.compile(broken, From c96f02f2e831e4d8563879ecafbc1800e2d73d9f Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 13 Jan 2017 19:29:55 -0800 Subject: [PATCH 097/154] 8172531: Correct misstatements in javax.lang.model visitor documentation Reviewed-by: jjg --- .../model/element/AnnotationValueVisitor.java | 8 ++++---- .../lang/model/element/ElementVisitor.java | 8 ++++---- .../javax/lang/model/type/TypeVisitor.java | 8 ++++---- .../util/AbstractAnnotationValueVisitor6.java | 11 +---------- .../util/AbstractAnnotationValueVisitor7.java | 11 +---------- .../util/AbstractAnnotationValueVisitor8.java | 11 +---------- .../model/util/AbstractElementVisitor6.java | 11 +---------- .../model/util/AbstractElementVisitor7.java | 11 +---------- .../model/util/AbstractElementVisitor8.java | 11 +---------- .../lang/model/util/AbstractTypeVisitor6.java | 11 +---------- .../lang/model/util/AbstractTypeVisitor7.java | 11 +---------- .../lang/model/util/AbstractTypeVisitor8.java | 11 +---------- .../lang/model/util/ElementKindVisitor6.java | 19 +++++-------------- .../lang/model/util/ElementKindVisitor7.java | 19 +++++-------------- .../lang/model/util/ElementKindVisitor8.java | 19 +++++-------------- .../lang/model/util/ElementKindVisitor9.java | 10 +++++----- .../lang/model/util/ElementScanner6.java | 14 +++++++------- .../lang/model/util/ElementScanner7.java | 14 +++++++------- .../lang/model/util/ElementScanner8.java | 14 +++++++------- .../lang/model/util/ElementScanner9.java | 14 +++++++------- .../util/SimpleAnnotationValueVisitor6.java | 11 +---------- .../util/SimpleAnnotationValueVisitor7.java | 11 +---------- .../util/SimpleAnnotationValueVisitor8.java | 11 +---------- .../model/util/SimpleElementVisitor6.java | 11 +---------- .../model/util/SimpleElementVisitor7.java | 11 +---------- .../model/util/SimpleElementVisitor8.java | 11 +---------- .../lang/model/util/SimpleTypeVisitor6.java | 11 +---------- .../lang/model/util/SimpleTypeVisitor7.java | 11 +---------- .../lang/model/util/SimpleTypeVisitor8.java | 11 +---------- .../lang/model/util/TypeKindVisitor6.java | 19 +++++-------------- .../lang/model/util/TypeKindVisitor7.java | 19 +++++-------------- .../lang/model/util/TypeKindVisitor8.java | 19 +++++-------------- .../lang/model/util/TypeKindVisitor9.java | 10 +++++----- 33 files changed, 98 insertions(+), 314 deletions(-) diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java b/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java index 37d55d5ca80..8e152c53ead 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ import javax.lang.model.type.TypeMirror; * implementing this interface are used to operate on a value when the * type of that value is unknown at compile time. When a visitor is * passed to a value's {@link AnnotationValue#accept accept} method, - * the visitXYZ method applicable to that value is + * the visitXyz method applicable to that value is * invoked. * *

Classes implementing this interface may or may not throw a @@ -65,9 +65,9 @@ import javax.lang.model.type.TypeMirror; * be added in a source compatible way if they were added as * default methods. However, default methods are only * available on Java SE 8 and higher releases and the {@code - * javax.lang.model.*} packages bundled in Java SE 8 are required to + * javax.lang.model.*} packages bundled in Java SE 8 were required to * also be runnable on Java SE 7. Therefore, default methods - * cannot be used when extending {@code javax.lang.model.*} + * were not used when extending {@code javax.lang.model.*} * to cover Java SE 8 language features. However, default methods may * be used in subsequent revisions of the {@code javax.lang.model.*} * packages that are only required to run on Java SE 8 and higher diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java index 27125a5c515..b549fbd3e00 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ import javax.lang.model.util.*; * pattern. Classes implementing this interface are used to operate * on an element when the kind of element is unknown at compile time. * When a visitor is passed to an element's {@link Element#accept - * accept} method, the visitXYZ method most applicable + * accept} method, the visitXyz method most applicable * to that element is invoked. * *

Classes implementing this interface may or may not throw a @@ -56,9 +56,9 @@ import javax.lang.model.util.*; * be added in a source compatible way if they were added as * default methods. However, default methods are only * available on Java SE 8 and higher releases and the {@code - * javax.lang.model.*} packages bundled in Java SE 8 are required to + * javax.lang.model.*} packages bundled in Java SE 8 were required to * also be runnable on Java SE 7. Therefore, default methods - * cannot be used when extending {@code javax.lang.model.*} + * were not used when extending {@code javax.lang.model.*} * to cover Java SE 8 language features. However, default methods may * be used in subsequent revisions of the {@code javax.lang.model.*} * packages that are only required to run on Java SE 8 and higher diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java b/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java index 7e6026d0914..451753a0095 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ import javax.lang.model.element.*; * visitor design pattern. Classes implementing this * interface are used to operate on a type when the kind of * type is unknown at compile time. When a visitor is passed to a - * type's {@link TypeMirror#accept accept} method, the visitXYZ + * type's {@link TypeMirror#accept accept} method, the visitXyz * method most applicable to that type is invoked. * *

Classes implementing this interface may or may not throw a @@ -56,9 +56,9 @@ import javax.lang.model.element.*; * be added in a source compatible way if they were added as * default methods. However, default methods are only * available on Java SE 8 and higher releases and the {@code - * javax.lang.model.*} packages bundled in Java SE 8 are required to + * javax.lang.model.*} packages bundled in Java SE 8 were required to * also be runnable on Java SE 7. Therefore, default methods - * cannot be used when extending {@code javax.lang.model.*} + * were not used when extending {@code javax.lang.model.*} * to cover Java SE 8 language features. However, default methods may * be used in subsequent revisions of the {@code javax.lang.model.*} * packages that are only required to run on Java SE 8 and higher diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java index 795ce97b61c..8367c1aa587 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,15 +54,6 @@ import javax.annotation.processing.SupportedSourceVersion; * behavior for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods * @param

the type of the additional parameter to this visitor's methods. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java index b03e5a7e8e7..20a77e985d1 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,15 +51,6 @@ import javax.annotation.processing.SupportedSourceVersion; * behavior for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods * @param

the type of the additional parameter to this visitor's methods. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java index eddd27d0998..689e301f803 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,15 +51,6 @@ import javax.annotation.processing.SupportedSourceVersion; * behavior for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods * @param

the type of the additional parameter to this visitor's methods. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java index 9f2b6e85186..daa0e097efd 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,15 +53,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java index 94dcfc8cff5..69263575588 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,15 +52,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java index 8237407f1a7..53878285b15 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,15 +52,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java index eb7bbce728a..8ad1fe1f5db 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,15 +52,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java index 1973446d4af..55ac050fb3e 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,15 +52,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java index 87163338a96..2665d1a90d6 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,15 +52,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java index 730e5287349..562e6e5cfd2 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,10 +36,10 @@ import javax.lang.model.SourceVersion; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * @@ -67,15 +67,6 @@ import javax.lang.model.SourceVersion; * for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java index f62c272e635..3bf25d10f70 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_7 RELEASE_7} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * @@ -65,15 +65,6 @@ import static javax.lang.model.SourceVersion.*; * for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java index 57daa2b38dc..d23265df3e8 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,10 @@ import javax.lang.model.SourceVersion; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_8 RELEASE_8} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * @@ -65,15 +65,6 @@ import javax.lang.model.SourceVersion; * for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java index 3e1fea46ce0..fc5a9851104 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,10 @@ import javax.lang.model.SourceVersion; * A visitor of program elements based on their {@linkplain * ElementKind kind} with default behavior appropriate for the {@link * SourceVersion#RELEASE_9 RELEASE_9} source version. For {@linkplain - * Element elements} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * Element elements} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java index 372253192e0..749cc600d86 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6} - * source version. The visitXYZ methods in this + * source version. The visitXyz methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXyz methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXyz method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXyz. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXyz at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXyz, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java index b3590689c5b..35b90dcfca6 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} - * source version. The visitXYZ methods in this + * source version. The visitXyz methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXyz methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXyz method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXyz. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXyz at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXyz, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java index 25f00a011a8..0fd2f21046d 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} - * source version. The visitXYZ methods in this + * source version. The visitXyz methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXyz methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXyz method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXyz. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXyz at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXyz, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java index 08269399713..b7dd53bd9c8 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,26 +34,26 @@ import static javax.lang.model.SourceVersion.*; /** * A scanning visitor of program elements with default behavior * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9} - * source version. The visitXYZ methods in this + * source version. The visitXyz methods in this * class scan their component elements by calling {@code scan} on * their {@linkplain Element#getEnclosedElements enclosed elements}, * {@linkplain ExecutableElement#getParameters parameters}, etc., as * indicated in the individual method specifications. A subclass can * control the order elements are visited by overriding the - * visitXYZ methods. Note that clients of a scanner + * visitXyz methods. Note that clients of a scanner * may get the desired behavior be invoking {@code v.scan(e, p)} rather * than {@code v.visit(e, p)} on the root objects of interest. * - *

When a subclass overrides a visitXYZ method, the + *

When a subclass overrides a visitXyz method, the * new method can cause the enclosed elements to be scanned in the - * default way by calling super.visitXYZ. In this + * default way by calling super.visitXyz. In this * fashion, the concrete visitor can control the ordering of traversal * over the component elements with respect to the additional * processing; for example, consistently calling - * super.visitXYZ at the start of the overridden + * super.visitXyz at the start of the overridden * methods will yield a preorder traversal, etc. If the component * elements should be traversed in some other order, instead of - * calling super.visitXYZ, an overriding visit method + * calling super.visitXyz, an overriding visit method * should call {@code scan} with the elements in the desired order. * *

Methods in this class may be overridden subject to their diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java index 0006dd4c9df..a979ff5abba 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,15 +63,6 @@ import javax.annotation.processing.SupportedSourceVersion; * behavior for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods * @param

the type of the additional parameter to this visitor's methods. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java index c6d263fc63f..bb895bc7ac4 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,15 +58,6 @@ import static javax.lang.model.SourceVersion.*; * behavior for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods * @param

the type of the additional parameter to this visitor's methods. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java index 1dd055350d0..957c556d014 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,15 +58,6 @@ import static javax.lang.model.SourceVersion.*; * behavior for the visit method in question. When the new visitor is * introduced, all or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods * @param

the type of the additional parameter to this visitor's methods. * diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java index 1f9ca8cab66..81fc96e0aae 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,15 +65,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@code Void} * for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's methods. Use {@code Void} diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java index 2abe913110a..bbbd77bdb28 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,15 +62,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@code Void} * for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's methods. Use {@code Void} diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java index 22d50e7fd74..776bc6439a6 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,15 +61,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@code Void} * for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's methods. Use {@code Void} diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java index 35ea1f71819..eba95187075 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,15 +64,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java index 99ec8f720b5..8a2e05f479c 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,15 +61,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java index 7636f2e03f5..098f5f0f353 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,15 +61,6 @@ import static javax.lang.model.SourceVersion.*; * visit method in question. When the new visitor is introduced, all * or portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java index e32166f63db..0917063e54e 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_6 * RELEASE_6} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * @@ -63,15 +63,6 @@ import static javax.lang.model.SourceVersion.*; * method in question. When the new visitor is introduced, all or * portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java index 9fb9594976a..22529917d49 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,10 @@ import javax.lang.model.SourceVersion; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_7 * RELEASE_7} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * @@ -63,15 +63,6 @@ import javax.lang.model.SourceVersion; * method in question. When the new visitor is introduced, all or * portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java index 064652a8aef..63aea9a30eb 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_8 * RELEASE_8} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * @@ -63,15 +63,6 @@ import static javax.lang.model.SourceVersion.*; * method in question. When the new visitor is introduced, all or * portions of this visitor may be deprecated. * - *

Note that adding a default implementation of a new visit method - * in a visitor class will occur instead of adding a default - * method directly in the visitor interface since a Java SE 8 - * language feature cannot be used to this version of the API since - * this version is required to be runnable on Java SE 7 - * implementations. Future versions of the API that are only required - * to run on Java SE 8 and later may take advantage of default methods - * in this situation. - * * @param the return type of this visitor's methods. Use {@link * Void} for visitors that do not need to return results. * @param

the type of the additional parameter to this visitor's diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java index 7e635fb37d0..7e958e65ebe 100644 --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,10 +34,10 @@ import static javax.lang.model.SourceVersion.*; * A visitor of types based on their {@linkplain TypeKind kind} with * default behavior appropriate for the {@link SourceVersion#RELEASE_9 * RELEASE_9} source version. For {@linkplain - * TypeMirror types} XYZ that may have more than one - * kind, the visitXYZ methods in this class delegate - * to the visitXYZKind method corresponding to the - * first argument's kind. The visitXYZKind methods + * TypeMirror types} Xyz that may have more than one + * kind, the visitXyz methods in this class delegate + * to the visitXyzAsKind method corresponding to the + * first argument's kind. The visitXyzAsKind methods * call {@link #defaultAction defaultAction}, passing their arguments * to {@code defaultAction}'s corresponding parameters. * From 32ee8faef4017b16001002cd76a22e552dcf16b4 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Sat, 21 Jan 2017 20:31:21 -0800 Subject: [PATCH 098/154] 8173024: Replace direct use of AuthResources resource bundle from jdk.security.auth Reviewed-by: weijun --- .../java.base/share/classes/module-info.java | 3 -- .../sun/security/provider/ConfigFile.java | 9 +++-- .../security/provider/SubjectCodeSource.java | 12 ++----- .../security/util/AuthResourcesProvider.java | 29 --------------- .../util/AuthResourcesProviderImpl.java | 35 ------------------- .../sun/security/util/ResourcesMgr.java | 34 +++++++++--------- .../sun/security/auth/NTDomainPrincipal.java | 10 +++--- .../security/auth/NTNumericCredential.java | 5 ++- .../classes/com/sun/security/auth/NTSid.java | 15 ++++---- .../security/auth/NTSidDomainPrincipal.java | 5 ++- .../security/auth/NTSidGroupPrincipal.java | 5 ++- .../auth/NTSidPrimaryGroupPrincipal.java | 5 ++- .../sun/security/auth/NTSidUserPrincipal.java | 5 ++- .../sun/security/auth/NTUserPrincipal.java | 10 +++--- .../auth/SolarisNumericGroupPrincipal.java | 14 ++++---- .../auth/SolarisNumericUserPrincipal.java | 8 ++--- .../sun/security/auth/SolarisPrincipal.java | 10 +++--- .../auth/UnixNumericGroupPrincipal.java | 15 ++++---- .../auth/UnixNumericUserPrincipal.java | 10 +++--- .../com/sun/security/auth/UnixPrincipal.java | 10 +++--- .../com/sun/security/auth/X500Principal.java | 6 ++-- .../security/auth/module/JndiLoginModule.java | 11 ++---- .../auth/module/KeyStoreLoginModule.java | 15 ++++---- .../security/auth/module/Krb5LoginModule.java | 9 ++--- .../security/auth/module/LdapLoginModule.java | 12 ++----- .../share/classes/module-info.java | 2 -- 26 files changed, 91 insertions(+), 213 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java delete mode 100644 jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index 1114d513687..b831d9a3549 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -310,7 +310,6 @@ module java.base { // JDK-internal service types uses jdk.internal.logger.DefaultLoggerFinder; uses sun.security.ssl.ClientKeyExchangeService; - uses sun.security.util.AuthResourcesProvider; uses sun.text.spi.JavaTimeDateTimePatternProvider; uses sun.util.spi.CalendarProvider; uses sun.util.locale.provider.LocaleDataMetaInfo; @@ -322,6 +321,4 @@ module java.base { provides java.nio.file.spi.FileSystemProvider with jdk.internal.jrtfs.JrtFileSystemProvider; - provides sun.security.util.AuthResourcesProvider with - sun.security.util.AuthResourcesProviderImpl; } diff --git a/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java b/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java index 25a975504d6..450a4292cff 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/ConfigFile.java @@ -331,9 +331,8 @@ public final class ConfigFile extends Configuration { if (debugConfig != null) { debugConfig.println(fnfe.toString()); } - throw new IOException(ResourcesMgr.getString - ("Configuration.Error.No.such.file.or.directory", - "sun.security.util.AuthResources")); + throw new IOException(ResourcesMgr.getAuthResourceString + ("Configuration.Error.No.such.file.or.directory")); } } @@ -661,8 +660,8 @@ public final class ConfigFile extends Configuration { } private IOException ioException(String resourceKey, Object... args) { - MessageFormat form = new MessageFormat(ResourcesMgr.getString - (resourceKey, "sun.security.util.AuthResources")); + MessageFormat form = new MessageFormat( + ResourcesMgr.getAuthResourceString(resourceKey)); return new IOException(form.format(args)); } } diff --git a/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java b/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java index a92ff27906a..26a3d4e3f89 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/SubjectCodeSource.java @@ -34,6 +34,7 @@ import java.lang.reflect.Constructor; import javax.security.auth.Subject; import sun.security.provider.PolicyParser.PrincipalEntry; +import sun.security.util.ResourcesMgr; /** *

This SubjectCodeSource class contains @@ -47,15 +48,6 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { private static final long serialVersionUID = 6039418085604715275L; - private static final java.util.ResourceBundle rb = - java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction() { - public java.util.ResourceBundle run() { - return (java.util.ResourceBundle.getBundle - ("sun.security.util.AuthResources")); - } - }); - private Subject subject; private LinkedList principals; private static final Class[] PARAMS = { String.class }; @@ -391,7 +383,7 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable { ListIterator li = principals.listIterator(); while (li.hasNext()) { PrincipalEntry pppe = li.next(); - returnMe = returnMe + rb.getString("NEWLINE") + + returnMe = returnMe + ResourcesMgr.getAuthResourceString("NEWLINE") + pppe.getPrincipalClass() + " " + pppe.getPrincipalName(); } diff --git a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java b/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java deleted file mode 100644 index 126286a6ff1..00000000000 --- a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 sun.security.util; - -public interface AuthResourcesProvider extends java.util.spi.ResourceBundleProvider { -} diff --git a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java b/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java deleted file mode 100644 index 6572ad0113d..00000000000 --- a/jdk/src/java.base/share/classes/sun/security/util/AuthResourcesProviderImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 sun.security.util; - -import java.util.spi.AbstractResourceBundleProvider; - -public final class AuthResourcesProviderImpl extends AbstractResourceBundleProvider - implements AuthResourcesProvider { - public AuthResourcesProviderImpl() { - super("java.class"); - } -} \ No newline at end of file diff --git a/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java b/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java index 091f2ea8e13..725d21b6eb7 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java +++ b/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java @@ -25,18 +25,22 @@ package sun.security.util; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.concurrent.ConcurrentHashMap; +import jdk.internal.misc.VM; + /** */ public class ResourcesMgr { - // intended for java.security, javax.security and sun.security resources - private static java.util.ResourceBundle bundle; + private final static String RESOURCES = "sun.security.util.Resources"; + private final static String AUTH_RESOURCES = "sun.security.util.AuthResources"; - // intended for com.sun.security resources - private static java.util.ResourceBundle altBundle; + private final static Map bundles = new ConcurrentHashMap<>(); public static String getString(String s) { - + ResourceBundle bundle = bundles.get(RESOURCES); if (bundle == null) { // only load if/when needed @@ -52,19 +56,15 @@ public class ResourcesMgr { return bundle.getString(s); } - public static String getString(String s, final String altBundleName) { - - if (altBundle == null) { - - // only load if/when needed - altBundle = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public java.util.ResourceBundle run() { - return (java.util.ResourceBundle.getBundle(altBundleName)); - } - }); + public static String getAuthResourceString(String s) { + if (VM.initLevel() == 3) { + // cannot trigger loading of any resource bundle as + // it depends on the system class loader fully initialized. + throw new InternalError("system class loader is being initialized"); } - return altBundle.getString(s); + return bundles.computeIfAbsent(AUTH_RESOURCES, ResourceBundle::getBundle) + .getString(s); } + } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java index 2b15a509e4c..ed9c2eff568 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java @@ -65,9 +65,8 @@ public class NTDomainPrincipal implements Principal, java.io.Serializable { public NTDomainPrincipal(String name) { if (name == null) { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("invalid.null.input.value", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); Object[] source = {"name"}; throw new NullPointerException(form.format(source)); } @@ -92,9 +91,8 @@ public class NTDomainPrincipal implements Principal, java.io.Serializable { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTDomainPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTDomainPrincipal.name")); Object[] source = {name}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java index 480e400ceb1..22c186a4989 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTNumericCredential.java @@ -61,9 +61,8 @@ public class NTNumericCredential { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTNumericCredential.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTNumericCredential.name")); Object[] source = {Long.toString(impersonationToken)}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java index 602e817ea72..b5e2dc7d6d6 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java @@ -70,17 +70,15 @@ public class NTSid implements Principal, java.io.Serializable { public NTSid (String stringSid) { if (stringSid == null) { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("invalid.null.input.value", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); Object[] source = {"stringSid"}; throw new NullPointerException(form.format(source)); } if (stringSid.length() == 0) { throw new IllegalArgumentException - (sun.security.util.ResourcesMgr.getString - ("Invalid.NTSid.value", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("Invalid.NTSid.value")); } sid = new String(stringSid); } @@ -101,9 +99,8 @@ public class NTSid implements Principal, java.io.Serializable { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTSid.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTSid.name")); Object[] source = {sid}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java index 2b033bbbc66..78858375a05 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidDomainPrincipal.java @@ -68,9 +68,8 @@ public class NTSidDomainPrincipal extends NTSid { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTSidDomainPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTSidDomainPrincipal.name")); Object[] source = {getName()}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java index d63451e992a..3ebd8fe996a 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidGroupPrincipal.java @@ -63,9 +63,8 @@ public class NTSidGroupPrincipal extends NTSid { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTSidGroupPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTSidGroupPrincipal.name")); Object[] source = {getName()}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java index 7a482a70c9a..7b636f42222 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidPrimaryGroupPrincipal.java @@ -65,9 +65,8 @@ public class NTSidPrimaryGroupPrincipal extends NTSid { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTSidPrimaryGroupPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTSidPrimaryGroupPrincipal.name")); Object[] source = {getName()}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java index b2e583d816c..983dc2b0590 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSidUserPrincipal.java @@ -62,9 +62,8 @@ public class NTSidUserPrincipal extends NTSid { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTSidUserPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTSidUserPrincipal.name")); Object[] source = {getName()}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java index 687682b56e1..a7c2ce97cd0 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java @@ -61,9 +61,8 @@ public class NTUserPrincipal implements Principal, java.io.Serializable { public NTUserPrincipal(String name) { if (name == null) { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("invalid.null.input.value", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); Object[] source = {"name"}; throw new NullPointerException(form.format(source)); } @@ -86,9 +85,8 @@ public class NTUserPrincipal implements Principal, java.io.Serializable { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("NTUserPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("NTUserPrincipal.name")); Object[] source = {name}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java index 0dcde2dd744..aa607107baf 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java @@ -26,6 +26,7 @@ package com.sun.security.auth; import java.security.Principal; +import static sun.security.util.ResourcesMgr.getAuthResourceString; /** * This class implements the {@code Principal} interface @@ -53,9 +54,6 @@ public class SolarisNumericGroupPrincipal implements private static final long serialVersionUID = 2345199581042573224L; - private static final java.util.ResourceBundle rb = - java.util.ResourceBundle.getBundle("sun.security.util.AuthResources"); - /** * @serial */ @@ -82,7 +80,7 @@ public class SolarisNumericGroupPrincipal implements */ public SolarisNumericGroupPrincipal(String name, boolean primaryGroup) { if (name == null) - throw new NullPointerException(rb.getString("provided.null.name")); + throw new NullPointerException(getAuthResourceString("provided.null.name")); this.name = name; this.primaryGroup = primaryGroup; @@ -146,11 +144,11 @@ public class SolarisNumericGroupPrincipal implements * {@code SolarisNumericGroupPrincipal}. */ public String toString() { - return((primaryGroup ? - rb.getString + return primaryGroup ? + getAuthResourceString ("SolarisNumericGroupPrincipal.Primary.Group.") + name : - rb.getString - ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name)); + getAuthResourceString + ("SolarisNumericGroupPrincipal.Supplementary.Group.") + name; } /** diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java index 806f62187c4..c9521105c1f 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java @@ -26,6 +26,7 @@ package com.sun.security.auth; import java.security.Principal; +import static sun.security.util.ResourcesMgr.getAuthResourceString; /** * This class implements the {@code Principal} interface @@ -52,9 +53,6 @@ public class SolarisNumericUserPrincipal implements private static final long serialVersionUID = -3178578484679887104L; - private static final java.util.ResourceBundle rb = - java.util.ResourceBundle.getBundle("sun.security.util.AuthResources"); - /** * @serial */ @@ -72,7 +70,7 @@ public class SolarisNumericUserPrincipal implements */ public SolarisNumericUserPrincipal(String name) { if (name == null) - throw new NullPointerException(rb.getString("provided.null.name")); + throw new NullPointerException(getAuthResourceString("provided.null.name")); this.name = name; } @@ -118,7 +116,7 @@ public class SolarisNumericUserPrincipal implements * {@code SolarisNumericUserPrincipal}. */ public String toString() { - return(rb.getString("SolarisNumericUserPrincipal.") + name); + return(getAuthResourceString("SolarisNumericUserPrincipal.") + name); } /** diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java index f4491db4dc8..3ec93179fba 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/SolarisPrincipal.java @@ -26,6 +26,8 @@ package com.sun.security.auth; import java.security.Principal; +import static sun.security.util.ResourcesMgr.getAuthResourceString; + /** * This class implements the {@code Principal} interface @@ -50,10 +52,6 @@ public class SolarisPrincipal implements Principal, java.io.Serializable { private static final long serialVersionUID = -7840670002439379038L; - private static final java.util.ResourceBundle rb = - java.util.ResourceBundle.getBundle("sun.security.util.AuthResources"); - - /** * @serial */ @@ -69,7 +67,7 @@ public class SolarisPrincipal implements Principal, java.io.Serializable { */ public SolarisPrincipal(String name) { if (name == null) - throw new NullPointerException(rb.getString("provided.null.name")); + throw new NullPointerException(getAuthResourceString("provided.null.name")); this.name = name; } @@ -89,7 +87,7 @@ public class SolarisPrincipal implements Principal, java.io.Serializable { * @return a string representation of this {@code SolarisPrincipal}. */ public String toString() { - return(rb.getString("SolarisPrincipal.") + name); + return(getAuthResourceString("SolarisPrincipal.") + name); } /** diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java index f71aa128c95..5498c5d5c62 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java @@ -74,9 +74,8 @@ public class UnixNumericGroupPrincipal implements public UnixNumericGroupPrincipal(String name, boolean primaryGroup) { if (name == null) { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("invalid.null.input.value", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); Object[] source = {"name"}; throw new NullPointerException(form.format(source)); } @@ -146,16 +145,14 @@ public class UnixNumericGroupPrincipal implements if (primaryGroup) { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("UnixNumericGroupPrincipal.Primary.Group.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("UnixNumericGroupPrincipal.Primary.Group.name")); Object[] source = {name}; return form.format(source); } else { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("UnixNumericGroupPrincipal.Supplementary.Group.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("UnixNumericGroupPrincipal.Supplementary.Group.name")); Object[] source = {name}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java index e07cb8ad39f..30a1e9ca81d 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java @@ -64,9 +64,8 @@ public class UnixNumericUserPrincipal implements public UnixNumericUserPrincipal(String name) { if (name == null) { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("invalid.null.input.value", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); Object[] source = {"name"}; throw new NullPointerException(form.format(source)); } @@ -116,9 +115,8 @@ public class UnixNumericUserPrincipal implements */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("UnixNumericUserPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("UnixNumericUserPrincipal.name")); Object[] source = {name}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java index 1215015330a..fde93a62a53 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java @@ -61,9 +61,8 @@ public class UnixPrincipal implements Principal, java.io.Serializable { public UnixPrincipal(String name) { if (name == null) { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("invalid.null.input.value", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); Object[] source = {"name"}; throw new NullPointerException(form.format(source)); } @@ -87,9 +86,8 @@ public class UnixPrincipal implements Principal, java.io.Serializable { */ public String toString() { java.text.MessageFormat form = new java.text.MessageFormat - (sun.security.util.ResourcesMgr.getString - ("UnixPrincipal.name", - "sun.security.util.AuthResources")); + (sun.security.util.ResourcesMgr.getAuthResourceString + ("UnixPrincipal.name")); Object[] source = {name}; return form.format(source); } diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java index a3a04a04fa1..bad8ae8addc 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/X500Principal.java @@ -27,6 +27,7 @@ package com.sun.security.auth; import java.security.Principal; import sun.security.x509.X500Name; +import static sun.security.util.ResourcesMgr.getAuthResourceString; /** * This class represents an X.500 {@code Principal}. @@ -55,9 +56,6 @@ public class X500Principal implements Principal, java.io.Serializable { private static final long serialVersionUID = -8222422609431628648L; - private static final java.util.ResourceBundle rb = - java.util.ResourceBundle.getBundle("sun.security.util.AuthResources"); - /** * @serial */ @@ -80,7 +78,7 @@ public class X500Principal implements Principal, java.io.Serializable { */ public X500Principal(String name) { if (name == null) - throw new NullPointerException(rb.getString("provided.null.name")); + throw new NullPointerException(getAuthResourceString("provided.null.name")); try { thisX500Name = new X500Name(name); diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java index 4e0225372b7..349409c579d 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/JndiLoginModule.java @@ -32,15 +32,13 @@ import javax.security.auth.spi.*; import javax.naming.*; import javax.naming.directory.*; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Map; import java.util.LinkedList; -import java.util.ResourceBundle; import com.sun.security.auth.UnixPrincipal; import com.sun.security.auth.UnixNumericUserPrincipal; import com.sun.security.auth.UnixNumericGroupPrincipal; +import static sun.security.util.ResourcesMgr.getAuthResourceString; /** @@ -153,9 +151,6 @@ import com.sun.security.auth.UnixNumericGroupPrincipal; */ public class JndiLoginModule implements LoginModule { - private static final ResourceBundle rb = - ResourceBundle.getBundle("sun.security.util.AuthResources"); - /** JNDI Provider */ public final String USER_PROVIDER = "user.provider.url"; public final String GROUP_PROVIDER = "group.provider.url"; @@ -677,9 +672,9 @@ public class JndiLoginModule implements LoginModule { Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback(protocol + " " - + rb.getString("username.")); + + getAuthResourceString("username.")); callbacks[1] = new PasswordCallback(protocol + " " + - rb.getString("password."), + getAuthResourceString("password."), false); try { diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java index 34f98390ee2..625739c1b52 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java @@ -51,6 +51,7 @@ import javax.security.auth.login.LoginException; import javax.security.auth.spi.LoginModule; import sun.security.util.Password; +import static sun.security.util.ResourcesMgr.getAuthResourceString; /** * Provides a JAAS login module that prompts for a key store alias and @@ -112,9 +113,6 @@ import sun.security.util.Password; */ public class KeyStoreLoginModule implements LoginModule { - private static final ResourceBundle rb = - ResourceBundle.getBundle("sun.security.util.AuthResources"); - /* -- Fields -- */ private static final int UNINITIALIZED = 0; @@ -132,7 +130,7 @@ public class KeyStoreLoginModule implements LoginModule { private static final TextOutputCallback bannerCallback = new TextOutputCallback (TextOutputCallback.INFORMATION, - rb.getString("Please.enter.keystore.information")); + getAuthResourceString("Please.enter.keystore.information")); private final ConfirmationCallback confirmationCallback = new ConfirmationCallback (ConfirmationCallback.INFORMATION, @@ -344,11 +342,10 @@ public class KeyStoreLoginModule implements LoginModule { NameCallback aliasCallback; if (keyStoreAlias == null || keyStoreAlias.length() == 0) { - aliasCallback = new NameCallback( - rb.getString("Keystore.alias.")); + aliasCallback = new NameCallback(getAuthResourceString("Keystore.alias.")); } else { aliasCallback = - new NameCallback(rb.getString("Keystore.alias."), + new NameCallback(getAuthResourceString("Keystore.alias."), keyStoreAlias); } @@ -360,11 +357,11 @@ public class KeyStoreLoginModule implements LoginModule { break; case NORMAL: keyPassCallback = new PasswordCallback - (rb.getString("Private.key.password.optional."), false); + (getAuthResourceString("Private.key.password.optional."), false); // fall thru case TOKEN: storePassCallback = new PasswordCallback - (rb.getString("Keystore.password."), false); + (getAuthResourceString("Keystore.password."), false); break; } prompt(aliasCallback, storePassCallback, keyPassCallback); diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java index 2aa1e8ae65d..df5733b7544 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java @@ -27,8 +27,6 @@ package com.sun.security.auth.module; import java.io.*; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.MessageFormat; import java.util.*; @@ -45,6 +43,7 @@ import sun.security.krb5.*; import sun.security.jgss.krb5.Krb5Util; import sun.security.krb5.Credentials; import sun.security.util.HexDumpEncoder; +import static sun.security.util.ResourcesMgr.getAuthResourceString; /** * This {@code LoginModule} authenticates users using @@ -419,8 +418,6 @@ public class Krb5LoginModule implements LoginModule { private static final String NAME = "javax.security.auth.login.name"; private static final String PWD = "javax.security.auth.login.password"; - private static final ResourceBundle rb = - ResourceBundle.getBundle("sun.security.util.AuthResources"); /** * Initialize this {@code LoginModule}. @@ -831,7 +828,7 @@ public class Krb5LoginModule implements LoginModule { Callback[] callbacks = new Callback[1]; MessageFormat form = new MessageFormat( - rb.getString( + getAuthResourceString( "Kerberos.username.defUsername.")); Object[] source = {defUsername}; callbacks[0] = new NameCallback(form.format(source)); @@ -886,7 +883,7 @@ public class Krb5LoginModule implements LoginModule { Callback[] callbacks = new Callback[1]; String userName = krb5PrincName.toString(); MessageFormat form = new MessageFormat( - rb.getString( + getAuthResourceString( "Kerberos.password.for.username.")); Object[] source = {userName}; callbacks[0] = new PasswordCallback( diff --git a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java index b3743a662fd..c0f5788cfa8 100644 --- a/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java +++ b/jdk/src/jdk.security.auth/share/classes/com/sun/security/auth/module/LdapLoginModule.java @@ -25,14 +25,11 @@ package com.sun.security.auth.module; -import java.security.AccessController; import java.net.SocketPermission; import java.security.Principal; -import java.security.PrivilegedAction; import java.util.Arrays; import java.util.Hashtable; import java.util.Map; -import java.util.ResourceBundle; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Set; @@ -47,6 +44,7 @@ import javax.security.auth.spi.*; import com.sun.security.auth.LdapPrincipal; import com.sun.security.auth.UserPrincipal; +import static sun.security.util.ResourcesMgr.getAuthResourceString; /** @@ -305,10 +303,6 @@ import com.sun.security.auth.UserPrincipal; */ public class LdapLoginModule implements LoginModule { - // Use the default classloader for this class to load the prompt strings. - private static final ResourceBundle rb = - ResourceBundle.getBundle("sun.security.util.AuthResources"); - // Keys to retrieve the stored username and password private static final String USERNAME_KEY = "javax.security.auth.login.name"; private static final String PASSWORD_KEY = @@ -957,8 +951,8 @@ public class LdapLoginModule implements LoginModule { "to acquire authentication information from the user"); Callback[] callbacks = new Callback[2]; - callbacks[0] = new NameCallback(rb.getString("username.")); - callbacks[1] = new PasswordCallback(rb.getString("password."), false); + callbacks[0] = new NameCallback(getAuthResourceString("username.")); + callbacks[1] = new PasswordCallback(getAuthResourceString("password."), false); try { callbackHandler.handle(callbacks); diff --git a/jdk/src/jdk.security.auth/share/classes/module-info.java b/jdk/src/jdk.security.auth/share/classes/module-info.java index 5181d23f513..4675b238e19 100644 --- a/jdk/src/jdk.security.auth/share/classes/module-info.java +++ b/jdk/src/jdk.security.auth/share/classes/module-info.java @@ -36,8 +36,6 @@ module jdk.security.auth { exports com.sun.security.auth.login; exports com.sun.security.auth.module; - uses sun.security.util.AuthResourcesProvider; - provides javax.security.auth.spi.LoginModule with com.sun.security.auth.module.Krb5LoginModule, com.sun.security.auth.module.UnixLoginModule, From dfca46bc7e09c4300e291301cacc27fa7b4dce45 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Fri, 13 Jan 2017 20:39:16 -0800 Subject: [PATCH 099/154] 8160881: Remove jvisualvm from JDK9 Reviewed-by: erikj, ihse, ksrini --- jdk/src/linux/doc/man/ja/jvisualvm.1 | 126 ------------------ jdk/src/linux/doc/man/jvisualvm.1 | 104 --------------- .../solaris/doc/sun/man/man1/ja/jvisualvm.1 | 126 ------------------ jdk/src/solaris/doc/sun/man/man1/jvisualvm.1 | 104 --------------- jdk/test/tools/launcher/VersionCheck.java | 2 - 5 files changed, 462 deletions(-) delete mode 100644 jdk/src/linux/doc/man/ja/jvisualvm.1 delete mode 100644 jdk/src/linux/doc/man/jvisualvm.1 delete mode 100644 jdk/src/solaris/doc/sun/man/man1/ja/jvisualvm.1 delete mode 100644 jdk/src/solaris/doc/sun/man/man1/jvisualvm.1 diff --git a/jdk/src/linux/doc/man/ja/jvisualvm.1 b/jdk/src/linux/doc/man/ja/jvisualvm.1 deleted file mode 100644 index a3349bfd6b1..00000000000 --- a/jdk/src/linux/doc/man/ja/jvisualvm.1 +++ /dev/null @@ -1,126 +0,0 @@ -'\" t -.\" -.\" 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. -.\" -.\" Title: jvisualvm -.\" Language: Japanese -.\" Date: 2013ǯ11·î21Æü -.\" SectDesc: Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó¥°¤ª¤è¤Ó´ÉÍý¥Ä¡¼¥ë -.\" Software: JDK 8 -.\" Arch: ÈÆÍÑ -.\" Part Number: E58103-01 -.\" Doc ID: JSSON -.\" -.if n .pl 99999 -.TH "jvisualvm" "1" "2013ǯ11·î21Æü" "JDK 8" "Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- -.SH "̾Á°" -jvisualvm \- Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò»ë³ÐŪ¤Ë¥â¥Ë¥¿¡¼¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥È¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ë¤·¤Þ¤¹¡£ -.SH "³µÍ×" -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fBjvisualvm\fR [ \fIoptions\fR ] -.fi -.if n \{\ -.RE -.\} -.PP -\fIoptions\fR -.RS 4 -¥³¥Þ¥ó¥É¹Ô¥ª¥×¥·¥ç¥ó¡£¥ª¥×¥·¥ç¥ó¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ -.RE -.SH "ÀâÌÀ" -.PP -Java VisualVM¤Ï¡¢»ØÄꤵ¤ì¤¿Java Virtual Machine (JVM)¤ÇJava¥Æ¥¯¥Î¥í¥¸¡¦¥Ù¡¼¥¹¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó(Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó)¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤È¤­¤Ë¡¢¤½¤ÎJava¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ê¾ðÊó¤òÄ󶡤¹¤ëľ´¶Åª¤Ê¥°¥é¥Õ¥£¥«¥ë¡¦¥æ¡¼¥¶¡¼¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç¤¹¡£Java VisualVM¤È¤¤¤¦Ì¾Á°¤Ï¡¢Java VisualVM¤¬JVM¥½¥Õ¥È¥¦¥§¥¢¤Ë´Ø¤¹¤ë¾ðÊó¤ò»ë³ÐŪ¤ËÄ󶡤¹¤ë¤È¤¤¤¦»ö¼Â¤ËͳÍ褷¤Æ¤¤¤Þ¤¹¡£ -.PP -Java VisualVM¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¥â¥Ë¥¿¥ê¥ó¥°¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¦¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤ò1¤Ä¤Î¥Ä¡¼¥ë¤ËÅý¹ç¤·¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢¥¹¥¿¥ó¥É¥¢¥í¥ó¡¦¥Ä¡¼¥ë\fBjmap\fR¡¢\fBjinfo\fR¡¢\fBjstat\fR¤ª¤è¤Ó\fBjstack\fR¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ëµ¡Ç½¤Î¤Û¤È¤ó¤É¤¬¡¢Java VisualVM¤ËÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£\fBjconsole\fR¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë°ìÉô¤Îµ¡Ç½¤Ê¤É¡¢Â¾¤Îµ¡Ç½¤Ï¥ª¥×¥·¥ç¥ó¤Î¥×¥é¥°¥¤¥ó¤È¤·¤ÆÄɲäǤ­¤Þ¤¹¡£ -.PP -Java VisualVM¤Ï¡¢Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î³«È¯¼Ô¤¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ò¹Ô¤Ã¤¿¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤ò¥â¥Ë¥¿¡¼¤ª¤è¤Ó²þÁ±¤·¤¿¤ê¤¹¤ë¤Î¤ËÌòΩ¤Á¤Þ¤¹¡£Java VisualVM¤ò»ÈÍѤ¹¤ë¤È¡¢³«È¯¼Ô¤Ï¥Ò¡¼¥×¡¦¥À¥ó¥×¤ÎÀ¸À®¤ª¤è¤Ó²òÀÏ¡¢¥á¥â¥ê¡¼¡¦¥ê¡¼¥¯¤ÎÆÃÄê¡¢¥¬¥Ù¡¼¥¸¡¦¥³¥ì¥¯¥·¥ç¥ó¤Î¼Â¹Ô¤ª¤è¤Ó¥â¥Ë¥¿¡¼¡¢¤ª¤è¤Ó¥á¥â¥ê¡¼¤ÈCPU¤Î´Ê°×¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¤Î¼Â¹Ô¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£¥×¥é¥°¥¤¥ó¤ÇJava VisualVM¤Îµ¡Ç½¤ò³ÈÄ¥¤Ç¤­¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢\fBjconsole\fR¥³¥Þ¥ó¥É¤Î¤Û¤È¤ó¤É¤Îµ¡Ç½¤Ï¡¢¡ÖMBean¡×¥¿¥Ö¤ª¤è¤ÓJConsole Plug\-in Wrapper¥×¥é¥°¥¤¥ó¤ò²ð¤·¤Æ»ÈÍѤǤ­¤Þ¤¹¡£É¸½à¤ÎJava VisualVM¥×¥é¥°¥¤¥ó¤Î¥«¥¿¥í¥°¤«¤éÁªÂò¤¹¤ë¤Ë¤Ï¡¢Java VisualVM¥á¥Ë¥å¡¼¤Î\fB¡Ö¥Ä¡¼¥ë¡×\fR¡¢\fB¡Ö¥×¥é¥°¥¤¥ó¡×\fR¤òÁªÂò¤·¤Þ¤¹¡£ -.PP -Java VisualVM¤òµ¯Æ°¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤Þ¤¹¡£ -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB% jvisualvm \fR - -.fi -.if n \{\ -.RE -.\} -.SH "¥ª¥×¥·¥ç¥ó" -.PP -¼¡¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢Java VisualVM¤òµ¯Æ°¤·¤¿¤È¤­¤Ë¼Â¹Ô²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£ -.PP -\-J\fIjvm_option\fR -.RS 4 -¤³¤Î\fBjvm_option\fR¤òJVM¥½¥Õ¥È¥¦¥§¥¢¤ËÅϤ·¤Þ¤¹¡£ -.RE -.SH "´ØÏ¢¹àÌÜ" -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -Java VisualVM³«È¯¼Ô¤Î¥µ¥¤¥È -http://visualvm\&.java\&.net/ -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -Java SE¥É¥­¥å¥á¥ó¥È¤ÎJava VisualVM -(http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/visualvm/index\&.html) -.RE -.br -'pl 8.5i -'bp diff --git a/jdk/src/linux/doc/man/jvisualvm.1 b/jdk/src/linux/doc/man/jvisualvm.1 deleted file mode 100644 index eae03edd804..00000000000 --- a/jdk/src/linux/doc/man/jvisualvm.1 +++ /dev/null @@ -1,104 +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. -." -." 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. -." -.TH jvisualvm 1 "10 May 2011" - -.LP -.SH "Name" -\f2jvisualvm\fP \- Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool -.LP -.SH "SYNOPSIS" -.LP -.nf -\f3 -.fl - \fP\f3jvisualvm\fP [ \f2options\fP ] -.fl -.fi - -.LP -.SH "PARAMETERS" -.LP -.LP -Options, if used, should follow immediately after the command name. Options may be in any order. For a discussion of parameters that apply to a specific option, see OPTIONS below. -.LP -.SH "DESCRIPTION" -.LP -.LP -Java VisualVM is an intuitive graphical user interface that provides detailed information about Java technology\-based applications (Java applications) while they are running on a given Java Virtual Machine (JVM(*)). The name Java VisualVM comes from the fact that Java VisualVM provides information about the JVM software \f2visually\fP. -.LP -.LP -Java VisualVM combines several monitoring, troubleshooting, and profiling utilities into a single tool. For example, most of the functionality offered by the standalone tools \f2jmap\fP, \f2jinfo\fP, \f2jstat\fP and \f2jstack\fP have been integrated into Java VisualVM. Other functionalities, such as some of those offered by the JConsole tool, can be added as optional plug\-ins. -.LP -.SH "OPTIONS" -.LP -.LP -The following option is possible when you launch Java VisualVM. -.LP -.RS 3 -.TP 3 -\-J\ -Pass this \f2\fP to the JVM software. -.RE - -.LP -.SH "USAGE" -.LP -.LP -Java VisualVM is useful to Java application developers to troubleshoot applications and to monitor and improve the applications' performance. Java VisualVM can allow developers to generate and analyse heap dumps, track down memory leaks, perform and monitor garbage collection, and perform lightweight memory and CPU profiling. Plug\-ins also exist that expand the functionality of Java VisualVM. For example, most of the functionality of the JConsole tool is available via the MBeans Tab and JConsole Plug\-in Wrapper plug\-ins. You can choose from a catalog of standard Java VisualVM plug\-ins by selecting 'Tools' | 'Plugins' in the Java VisualVM menus. -.LP -.LP -Start Java VisualVM with the following command: -.LP -.nf -\f3 -.fl -% jvisualvm \fP\f4\fP\f3 -.fl -\fP -.fi - -.LP -.SH "SEE ALSO" -.LP -.LP -For more details about Java VisualVM see the following pages. -.LP -.RS 3 -.TP 2 -o -.na -\f2Java VisualVM developers' site\fP @ -.fi -http://visualvm.java.net -.TP 2 -o -.na -\f2Java VisualVM in Java SE platform documentation\fP @ -.fi -http://download.oracle.com/javase/7/docs/technotes/guides/visualvm/index.html -.RE - -.LP -.LP -\f2(* The terms "Java Virtual Machine" and "JVM" mean a Virtual Machine for the Java platform.)\fP -.LP - diff --git a/jdk/src/solaris/doc/sun/man/man1/ja/jvisualvm.1 b/jdk/src/solaris/doc/sun/man/man1/ja/jvisualvm.1 deleted file mode 100644 index a3349bfd6b1..00000000000 --- a/jdk/src/solaris/doc/sun/man/man1/ja/jvisualvm.1 +++ /dev/null @@ -1,126 +0,0 @@ -'\" t -.\" -.\" 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. -.\" -.\" Title: jvisualvm -.\" Language: Japanese -.\" Date: 2013ǯ11·î21Æü -.\" SectDesc: Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó¥°¤ª¤è¤Ó´ÉÍý¥Ä¡¼¥ë -.\" Software: JDK 8 -.\" Arch: ÈÆÍÑ -.\" Part Number: E58103-01 -.\" Doc ID: JSSON -.\" -.if n .pl 99999 -.TH "jvisualvm" "1" "2013ǯ11·î21Æü" "JDK 8" "Java¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¡¢¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¢¥â¥Ë¥¿¥ê¥ó" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- -.SH "̾Á°" -jvisualvm \- Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò»ë³ÐŪ¤Ë¥â¥Ë¥¿¡¼¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥È¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ë¤·¤Þ¤¹¡£ -.SH "³µÍ×" -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fBjvisualvm\fR [ \fIoptions\fR ] -.fi -.if n \{\ -.RE -.\} -.PP -\fIoptions\fR -.RS 4 -¥³¥Þ¥ó¥É¹Ô¥ª¥×¥·¥ç¥ó¡£¥ª¥×¥·¥ç¥ó¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ -.RE -.SH "ÀâÌÀ" -.PP -Java VisualVM¤Ï¡¢»ØÄꤵ¤ì¤¿Java Virtual Machine (JVM)¤ÇJava¥Æ¥¯¥Î¥í¥¸¡¦¥Ù¡¼¥¹¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó(Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó)¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤È¤­¤Ë¡¢¤½¤ÎJava¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ÜºÙ¤Ê¾ðÊó¤òÄ󶡤¹¤ëľ´¶Åª¤Ê¥°¥é¥Õ¥£¥«¥ë¡¦¥æ¡¼¥¶¡¼¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç¤¹¡£Java VisualVM¤È¤¤¤¦Ì¾Á°¤Ï¡¢Java VisualVM¤¬JVM¥½¥Õ¥È¥¦¥§¥¢¤Ë´Ø¤¹¤ë¾ðÊó¤ò»ë³ÐŪ¤ËÄ󶡤¹¤ë¤È¤¤¤¦»ö¼Â¤ËͳÍ褷¤Æ¤¤¤Þ¤¹¡£ -.PP -Java VisualVM¤Ï¡¢¤¤¤¯¤Ä¤«¤Î¥â¥Ë¥¿¥ê¥ó¥°¡¢¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ª¤è¤Ó¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¡¦¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤ò1¤Ä¤Î¥Ä¡¼¥ë¤ËÅý¹ç¤·¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢¥¹¥¿¥ó¥É¥¢¥í¥ó¡¦¥Ä¡¼¥ë\fBjmap\fR¡¢\fBjinfo\fR¡¢\fBjstat\fR¤ª¤è¤Ó\fBjstack\fR¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ëµ¡Ç½¤Î¤Û¤È¤ó¤É¤¬¡¢Java VisualVM¤ËÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£\fBjconsole\fR¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤ÆÄ󶡤µ¤ì¤ë°ìÉô¤Îµ¡Ç½¤Ê¤É¡¢Â¾¤Îµ¡Ç½¤Ï¥ª¥×¥·¥ç¥ó¤Î¥×¥é¥°¥¤¥ó¤È¤·¤ÆÄɲäǤ­¤Þ¤¹¡£ -.PP -Java VisualVM¤Ï¡¢Java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î³«È¯¼Ô¤¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥È¥é¥Ö¥ë¥·¥å¡¼¥Æ¥£¥ó¥°¤ò¹Ô¤Ã¤¿¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤ò¥â¥Ë¥¿¡¼¤ª¤è¤Ó²þÁ±¤·¤¿¤ê¤¹¤ë¤Î¤ËÌòΩ¤Á¤Þ¤¹¡£Java VisualVM¤ò»ÈÍѤ¹¤ë¤È¡¢³«È¯¼Ô¤Ï¥Ò¡¼¥×¡¦¥À¥ó¥×¤ÎÀ¸À®¤ª¤è¤Ó²òÀÏ¡¢¥á¥â¥ê¡¼¡¦¥ê¡¼¥¯¤ÎÆÃÄê¡¢¥¬¥Ù¡¼¥¸¡¦¥³¥ì¥¯¥·¥ç¥ó¤Î¼Â¹Ô¤ª¤è¤Ó¥â¥Ë¥¿¡¼¡¢¤ª¤è¤Ó¥á¥â¥ê¡¼¤ÈCPU¤Î´Ê°×¥×¥í¥Õ¥¡¥¤¥ê¥ó¥°¤Î¼Â¹Ô¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£¥×¥é¥°¥¤¥ó¤ÇJava VisualVM¤Îµ¡Ç½¤ò³ÈÄ¥¤Ç¤­¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢\fBjconsole\fR¥³¥Þ¥ó¥É¤Î¤Û¤È¤ó¤É¤Îµ¡Ç½¤Ï¡¢¡ÖMBean¡×¥¿¥Ö¤ª¤è¤ÓJConsole Plug\-in Wrapper¥×¥é¥°¥¤¥ó¤ò²ð¤·¤Æ»ÈÍѤǤ­¤Þ¤¹¡£É¸½à¤ÎJava VisualVM¥×¥é¥°¥¤¥ó¤Î¥«¥¿¥í¥°¤«¤éÁªÂò¤¹¤ë¤Ë¤Ï¡¢Java VisualVM¥á¥Ë¥å¡¼¤Î\fB¡Ö¥Ä¡¼¥ë¡×\fR¡¢\fB¡Ö¥×¥é¥°¥¤¥ó¡×\fR¤òÁªÂò¤·¤Þ¤¹¡£ -.PP -Java VisualVM¤òµ¯Æ°¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤Þ¤¹¡£ -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB% jvisualvm \fR - -.fi -.if n \{\ -.RE -.\} -.SH "¥ª¥×¥·¥ç¥ó" -.PP -¼¡¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢Java VisualVM¤òµ¯Æ°¤·¤¿¤È¤­¤Ë¼Â¹Ô²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£ -.PP -\-J\fIjvm_option\fR -.RS 4 -¤³¤Î\fBjvm_option\fR¤òJVM¥½¥Õ¥È¥¦¥§¥¢¤ËÅϤ·¤Þ¤¹¡£ -.RE -.SH "´ØÏ¢¹àÌÜ" -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -Java VisualVM³«È¯¼Ô¤Î¥µ¥¤¥È -http://visualvm\&.java\&.net/ -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -Java SE¥É¥­¥å¥á¥ó¥È¤ÎJava VisualVM -(http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/visualvm/index\&.html) -.RE -.br -'pl 8.5i -'bp diff --git a/jdk/src/solaris/doc/sun/man/man1/jvisualvm.1 b/jdk/src/solaris/doc/sun/man/man1/jvisualvm.1 deleted file mode 100644 index eae03edd804..00000000000 --- a/jdk/src/solaris/doc/sun/man/man1/jvisualvm.1 +++ /dev/null @@ -1,104 +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. -." -." 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. -." -.TH jvisualvm 1 "10 May 2011" - -.LP -.SH "Name" -\f2jvisualvm\fP \- Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool -.LP -.SH "SYNOPSIS" -.LP -.nf -\f3 -.fl - \fP\f3jvisualvm\fP [ \f2options\fP ] -.fl -.fi - -.LP -.SH "PARAMETERS" -.LP -.LP -Options, if used, should follow immediately after the command name. Options may be in any order. For a discussion of parameters that apply to a specific option, see OPTIONS below. -.LP -.SH "DESCRIPTION" -.LP -.LP -Java VisualVM is an intuitive graphical user interface that provides detailed information about Java technology\-based applications (Java applications) while they are running on a given Java Virtual Machine (JVM(*)). The name Java VisualVM comes from the fact that Java VisualVM provides information about the JVM software \f2visually\fP. -.LP -.LP -Java VisualVM combines several monitoring, troubleshooting, and profiling utilities into a single tool. For example, most of the functionality offered by the standalone tools \f2jmap\fP, \f2jinfo\fP, \f2jstat\fP and \f2jstack\fP have been integrated into Java VisualVM. Other functionalities, such as some of those offered by the JConsole tool, can be added as optional plug\-ins. -.LP -.SH "OPTIONS" -.LP -.LP -The following option is possible when you launch Java VisualVM. -.LP -.RS 3 -.TP 3 -\-J\ -Pass this \f2\fP to the JVM software. -.RE - -.LP -.SH "USAGE" -.LP -.LP -Java VisualVM is useful to Java application developers to troubleshoot applications and to monitor and improve the applications' performance. Java VisualVM can allow developers to generate and analyse heap dumps, track down memory leaks, perform and monitor garbage collection, and perform lightweight memory and CPU profiling. Plug\-ins also exist that expand the functionality of Java VisualVM. For example, most of the functionality of the JConsole tool is available via the MBeans Tab and JConsole Plug\-in Wrapper plug\-ins. You can choose from a catalog of standard Java VisualVM plug\-ins by selecting 'Tools' | 'Plugins' in the Java VisualVM menus. -.LP -.LP -Start Java VisualVM with the following command: -.LP -.nf -\f3 -.fl -% jvisualvm \fP\f4\fP\f3 -.fl -\fP -.fi - -.LP -.SH "SEE ALSO" -.LP -.LP -For more details about Java VisualVM see the following pages. -.LP -.RS 3 -.TP 2 -o -.na -\f2Java VisualVM developers' site\fP @ -.fi -http://visualvm.java.net -.TP 2 -o -.na -\f2Java VisualVM in Java SE platform documentation\fP @ -.fi -http://download.oracle.com/javase/7/docs/technotes/guides/visualvm/index.html -.RE - -.LP -.LP -\f2(* The terms "Java Virtual Machine" and "JVM" mean a Virtual Machine for the Java platform.)\fP -.LP - diff --git a/jdk/test/tools/launcher/VersionCheck.java b/jdk/test/tools/launcher/VersionCheck.java index aa507b6da43..c199e1ed88f 100644 --- a/jdk/test/tools/launcher/VersionCheck.java +++ b/jdk/test/tools/launcher/VersionCheck.java @@ -58,7 +58,6 @@ public class VersionCheck extends TestHelper { "jmc", "jmc.ini", "jweblauncher", - "jvisualvm", "packager", "ssvagent", "unpack200", @@ -100,7 +99,6 @@ public class VersionCheck extends TestHelper { "jstat", "jstatd", "jweblauncher", - "jvisualvm", "keytool", "kinit", "klist", From 48706a1a2a4fceb6ab59bf564c85ca7881969cfe Mon Sep 17 00:00:00 2001 From: John Jiang Date: Mon, 16 Jan 2017 15:16:10 +0800 Subject: [PATCH 100/154] 8167146: sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java failed with "Remote host terminated the handshake" The fix takes the server to accept request after the client threads start, and also deal with possible timeout issue. Reviewed-by: xuelei --- .../security/pkcs11/sslecc/CipherTest.java | 13 ++++++-- .../security/pkcs11/sslecc/JSSEClient.java | 33 ++++++++++++++----- .../security/pkcs11/sslecc/JSSEServer.java | 33 ++++++++++++++----- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java b/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java index f118d76d5c5..5f7a01c5ef8 100644 --- a/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java +++ b/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ import java.util.concurrent.*; import java.security.*; import java.security.cert.*; -import java.security.cert.Certificate; import javax.net.ssl.*; @@ -61,6 +60,8 @@ public class CipherTest { private static PeerFactory peerFactory; + static final CountDownLatch clientCondition = new CountDownLatch(1); + static abstract class Server implements Runnable { final CipherTest cipherTest; @@ -313,6 +314,10 @@ public class CipherTest { } threads[i].start(); } + + // The client threads are ready. + clientCondition.countDown(); + try { for (int i = 0; i < THREADS; i++) { threads[i].join(); @@ -367,6 +372,10 @@ public class CipherTest { try { runTest(params); System.out.println("Passed " + params); + } catch (SocketTimeoutException ste) { + System.out.println("The client connects to the server timeout, " + + "so ignore the test."); + break; } catch (Exception e) { cipherTest.setFailed(); System.out.println("** Failed " + params + "**"); diff --git a/jdk/test/sun/security/pkcs11/sslecc/JSSEClient.java b/jdk/test/sun/security/pkcs11/sslecc/JSSEClient.java index 18bab968f6c..52bc2e2c118 100644 --- a/jdk/test/sun/security/pkcs11/sslecc/JSSEClient.java +++ b/jdk/test/sun/security/pkcs11/sslecc/JSSEClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,7 @@ import java.io.*; import java.net.*; -import java.util.*; -import java.security.*; -import java.security.cert.*; import java.security.cert.Certificate; import javax.net.ssl.*; @@ -46,10 +43,30 @@ class JSSEClient extends CipherTest.Client { SSLSocket socket = null; try { keyManager.setAuthType(params.clientAuth); - sslContext.init(new KeyManager[] {keyManager}, new TrustManager[] {cipherTest.trustManager}, cipherTest.secureRandom); - SSLSocketFactory factory = (SSLSocketFactory)sslContext.getSocketFactory(); - socket = (SSLSocket)factory.createSocket("127.0.0.1", cipherTest.serverPort); - socket.setSoTimeout(cipherTest.TIMEOUT); + sslContext.init( + new KeyManager[] { keyManager }, + new TrustManager[] { CipherTest.trustManager }, + CipherTest.secureRandom); + SSLSocketFactory factory + = (SSLSocketFactory) sslContext.getSocketFactory(); + + socket = (SSLSocket) factory.createSocket(); + try { + socket.connect(new InetSocketAddress("127.0.0.1", + CipherTest.serverPort), 15000); + } catch (IOException ioe) { + // The server side may be impacted by naughty test cases or + // third party routines, and cannot accept connections. + // + // Just ignore the test if the connection cannot be + // established. + System.out.println( + "Cannot make a connection in 15 seconds. " + + "Ignore in client side."); + return; + } + + socket.setSoTimeout(CipherTest.TIMEOUT); socket.setEnabledCipherSuites(new String[] {params.cipherSuite}); socket.setEnabledProtocols(new String[] {params.protocol}); InputStream in = socket.getInputStream(); diff --git a/jdk/test/sun/security/pkcs11/sslecc/JSSEServer.java b/jdk/test/sun/security/pkcs11/sslecc/JSSEServer.java index 90c55e68e4a..bd933919af2 100644 --- a/jdk/test/sun/security/pkcs11/sslecc/JSSEServer.java +++ b/jdk/test/sun/security/pkcs11/sslecc/JSSEServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,8 +24,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.SocketTimeoutException; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocket; @@ -40,24 +43,37 @@ class JSSEServer extends CipherTest.Server { JSSEServer(CipherTest cipherTest) throws Exception { super(cipherTest); SSLContext serverContext = SSLContext.getInstance("TLS"); - serverContext.init(new KeyManager[] {cipherTest.keyManager}, new TrustManager[] {cipherTest.trustManager}, cipherTest.secureRandom); + serverContext.init( + new KeyManager[] { CipherTest.keyManager }, + new TrustManager[] { CipherTest.trustManager }, + CipherTest.secureRandom); SSLServerSocketFactory factory = (SSLServerSocketFactory)serverContext.getServerSocketFactory(); serverSocket = (SSLServerSocket)factory.createServerSocket(0); - cipherTest.serverPort = serverSocket.getLocalPort(); + serverSocket.setSoTimeout(CipherTest.TIMEOUT); + CipherTest.serverPort = serverSocket.getLocalPort(); serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites()); serverSocket.setWantClientAuth(true); } @Override public void run() { - System.out.println("JSSE Server listening on port " + cipherTest.serverPort); + System.out.println("JSSE Server listening on port " + CipherTest.serverPort); Executor exec = Executors.newFixedThreadPool (CipherTest.THREADS, DaemonThreadFactory.INSTANCE); + try { + if (!CipherTest.clientCondition.await(CipherTest.TIMEOUT, + TimeUnit.MILLISECONDS)) { + System.out.println( + "The client is not the expected one or timeout. " + + "Ignore in server side."); + return; + } + while (true) { final SSLSocket socket = (SSLSocket)serverSocket.accept(); - socket.setSoTimeout(cipherTest.TIMEOUT); + socket.setSoTimeout(CipherTest.TIMEOUT); Runnable r = new Runnable() { @Override public void run() { @@ -86,11 +102,12 @@ class JSSEServer extends CipherTest.Server { }; exec.execute(r); } - } catch (IOException e) { + } catch (SocketTimeoutException ste) { + System.out.println("The server got timeout for waiting for the connection, " + + "so ignore the test."); + } catch (Exception e) { cipherTest.setFailed(); e.printStackTrace(); - // } } - } From e8145f87397f263f543b3893e40e43a5a2d8a53a Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 16 Jan 2017 09:53:34 +0100 Subject: [PATCH 101/154] 8171386: jshell tool: paging of javadoc output broken on Windows Fixing detection of console window size. Reviewed-by: rfield --- .../windows/native/lible/WindowsTerminal.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp b/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp index b6c0bc62638..f0299ee8a02 100644 --- a/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp +++ b/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp @@ -102,26 +102,26 @@ JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getConsoleOutputC JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getWindowsTerminalWidth (JNIEnv *, jobject) { - HANDLE hStdIn; - if ((hStdIn = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) { + HANDLE hStdOut; + if ((hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)) == INVALID_HANDLE_VALUE) { return -1; } CONSOLE_SCREEN_BUFFER_INFO info; - if (! GetConsoleScreenBufferInfo(hStdIn, &info)) { + if (! GetConsoleScreenBufferInfo(hStdOut, &info)) { return -1; } - return info.dwSize.X; + return info.srWindow.Right - info.srWindow.Left; } JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getWindowsTerminalHeight (JNIEnv *, jobject) { - HANDLE hStdIn; - if ((hStdIn = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) { + HANDLE hStdOut; + if ((hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)) == INVALID_HANDLE_VALUE) { return -1; } CONSOLE_SCREEN_BUFFER_INFO info; - if (! GetConsoleScreenBufferInfo(hStdIn, &info)) { + if (! GetConsoleScreenBufferInfo(hStdOut, &info)) { return -1; } - return info.dwSize.Y; + return info.srWindow.Bottom - info.srWindow.Top + 1; } From a019f44ab1a0ea3c722803e8d908f51e178058d4 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Mon, 16 Jan 2017 12:32:46 +0100 Subject: [PATCH 102/154] 8172842: Invoke lldb with --batch from failure handler Reviewed-by: erikj, dsamersoff --- test/failure_handler/src/share/conf/mac.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/failure_handler/src/share/conf/mac.properties b/test/failure_handler/src/share/conf/mac.properties index 0e962f63c8d..de14390fcb1 100644 --- a/test/failure_handler/src/share/conf/mac.properties +++ b/test/failure_handler/src/share/conf/mac.properties @@ -64,7 +64,7 @@ native.stack.args=-c\0DevToolsSecurity --status | grep -q enabled && lldb -o 'at native.core.app=bash native.core.delimiter=\0 native.core.args=-c\0gcore -o ./core.%p %p || \ - (DevToolsSecurity --status | grep -q enabled && lldb -o 'attach %p' -o 'process save-core core.%p' -o 'detach' -o 'quit') + (DevToolsSecurity --status | grep -q enabled && lldb --batch -o 'attach %p' -o 'process save-core core.%p' -o 'detach' -o 'quit') native.core.params.timeout=3600000 ################################################################################ # environment info to gather From d130871ed3b3aab0adc1967288efb93da7b9ec07 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 16 Jan 2017 13:50:59 +0100 Subject: [PATCH 103/154] 8172714: Remove unused and unexpanded variables from spec.gmk.in Reviewed-by: erikj, tbell --- common/autoconf/spec.gmk.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index baccc4ffc0d..471f9096e01 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -274,8 +274,6 @@ JAVADOC_OUTPUTDIR = $(DOCS_IMAGE_DIR) CONFIGURESUPPORT_OUTPUTDIR:=@CONFIGURESUPPORT_OUTPUTDIR@ BUILDJDK_OUTPUTDIR=$(BUILD_OUTPUT)/buildjdk -BUILD_HOTSPOT=@BUILD_HOTSPOT@ - BUILD_FAILURE_HANDLER := @BUILD_FAILURE_HANDLER@ ENABLE_GENERATE_CLASSLIST := @ENABLE_GENERATE_CLASSLIST@ @@ -642,7 +640,6 @@ NAWK:=@NAWK@ NICE:=@NICE@ PATCH:=@PATCH@ PRINTF:=@PRINTF@ -PWD:=@THEPWDCMD@ RM:=@RM@ RMDIR:=@RMDIR@ SED:=@SED@ From e036a82aa25ba1474fa663d294c62edaa24a1de8 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 16 Jan 2017 13:53:14 +0100 Subject: [PATCH 104/154] 8162750: -D__solaris__ added twice Reviewed-by: erikj --- common/autoconf/flags.m4 | 5 ----- common/autoconf/generated-configure.sh | 12 +----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index f52d76762ef..e5ae8eed060 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -815,11 +815,6 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER], $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__" fi - if test "x$OPENJDK_TARGET_OS" = xsolaris; then - $2CFLAGS_JDK="${$2CFLAGS_JDK} -D__solaris__" - $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__" - fi - $2CFLAGS_JDK="${$2CFLAGS_JDK} ${$2EXTRA_CFLAGS}" $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2EXTRA_CXXFLAGS}" $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$2EXTRA_LDFLAGS}" diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index fb03dcc3108..006fff3175c 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5180,7 +5180,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=1484228046 +DATE_WHEN_GENERATED=1484571183 ############################################################################### # @@ -49945,11 +49945,6 @@ $as_echo "$supports" >&6; } CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__" fi - if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__" - CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__" - fi - CFLAGS_JDK="${CFLAGS_JDK} ${EXTRA_CFLAGS}" CXXFLAGS_JDK="${CXXFLAGS_JDK} ${EXTRA_CXXFLAGS}" LDFLAGS_JDK="${LDFLAGS_JDK} ${EXTRA_LDFLAGS}" @@ -50768,11 +50763,6 @@ $as_echo "$supports" >&6; } OPENJDK_BUILD_CXXFLAGS_JDK="${OPENJDK_BUILD_CXXFLAGS_JDK} -D__solaris__" fi - if test "x$OPENJDK_TARGET_OS" = xsolaris; then - OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -D__solaris__" - OPENJDK_BUILD_CXXFLAGS_JDK="${OPENJDK_BUILD_CXXFLAGS_JDK} -D__solaris__" - fi - OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} ${OPENJDK_BUILD_EXTRA_CFLAGS}" OPENJDK_BUILD_CXXFLAGS_JDK="${OPENJDK_BUILD_CXXFLAGS_JDK} ${OPENJDK_BUILD_EXTRA_CXXFLAGS}" OPENJDK_BUILD_LDFLAGS_JDK="${OPENJDK_BUILD_LDFLAGS_JDK} ${OPENJDK_BUILD_EXTRA_LDFLAGS}" From f2be16d5f3e56ab4e23e47dc90809dcc59b71e40 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Mon, 16 Jan 2017 21:17:24 +0800 Subject: [PATCH 105/154] 8156595: java/io/pathNames/GeneralWin32.java fail intermittently on windows-x64 Reviewed-by: psandoz --- jdk/test/ProblemList.txt | 2 -- jdk/test/java/io/pathNames/General.java | 8 +++++-- jdk/test/java/io/pathNames/GeneralWin32.java | 24 ++++++++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 335323c89d2..18cc959c84e 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -141,8 +141,6 @@ java/lang/management/MemoryMXBean/PendingAllGC.sh 8158837 generic- # jdk_io -java/io/pathNames/GeneralWin32.java 8156595 windows-all - ############################################################################ # jdk_management diff --git a/jdk/test/java/io/pathNames/General.java b/jdk/test/java/io/pathNames/General.java index 6df31d2668f..0583d29194d 100644 --- a/jdk/test/java/io/pathNames/General.java +++ b/jdk/test/java/io/pathNames/General.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ public class General { private static int gensymCounter = 0; protected static final String userDir = System.getProperty("user.dir"); + protected static final String workSubDir = "tmp"; protected static String baseDir = null; protected static String relative = null; @@ -60,7 +61,10 @@ public class General { * direct or indirect calling) in a whole test. */ protected static void initTestData(int depth) throws IOException { - File parent = new File(userDir); + File parent = new File(userDir + File.separator + workSubDir); + if (!parent.mkdir()) { + throw new IOException("Fail to create directory: " + parent); + } for (int i = 0; i < depth; i++) { File tmp = new File(parent, gensym()); tmp.createNewFile(); diff --git a/jdk/test/java/io/pathNames/GeneralWin32.java b/jdk/test/java/io/pathNames/GeneralWin32.java index 4644a6fd0e2..6ee64fd86f0 100644 --- a/jdk/test/java/io/pathNames/GeneralWin32.java +++ b/jdk/test/java/io/pathNames/GeneralWin32.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,8 @@ public class GeneralWin32 extends General { private static void checkCaseLookup() throws IOException { /* Use long names here to avoid 8.3 format, which Samba servers often force to lowercase */ - File d = new File("XyZzY0123", "FOO_bar_BAZ"); + File r = new File (workSubDir, "XyZzY0123"); + File d = new File(r, "FOO_bar_BAZ"); File f = new File(d, "GLORPified"); if (!f.exists()) { if (!d.exists()) { @@ -74,9 +75,9 @@ public class GeneralWin32 extends General { case of filenames, rather than just using the input case */ File y = new File(userDir, f.getPath()); String ans = y.getPath(); - check(ans, "XyZzY0123\\FOO_bar_BAZ\\GLORPified"); - check(ans, "xyzzy0123\\foo_bar_baz\\glorpified"); - check(ans, "XYZZY0123\\FOO_BAR_BAZ\\GLORPIFIED"); + check(ans, workSubDir + File.separator + "XyZzY0123\\FOO_bar_BAZ\\GLORPified"); + check(ans, workSubDir + File.separator + "xyzzy0123\\foo_bar_baz\\glorpified"); + check(ans, workSubDir + File.separator + "XYZZY0123\\FOO_BAR_BAZ\\GLORPIFIED"); } private static void checkWild(File f) throws Exception { @@ -125,20 +126,19 @@ public class GeneralWin32 extends General { throw new RuntimeException("Can't find an active drive"); } - private static void checkDrive(int depth, char drive, boolean exists) + private static void checkDrive(int depth, String drive, boolean exists) throws Exception { - String d = drive + ":"; - File df = new File(d); - String ans = exists ? df.getAbsolutePath() : d; + File df = new File(drive); + String ans = exists ? df.getAbsolutePath() : drive; if (!ans.endsWith("\\")) ans = ans + "\\"; - checkNames(depth, false, ans, d); + checkNames(depth, false, ans, drive); } private static void checkDrivePaths(int depth) throws Exception { - checkDrive(depth, findActiveDrive(), true); - checkDrive(depth, findInactiveDrive(), false); + checkDrive(depth, findActiveDrive() + ":" + workSubDir + File.separator, true); + checkDrive(depth, findInactiveDrive() + ":", false); } From 56e387c99e3fffa83ca96b32274080ae84f5d8ca Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Mon, 16 Jan 2017 16:37:47 +0300 Subject: [PATCH 106/154] 8165705: Robot.createScreenCapture produces black screenshot on Oracle Linux 7.1 Reviewed-by: serb --- .../unix/classes/sun/awt/X11/XRobotPeer.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java index c300431cf88..0dbd8e00e9b 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java @@ -27,7 +27,7 @@ package sun.awt.X11; import java.awt.*; import java.awt.peer.*; import java.security.AccessController; -import java.security.PrivilegedAction; +import sun.security.action.GetPropertyAction; import sun.awt.AWTAccessor; import sun.awt.SunToolkit; @@ -40,11 +40,11 @@ class XRobotPeer implements RobotPeer { static final boolean tryGtk; static { loadNativeLibraries(); - tryGtk = AccessController.doPrivileged((PrivilegedAction)() - -> Boolean.getBoolean("awt.robot.gtk")); + tryGtk = Boolean.parseBoolean( + AccessController.doPrivileged( + new GetPropertyAction("awt.robot.gtk", "true") + )); } - - private static boolean isGtkSupported = false; private static volatile boolean useGtk; private X11GraphicsConfig xgc = null; From 3f3fa9260c4d6bcb1c949777f21b8fe54cfaa83d Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 16 Jan 2017 15:44:30 +0100 Subject: [PATCH 107/154] 8169631: [JAXP] XALAN: transformation of XML via namespace-unaware SAX input yields a different result than namespace-unaware DOM input Reviewed-by: joehw --- .../xalan/internal/xsltc/trax/DOM2SAX.java | 106 +--- .../xml/internal/dtm/ref/sax2dtm/SAX2DTM.java | 492 +++++++----------- .../internal/dtm/ref/sax2dtm/SAX2DTM2.java | 426 +++++++-------- .../unittest/transform/TransformerTest.java | 293 ++++++++--- 4 files changed, 611 insertions(+), 706 deletions(-) diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java index 0ed98009a06..5b2893d4188 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2SAX.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. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,20 +17,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * $Id: DOM2SAX.java,v 1.2.4.1 2005/09/06 11:52:46 pvedula Exp $ - */ - package com.sun.org.apache.xalan.internal.xsltc.trax; import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl; import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Stack; -import java.util.Vector; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.xml.sax.ContentHandler; @@ -58,7 +54,7 @@ public class DOM2SAX implements XMLReader, Locator { private ContentHandler _sax = null; private LexicalHandler _lex = null; private SAXImpl _saxImpl = null; - private Map _nsPrefixes = new HashMap<>(); + private Map> _nsPrefixes = new HashMap<>(); public DOM2SAX(Node root) { _dom = root; @@ -73,7 +69,7 @@ public class DOM2SAX implements XMLReader, Locator { { _sax = handler; if (handler instanceof LexicalHandler) { - _lex = (LexicalHandler) handler; + _lex = (LexicalHandler)handler; } if (handler instanceof SAXImpl) { @@ -90,25 +86,22 @@ public class DOM2SAX implements XMLReader, Locator { throws SAXException { boolean pushed = true; - Stack uriStack = _nsPrefixes.get(prefix); + Stack uriStack = _nsPrefixes.get(prefix); if (uriStack != null) { if (uriStack.isEmpty()) { _sax.startPrefixMapping(prefix, uri); uriStack.push(uri); - } - else { - final String lastUri = (String) uriStack.peek(); + } else { + final String lastUri = uriStack.peek(); if (!lastUri.equals(uri)) { _sax.startPrefixMapping(prefix, uri); uriStack.push(uri); - } - else { + } else { pushed = false; } } - } - else { + } else { _sax.startPrefixMapping(prefix, uri); _nsPrefixes.put(prefix, uriStack = new Stack()); uriStack.push(uri); @@ -123,7 +116,7 @@ public class DOM2SAX implements XMLReader, Locator { private void endPrefixMapping(String prefix) throws SAXException { - final Stack uriStack = _nsPrefixes.get(prefix); + final Stack uriStack = _nsPrefixes.get(prefix); if (uriStack != null) { _sax.endPrefixMapping(prefix); @@ -131,22 +124,6 @@ public class DOM2SAX implements XMLReader, Locator { } } - /** - * If the DOM was created using a DOM 1.0 API, the local name may be - * null. If so, get the local name from the qualified name before - * generating the SAX event. - */ - private static String getLocalName(Node node) { - final String localName = node.getLocalName(); - - if (localName == null) { - final String qname = node.getNodeName(); - final int col = qname.lastIndexOf(':'); - return (col > 0) ? qname.substring(col + 1) : qname; - } - return localName; - } - public void parse(InputSource unused) throws IOException, SAXException { parse(_dom); } @@ -173,8 +150,8 @@ public class DOM2SAX implements XMLReader, Locator { * declarations. */ private void parse(Node node) throws IOException, SAXException { - Node first = null; - if (node == null) return; + if (node == null) + return; switch (node.getNodeType()) { case Node.ATTRIBUTE_NODE: // handled by ELEMENT_NODE @@ -198,7 +175,6 @@ public class DOM2SAX implements XMLReader, Locator { _sax.characters(cdata.toCharArray(), 0, cdata.length()); } break; - case Node.COMMENT_NODE: // should be handled!!! if (_lex != null) { final String value = node.getNodeValue(); @@ -216,10 +192,9 @@ public class DOM2SAX implements XMLReader, Locator { } _sax.endDocument(); break; - case Node.ELEMENT_NODE: String prefix; - Vector pushedPrefixes = new Vector(); + ArrayList pushedPrefixes = new ArrayList<>(); final AttributesImpl attrs = new AttributesImpl(); final NamedNodeMap map = node.getAttributes(); final int length = map.getLength(); @@ -235,7 +210,7 @@ public class DOM2SAX implements XMLReader, Locator { final int colon = qnameAttr.lastIndexOf(':'); prefix = (colon > 0) ? qnameAttr.substring(colon + 1) : EMPTYSTRING; if (startPrefixMapping(prefix, uriAttr)) { - pushedPrefixes.addElement(prefix); + pushedPrefixes.add(prefix); } } } @@ -248,27 +223,25 @@ public class DOM2SAX implements XMLReader, Locator { // Ignore NS declarations here if (!qnameAttr.startsWith(XMLNS_PREFIX)) { final String uriAttr = attr.getNamespaceURI(); - final String localNameAttr = getLocalName(attr); // Uri may be implicitly declared if (uriAttr != null) { final int colon = qnameAttr.lastIndexOf(':'); if (colon > 0) { prefix = qnameAttr.substring(0, colon); - } - else { + } else { // If no prefix for this attr, we need to create // one because we cannot use the default ns prefix = BasisLibrary.generatePrefix(); qnameAttr = prefix + ':' + qnameAttr; } if (startPrefixMapping(prefix, uriAttr)) { - pushedPrefixes.addElement(prefix); + pushedPrefixes.add(prefix); } } // Add attribute to list - attrs.addAttribute(attr.getNamespaceURI(), getLocalName(attr), + attrs.addAttribute(attr.getNamespaceURI(), attr.getLocalName(), qnameAttr, "CDATA", attr.getNodeValue()); } } @@ -276,22 +249,21 @@ public class DOM2SAX implements XMLReader, Locator { // Now process the element itself final String qname = node.getNodeName(); final String uri = node.getNamespaceURI(); - final String localName = getLocalName(node); + final String localName = node.getLocalName(); - // Uri may be implicitly declared + // URI may be implicitly declared if (uri != null) { final int colon = qname.lastIndexOf(':'); prefix = (colon > 0) ? qname.substring(0, colon) : EMPTYSTRING; if (startPrefixMapping(prefix, uri)) { - pushedPrefixes.addElement(prefix); + pushedPrefixes.add(prefix); } } // Generate SAX event to start element if (_saxImpl != null) { _saxImpl.startElement(uri, localName, qname, attrs, node); - } - else { + } else { _sax.startElement(uri, localName, qname, attrs); } @@ -308,15 +280,13 @@ public class DOM2SAX implements XMLReader, Locator { // Generate endPrefixMapping() for all pushed prefixes final int nPushedPrefixes = pushedPrefixes.size(); for (int i = 0; i < nPushedPrefixes; i++) { - endPrefixMapping((String) pushedPrefixes.elementAt(i)); + endPrefixMapping(pushedPrefixes.get(i)); } break; - case Node.PROCESSING_INSTRUCTION_NODE: _sax.processingInstruction(node.getNodeName(), node.getNodeValue()); break; - case Node.TEXT_NODE: final String data = node.getNodeValue(); _sax.characters(data.toCharArray(), 0, data.length()); @@ -449,36 +419,4 @@ public class DOM2SAX implements XMLReader, Locator { public String getSystemId() { return null; } - - // Debugging - private String getNodeTypeFromCode(short code) { - String retval = null; - switch (code) { - case Node.ATTRIBUTE_NODE : - retval = "ATTRIBUTE_NODE"; break; - case Node.CDATA_SECTION_NODE : - retval = "CDATA_SECTION_NODE"; break; - case Node.COMMENT_NODE : - retval = "COMMENT_NODE"; break; - case Node.DOCUMENT_FRAGMENT_NODE : - retval = "DOCUMENT_FRAGMENT_NODE"; break; - case Node.DOCUMENT_NODE : - retval = "DOCUMENT_NODE"; break; - case Node.DOCUMENT_TYPE_NODE : - retval = "DOCUMENT_TYPE_NODE"; break; - case Node.ELEMENT_NODE : - retval = "ELEMENT_NODE"; break; - case Node.ENTITY_NODE : - retval = "ENTITY_NODE"; break; - case Node.ENTITY_REFERENCE_NODE : - retval = "ENTITY_REFERENCE_NODE"; break; - case Node.NOTATION_NODE : - retval = "NOTATION_NODE"; break; - case Node.PROCESSING_INSTRUCTION_NODE : - retval = "PROCESSING_INSTRUCTION_NODE"; break; - case Node.TEXT_NODE: - retval = "TEXT_NODE"; break; - } - return retval; - } } diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java index a87f26aa76e..9dd0491b69c 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -17,14 +17,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * $Id: SAX2DTM.java,v 1.2.4.1 2005/09/15 08:15:11 suresh_emailid Exp $ - */ + package com.sun.org.apache.xml.internal.dtm.ref.sax2dtm; - -import com.sun.org.apache.xml.internal.dtm.*; -import com.sun.org.apache.xml.internal.dtm.ref.*; +import com.sun.org.apache.xml.internal.dtm.DTM; +import com.sun.org.apache.xml.internal.dtm.DTMManager; +import com.sun.org.apache.xml.internal.dtm.DTMWSFilter; +import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBaseIterators; +import com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault; +import com.sun.org.apache.xml.internal.dtm.ref.DTMStringPool; +import com.sun.org.apache.xml.internal.dtm.ref.DTMTreeWalker; +import com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource; +import com.sun.org.apache.xml.internal.dtm.ref.NodeLocator; import com.sun.org.apache.xml.internal.res.XMLErrorResources; import com.sun.org.apache.xml.internal.res.XMLMessages; import com.sun.org.apache.xml.internal.utils.FastStringBuffer; @@ -36,13 +40,23 @@ import com.sun.org.apache.xml.internal.utils.SystemIDResolver; import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException; import com.sun.org.apache.xml.internal.utils.XMLString; import com.sun.org.apache.xml.internal.utils.XMLStringFactory; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Vector; import javax.xml.transform.Source; import javax.xml.transform.SourceLocator; -import org.xml.sax.*; -import org.xml.sax.ext.*; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.DTDHandler; +import org.xml.sax.EntityResolver; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.ext.DeclHandler; +import org.xml.sax.ext.LexicalHandler; /** * This class implements a DTM that tends to be optimized more for speed than @@ -82,7 +96,6 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * Made protected rather than private so SAX2RTFDTM can access it. */ - //private FastStringBuffer m_chars = new FastStringBuffer(13, 13); protected FastStringBuffer m_chars; /** This vector holds offset and length data. @@ -102,8 +115,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators /** Namespace support, only relevent at construction time. * Made protected rather than private so SAX2RTFDTM can access it. */ - transient protected java.util.Vector m_prefixMappings = - new java.util.Vector(); + transient protected Vector m_prefixMappings = new Vector<>(); /** Namespace support, only relevent at construction time. * Made protected rather than private so SAX2RTFDTM can access it. @@ -164,7 +176,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * Vector of entities. Each record is composed of four Strings: * publicId, systemID, notationName, and name. */ - private Vector m_entities = null; + private ArrayList m_entities = null; /** m_entities public ID offset. */ private static final int ENTITY_FIELD_PUBLICID = 0; @@ -196,13 +208,15 @@ public class SAX2DTM extends DTMDefaultBaseIterators */ protected boolean m_useSourceLocationProperty = false; - /** Made protected for access by SAX2RTFDTM. + /** Made protected for access by SAX2RTFDTM. */ protected StringVector m_sourceSystemId; - /** Made protected for access by SAX2RTFDTM. + + /** Made protected for access by SAX2RTFDTM. */ protected IntVector m_sourceLine; - /** Made protected for access by SAX2RTFDTM. + + /** Made protected for access by SAX2RTFDTM. */ protected IntVector m_sourceColumn; @@ -252,23 +266,19 @@ public class SAX2DTM extends DTMDefaultBaseIterators boolean usePrevsib, boolean newNameTable) { - super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory, doIndexing, blocksize, usePrevsib, newNameTable); // %OPT% Use smaller sizes for all internal storage units when // the blocksize is small. This reduces the cost of creating an RTF. - if (blocksize <= 64) - { + if (blocksize <= 64) { m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS_SMALL); m_dataOrQName = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS_SMALL); m_valuesOrPrefixes = new DTMStringPool(16); m_chars = new FastStringBuffer(7, 10); m_contextIndexes = new IntStack(4); m_parents = new IntStack(4); - } - else - { + } else { m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS); m_dataOrQName = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS); m_valuesOrPrefixes = new DTMStringPool(); @@ -289,7 +299,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators // m_useSourceLocationProperty=com.sun.org.apache.xalan.internal.processor.TransformerFactoryImpl.m_source_location; m_useSourceLocationProperty = mgr.getSource_location(); m_sourceSystemId = (m_useSourceLocationProperty) ? new StringVector() : null; - m_sourceLine = (m_useSourceLocationProperty) ? new IntVector() : null; + m_sourceLine = (m_useSourceLocationProperty) ? new IntVector() : null; m_sourceColumn = (m_useSourceLocationProperty) ? new IntVector() : null; } @@ -297,8 +307,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * Set whether information about document source location * should be maintained or not. */ - public void setUseSourceLocation(boolean useSourceLocation) - { + public void setUseSourceLocation(boolean useSourceLocation) { m_useSourceLocationProperty = useSourceLocation; } @@ -309,17 +318,14 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return The data or qualified name, or DTM.NULL. */ - protected int _dataOrQName(int identity) - { - + protected int _dataOrQName(int identity) { if (identity < m_size) return m_dataOrQName.elementAt(identity); // Check to see if the information requested has been processed, and, // if not, advance the iterator until we the information has been // processed. - while (true) - { + while (true) { boolean isMore = nextNode(); if (!isMore) @@ -332,8 +338,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators /** * Ask the CoRoutine parser to doTerminate and clear the reference. */ - public void clearCoRoutine() - { + public void clearCoRoutine() { clearCoRoutine(true); } @@ -344,11 +349,8 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param callDoTerminate true of doTerminate should be called on the * coRoutine parser. */ - public void clearCoRoutine(boolean callDoTerminate) - { - - if (null != m_incrementalSAXSource) - { + public void clearCoRoutine(boolean callDoTerminate) { + if (null != m_incrementalSAXSource) { if (callDoTerminate) m_incrementalSAXSource.deliverMoreNodes(false); @@ -368,9 +370,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param incrementalSAXSource The parser that we want to recieve events from * on demand. */ - public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource) - { - + public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource) { // Establish coroutine link so we can request more data // // Note: It's possible that some versions of IncrementalSAXSource may @@ -406,11 +406,9 @@ public class SAX2DTM extends DTMDefaultBaseIterators * Note that IncrementalSAXSource_Filter is package private, hence * it can be statically referenced using instanceof (CR 6537912). */ - public ContentHandler getContentHandler() - { - - if (m_incrementalSAXSource.getClass() - .getName().equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter")) + public ContentHandler getContentHandler() { + if (m_incrementalSAXSource.getClass().getName() + .equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter")) return (ContentHandler) m_incrementalSAXSource; else return this; @@ -429,11 +427,9 @@ public class SAX2DTM extends DTMDefaultBaseIterators * Note that IncrementalSAXSource_Filter is package private, hence * it can be statically referenced using instanceof (CR 6537912). */ - public LexicalHandler getLexicalHandler() - { - - if (m_incrementalSAXSource.getClass() - .getName().equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter")) + public LexicalHandler getLexicalHandler() { + if (m_incrementalSAXSource.getClass().getName() + .equals("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Filter")) return (LexicalHandler) m_incrementalSAXSource; else return this; @@ -444,8 +440,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return null if this model doesn't respond to SAX entity ref events. */ - public EntityResolver getEntityResolver() - { + public EntityResolver getEntityResolver() { return this; } @@ -454,8 +449,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return null if this model doesn't respond to SAX dtd events. */ - public DTDHandler getDTDHandler() - { + public DTDHandler getDTDHandler() { return this; } @@ -464,8 +458,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return null if this model doesn't respond to SAX error events. */ - public ErrorHandler getErrorHandler() - { + public ErrorHandler getErrorHandler() { return this; } @@ -474,8 +467,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return null if this model doesn't respond to SAX Decl events. */ - public DeclHandler getDeclHandler() - { + public DeclHandler getDeclHandler() { return this; } @@ -485,8 +477,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * transformation and the parse run simultaneously. Guidance to the * DTMManager. */ - public boolean needsTwoThreads() - { + public boolean needsTwoThreads() { return null != m_incrementalSAXSource; } @@ -509,9 +500,8 @@ public class SAX2DTM extends DTMDefaultBaseIterators */ public void dispatchCharactersEvents(int nodeHandle, ContentHandler ch, boolean normalize) - throws SAXException + throws SAXException { - int identity = makeNodeIdentity(nodeHandle); if (identity == DTM.NULL) @@ -519,8 +509,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators int type = _type(identity); - if (isTextType(type)) - { + if (isTextType(type)) { int dataIndex = m_dataOrQName.elementAt(identity); int offset = m_data.elementAt(dataIndex); int length = m_data.elementAt(dataIndex + 1); @@ -529,13 +518,10 @@ public class SAX2DTM extends DTMDefaultBaseIterators m_chars.sendNormalizedSAXcharacters(ch, offset, length); else m_chars.sendSAXcharacters(ch, offset, length); - } - else - { + } else { int firstChild = _firstch(identity); - if (DTM.NULL != firstChild) - { + if (DTM.NULL != firstChild) { int offset = -1; int length = 0; int startNode = identity; @@ -545,12 +531,10 @@ public class SAX2DTM extends DTMDefaultBaseIterators do { type = _type(identity); - if (isTextType(type)) - { + if (isTextType(type)) { int dataIndex = _dataOrQName(identity); - if (-1 == offset) - { + if (-1 == offset) { offset = m_data.elementAt(dataIndex); } @@ -560,36 +544,31 @@ public class SAX2DTM extends DTMDefaultBaseIterators identity = getNextNodeIdentity(identity); } while (DTM.NULL != identity && (_parent(identity) >= startNode)); - if (length > 0) - { + if (length > 0) { if(normalize) m_chars.sendNormalizedSAXcharacters(ch, offset, length); else m_chars.sendSAXcharacters(ch, offset, length); } - } - else if(type != DTM.ELEMENT_NODE) - { + } else if(type != DTM.ELEMENT_NODE) { int dataIndex = _dataOrQName(identity); - if (dataIndex < 0) - { + if (dataIndex < 0) { dataIndex = -dataIndex; dataIndex = m_data.elementAt(dataIndex + 1); } String str = m_valuesOrPrefixes.indexToString(dataIndex); - if(normalize) - FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(), - 0, str.length(), ch); - else - ch.characters(str.toCharArray(), 0, str.length()); + if(normalize) + FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(), + 0, str.length(), ch); + else + ch.characters(str.toCharArray(), 0, str.length()); } } } - /** * Given a node handle, return its DOM-style node name. This will * include names such as #text or #document. @@ -599,39 +578,29 @@ public class SAX2DTM extends DTMDefaultBaseIterators * %REVIEW% Document when empty string is possible... * %REVIEW-COMMENT% It should never be empty, should it? */ - public String getNodeName(int nodeHandle) - { - + public String getNodeName(int nodeHandle) { int expandedTypeID = getExpandedTypeID(nodeHandle); // If just testing nonzero, no need to shift... int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID); - if (0 == namespaceID) - { + if (0 == namespaceID) { // Don't retrieve name until/unless needed // String name = m_expandedNameTable.getLocalName(expandedTypeID); int type = getNodeType(nodeHandle); - if (type == DTM.NAMESPACE_NODE) - { + if (type == DTM.NAMESPACE_NODE) { if (null == m_expandedNameTable.getLocalName(expandedTypeID)) return "xmlns"; else return "xmlns:" + m_expandedNameTable.getLocalName(expandedTypeID); - } - else if (0 == m_expandedNameTable.getLocalNameID(expandedTypeID)) - { + } else if (0 == m_expandedNameTable.getLocalNameID(expandedTypeID)) { return m_fixednames[type]; - } - else + } else return m_expandedNameTable.getLocalName(expandedTypeID); - } - else - { + } else { int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle)); - if (qnameIndex < 0) - { + if (qnameIndex < 0) { qnameIndex = -qnameIndex; qnameIndex = m_data.elementAt(qnameIndex); } @@ -648,27 +617,21 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param nodeHandle the id of the node. * @return String Name of this node, which may be an empty string. */ - public String getNodeNameX(int nodeHandle) - { - + public String getNodeNameX(int nodeHandle) { int expandedTypeID = getExpandedTypeID(nodeHandle); int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID); - if (0 == namespaceID) - { + if (namespaceID == 0) { String name = m_expandedNameTable.getLocalName(expandedTypeID); if (name == null) return ""; else return name; - } - else - { + } else { int qnameIndex = m_dataOrQName.elementAt(makeNodeIdentity(nodeHandle)); - if (qnameIndex < 0) - { + if (qnameIndex < 0) { qnameIndex = -qnameIndex; qnameIndex = m_data.elementAt(qnameIndex); } @@ -686,11 +649,9 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @return true if the attribute was specified; * false if it was defaulted. */ - public boolean isAttributeSpecified(int attributeHandle) - { - + public boolean isAttributeSpecified(int attributeHandle) { // I'm not sure if I want to do anything with this... - return true; // ?? + return true; // ?? } /** @@ -701,9 +662,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return the system identifier String object, or null if there is none. */ - public String getDocumentTypeDeclarationSystemIdentifier() - { - + public String getDocumentTypeDeclarationSystemIdentifier() { /** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMDefaultBase abstract method */ error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"Not yet supported!"); @@ -717,14 +676,11 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param identity The node identity (index). * @return identity+1, or DTM.NULL. */ - protected int getNextNodeIdentity(int identity) - { - + protected int getNextNodeIdentity(int identity) { identity += 1; - while (identity >= m_size) - { - if (null == m_incrementalSAXSource) + while (identity >= m_size) { + if (m_incrementalSAXSource == null) return DTM.NULL; nextNode(); @@ -739,10 +695,10 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param nodeHandle The node ID. * @param ch A non-null reference to a ContentHandler. * - * @throws org.xml.sax.SAXException + * @throws SAXException */ - public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch) - throws org.xml.sax.SAXException + public void dispatchToEvents(int nodeHandle, ContentHandler ch) + throws SAXException { DTMTreeWalker treeWalker = m_walker; @@ -1087,28 +1043,22 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @return String containing the URI of the Unparsed Entity, or an * empty string if no such entity exists. */ - public String getUnparsedEntityURI(String name) - { - + public String getUnparsedEntityURI(String name) { String url = ""; - if (null == m_entities) + if (null == m_entities) { return url; + } int n = m_entities.size(); - for (int i = 0; i < n; i += ENTITY_FIELDS_PER) - { - String ename = (String) m_entities.elementAt(i + ENTITY_FIELD_NAME); + for (int i = 0; i < n; i += ENTITY_FIELDS_PER) { + String ename = m_entities.get(i + ENTITY_FIELD_NAME); - if (null != ename && ename.equals(name)) - { - String nname = (String) m_entities.elementAt(i - + ENTITY_FIELD_NOTATIONNAME); - - if (null != nname) - { + if (null != ename && ename.equals(name)) { + String nname = m_entities.get(i + ENTITY_FIELD_NOTATIONNAME); + if (null != nname) { // The draft says: "The XSLT processor may use the public // identifier to generate a URI for the entity instead of the URI // specified in the system identifier. If the XSLT processor does @@ -1118,11 +1068,10 @@ public class SAX2DTM extends DTMDefaultBaseIterators // the resource containing the entity declaration as the base // URI [RFC2396]." // So I'm falling a bit short here. - url = (String) m_entities.elementAt(i + ENTITY_FIELD_SYSTEMID); + url = m_entities.get(i + ENTITY_FIELD_SYSTEMID); - if (null == url) - { - url = (String) m_entities.elementAt(i + ENTITY_FIELD_PUBLICID); + if (null == url) { + url = m_entities.get(i + ENTITY_FIELD_PUBLICID); } } @@ -1400,26 +1349,18 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return The prefix if there is one, or null. */ - public String getPrefix(String qname, String uri) - { - + public String getPrefix(String qname, String uri) { String prefix; int uriIndex = -1; - if (null != uri && uri.length() > 0) - { - - do - { + if (null != uri && uri.length() > 0) { + do { uriIndex = m_prefixMappings.indexOf(uri, ++uriIndex); - } while ( (uriIndex & 0x01) == 0); + } while ((uriIndex & 0x01) == 0); - if (uriIndex >= 0) - { - prefix = (String) m_prefixMappings.elementAt(uriIndex - 1); - } - else if (null != qname) - { + if (uriIndex >= 0) { + prefix = m_prefixMappings.elementAt(uriIndex - 1); + } else if (null != qname) { int indexOfNSSep = qname.indexOf(':'); if (qname.equals("xmlns")) @@ -1429,33 +1370,24 @@ public class SAX2DTM extends DTMDefaultBaseIterators else prefix = (indexOfNSSep > 0) ? qname.substring(0, indexOfNSSep) : null; - } - else - { + } else { prefix = null; } - } - else if (null != qname) - { + } else if (null != qname) { int indexOfNSSep = qname.indexOf(':'); - if (indexOfNSSep > 0) - { + if (indexOfNSSep > 0) { if (qname.startsWith("xmlns:")) prefix = qname.substring(indexOfNSSep + 1); else prefix = qname.substring(0, indexOfNSSep); - } - else - { + } else { if (qname.equals("xmlns")) prefix = ""; else prefix = null; } - } - else - { + } else { prefix = null; } @@ -1470,38 +1402,31 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @return The prefix if there is one, or null. */ - public int getIdForNamespace(String uri) - { - + public int getIdForNamespace(String uri) { return m_valuesOrPrefixes.stringToIndex(uri); - } - /** + /** * Get a prefix either from the qname or from the uri mapping, or just make * one up! * * @return The prefix if there is one, or null. */ - public String getNamespaceURI(String prefix) - { - + public String getNamespaceURI(String prefix) { String uri = ""; int prefixIndex = m_contextIndexes.peek() - 1 ; - if(null == prefix) + if (null == prefix) { prefix = ""; + } - do - { - prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex); - } while ( (prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01); - - if (prefixIndex > -1) - { - uri = (String) m_prefixMappings.elementAt(prefixIndex + 1); - } + do { + prefixIndex = m_prefixMappings.indexOf(prefix, ++prefixIndex); + } while ((prefixIndex >= 0) && (prefixIndex & 0x01) == 0x01); + if (prefixIndex > -1) { + uri = m_prefixMappings.elementAt(prefixIndex + 1); + } return uri; } @@ -1578,7 +1503,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * default behaviour. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.EntityResolver#resolveEntity + * @see EntityResolver#resolveEntity * * @throws SAXException */ @@ -1605,7 +1530,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param systemId The notation system identifier. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.DTDHandler#notationDecl + * @see DTDHandler#notationDecl * * @throws SAXException */ @@ -1630,41 +1555,35 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param notationName The name of the associated notation. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.DTDHandler#unparsedEntityDecl + * @see DTDHandler#unparsedEntityDecl * * @throws SAXException */ - public void unparsedEntityDecl( - String name, String publicId, String systemId, String notationName) - throws SAXException + public void unparsedEntityDecl(String name, String publicId, String systemId, + String notationName) throws SAXException { - - if (null == m_entities) - { - m_entities = new Vector(); + if (null == m_entities) { + m_entities = new ArrayList<>(); } - try - { + try { systemId = SystemIDResolver.getAbsoluteURI(systemId, getDocumentBaseURI()); - } - catch (Exception e) - { - throw new org.xml.sax.SAXException(e); + } catch (Exception e) { + throw new SAXException(e); } // private static final int ENTITY_FIELD_PUBLICID = 0; - m_entities.addElement(publicId); + m_entities.add(publicId); // private static final int ENTITY_FIELD_SYSTEMID = 1; - m_entities.addElement(systemId); + m_entities.add(systemId); // private static final int ENTITY_FIELD_NOTATIONNAME = 2; - m_entities.addElement(notationName); + m_entities.add(notationName); // private static final int ENTITY_FIELD_NAME = 3; - m_entities.addElement(name); + m_entities.add(name); } //////////////////////////////////////////////////////////////////// @@ -1679,8 +1598,8 @@ public class SAX2DTM extends DTMDefaultBaseIterators * with other document events.

* * @param locator A locator for all SAX document events. - * @see org.xml.sax.ContentHandler#setDocumentLocator - * @see org.xml.sax.Locator + * @see ContentHandler#setDocumentLocator + * @see Locator */ public void setDocumentLocator(Locator locator) { @@ -1693,7 +1612,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#startDocument + * @see ContentHandler#startDocument */ public void startDocument() throws SAXException { @@ -1716,7 +1635,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#endDocument + * @see ContentHandler#endDocument */ public void endDocument() throws SAXException { @@ -1754,7 +1673,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param uri The Namespace URI mapped to the prefix. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#startPrefixMapping + * @see ContentHandler#startPrefixMapping */ public void startPrefixMapping(String prefix, String uri) throws SAXException @@ -1780,7 +1699,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param prefix The Namespace prefix being declared. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#endPrefixMapping + * @see ContentHandler#endPrefixMapping */ public void endPrefixMapping(String prefix) throws SAXException { @@ -1815,16 +1734,13 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @return true if the declaration has already been declared in the * current context. */ - protected boolean declAlreadyDeclared(String prefix) - { - + protected boolean declAlreadyDeclared(String prefix) { int startDecls = m_contextIndexes.peek(); - java.util.Vector prefixMappings = m_prefixMappings; + Vector prefixMappings = m_prefixMappings; int nDecls = prefixMappings.size(); - for (int i = startDecls; i < nDecls; i += 2) - { - String prefixDecl = (String) prefixMappings.elementAt(i); + for (int i = startDecls; i < nDecls; i += 2) { + String prefixDecl = prefixMappings.elementAt(i); if (prefixDecl == null) continue; @@ -1836,7 +1752,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators return false; } - boolean m_pastFirstElement=false; + boolean m_pastFirstElement=false; /** * Receive notification of the start of an element. @@ -1857,35 +1773,38 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param attributes The specified or defaulted attributes. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#startElement + * @see ContentHandler#startElement */ - public void startElement( - String uri, String localName, String qName, Attributes attributes) - throws SAXException + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException { - if (DEBUG) - { - System.out.println("startElement: uri: " + uri + ", localname: " - + localName + ", qname: "+qName+", atts: " + attributes); + if (DEBUG) { + System.out.println("startElement: uri: " + uri + + ", localname: " + localName + + ", qname: "+qName+", atts: " + attributes); - boolean DEBUG_ATTRS=true; - if(DEBUG_ATTRS & attributes!=null) - { - int n = attributes.getLength(); - if(n==0) - System.out.println("\tempty attribute list"); - else for (int i = 0; i < n; i++) - System.out.println("\t attr: uri: " + attributes.getURI(i) + - ", localname: " + attributes.getLocalName(i) + - ", qname: " + attributes.getQName(i) + - ", type: " + attributes.getType(i) + - ", value: " + attributes.getValue(i) - ); - } - } + boolean DEBUG_ATTRS=true; + if (DEBUG_ATTRS & attributes!=null) { + int n = attributes.getLength(); + if (n==0) { + System.out.println("\tempty attribute list"); + } else for (int i = 0; i < n; i++) { + System.out.println("\t attr: uri: " + attributes.getURI(i) + + ", localname: " + attributes.getLocalName(i) + + ", qname: " + attributes.getQName(i) + + ", type: " + attributes.getType(i) + + ", value: " + attributes.getValue(i)); + } + } + } charactersFlush(); + if ((localName == null || localName.isEmpty()) && + (uri == null || uri.isEmpty())) { + localName = qName; + } + int exName = m_expandedNameTable.getExpandedTypeID(uri, localName, DTM.ELEMENT_NODE); String prefix = getPrefix(qName, uri); int prefixIndex = (null != prefix) @@ -1894,20 +1813,18 @@ public class SAX2DTM extends DTMDefaultBaseIterators int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_parents.peek(), m_previous, prefixIndex, true); - if(m_indexing) + if (m_indexing) indexNode(exName, elemNode); - m_parents.push(elemNode); int startDecls = m_contextIndexes.peek(); int nDecls = m_prefixMappings.size(); int prev = DTM.NULL; - if(!m_pastFirstElement) - { + if (!m_pastFirstElement) { // SPECIAL CASE: Implied declaration at root element - prefix="xml"; + prefix = "xml"; String declURL = "http://www.w3.org/XML/1998/namespace"; exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE); int val = m_valuesOrPrefixes.stringToIndex(declURL); @@ -1916,14 +1833,13 @@ public class SAX2DTM extends DTMDefaultBaseIterators m_pastFirstElement=true; } - for (int i = startDecls; i < nDecls; i += 2) - { - prefix = (String) m_prefixMappings.elementAt(i); + for (int i = startDecls; i < nDecls; i += 2) { + prefix = m_prefixMappings.elementAt(i); if (prefix == null) continue; - String declURL = (String) m_prefixMappings.elementAt(i + 1); + String declURL = m_prefixMappings.elementAt(i + 1); exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE); @@ -1935,8 +1851,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators int n = attributes.getLength(); - for (int i = 0; i < n; i++) - { + for (int i = 0; i < n; i++) { String attrUri = attributes.getURI(i); String attrQName = attributes.getQName(i); String valString = attributes.getValue(i); @@ -1947,17 +1862,13 @@ public class SAX2DTM extends DTMDefaultBaseIterators String attrLocalName = attributes.getLocalName(i); - if ((null != attrQName) - && (attrQName.equals("xmlns") - || attrQName.startsWith("xmlns:"))) - { + if ((null != attrQName) && + (attrQName.equals("xmlns") || attrQName.startsWith("xmlns:"))) { if (declAlreadyDeclared(prefix)) continue; // go to the next attribute. nodeType = DTM.NAMESPACE_NODE; - } - else - { + } else { nodeType = DTM.ATTRIBUTE_NODE; if (attributes.getType(i).equalsIgnoreCase("ID")) @@ -1966,15 +1877,13 @@ public class SAX2DTM extends DTMDefaultBaseIterators // Bit of a hack... if somehow valString is null, stringToIndex will // return -1, which will make things very unhappy. - if(null == valString) + if (null == valString) valString = ""; int val = m_valuesOrPrefixes.stringToIndex(valString); //String attrLocalName = attributes.getLocalName(i); - if (null != prefix) - { - + if (null != prefix) { prefixIndex = m_valuesOrPrefixes.stringToIndex(attrQName); int dataIndex = m_data.size(); @@ -1993,8 +1902,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators if (DTM.NULL != prev) m_nextsib.setElementAt(DTM.NULL,prev); - if (null != m_wsfilter) - { + if (null != m_wsfilter) { short wsv = m_wsfilter.getShouldStripSpace(makeNodeHandle(elemNode), this); boolean shouldStrip = (DTMWSFilter.INHERIT == wsv) ? getShouldStripWhitespace() @@ -2026,7 +1934,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * empty string if qualified names are not available. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#endElement + * @see ContentHandler#endElement */ public void endElement(String uri, String localName, String qName) throws SAXException @@ -2074,7 +1982,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * character array. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#characters + * @see ContentHandler#characters */ public void characters(char ch[], int start, int length) throws SAXException { @@ -2109,7 +2017,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * character array. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#ignorableWhitespace + * @see ContentHandler#ignorableWhitespace */ public void ignorableWhitespace(char ch[], int start, int length) throws SAXException @@ -2133,7 +2041,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * none is supplied. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#processingInstruction + * @see ContentHandler#processingInstruction */ public void processingInstruction(String target, String data) throws SAXException @@ -2163,7 +2071,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param name The name of the skipped entity. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#processingInstruction + * @see ContentHandler#processingInstruction */ public void skippedEntity(String name) throws SAXException { @@ -2187,8 +2095,8 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param e The warning information encoded as an exception. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ErrorHandler#warning - * @see org.xml.sax.SAXParseException + * @see ErrorHandler#warning + * @see SAXParseException */ public void warning(SAXParseException e) throws SAXException { @@ -2208,8 +2116,8 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param e The warning information encoded as an exception. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ErrorHandler#warning - * @see org.xml.sax.SAXParseException + * @see ErrorHandler#warning + * @see SAXParseException */ public void error(SAXParseException e) throws SAXException { @@ -2230,8 +2138,8 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param e The error information encoded as an exception. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ErrorHandler#fatalError - * @see org.xml.sax.SAXParseException + * @see ErrorHandler#fatalError + * @see SAXParseException */ public void fatalError(SAXParseException e) throws SAXException { @@ -2299,7 +2207,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param value The replacement text of the entity. * @throws SAXException The application may raise an exception. * @see #externalEntityDecl - * @see org.xml.sax.DTDHandler#unparsedEntityDecl + * @see DTDHandler#unparsedEntityDecl */ public void internalEntityDecl(String name, String value) throws SAXException @@ -2321,7 +2229,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * @param systemId The declared system identifier of the entity. * @throws SAXException The application may raise an exception. * @see #internalEntityDecl - * @see org.xml.sax.DTDHandler#unparsedEntityDecl + * @see DTDHandler#unparsedEntityDecl */ public void externalEntityDecl( String name, String publicId, String systemId) throws SAXException @@ -2386,15 +2294,15 @@ public class SAX2DTM extends DTMDefaultBaseIterators * properly nested within start/end entity events.

* *

Note that skipped entities will be reported through the - * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity} + * {@link ContentHandler#skippedEntity skippedEntity} * event, which is part of the ContentHandler interface.

* * @param name The name of the entity. If it is a parameter * entity, the name will begin with '%'. * @throws SAXException The application may raise an exception. * @see #endEntity - * @see org.xml.sax.ext.DeclHandler#internalEntityDecl - * @see org.xml.sax.ext.DeclHandler#externalEntityDecl + * @see DeclHandler#internalEntityDecl + * @see DeclHandler#externalEntityDecl */ public void startEntity(String name) throws SAXException { @@ -2419,7 +2327,7 @@ public class SAX2DTM extends DTMDefaultBaseIterators * Report the start of a CDATA section. * *

The contents of the CDATA section will be reported through - * the regular {@link org.xml.sax.ContentHandler#characters + * the regular {@link ContentHandler#characters * characters} event.

* * @throws SAXException The application may raise an exception. diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java index 526f5e1b5f0..be63de6b4df 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 1999-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -17,13 +17,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * $Id: SAX2DTM2.java,v 1.2.4.1 2005/09/15 08:15:12 suresh_emailid Exp $ - */ + package com.sun.org.apache.xml.internal.dtm.ref.sax2dtm; -import com.sun.org.apache.xml.internal.dtm.*; -import com.sun.org.apache.xml.internal.dtm.ref.*; +import com.sun.org.apache.xml.internal.dtm.DTM; +import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; +import com.sun.org.apache.xml.internal.dtm.DTMException; +import com.sun.org.apache.xml.internal.dtm.DTMManager; +import com.sun.org.apache.xml.internal.dtm.DTMWSFilter; +import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase; +import com.sun.org.apache.xml.internal.dtm.ref.ExpandedNameTable; +import com.sun.org.apache.xml.internal.dtm.ref.ExtendedType; import com.sun.org.apache.xml.internal.utils.FastStringBuffer; import com.sun.org.apache.xml.internal.utils.XMLString; import com.sun.org.apache.xml.internal.utils.XMLStringDefault; @@ -31,11 +35,12 @@ import com.sun.org.apache.xml.internal.utils.XMLStringFactory; import com.sun.org.apache.xml.internal.res.XMLMessages; import com.sun.org.apache.xml.internal.res.XMLErrorResources; import com.sun.org.apache.xml.internal.serializer.SerializationHandler; - -import javax.xml.transform.Source; -import java.util.Vector; import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector; -import org.xml.sax.*; +import java.util.ArrayList; +import javax.xml.transform.Source; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; /** * SAX2DTM2 is an optimized version of SAX2DTM which is used in non-incremental situation. @@ -53,10 +58,6 @@ import org.xml.sax.*; * The design of SAX2DTM2 may limit its extensibilty. If you have a reason to extend the * SAX2DTM model, please extend from SAX2DTM instead of this class. *

- * TODO: This class is currently only used by XSLTC. We need to investigate the possibility - * of also using it in Xalan-J Interpretive. Xalan's performance is likely to get an instant - * boost if we use SAX2DTM2 instead of SAX2DTM in non-incremental case. - *

* %MK% The code in this class is critical to the XSLTC_DTM performance. Be very careful * when making changes here! */ @@ -87,11 +88,10 @@ public class SAX2DTM2 extends SAX2DTM */ public DTMAxisIterator setStartNode(int node) { -//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily + //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); - if (_isRestartable) - { + if (_isRestartable) { _startNode = node; _currentNode = (node == DTM.NULL) ? DTM.NULL : _firstch2(makeNodeIdentity(node)); @@ -108,8 +108,7 @@ public class SAX2DTM2 extends SAX2DTM * @return The next node handle in the iteration, or END if no more * are available. */ - public int next() - { + public int next() { if (_currentNode != NULL) { int node = _currentNode; _currentNode = _nextsib2(node); @@ -139,13 +138,11 @@ public class SAX2DTM2 extends SAX2DTM * * @return A DTMAxisIterator set to the start of the iteration. */ - public DTMAxisIterator setStartNode(int node) - { -//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily + public DTMAxisIterator setStartNode(int node) { + //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); - if (_isRestartable) - { + if (_isRestartable) { _startNode = node; if (node != DTM.NULL) @@ -229,8 +226,7 @@ public class SAX2DTM2 extends SAX2DTM * * @param nodeType The extended type ID being requested. */ - public TypedChildrenIterator(int nodeType) - { + public TypedChildrenIterator(int nodeType) { _nodeType = nodeType; } @@ -242,17 +238,14 @@ public class SAX2DTM2 extends SAX2DTM * * @return A DTMAxisIterator set to the start of the iteration. */ - public DTMAxisIterator setStartNode(int node) - { -//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily + public DTMAxisIterator setStartNode(int node) { + //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); - if (_isRestartable) - { + if (_isRestartable) { _startNode = node; - _currentNode = (node == DTM.NULL) - ? DTM.NULL - : _firstch2(makeNodeIdentity(_startNode)); + _currentNode = (node == DTM.NULL) ? DTM.NULL : + _firstch2(makeNodeIdentity(_startNode)); return resetPosition(); } @@ -265,8 +258,7 @@ public class SAX2DTM2 extends SAX2DTM * * @return The next node handle in the iteration, or END. */ - public int next() - { + public int next() { int node = _currentNode; if (node == DTM.NULL) return DTM.NULL; @@ -301,14 +293,12 @@ public class SAX2DTM2 extends SAX2DTM _currentNode = _nextsib2(node); return returnNode(makeNodeHandle(node)); } - } /** * Return the node at the given position. */ - public int getNodeByPosition(int position) - { + public int getNodeByPosition(int position) { if (position <= 0) return DTM.NULL; @@ -327,8 +317,7 @@ public class SAX2DTM2 extends SAX2DTM node = _nextsib2(node); } return NULL; - } - else { + } else { while (node != DTM.NULL) { if (_exptype2(node) >= DTM.NTYPES) { pos++; @@ -415,13 +404,11 @@ public class SAX2DTM2 extends SAX2DTM * * @return A DTMAxisIterator set to the start of the iteration. */ - public DTMAxisIterator setStartNode(int node) - { -//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily + public DTMAxisIterator setStartNode(int node) { + //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); - if (_isRestartable) - { + if (_isRestartable) { _startNode = node; _currentNode = makeNodeIdentity(node); @@ -436,8 +423,7 @@ public class SAX2DTM2 extends SAX2DTM * * @return The next node handle in the iteration, or END. */ - public int next() - { + public int next() { _currentNode = (_currentNode == DTM.NULL) ? DTM.NULL : _nextsib2(_currentNode); return returnNode(makeNodeHandle(_currentNode)); @@ -460,8 +446,7 @@ public class SAX2DTM2 extends SAX2DTM * * @param type The extended type ID being requested. */ - public TypedFollowingSiblingIterator(int type) - { + public TypedFollowingSiblingIterator(int type) { _nodeType = type; } @@ -470,8 +455,7 @@ public class SAX2DTM2 extends SAX2DTM * * @return The next node handle in the iteration, or END. */ - public int next() - { + public int next() { if (_currentNode == DTM.NULL) { return DTM.NULL; } @@ -481,8 +465,7 @@ public class SAX2DTM2 extends SAX2DTM if (nodeType != DTM.ELEMENT_NODE) { while ((node = _nextsib2(node)) != DTM.NULL && _exptype2(node) != nodeType) {} - } - else { + } else { while ((node = _nextsib2(node)) != DTM.NULL && _exptype2(node) < DTM.NTYPES) {} } @@ -498,8 +481,7 @@ public class SAX2DTM2 extends SAX2DTM /** * Iterator that returns attribute nodes (of what nodes?) */ - public final class AttributeIterator extends InternalAxisIteratorBase - { + public final class AttributeIterator extends InternalAxisIteratorBase { // assumes caller will pass element nodes @@ -511,13 +493,11 @@ public class SAX2DTM2 extends SAX2DTM * * @return A DTMAxisIterator set to the start of the iteration. */ - public DTMAxisIterator setStartNode(int node) - { -//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily + public DTMAxisIterator setStartNode(int node) { + //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); - if (_isRestartable) - { + if (_isRestartable) { _startNode = node; _currentNode = getFirstAttributeIdentity(makeNodeIdentity(node)); @@ -532,9 +512,7 @@ public class SAX2DTM2 extends SAX2DTM * * @return The next node handle in the iteration, or END. */ - public int next() - { - + public int next() { final int node = _currentNode; if (node != NULL) { @@ -561,8 +539,7 @@ public class SAX2DTM2 extends SAX2DTM * * @param nodeType The extended type ID that is requested. */ - public TypedAttributeIterator(int nodeType) - { + public TypedAttributeIterator(int nodeType) { _nodeType = nodeType; } @@ -576,14 +553,10 @@ public class SAX2DTM2 extends SAX2DTM * * @return A DTMAxisIterator set to the start of the iteration. */ - public DTMAxisIterator setStartNode(int node) - { - if (_isRestartable) - { + public DTMAxisIterator setStartNode(int node) { + if (_isRestartable) { _startNode = node; - _currentNode = getTypedAttribute(node, _nodeType); - return resetPosition(); } @@ -595,9 +568,7 @@ public class SAX2DTM2 extends SAX2DTM * * @return The next node handle in the iteration, or END. */ - public int next() - { - + public int next() { final int node = _currentNode; // singleton iterator, since there can only be one attribute of @@ -624,8 +595,7 @@ public class SAX2DTM2 extends SAX2DTM * * @return true. */ - public boolean isReverse() - { + public boolean isReverse() { return true; } @@ -637,30 +607,25 @@ public class SAX2DTM2 extends SAX2DTM * * @return A DTMAxisIterator set to the start of the iteration. */ - public DTMAxisIterator setStartNode(int node) - { -//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily + public DTMAxisIterator setStartNode(int node) { + //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); - if (_isRestartable) - { + if (_isRestartable) { _startNode = node; node = _startNodeID = makeNodeIdentity(node); - if(node == NULL) - { + if(node == NULL) { _currentNode = node; return resetPosition(); } int type = _type2(node); - if(ExpandedNameTable.ATTRIBUTE == type - || ExpandedNameTable.NAMESPACE == type ) + if (ExpandedNameTable.ATTRIBUTE == type || + ExpandedNameTable.NAMESPACE == type) { _currentNode = node; - } - else - { + } else { // Be careful to handle the Document node properly _currentNode = _parent2(node); if(NULL!=_currentNode) @@ -680,18 +645,12 @@ public class SAX2DTM2 extends SAX2DTM * * @return The next node handle in the iteration, or END. */ - public int next() - { - - if (_currentNode == _startNodeID || _currentNode == DTM.NULL) - { + public int next() { + if (_currentNode == _startNodeID || _currentNode == DTM.NULL) { return NULL; - } - else - { + } else { final int node = _currentNode; _currentNode = _nextsib2(node); - return returnNode(makeNodeHandle(node)); } } @@ -714,8 +673,7 @@ public class SAX2DTM2 extends SAX2DTM * * @param type The extended type ID being requested. */ - public TypedPrecedingSiblingIterator(int type) - { + public TypedPrecedingSiblingIterator(int type) { _nodeType = type; } @@ -724,8 +682,7 @@ public class SAX2DTM2 extends SAX2DTM * * @return The next node handle in the iteration, or END. */ - public int next() - { + public int next() { int node = _currentNode; final int nodeType = _nodeType; @@ -735,8 +692,7 @@ public class SAX2DTM2 extends SAX2DTM while (node != NULL && node != startNodeID && _exptype2(node) != nodeType) { node = _nextsib2(node); } - } - else { + } else { while (node != NULL && node != startNodeID && _exptype2(node) < DTM.NTYPES) { node = _nextsib2(node); } @@ -745,8 +701,7 @@ public class SAX2DTM2 extends SAX2DTM if (node == DTM.NULL || node == startNodeID) { _currentNode = NULL; return NULL; - } - else { + } else { _currentNode = _nextsib2(node); return returnNode(makeNodeHandle(node)); } @@ -755,8 +710,7 @@ public class SAX2DTM2 extends SAX2DTM /** * Return the index of the last node in this iterator. */ - public int getLast() - { + public int getLast() { if (_last != -1) return _last; @@ -774,8 +728,7 @@ public class SAX2DTM2 extends SAX2DTM } node = _nextsib2(node); } - } - else { + } else { while (node != NULL && node != startNodeID) { if (_exptype2(node) >= DTM.NTYPES) { last++; @@ -860,7 +813,7 @@ public class SAX2DTM2 extends SAX2DTM */ public DTMAxisIterator setStartNode(int node) { -//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily + //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily if (node == DTMDefaultBase.ROOTNODE) node = getDocument(); if (_isRestartable) @@ -1799,9 +1752,7 @@ public class SAX2DTM2 extends SAX2DTM // %OPT% These values are unlikely to be equal. Storing // them in a plain Vector is more efficient than storing in the // DTMStringPool because we can save the cost for hash calculation. - // - // %REVISIT% Do we need a custom class (e.g. StringVector) here? - protected Vector m_values; + protected ArrayList m_values; // The current index into the m_values Vector. private int m_valueIndex = 0; @@ -1881,9 +1832,8 @@ public class SAX2DTM2 extends SAX2DTM m_buildIdIndex = buildIdIndex; // Some documents do not have attribute nodes. That is why - // we set the initial size of this Vector to be small and set - // the increment to a bigger number. - m_values = new Vector(32, 512); + // we set the initial size of this ArrayList to be small. + m_values = new ArrayList<>(32); m_maxNodeIndex = 1 << DTMManager.IDENT_DTM_NODE_BITS; @@ -1953,10 +1903,7 @@ public class SAX2DTM2 extends SAX2DTM * @param identity A node identity, which must not be equal to * DTM.NULL */ - public final int _firstch2(int identity) - { - //return m_firstch.elementAt(identity); - + public final int _firstch2(int identity) { if (identity < m_blocksize) return m_firstch_map0[identity]; else @@ -1969,10 +1916,7 @@ public class SAX2DTM2 extends SAX2DTM * @param identity A node identity, which must not be equal to * DTM.NULL */ - public final int _parent2(int identity) - { - //return m_parent.elementAt(identity); - + public final int _parent2(int identity) { if (identity < m_blocksize) return m_parent_map0[identity]; else @@ -1985,9 +1929,7 @@ public class SAX2DTM2 extends SAX2DTM * @param identity A node identity, which must not be equal to * DTM.NULL */ - public final int _type2(int identity) - { - //int eType = _exptype2(identity); + public final int _type2(int identity) { int eType; if (identity < m_blocksize) eType = m_exptype_map0[identity]; @@ -2006,12 +1948,9 @@ public class SAX2DTM2 extends SAX2DTM *

This one is only used by DOMAdapter.getExpandedTypeID(int), which * is mostly called from the compiled translets. */ - public final int getExpandedTypeID2(int nodeHandle) - { + public final int getExpandedTypeID2(int nodeHandle) { int nodeID = makeNodeIdentity(nodeHandle); - //return (nodeID != NULL) ? _exptype2(nodeID) : NULL; - if (nodeID != NULL) { if (nodeID < m_blocksize) return m_exptype_map0[nodeID]; @@ -2026,12 +1965,10 @@ public class SAX2DTM2 extends SAX2DTM * END of DTM base accessor interfaces *************************************************************************/ - /** * Return the node type from the expanded type */ - public final int _exptype2Type(int exptype) - { + public final int _exptype2Type(int exptype) { if (NULL != exptype) return m_extendedTypes[exptype].getNodeType(); else @@ -2046,16 +1983,14 @@ public class SAX2DTM2 extends SAX2DTM * * @return The prefix if there is one, or null. */ - public int getIdForNamespace(String uri) - { + public int getIdForNamespace(String uri) { int index = m_values.indexOf(uri); - if (index < 0) - { - m_values.addElement(uri); + if (index < 0) { + m_values.add(uri); return m_valueIndex++; - } - else + } else { return index; + } } /** @@ -2079,15 +2014,25 @@ public class SAX2DTM2 extends SAX2DTM * @param attributes The specified or defaulted attributes. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#startElement + * @see ContentHandler#startElement */ - public void startElement(String uri, String localName, String qName, Attributes attributes) - throws SAXException + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException { - charactersFlush(); - int exName = m_expandedNameTable.getExpandedTypeID(uri, localName, DTM.ELEMENT_NODE); + // in case URI and localName are empty, the input is not using the + // namespaces feature. Then we should take the part after the last + // colon of qName as localName (strip all namespace prefixes) + if ((uri == null || uri.isEmpty()) && + (localName == null || localName.isEmpty())) + { + final int colon = qName.lastIndexOf(':'); + localName = (colon > -1) ? qName.substring(colon + 1) : qName; + } + + int exName = m_expandedNameTable.getExpandedTypeID(uri, localName, + DTM.ELEMENT_NODE); int prefixIndex = (qName.length() != localName.length()) ? m_valuesOrPrefixes.stringToIndex(qName) : 0; @@ -2095,7 +2040,7 @@ public class SAX2DTM2 extends SAX2DTM int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_parents.peek(), m_previous, prefixIndex, true); - if(m_indexing) + if (m_indexing) indexNode(exName, elemNode); m_parents.push(elemNode); @@ -2104,31 +2049,31 @@ public class SAX2DTM2 extends SAX2DTM int nDecls = m_prefixMappings.size(); String prefix; - if(!m_pastFirstElement) - { + if (!m_pastFirstElement) { // SPECIAL CASE: Implied declaration at root element - prefix="xml"; + prefix = "xml"; String declURL = "http://www.w3.org/XML/1998/namespace"; - exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE); - m_values.addElement(declURL); + exName = m_expandedNameTable.getExpandedTypeID(null, prefix, + DTM.NAMESPACE_NODE); + m_values.add(declURL); int val = m_valueIndex++; addNode(DTM.NAMESPACE_NODE, exName, elemNode, DTM.NULL, val, false); m_pastFirstElement=true; } - for (int i = startDecls; i < nDecls; i += 2) - { - prefix = (String) m_prefixMappings.elementAt(i); + for (int i = startDecls; i < nDecls; i += 2) { + prefix = m_prefixMappings.elementAt(i); if (prefix == null) continue; - String declURL = (String) m_prefixMappings.elementAt(i + 1); + String declURL = m_prefixMappings.elementAt(i + 1); - exName = m_expandedNameTable.getExpandedTypeID(null, prefix, DTM.NAMESPACE_NODE); + exName = m_expandedNameTable.getExpandedTypeID(null, prefix, + DTM.NAMESPACE_NODE); - m_values.addElement(declURL); + m_values.add(declURL); int val = m_valueIndex++; addNode(DTM.NAMESPACE_NODE, exName, elemNode, DTM.NULL, val, false); @@ -2136,28 +2081,37 @@ public class SAX2DTM2 extends SAX2DTM int n = attributes.getLength(); - for (int i = 0; i < n; i++) - { + for (int i = 0; i < n; i++) { String attrUri = attributes.getURI(i); + String attrLocalName = attributes.getLocalName(i); String attrQName = attributes.getQName(i); String valString = attributes.getValue(i); + // in case URI and localName are empty, the input is not using the + // namespaces feature. Then we should take the part after the last + // colon of qName as localName (strip all namespace prefixes) + // When the URI is empty but localName has colons then we can also + // assume non namespace aware and prefixes can be stripped + if (attrUri == null || attrUri.isEmpty()) { + if (attrLocalName == null || attrLocalName.isEmpty()) { + final int colon = attrQName.lastIndexOf(':'); + attrLocalName = (colon > -1) ? attrQName.substring(colon + 1) : attrQName; + } else { + final int colon = attrLocalName.lastIndexOf(':'); + attrLocalName = (colon > -1) ? attrLocalName.substring(colon + 1) : attrLocalName; + } + } + int nodeType; - - String attrLocalName = attributes.getLocalName(i); - - if ((null != attrQName) - && (attrQName.equals("xmlns") - || attrQName.startsWith("xmlns:"))) + if ((null != attrQName) && + (attrQName.equals("xmlns") || attrQName.startsWith("xmlns:"))) { prefix = getPrefix(attrQName, attrUri); if (declAlreadyDeclared(prefix)) continue; // go to the next attribute. nodeType = DTM.NAMESPACE_NODE; - } - else - { + } else { nodeType = DTM.ATTRIBUTE_NODE; if (m_buildIdIndex && attributes.getType(i).equalsIgnoreCase("ID")) @@ -2166,36 +2120,31 @@ public class SAX2DTM2 extends SAX2DTM // Bit of a hack... if somehow valString is null, stringToIndex will // return -1, which will make things very unhappy. - if(null == valString) + if (null == valString) valString = ""; - m_values.addElement(valString); + m_values.add(valString); int val = m_valueIndex++; - if (attrLocalName.length() != attrQName.length()) - { - + if (attrLocalName.length() != attrQName.length()) { prefixIndex = m_valuesOrPrefixes.stringToIndex(attrQName); - int dataIndex = m_data.size(); - m_data.addElement(prefixIndex); m_data.addElement(val); - val = -dataIndex; } - exName = m_expandedNameTable.getExpandedTypeID(attrUri, attrLocalName, nodeType); - addNode(nodeType, exName, elemNode, DTM.NULL, val, - false); + exName = m_expandedNameTable.getExpandedTypeID(attrUri, attrLocalName, + nodeType); + addNode(nodeType, exName, elemNode, DTM.NULL, val, false); } - if (null != m_wsfilter) - { - short wsv = m_wsfilter.getShouldStripSpace(makeNodeHandle(elemNode), this); - boolean shouldStrip = (DTMWSFilter.INHERIT == wsv) - ? getShouldStripWhitespace() - : (DTMWSFilter.STRIP == wsv); + if (null != m_wsfilter) { + short wsv = m_wsfilter.getShouldStripSpace(makeNodeHandle(elemNode), + this); + boolean shouldStrip = (DTMWSFilter.INHERIT == wsv) ? + getShouldStripWhitespace() : + (DTMWSFilter.STRIP == wsv); pushShouldStripWhitespace(shouldStrip); } @@ -2223,7 +2172,7 @@ public class SAX2DTM2 extends SAX2DTM * empty string if qualified names are not available. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#endElement + * @see ContentHandler#endElement */ public void endElement(String uri, String localName, String qName) throws SAXException @@ -2257,9 +2206,7 @@ public class SAX2DTM2 extends SAX2DTM * @param length The number of characters to use from the array. * @throws SAXException The application may raise an exception. */ - public void comment(char ch[], int start, int length) throws SAXException - { - + public void comment(char ch[], int start, int length) throws SAXException { if (m_insideDTD) // ignore comments if we're inside the DTD return; @@ -2267,7 +2214,7 @@ public class SAX2DTM2 extends SAX2DTM // %OPT% Saving the comment string in a Vector has a lower cost than // saving it in DTMStringPool. - m_values.addElement(new String(ch, start, length)); + m_values.add(new String(ch, start, length)); int dataIndex = m_valueIndex++; m_previous = addNode(DTM.COMMENT_NODE, DTM.COMMENT_NODE, @@ -2279,13 +2226,10 @@ public class SAX2DTM2 extends SAX2DTM * * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#startDocument + * @see ContentHandler#startDocument */ - public void startDocument() throws SAXException - { - - int doc = addNode(DTM.DOCUMENT_NODE, - DTM.DOCUMENT_NODE, + public void startDocument() throws SAXException { + int doc = addNode(DTM.DOCUMENT_NODE, DTM.DOCUMENT_NODE, DTM.NULL, DTM.NULL, 0, true); m_parents.push(doc); @@ -2299,10 +2243,9 @@ public class SAX2DTM2 extends SAX2DTM * * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#endDocument + * @see ContentHandler#endDocument */ - public void endDocument() throws SAXException - { + public void endDocument() throws SAXException { super.endDocument(); // Add a NULL entry to the end of the node arrays as @@ -2334,16 +2277,15 @@ public class SAX2DTM2 extends SAX2DTM * @return The index identity of the node that was added. */ protected final int addNode(int type, int expandedTypeID, - int parentIndex, int previousSibling, - int dataOrPrefix, boolean canHaveFirstChild) + int parentIndex, int previousSibling, + int dataOrPrefix, boolean canHaveFirstChild) { // Common to all nodes: int nodeIndex = m_size++; // Have we overflowed a DTM Identity's addressing range? //if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS)) - if (nodeIndex == m_maxNodeIndex) - { + if (nodeIndex == m_maxNodeIndex) { addNewDTMID(nodeIndex); m_maxNodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS); } @@ -2366,8 +2308,7 @@ public class SAX2DTM2 extends SAX2DTM // is called, to handle successive characters() events. // Special handling by type: Declare namespaces, attach first child - switch(type) - { + switch(type) { case DTM.NAMESPACE_NODE: declareNamespaceInContext(parentIndex,nodeIndex); break; @@ -2376,8 +2317,7 @@ public class SAX2DTM2 extends SAX2DTM default: if (DTM.NULL != previousSibling) { m_nextsib.setElementAt(nodeIndex,previousSibling); - } - else if (DTM.NULL != parentIndex) { + } else if (DTM.NULL != parentIndex) { m_firstch.setElementAt(nodeIndex,parentIndex); } break; @@ -2390,16 +2330,12 @@ public class SAX2DTM2 extends SAX2DTM * Check whether accumulated text should be stripped; if not, * append the appropriate flavor of text/cdata node. */ - protected final void charactersFlush() - { - - if (m_textPendingStart >= 0) // -1 indicates no-text-in-progress - { + protected final void charactersFlush() { + if (m_textPendingStart >= 0) { // -1 indicates no-text-in-progress int length = m_chars.size() - m_textPendingStart; boolean doStrip = false; - if (getShouldStripWhitespace()) - { + if (getShouldStripWhitespace()) { doStrip = m_chars.isWhitespace(m_textPendingStart, length); } @@ -2412,19 +2348,19 @@ public class SAX2DTM2 extends SAX2DTM // If the offset and length do not exceed the given limits // (offset < 2^21 and length < 2^10), then save both the offset // and length in a bitwise encoded value. - if (length <= TEXT_LENGTH_MAX - && m_textPendingStart <= TEXT_OFFSET_MAX) { + if (length <= TEXT_LENGTH_MAX && + m_textPendingStart <= TEXT_OFFSET_MAX) { m_previous = addNode(m_coalescedTextType, DTM.TEXT_NODE, - m_parents.peek(), m_previous, - length + (m_textPendingStart << TEXT_LENGTH_BITS), - false); + m_parents.peek(), m_previous, + length + (m_textPendingStart << TEXT_LENGTH_BITS), + false); } else { // Store offset and length in the m_data array if one exceeds // the given limits. Use a negative dataIndex as an indication. int dataIndex = m_data.size(); m_previous = addNode(m_coalescedTextType, DTM.TEXT_NODE, - m_parents.peek(), m_previous, -dataIndex, false); + m_parents.peek(), m_previous, -dataIndex, false); m_data.addElement(m_textPendingStart); m_data.addElement(length); @@ -2452,7 +2388,7 @@ public class SAX2DTM2 extends SAX2DTM * none is supplied. * @throws SAXException Any SAX exception, possibly * wrapping another exception. - * @see org.xml.sax.ContentHandler#processingInstruction + * @see ContentHandler#processingInstruction */ public void processingInstruction(String target, String data) throws SAXException @@ -2467,7 +2403,7 @@ public class SAX2DTM2 extends SAX2DTM -dataIndex, false); m_data.addElement(m_valuesOrPrefixes.stringToIndex(target)); - m_values.addElement(data); + m_values.add(data); m_data.addElement(m_valueIndex++); } @@ -2865,9 +2801,9 @@ public class SAX2DTM2 extends SAX2DTM } if (m_xstrf != null) - return m_xstrf.newstr((String)m_values.elementAt(dataIndex)); + return m_xstrf.newstr(m_values.get(dataIndex)); else - return new XMLStringDefault((String)m_values.elementAt(dataIndex)); + return new XMLStringDefault(m_values.get(dataIndex)); } } @@ -2966,7 +2902,7 @@ public class SAX2DTM2 extends SAX2DTM dataIndex = m_data.elementAt(dataIndex + 1); } - return (String)m_values.elementAt(dataIndex); + return m_values.get(dataIndex); } } @@ -3106,7 +3042,7 @@ public class SAX2DTM2 extends SAX2DTM dataIndex = m_data.elementAt(dataIndex + 1); } - String str = (String)m_values.elementAt(dataIndex); + String str = m_values.get(dataIndex); if(normalize) FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(), @@ -3160,7 +3096,7 @@ public class SAX2DTM2 extends SAX2DTM dataIndex = m_data.elementAt(dataIndex + 1); } - return (String)m_values.elementAt(dataIndex); + return m_values.get(dataIndex); } } @@ -3202,8 +3138,7 @@ public class SAX2DTM2 extends SAX2DTM if (uri.length() == 0) { handler.startElement(name); return name; - } - else { + } else { int qnameIndex = m_dataOrQName.elementAt(nodeID); if (qnameIndex == 0) { @@ -3223,14 +3158,12 @@ public class SAX2DTM2 extends SAX2DTM String prefix; if (prefixIndex > 0) { prefix = qName.substring(0, prefixIndex); - } - else { + } else { prefix = null; } handler.namespaceAfterStartElement(prefix, uri); return qName; } - } /** @@ -3285,7 +3218,7 @@ public class SAX2DTM2 extends SAX2DTM dataIndex = m_data.elementAt(dataIndex + 1); } - String nodeValue = (String)m_values.elementAt(dataIndex); + String nodeValue = m_values.get(dataIndex); handler.namespaceAfterStartElement(nodeName, nodeValue); @@ -3335,7 +3268,6 @@ public class SAX2DTM2 extends SAX2DTM } - /** * Copy an Attribute node to a SerializationHandler * @@ -3347,14 +3279,6 @@ public class SAX2DTM2 extends SAX2DTM SerializationHandler handler) throws SAXException { - /* - final String uri = getNamespaceName(node); - if (uri.length() != 0) { - final String prefix = getPrefix(node); - handler.namespaceAfterStartElement(prefix, uri); - } - handler.addAttribute(getNodeName(node), getNodeValue(node)); - */ final ExtendedType extType = m_extendedTypes[exptype]; final String uri = extType.getNamespace(); final String localName = extType.getLocalName(); @@ -3377,7 +3301,7 @@ public class SAX2DTM2 extends SAX2DTM } String nodeName = (prefix != null) ? qname : localName; - String nodeValue = (String)m_values.elementAt(valueIndex); + String nodeValue = m_values.get(valueIndex); handler.addAttribute(uri, localName, nodeName, "CDATA", nodeValue); } diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java index 1ae853d81e0..7b67f09760c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java @@ -37,6 +37,7 @@ import java.io.StringWriter; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; @@ -74,11 +75,30 @@ import com.sun.org.apache.xml.internal.serialize.XMLSerializer; * @run testng/othervm -DrunSecMngr=true transform.TransformerTest * @run testng/othervm transform.TransformerTest * @summary Transformer Tests - * @bug 6272879 6305029 6505031 8150704 8162598 8169112 8169772 + * @bug 6272879 6305029 6505031 8150704 8162598 8169112 8169631 8169772 */ @Listeners({jaxp.library.FilePolicy.class}) public class TransformerTest { + // some global constants + private static final String LINE_SEPARATOR = + getSystemProperty("line.separator"); + + private static final String NAMESPACES = + "http://xml.org/sax/features/namespaces"; + + private static final String NAMESPACE_PREFIXES = + "http://xml.org/sax/features/namespace-prefixes"; + + private static abstract class TestTemplate { + protected void printSnippet(String title, String snippet) { + StringBuilder div = new StringBuilder(); + for (int i = 0; i < title.length(); i++) + div.append("="); + System.out.println(title + "\n" + div + "\n" + snippet + "\n"); + } + } + /** * Reads the contents of the given file into a string. * WARNING: this method adds a final line feed even if the last line of the file doesn't contain one. @@ -101,44 +121,7 @@ public class TransformerTest { } } - /** - * Utility method for testBug8162598(). - * Provides a convenient way to check/assert the expected namespaces - * of a Node and its siblings. - * - * @param test - * The node to check - * @param nstest - * Expected namespace of the node - * @param nsb - * Expected namespace of the first sibling - * @param nsc - * Expected namespace of the first sibling of the first sibling - */ - private void checkNodeNS8162598(Node test, String nstest, String nsb, String nsc) { - String testNodeName = test.getNodeName(); - if (nstest == null) { - Assert.assertNull(test.getNamespaceURI(), "unexpected namespace for " + testNodeName); - } else { - Assert.assertEquals(test.getNamespaceURI(), nstest, "unexpected namespace for " + testNodeName); - } - Node b = test.getChildNodes().item(0); - if (nsb == null) { - Assert.assertNull(b.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b"); - } else { - Assert.assertEquals(b.getNamespaceURI(), nsb, "unexpected namespace for " + testNodeName + "->b"); - } - Node c = b.getChildNodes().item(0); - if (nsc == null) { - Assert.assertNull(c.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b->c"); - } else { - Assert.assertEquals(c.getNamespaceURI(), nsc, "unexpected namespace for " + testNodeName + "->b->c"); - } - } - private class XMLReaderFor6305029 implements XMLReader { - private static final String NAMESPACES = "http://xml.org/sax/features/namespaces"; - private static final String NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes"; private boolean namespaces = true; private boolean namespacePrefixes = false; private EntityResolver resolver; @@ -235,8 +218,6 @@ public class TransformerTest { */ @Test public final void testBug6272879() throws IOException, TransformerException { - final String LINE_SEPARATOR = getSystemProperty("line.separator"); - final String xsl = "" + LINE_SEPARATOR + "" + LINE_SEPARATOR + @@ -349,9 +330,125 @@ public class TransformerTest { Assert.assertTrue(s.contains("map1key1value") && s.contains("map2key1value")); } + private static class Test8169631 extends TestTemplate { + private final static String xsl = + "" + LINE_SEPARATOR + + "" + LINE_SEPARATOR + + " " + LINE_SEPARATOR + + " " + LINE_SEPARATOR + + " " + LINE_SEPARATOR + + " " + LINE_SEPARATOR + + " " + LINE_SEPARATOR + + " " + LINE_SEPARATOR + + "" + LINE_SEPARATOR; + + private final static String sourceXml = + "" + LINE_SEPARATOR + + "" + LINE_SEPARATOR + + " 1" + LINE_SEPARATOR + + " 2" + LINE_SEPARATOR + + " 3" + LINE_SEPARATOR + + "" + LINE_SEPARATOR; + + /** + * Utility method to print out transformation result and check values. + * + * @param type + * Text describing type of transformation + * @param result + * Resulting output of transformation + * @param elementCount + * Counter of elements to check + * @param attribCount + * Counter of attributes to check + */ + private void verifyResult(String type, String result, int elementCount, + int attribCount) + { + printSnippet("Result of transformation from " + type + ":", + result); + Assert.assertEquals( + result.contains("" + elementCount + ""), + true, "Result of transformation from " + type + + " should have count of " + elementCount + " elements."); + Assert.assertEquals( + result.contains("" + attribCount + + ""), true, "Result of transformation from " + + type + " should have count of "+ attribCount + " attributes."); + } + + public void run() throws IOException, TransformerException, + SAXException, ParserConfigurationException + { + printSnippet("Source:", sourceXml); + + printSnippet("Stylesheet:", xsl); + + // create default transformer (namespace aware) + TransformerFactory tf1 = TransformerFactory.newInstance(); + ByteArrayInputStream bais = new ByteArrayInputStream(xsl.getBytes()); + Transformer t1 = tf1.newTransformer(new StreamSource(bais)); + + // test transformation from stream source with namespace support + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + bais = new ByteArrayInputStream(sourceXml.getBytes()); + t1.transform(new StreamSource(bais), new StreamResult(baos)); + verifyResult("StreamSource with namespace support", baos.toString(), 0, 1); + + // test transformation from DOM source with namespace support + bais.reset(); + baos.reset(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + Document doc = dbf.newDocumentBuilder().parse(new InputSource(bais)); + t1.transform(new DOMSource(doc), new StreamResult(baos)); + verifyResult("DOMSource with namespace support", baos.toString(), 0, 1); + + // test transformation from DOM source without namespace support + bais.reset(); + baos.reset(); + dbf.setNamespaceAware(false); + doc = dbf.newDocumentBuilder().parse(new InputSource(bais)); + t1.transform(new DOMSource(doc), new StreamResult(baos)); + verifyResult("DOMSource without namespace support", baos.toString(), 3, 3); + + // test transformation from SAX source with namespace support + bais.reset(); + baos.reset(); + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); + XMLReader xmlr = spf.newSAXParser().getXMLReader(); + SAXSource saxS = new SAXSource(xmlr, new InputSource(bais)); + t1.transform(saxS, new StreamResult(baos)); + verifyResult("SAXSource with namespace support", baos.toString(), 0, 1); + + // test transformation from SAX source without namespace support + bais.reset(); + baos.reset(); + spf.setNamespaceAware(false); + xmlr = spf.newSAXParser().getXMLReader(); + saxS = new SAXSource(xmlr, new InputSource(bais)); + t1.transform(saxS, new StreamResult(baos)); + verifyResult("SAXSource without namespace support", baos.toString(), 3, 3); + } + } + + /* + * @bug 8169631 + * @summary Test combinations of namespace awareness settings on + * XSL transformations + */ + @Test + public final void testBug8169631() throws IOException, SAXException, + TransformerException, ParserConfigurationException + { + new Test8169631().run(); + } + /* * @bug 8150704 - * @summary Test that XSL transformation with lots of temporary result trees will not run out of DTM IDs. + * @summary Test that XSL transformation with lots of temporary result + * trees will not run out of DTM IDs. */ @Test public final void testBug8150704() throws TransformerException, IOException { @@ -375,16 +472,8 @@ public class TransformerTest { System.out.println("Passed."); } - /* - * @bug 8162598 - * @summary Test XSLTC handling of namespaces, especially empty namespace definitions to reset the - * default namespace - */ - @Test - public final void testBug8162598() throws IOException, TransformerException { - final String LINE_SEPARATOR = getSystemProperty("line.separator"); - - final String xsl = + private static class Test8162598 extends TestTemplate { + private static final String xsl = "" + LINE_SEPARATOR + "" + LINE_SEPARATOR + " " + LINE_SEPARATOR + @@ -402,39 +491,85 @@ public class TransformerTest { " " + LINE_SEPARATOR + ""; + private static final String sourceXml = + "" + LINE_SEPARATOR; + /** + * Utility method for testBug8162598(). + * Provides a convenient way to check/assert the expected namespaces + * of a Node and its siblings. + * + * @param test + * The node to check + * @param nstest + * Expected namespace of the node + * @param nsb + * Expected namespace of the first sibling + * @param nsc + * Expected namespace of the first sibling of the first sibling + */ - final String sourceXml = - "" + LINE_SEPARATOR; + private void checkNodeNS(Node test, String nstest, String nsb, String nsc) { + String testNodeName = test.getNodeName(); + if (nstest == null) { + Assert.assertNull(test.getNamespaceURI(), "unexpected namespace for " + testNodeName); + } else { + Assert.assertEquals(test.getNamespaceURI(), nstest, "unexpected namespace for " + testNodeName); + } + Node b = test.getChildNodes().item(0); + if (nsb == null) { + Assert.assertNull(b.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b"); + } else { + Assert.assertEquals(b.getNamespaceURI(), nsb, "unexpected namespace for " + testNodeName + "->b"); + } + Node c = b.getChildNodes().item(0); + if (nsc == null) { + Assert.assertNull(c.getNamespaceURI(), "unexpected namespace for " + testNodeName + "->b->c"); + } else { + Assert.assertEquals(c.getNamespaceURI(), nsc, "unexpected namespace for " + testNodeName + "->b->c"); + } + } - System.out.println("Stylesheet:"); - System.out.println("============================="); - System.out.println(xsl); - System.out.println(); + public void run() throws IOException, TransformerException { + printSnippet("Source:", sourceXml); - System.out.println("Source before transformation:"); - System.out.println("============================="); - System.out.println(sourceXml); - System.out.println(); + printSnippet("Stylesheet:", xsl); - // transform to DOM result - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer t = tf.newTransformer(new StreamSource(new ByteArrayInputStream(xsl.getBytes()))); - DOMResult result = new DOMResult(); - t.transform(new StreamSource(new ByteArrayInputStream(sourceXml.getBytes())), result); - Document document = (Document)result.getNode(); + // transform to DOM result + TransformerFactory tf = TransformerFactory.newInstance(); + ByteArrayInputStream bais = new ByteArrayInputStream(xsl.getBytes()); + Transformer t = tf.newTransformer(new StreamSource(bais)); + DOMResult result = new DOMResult(); + bais = new ByteArrayInputStream(sourceXml.getBytes()); + t.transform(new StreamSource(bais), result); + Document document = (Document)result.getNode(); - System.out.println("Result after transformation:"); - System.out.println("============================"); - OutputFormat format = new OutputFormat(); - format.setIndenting(true); - new XMLSerializer(System.out, format).serialize(document); - System.out.println(); - checkNodeNS8162598(document.getElementsByTagName("test1").item(0), "ns2", "ns2", null); - checkNodeNS8162598(document.getElementsByTagName("test2").item(0), "ns1", "ns2", null); - checkNodeNS8162598(document.getElementsByTagName("test3").item(0), null, null, null); - checkNodeNS8162598(document.getElementsByTagName("test4").item(0), null, null, null); - checkNodeNS8162598(document.getElementsByTagName("test5").item(0), "ns1", "ns1", null); - Assert.assertNull(document.getElementsByTagName("test6").item(0).getNamespaceURI(), "unexpected namespace for test6"); + System.out.println("Result after transformation:"); + System.out.println("============================"); + OutputFormat format = new OutputFormat(); + format.setIndenting(true); + new XMLSerializer(System.out, format).serialize(document); + System.out.println(); + + checkNodeNS(document.getElementsByTagName("test1").item(0), "ns2", "ns2", null); + checkNodeNS(document.getElementsByTagName("test2").item(0), "ns1", "ns2", null); + checkNodeNS(document.getElementsByTagName("test3").item(0), null, null, null); + checkNodeNS(document.getElementsByTagName("test4").item(0), null, null, null); + checkNodeNS(document.getElementsByTagName("test5").item(0), "ns1", "ns1", null); + Assert.assertNull(document.getElementsByTagName("test6").item(0).getNamespaceURI(), + "unexpected namespace for test6"); + } + } + + /* + * @bug 8162598 + * @summary Test XSLTC handling of namespaces, especially empty namespace + * definitions to reset the default namespace + */ + @Test + public final void testBug8162598() throws IOException, + TransformerException + { + new Test8162598().run(); } /** From 6b74b5d2e9113978b16ec73cf1951307a77ed78a Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Mon, 16 Jan 2017 12:15:44 -0800 Subject: [PATCH 108/154] 8160286: jmod hash is creating unlinkable modules Reviewed-by: alanb, psandoz, chegar --- .../internal/module/ModuleHashesBuilder.java | 312 +++++++++++++ .../sun/tools/jar/GNUStyleOptions.java | 8 +- .../share/classes/sun/tools/jar/Main.java | 138 ++---- .../classes/jdk/tools/jmod/JmodTask.java | 343 ++++++--------- .../jdk/tools/jmod/resources/jmod.properties | 2 +- jdk/test/tools/jmod/JmodTest.java | 50 +-- jdk/test/tools/jmod/hashes/HashesTest.java | 412 +++++++++++++++--- .../tools/jmod/hashes/src/m1/module-info.java | 27 -- .../tools/jmod/hashes/src/m1/org/m1/Main.java | 34 -- .../tools/jmod/hashes/src/m2/module-info.java | 26 -- .../tools/jmod/hashes/src/m2/org/m2/Util.java | 32 -- .../tools/jmod/hashes/src/m3/module-info.java | 26 -- .../tools/jmod/hashes/src/m3/org/m3/Name.java | 32 -- .../jmod/hashes/src/org.bar/module-info.java | 26 -- .../jmod/hashes/src/org.foo/module-info.java | 26 -- 15 files changed, 841 insertions(+), 653 deletions(-) create mode 100644 jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java delete mode 100644 jdk/test/tools/jmod/hashes/src/m1/module-info.java delete mode 100644 jdk/test/tools/jmod/hashes/src/m1/org/m1/Main.java delete mode 100644 jdk/test/tools/jmod/hashes/src/m2/module-info.java delete mode 100644 jdk/test/tools/jmod/hashes/src/m2/org/m2/Util.java delete mode 100644 jdk/test/tools/jmod/hashes/src/m3/module-info.java delete mode 100644 jdk/test/tools/jmod/hashes/src/m3/org/m3/Name.java delete mode 100644 jdk/test/tools/jmod/hashes/src/org.bar/module-info.java delete mode 100644 jdk/test/tools/jmod/hashes/src/org.foo/module-info.java diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java new file mode 100644 index 00000000000..d808fe1db48 --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.module; + +import java.io.PrintStream; +import java.lang.module.Configuration; +import java.lang.module.ResolvedModule; +import java.net.URI; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayDeque; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Stream; +import static java.util.stream.Collectors.*; + +/** + * A Builder to compute ModuleHashes from a given configuration + */ +public class ModuleHashesBuilder { + private final Configuration configuration; + private final Set hashModuleCandidates; + + /** + * Constructs a ModuleHashesBuilder that finds the packaged modules + * from the location of ModuleReference found from the given Configuration. + * + * @param config Configuration for building module hashes + * @param modules the candidate modules to be hashed + */ + public ModuleHashesBuilder(Configuration config, Set modules) { + this.configuration = config; + this.hashModuleCandidates = modules; + } + + /** + * Returns a map of a module M to ModuleHashes for the modules + * that depend upon M directly or indirectly. + * + * The key for each entry in the returned map is a module M that has + * no outgoing edges to any of the candidate modules to be hashed + * i.e. M is a leaf node in a connected subgraph containing M and + * other candidate modules from the module graph filtering + * the outgoing edges from M to non-candidate modules. + */ + public Map computeHashes(Set roots) { + // build a graph containing the the packaged modules and + // its transitive dependences matching --hash-modules + Graph.Builder builder = new Graph.Builder<>(); + Deque deque = new ArrayDeque<>(configuration.modules()); + Set visited = new HashSet<>(); + while (!deque.isEmpty()) { + ResolvedModule rm = deque.pop(); + if (!visited.contains(rm)) { + visited.add(rm); + builder.addNode(rm.name()); + for (ResolvedModule dm : rm.reads()) { + if (!visited.contains(dm)) { + deque.push(dm); + } + builder.addEdge(rm.name(), dm.name()); + } + } + } + + // each node in a transposed graph is a matching packaged module + // in which the hash of the modules that depend upon it is recorded + Graph transposedGraph = builder.build().transpose(); + + // traverse the modules in topological order that will identify + // the modules to record the hashes - it is the first matching + // module and has not been hashed during the traversal. + Set mods = new HashSet<>(); + Map hashes = new HashMap<>(); + builder.build() + .orderedNodes() + .filter(mn -> roots.contains(mn) && !mods.contains(mn)) + .forEach(mn -> { + // Compute hashes of the modules that depend on mn directly and + // indirectly excluding itself. + Set ns = transposedGraph.dfs(mn) + .stream() + .filter(n -> !n.equals(mn) && hashModuleCandidates.contains(n)) + .collect(toSet()); + mods.add(mn); + mods.addAll(ns); + + if (!ns.isEmpty()) { + Map moduleToPath = ns.stream() + .collect(toMap(Function.identity(), this::moduleToPath)); + hashes.put(mn, ModuleHashes.generate(moduleToPath, "SHA-256")); + } + }); + return hashes; + } + + private Path moduleToPath(String name) { + ResolvedModule rm = configuration.findModule(name).orElseThrow( + () -> new InternalError("Selected module " + name + " not on module path")); + + URI uri = rm.reference().location().get(); + Path path = Paths.get(uri); + String fn = path.getFileName().toString(); + if (!fn.endsWith(".jar") && !fn.endsWith(".jmod")) { + throw new UnsupportedOperationException(path + " is not a modular JAR or jmod file"); + } + return path; + } + + /* + * Utilty class + */ + static class Graph { + private final Set nodes; + private final Map> edges; + + public Graph(Set nodes, Map> edges) { + this.nodes = Collections.unmodifiableSet(nodes); + this.edges = Collections.unmodifiableMap(edges); + } + + public Set nodes() { + return nodes; + } + + public Map> edges() { + return edges; + } + + public Set adjacentNodes(T u) { + return edges.get(u); + } + + public boolean contains(T u) { + return nodes.contains(u); + } + + /** + * Returns nodes sorted in topological order. + */ + public Stream orderedNodes() { + TopoSorter sorter = new TopoSorter<>(this); + return sorter.result.stream(); + } + + /** + * Traverse this graph and performs the given action in topological order + */ + public void ordered(Consumer action) { + TopoSorter sorter = new TopoSorter<>(this); + sorter.ordered(action); + } + + /** + * Traverses this graph and performs the given action in reverse topological order + */ + public void reverse(Consumer action) { + TopoSorter sorter = new TopoSorter<>(this); + sorter.reverse(action); + } + + /** + * Returns a transposed graph from this graph + */ + public Graph transpose() { + Builder builder = new Builder<>(); + nodes.stream().forEach(builder::addNode); + // reverse edges + edges.keySet().forEach(u -> { + edges.get(u).stream() + .forEach(v -> builder.addEdge(v, u)); + }); + return builder.build(); + } + + /** + * Returns all nodes reachable from the given root. + */ + public Set dfs(T root) { + return dfs(Set.of(root)); + } + + /** + * Returns all nodes reachable from the given set of roots. + */ + public Set dfs(Set roots) { + Deque deque = new LinkedList<>(roots); + Set visited = new HashSet<>(); + while (!deque.isEmpty()) { + T u = deque.pop(); + if (!visited.contains(u)) { + visited.add(u); + if (contains(u)) { + adjacentNodes(u).stream() + .filter(v -> !visited.contains(v)) + .forEach(deque::push); + } + } + } + return visited; + } + + public void printGraph(PrintStream out) { + out.println("graph for " + nodes); + nodes.stream() + .forEach(u -> adjacentNodes(u).stream() + .forEach(v -> out.format(" %s -> %s%n", u, v))); + } + + static class Builder { + final Set nodes = new HashSet<>(); + final Map> edges = new HashMap<>(); + + public void addNode(T node) { + if (nodes.contains(node)) { + return; + } + nodes.add(node); + edges.computeIfAbsent(node, _e -> new HashSet<>()); + } + + public void addEdge(T u, T v) { + addNode(u); + addNode(v); + edges.get(u).add(v); + } + + public Graph build() { + return new Graph(nodes, edges); + } + } + } + + /** + * Topological sort + */ + private static class TopoSorter { + final Deque result = new LinkedList<>(); + final Deque nodes; + final Graph graph; + + TopoSorter(Graph graph) { + this.graph = graph; + this.nodes = new LinkedList<>(graph.nodes); + sort(); + } + + public void ordered(Consumer action) { + result.iterator().forEachRemaining(action); + } + + public void reverse(Consumer action) { + result.descendingIterator().forEachRemaining(action); + } + + private void sort() { + Deque visited = new LinkedList<>(); + Deque done = new LinkedList<>(); + T node; + while ((node = nodes.poll()) != null) { + if (!visited.contains(node)) { + visit(node, visited, done); + } + } + } + + private void visit(T node, Deque visited, Deque done) { + if (visited.contains(node)) { + if (!done.contains(node)) { + throw new IllegalArgumentException("Cyclic detected: " + + node + " " + graph.edges().get(node)); + } + return; + } + visited.add(node); + graph.edges().get(node).stream() + .forEach(x -> visit(x, visited, done)); + done.add(node); + result.addLast(node); + } + } +} diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java index a98e0eed289..601a5371932 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; + +import jdk.internal.module.ModulePath; import jdk.internal.module.ModuleResolution; /** @@ -155,8 +157,8 @@ class GNUStyleOptions { for (String dir : dirs) { paths[i++] = Paths.get(dir); } - jartool.moduleFinder = ModuleFinder.compose(jartool.moduleFinder, - ModuleFinder.of(paths)); + jartool.moduleFinder = + new ModulePath(Runtime.version(), true, paths); } }, new Option(false, OptionType.CREATE_UPDATE, "--do-not-resolve-by-default") { diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java index 10e9d10f029..36e2ad3b78b 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java @@ -47,7 +47,6 @@ import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.*; import java.util.function.Consumer; -import java.util.function.Function; import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -60,6 +59,7 @@ import java.text.MessageFormat; import jdk.internal.module.Checks; import jdk.internal.module.ModuleHashes; +import jdk.internal.module.ModuleHashesBuilder; import jdk.internal.module.ModuleInfo; import jdk.internal.module.ModuleInfoExtender; import jdk.internal.module.ModuleResolution; @@ -68,7 +68,6 @@ import jdk.internal.util.jar.JarIndex; import static jdk.internal.util.jar.JarIndex.INDEX_NAME; import static java.util.jar.JarFile.MANIFEST_NAME; import static java.util.stream.Collectors.joining; -import static java.util.stream.Collectors.toSet; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; /** @@ -1930,8 +1929,7 @@ public class Main { if (moduleHashes != null) { extender.hashes(moduleHashes); } else { - // should it issue warning or silent? - System.out.println("warning: no module is recorded in hash in " + mn); + warn("warning: no module is recorded in hash in " + mn); } } @@ -1947,10 +1945,9 @@ public class Main { * Compute and record hashes */ private class Hasher { + final ModuleHashesBuilder hashesBuilder; final ModuleFinder finder; - final Map moduleNameToPath; final Set modules; - final Configuration configuration; Hasher(ModuleDescriptor descriptor, String fname) throws IOException { // Create a module finder that finds the modular JAR // being created/updated @@ -1980,119 +1977,46 @@ public class Main { } }); - // Determine the modules that matches the modulesToHash pattern - this.modules = moduleFinder.findAll().stream() - .map(moduleReference -> moduleReference.descriptor().name()) + // Determine the modules that matches the pattern {@code modulesToHash} + Set roots = finder.findAll().stream() + .map(ref -> ref.descriptor().name()) .filter(mn -> modulesToHash.matcher(mn).find()) .collect(Collectors.toSet()); - // a map from a module name to Path of the modular JAR - this.moduleNameToPath = moduleFinder.findAll().stream() - .map(ModuleReference::descriptor) - .map(ModuleDescriptor::name) - .collect(Collectors.toMap(Function.identity(), mn -> moduleToPath(mn))); - - Configuration config = null; - try { - config = Configuration.empty() - .resolveRequires(ModuleFinder.ofSystem(), finder, modules); - } catch (ResolutionException e) { - // should it throw an error? or emit a warning - System.out.println("warning: " + e.getMessage()); + // use system module path unless it creates a modular JAR for + // a module that is present in the system image e.g. upgradeable + // module + ModuleFinder system; + String name = descriptor.name(); + if (name != null && ModuleFinder.ofSystem().find(name).isPresent()) { + system = ModuleFinder.of(); + } else { + system = ModuleFinder.ofSystem(); } - this.configuration = config; + // get a resolved module graph + Configuration config = + Configuration.empty().resolveRequires(system, finder, roots); + + // filter modules resolved from the system module finder + this.modules = config.modules().stream() + .map(ResolvedModule::name) + .filter(mn -> roots.contains(mn) && !system.find(mn).isPresent()) + .collect(Collectors.toSet()); + + this.hashesBuilder = new ModuleHashesBuilder(config, modules); } /** - * Compute hashes of the modules that depend upon the specified + * Compute hashes of the specified module. + * + * It records the hashing modules that depend upon the specified * module directly or indirectly. */ ModuleHashes computeHashes(String name) { - // the transposed graph includes all modules in the resolved graph - Map> graph = transpose(); - - // find the modules that transitively depend upon the specified name - Deque deque = new ArrayDeque<>(); - deque.add(name); - Set mods = visitNodes(graph, deque); - - // filter modules matching the pattern specified in --hash-modules, - // as well as the modular jar file that is being created / updated - Map modulesForHash = mods.stream() - .filter(mn -> !mn.equals(name) && modules.contains(mn)) - .collect(Collectors.toMap(Function.identity(), moduleNameToPath::get)); - - if (modulesForHash.isEmpty()) + if (hashesBuilder == null) return null; - return ModuleHashes.generate(modulesForHash, "SHA-256"); - } - - /** - * Returns all nodes traversed from the given roots. - */ - private Set visitNodes(Map> graph, - Deque roots) { - Set visited = new HashSet<>(); - while (!roots.isEmpty()) { - String mn = roots.pop(); - if (!visited.contains(mn)) { - visited.add(mn); - - // the given roots may not be part of the graph - if (graph.containsKey(mn)) { - for (String dm : graph.get(mn)) { - if (!visited.contains(dm)) - roots.push(dm); - } - } - } - } - return visited; - } - - /** - * Returns a transposed graph from the resolved module graph. - */ - private Map> transpose() { - Map> transposedGraph = new HashMap<>(); - Deque deque = new ArrayDeque<>(modules); - - Set visited = new HashSet<>(); - while (!deque.isEmpty()) { - String mn = deque.pop(); - if (!visited.contains(mn)) { - visited.add(mn); - - // add an empty set - transposedGraph.computeIfAbsent(mn, _k -> new HashSet<>()); - - ResolvedModule resolvedModule = configuration.findModule(mn).get(); - for (ResolvedModule dm : resolvedModule.reads()) { - String name = dm.name(); - if (!visited.contains(name)) { - deque.push(name); - } - // reverse edge - transposedGraph.computeIfAbsent(name, _k -> new HashSet<>()) - .add(mn); - } - } - } - return transposedGraph; - } - - private Path moduleToPath(String name) { - ModuleReference mref = moduleFinder.find(name).orElseThrow( - () -> new InternalError(formatMsg2("error.hash.dep",name , name))); - - URI uri = mref.location().get(); - Path path = Paths.get(uri); - String fn = path.getFileName().toString(); - if (!fn.endsWith(".jar")) { - throw new UnsupportedOperationException(path + " is not a modular JAR"); - } - return path; + return hashesBuilder.computeHashes(Set.of(name)).get(name); } } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java index 4a8839ee16a..31e76e294ec 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,13 +58,10 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardCopyOption; import java.nio.file.attribute.BasicFileAttributes; import java.text.MessageFormat; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.Deque; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -101,6 +98,7 @@ import jdk.internal.joptsimple.OptionSpec; import jdk.internal.joptsimple.ValueConverter; import jdk.internal.loader.ResourceHelper; import jdk.internal.module.ModuleHashes; +import jdk.internal.module.ModuleHashesBuilder; import jdk.internal.module.ModuleInfo; import jdk.internal.module.ModuleInfoExtender; import jdk.internal.module.ModulePath; @@ -286,7 +284,27 @@ public class JmodTask { } private boolean hashModules() { - return new Hasher(options.moduleFinder).run(); + if (options.dryrun) { + out.println("Dry run:"); + } + + Hasher hasher = new Hasher(options.moduleFinder); + hasher.computeHashes().forEach((mn, hashes) -> { + if (options.dryrun) { + out.format("%s%n", mn); + hashes.names().stream() + .sorted() + .forEach(name -> out.format(" hashes %s %s %s%n", + name, hashes.algorithm(), toHex(hashes.hashFor(name)))); + } else { + try { + hasher.updateModuleInfo(mn, hashes); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + }); + return true; } private boolean describe() throws IOException { @@ -377,7 +395,7 @@ public class JmodTask { // create jmod with temporary name to avoid it being examined // when scanning the module path Path target = options.jmodFile; - Path tempTarget = target.resolveSibling(target.getFileName() + ".tmp"); + Path tempTarget = Files.createTempFile(target.getFileName().toString(), ".tmp"); try { try (JmodOutputStream jos = JmodOutputStream.newOutputStream(tempTarget)) { jmod.write(jos); @@ -411,7 +429,6 @@ public class JmodTask { final String osArch = options.osArch; final String osVersion = options.osVersion; final List excludes = options.excludes; - final Hasher hasher = hasher(); final ModuleResolution moduleResolution = options.moduleResolution; JmodFileWriter() { } @@ -514,8 +531,17 @@ public class JmodTask { if (moduleVersion != null) extender.version(moduleVersion); - if (hasher != null) { - ModuleHashes moduleHashes = hasher.computeHashes(descriptor.name()); + // --hash-modules + if (options.modulesToHash != null) { + // To compute hashes, it creates a Configuration to resolve + // a module graph. The post-resolution check requires + // the packages in ModuleDescriptor be available for validation. + ModuleDescriptor md; + try (InputStream is = miSupplier.get()) { + md = ModuleDescriptor.read(is, () -> packages); + } + + ModuleHashes moduleHashes = computeHashes(md); if (moduleHashes != null) { extender.hashes(moduleHashes); } else { @@ -557,50 +583,34 @@ public class JmodTask { * The jmod file is being created and does not exist in the * given modulepath. */ - private Hasher hasher() { - if (options.modulesToHash == null) - return null; - - try { - Supplier miSupplier = newModuleInfoSupplier(); - if (miSupplier == null) { - throw new IOException(MODULE_INFO + " not found"); + private ModuleHashes computeHashes(ModuleDescriptor descriptor) { + String mn = descriptor.name(); + URI uri = options.jmodFile.toUri(); + ModuleReference mref = new ModuleReference(descriptor, uri) { + @Override + public ModuleReader open() { + throw new UnsupportedOperationException("opening " + mn); } + }; - ModuleDescriptor descriptor; - try (InputStream in = miSupplier.get()) { - descriptor = ModuleDescriptor.read(in); - } - - URI uri = options.jmodFile.toUri(); - ModuleReference mref = new ModuleReference(descriptor, uri) { + // compose a module finder with the module path and also + // a module finder that can find the jmod file being created + ModuleFinder finder = ModuleFinder.compose(options.moduleFinder, + new ModuleFinder() { @Override - public ModuleReader open() { - throw new UnsupportedOperationException(); + public Optional find(String name) { + if (descriptor.name().equals(name)) + return Optional.of(mref); + else return Optional.empty(); } - }; - // compose a module finder with the module path and also - // a module finder that can find the jmod file being created - ModuleFinder finder = ModuleFinder.compose(options.moduleFinder, - new ModuleFinder() { - @Override - public Optional find(String name) { - if (descriptor.name().equals(name)) - return Optional.of(mref); - else return Optional.empty(); - } + @Override + public Set findAll() { + return Collections.singleton(mref); + } + }); - @Override - public Set findAll() { - return Collections.singleton(mref); - } - }); - - return new Hasher(finder); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + return new Hasher(mn, finder).computeHashes().get(mn); } /** @@ -789,192 +799,93 @@ public class JmodTask { * Compute and record hashes */ private class Hasher { - final ModuleFinder moduleFinder; - final Map moduleNameToPath; - final Set modules; final Configuration configuration; - final boolean dryrun = options.dryrun; + final ModuleHashesBuilder hashesBuilder; + final Set modules; + final String moduleName; // a specific module to record hashes, if set + + /** + * This constructor is for jmod hash command. + * + * This Hasher will determine which modules to record hashes, i.e. + * the module in a subgraph of modules to be hashed and that + * has no outgoing edges. It will record in each of these modules, + * say `M`, with the the hashes of modules that depend upon M + * directly or indirectly matching the specified --hash-modules pattern. + */ Hasher(ModuleFinder finder) { - this.moduleFinder = finder; + this(null, finder); + } + + /** + * Constructs a Hasher to compute hashes. + * + * If a module name `M` is specified, it will compute the hashes of + * modules that depend upon M directly or indirectly matching the + * specified --hash-modules pattern and record in the ModuleHashes + * attribute in M's module-info.class. + * + * @param name name of the module to record hashes + * @param finder module finder for the specified --module-path + */ + Hasher(String name, ModuleFinder finder) { // Determine the modules that matches the pattern {@code modulesToHash} - this.modules = moduleFinder.findAll().stream() + Set roots = finder.findAll().stream() .map(mref -> mref.descriptor().name()) .filter(mn -> options.modulesToHash.matcher(mn).find()) .collect(Collectors.toSet()); - // a map from a module name to Path of the packaged module - this.moduleNameToPath = moduleFinder.findAll().stream() - .map(mref -> mref.descriptor().name()) - .collect(Collectors.toMap(Function.identity(), mn -> moduleToPath(mn))); - + // use system module path unless it creates a JMOD file for + // a module that is present in the system image e.g. upgradeable + // module + ModuleFinder system; + if (name != null && ModuleFinder.ofSystem().find(name).isPresent()) { + system = ModuleFinder.of(); + } else { + system = ModuleFinder.ofSystem(); + } // get a resolved module graph Configuration config = null; try { - config = Configuration.empty() - .resolveRequires(ModuleFinder.ofSystem(), moduleFinder, modules); + config = Configuration.empty().resolveRequires(system, finder, roots); } catch (ResolutionException e) { - warning("warn.module.resolution.fail", e.getMessage()); + throw new CommandException("err.module.resolution.fail", e.getMessage()); } + + this.moduleName = name; this.configuration = config; + + // filter modules resolved from the system module finder + this.modules = config.modules().stream() + .map(ResolvedModule::name) + .filter(mn -> roots.contains(mn) && !system.find(mn).isPresent()) + .collect(Collectors.toSet()); + + this.hashesBuilder = new ModuleHashesBuilder(config, modules); } /** - * This method is for jmod hash command. + * Returns a map of a module M to record hashes of the modules + * that depend upon M directly or indirectly. * - * Identify the base modules in the module graph, i.e. no outgoing edge - * to any of the modules to be hashed. + * For jmod hash command, the returned map contains one entry + * for each module M that has no outgoing edges to any of the + * modules matching the specified --hash-modules pattern. * - * For each base module M, compute the hashes of all modules that depend - * upon M directly or indirectly. Then update M's module-info.class - * to record the hashes. + * Each entry represents a leaf node in a connected subgraph containing + * M and other candidate modules from the module graph where M's outgoing + * edges to any module other than the ones matching the specified + * --hash-modules pattern are excluded. */ - boolean run() { - if (configuration == null) - return false; - - // transposed graph containing the the packaged modules and - // its transitive dependences matching --hash-modules - Map> graph = new HashMap<>(); - for (String root : modules) { - Deque deque = new ArrayDeque<>(); - deque.add(root); - Set visited = new HashSet<>(); - while (!deque.isEmpty()) { - String mn = deque.pop(); - if (!visited.contains(mn)) { - visited.add(mn); - - if (modules.contains(mn)) - graph.computeIfAbsent(mn, _k -> new HashSet<>()); - - ResolvedModule resolvedModule = configuration.findModule(mn).get(); - for (ResolvedModule dm : resolvedModule.reads()) { - String name = dm.name(); - if (!visited.contains(name)) { - deque.push(name); - } - - // reverse edge - if (modules.contains(name) && modules.contains(mn)) { - graph.computeIfAbsent(name, _k -> new HashSet<>()).add(mn); - } - } - } - } - } - - if (dryrun) - out.println("Dry run:"); - - // each node in a transposed graph is a matching packaged module - // in which the hash of the modules that depend upon it is recorded - graph.entrySet().stream() - .filter(e -> !e.getValue().isEmpty()) - .forEach(e -> { - String mn = e.getKey(); - Map modulesForHash = e.getValue().stream() - .collect(Collectors.toMap(Function.identity(), - moduleNameToPath::get)); - ModuleHashes hashes = ModuleHashes.generate(modulesForHash, "SHA-256"); - if (dryrun) { - out.format("%s%n", mn); - hashes.names().stream() - .sorted() - .forEach(name -> out.format(" hashes %s %s %s%n", - name, hashes.algorithm(), hashes.hashFor(name))); - } else { - try { - updateModuleInfo(mn, hashes); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - } - }); - return true; - } - - /** - * Compute hashes of the specified module. - * - * It records the hashing modules that depend upon the specified - * module directly or indirectly. - */ - ModuleHashes computeHashes(String name) { - if (configuration == null) + Map computeHashes() { + if (hashesBuilder == null) return null; - // the transposed graph includes all modules in the resolved graph - Map> graph = transpose(); - - // find the modules that transitively depend upon the specified name - Deque deque = new ArrayDeque<>(); - deque.add(name); - Set mods = visitNodes(graph, deque); - - // filter modules matching the pattern specified --hash-modules - // as well as itself as the jmod file is being generated - Map modulesForHash = mods.stream() - .filter(mn -> !mn.equals(name) && modules.contains(mn)) - .collect(Collectors.toMap(Function.identity(), moduleNameToPath::get)); - - if (modulesForHash.isEmpty()) - return null; - - return ModuleHashes.generate(modulesForHash, "SHA-256"); - } - - /** - * Returns all nodes traversed from the given roots. - */ - private Set visitNodes(Map> graph, - Deque roots) { - Set visited = new HashSet<>(); - while (!roots.isEmpty()) { - String mn = roots.pop(); - if (!visited.contains(mn)) { - visited.add(mn); - // the given roots may not be part of the graph - if (graph.containsKey(mn)) { - for (String dm : graph.get(mn)) { - if (!visited.contains(dm)) { - roots.push(dm); - } - } - } - } + if (moduleName != null) { + return hashesBuilder.computeHashes(Set.of(moduleName)); + } else { + return hashesBuilder.computeHashes(modules); } - return visited; - } - - /** - * Returns a transposed graph from the resolved module graph. - */ - private Map> transpose() { - Map> transposedGraph = new HashMap<>(); - Deque deque = new ArrayDeque<>(modules); - - Set visited = new HashSet<>(); - while (!deque.isEmpty()) { - String mn = deque.pop(); - if (!visited.contains(mn)) { - visited.add(mn); - - transposedGraph.computeIfAbsent(mn, _k -> new HashSet<>()); - - ResolvedModule resolvedModule = configuration.findModule(mn).get(); - for (ResolvedModule dm : resolvedModule.reads()) { - String name = dm.name(); - if (!visited.contains(name)) { - deque.push(name); - } - - // reverse edge - transposedGraph.computeIfAbsent(name, _k -> new HashSet<>()) - .add(mn); - } - } - } - return transposedGraph; } /** @@ -993,11 +904,11 @@ public class JmodTask { extender.write(out); } - private void updateModuleInfo(String name, ModuleHashes moduleHashes) + void updateModuleInfo(String name, ModuleHashes moduleHashes) throws IOException { - Path target = moduleNameToPath.get(name); - Path tempTarget = target.resolveSibling(target.getFileName() + ".tmp"); + Path target = moduleToPath(name); + Path tempTarget = Files.createTempFile(target.getFileName().toString(), ".tmp"); try { if (target.getFileName().toString().endsWith(".jmod")) { updateJmodFile(target, tempTarget, moduleHashes); @@ -1075,10 +986,10 @@ public class JmodTask { } private Path moduleToPath(String name) { - ModuleReference mref = moduleFinder.find(name).orElseThrow( + ResolvedModule rm = configuration.findModule(name).orElseThrow( () -> new InternalError("Selected module " + name + " not on module path")); - URI uri = mref.location().get(); + URI uri = rm.reference().location().get(); Path path = Paths.get(uri); String fn = path.getFileName().toString(); if (!fn.endsWith(".jar") && !fn.endsWith(".jmod")) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties index dbbfd03a74d..51daee12ed3 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties @@ -108,9 +108,9 @@ err.internal.error=internal error: {0} {1} {2} err.invalid.dryrun.option=--dry-run can only be used with hash mode err.module.descriptor.not.found=Module descriptor not found err.missing.export.or.open.packages=Packages that are exported or open in {0} are not present: {1} +err.module.resolution.fail=Resolution failed: {0} warn.invalid.arg=Invalid classname or pathname not exist: {0} warn.no.module.hashes=No hashes recorded: no module specified for hashing depends on {0} -warn.module.resolution.fail=No hashes recorded: {0} warn.ignore.entry=ignoring entry {0}, in section {1} warn.ignore.duplicate.entry=ignoring duplicate entry {0}, in section {1} diff --git a/jdk/test/tools/jmod/JmodTest.java b/jdk/test/tools/jmod/JmodTest.java index 8ed6343696d..f253b491af9 100644 --- a/jdk/test/tools/jmod/JmodTest.java +++ b/jdk/test/tools/jmod/JmodTest.java @@ -579,37 +579,25 @@ public class JmodTest { }); } - @Test - public void testTmpFileAlreadyExists() throws IOException { - // Implementation detail: jmod tool creates .tmp - // Ensure that there are no problems if existing - - Path jmod = MODS_DIR.resolve("testTmpFileAlreadyExists.jmod"); - Path tmp = MODS_DIR.resolve("testTmpFileAlreadyExists.jmod.tmp"); - FileUtils.deleteFileIfExistsWithRetry(jmod); - FileUtils.deleteFileIfExistsWithRetry(tmp); - Files.createFile(tmp); - String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString(); - - jmod("create", - "--class-path", cp, - jmod.toString()) - .assertSuccess() - .resultChecker(r -> - assertTrue(Files.notExists(tmp), "Unexpected tmp file:" + tmp) - ); - } - @Test public void testTmpFileRemoved() throws IOException { // Implementation detail: jmod tool creates .tmp // Ensure that it is removed in the event of a failure. // The failure in this case is a class in the unnamed package. - Path jmod = MODS_DIR.resolve("testTmpFileRemoved.jmod"); - Path tmp = MODS_DIR.resolve("testTmpFileRemoved.jmod.tmp"); + String filename = "testTmpFileRemoved.jmod"; + Path jmod = MODS_DIR.resolve(filename); + + // clean up files FileUtils.deleteFileIfExistsWithRetry(jmod); - FileUtils.deleteFileIfExistsWithRetry(tmp); + findTmpFiles(filename).forEach(tmp -> { + try { + FileUtils.deleteFileIfExistsWithRetry(tmp); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + String cp = EXPLODED_DIR.resolve("foo").resolve("classes") + File.pathSeparator + EXPLODED_DIR.resolve("foo").resolve("classes") .resolve("jdk").resolve("test").resolve("foo").toString(); @@ -620,10 +608,22 @@ public class JmodTest { .assertFailure() .resultChecker(r -> { assertContains(r.output, "unnamed package"); - assertTrue(Files.notExists(tmp), "Unexpected tmp file:" + tmp); + Set tmpfiles = findTmpFiles(filename).collect(toSet()); + assertTrue(tmpfiles.isEmpty(), "Unexpected tmp file:" + tmpfiles); }); } + private Stream findTmpFiles(String prefix) { + try { + Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir")); + return Files.find(tmpdir, 1, (p, attrs) -> + p.getFileName().toString().startsWith(prefix) + && p.getFileName().toString().endsWith(".tmp")); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + // --- static boolean compileModule(String name, Path dest) throws IOException { diff --git a/jdk/test/tools/jmod/hashes/HashesTest.java b/jdk/test/tools/jmod/hashes/HashesTest.java index 8d4b2f68300..3700554983f 100644 --- a/jdk/test/tools/jmod/hashes/HashesTest.java +++ b/jdk/test/tools/jmod/hashes/HashesTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,19 +23,22 @@ /* * @test + * @bug 8160286 * @summary Test the recording and checking of module hashes - * @author Andrei Eremeev * @library /lib/testlibrary * @modules java.base/jdk.internal.misc * java.base/jdk.internal.module - * jdk.jlink * jdk.compiler - * @build CompilerUtils + * jdk.jartool + * jdk.jlink + * @build CompilerUtils ModuleInfoMaker * @run testng HashesTest */ +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReader; @@ -53,109 +56,311 @@ import java.util.List; import java.util.Set; import java.util.spi.ToolProvider; import java.util.stream.Collectors; +import java.util.stream.Stream; import jdk.internal.module.ModuleInfo; import jdk.internal.module.ModuleHashes; import jdk.internal.module.ModulePath; -import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import static org.testng.Assert.*; +import static java.lang.module.ModuleDescriptor.Requires.Modifier.*; public class HashesTest { static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") .orElseThrow(() -> new RuntimeException("jmod tool not found") ); + static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); - private final Path testSrc = Paths.get(System.getProperty("test.src")); - private final Path modSrc = testSrc.resolve("src"); - private final Path mods = Paths.get("mods"); - private final Path jmods = Paths.get("jmods"); - private final String[] modules = new String[] { "m1", "m2", "m3"}; - - @BeforeTest - private void setup() throws Exception { - if (Files.exists(jmods)) { - deleteDirectory(jmods); + private final Path mods; + private final Path srcDir; + private final Path lib; + private final ModuleInfoMaker builder; + HashesTest(Path dest) throws IOException { + if (Files.exists(dest)) { + deleteDirectory(dest); } - Files.createDirectories(jmods); + this.mods = dest.resolve("mods"); + this.srcDir = dest.resolve("src"); + this.lib = dest.resolve("lib"); + this.builder = new ModuleInfoMaker(srcDir); - // build m2, m3 required by m1 - compileModule("m2", modSrc); - jmod("m2"); - - compileModule("m3", modSrc); - jmod("m3"); - - // build m1 - compileModule("m1", modSrc); - // no hash is recorded since m1 has outgoing edges - jmod("m1", "--module-path", jmods.toString(), "--hash-modules", ".*"); - - // compile org.bar and org.foo - compileModule("org.bar", modSrc); - compileModule("org.foo", modSrc); + Files.createDirectories(lib); + Files.createDirectories(mods); } @Test - public void test() throws Exception { - for (String mn : modules) { - assertTrue(hashes(mn) == null); - } + public static void test() throws IOException { + Path dest = Paths.get("test"); + HashesTest ht = new HashesTest(dest); + + // create modules for test cases + ht.makeModule("m2"); + ht.makeModule("m3"); + ht.makeModule("m1", "m2", "m3"); + + ht.makeModule("org.bar", TRANSITIVE, "m1"); + ht.makeModule("org.foo", TRANSITIVE, "org.bar"); + + // create JMOD for m1, m2, m3 + ht.makeJmod("m2"); + ht.makeJmod("m3"); + + // no hash is recorded since m1 has outgoing edges + ht.jmodHashModules("m1", ".*"); + + // no hash is recorded in m1, m2, m3 + assertTrue(ht.hashes("m1") == null); + assertTrue(ht.hashes("m2") == null); + assertTrue(ht.hashes("m3") == null); // hash m1 in m2 - jmod("m2", "--module-path", jmods.toString(), "--hash-modules", "m1"); - checkHashes(hashes("m2"), "m1"); + ht.jmodHashModules("m2", "m1"); + ht.checkHashes("m2", "m1"); // hash m1 in m2 - jmod("m2", "--module-path", jmods.toString(), "--hash-modules", ".*"); - checkHashes(hashes("m2"), "m1"); + ht.jmodHashModules("m2", ".*"); + ht.checkHashes("m2", "m1"); // create m2.jmod with no hash - jmod("m2"); + ht.makeJmod("m2"); // run jmod hash command to hash m1 in m2 and m3 - runJmod(Arrays.asList("hash", "--module-path", jmods.toString(), - "--hash-modules", ".*")); - checkHashes(hashes("m2"), "m1"); - checkHashes(hashes("m3"), "m1"); + runJmod(List.of("hash", "--module-path", ht.lib.toString(), + "--hash-modules", ".*")); + ht.checkHashes("m2", "m1"); + ht.checkHashes("m3", "m1"); - jmod("org.bar"); - jmod("org.foo"); + // check transitive requires + ht.makeJmod("org.bar"); + ht.makeJmod("org.foo"); - jmod("org.bar", "--module-path", jmods.toString(), "--hash-modules", "org.*"); - checkHashes(hashes("org.bar"), "org.foo"); + ht.jmodHashModules("org.bar", "org.*"); + ht.checkHashes("org.bar", "org.foo"); - jmod("m3", "--module-path", jmods.toString(), "--hash-modules", ".*"); - checkHashes(hashes("m3"), "org.foo", "org.bar", "m1"); + ht.jmodHashModules( "m3", ".*"); + ht.checkHashes("m3", "org.foo", "org.bar", "m1"); } - private void checkHashes(ModuleHashes hashes, String... hashModules) { + @Test + public static void multiBaseModules() throws IOException { + Path dest = Paths.get("test2"); + HashesTest ht = new HashesTest(dest); + + /* + * y2 -----------> y1 + * |______ + * | | + * V V + * z3 -> z2 + * | | + * | V + * |---> z1 + */ + + ht.makeModule("z1"); + ht.makeModule("z2", "z1"); + ht.makeModule("z3", "z1", "z2"); + + ht.makeModule("y1"); + ht.makeModule("y2", "y1", "z2", "z3"); + + Set ys = Set.of("y1", "y2"); + Set zs = Set.of("z1", "z2", "z3"); + + // create JMOD files + Stream.concat(ys.stream(), zs.stream()).forEach(ht::makeJmod); + + // run jmod hash command + runJmod(List.of("hash", "--module-path", ht.lib.toString(), + "--hash-modules", ".*")); + + /* + * z1 and y1 are the modules with hashes recorded. + */ + ht.checkHashes("y1", "y2"); + ht.checkHashes("z1", "z2", "z3", "y2"); + Stream.concat(ys.stream(), zs.stream()) + .filter(mn -> !mn.equals("y1") && !mn.equals("z1")) + .forEach(mn -> assertTrue(ht.hashes(mn) == null)); + } + + @Test + public static void mixJmodAndJarFile() throws IOException { + Path dest = Paths.get("test3"); + HashesTest ht = new HashesTest(dest); + + /* + * j3 -----------> j2 + * |______ + * | | + * V V + * m3 -> m2 + * | | + * | V + * |---> m1 -> j1 -> jdk.jlink + */ + + ht.makeModule("j1"); + ht.makeModule("j2"); + ht.makeModule("m1", "j1"); + ht.makeModule("m2", "m1"); + ht.makeModule("m3", "m1", "m2"); + + ht.makeModule("j3", "j2", "m2", "m3"); + + Set jars = Set.of("j1", "j2", "j3"); + Set jmods = Set.of("m1", "m2", "m3"); + + // create JMOD and JAR files + jars.forEach(ht::makeJar); + jmods.forEach(ht::makeJmod); + + // run jmod hash command + runJmod(List.of("hash", "--module-path", ht.lib.toString(), + "--hash-modules", "^j.*|^m.*")); + + /* + * j1 and j2 are the modules with hashes recorded. + */ + ht.checkHashes("j2", "j3"); + ht.checkHashes("j1", "m1", "m2", "m3", "j3"); + Stream.concat(jars.stream(), jmods.stream()) + .filter(mn -> !mn.equals("j1") && !mn.equals("j2")) + .forEach(mn -> assertTrue(ht.hashes(mn) == null)); + } + + @Test + public static void upgradeableModule() throws IOException { + Path mpath = Paths.get(System.getProperty("java.home"), "jmods"); + if (!Files.exists(mpath)) { + return; + } + + Path dest = Paths.get("test4"); + HashesTest ht = new HashesTest(dest); + ht.makeModule("m1"); + ht.makeModule("java.xml.bind", "m1"); + ht.makeModule("java.xml.ws", "java.xml.bind"); + ht.makeModule("m2", "java.xml.ws"); + + ht.makeJmod("m1"); + ht.makeJmod("m2"); + ht.makeJmod("java.xml.ws"); + ht.makeJmod("java.xml.bind", + "--module-path", + ht.lib.toString() + File.pathSeparator + mpath, + "--hash-modules", "^java.xml.*|^m.*"); + + ht.checkHashes("java.xml.bind", "java.xml.ws", "m2"); + } + + @Test + public static void testImageJmods() throws IOException { + Path mpath = Paths.get(System.getProperty("java.home"), "jmods"); + if (!Files.exists(mpath)) { + return; + } + + Path dest = Paths.get("test5"); + HashesTest ht = new HashesTest(dest); + ht.makeModule("m1", "jdk.compiler", "jdk.attach"); + ht.makeModule("m2", "m1"); + ht.makeModule("m3", "java.compiler"); + + ht.makeJmod("m1"); + ht.makeJmod("m2"); + + runJmod(List.of("hash", + "--module-path", + mpath.toString() + File.pathSeparator + ht.lib.toString(), + "--hash-modules", ".*")); + + validateImageJmodsTest(ht, mpath); + } + + @Test + public static void testImageJmods1() throws IOException { + Path mpath = Paths.get(System.getProperty("java.home"), "jmods"); + if (!Files.exists(mpath)) { + return; + } + + Path dest = Paths.get("test6"); + HashesTest ht = new HashesTest(dest); + ht.makeModule("m1", "jdk.compiler", "jdk.attach"); + ht.makeModule("m2", "m1"); + ht.makeModule("m3", "java.compiler"); + + ht.makeJar("m2"); + ht.makeJar("m1", + "--module-path", + mpath.toString() + File.pathSeparator + ht.lib.toString(), + "--hash-modules", ".*"); + validateImageJmodsTest(ht, mpath); + } + + private static void validateImageJmodsTest(HashesTest ht, Path mpath) + throws IOException + { + // hash is recorded in m1 and not any other packaged modules on module path + ht.checkHashes("m1", "m2"); + assertTrue(ht.hashes("m2") == null); + + // should not override any JDK packaged modules + ModuleFinder finder = new ModulePath(Runtime.version(), + true, + mpath); + assertTrue(ht.hashes(finder,"jdk.compiler") == null); + assertTrue(ht.hashes(finder,"jdk.attach") == null); + } + + private void checkHashes(String mn, String... hashModules) throws IOException { + ModuleHashes hashes = hashes(mn); assertTrue(hashes.names().equals(Set.of(hashModules))); } - private ModuleHashes hashes(String name) throws Exception { + private ModuleHashes hashes(String name) { ModuleFinder finder = new ModulePath(Runtime.version(), true, - jmods.resolve(name + ".jmod")); + lib); + return hashes(finder, name); + } + + private ModuleHashes hashes(ModuleFinder finder, String name) { ModuleReference mref = finder.find(name).orElseThrow(RuntimeException::new); - ModuleReader reader = mref.open(); - try (InputStream in = reader.open("module-info.class").get()) { - ModuleHashes hashes = ModuleInfo.read(in, null).recordedHashes(); - System.out.format("hashes in module %s %s%n", name, + try { + ModuleReader reader = mref.open(); + try (InputStream in = reader.open("module-info.class").get()) { + ModuleHashes hashes = ModuleInfo.read(in, null).recordedHashes(); + System.out.format("hashes in module %s %s%n", name, (hashes != null) ? "present" : "absent"); - if (hashes != null) { - hashes.names().stream() - .sorted() - .forEach(n -> System.out.format(" %s %s%n", n, hashes.hashFor(n))); + if (hashes != null) { + hashes.names().stream().sorted().forEach(n -> + System.out.format(" %s %s%n", n, toHex(hashes.hashFor(n))) + ); + } + return hashes; + } finally { + reader.close(); } - return hashes; - } finally { - reader.close(); + } catch (IOException e) { + throw new UncheckedIOException(e); } } + private String toHex(byte[] ba) { + StringBuilder sb = new StringBuilder(ba.length); + for (byte b: ba) { + sb.append(String.format("%02x", b & 0xff)); + } + return sb.toString(); + } + private void deleteDirectory(Path dir) throws IOException { Files.walkFileTree(dir, new SimpleFileVisitor() { @Override @@ -176,31 +381,94 @@ public class HashesTest { }); } + + private void makeModule(String mn, String... deps) throws IOException { + makeModule(mn, null, deps); + } + + private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod, String... deps) + throws IOException + { + if (mod != null && mod != TRANSITIVE && mod != STATIC) { + throw new IllegalArgumentException(mod.toString()); + } + + StringBuilder sb = new StringBuilder(); + sb.append("module " + mn + " {").append("\n"); + Arrays.stream(deps).forEach(req -> { + sb.append(" requires "); + if (mod != null) { + sb.append(mod.toString().toLowerCase()).append(" "); + } + sb.append(req + ";\n"); + }); + sb.append("}\n"); + builder.writeJavaFiles(mn, sb.toString()); + + compileModule(mn, srcDir); + } + private void compileModule(String moduleName, Path src) throws IOException { Path msrc = src.resolve(moduleName); assertTrue(CompilerUtils.compile(msrc, mods, "--module-source-path", src.toString())); } - private void jmod(String moduleName, String... options) throws IOException { + private void jmodHashModules(String moduleName, String hashModulesPattern) { + makeJmod(moduleName, "--module-path", lib.toString(), + "--hash-modules", hashModulesPattern); + } + + private void makeJmod(String moduleName, String... options) { Path mclasses = mods.resolve(moduleName); - Path outfile = jmods.resolve(moduleName + ".jmod"); + Path outfile = lib.resolve(moduleName + ".jmod"); List args = new ArrayList<>(); args.add("create"); Collections.addAll(args, options); Collections.addAll(args, "--class-path", mclasses.toString(), outfile.toString()); - if (Files.exists(outfile)) - Files.delete(outfile); - + if (Files.exists(outfile)) { + try { + Files.delete(outfile); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } runJmod(args); } - private void runJmod(List args) { + private static void runJmod(List args) { int rc = JMOD_TOOL.run(System.out, System.out, args.toArray(new String[args.size()])); - System.out.println("jmod options: " + args.stream().collect(Collectors.joining(" "))); + System.out.println("jmod " + args.stream().collect(Collectors.joining(" "))); if (rc != 0) { - throw new AssertionError("Jmod failed: rc = " + rc); + throw new AssertionError("jmod failed: rc = " + rc); + } + } + + private void makeJar(String moduleName, String... options) { + Path mclasses = mods.resolve(moduleName); + Path outfile = lib.resolve(moduleName + ".jar"); + List args = new ArrayList<>(); + Stream.concat(Stream.of("--create", + "--file=" + outfile.toString()), + Arrays.stream(options)) + .forEach(args::add); + args.add("-C"); + args.add(mclasses.toString()); + args.add("."); + + if (Files.exists(outfile)) { + try { + Files.delete(outfile); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + int rc = JAR_TOOL.run(System.out, System.out, args.toArray(new String[args.size()])); + System.out.println("jar " + args.stream().collect(Collectors.joining(" "))); + if (rc != 0) { + throw new AssertionError("jar failed: rc = " + rc); } } } diff --git a/jdk/test/tools/jmod/hashes/src/m1/module-info.java b/jdk/test/tools/jmod/hashes/src/m1/module-info.java deleted file mode 100644 index be3af51bf37..00000000000 --- a/jdk/test/tools/jmod/hashes/src/m1/module-info.java +++ /dev/null @@ -1,27 +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. - */ - -module m1 { - requires m2; - requires m3; -} diff --git a/jdk/test/tools/jmod/hashes/src/m1/org/m1/Main.java b/jdk/test/tools/jmod/hashes/src/m1/org/m1/Main.java deleted file mode 100644 index 4108327b1fe..00000000000 --- a/jdk/test/tools/jmod/hashes/src/m1/org/m1/Main.java +++ /dev/null @@ -1,34 +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. - */ - -package org.m1; - -import org.m2.Util; -import org.m3.Name; - -public class Main { - public static void main(String[] args) { - System.out.println(Util.timeOfDay()); - System.out.println(Name.name()); - } -} diff --git a/jdk/test/tools/jmod/hashes/src/m2/module-info.java b/jdk/test/tools/jmod/hashes/src/m2/module-info.java deleted file mode 100644 index 4489049b402..00000000000 --- a/jdk/test/tools/jmod/hashes/src/m2/module-info.java +++ /dev/null @@ -1,26 +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. - */ - -module m2 { - exports org.m2; -} diff --git a/jdk/test/tools/jmod/hashes/src/m2/org/m2/Util.java b/jdk/test/tools/jmod/hashes/src/m2/org/m2/Util.java deleted file mode 100644 index b6ae4950971..00000000000 --- a/jdk/test/tools/jmod/hashes/src/m2/org/m2/Util.java +++ /dev/null @@ -1,32 +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. - */ - -package org.m2; - -public class Util { - private Util() { } - - public static String timeOfDay() { - return "Time for lunch"; - } -} diff --git a/jdk/test/tools/jmod/hashes/src/m3/module-info.java b/jdk/test/tools/jmod/hashes/src/m3/module-info.java deleted file mode 100644 index a39d7ba860e..00000000000 --- a/jdk/test/tools/jmod/hashes/src/m3/module-info.java +++ /dev/null @@ -1,26 +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. - */ - -module m3 { - exports org.m3; -} diff --git a/jdk/test/tools/jmod/hashes/src/m3/org/m3/Name.java b/jdk/test/tools/jmod/hashes/src/m3/org/m3/Name.java deleted file mode 100644 index 62040eb55b2..00000000000 --- a/jdk/test/tools/jmod/hashes/src/m3/org/m3/Name.java +++ /dev/null @@ -1,32 +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. - */ - -package org.m3; - -public class Name { - private Name() { } - - public static String name() { - return "m3"; - } -} diff --git a/jdk/test/tools/jmod/hashes/src/org.bar/module-info.java b/jdk/test/tools/jmod/hashes/src/org.bar/module-info.java deleted file mode 100644 index 8a130077fec..00000000000 --- a/jdk/test/tools/jmod/hashes/src/org.bar/module-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -module org.bar { - requires transitive m1; -} diff --git a/jdk/test/tools/jmod/hashes/src/org.foo/module-info.java b/jdk/test/tools/jmod/hashes/src/org.foo/module-info.java deleted file mode 100644 index 056399028b6..00000000000 --- a/jdk/test/tools/jmod/hashes/src/org.foo/module-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -module org.foo { - requires transitive org.bar; -} From f1eb002e955abea522b6938d032ad5a7b379eb89 Mon Sep 17 00:00:00 2001 From: Srikanth Adayapalam Date: Tue, 17 Jan 2017 09:17:10 +0530 Subject: [PATCH 109/154] 8171993: AssertionError when compiling method reference with generic code and varargs Reviewed-by: mcimadamore --- .../sun/tools/javac/comp/LambdaToMethod.java | 1 + .../lambda/MethodReferenceVarargsTest.java | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 langtools/test/tools/javac/lambda/MethodReferenceVarargsTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index b4ef9d2a770..7868d9e6f9c 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -792,6 +792,7 @@ public class LambdaToMethod extends TreeTranslator { switch (tree.getTag()) { case APPLY: ((JCMethodInvocation)tree).varargsElement = varargsElement; break; case NEWCLASS: ((JCNewClass)tree).varargsElement = varargsElement; break; + case TYPECAST: setVarargsIfNeeded(((JCTypeCast) tree).expr, varargsElement); break; default: throw new AssertionError(); } } diff --git a/langtools/test/tools/javac/lambda/MethodReferenceVarargsTest.java b/langtools/test/tools/javac/lambda/MethodReferenceVarargsTest.java new file mode 100644 index 00000000000..7648ca4bb9f --- /dev/null +++ b/langtools/test/tools/javac/lambda/MethodReferenceVarargsTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8171993 + * @summary AssertionError when compiling method reference with generic code and varargs. + * @compile MethodReferenceVarargsTest.java + */ + +public class MethodReferenceVarargsTest { + public T invoke(Object... args) { + return null; + } + public static void test() { // works with alone. + MethodReferenceVarargsTest bug = new MethodReferenceVarargsTest<>(); + java.util.function.Function b = bug::invoke; + java.util.function.Function f = (args) -> bug.invoke(args); + } +} \ No newline at end of file From 53792b463ecfad0429230664aad728561921dd17 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 17 Jan 2017 07:41:04 +0100 Subject: [PATCH 110/154] 8172262: packages missing from docs build Do not return packages without members from Elements.getPackageElement(String), to avoid ambiguities among such packages in multiple modules. Reviewed-by: jjg --- .../sun/tools/javac/model/JavacElements.java | 38 +++++++++++++++--- .../tools/javac/resources/compiler.properties | 6 ++- .../tools/javac/diags/examples.not-yet.txt | 1 + .../javac/modules/AnnotationProcessing.java | 40 +++++++++++++++---- 4 files changed, 71 insertions(+), 14 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java index 24e48c04a25..34cba3183d6 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java @@ -25,9 +25,11 @@ package com.sun.tools.javac.model; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.lang.model.AnnotatedConstruct; import javax.lang.model.SourceVersion; @@ -67,6 +69,7 @@ import static com.sun.tools.javac.code.TypeTag.CLASS; import com.sun.tools.javac.comp.Modules; import com.sun.tools.javac.comp.Resolve; import com.sun.tools.javac.comp.Resolve.RecoveryLoadClass; +import com.sun.tools.javac.resources.CompilerProperties.Notes; import static com.sun.tools.javac.tree.JCTree.Tag.*; /** @@ -87,6 +90,8 @@ public class JavacElements implements Elements { private final Enter enter; private final Resolve resolve; private final JavacTaskImpl javacTaskImpl; + private final Log log; + private final boolean allowModules; public static JavacElements instance(Context context) { JavacElements instance = context.get(JavacElements.class); @@ -106,6 +111,9 @@ public class JavacElements implements Elements { resolve = Resolve.instance(context); JavacTask t = context.get(JavacTask.class); javacTaskImpl = t instanceof JavacTaskImpl ? (JavacTaskImpl) t : null; + log = Log.instance(context); + Source source = Source.instance(context); + allowModules = source.allowModules(); } @Override @DefinedBy(Api.LANGUAGE_MODEL) @@ -134,7 +142,7 @@ public class JavacElements implements Elements { ensureEntered("getPackageElement"); if (name.length() == 0) return syms.unnamedModule.unnamedPackage; - return doGetElement(module, name, PackageSymbol.class); + return doGetElement(module, "getPackageElement", name, PackageSymbol.class); } @Override @DefinedBy(Api.LANGUAGE_MODEL) @@ -151,22 +159,27 @@ public class JavacElements implements Elements { private ClassSymbol doGetTypeElement(ModuleElement module, CharSequence name) { ensureEntered("getTypeElement"); - return doGetElement(module, name, ClassSymbol.class); + return doGetElement(module, "getTypeElement", name, ClassSymbol.class); } - private S doGetElement(ModuleElement module, CharSequence name, Class clazz) { + private S doGetElement(ModuleElement module, String methodName, + CharSequence name, Class clazz) { String strName = name.toString(); if (!SourceVersion.isName(strName)) { return null; } if (module == null) { - return unboundNameToSymbol(strName, clazz); + return unboundNameToSymbol(methodName, strName, clazz); } else { return nameToSymbol((ModuleSymbol) module, strName, clazz); } } - private S unboundNameToSymbol(String nameStr, Class clazz) { + private final Set alreadyWarnedDuplicates = new HashSet<>(); + + private S unboundNameToSymbol(String methodName, + String nameStr, + Class clazz) { if (modules.getDefaultModule() == syms.noModule) { //not a modular mode: return nameToSymbol(syms.noModule, nameStr, clazz); } @@ -179,12 +192,25 @@ public class JavacElements implements Elements { S sym = nameToSymbol(msym, nameStr, clazz); if (sym != null) { - found.add(sym); + if (!allowModules || clazz == ClassSymbol.class || !sym.members().isEmpty()) { + //do not add packages without members: + found.add(sym); + } } } if (found.size() == 1) { return found.iterator().next(); + } else if (found.size() > 1) { + //more than one element found, produce a note: + if (alreadyWarnedDuplicates.add(methodName + ":" + nameStr)) { + String moduleNames = found.stream() + .map(s -> s.packge().modle) + .map(m -> m.toString()) + .collect(Collectors.joining(", ")); + log.note(Notes.MultipleElements(methodName, nameStr, moduleNames)); + } + return null; } else { //not found, or more than one element found: return null; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 3e3e88195ae..5da57e1e35c 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -1436,6 +1436,10 @@ compiler.note.unchecked.plural.additional=\ compiler.note.proc.messager=\ {0} +# 0: string, 1: string, 2: string +compiler.note.multiple.elements=\ + Multiple elements named '{1}' in modules '{2}' were found by javax.lang.model.util.Elements.{0}. + ##### # 0: number diff --git a/langtools/test/tools/javac/diags/examples.not-yet.txt b/langtools/test/tools/javac/diags/examples.not-yet.txt index ba3a1682adf..367c4aec9e0 100644 --- a/langtools/test/tools/javac/diags/examples.not-yet.txt +++ b/langtools/test/tools/javac/diags/examples.not-yet.txt @@ -120,6 +120,7 @@ compiler.misc.bad.class.file # class file is malforme compiler.misc.bad.const.pool.entry # constant pool entry has wrong type compiler.warn.access.to.member.from.serializable.lambda # in order to generate it we need to modify a restricted package compiler.warn.invalid.path # this warning is generated only in Windows systems +compiler.note.multiple.elements # needs user code # The following module-related messages will have to stay on the not-yet list for various reasons: compiler.warn.locn.unknown.file.on.module.path # Never issued ATM (short circuited with an if (false)) diff --git a/langtools/test/tools/javac/modules/AnnotationProcessing.java b/langtools/test/tools/javac/modules/AnnotationProcessing.java index d0606a5c3ce..23066df7f25 100644 --- a/langtools/test/tools/javac/modules/AnnotationProcessing.java +++ b/langtools/test/tools/javac/modules/AnnotationProcessing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 8133884 8162711 8133896 8172158 + * @bug 8133884 8162711 8133896 8172158 8172262 * @summary Verify that annotation processing works. * @library /tools/lib * @modules @@ -50,6 +50,7 @@ import java.util.Objects; import java.util.Set; import java.util.concurrent.Callable; import java.util.function.Function; +import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.annotation.processing.AbstractProcessor; @@ -1067,24 +1068,43 @@ public class AnnotationProcessing extends ModuleTestBase { "package impl1; public class Impl { }", "package impl.conflict.module; class Impl { }", "package impl.conflict.clazz; public class pkg { public static class I { } }", - "package impl.conflict.src; public class Impl { }"); + "package impl.conflict.src; public class Impl { }", + "package nested.pack.pack; public class Impl { }", + "package unique.nested; public class Impl { }"); tb.writeJavaFiles(m2, "module m2x { }", "package impl2; public class Impl { }", "package impl.conflict.module; class Impl { }", - "package impl.conflict; public class clazz { public static class pkg { } }"); + "package impl.conflict; public class clazz { public static class pkg { } }", + "package nested.pack; public class Impl { }"); //from source: - new JavacTask(tb) + String log = new JavacTask(tb) .options("--module-source-path", moduleSrc.toString(), "--source-path", src.toString(), "-processorpath", System.getProperty("test.class.path"), - "-processor", UnboundLookup.class.getName()) + "-processor", UnboundLookup.class.getName(), + "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(moduleSrc)) .run() - .writeAll(); + .writeAll() + .getOutput(OutputKind.DIRECT); + + String moduleImplConflictString = + "- compiler.note.multiple.elements: getTypeElement, impl.conflict.module.Impl, m2x, m1x"; + String srcConflictString = + "- compiler.note.multiple.elements: getTypeElement, impl.conflict.src.Impl, m1x, unnamed module"; + + if (!log.contains(moduleImplConflictString) || + !log.contains(srcConflictString)) { + throw new AssertionError("Expected output not found: " + log); + } + + if (log.split(Pattern.quote(moduleImplConflictString)).length > 2) { + throw new AssertionError("Too many warnings in: " + log); + } new JavacTask(tb) .options("--source-path", src.toString()) @@ -1130,11 +1150,17 @@ public class AnnotationProcessing extends ModuleTestBase { assertTypeElementExists("impl.conflict.clazz", "m2x"); assertPackageElementExists("impl.conflict.clazz", "m1x"); assertPackageElementExists("impl2", "m2x"); + assertPackageElementExists("nested.pack.pack", "m1x"); + assertPackageElementExists("nested.pack", "m2x"); + assertTypeElementExists("unique.nested.Impl", "m1x"); assertTypeElementNotFound("impl.conflict.module.Impl"); + assertTypeElementNotFound("impl.conflict.module.Impl"); //check that the warning/note is produced only once assertPackageElementNotFound("impl.conflict.module"); assertTypeElementNotFound("impl.conflict.src.Impl"); assertPackageElementNotFound("impl.conflict.src"); assertTypeElementNotFound("impl.conflict.clazz.pkg"); + assertPackageElementNotFound("unique"); //do not return packages without members in module mode + assertTypeElementNotFound("nested"); //cannot distinguish between m1x and m2x return false; } From ffab9993d7ae208b20b65c38a29464ba2fe23d05 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Tue, 17 Jan 2017 18:24:28 +0300 Subject: [PATCH 111/154] 8161732: [TEST_BUG] Test closed/java/awt/MenuBar/MenuBarPeer/MenuBarPeerDisposeTest.java fails in unix enviroments with NullPointerException Reviewed-by: yan --- .../unix/classes/sun/awt/X11/XMenuBarPeer.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java index c9a8108a2e9..65dda8489f1 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -248,9 +248,11 @@ public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer { XMenuItemPeer.TextMetrics[] itemMetrics = new XMenuItemPeer.TextMetrics[itemCnt]; for (int i = 0; i < itemCnt; i++) { itemMetrics[i] = itemVector[i].getTextMetrics(); - Dimension dim = itemMetrics[i].getTextDimension(); - if (dim != null) { - maxHeight = Math.max(maxHeight, dim.height); + if (itemMetrics[i] != null) { + Dimension dim = itemMetrics[i].getTextDimension(); + if (dim != null) { + maxHeight = Math.max(maxHeight, dim.height); + } } } //Calculate bounds @@ -260,6 +262,9 @@ public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer { for (int i = 0; i < itemCnt; i++) { XMenuItemPeer item = itemVector[i]; XMenuItemPeer.TextMetrics metrics = itemMetrics[i]; + if (metrics == null) { + continue; + } Dimension dim = metrics.getTextDimension(); if (dim != null) { int itemWidth = BAR_ITEM_MARGIN_LEFT + dim.width + BAR_ITEM_MARGIN_RIGHT; @@ -280,9 +285,6 @@ public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer { Point textOrigin = new Point(nextOffset + BAR_ITEM_MARGIN_LEFT, BAR_SPACING_TOP + BAR_ITEM_MARGIN_TOP + y); nextOffset += itemWidth + BAR_ITEM_SPACING; item.map(bounds, textOrigin); - } else { - Rectangle bounds = new Rectangle(nextOffset, BAR_SPACING_TOP, 0, 0); - Point textOrigin = new Point(nextOffset + BAR_ITEM_MARGIN_LEFT, BAR_SPACING_TOP + BAR_ITEM_MARGIN_TOP); } } XMenuItemPeer mappedVector[] = new XMenuItemPeer[mappedCnt]; From 842350c6669a3aae89c2daf6126b730484599c3e Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Tue, 17 Jan 2017 11:34:47 -0800 Subject: [PATCH 112/154] 8171139: Simplify ResourceBundle.CacheKey and ClassLoader may not be needed Reviewed-by: dfuchs --- .../classes/java/util/ResourceBundle.java | 345 +++++++----------- .../ResourceBundle/ResourceBundleTest.java | 61 +++- 2 files changed, 186 insertions(+), 220 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java index 109ca64a42e..a1f2779deef 100644 --- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java +++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java @@ -43,6 +43,7 @@ package java.util; import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; +import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; @@ -365,7 +366,7 @@ public abstract class ResourceBundle { @Override public ResourceBundle getBundle(String baseName, Locale locale, Module module) { // use the given module as the caller to bypass the access check - return getBundleImpl(module, module, getLoader(module), + return getBundleImpl(module, module, baseName, locale, Control.INSTANCE); } @@ -537,63 +538,19 @@ public abstract class ResourceBundle { return locale; } - /* - * Automatic determination of the ClassLoader to be used to load - * resources on behalf of the client. - */ - private static ClassLoader getLoader(Class caller) { - ClassLoader cl = caller == null ? null : caller.getClassLoader(); - if (cl == null) { - // When the caller's loader is the boot class loader, cl is null - // here. In that case, ClassLoader.getSystemClassLoader() may - // return the same class loader that the application is - // using. We therefore use a wrapper ClassLoader to create a - // separate scope for bundles loaded on behalf of the Java - // runtime so that these bundles cannot be returned from the - // cache to the application (5048280). - cl = RBClassLoader.INSTANCE; - } - return cl; - } - private static ClassLoader getLoader(Module module) { PrivilegedAction pa = module::getClassLoader; return AccessController.doPrivileged(pa); } /** - * A wrapper of ClassLoader.getSystemClassLoader(). + * @param module a non-null-screened module form the {@link CacheKey#getModule()}. + * @return the ClassLoader to use in {@link Control#needsReload} + * and {@link Control#newBundle} */ - private static class RBClassLoader extends ClassLoader { - private static final RBClassLoader INSTANCE = AccessController.doPrivileged( - new PrivilegedAction() { - public RBClassLoader run() { - return new RBClassLoader(); - } - }); - private RBClassLoader() { - } - public Class loadClass(String name) throws ClassNotFoundException { - ClassLoader loader = ClassLoader.getSystemClassLoader(); - if (loader != null) { - return loader.loadClass(name); - } - return Class.forName(name); - } - public URL getResource(String name) { - ClassLoader loader = ClassLoader.getSystemClassLoader(); - if (loader != null) { - return loader.getResource(name); - } - return ClassLoader.getSystemResource(name); - } - public InputStream getResourceAsStream(String name) { - ClassLoader loader = ClassLoader.getSystemClassLoader(); - if (loader != null) { - return loader.getResourceAsStream(name); - } - return ClassLoader.getSystemResourceAsStream(name); - } + private static ClassLoader getLoaderForControl(Module module) { + ClassLoader loader = getLoader(module); + return loader == null ? ClassLoader.getSystemClassLoader() : loader; } /** @@ -610,23 +567,23 @@ public abstract class ResourceBundle { /** * Key used for cached resource bundles. The key checks the base - * name, the locale, the class loader, and the caller module + * name, the locale, the bundle module, and the caller module * to determine if the resource is a match to the requested one. - * The loader may be null, but the base name, the locale and - * module must have a non-null value. + * The base name, the locale and both modules must have a non-null value. */ - private static class CacheKey implements Cloneable { + private static final class CacheKey { // These four are the actual keys for lookup in Map. - private String name; - private Locale locale; - private KeyElementReference loaderRef; - private KeyElementReference moduleRef; - private KeyElementReference callerRef; - + private final String name; + private volatile Locale locale; + private final KeyElementReference moduleRef; + private final KeyElementReference callerRef; + // this is the part of hashCode that pertains to module and callerModule + // which can be GCed.. + private final int modulesHash; // bundle format which is necessary for calling // Control.needsReload(). - private String format; + private volatile String format; // These time values are in CacheKey so that NONEXISTENT_BUNDLE // doesn't need to be cloned for caching. @@ -639,63 +596,55 @@ public abstract class ResourceBundle { private volatile long expirationTime; // Placeholder for an error report by a Throwable - private Throwable cause; - - // Hash code value cache to avoid recalculating the hash code - // of this instance. - private int hashCodeCache; + private volatile Throwable cause; // ResourceBundleProviders for loading ResourceBundles - private ServiceLoader providers; - private boolean providersChecked; + private volatile ServiceLoader providers; + private volatile boolean providersChecked; // Boolean.TRUE if the factory method caller provides a ResourceBundleProvier. - private Boolean callerHasProvider; + private volatile Boolean callerHasProvider; - CacheKey(String baseName, Locale locale, ClassLoader loader, Module module, Module caller) { + CacheKey(String baseName, Locale locale, Module module, Module caller) { Objects.requireNonNull(module); + Objects.requireNonNull(caller); this.name = baseName; this.locale = locale; - if (loader == null) { - this.loaderRef = null; - } else { - this.loaderRef = new KeyElementReference<>(loader, referenceQueue, this); - } this.moduleRef = new KeyElementReference<>(module, referenceQueue, this); this.callerRef = new KeyElementReference<>(caller, referenceQueue, this); + this.modulesHash = module.hashCode() ^ caller.hashCode(); + } - calculateHashCode(); + CacheKey(CacheKey src) { + // Create References to src's modules + this.moduleRef = new KeyElementReference<>( + Objects.requireNonNull(src.getModule()), referenceQueue, this); + this.callerRef = new KeyElementReference<>( + Objects.requireNonNull(src.getCallerModule()), referenceQueue, this); + // Copy fields from src. ResourceBundleProviders related fields + // and "cause" should not be copied. + this.name = src.name; + this.locale = src.locale; + this.modulesHash = src.modulesHash; + this.format = src.format; + this.loadTime = src.loadTime; + this.expirationTime = src.expirationTime; } String getName() { return name; } - CacheKey setName(String baseName) { - if (!this.name.equals(baseName)) { - this.name = baseName; - calculateHashCode(); - } - return this; - } - Locale getLocale() { return locale; } CacheKey setLocale(Locale locale) { - if (!this.locale.equals(locale)) { - this.locale = locale; - calculateHashCode(); - } + this.locale = locale; return this; } - ClassLoader getLoader() { - return (loaderRef != null) ? loaderRef.get() : null; - } - Module getModule() { return moduleRef.get(); } @@ -728,7 +677,7 @@ public abstract class ResourceBundle { try { final CacheKey otherEntry = (CacheKey)other; //quick check to see if they are not equal - if (hashCodeCache != otherEntry.hashCodeCache) { + if (modulesHash != otherEntry.modulesHash) { return false; } //are the names the same? @@ -739,24 +688,11 @@ public abstract class ResourceBundle { if (!locale.equals(otherEntry.locale)) { return false; } - //are refs (both non-null) or (both null)? - if (loaderRef == null) { - return otherEntry.loaderRef == null; - } - ClassLoader loader = getLoader(); + // are modules and callerModules the same and non-null? Module module = getModule(); Module caller = getCallerModule(); - - return (otherEntry.loaderRef != null) - // with a null reference we can no longer find - // out which class loader or module was referenced; so - // treat it as unequal - && (loader != null) - && (loader == otherEntry.getLoader()) - && (module != null) - && (module.equals(otherEntry.getModule())) - && (caller != null) - && (caller.equals(otherEntry.getCallerModule())); + return ((module != null) && (module.equals(otherEntry.getModule())) && + (caller != null) && (caller.equals(otherEntry.getCallerModule()))); } catch (NullPointerException | ClassCastException e) { } return false; @@ -764,51 +700,7 @@ public abstract class ResourceBundle { @Override public int hashCode() { - return hashCodeCache; - } - - private void calculateHashCode() { - hashCodeCache = name.hashCode() << 3; - hashCodeCache ^= locale.hashCode(); - ClassLoader loader = getLoader(); - if (loader != null) { - hashCodeCache ^= loader.hashCode(); - } - Module module = getModule(); - if (module != null) { - hashCodeCache ^= module.hashCode(); - } - Module caller = getCallerModule(); - if (caller != null) { - hashCodeCache ^= caller.hashCode(); - } - } - - @Override - public Object clone() { - try { - CacheKey clone = (CacheKey) super.clone(); - if (loaderRef != null) { - clone.loaderRef = new KeyElementReference<>(getLoader(), - referenceQueue, clone); - } - clone.moduleRef = new KeyElementReference<>(getModule(), - referenceQueue, clone); - clone.callerRef = new KeyElementReference<>(getCallerModule(), - referenceQueue, clone); - - // Clear the reference to ResourceBundleProviders and the flag - clone.providers = null; - clone.providersChecked = false; - // Clear the reference to a Throwable - clone.cause = null; - // Clear callerHasProvider - clone.callerHasProvider = null; - return clone; - } catch (CloneNotSupportedException e) { - //this should never happen - throw new InternalError(e); - } + return (name.hashCode() << 3) ^ locale.hashCode() ^ modulesHash; } String getFormat() { @@ -845,8 +737,12 @@ public abstract class ResourceBundle { l = "\"\""; } } - return "CacheKey[" + name + ", lc=" + l + ", ldr=" + getLoader() - + "(format=" + format + ")]"; + return "CacheKey[" + name + + ", locale=" + l + + ", module=" + getModule() + + ", callerModule=" + getCallerModule() + + ", format=" + format + + "]"; } } @@ -1568,7 +1464,7 @@ public abstract class ResourceBundle { Locale locale, Class caller, Control control) { - return getBundleImpl(baseName, locale, caller, getLoader(caller), control); + return getBundleImpl(baseName, locale, caller, caller.getClassLoader(), control); } /** @@ -1587,26 +1483,25 @@ public abstract class ResourceBundle { Class caller, ClassLoader loader, Control control) { - if (caller != null && caller.getModule().isNamed()) { - Module module = caller.getModule(); - ClassLoader ml = getLoader(module); - // get resource bundles for a named module only - // if loader is the module's class loader - if (loader == ml || (ml == null && loader == RBClassLoader.INSTANCE)) { - return getBundleImpl(module, module, loader, baseName, locale, control); - } - } - // find resource bundles from unnamed module - Module unnamedModule = loader != null - ? loader.getUnnamedModule() - : ClassLoader.getSystemClassLoader().getUnnamedModule(); - if (caller == null) { throw new InternalError("null caller"); } - Module callerModule = caller.getModule(); - return getBundleImpl(callerModule, unnamedModule, loader, baseName, locale, control); + + // get resource bundles for a named module only if loader is the module's class loader + if (callerModule.isNamed() && loader == getLoader(callerModule)) { + return getBundleImpl(callerModule, callerModule, baseName, locale, control); + } + + // find resource bundles from unnamed module of given class loader + // Java agent can add to the bootclasspath e.g. via + // java.lang.instrument.Instrumentation and load classes in unnamed module. + // It may call RB::getBundle that will end up here with loader == null. + Module unnamedModule = loader != null + ? loader.getUnnamedModule() + : BootLoader.getUnnamedModule(); + + return getBundleImpl(callerModule, unnamedModule, baseName, locale, control); } private static ResourceBundle getBundleFromModule(Class caller, @@ -1622,12 +1517,11 @@ public abstract class ResourceBundle { sm.checkPermission(GET_CLASSLOADER_PERMISSION); } } - return getBundleImpl(callerModule, module, getLoader(module), baseName, locale, control); + return getBundleImpl(callerModule, module, baseName, locale, control); } private static ResourceBundle getBundleImpl(Module callerModule, Module module, - ClassLoader loader, String baseName, Locale locale, Control control) { @@ -1636,10 +1530,10 @@ public abstract class ResourceBundle { } // We create a CacheKey here for use by this call. The base name - // loader, and module will never change during the bundle loading + // and modules will never change during the bundle loading // process. We have to make sure that the locale is set before // using it as a cache key. - CacheKey cacheKey = new CacheKey(baseName, locale, loader, module, callerModule); + CacheKey cacheKey = new CacheKey(baseName, locale, module, callerModule); ResourceBundle bundle = null; // Quick lookup of the cache. @@ -1708,6 +1602,11 @@ public abstract class ResourceBundle { bundle = baseBundle; } + // keep callerModule and module reachable for as long as we are operating + // with WeakReference(s) to them (in CacheKey)... + Reference.reachabilityFence(callerModule); + Reference.reachabilityFence(module); + return bundle; } @@ -1745,7 +1644,7 @@ public abstract class ResourceBundle { } // Before we do the real loading work, see whether we need to - // do some housekeeping: If references to class loaders or + // do some housekeeping: If references to modules or // resource bundles have been nulled out, remove all related // information from the cache. Object ref; @@ -1781,31 +1680,24 @@ public abstract class ResourceBundle { } if (bundle != NONEXISTENT_BUNDLE) { - CacheKey constKey = (CacheKey) cacheKey.clone(); trace("findBundle: %d %s %s formats: %s%n", index, candidateLocales, cacheKey, formats); - try { - if (module.isNamed()) { - bundle = loadBundle(cacheKey, formats, control, module, callerModule); - } else { - bundle = loadBundle(cacheKey, formats, control, expiredBundle); - } - if (bundle != null) { - if (bundle.parent == null) { - bundle.setParent(parent); - } - bundle.locale = targetLocale; - bundle = putBundleInCache(cacheKey, bundle, control); - return bundle; - } - - // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle - // instance for the locale. - putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control); - } finally { - if (constKey.getCause() instanceof InterruptedException) { - Thread.currentThread().interrupt(); - } + if (module.isNamed()) { + bundle = loadBundle(cacheKey, formats, control, module, callerModule); + } else { + bundle = loadBundle(cacheKey, formats, control, expiredBundle); } + if (bundle != null) { + if (bundle.parent == null) { + bundle.setParent(parent); + } + bundle.locale = targetLocale; + bundle = putBundleInCache(cacheKey, bundle, control); + return bundle; + } + + // Put NONEXISTENT_BUNDLE in the cache as a mark that there's no bundle + // instance for the locale. + putBundleInCache(cacheKey, NONEXISTENT_BUNDLE, control); } return parent; } @@ -1991,12 +1883,20 @@ public abstract class ResourceBundle { // specified by the getFormats() value. Locale targetLocale = cacheKey.getLocale(); + Module module = cacheKey.getModule(); + if (module == null) { + // should not happen + throw new InternalError( + "Module for cache key: " + cacheKey + " has been GCed."); + } + ClassLoader loader = getLoaderForControl(module); + ResourceBundle bundle = null; for (String format : formats) { try { // ResourceBundle.Control.newBundle may be overridden bundle = control.newBundle(cacheKey.getName(), targetLocale, format, - cacheKey.getLoader(), reload); + loader, reload); } catch (LinkageError | Exception error) { // We need to handle the LinkageError case due to // inconsistent case-sensitivity in ClassLoader. @@ -2138,12 +2038,15 @@ public abstract class ResourceBundle { if (!bundle.expired && expirationTime >= 0 && expirationTime <= System.currentTimeMillis()) { try { - bundle.expired = control.needsReload(key.getName(), - key.getLocale(), - key.getFormat(), - key.getLoader(), - bundle, - key.loadTime); + Module module = cacheKey.getModule(); + bundle.expired = + module == null || // already GCed + control.needsReload(key.getName(), + key.getLocale(), + key.getFormat(), + getLoaderForControl(module), + bundle, + key.loadTime); } catch (Exception e) { cacheKey.setCause(e); } @@ -2185,7 +2088,7 @@ public abstract class ResourceBundle { Control control) { setExpirationTime(cacheKey, control); if (cacheKey.expirationTime != Control.TTL_DONT_CACHE) { - CacheKey key = (CacheKey) cacheKey.clone(); + CacheKey key = new CacheKey(cacheKey); BundleReference bundleRef = new BundleReference(bundle, referenceQueue, key); bundle.cacheKey = key; @@ -2239,7 +2142,7 @@ public abstract class ResourceBundle { @CallerSensitive public static final void clearCache() { Class caller = Reflection.getCallerClass(); - clearCache(getLoader(caller), caller.getModule()); + clearCacheImpl(caller.getModule(), caller.getClassLoader()); } /** @@ -2254,7 +2157,8 @@ public abstract class ResourceBundle { @CallerSensitive public static final void clearCache(ClassLoader loader) { Objects.requireNonNull(loader); - clearCache(loader, Reflection.getCallerClass().getModule()); + Class caller = Reflection.getCallerClass(); + clearCacheImpl(caller.getModule(), loader); } /** @@ -2272,14 +2176,19 @@ public abstract class ResourceBundle { * @see ResourceBundle.Control#getTimeToLive(String,Locale) */ public static final void clearCache(Module module) { - clearCache(module.getClassLoader(), module); + Objects.requireNonNull(module); + clearCacheImpl(module, module.getClassLoader()); } - private static void clearCache(ClassLoader loader, Module module) { - Set set = cacheList.keySet(); - set.stream() - .filter((key) -> (key.getLoader() == loader && key.getModule() == module)) - .forEach(set::remove); + private static void clearCacheImpl(Module callerModule, ClassLoader loader) { + cacheList.keySet().removeIf( + key -> { + Module m; + return key.getCallerModule() == callerModule && + (m = key.getModule()) != null && + getLoader(m) == loader; + } + ); } /** diff --git a/jdk/test/java/util/ResourceBundle/ResourceBundleTest.java b/jdk/test/java/util/ResourceBundle/ResourceBundleTest.java index 4a939fbc44e..44b845256e9 100644 --- a/jdk/test/java/util/ResourceBundle/ResourceBundleTest.java +++ b/jdk/test/java/util/ResourceBundle/ResourceBundleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - @bug 4049325 4073127 4083270 4106034 4108126 8027930 + @bug 4049325 4073127 4083270 4106034 4108126 8027930 8171139 @summary test Resource Bundle @build TestResource TestResource_de TestResource_fr TestResource_fr_CH @build TestResource_it FakeTestResource @@ -65,6 +65,7 @@ import java.text.*; import java.util.*; import java.util.ResourceBundle.Control; import java.io.*; +import java.net.URL; public class ResourceBundleTest extends RBTestFmwk { public static void main(String[] args) throws Exception { @@ -330,6 +331,44 @@ public class ResourceBundleTest extends RBTestFmwk { } } + /* + * @bug 8171139 + * @summary Make sure clearCache() clears cached ResourceBundle instances + */ + public void TestClearCache() { + final String className = "TestResource"; + Locale loc = Locale.getDefault(); + + // testing no-arg clearCache() + ResourceBundle rb1 = ResourceBundle.getBundle(className, loc); + ResourceBundle.clearCache(); + ResourceBundle rb2 = ResourceBundle.getBundle(className, loc); + if (rb1 == rb2) { + errln("clearCache(no-arg) did not clear cache"); + } + + // clearCache() with a custom classloader + ClassLoader cl1 = new DummyClassLoader(); + rb1 = ResourceBundle.getBundle(className, loc, cl1); + if (rb1 == rb2) { + errln("Same bundle was returned for different class loaders"); + } + ResourceBundle.clearCache(cl1); + rb2= ResourceBundle.getBundle(className, loc, cl1); + if (rb1 == rb2) { + errln("clearCache(classLoader) did not clear cache"); + } + ClassLoader cl2 = new DummyClassLoader(); + rb1 = ResourceBundle.getBundle(className, loc, cl2); + if (rb1 == rb2) { + errln("Same bundle was returned for different class loaders"); + } + ResourceBundle.clearCache(cl1); + rb2 = ResourceBundle.getBundle(className, loc, cl2); + if (rb1 != rb2) { + errln("clearCache(classLoader) incorrectly cleared cache"); + } + } private void makePropertiesFile() { try { @@ -393,4 +432,22 @@ public class ResourceBundleTest extends RBTestFmwk { errln("Wrong number of elements in key list: expected " + expectedKeys.length + " got " + elementCount); } + + private static class DummyClassLoader extends ClassLoader { + public DummyClassLoader() { + super(DummyClassLoader.class.getClassLoader()); + } + + public Class loadClass(String name) throws ClassNotFoundException { + return DummyClassLoader.class.getClassLoader().loadClass(name); + } + + public URL getResource(String name) { + return DummyClassLoader.class.getClassLoader().getResource(name); + } + + public InputStream getResourceAsStream(String name) { + return DummyClassLoader.class.getClassLoader().getResourceAsStream(name); + } + } } From e13c369fbf3e34c09c5caf4a27b23b1ac5932a40 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 17 Jan 2017 11:56:40 -0800 Subject: [PATCH 113/154] 8171456: Upgrade harfbuzz in JDK 9 to v1.4.1 Reviewed-by: serb, vadim, simonis --- .../native/libfontmanager/harfbuzz/hb-blob.cc | 16 +- .../harfbuzz/hb-buffer-deserialize-json.hh | 744 ++--- .../harfbuzz/hb-buffer-deserialize-text.hh | 490 ++-- .../harfbuzz/hb-buffer-private.hh | 6 +- .../harfbuzz/hb-buffer-serialize.cc | 14 +- .../libfontmanager/harfbuzz/hb-buffer.cc | 44 +- .../harfbuzz/hb-cache-private.hh | 8 +- .../libfontmanager/harfbuzz/hb-common.cc | 50 +- .../libfontmanager/harfbuzz/hb-coretext.cc | 26 +- .../native/libfontmanager/harfbuzz/hb-face.cc | 74 +- .../harfbuzz/hb-fallback-shape.cc | 4 +- .../harfbuzz/hb-font-private.hh | 115 +- .../native/libfontmanager/harfbuzz/hb-font.cc | 365 +-- .../native/libfontmanager/harfbuzz/hb-font.h | 5 + .../native/libfontmanager/harfbuzz/hb-ft.cc | 54 +- .../harfbuzz/hb-open-type-private.hh | 10 +- .../harfbuzz/hb-ot-cbdt-table.hh | 384 +++ .../libfontmanager/harfbuzz/hb-ot-font.cc | 113 +- .../harfbuzz/hb-ot-layout-common-private.hh | 497 +++- .../harfbuzz/hb-ot-layout-gdef-table.hh | 52 +- .../harfbuzz/hb-ot-layout-gpos-table.hh | 117 +- .../harfbuzz/hb-ot-layout-gsub-table.hh | 82 +- .../harfbuzz/hb-ot-layout-gsubgpos-private.hh | 36 +- .../harfbuzz/hb-ot-layout-private.hh | 3 + .../libfontmanager/harfbuzz/hb-ot-layout.cc | 57 +- .../libfontmanager/harfbuzz/hb-ot-layout.h | 19 + .../harfbuzz/hb-ot-map-private.hh | 18 +- .../libfontmanager/harfbuzz/hb-ot-map.cc | 118 +- .../libfontmanager/harfbuzz/hb-ot-math.h | 209 ++ .../harfbuzz/hb-ot-shape-complex-arabic.cc | 1 + .../harfbuzz/hb-ot-shape-complex-default.cc | 1 + .../harfbuzz/hb-ot-shape-complex-hangul.cc | 1 + .../harfbuzz/hb-ot-shape-complex-hebrew.cc | 13 + .../hb-ot-shape-complex-indic-machine.hh | 2560 ++++++++--------- .../harfbuzz/hb-ot-shape-complex-indic.cc | 20 +- .../hb-ot-shape-complex-myanmar-machine.hh | 374 +-- .../harfbuzz/hb-ot-shape-complex-myanmar.cc | 2 + .../harfbuzz/hb-ot-shape-complex-private.hh | 8 + .../harfbuzz/hb-ot-shape-complex-thai.cc | 1 + .../harfbuzz/hb-ot-shape-complex-tibetan.cc | 1 + .../hb-ot-shape-complex-use-machine.hh | 422 +-- .../harfbuzz/hb-ot-shape-complex-use.cc | 44 +- .../harfbuzz/hb-ot-shape-private.hh | 6 +- .../libfontmanager/harfbuzz/hb-ot-shape.cc | 70 +- .../libfontmanager/harfbuzz/hb-ot-tag.cc | 23 +- .../native/libfontmanager/harfbuzz/hb-ot.h | 1 + .../libfontmanager/harfbuzz/hb-private.hh | 11 +- .../libfontmanager/harfbuzz/hb-set-private.hh | 4 +- .../native/libfontmanager/harfbuzz/hb-set.cc | 66 +- .../harfbuzz/hb-shape-plan-private.hh | 9 +- .../libfontmanager/harfbuzz/hb-shape-plan.cc | 153 +- .../libfontmanager/harfbuzz/hb-shape-plan.h | 19 + .../libfontmanager/harfbuzz/hb-shape.cc | 5 +- .../libfontmanager/harfbuzz/hb-unicode.cc | 60 +- .../libfontmanager/harfbuzz/hb-version.h | 6 +- .../native/libfontmanager/hb-jdk-font.cc | 20 +- 56 files changed, 4645 insertions(+), 2986 deletions(-) create mode 100644 jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-cbdt-table.hh create mode 100644 jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-math.h diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-blob.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-blob.cc index 5068dc14d9a..02c60253bfc 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-blob.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-blob.cc @@ -247,7 +247,7 @@ hb_blob_destroy (hb_blob_t *blob) * @destroy: callback to call when @data is not needed anymore. * @replace: whether to replace an existing data with the same key. * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -266,9 +266,9 @@ hb_blob_set_user_data (hb_blob_t *blob, * @blob: a blob. * @key: key for data to get. * + * * - * - * Return value: (transfer none): + * Return value: (transfer none): * * Since: 0.9.2 **/ @@ -284,7 +284,7 @@ hb_blob_get_user_data (hb_blob_t *blob, * hb_blob_make_immutable: * @blob: a blob. * - * + * * * Since: 0.9.2 **/ @@ -301,7 +301,7 @@ hb_blob_make_immutable (hb_blob_t *blob) * hb_blob_is_immutable: * @blob: a blob. * - * + * * * Return value: TODO * @@ -318,7 +318,7 @@ hb_blob_is_immutable (hb_blob_t *blob) * hb_blob_get_length: * @blob: a blob. * - * + * * * Return value: the length of blob data in bytes. * @@ -335,9 +335,9 @@ hb_blob_get_length (hb_blob_t *blob) * @blob: a blob. * @length: (out): * + * * - * - * Returns: (transfer none) (array length=length): + * Returns: (transfer none) (array length=length): * * Since: 0.9.2 **/ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-json.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-json.hh index 5d4387149ac..7581c2cd739 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-json.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-json.hh @@ -34,397 +34,397 @@ #line 36 "hb-buffer-deserialize-json.hh" static const unsigned char _deserialize_json_trans_keys[] = { - 0u, 0u, 9u, 123u, 9u, 34u, 97u, 103u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, - 48u, 57u, 9u, 125u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, - 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u, - 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, - 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, + 0u, 0u, 9u, 123u, 9u, 34u, 97u, 103u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, + 48u, 57u, 9u, 125u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, + 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u, + 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, + 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 65u, 122u, 34u, 122u, 9u, 125u, 9u, 125u, 9u, 93u, 9u, 123u, 0u, 0u, 0 }; static const char _deserialize_json_key_spans[] = { - 0, 115, 26, 7, 2, 1, 50, 49, - 10, 117, 117, 117, 1, 50, 49, 10, - 117, 117, 1, 1, 50, 49, 117, 117, - 2, 1, 50, 49, 10, 117, 117, 1, - 50, 49, 10, 117, 117, 1, 50, 49, + 0, 115, 26, 7, 2, 1, 50, 49, + 10, 117, 117, 117, 1, 50, 49, 10, + 117, 117, 1, 1, 50, 49, 117, 117, + 2, 1, 50, 49, 10, 117, 117, 1, + 50, 49, 10, 117, 117, 1, 50, 49, 58, 89, 117, 117, 85, 115, 0 }; static const short _deserialize_json_index_offsets[] = { - 0, 0, 116, 143, 151, 154, 156, 207, - 257, 268, 386, 504, 622, 624, 675, 725, - 736, 854, 972, 974, 976, 1027, 1077, 1195, - 1313, 1316, 1318, 1369, 1419, 1430, 1548, 1666, - 1668, 1719, 1769, 1780, 1898, 2016, 2018, 2069, + 0, 0, 116, 143, 151, 154, 156, 207, + 257, 268, 386, 504, 622, 624, 675, 725, + 736, 854, 972, 974, 976, 1027, 1077, 1195, + 1313, 1316, 1318, 1369, 1419, 1430, 1548, 1666, + 1668, 1719, 1769, 1780, 1898, 2016, 2018, 2069, 2119, 2178, 2268, 2386, 2504, 2590, 2706 }; static const char _deserialize_json_indicies[] = { - 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 1, 3, 3, 3, - 3, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 1, 4, 1, - 5, 1, 6, 7, 1, 1, 8, 1, - 9, 10, 1, 11, 1, 11, 11, 11, - 11, 11, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 11, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 12, 1, - 12, 12, 12, 12, 12, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 12, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 13, 1, 1, 14, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 1, 16, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 1, 18, 18, 18, - 18, 18, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 18, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 19, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 20, 1, 21, 21, 21, 21, 21, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 21, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 22, - 1, 18, 18, 18, 18, 18, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 18, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 1, 1, 1, - 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 20, 1, 23, - 1, 23, 23, 23, 23, 23, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 23, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 24, 1, 24, 24, 24, 24, - 24, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 24, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 25, 1, 1, 26, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 1, 28, 29, - 29, 29, 29, 29, 29, 29, 29, 29, - 1, 30, 30, 30, 30, 30, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 30, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 31, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 32, 1, 30, - 30, 30, 30, 30, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 30, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 31, 1, 1, 1, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 32, 1, 33, 1, 34, - 1, 34, 34, 34, 34, 34, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 34, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 35, 1, 35, 35, 35, 35, - 35, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 35, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 36, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 1, 38, 38, - 38, 38, 38, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 38, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 39, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 40, 1, 38, 38, 38, 38, - 38, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 38, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 39, - 1, 1, 1, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 40, 1, 42, 43, 1, 44, 1, 44, - 44, 44, 44, 44, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 44, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 45, 1, 45, 45, 45, 45, 45, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 45, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 46, 1, - 1, 47, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 1, 49, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 1, 51, - 51, 51, 51, 51, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 51, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 52, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 53, 1, 51, 51, 51, - 51, 51, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 51, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 52, 1, 1, 1, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 53, 1, 54, 1, 54, 54, 54, - 54, 54, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 54, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 55, 1, - 55, 55, 55, 55, 55, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 55, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 56, 1, 1, 57, - 58, 58, 58, 58, 58, 58, 58, 58, - 58, 1, 59, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 1, 61, 61, 61, - 61, 61, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 61, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 62, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 63, 1, 61, 61, 61, 61, 61, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 61, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 62, 1, - 1, 1, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 63, - 1, 64, 1, 64, 64, 64, 64, 64, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 64, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 65, 1, 65, 65, - 65, 65, 65, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 65, 1, 66, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 67, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 1, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 1, 1, 1, 1, 1, 1, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 1, 70, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 71, 71, - 1, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 1, 1, 1, 1, 1, - 1, 1, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 1, 1, 1, 1, - 71, 1, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 1, 72, 72, 72, - 72, 72, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 72, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 73, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 74, 1, 72, 72, 72, 72, 72, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 72, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 73, 1, - 1, 1, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 74, - 1, 76, 76, 76, 76, 76, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 76, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 77, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 78, 1, 0, - 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 1, 3, 3, 3, + 3, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 1, 4, 1, + 5, 1, 6, 7, 1, 1, 8, 1, + 9, 10, 1, 11, 1, 11, 11, 11, + 11, 11, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 11, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 12, 1, + 12, 12, 12, 12, 12, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 12, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 13, 1, 1, 14, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 1, 16, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 1, 18, 18, 18, + 18, 18, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 18, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 19, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 20, 1, 21, 21, 21, 21, 21, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 21, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 22, + 1, 18, 18, 18, 18, 18, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 18, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 19, 1, 1, 1, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 20, 1, 23, + 1, 23, 23, 23, 23, 23, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 23, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 24, 1, 24, 24, 24, 24, + 24, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 24, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 25, 1, 1, 26, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 1, 28, 29, + 29, 29, 29, 29, 29, 29, 29, 29, + 1, 30, 30, 30, 30, 30, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 30, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 31, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 32, 1, 30, + 30, 30, 30, 30, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 30, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 31, 1, 1, 1, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 32, 1, 33, 1, 34, + 1, 34, 34, 34, 34, 34, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 34, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 35, 1, 35, 35, 35, 35, + 35, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 35, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 36, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 1, 38, 38, + 38, 38, 38, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 38, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 39, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 40, 1, 38, 38, 38, 38, + 38, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 38, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 39, + 1, 1, 1, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 40, 1, 42, 43, 1, 44, 1, 44, + 44, 44, 44, 44, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 44, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 45, 1, 45, 45, 45, 45, 45, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 45, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 46, 1, + 1, 47, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 1, 49, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 1, 51, + 51, 51, 51, 51, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 51, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 52, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 53, 1, 51, 51, 51, + 51, 51, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 51, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 52, 1, 1, 1, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 53, 1, 54, 1, 54, 54, 54, + 54, 54, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 54, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 55, 1, + 55, 55, 55, 55, 55, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 55, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 56, 1, 1, 57, + 58, 58, 58, 58, 58, 58, 58, 58, + 58, 1, 59, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 1, 61, 61, 61, + 61, 61, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 61, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 62, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 63, 1, 61, 61, 61, 61, 61, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 61, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 62, 1, + 1, 1, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 63, + 1, 64, 1, 64, 64, 64, 64, 64, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 64, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 65, 1, 65, 65, + 65, 65, 65, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 65, 1, 66, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 67, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 1, + 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 1, 1, 1, 1, 1, 1, + 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 1, 70, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 71, 71, + 1, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 1, 1, 1, 1, 1, + 1, 1, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 1, 1, 1, 1, + 71, 1, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 1, 72, 72, 72, + 72, 72, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 72, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 73, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 74, 1, 72, 72, 72, 72, 72, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 72, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 73, 1, + 1, 1, 75, 75, 75, 75, 75, 75, + 75, 75, 75, 75, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 74, + 1, 76, 76, 76, 76, 76, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 76, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 77, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 78, 1, 0, + 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 0 }; static const char _deserialize_json_trans_targs[] = { - 1, 0, 2, 2, 3, 4, 18, 24, - 37, 5, 12, 6, 7, 8, 9, 11, - 9, 11, 10, 2, 44, 10, 44, 13, - 14, 15, 16, 17, 16, 17, 10, 2, - 44, 19, 20, 21, 22, 23, 10, 2, - 44, 23, 25, 31, 26, 27, 28, 29, - 30, 29, 30, 10, 2, 44, 32, 33, - 34, 35, 36, 35, 36, 10, 2, 44, - 38, 39, 40, 42, 43, 41, 10, 41, + 1, 0, 2, 2, 3, 4, 18, 24, + 37, 5, 12, 6, 7, 8, 9, 11, + 9, 11, 10, 2, 44, 10, 44, 13, + 14, 15, 16, 17, 16, 17, 10, 2, + 44, 19, 20, 21, 22, 23, 10, 2, + 44, 23, 25, 31, 26, 27, 28, 29, + 30, 29, 30, 10, 2, 44, 32, 33, + 34, 35, 36, 35, 36, 10, 2, 44, + 38, 39, 40, 42, 43, 41, 10, 41, 10, 2, 44, 43, 44, 45, 46 }; static const char _deserialize_json_trans_actions[] = { - 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 2, 2, - 0, 0, 3, 3, 4, 0, 5, 0, - 0, 2, 2, 2, 0, 0, 6, 6, - 7, 0, 0, 0, 2, 2, 8, 8, - 9, 0, 0, 0, 0, 0, 2, 2, - 2, 0, 0, 10, 10, 11, 0, 0, - 2, 2, 2, 0, 0, 12, 12, 13, - 0, 0, 0, 2, 2, 2, 14, 0, + 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 2, + 0, 0, 3, 3, 4, 0, 5, 0, + 0, 2, 2, 2, 0, 0, 6, 6, + 7, 0, 0, 0, 2, 2, 8, 8, + 9, 0, 0, 0, 0, 0, 2, 2, + 2, 0, 0, 10, 10, 11, 0, 0, + 2, 2, 2, 0, 0, 12, 12, 13, + 0, 0, 0, 2, 2, 2, 14, 0, 15, 15, 16, 0, 0, 0, 0 }; @@ -461,7 +461,7 @@ _hb_buffer_deserialize_glyphs_json (hb_buffer_t *buffer, int cs; hb_glyph_info_t info = {0}; hb_glyph_position_t pos = {0}; - + #line 466 "hb-buffer-deserialize-json.hh" { cs = deserialize_json_start; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-text.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-text.hh index c45442c0274..259719c1fea 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-text.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-deserialize-text.hh @@ -34,274 +34,274 @@ #line 36 "hb-buffer-deserialize-text.hh" static const unsigned char _deserialize_text_trans_keys[] = { - 0u, 0u, 9u, 122u, 45u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 48u, 57u, 45u, 57u, - 48u, 57u, 44u, 44u, 45u, 57u, 48u, 57u, 44u, 57u, 9u, 124u, 9u, 124u, 0u, 0u, - 9u, 122u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, + 0u, 0u, 9u, 122u, 45u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 48u, 57u, 45u, 57u, + 48u, 57u, 44u, 44u, 45u, 57u, 48u, 57u, 44u, 57u, 9u, 124u, 9u, 124u, 0u, 0u, + 9u, 122u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 0 }; static const char _deserialize_text_key_spans[] = { - 0, 114, 13, 10, 13, 10, 10, 13, - 10, 1, 13, 10, 14, 116, 116, 0, - 114, 116, 116, 116, 116, 116, 116, 116, + 0, 114, 13, 10, 13, 10, 10, 13, + 10, 1, 13, 10, 14, 116, 116, 0, + 114, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116 }; static const short _deserialize_text_index_offsets[] = { - 0, 0, 115, 129, 140, 154, 165, 176, - 190, 201, 203, 217, 228, 243, 360, 477, - 478, 593, 710, 827, 944, 1061, 1178, 1295, + 0, 0, 115, 129, 140, 154, 165, 176, + 190, 201, 203, 217, 228, 243, 360, 477, + 478, 593, 710, 827, 944, 1061, 1178, 1295, 1412, 1529, 1646 }; static const char _deserialize_text_indicies[] = { - 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 2, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 1, 1, 1, 1, 1, 1, - 1, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 1, 1, 1, 1, 1, - 1, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 1, 5, 1, 1, 6, - 7, 7, 7, 7, 7, 7, 7, 7, - 7, 1, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 1, 10, 1, 1, - 11, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 1, 13, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 1, 15, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 1, 17, 1, 1, 18, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 1, 20, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 1, 22, 1, 23, 1, 1, 24, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 1, 26, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 1, 22, 1, 1, - 1, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 1, 28, 28, 28, 28, - 28, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 28, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 29, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 30, 1, 1, 31, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 32, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 33, - 1, 34, 34, 34, 34, 34, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 34, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 35, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 36, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 3, - 3, 3, 3, 3, 3, 3, 3, 3, - 1, 1, 1, 1, 1, 1, 1, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 1, 1, 1, 1, 1, 1, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 1, 28, 28, 28, 28, 28, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 28, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 29, 1, 1, 1, - 1, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 1, 1, 1, 30, 1, - 1, 31, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 32, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 33, 1, 38, - 38, 38, 38, 38, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 38, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 39, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 40, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 41, 1, 42, 42, 42, 42, - 42, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 42, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 43, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 44, - 1, 42, 42, 42, 42, 42, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 42, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 43, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 44, 1, 38, 38, - 38, 38, 38, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 38, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 39, 1, 1, 1, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 40, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 41, 1, 45, 45, 45, 45, 45, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 45, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 46, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 47, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 48, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 49, 1, - 50, 50, 50, 50, 50, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 50, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 51, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 52, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 53, 1, 50, 50, 50, - 50, 50, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 50, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 51, - 1, 1, 1, 1, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 52, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 53, 1, 45, 45, 45, 45, 45, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 45, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 46, 1, 1, 1, - 1, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 1, 1, 1, 1, 1, - 1, 47, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 48, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 49, 1, 28, - 28, 28, 28, 28, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 28, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 29, 1, 55, 55, 1, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 1, 1, 1, 30, 1, 1, 31, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 1, 1, 32, 1, 55, 1, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, + 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 1, 1, 1, 1, 1, 1, + 1, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 1, 1, 1, 1, 1, + 1, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 1, 5, 1, 1, 6, + 7, 7, 7, 7, 7, 7, 7, 7, + 7, 1, 8, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 1, 10, 1, 1, + 11, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 1, 13, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 1, 15, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 1, 17, 1, 1, 18, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 1, 20, + 21, 21, 21, 21, 21, 21, 21, 21, + 21, 1, 22, 1, 23, 1, 1, 24, + 25, 25, 25, 25, 25, 25, 25, 25, + 25, 1, 26, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 1, 22, 1, 1, + 1, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 1, 28, 28, 28, 28, + 28, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 28, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 29, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 30, 1, 1, 31, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 32, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 33, + 1, 34, 34, 34, 34, 34, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 34, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 35, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 36, 1, 1, 0, + 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 1, 1, 1, 1, 1, 1, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 1, 28, 28, 28, 28, 28, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 28, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 29, 1, 1, 1, + 1, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 1, 1, 1, 30, 1, + 1, 31, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 32, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 33, 1, 38, + 38, 38, 38, 38, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 38, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 39, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 40, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 41, 1, 42, 42, 42, 42, + 42, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 42, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 43, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 44, + 1, 42, 42, 42, 42, 42, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 42, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 43, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 44, 1, 38, 38, + 38, 38, 38, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 38, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 39, 1, 1, 1, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 40, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 41, 1, 45, 45, 45, 45, 45, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 45, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 46, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 47, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 48, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 49, 1, + 50, 50, 50, 50, 50, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 50, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 51, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 52, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 53, 1, 50, 50, 50, + 50, 50, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 50, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 51, + 1, 1, 1, 1, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 52, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 53, 1, 45, 45, 45, 45, 45, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 45, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 46, 1, 1, 1, + 1, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 1, 1, 1, 1, 1, + 1, 47, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 48, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 49, 1, 28, + 28, 28, 28, 28, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 28, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 29, 1, 55, 55, 1, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, + 1, 1, 1, 30, 1, 1, 31, 55, + 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, + 55, 1, 1, 32, 1, 55, 1, 55, + 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 1, 33, 1, 0 }; static const char _deserialize_text_trans_targs[] = { - 1, 0, 13, 17, 26, 3, 18, 21, - 18, 21, 5, 19, 20, 19, 20, 22, - 25, 8, 9, 12, 9, 12, 10, 11, - 23, 24, 23, 24, 14, 2, 6, 7, - 15, 16, 14, 15, 16, 17, 14, 4, - 15, 16, 14, 15, 16, 14, 2, 7, + 1, 0, 13, 17, 26, 3, 18, 21, + 18, 21, 5, 19, 20, 19, 20, 22, + 25, 8, 9, 12, 9, 12, 10, 11, + 23, 24, 23, 24, 14, 2, 6, 7, + 15, 16, 14, 15, 16, 17, 14, 4, + 15, 16, 14, 15, 16, 14, 2, 7, 15, 16, 14, 2, 15, 16, 25, 26 }; static const char _deserialize_text_trans_actions[] = { - 0, 0, 1, 1, 1, 2, 2, 2, - 0, 0, 2, 2, 2, 0, 0, 2, - 2, 2, 2, 2, 0, 0, 3, 2, - 2, 2, 0, 0, 4, 5, 5, 5, - 4, 4, 0, 0, 0, 0, 6, 7, - 6, 6, 8, 8, 8, 9, 10, 10, + 0, 0, 1, 1, 1, 2, 2, 2, + 0, 0, 2, 2, 2, 0, 0, 2, + 2, 2, 2, 2, 0, 0, 3, 2, + 2, 2, 0, 0, 4, 5, 5, 5, + 4, 4, 0, 0, 0, 0, 6, 7, + 6, 6, 8, 8, 8, 9, 10, 10, 9, 9, 11, 12, 11, 11, 0, 0 }; static const char _deserialize_text_eof_actions[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4, 0, 0, - 0, 4, 6, 8, 8, 6, 9, 11, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 4, 0, 0, + 0, 4, 6, 8, 8, 6, 9, 11, 11, 9, 4 }; @@ -338,7 +338,7 @@ _hb_buffer_deserialize_glyphs_text (hb_buffer_t *buffer, int cs; hb_glyph_info_t info = {0}; hb_glyph_position_t pos = {0}; - + #line 343 "hb-buffer-deserialize-text.hh" { cs = deserialize_text_start; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-private.hh index 1fc2252d12c..b92b67b7e26 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-buffer-private.hh @@ -134,7 +134,7 @@ struct hb_buffer_t { #ifndef HB_NDEBUG unsigned int end = start + count; assert (end <= 8); - unsigned int bits = (1<> value_bits) != (key >> cache_bits)) return false; - *value = v & ((1<> key_bits) || (value >> value_bits))) return false; /* Overflows */ - unsigned int k = key & ((1<>cache_bits)< hb_cmap_cache_t; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-common.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-common.cc index d7b75ac1b1e..aae6351cc5f 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-common.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-common.cc @@ -57,12 +57,12 @@ _hb_options_init (void) /** * hb_tag_from_string: - * @str: (array length=len) (element-type uint8_t): - * @len: + * @str: (array length=len) (element-type uint8_t): + * @len: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -87,10 +87,10 @@ hb_tag_from_string (const char *str, int len) /** * hb_tag_to_string: - * @tag: - * @buf: (out caller-allocates) (array fixed-size=4) (element-type uint8_t): - * + * @tag: + * @buf: (out caller-allocates) (array fixed-size=4) (element-type uint8_t): * + * * * Since: 0.9.5 **/ @@ -115,12 +115,12 @@ const char direction_strings[][4] = { /** * hb_direction_from_string: - * @str: (array length=len) (element-type uint8_t): - * @len: + * @str: (array length=len) (element-type uint8_t): + * @len: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -143,11 +143,11 @@ hb_direction_from_string (const char *str, int len) /** * hb_direction_to_string: - * @direction: + * @direction: * + * * - * - * Return value: (transfer none): + * Return value: (transfer none): * * Since: 0.9.2 **/ @@ -337,7 +337,7 @@ hb_language_to_string (hb_language_t language) /** * hb_language_get_default: * - * + * * * Return value: (transfer none): * @@ -366,7 +366,7 @@ hb_language_get_default (void) * * Converts an ISO 15924 script tag to a corresponding #hb_script_t. * - * Return value: + * Return value: * An #hb_script_t corresponding to the ISO 15924 tag. * * Since: 0.9.2 @@ -415,7 +415,7 @@ hb_script_from_iso15924_tag (hb_tag_t tag) * corresponding #hb_script_t. Shorthand for hb_tag_from_string() then * hb_script_from_iso15924_tag(). * - * Return value: + * Return value: * An #hb_script_t corresponding to the ISO 15924 tag. * * Since: 0.9.2 @@ -445,11 +445,11 @@ hb_script_to_iso15924_tag (hb_script_t script) /** * hb_script_get_horizontal_direction: - * @script: + * @script: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -588,13 +588,13 @@ hb_version_string (void) /** * hb_version_atleast: - * @major: - * @minor: - * @micro: + * @major: + * @minor: + * @micro: * + * * - * - * Return value: + * Return value: * * Since: 0.9.30 **/ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-coretext.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-coretext.cc index bd769a04aa8..01e3a23f2b1 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-coretext.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-coretext.cc @@ -145,6 +145,22 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size) DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed"); return NULL; } + + /* crbug.com/576941 and crbug.com/625902 and the investigation in the latter + * bug indicate that the cascade list reconfiguration occasionally causes + * crashes in CoreText on OS X 10.9, thus let's skip this step on older + * operating system versions. Except for the emoji font, where _not_ + * reconfiguring the cascade list causes CoreText crashes. For details, see + * crbug.com/549610 */ + // 0x00070000 stands for "kCTVersionNumber10_10", see CoreText.h + if (&CTGetCoreTextVersion != NULL && CTGetCoreTextVersion() < 0x00070000) { + CFStringRef fontName = CTFontCopyPostScriptName (ct_font); + bool isEmojiFont = CFStringCompare (fontName, CFSTR("AppleColorEmoji"), 0) == kCFCompareEqualTo; + CFRelease (fontName); + if (!isEmojiFont) + return ct_font; + } + CFURLRef original_url = (CFURLRef)CTFontCopyAttribute(ct_font, kCTFontURLAttribute); /* Create font copy with cascade list that has LastResort first; this speeds up CoreText @@ -272,7 +288,9 @@ struct hb_coretext_shaper_shape_plan_data_t {}; hb_coretext_shaper_shape_plan_data_t * _hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, - unsigned int num_user_features HB_UNUSED) + unsigned int num_user_features HB_UNUSED, + const int *coords HB_UNUSED, + unsigned int num_coords HB_UNUSED) { return (hb_coretext_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } @@ -717,7 +735,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, pchars[chars_len++] = 0xFFFDu; else { pchars[chars_len++] = 0xD800u + ((c - 0x10000u) >> 10); - pchars[chars_len++] = 0xDC00u + ((c - 0x10000u) & ((1 << 10) - 1)); + pchars[chars_len++] = 0xDC00u + ((c - 0x10000u) & ((1u << 10) - 1)); } } @@ -1264,7 +1282,9 @@ struct hb_coretext_aat_shaper_shape_plan_data_t {}; hb_coretext_aat_shaper_shape_plan_data_t * _hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, - unsigned int num_user_features HB_UNUSED) + unsigned int num_user_features HB_UNUSED, + const int *coords HB_UNUSED, + unsigned int num_coords HB_UNUSED) { return (hb_coretext_aat_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc index b5019a122de..bb6673cdf2b 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc @@ -35,8 +35,6 @@ #include "hb-ot-head-table.hh" #include "hb-ot-maxp-table.hh" -#include "hb-cache-private.hh" - #include @@ -70,10 +68,10 @@ const hb_face_t _hb_face_nil = { /** * hb_face_create_for_tables: * @reference_table_func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * + * @user_data: + * @destroy: * + * * * Return value: (transfer full) * @@ -150,10 +148,10 @@ _hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void /** * hb_face_create: (Xconstructor) - * @blob: - * @index: - * + * @blob: + * @index: * + * * * Return value: (transfer full): * @@ -185,7 +183,7 @@ hb_face_create (hb_blob_t *blob, /** * hb_face_get_empty: * - * + * * * Return value: (transfer full) * @@ -202,9 +200,9 @@ hb_face_get_empty (void) * hb_face_reference: (skip) * @face: a face. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -218,7 +216,7 @@ hb_face_reference (hb_face_t *face) * hb_face_destroy: (skip) * @face: a face. * - * + * * * Since: 0.9.2 **/ @@ -248,14 +246,14 @@ hb_face_destroy (hb_face_t *face) /** * hb_face_set_user_data: (skip) * @face: a face. - * @key: - * @data: - * @destroy: - * @replace: + * @key: + * @data: + * @destroy: + * @replace: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -272,9 +270,9 @@ hb_face_set_user_data (hb_face_t *face, /** * hb_face_get_user_data: (skip) * @face: a face. - * @key: - * + * @key: * + * * * Return value: (transfer none): * @@ -291,7 +289,7 @@ hb_face_get_user_data (hb_face_t *face, * hb_face_make_immutable: * @face: a face. * - * + * * * Since: 0.9.2 **/ @@ -308,9 +306,9 @@ hb_face_make_immutable (hb_face_t *face) * hb_face_is_immutable: * @face: a face. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -324,9 +322,9 @@ hb_face_is_immutable (hb_face_t *face) /** * hb_face_reference_table: * @face: a face. - * @tag: - * + * @tag: * + * * * Return value: (transfer full): * @@ -343,7 +341,7 @@ hb_face_reference_table (hb_face_t *face, * hb_face_reference_blob: * @face: a face. * - * + * * * Return value: (transfer full): * @@ -358,9 +356,9 @@ hb_face_reference_blob (hb_face_t *face) /** * hb_face_set_index: * @face: a face. - * @index: - * + * @index: * + * * * Since: 0.9.2 **/ @@ -378,9 +376,9 @@ hb_face_set_index (hb_face_t *face, * hb_face_get_index: * @face: a face. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -393,9 +391,9 @@ hb_face_get_index (hb_face_t *face) /** * hb_face_set_upem: * @face: a face. - * @upem: - * + * @upem: * + * * * Since: 0.9.2 **/ @@ -413,9 +411,9 @@ hb_face_set_upem (hb_face_t *face, * hb_face_get_upem: * @face: a face. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -437,9 +435,9 @@ hb_face_t::load_upem (void) const /** * hb_face_set_glyph_count: * @face: a face. - * @glyph_count: - * + * @glyph_count: * + * * * Since: 0.9.7 **/ @@ -457,9 +455,9 @@ hb_face_set_glyph_count (hb_face_t *face, * hb_face_get_glyph_count: * @face: a face. * + * * - * - * Return value: + * Return value: * * Since: 0.9.7 **/ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-fallback-shape.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-fallback-shape.cc index dee7d7d12eb..9f40c911c5f 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-fallback-shape.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-fallback-shape.cc @@ -73,7 +73,9 @@ struct hb_fallback_shaper_shape_plan_data_t {}; hb_fallback_shaper_shape_plan_data_t * _hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, - unsigned int num_user_features HB_UNUSED) + unsigned int num_user_features HB_UNUSED, + const int *coords HB_UNUSED, + unsigned int num_coords HB_UNUSED) { return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font-private.hh index d7b48776e1e..9254cd0f4e5 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font-private.hh @@ -108,6 +108,10 @@ struct hb_font_t { unsigned int x_ppem; unsigned int y_ppem; + /* Font variation coordinates. */ + unsigned int num_coords; + int *coords; + hb_font_funcs_t *klass; void *user_data; hb_destroy_func_t destroy; @@ -116,8 +120,14 @@ struct hb_font_t { /* Convert from font-space to user-space */ - inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); } - inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); } + inline int dir_scale (hb_direction_t direction) + { return HB_DIRECTION_IS_VERTICAL(direction) ? y_scale : x_scale; } + inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, x_scale); } + inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, y_scale); } + inline hb_position_t em_scalef_x (float v) { return em_scalef (v, this->x_scale); } + inline hb_position_t em_scalef_y (float v) { return em_scalef (v, this->y_scale); } + inline hb_position_t em_scale_dir (int16_t v, hb_direction_t direction) + { return em_scale (v, dir_scale (direction)); } /* Convert from parent-font user-space to our user-space */ inline hb_position_t parent_scale_x_distance (hb_position_t v) { @@ -292,24 +302,32 @@ struct hb_font_t { /* A bit higher-level, and with fallback */ + inline void get_h_extents_with_fallback (hb_font_extents_t *extents) + { + if (!get_font_h_extents (extents)) + { + extents->ascender = y_scale * .8; + extents->descender = extents->ascender - y_scale; + extents->line_gap = 0; + } + } + inline void get_v_extents_with_fallback (hb_font_extents_t *extents) + { + if (!get_font_v_extents (extents)) + { + extents->ascender = x_scale / 2; + extents->descender = extents->ascender - x_scale; + extents->line_gap = 0; + } + } + inline void get_extents_for_direction (hb_direction_t direction, hb_font_extents_t *extents) { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { - if (!get_font_h_extents (extents)) - { - extents->ascender = y_scale * .8; - extents->descender = y_scale - extents->ascender; - extents->line_gap = 0; - } - } else { - if (!get_font_v_extents (extents)) - { - extents->ascender = x_scale / 2; - extents->descender = x_scale - extents->ascender; - extents->line_gap = 0; - } - } + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + get_h_extents_with_fallback (extents); + else + get_v_extents_with_fallback (extents); } inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, @@ -325,14 +343,38 @@ struct hb_font_t { } } - /* Internal only */ inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y) { *x = get_glyph_h_advance (glyph) / 2; - /* TODO use font_extents.ascender */ - *y = y_scale; + /* TODO cache this somehow?! */ + hb_font_extents_t extents; + get_h_extents_with_fallback (&extents); + *y = extents.ascender; + } + + inline void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + if (!get_glyph_h_origin (glyph, x, y) && + get_glyph_v_origin (glyph, x, y)) + { + hb_position_t dx, dy; + guess_v_origin_minus_h_origin (glyph, &dx, &dy); + *x -= dx; *y -= dy; + } + } + inline void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph, + hb_position_t *x, hb_position_t *y) + { + if (!get_glyph_v_origin (glyph, x, y) && + get_glyph_h_origin (glyph, x, y)) + { + hb_position_t dx, dy; + guess_v_origin_minus_h_origin (glyph, &dx, &dy); + *x += dx; *y += dy; + } } inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, @@ -340,25 +382,9 @@ struct hb_font_t { hb_position_t *x, hb_position_t *y) { if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) - { - if (!get_glyph_h_origin (glyph, x, y) && - get_glyph_v_origin (glyph, x, y)) - { - hb_position_t dx, dy; - guess_v_origin_minus_h_origin (glyph, &dx, &dy); - *x -= dx; *y -= dy; - } - } + get_glyph_h_origin_with_fallback (glyph, x, y); else - { - if (!get_glyph_v_origin (glyph, x, y) && - get_glyph_h_origin (glyph, x, y)) - { - hb_position_t dx, dy; - guess_v_origin_minus_h_origin (glyph, &dx, &dy); - *x += dx; *y += dy; - } - } + get_glyph_v_origin_with_fallback (glyph, x, y); } inline void add_glyph_h_origin (hb_codepoint_t glyph, @@ -366,7 +392,7 @@ struct hb_font_t { { hb_position_t origin_x, origin_y; - get_glyph_h_origin (glyph, &origin_x, &origin_y); + get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y); *x += origin_x; *y += origin_y; @@ -376,7 +402,7 @@ struct hb_font_t { { hb_position_t origin_x, origin_y; - get_glyph_v_origin (glyph, &origin_x, &origin_y); + get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y); *x += origin_x; *y += origin_y; @@ -398,7 +424,7 @@ struct hb_font_t { { hb_position_t origin_x, origin_y; - get_glyph_h_origin (glyph, &origin_x, &origin_y); + get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y); *x -= origin_x; *y -= origin_y; @@ -408,7 +434,7 @@ struct hb_font_t { { hb_position_t origin_x, origin_y; - get_glyph_v_origin (glyph, &origin_x, &origin_y); + get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y); *x -= origin_x; *y -= origin_y; @@ -504,7 +530,6 @@ struct hb_font_t { return false; } - private: inline hb_position_t em_scale (int16_t v, int scale) { int upem = face->get_upem (); @@ -512,6 +537,10 @@ struct hb_font_t { scaled += scaled >= 0 ? upem/2 : -upem/2; /* Round. */ return (hb_position_t) (scaled / upem); } + inline hb_position_t em_scalef (float v, int scale) + { + return (hb_position_t) (v * scale / face->get_upem ()); + } }; #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.cc index eb0f9fcfd09..b81c46e51d1 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.cc @@ -35,8 +35,6 @@ #include "hb-ot-head-table.hh" #include "hb-ot-maxp-table.hh" -#include "hb-cache-private.hh" - #include @@ -401,9 +399,9 @@ static const hb_font_funcs_t _hb_font_funcs_parent = { /** * hb_font_funcs_create: (Xconstructor) * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * * Since: 0.9.2 **/ @@ -423,9 +421,9 @@ hb_font_funcs_create (void) /** * hb_font_funcs_get_empty: * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * * Since: 0.9.2 **/ @@ -439,9 +437,9 @@ hb_font_funcs_get_empty (void) * hb_font_funcs_reference: (skip) * @ffuncs: font functions. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -455,7 +453,7 @@ hb_font_funcs_reference (hb_font_funcs_t *ffuncs) * hb_font_funcs_destroy: (skip) * @ffuncs: font functions. * - * + * * * Since: 0.9.2 **/ @@ -475,14 +473,14 @@ hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) /** * hb_font_funcs_set_user_data: (skip) * @ffuncs: font functions. - * @key: - * @data: - * @destroy: - * @replace: + * @key: + * @data: + * @destroy: + * @replace: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -499,11 +497,11 @@ hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, /** * hb_font_funcs_get_user_data: (skip) * @ffuncs: font functions. - * @key: + * @key: * + * * - * - * Return value: (transfer none): + * Return value: (transfer none): * * Since: 0.9.2 **/ @@ -519,7 +517,7 @@ hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, * hb_font_funcs_make_immutable: * @ffuncs: font functions. * - * + * * * Since: 0.9.2 **/ @@ -536,9 +534,9 @@ hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) * hb_font_funcs_is_immutable: * @ffuncs: font functions. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -629,13 +627,13 @@ hb_font_get_v_extents (hb_font_t *font, /** * hb_font_get_glyph: * @font: a font. - * @unicode: - * @variation_selector: - * @glyph: (out): + * @unicode: + * @variation_selector: + * @glyph: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -652,12 +650,12 @@ hb_font_get_glyph (hb_font_t *font, /** * hb_font_get_nominal_glyph: * @font: a font. - * @unicode: - * @glyph: (out): + * @unicode: + * @glyph: (out): * + * * - * - * Return value: + * Return value: * * Since: 1.2.3 **/ @@ -672,13 +670,13 @@ hb_font_get_nominal_glyph (hb_font_t *font, /** * hb_font_get_variation_glyph: * @font: a font. - * @unicode: - * @variation_selector: - * @glyph: (out): + * @unicode: + * @variation_selector: + * @glyph: (out): * + * * - * - * Return value: + * Return value: * * Since: 1.2.3 **/ @@ -693,11 +691,11 @@ hb_font_get_variation_glyph (hb_font_t *font, /** * hb_font_get_glyph_h_advance: * @font: a font. - * @glyph: + * @glyph: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -711,11 +709,11 @@ hb_font_get_glyph_h_advance (hb_font_t *font, /** * hb_font_get_glyph_v_advance: * @font: a font. - * @glyph: + * @glyph: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -729,13 +727,13 @@ hb_font_get_glyph_v_advance (hb_font_t *font, /** * hb_font_get_glyph_h_origin: * @font: a font. - * @glyph: - * @x: (out): - * @y: (out): + * @glyph: + * @x: (out): + * @y: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -750,13 +748,13 @@ hb_font_get_glyph_h_origin (hb_font_t *font, /** * hb_font_get_glyph_v_origin: * @font: a font. - * @glyph: - * @x: (out): - * @y: (out): + * @glyph: + * @x: (out): + * @y: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -771,12 +769,12 @@ hb_font_get_glyph_v_origin (hb_font_t *font, /** * hb_font_get_glyph_h_kerning: * @font: a font. - * @left_glyph: - * @right_glyph: + * @left_glyph: + * @right_glyph: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -790,12 +788,12 @@ hb_font_get_glyph_h_kerning (hb_font_t *font, /** * hb_font_get_glyph_v_kerning: * @font: a font. - * @top_glyph: - * @bottom_glyph: + * @top_glyph: + * @bottom_glyph: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -809,12 +807,12 @@ hb_font_get_glyph_v_kerning (hb_font_t *font, /** * hb_font_get_glyph_extents: * @font: a font. - * @glyph: - * @extents: (out): + * @glyph: + * @extents: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -829,14 +827,14 @@ hb_font_get_glyph_extents (hb_font_t *font, /** * hb_font_get_glyph_contour_point: * @font: a font. - * @glyph: - * @point_index: - * @x: (out): - * @y: (out): + * @glyph: + * @point_index: + * @x: (out): + * @y: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -851,13 +849,13 @@ hb_font_get_glyph_contour_point (hb_font_t *font, /** * hb_font_get_glyph_name: * @font: a font. - * @glyph: - * @name: (array length=size): - * @size: + * @glyph: + * @name: (array length=size): + * @size: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -872,13 +870,13 @@ hb_font_get_glyph_name (hb_font_t *font, /** * hb_font_get_glyph_from_name: * @font: a font. - * @name: (array length=len): - * @len: - * @glyph: (out): + * @name: (array length=len): + * @len: + * @glyph: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -913,12 +911,12 @@ hb_font_get_extents_for_direction (hb_font_t *font, /** * hb_font_get_glyph_advance_for_direction: * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * + * @glyph: + * @direction: + * @x: (out): + * @y: (out): * + * * * Since: 0.9.2 **/ @@ -934,12 +932,12 @@ hb_font_get_glyph_advance_for_direction (hb_font_t *font, /** * hb_font_get_glyph_origin_for_direction: * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * + * @glyph: + * @direction: + * @x: (out): + * @y: (out): * + * * * Since: 0.9.2 **/ @@ -955,12 +953,12 @@ hb_font_get_glyph_origin_for_direction (hb_font_t *font, /** * hb_font_add_glyph_origin_for_direction: * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * + * @glyph: + * @direction: + * @x: (out): + * @y: (out): * + * * * Since: 0.9.2 **/ @@ -976,12 +974,12 @@ hb_font_add_glyph_origin_for_direction (hb_font_t *font, /** * hb_font_subtract_glyph_origin_for_direction: * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * + * @glyph: + * @direction: + * @x: (out): + * @y: (out): * + * * * Since: 0.9.2 **/ @@ -997,13 +995,13 @@ hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, /** * hb_font_get_glyph_kerning_for_direction: * @font: a font. - * @first_glyph: - * @second_glyph: - * @direction: - * @x: (out): - * @y: (out): - * + * @first_glyph: + * @second_glyph: + * @direction: + * @x: (out): + * @y: (out): * + * * * Since: 0.9.2 **/ @@ -1019,13 +1017,13 @@ hb_font_get_glyph_kerning_for_direction (hb_font_t *font, /** * hb_font_get_glyph_extents_for_origin: * @font: a font. - * @glyph: - * @direction: - * @extents: (out): + * @glyph: + * @direction: + * @extents: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -1041,15 +1039,15 @@ hb_font_get_glyph_extents_for_origin (hb_font_t *font, /** * hb_font_get_glyph_contour_point_for_origin: * @font: a font. - * @glyph: - * @point_index: - * @direction: - * @x: (out): - * @y: (out): + * @glyph: + * @point_index: + * @direction: + * @x: (out): + * @y: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -1066,11 +1064,11 @@ hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, /** * hb_font_glyph_to_string: * @font: a font. - * @glyph: - * @s: (array length=size): - * @size: - * + * @glyph: + * @s: (array length=size): + * @size: * + * * * Since: 0.9.2 **/ @@ -1086,13 +1084,13 @@ hb_font_glyph_to_string (hb_font_t *font, /** * hb_font_glyph_from_string: * @font: a font. - * @s: (array length=len) (element-type uint8_t): - * @len: - * @glyph: (out): + * @s: (array length=len) (element-type uint8_t): + * @len: + * @glyph: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -1113,9 +1111,9 @@ hb_font_glyph_from_string (hb_font_t *font, * hb_font_create: (Xconstructor) * @face: a face. * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * * Since: 0.9.2 **/ @@ -1143,9 +1141,9 @@ hb_font_create (hb_face_t *face) * hb_font_create_sub_font: * @parent: parent font. * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * * Since: 0.9.2 **/ @@ -1167,13 +1165,15 @@ hb_font_create_sub_font (hb_font_t *parent) font->x_ppem = parent->x_ppem; font->y_ppem = parent->y_ppem; + /* TODO: copy variation coordinates. */ + return font; } /** * hb_font_get_empty: * - * + * * * Return value: (transfer full) * @@ -1196,6 +1196,9 @@ hb_font_get_empty (void) 0, /* x_ppem */ 0, /* y_ppem */ + 0, /* num_coords */ + NULL, /* coords */ + const_cast (&_hb_font_funcs_nil), /* klass */ NULL, /* user_data */ NULL, /* destroy */ @@ -1214,9 +1217,9 @@ hb_font_get_empty (void) * hb_font_reference: (skip) * @font: a font. * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * * Since: 0.9.2 **/ @@ -1230,7 +1233,7 @@ hb_font_reference (hb_font_t *font) * hb_font_destroy: (skip) * @font: a font. * - * + * * * Since: 0.9.2 **/ @@ -1250,20 +1253,22 @@ hb_font_destroy (hb_font_t *font) hb_face_destroy (font->face); hb_font_funcs_destroy (font->klass); + free (font->coords); + free (font); } /** * hb_font_set_user_data: (skip) * @font: a font. - * @key: - * @data: - * @destroy: - * @replace: + * @key: + * @data: + * @destroy: + * @replace: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -1280,11 +1285,11 @@ hb_font_set_user_data (hb_font_t *font, /** * hb_font_get_user_data: (skip) * @font: a font. - * @key: + * @key: * + * * - * - * Return value: (transfer none): + * Return value: (transfer none): * * Since: 0.9.2 **/ @@ -1299,7 +1304,7 @@ hb_font_get_user_data (hb_font_t *font, * hb_font_make_immutable: * @font: a font. * - * + * * * Since: 0.9.2 **/ @@ -1319,9 +1324,9 @@ hb_font_make_immutable (hb_font_t *font) * hb_font_is_immutable: * @font: a font. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -1361,9 +1366,9 @@ hb_font_set_parent (hb_font_t *font, * hb_font_get_parent: * @font: a font. * + * * - * - * Return value: (transfer none): + * Return value: (transfer none): * * Since: 0.9.2 **/ @@ -1377,9 +1382,9 @@ hb_font_get_parent (hb_font_t *font) * hb_font_get_face: * @font: a font. * + * * - * - * Return value: (transfer none): + * Return value: (transfer none): * * Since: 0.9.2 **/ @@ -1394,10 +1399,10 @@ hb_font_get_face (hb_font_t *font) * hb_font_set_funcs: * @font: a font. * @klass: (closure font_data) (destroy destroy) (scope notified): - * @font_data: - * @destroy: - * + * @font_data: + * @destroy: * + * * * Since: 0.9.2 **/ @@ -1430,9 +1435,9 @@ hb_font_set_funcs (hb_font_t *font, * hb_font_set_funcs_data: * @font: a font. * @font_data: (destroy destroy) (scope notified): - * @destroy: - * + * @destroy: * + * * * Since: 0.9.2 **/ @@ -1459,10 +1464,10 @@ hb_font_set_funcs_data (hb_font_t *font, /** * hb_font_set_scale: * @font: a font. - * @x_scale: - * @y_scale: - * + * @x_scale: + * @y_scale: * + * * * Since: 0.9.2 **/ @@ -1481,10 +1486,10 @@ hb_font_set_scale (hb_font_t *font, /** * hb_font_get_scale: * @font: a font. - * @x_scale: (out): - * @y_scale: (out): - * + * @x_scale: (out): + * @y_scale: (out): * + * * * Since: 0.9.2 **/ @@ -1500,10 +1505,10 @@ hb_font_get_scale (hb_font_t *font, /** * hb_font_set_ppem: * @font: a font. - * @x_ppem: - * @y_ppem: - * + * @x_ppem: + * @y_ppem: * + * * * Since: 0.9.2 **/ @@ -1522,10 +1527,10 @@ hb_font_set_ppem (hb_font_t *font, /** * hb_font_get_ppem: * @font: a font. - * @x_ppem: (out): - * @y_ppem: (out): - * + * @x_ppem: (out): + * @y_ppem: (out): * + * * * Since: 0.9.2 **/ @@ -1539,6 +1544,32 @@ hb_font_get_ppem (hb_font_t *font, } +void +hb_font_set_var_coords_normalized (hb_font_t *font, + int *coords, /* XXX 2.14 normalized */ + unsigned int coords_length) +{ + if (font->immutable) + return; + + /* Skip tail zero entries. */ + while (coords_length && !coords[coords_length - 1]) + coords_length--; + + int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : NULL; + if (unlikely (coords_length && !copy)) + return; + + free (font->coords); + + if (coords_length) + memcpy (copy, coords, coords_length * sizeof (coords[0])); + + font->coords = copy; + font->num_coords = coords_length; +} + + #ifndef HB_DISABLE_DEPRECATED /* diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.h b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.h index da9a3a7543c..ff5d88f642c 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.h @@ -604,6 +604,11 @@ hb_font_get_ppem (hb_font_t *font, unsigned int *y_ppem); +HB_EXTERN void +hb_font_set_var_coords_normalized (hb_font_t *font, + int *coords, /* XXX 2.14 normalized */ + unsigned int coords_length); + HB_END_DECLS #endif /* HB_FONT_H */ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc index fb3c1dfbcf0..fda781623fd 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc @@ -33,7 +33,10 @@ #include "hb-font-private.hh" +#include "hb-cache-private.hh" // Maybe use in the future? + #include FT_ADVANCES_H +#include FT_MULTIPLE_MASTERS_H #include FT_TRUETYPE_TABLES_H @@ -111,7 +114,7 @@ _hb_ft_font_destroy (hb_ft_font_t *ft_font) * @font: * @load_flags: * - * + * * * Since: 1.0.5 **/ @@ -133,7 +136,7 @@ hb_ft_font_set_load_flags (hb_font_t *font, int load_flags) * hb_ft_font_get_load_flags: * @font: * - * + * * * Return value: * Since: 1.0.5 @@ -504,12 +507,12 @@ reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) /** * hb_ft_face_create: - * @ft_face: (destroy destroy) (scope notified): + * @ft_face: (destroy destroy) (scope notified): * @destroy: * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * Since: 0.9.2 **/ hb_face_t * @@ -541,9 +544,9 @@ hb_ft_face_create (FT_Face ft_face, * hb_ft_face_create_referenced: * @ft_face: * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * Since: 0.9.38 **/ hb_face_t * @@ -561,11 +564,11 @@ hb_ft_face_finalize (FT_Face ft_face) /** * hb_ft_face_create_cached: - * @ft_face: + * @ft_face: * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * Since: 0.9.2 **/ hb_face_t * @@ -586,12 +589,12 @@ hb_ft_face_create_cached (FT_Face ft_face) /** * hb_ft_font_create: - * @ft_face: (destroy destroy) (scope notified): + * @ft_face: (destroy destroy) (scope notified): * @destroy: * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * Since: 0.9.2 **/ hb_font_t * @@ -606,14 +609,31 @@ hb_ft_font_create (FT_Face ft_face, hb_face_destroy (face); _hb_ft_font_set_funcs (font, ft_face, false); hb_font_set_scale (font, - (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16), - (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16)); + (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16), + (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16)); #if 0 /* hb-ft works in no-hinting model */ hb_font_set_ppem (font, ft_face->size->metrics.x_ppem, ft_face->size->metrics.y_ppem); #endif +#ifdef HAVE_FT_GET_VAR_BLEND_COORDINATES + FT_MM_Var *mm_var = NULL; + if (!FT_Get_MM_Var (ft_face, &mm_var)) + { + FT_Fixed coords[mm_var->num_axis]; + int hbCoords[mm_var->num_axis]; + if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, coords)) + { + for (int i = 0; i < mm_var->num_axis; ++i) + hbCoords[i] = coords[i] >> 2; + + hb_font_set_var_coords_normalized (font, hbCoords, mm_var->num_axis); + } + } + free (mm_var); +#endif + return font; } @@ -621,9 +641,9 @@ hb_ft_font_create (FT_Face ft_face, * hb_ft_font_create_referenced: * @ft_face: * + * * - * - * Return value: (transfer full): + * Return value: (transfer full): * Since: 0.9.38 **/ hb_font_t * diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-type-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-type-private.hh index 27c5f1703cd..15e927dcd8f 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-type-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-open-type-private.hh @@ -105,7 +105,7 @@ static inline Type& StructAfter(TObject &X) inline unsigned int get_size (void) const { return (size); } #define DEFINE_SIZE_UNION(size, _member) \ - DEFINE_INSTANCE_ASSERTION (this->u._member.static_size == (size)); \ + DEFINE_INSTANCE_ASSERTION (0*sizeof(this->u._member.static_size) + sizeof(this->u._member) == (size)); \ static const unsigned int min_size = (size) #define DEFINE_SIZE_MIN(size) \ @@ -650,7 +650,9 @@ struct IntType DEFINE_SIZE_STATIC (Size); }; +typedef IntType CHAR; /* 8-bit signed integer. */ typedef IntType BYTE; /* 8-bit unsigned integer. */ +typedef IntType INT8; /* 8-bit signed integer. */ typedef IntType USHORT; /* 16-bit unsigned integer. */ typedef IntType SHORT; /* 16-bit signed integer. */ typedef IntType ULONG; /* 32-bit unsigned integer. */ @@ -805,6 +807,7 @@ struct OffsetTo : Offset if (unlikely (!c->check_struct (this))) return_trace (false); unsigned int offset = *this; if (unlikely (!offset)) return_trace (true); + if (unlikely (!c->check_range (base, offset))) return_trace (false); const Type &obj = StructAtOffset (base, offset); return_trace (likely (obj.sanitize (c)) || neuter (c)); } @@ -815,6 +818,7 @@ struct OffsetTo : Offset if (unlikely (!c->check_struct (this))) return_trace (false); unsigned int offset = *this; if (unlikely (!offset)) return_trace (true); + if (unlikely (!c->check_range (base, offset))) return_trace (false); const Type &obj = StructAtOffset (base, offset); return_trace (likely (obj.sanitize (c, user_data)) || neuter (c)); } @@ -948,8 +952,8 @@ struct ArrayOf }; /* Array of Offset's */ -template -struct OffsetArrayOf : ArrayOf > {}; +template +struct OffsetArrayOf : ArrayOf > {}; /* Array of offsets relative to the beginning of the array itself. */ template diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-cbdt-table.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-cbdt-table.hh new file mode 100644 index 00000000000..52897abd3a3 --- /dev/null +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-cbdt-table.hh @@ -0,0 +1,384 @@ +/* + * Copyright © 2016 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Seigo Nonaka + */ + +#ifndef HB_OT_CBDT_TABLE_HH +#define HB_OT_CBDT_TABLE_HH + +#include "hb-open-type-private.hh" + +namespace OT { + +struct SmallGlyphMetrics +{ + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + inline void get_extents (hb_glyph_extents_t *extents) const + { + extents->x_bearing = bearingX; + extents->y_bearing = bearingY; + extents->width = width; + extents->height = -height; + } + + BYTE height; + BYTE width; + CHAR bearingX; + CHAR bearingY; + BYTE advance; + + DEFINE_SIZE_STATIC(5); +}; + +struct BigGlyphMetrics : SmallGlyphMetrics +{ + CHAR vertBearingX; + CHAR vertBearingY; + BYTE vertAdvance; + + DEFINE_SIZE_STATIC(8); +}; + +struct SBitLineMetrics +{ + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + CHAR ascender; + CHAR decender; + BYTE widthMax; + CHAR caretSlopeNumerator; + CHAR caretSlopeDenominator; + CHAR caretOffset; + CHAR minOriginSB; + CHAR minAdvanceSB; + CHAR maxBeforeBL; + CHAR minAfterBL; + CHAR padding1; + CHAR padding2; + + DEFINE_SIZE_STATIC(12); +}; + + +/* + * Index Subtables. + */ + +struct IndexSubtableHeader +{ + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + USHORT indexFormat; + USHORT imageFormat; + ULONG imageDataOffset; + + DEFINE_SIZE_STATIC(8); +}; + +template +struct IndexSubtableFormat1Or3 +{ + inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + c->check_array (offsetArrayZ, offsetArrayZ[0].static_size, glyph_count + 1)); + } + + bool get_image_data (unsigned int idx, + unsigned int *offset, + unsigned int *length) const + { + if (unlikely (offsetArrayZ[idx + 1] <= offsetArrayZ[idx])) + return false; + + *offset = header.imageDataOffset + offsetArrayZ[idx]; + *length = offsetArrayZ[idx + 1] - offsetArrayZ[idx]; + return true; + } + + IndexSubtableHeader header; + Offset offsetArrayZ[VAR]; + + DEFINE_SIZE_ARRAY(8, offsetArrayZ); +}; + +struct IndexSubtableFormat1 : IndexSubtableFormat1Or3 {}; +struct IndexSubtableFormat3 : IndexSubtableFormat1Or3 {}; + +struct IndexSubtable +{ + inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const + { + TRACE_SANITIZE (this); + if (!u.header.sanitize (c)) return_trace (false); + switch (u.header.indexFormat) { + case 1: return_trace (u.format1.sanitize (c, glyph_count)); + case 3: return_trace (u.format3.sanitize (c, glyph_count)); + default:return_trace (true); + } + } + + inline bool get_extents (hb_glyph_extents_t *extents) const + { + switch (u.header.indexFormat) { + case 2: case 5: /* TODO */ + case 1: case 3: case 4: /* Variable-metrics formats do not have metrics here. */ + default:return (false); + } + } + + bool get_image_data (unsigned int idx, + unsigned int *offset, + unsigned int *length, + unsigned int *format) const + { + *format = u.header.imageFormat; + switch (u.header.indexFormat) { + case 1: return u.format1.get_image_data (idx, offset, length); + case 3: return u.format3.get_image_data (idx, offset, length); + default: return false; + } + } + + protected: + union { + IndexSubtableHeader header; + IndexSubtableFormat1 format1; + IndexSubtableFormat3 format3; + /* TODO: Format 2, 4, 5. */ + } u; + public: + DEFINE_SIZE_UNION (8, header); +}; + +struct IndexSubtableRecord +{ + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + firstGlyphIndex <= lastGlyphIndex && + offsetToSubtable.sanitize (c, this, lastGlyphIndex - firstGlyphIndex + 1)); + } + + inline bool get_extents (hb_glyph_extents_t *extents) const + { + return (this+offsetToSubtable).get_extents (extents); + } + + bool get_image_data (unsigned int gid, + unsigned int *offset, + unsigned int *length, + unsigned int *format) const + { + if (gid < firstGlyphIndex || gid > lastGlyphIndex) + { + return false; + } + return (this+offsetToSubtable).get_image_data (gid - firstGlyphIndex, + offset, length, format); + } + + USHORT firstGlyphIndex; + USHORT lastGlyphIndex; + OffsetTo offsetToSubtable; + + DEFINE_SIZE_STATIC(8); +}; + +struct IndexSubtableArray +{ + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, count))) + return_trace (false); + for (unsigned int i = 0; i < count; i++) + if (unlikely (!indexSubtablesZ[i].sanitize (c, this))) + return_trace (false); + return_trace (true); + } + + public: + const IndexSubtableRecord* find_table (hb_codepoint_t glyph, unsigned int numTables) const + { + for (unsigned int i = 0; i < numTables; ++i) + { + unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex; + unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex; + if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) { + return &indexSubtablesZ[i]; + } + } + return NULL; + } + + protected: + IndexSubtableRecord indexSubtablesZ[VAR]; + + public: + DEFINE_SIZE_ARRAY(0, indexSubtablesZ); +}; + +struct BitmapSizeTable +{ + friend struct CBLC; + + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + indexSubtableArrayOffset.sanitize (c, base, numberOfIndexSubtables) && + c->check_range (&(base+indexSubtableArrayOffset), indexTablesSize) && + horizontal.sanitize (c) && + vertical.sanitize (c)); + } + + const IndexSubtableRecord *find_table (hb_codepoint_t glyph, const void *base) const + { + return (base+indexSubtableArrayOffset).find_table (glyph, numberOfIndexSubtables); + } + + protected: + OffsetTo indexSubtableArrayOffset; + ULONG indexTablesSize; + ULONG numberOfIndexSubtables; + ULONG colorRef; + SBitLineMetrics horizontal; + SBitLineMetrics vertical; + USHORT startGlyphIndex; + USHORT endGlyphIndex; + BYTE ppemX; + BYTE ppemY; + BYTE bitDepth; + CHAR flags; + +public: + DEFINE_SIZE_STATIC(48); +}; + + +/* + * Glyph Bitmap Data Formats. + */ + +struct GlyphBitmapDataFormat17 +{ + SmallGlyphMetrics glyphMetrics; + ULONG dataLen; + BYTE dataZ[VAR]; + + DEFINE_SIZE_ARRAY(9, dataZ); +}; + + +/* + * CBLC -- Color Bitmap Location Table + */ + +#define HB_OT_TAG_CBLC HB_TAG('C','B','L','C') + +struct CBLC +{ + static const hb_tag_t tableTag = HB_OT_TAG_CBLC; + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + likely (version.major == 2 || version.major == 3) && + sizeTables.sanitize (c, this)); + } + + public: + const IndexSubtableRecord *find_table (hb_codepoint_t glyph, + unsigned int *x_ppem, unsigned int *y_ppem) const + { + /* TODO: Make it possible to select strike. */ + + unsigned int count = sizeTables.len; + for (uint32_t i = 0; i < count; ++i) + { + unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex; + unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex; + if (startGlyphIndex <= glyph && glyph <= endGlyphIndex) + { + *x_ppem = sizeTables[i].ppemX; + *y_ppem = sizeTables[i].ppemY; + return sizeTables[i].find_table (glyph, this); + } + } + + return NULL; + } + + protected: + FixedVersion<>version; + ArrayOf sizeTables; + + public: + DEFINE_SIZE_ARRAY(8, sizeTables); +}; + +/* + * CBDT -- Color Bitmap Data Table + */ +#define HB_OT_TAG_CBDT HB_TAG('C','B','D','T') + +struct CBDT +{ + static const hb_tag_t tableTag = HB_OT_TAG_CBDT; + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + likely (version.major == 2 || version.major == 3)); + } + + protected: + FixedVersion<>version; + BYTE dataZ[VAR]; + + public: + DEFINE_SIZE_ARRAY(4, dataZ); +}; + +} /* namespace OT */ + +#endif /* HB_OT_CBDT_TABLE_HH */ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-font.cc index 3c63f336a6b..3b3122b69a3 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-font.cc @@ -31,6 +31,7 @@ #include "hb-font-private.hh" #include "hb-ot-cmap-table.hh" +#include "hb-ot-cbdt-table.hh" #include "hb-ot-glyf-table.hh" #include "hb-ot-head-table.hh" #include "hb-ot-hhea-table.hh" @@ -47,6 +48,7 @@ struct hb_ot_face_metrics_accelerator_t unsigned short ascender; unsigned short descender; unsigned short line_gap; + bool has_font_extents; const OT::_mtx *table; hb_blob_t *blob; @@ -54,9 +56,10 @@ struct hb_ot_face_metrics_accelerator_t inline void init (hb_face_t *face, hb_tag_t _hea_tag, hb_tag_t _mtx_tag, - hb_tag_t os2_tag) + hb_tag_t os2_tag, + unsigned int default_advance = 0) { - this->default_advance = face->get_upem (); + this->default_advance = default_advance ? default_advance : face->get_upem (); bool got_font_extents = false; if (os2_tag) @@ -82,9 +85,12 @@ struct hb_ot_face_metrics_accelerator_t this->ascender = _hea->ascender; this->descender = _hea->descender; this->line_gap = _hea->lineGap; + got_font_extents = (this->ascender | this->descender) != 0; } hb_blob_destroy (_hea_blob); + this->has_font_extents = got_font_extents; + this->blob = OT::Sanitizer::sanitize (face->reference_table (_mtx_tag)); /* Cap num_metrics() and num_advances() based on table length. */ @@ -202,6 +208,91 @@ struct hb_ot_face_glyf_accelerator_t } }; +struct hb_ot_face_cbdt_accelerator_t +{ + hb_blob_t *cblc_blob; + hb_blob_t *cbdt_blob; + const OT::CBLC *cblc; + const OT::CBDT *cbdt; + + unsigned int cbdt_len; + float upem; + + inline void init (hb_face_t *face) + { + upem = face->get_upem(); + + cblc_blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_CBLC)); + cbdt_blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_CBDT)); + cbdt_len = hb_blob_get_length (cbdt_blob); + + if (hb_blob_get_length (cblc_blob) == 0) { + cblc = NULL; + cbdt = NULL; + return; /* Not a bitmap font. */ + } + cblc = OT::Sanitizer::lock_instance (cblc_blob); + cbdt = OT::Sanitizer::lock_instance (cbdt_blob); + + } + + inline void fini (void) + { + hb_blob_destroy (this->cblc_blob); + hb_blob_destroy (this->cbdt_blob); + } + + inline bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const + { + unsigned int x_ppem = upem, y_ppem = upem; /* TODO Use font ppem if available. */ + + if (cblc == NULL) + return false; // Not a color bitmap font. + + const OT::IndexSubtableRecord *subtable_record = this->cblc->find_table(glyph, &x_ppem, &y_ppem); + if (subtable_record == NULL) + return false; + + if (subtable_record->get_extents (extents)) + return true; + + unsigned int image_offset = 0, image_length = 0, image_format = 0; + if (!subtable_record->get_image_data (glyph, &image_offset, &image_length, &image_format)) + return false; + + { + /* TODO Move the following into CBDT struct when adding more formats. */ + + if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length)) + return false; + + switch (image_format) + { + case 17: { + if (unlikely (image_length < OT::GlyphBitmapDataFormat17::min_size)) + return false; + + const OT::GlyphBitmapDataFormat17& glyphFormat17 = + OT::StructAtOffset (this->cbdt, image_offset); + glyphFormat17.glyphMetrics.get_extents (extents); + } + break; + default: + // TODO: Support other image formats. + return false; + } + } + + /* Convert to the font units. */ + extents->x_bearing *= upem / (float) x_ppem; + extents->y_bearing *= upem / (float) y_ppem; + extents->width *= upem / (float) x_ppem; + extents->height *= upem / (float) y_ppem; + + return true; + } +}; + typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph); @@ -264,7 +355,11 @@ struct hb_ot_face_cmap_accelerator_t if (!subtable) subtable = cmap->find_subtable (0, 2); if (!subtable) subtable = cmap->find_subtable (0, 1); if (!subtable) subtable = cmap->find_subtable (0, 0); - if (!subtable)(subtable = cmap->find_subtable (3, 0)) && (symbol = true); + if (!subtable) + { + subtable = cmap->find_subtable (3, 0); + if (subtable) symbol = true; + } /* Meh. */ if (!subtable) subtable = &OT::Null(OT::CmapSubtable); @@ -374,6 +469,7 @@ struct hb_ot_font_t hb_ot_face_metrics_accelerator_t h_metrics; hb_ot_face_metrics_accelerator_t v_metrics; hb_lazy_loader_t glyf; + hb_lazy_loader_t cbdt; }; @@ -387,8 +483,10 @@ _hb_ot_font_create (hb_face_t *face) ot_font->cmap.init (face); ot_font->h_metrics.init (face, HB_OT_TAG_hhea, HB_OT_TAG_hmtx, HB_OT_TAG_os2); - ot_font->v_metrics.init (face, HB_OT_TAG_vhea, HB_OT_TAG_vmtx, HB_TAG_NONE); /* TODO Can we do this lazily? */ + ot_font->v_metrics.init (face, HB_OT_TAG_vhea, HB_OT_TAG_vmtx, HB_TAG_NONE, + ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */ ot_font->glyf.init (face); + ot_font->cbdt.init (face); return ot_font; } @@ -400,6 +498,7 @@ _hb_ot_font_destroy (hb_ot_font_t *ot_font) ot_font->h_metrics.fini (); ot_font->v_metrics.fini (); ot_font->glyf.fini (); + ot_font->cbdt.fini (); free (ot_font); } @@ -458,6 +557,8 @@ hb_ot_get_glyph_extents (hb_font_t *font HB_UNUSED, { const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; bool ret = ot_font->glyf->get_extents (glyph, extents); + if (!ret) + ret = ot_font->cbdt->get_extents (glyph, extents); extents->x_bearing = font->em_scale_x (extents->x_bearing); extents->y_bearing = font->em_scale_y (extents->y_bearing); extents->width = font->em_scale_x (extents->width); @@ -475,7 +576,7 @@ hb_ot_get_font_h_extents (hb_font_t *font HB_UNUSED, metrics->ascender = font->em_scale_y (ot_font->h_metrics.ascender); metrics->descender = font->em_scale_y (ot_font->h_metrics.descender); metrics->line_gap = font->em_scale_y (ot_font->h_metrics.line_gap); - return true; + return ot_font->h_metrics.has_font_extents; } static hb_bool_t @@ -488,7 +589,7 @@ hb_ot_get_font_v_extents (hb_font_t *font HB_UNUSED, metrics->ascender = font->em_scale_x (ot_font->v_metrics.ascender); metrics->descender = font->em_scale_x (ot_font->v_metrics.descender); metrics->line_gap = font->em_scale_x (ot_font->v_metrics.line_gap); - return true; + return ot_font->v_metrics.has_font_extents; } static hb_font_funcs_t *static_ot_funcs = NULL; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh index f6d966cc97d..80dc44eb1d8 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-common-private.hh @@ -507,7 +507,7 @@ struct Feature { return this+featureParams; } inline bool sanitize (hb_sanitize_context_t *c, - const Record::sanitize_closure_t *closure) const + const Record::sanitize_closure_t *closure = NULL) const { TRACE_SANITIZE (this); if (unlikely (!(c->check_struct (this) && lookupIndex.sanitize (c)))) @@ -731,8 +731,8 @@ struct CoverageFormat1 inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; }; inline bool more (void) { return i < c->glyphArray.len; } inline void next (void) { i++; } - inline uint16_t get_glyph (void) { return c->glyphArray[i]; } - inline uint16_t get_coverage (void) { return i; } + inline hb_codepoint_t get_glyph (void) { return c->glyphArray[i]; } + inline unsigned int get_coverage (void) { return i; } private: const struct CoverageFormat1 *c; @@ -829,26 +829,33 @@ struct CoverageFormat2 public: /* Older compilers need this to be public. */ - struct Iter { - inline void init (const CoverageFormat2 &c_) { + struct Iter + { + inline void init (const CoverageFormat2 &c_) + { c = &c_; coverage = 0; i = 0; j = c->rangeRecord.len ? c_.rangeRecord[0].start : 0; } inline bool more (void) { return i < c->rangeRecord.len; } - inline void next (void) { - coverage++; - if (j == c->rangeRecord[i].end) { + inline void next (void) + { + if (j >= c->rangeRecord[i].end) + { i++; if (more ()) + { j = c->rangeRecord[i].start; + coverage = c->rangeRecord[i].value; + } return; } + coverage++; j++; } - inline uint16_t get_glyph (void) { return j; } - inline uint16_t get_coverage (void) { return coverage; } + inline hb_codepoint_t get_glyph (void) { return j; } + inline unsigned int get_coverage (void) { return coverage; } private: const struct CoverageFormat2 *c; @@ -957,14 +964,14 @@ struct Coverage default: break; } } - inline uint16_t get_glyph (void) { + inline hb_codepoint_t get_glyph (void) { switch (format) { case 1: return u.format1.get_glyph (); case 2: return u.format2.get_glyph (); default:return 0; } } - inline uint16_t get_coverage (void) { + inline unsigned int get_coverage (void) { switch (format) { case 1: return u.format1.get_coverage (); case 2: return u.format2.get_coverage (); @@ -1161,12 +1168,381 @@ struct ClassDef }; +/* + * Item Variation Store + */ + +struct VarRegionAxis +{ + inline float evaluate (int coord) const + { + int start = startCoord, peak = peakCoord, end = endCoord; + + /* TODO Move these to sanitize(). */ + if (unlikely (start > peak || peak > end)) + return 1.; + if (unlikely (start < 0 && end > 0 && peak != 0)) + return 1.; + + if (peak == 0 || coord == peak) + return 1.; + + if (coord <= start || end <= coord) + return 0.; + + /* Interpolate */ + if (coord < peak) + return float (coord - start) / (peak - start); + else + return float (end - coord) / (end - peak); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + /* TODO Handle invalid start/peak/end configs, so we don't + * have to do that at runtime. */ + } + + public: + F2DOT14 startCoord; + F2DOT14 peakCoord; + F2DOT14 endCoord; + public: + DEFINE_SIZE_STATIC (6); +}; + +struct VarRegionList +{ + inline float evaluate (unsigned int region_index, + int *coords, unsigned int coord_len) const + { + if (unlikely (region_index >= regionCount)) + return 0.; + + const VarRegionAxis *axes = axesZ + (region_index * axisCount); + + float v = 1.; + unsigned int count = MIN (coord_len, (unsigned int) axisCount); + for (unsigned int i = 0; i < count; i++) + { + float factor = axes[i].evaluate (coords[i]); + if (factor == 0.) + return 0.; + v *= factor; + } + return v; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + c->check_array (axesZ, axesZ[0].static_size, + (unsigned int) axisCount * (unsigned int) regionCount)); + } + + protected: + USHORT axisCount; + USHORT regionCount; + VarRegionAxis axesZ[VAR]; + public: + DEFINE_SIZE_ARRAY (4, axesZ); +}; + +struct VarData +{ + inline unsigned int get_row_size (void) const + { return shortCount + regionIndices.len; } + + inline unsigned int get_size (void) const + { return itemCount * get_row_size (); } + + inline float get_delta (unsigned int inner, + int *coords, unsigned int coord_count, + const VarRegionList ®ions) const + { + if (unlikely (inner >= itemCount)) + return 0.; + + unsigned int count = regionIndices.len; + unsigned int scount = shortCount; + + const BYTE *bytes = &StructAfter (regionIndices); + const BYTE *row = bytes + inner * (scount + count); + + float delta = 0.; + unsigned int i = 0; + + const SHORT *scursor = reinterpret_cast (row); + for (; i < scount; i++) + { + float scalar = regions.evaluate (regionIndices.array[i], coords, coord_count); + delta += scalar * *scursor++; + } + const INT8 *bcursor = reinterpret_cast (scursor); + for (; i < count; i++) + { + float scalar = regions.evaluate (regionIndices.array[i], coords, coord_count); + delta += scalar * *bcursor++; + } + + return delta; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + regionIndices.sanitize(c) && + shortCount <= regionIndices.len && + c->check_array (&StructAfter (regionIndices), + get_row_size (), itemCount)); + } + + protected: + USHORT itemCount; + USHORT shortCount; + ArrayOf regionIndices; + BYTE bytesX[VAR]; + public: + DEFINE_SIZE_ARRAY2 (6, regionIndices, bytesX); +}; + +struct VariationStore +{ + inline float get_delta (unsigned int outer, unsigned int inner, + int *coords, unsigned int coord_count) const + { + if (unlikely (outer >= dataSets.len)) + return 0.; + + return (this+dataSets[outer]).get_delta (inner, + coords, coord_count, + this+regions); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && + format == 1 && + regions.sanitize (c, this) && + dataSets.sanitize (c, this)); + } + + protected: + USHORT format; + OffsetTo regions; + OffsetArrayOf dataSets; + public: + DEFINE_SIZE_ARRAY (8, dataSets); +}; + +/* + * Feature Variations + */ + +struct ConditionFormat1 +{ + friend struct Condition; + + private: + inline bool evaluate (const int *coords, unsigned int coord_len) const + { + int coord = axisIndex < coord_len ? coords[axisIndex] : 0; + return filterRangeMinValue <= coord && coord <= filterRangeMaxValue; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + protected: + USHORT format; /* Format identifier--format = 1 */ + USHORT axisIndex; + F2DOT14 filterRangeMinValue; + F2DOT14 filterRangeMaxValue; + public: + DEFINE_SIZE_STATIC (8); +}; + +struct Condition +{ + inline bool evaluate (const int *coords, unsigned int coord_len) const + { + switch (u.format) { + case 1: return u.format1.evaluate (coords, coord_len); + default:return false; + } + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (!u.format.sanitize (c)) return_trace (false); + switch (u.format) { + case 1: return_trace (u.format1.sanitize (c)); + default:return_trace (true); + } + } + + protected: + union { + USHORT format; /* Format identifier */ + ConditionFormat1 format1; + } u; + public: + DEFINE_SIZE_UNION (2, format); +}; + +struct ConditionSet +{ + inline bool evaluate (const int *coords, unsigned int coord_len) const + { + unsigned int count = conditions.len; + for (unsigned int i = 0; i < count; i++) + if (!(this+conditions.array[i]).evaluate (coords, coord_len)) + return false; + return true; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (conditions.sanitize (c, this)); + } + + protected: + OffsetArrayOf conditions; + public: + DEFINE_SIZE_ARRAY (2, conditions); +}; + +struct FeatureTableSubstitutionRecord +{ + friend struct FeatureTableSubstitution; + + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this) && feature.sanitize (c, base)); + } + + protected: + USHORT featureIndex; + OffsetTo feature; + public: + DEFINE_SIZE_STATIC (6); +}; + +struct FeatureTableSubstitution +{ + inline const Feature *find_substitute (unsigned int feature_index) const + { + unsigned int count = substitutions.len; + for (unsigned int i = 0; i < count; i++) + { + const FeatureTableSubstitutionRecord &record = substitutions.array[i]; + if (record.featureIndex == feature_index) + return &(this+record.feature); + } + return NULL; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (version.sanitize (c) && + likely (version.major == 1) && + substitutions.sanitize (c, this)); + } + + protected: + FixedVersion<> version; /* Version--0x00010000u */ + ArrayOf + substitutions; + public: + DEFINE_SIZE_ARRAY (6, substitutions); +}; + +struct FeatureVariationRecord +{ + friend struct FeatureVariations; + + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + return_trace (conditions.sanitize (c, base) && + substitutions.sanitize (c, base)); + } + + protected: + OffsetTo + conditions; + OffsetTo + substitutions; + public: + DEFINE_SIZE_STATIC (8); +}; + +struct FeatureVariations +{ + static const unsigned int NOT_FOUND_INDEX = 0xFFFFFFFFu; + + inline bool find_index (const int *coords, unsigned int coord_len, + unsigned int *index) const + { + unsigned int count = varRecords.len; + for (unsigned int i = 0; i < count; i++) + { + const FeatureVariationRecord &record = varRecords.array[i]; + if ((this+record.conditions).evaluate (coords, coord_len)) + { + *index = i; + return true; + } + } + *index = NOT_FOUND_INDEX; + return false; + } + + inline const Feature *find_substitute (unsigned int variations_index, + unsigned int feature_index) const + { + const FeatureVariationRecord &record = varRecords[variations_index]; + return (this+record.substitutions).find_substitute (feature_index); + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (version.sanitize (c) && + likely (version.major == 1) && + varRecords.sanitize (c, this)); + } + + protected: + FixedVersion<> version; /* Version--0x00010000u */ + ArrayOf + varRecords; + public: + DEFINE_SIZE_ARRAY (8, varRecords); +}; + + /* * Device Tables */ -struct Device +struct HintingDevice { + friend struct Device; + + private: inline hb_position_t get_x_delta (hb_font_t *font) const { return get_delta (font->x_ppem, font->x_scale); } @@ -1235,6 +1611,101 @@ struct Device DEFINE_SIZE_ARRAY (6, deltaValue); }; +struct VariationDevice +{ + friend struct Device; + + private: + + inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store) const + { return font->em_scalef_x (get_delta (font, store)); } + + inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store) const + { return font->em_scalef_y (get_delta (font, store)); } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (c->check_struct (this)); + } + + private: + + inline float get_delta (hb_font_t *font, const VariationStore &store) const + { + return store.get_delta (outerIndex, innerIndex, font->coords, font->num_coords); + } + + protected: + USHORT outerIndex; + USHORT innerIndex; + USHORT deltaFormat; /* Format identifier for this table: 0x0x8000 */ + public: + DEFINE_SIZE_STATIC (6); +}; + +struct DeviceHeader +{ + protected: + USHORT reserved1; + USHORT reserved2; + public: + USHORT format; /* Format identifier */ + public: + DEFINE_SIZE_STATIC (6); +}; + +struct Device +{ + inline hb_position_t get_x_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const + { + switch (u.b.format) + { + case 1: case 2: case 3: + return u.hinting.get_x_delta (font); + case 0x8000: + return u.variation.get_x_delta (font, store); + default: + return 0; + } + } + inline hb_position_t get_y_delta (hb_font_t *font, const VariationStore &store=Null(VariationStore)) const + { + switch (u.b.format) + { + case 1: case 2: case 3: + return u.hinting.get_y_delta (font); + case 0x8000: + return u.variation.get_y_delta (font, store); + default: + return 0; + } + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + if (!u.b.format.sanitize (c)) return_trace (false); + switch (u.b.format) { + case 1: case 2: case 3: + return_trace (u.hinting.sanitize (c)); + case 0x8000: + return_trace (u.variation.sanitize (c)); + default: + return_trace (true); + } + } + + protected: + union { + DeviceHeader b; + HintingDevice hinting; + VariationDevice variation; + } u; + public: + DEFINE_SIZE_UNION (6, b); +}; + } /* namespace OT */ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gdef-table.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gdef-table.hh index b77ce74062d..87abad61864 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gdef-table.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gdef-table.hh @@ -97,7 +97,7 @@ struct CaretValueFormat1 friend struct CaretValue; private: - inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const + inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction) const { return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->em_scale_x (coordinate) : font->em_scale_y (coordinate); } @@ -146,11 +146,11 @@ struct CaretValueFormat3 { friend struct CaretValue; - inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const + inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, const VariationStore &var_store) const { return HB_DIRECTION_IS_HORIZONTAL (direction) ? - font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font) : - font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font); + font->em_scale_x (coordinate) + (this+deviceTable).get_x_delta (font, var_store) : + font->em_scale_y (coordinate) + (this+deviceTable).get_y_delta (font, var_store); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -172,12 +172,15 @@ struct CaretValueFormat3 struct CaretValue { - inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const + inline hb_position_t get_caret_value (hb_font_t *font, + hb_direction_t direction, + hb_codepoint_t glyph_id, + const VariationStore &var_store) const { switch (u.format) { - case 1: return u.format1.get_caret_value (font, direction, glyph_id); + case 1: return u.format1.get_caret_value (font, direction); case 2: return u.format2.get_caret_value (font, direction, glyph_id); - case 3: return u.format3.get_caret_value (font, direction, glyph_id); + case 3: return u.format3.get_caret_value (font, direction, var_store); default:return 0; } } @@ -210,6 +213,7 @@ struct LigGlyph inline unsigned int get_lig_carets (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id, + const VariationStore &var_store, unsigned int start_offset, unsigned int *caret_count /* IN/OUT */, hb_position_t *caret_array /* OUT */) const @@ -218,7 +222,7 @@ struct LigGlyph const OffsetTo *array = carets.sub_array (start_offset, caret_count); unsigned int count = *caret_count; for (unsigned int i = 0; i < count; i++) - caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id); + caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id, var_store); } return carets.len; @@ -244,6 +248,7 @@ struct LigCaretList inline unsigned int get_lig_carets (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id, + const VariationStore &var_store, unsigned int start_offset, unsigned int *caret_count /* IN/OUT */, hb_position_t *caret_array /* OUT */) const @@ -256,7 +261,7 @@ struct LigCaretList return 0; } const LigGlyph &lig_glyph = this+ligGlyph[index]; - return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); + return lig_glyph.get_lig_carets (font, direction, glyph_id, var_store, start_offset, caret_count, caret_array); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -367,11 +372,17 @@ struct GDEF unsigned int start_offset, unsigned int *caret_count /* IN/OUT */, hb_position_t *caret_array /* OUT */) const - { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); } + { return (this+ligCaretList).get_lig_carets (font, + direction, glyph_id, get_var_store(), + start_offset, caret_count, caret_array); } - inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002u && markGlyphSetsDef[0] != 0; } + inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002u && markGlyphSetsDef != 0; } inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const - { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); } + { return version.to_int () >= 0x00010002u && (this+markGlyphSetsDef).covers (set_index, glyph_id); } + + inline bool has_var_store (void) const { return version.to_int () >= 0x00010003u && varStore != 0; } + inline const VariationStore &get_var_store (void) const + { return version.to_int () >= 0x00010003u ? this+varStore : Null(VariationStore); } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -382,10 +393,10 @@ struct GDEF attachList.sanitize (c, this) && ligCaretList.sanitize (c, this) && markAttachClassDef.sanitize (c, this) && - (version.to_int () < 0x00010002u || markGlyphSetsDef[0].sanitize (c, this))); + (version.to_int () < 0x00010002u || markGlyphSetsDef.sanitize (c, this)) && + (version.to_int () < 0x00010003u || varStore.sanitize (c, this))); } - /* glyph_props is a 16-bit integer where the lower 8-bit have bits representing * glyph class and other bits, and high 8-bit gthe mark attachment type (if any). * Not to be confused with lookup_props which is very similar. */ @@ -410,7 +421,7 @@ struct GDEF protected: FixedVersion<>version; /* Version of the GDEF table--currently - * 0x00010002u */ + * 0x00010003u */ OffsetTo glyphClassDef; /* Offset to class definition table * for glyph type--from beginning of @@ -428,12 +439,17 @@ struct GDEF * mark attachment type--from beginning * of GDEF header (may be Null) */ OffsetTo - markGlyphSetsDef[VAR]; /* Offset to the table of mark set + markGlyphSetsDef; /* Offset to the table of mark set * definitions--from beginning of GDEF * header (may be NULL). Introduced - * in version 00010002. */ + * in version 0x00010002. */ + OffsetTo + varStore; /* Offset to the table of Item Variation + * Store--from beginning of GDEF + * header (may be NULL). Introduced + * in version 0x00010003. */ public: - DEFINE_SIZE_ARRAY (12, markGlyphSetsDef); + DEFINE_SIZE_MIN (12); }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gpos-table.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gpos-table.hh index c065e179a23..d40d4614fa7 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gpos-table.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gpos-table.hh @@ -103,18 +103,17 @@ struct ValueFormat : USHORT inline unsigned int get_size (void) const { return get_len () * Value::static_size; } - void apply_value (hb_font_t *font, - hb_direction_t direction, + void apply_value (hb_apply_context_t *c, const void *base, const Value *values, hb_glyph_position_t &glyph_pos) const { - unsigned int x_ppem, y_ppem; unsigned int format = *this; - hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (direction); - if (!format) return; + hb_font_t *font = c->font; + hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (c->direction); + if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short (values++)); if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short (values++)); if (format & xAdvance) { @@ -129,27 +128,29 @@ struct ValueFormat : USHORT if (!has_device ()) return; - x_ppem = font->x_ppem; - y_ppem = font->y_ppem; + bool use_x_device = font->x_ppem || font->num_coords; + bool use_y_device = font->y_ppem || font->num_coords; - if (!x_ppem && !y_ppem) return; + if (!use_x_device && !use_y_device) return; + + const VariationStore &store = c->var_store; /* pixel -> fractional pixel */ if (format & xPlaDevice) { - if (x_ppem) glyph_pos.x_offset += (base + get_device (values)).get_x_delta (font); + if (use_x_device) glyph_pos.x_offset += (base + get_device (values)).get_x_delta (font, store); values++; } if (format & yPlaDevice) { - if (y_ppem) glyph_pos.y_offset += (base + get_device (values)).get_y_delta (font); + if (use_y_device) glyph_pos.y_offset += (base + get_device (values)).get_y_delta (font, store); values++; } if (format & xAdvDevice) { - if (horizontal && x_ppem) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font); + if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font, store); values++; } if (format & yAdvDevice) { /* y_advance values grow downward but font-space grows upward, hence negation */ - if (!horizontal && y_ppem) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font); + if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font, store); values++; } } @@ -231,11 +232,12 @@ struct ValueFormat : USHORT struct AnchorFormat1 { - inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED, + inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED, hb_position_t *x, hb_position_t *y) const { - *x = font->em_scale_x (xCoordinate); - *y = font->em_scale_y (yCoordinate); + hb_font_t *font = c->font; + *x = font->em_scale_x (xCoordinate); + *y = font->em_scale_y (yCoordinate); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -254,18 +256,19 @@ struct AnchorFormat1 struct AnchorFormat2 { - inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id, + inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id, hb_position_t *x, hb_position_t *y) const { - unsigned int x_ppem = font->x_ppem; - unsigned int y_ppem = font->y_ppem; - hb_position_t cx, cy; - hb_bool_t ret; + hb_font_t *font = c->font; + unsigned int x_ppem = font->x_ppem; + unsigned int y_ppem = font->y_ppem; + hb_position_t cx, cy; + hb_bool_t ret; - ret = (x_ppem || y_ppem) && - font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy); - *x = ret && x_ppem ? cx : font->em_scale_x (xCoordinate); - *y = ret && y_ppem ? cy : font->em_scale_y (yCoordinate); + ret = (x_ppem || y_ppem) && + font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy); + *x = ret && x_ppem ? cx : font->em_scale_x (xCoordinate); + *y = ret && y_ppem ? cy : font->em_scale_y (yCoordinate); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -285,16 +288,17 @@ struct AnchorFormat2 struct AnchorFormat3 { - inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED, + inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED, hb_position_t *x, hb_position_t *y) const { - *x = font->em_scale_x (xCoordinate); - *y = font->em_scale_y (yCoordinate); + hb_font_t *font = c->font; + *x = font->em_scale_x (xCoordinate); + *y = font->em_scale_y (yCoordinate); - if (font->x_ppem) - *x += (this+xDeviceTable).get_x_delta (font); - if (font->y_ppem) - *y += (this+yDeviceTable).get_x_delta (font); + if (font->x_ppem || font->num_coords) + *x += (this+xDeviceTable).get_x_delta (font, c->var_store); + if (font->y_ppem || font->num_coords) + *y += (this+yDeviceTable).get_y_delta (font, c->var_store); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -321,14 +325,14 @@ struct AnchorFormat3 struct Anchor { - inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id, + inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id, hb_position_t *x, hb_position_t *y) const { *x = *y = 0; switch (u.format) { - case 1: u.format1.get_anchor (font, glyph_id, x, y); return; - case 2: u.format2.get_anchor (font, glyph_id, x, y); return; - case 3: u.format3.get_anchor (font, glyph_id, x, y); return; + case 1: u.format1.get_anchor (c, glyph_id, x, y); return; + case 2: u.format2.get_anchor (c, glyph_id, x, y); return; + case 3: u.format3.get_anchor (c, glyph_id, x, y); return; default: return; } } @@ -370,7 +374,7 @@ struct AnchorMatrix { TRACE_SANITIZE (this); if (!c->check_struct (this)) return_trace (false); - if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return_trace (false); + if (unlikely (_hb_unsigned_int_mul_overflows (rows, cols))) return_trace (false); unsigned int count = rows * cols; if (!c->check_array (matrixZ, matrixZ[0].static_size, count)) return_trace (false); for (unsigned int i = 0; i < count; i++) @@ -428,8 +432,8 @@ struct MarkArray : ArrayOf /* Array of MarkRecords--in Coverage ord hb_position_t mark_x, mark_y, base_x, base_y; - mark_anchor.get_anchor (c->font, buffer->cur().codepoint, &mark_x, &mark_y); - glyph_anchor.get_anchor (c->font, buffer->info[glyph_pos].codepoint, &base_x, &base_y); + mark_anchor.get_anchor (c, buffer->cur().codepoint, &mark_x, &mark_y); + glyph_anchor.get_anchor (c, buffer->info[glyph_pos].codepoint, &base_x, &base_y); hb_glyph_position_t &o = buffer->cur_pos(); o.x_offset = base_x - mark_x; @@ -472,8 +476,7 @@ struct SinglePosFormat1 unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint); if (likely (index == NOT_COVERED)) return_trace (false); - valueFormat.apply_value (c->font, c->direction, this, - values, buffer->cur_pos()); + valueFormat.apply_value (c, this, values, buffer->cur_pos()); buffer->idx++; return_trace (true); @@ -523,7 +526,7 @@ struct SinglePosFormat2 if (likely (index >= valueCount)) return_trace (false); - valueFormat.apply_value (c->font, c->direction, this, + valueFormat.apply_value (c, this, &values[index * valueFormat.get_len ()], buffer->cur_pos()); @@ -640,10 +643,8 @@ struct PairSet min = mid + 1; else { - valueFormats[0].apply_value (c->font, c->direction, this, - &record->values[0], buffer->cur_pos()); - valueFormats[1].apply_value (c->font, c->direction, this, - &record->values[len1], buffer->pos[pos]); + valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos()); + valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]); if (len2) pos++; buffer->idx = pos; @@ -689,7 +690,7 @@ struct PairPosFormat1 (this+coverage).add_coverage (c->input); unsigned int count = pairSet.len; for (unsigned int i = 0; i < count; i++) - (this+pairSet[i]).collect_glyphs (c, &valueFormat1); + (this+pairSet[i]).collect_glyphs (c, valueFormat); } inline const Coverage &get_coverage (void) const @@ -708,7 +709,7 @@ struct PairPosFormat1 skippy_iter.reset (buffer->idx, 1); if (!skippy_iter.next ()) return_trace (false); - return_trace ((this+pairSet[index]).apply (c, &valueFormat1, skippy_iter.idx)); + return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx)); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -717,11 +718,11 @@ struct PairPosFormat1 if (!c->check_struct (this)) return_trace (false); - unsigned int len1 = valueFormat1.get_len (); - unsigned int len2 = valueFormat2.get_len (); + unsigned int len1 = valueFormat[0].get_len (); + unsigned int len2 = valueFormat[1].get_len (); PairSet::sanitize_closure_t closure = { this, - &valueFormat1, + valueFormat, len1, 1 + len1 + len2 }; @@ -734,10 +735,10 @@ struct PairPosFormat1 OffsetTo coverage; /* Offset to Coverage table--from * beginning of subtable */ - ValueFormat valueFormat1; /* Defines the types of data in + ValueFormat valueFormat[2]; /* [0] Defines the types of data in * ValueRecord1--for the first glyph * in the pair--may be zero (0) */ - ValueFormat valueFormat2; /* Defines the types of data in + /* [1] Defines the types of data in * ValueRecord2--for the second glyph * in the pair--may be zero (0) */ OffsetArrayOf @@ -790,10 +791,8 @@ struct PairPosFormat2 if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return_trace (false); const Value *v = &values[record_len * (klass1 * class2Count + klass2)]; - valueFormat1.apply_value (c->font, c->direction, this, - v, buffer->cur_pos()); - valueFormat2.apply_value (c->font, c->direction, this, - v + len1, buffer->pos[skippy_iter.idx]); + valueFormat1.apply_value (c, this, v, buffer->cur_pos()); + valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]); buffer->idx = skippy_iter.idx; if (len2) @@ -931,8 +930,8 @@ struct CursivePosFormat1 unsigned int j = skippy_iter.idx; hb_position_t entry_x, entry_y, exit_x, exit_y; - (this+this_record.exitAnchor).get_anchor (c->font, buffer->info[i].codepoint, &exit_x, &exit_y); - (this+next_record.entryAnchor).get_anchor (c->font, buffer->info[j].codepoint, &entry_x, &entry_y); + (this+this_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y); + (this+next_record.entryAnchor).get_anchor (c, buffer->info[j].codepoint, &entry_x, &entry_y); hb_glyph_position_t *pos = buffer->pos; @@ -1519,8 +1518,6 @@ struct GPOS : GSUBGPOS const OffsetTo &list = CastR > (lookupList); return_trace (list.sanitize (c, this)); } - public: - DEFINE_SIZE_STATIC (10); }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsub-table.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsub-table.hh index 44dcd120e3b..9a7481413de 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsub-table.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsub-table.hh @@ -41,7 +41,10 @@ struct SingleSubstFormat1 { TRACE_CLOSURE (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + /* TODO Switch to range-based API to work around malicious fonts. + * https://github.com/behdad/harfbuzz/issues/363 */ hb_codepoint_t glyph_id = iter.get_glyph (); if (c->glyphs->has (glyph_id)) c->glyphs->add ((glyph_id + deltaGlyphID) & 0xFFFFu); @@ -52,7 +55,10 @@ struct SingleSubstFormat1 { TRACE_COLLECT_GLYPHS (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + /* TODO Switch to range-based API to work around malicious fonts. + * https://github.com/behdad/harfbuzz/issues/363 */ hb_codepoint_t glyph_id = iter.get_glyph (); c->input->add (glyph_id); c->output->add ((glyph_id + deltaGlyphID) & 0xFFFFu); @@ -120,7 +126,11 @@ struct SingleSubstFormat2 { TRACE_CLOSURE (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + unsigned int count = substitute.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) c->glyphs->add (substitute[iter.get_coverage ()]); } @@ -130,7 +140,11 @@ struct SingleSubstFormat2 { TRACE_COLLECT_GLYPHS (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + unsigned int count = substitute.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ c->input->add (iter.get_glyph ()); c->output->add (substitute[iter.get_coverage ()]); } @@ -321,7 +335,11 @@ struct MultipleSubstFormat1 { TRACE_CLOSURE (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + unsigned int count = sequence.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) (this+sequence[iter.get_coverage ()]).closure (c); } @@ -439,7 +457,11 @@ struct AlternateSubstFormat1 { TRACE_CLOSURE (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + unsigned int count = alternateSet.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) { const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()]; unsigned int count = alt_set.len; @@ -453,7 +475,11 @@ struct AlternateSubstFormat1 { TRACE_COLLECT_GLYPHS (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + unsigned int count = alternateSet.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ c->input->add (iter.get_glyph ()); const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()]; unsigned int count = alt_set.len; @@ -762,7 +788,11 @@ struct LigatureSubstFormat1 { TRACE_CLOSURE (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + unsigned int count = ligatureSet.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) (this+ligatureSet[iter.get_coverage ()]).closure (c); } @@ -772,7 +802,11 @@ struct LigatureSubstFormat1 { TRACE_COLLECT_GLYPHS (this); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + unsigned int count = ligatureSet.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ c->input->add (iter.get_glyph ()); (this+ligatureSet[iter.get_coverage ()]).collect_glyphs (c); } @@ -923,7 +957,11 @@ struct ReverseChainSingleSubstFormat1 const ArrayOf &substitute = StructAfter > (lookahead); Coverage::Iter iter; - for (iter.init (this+coverage); iter.more (); iter.next ()) { + count = substitute.len; + for (iter.init (this+coverage); iter.more (); iter.next ()) + { + if (unlikely (iter.get_coverage () >= count)) + break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */ if (c->glyphs->has (iter.get_glyph ())) c->glyphs->add (substitute[iter.get_coverage ()]); } @@ -1273,8 +1311,6 @@ struct GSUB : GSUBGPOS const OffsetTo &list = CastR > (lookupList); return_trace (list.sanitize (c, this)); } - public: - DEFINE_SIZE_STATIC (10); }; @@ -1285,28 +1321,10 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef; unsigned int count = buffer->len; - hb_glyph_info_t *info = buffer->info; for (unsigned int i = 0; i < count; i++) { - unsigned int props = gdef.get_glyph_props (info[i].codepoint); - if (!props) - { - /* Never mark default-ignorables as marks. - * They won't get in the way of lookups anyway, - * but having them as mark will cause them to be skipped - * over if the lookup-flag says so, but at least for the - * Mongolian variation selectors, looks like Uniscribe - * marks them as non-mark. Some Mongolian fonts without - * GDEF rely on this. Another notable character that - * this applies to is COMBINING GRAPHEME JOINER. */ - props = (_hb_glyph_info_get_general_category (&info[i]) != - HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK || - _hb_glyph_info_is_default_ignorable (&info[i])) ? - HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : - HB_OT_LAYOUT_GLYPH_PROPS_MARK; - } - _hb_glyph_info_set_glyph_props (&info[i], props); - _hb_glyph_info_clear_lig_props (&info[i]); + _hb_glyph_info_set_glyph_props (&buffer->info[i], gdef.get_glyph_props (buffer->info[i].codepoint)); + _hb_glyph_info_clear_lig_props (&buffer->info[i]); buffer->info[i].syllable() = 0; } } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh index 73cfb77fe2a..d2141b226a3 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gsubgpos-private.hh @@ -469,6 +469,7 @@ struct hb_apply_context_t : unsigned int lookup_props; const GDEF &gdef; bool has_glyph_classes; + const VariationStore &var_store; skipping_iterator_t iter_input, iter_context; unsigned int lookup_index; unsigned int debug_depth; @@ -487,6 +488,7 @@ struct hb_apply_context_t : lookup_props (0), gdef (*hb_ot_layout_from_face (face)->gdef), has_glyph_classes (gdef.has_glyph_classes ()), + var_store (gdef.get_var_store ()), iter_input (), iter_context (), lookup_index ((unsigned int) -1), @@ -999,8 +1001,12 @@ static inline bool apply_lookup (hb_apply_context_t *c, end = int (end) + delta; if (end <= match_positions[idx]) { + /* End might end up being smaller than match_positions[idx] if the recursed + * lookup ended up removing many items, more than we have had matched. + * Just never rewind end back and get out of here. + * https://bugs.chromium.org/p/chromium/issues/detail?id=659496 */ + end = match_positions[idx]; /* There can't be any further changes. */ - assert (end == match_positions[idx]); break; } @@ -2269,6 +2275,24 @@ struct GSUBGPOS inline const Lookup& get_lookup (unsigned int i) const { return (this+lookupList)[i]; } + inline bool find_variations_index (const int *coords, unsigned int num_coords, + unsigned int *index) const + { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations)) + .find_index (coords, num_coords, index); } + inline const Feature& get_feature_variation (unsigned int feature_index, + unsigned int variations_index) const + { + if (FeatureVariations::NOT_FOUND_INDEX != variations_index && + version.to_int () >= 0x00010001u) + { + const Feature *feature = (this+featureVars).find_substitute (variations_index, + feature_index); + if (feature) + return *feature; + } + return get_feature (feature_index); + } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -2276,7 +2300,8 @@ struct GSUBGPOS likely (version.major == 1) && scriptList.sanitize (c, this) && featureList.sanitize (c, this) && - lookupList.sanitize (c, this)); + lookupList.sanitize (c, this) && + (version.to_int () < 0x00010001u || featureVars.sanitize (c, this))); } protected: @@ -2288,8 +2313,13 @@ struct GSUBGPOS featureList; /* FeatureList table */ OffsetTo lookupList; /* LookupList table */ + OffsetTo + featureVars; /* Offset to Feature Variations + table--from beginning of table + * (may be NULL). Introduced + * in version 0x00010001. */ public: - DEFINE_SIZE_STATIC (10); + DEFINE_SIZE_MIN (10); }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-private.hh index 2081949fe62..c7b43fe3d5b 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-private.hh @@ -124,6 +124,7 @@ namespace OT { struct GDEF; struct GSUB; struct GPOS; + struct MATH; } struct hb_ot_layout_lookup_accelerator_t @@ -152,10 +153,12 @@ struct hb_ot_layout_t hb_blob_t *gdef_blob; hb_blob_t *gsub_blob; hb_blob_t *gpos_blob; + hb_blob_t *math_blob; const struct OT::GDEF *gdef; const struct OT::GSUB *gsub; const struct OT::GPOS *gpos; + const struct OT::MATH *math; unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.cc index 74f61136780..1ee59f49747 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.cc @@ -60,6 +60,10 @@ _hb_ot_layout_create (hb_face_t *face) layout->gpos_blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_GPOS)); layout->gpos = OT::Sanitizer::lock_instance (layout->gpos_blob); + /* The MATH table is rarely used, so only try and load it in _get_math. */ + layout->math_blob = NULL; + layout->math = NULL; + { /* * The ugly business of blacklisting individual fonts' tables happen here! @@ -120,6 +124,14 @@ _hb_ot_layout_create (hb_face_t *face) /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ || (188 == gdef_len && 3426 == gpos_len && 264 == gsub_len) + /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ + || (1046 == gdef_len && 17112 == gpos_len && 71788 == gsub_len) + /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ + || (1058 == gdef_len && 17514 == gpos_len && 71794 == gsub_len) + /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ + || (1330 == gdef_len && 57938 == gpos_len && 109904 == gsub_len) + /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ + || (1330 == gdef_len && 58972 == gpos_len && 109904 == gsub_len) ) { /* Many versions of Tahoma have bad GDEF tables that incorrectly classify some spacing marks @@ -169,6 +181,7 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout) hb_blob_destroy (layout->gdef_blob); hb_blob_destroy (layout->gsub_blob); hb_blob_destroy (layout->gpos_blob); + hb_blob_destroy (layout->math_blob); free (layout); } @@ -192,7 +205,6 @@ _get_gpos (hb_face_t *face) return *hb_ot_layout_from_face (face)->gpos; } - /* * GDEF */ @@ -544,10 +556,13 @@ hb_ot_layout_feature_get_lookups (hb_face_t *face, unsigned int *lookup_count /* IN/OUT */, unsigned int *lookup_indexes /* OUT */) { - const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - const OT::Feature &f = g.get_feature (feature_index); - - return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes); + return hb_ot_layout_feature_with_variations_get_lookups (face, + table_tag, + feature_index, + HB_OT_LAYOUT_NO_VARIATIONS_INDEX, + start_offset, + lookup_count, + lookup_indexes); } /** @@ -798,6 +813,38 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, } +/* Variations support */ + +hb_bool_t +hb_ot_layout_table_find_feature_variations (hb_face_t *face, + hb_tag_t table_tag, + const int *coords, + unsigned int num_coords, + unsigned int *variations_index /* out */) +{ + const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); + + return g.find_variations_index (coords, num_coords, variations_index); +} + +unsigned int +hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, + hb_tag_t table_tag, + unsigned int feature_index, + unsigned int variations_index, + unsigned int start_offset, + unsigned int *lookup_count /* IN/OUT */, + unsigned int *lookup_indexes /* OUT */) +{ + ASSERT_STATIC (OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX); + const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); + + const OT::Feature &f = g.get_feature_variation (feature_index, variations_index); + + return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes); +} + + /* * OT::GSUB */ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.h b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.h index 2c455a954cd..5ee95105181 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout.h @@ -95,6 +95,7 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font, #define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu #define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu +#define HB_OT_LAYOUT_NO_VARIATIONS_INDEX 0xFFFFFFFFu HB_EXTERN unsigned int hb_ot_layout_table_get_script_tags (hb_face_t *face, @@ -236,6 +237,24 @@ Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face, void *user_data); #endif +/* Variations support */ + +HB_EXTERN hb_bool_t +hb_ot_layout_table_find_feature_variations (hb_face_t *face, + hb_tag_t table_tag, + const int *coords, + unsigned int num_coords, + unsigned int *variations_index /* out */); + +HB_EXTERN unsigned int +hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, + hb_tag_t table_tag, + unsigned int feature_index, + unsigned int variations_index, + unsigned int start_offset, + unsigned int *lookup_count /* IN/OUT */, + unsigned int *lookup_indexes /* OUT */); + /* * GSUB diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map-private.hh index 6d9cf96331d..dd1cad2f4f4 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map-private.hh @@ -139,12 +139,6 @@ struct hb_ot_map_t private: - HB_INTERNAL void add_lookups (hb_face_t *face, - unsigned int table_index, - unsigned int feature_index, - hb_mask_t mask, - bool auto_zwj); - hb_mask_t global_mask; hb_prealloced_array_t features; @@ -182,7 +176,9 @@ struct hb_ot_map_builder_t inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func) { add_pause (1, pause_func); } - HB_INTERNAL void compile (struct hb_ot_map_t &m); + HB_INTERNAL void compile (hb_ot_map_t &m, + const int *coords, + unsigned int num_coords); inline void finish (void) { feature_infos.finish (); @@ -194,6 +190,14 @@ struct hb_ot_map_builder_t private: + HB_INTERNAL void add_lookups (hb_ot_map_t &m, + hb_face_t *face, + unsigned int table_index, + unsigned int feature_index, + unsigned int variations_index, + hb_mask_t mask, + bool auto_zwj); + struct feature_info_t { hb_tag_t tag; unsigned int seq; /* sequence#, used for stable sorting only */ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.cc index 0f9f60875cc..6442e2590d6 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.cc @@ -31,44 +31,13 @@ #include "hb-ot-layout-private.hh" -void -hb_ot_map_t::add_lookups (hb_face_t *face, - unsigned int table_index, - unsigned int feature_index, - hb_mask_t mask, - bool auto_zwj) +void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const { - unsigned int lookup_indices[32]; - unsigned int offset, len; - unsigned int table_lookup_count; - - table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[table_index]); - - offset = 0; - do { - len = ARRAY_LENGTH (lookup_indices); - hb_ot_layout_feature_get_lookups (face, - table_tags[table_index], - feature_index, - offset, &len, - lookup_indices); - - for (unsigned int i = 0; i < len; i++) - { - if (lookup_indices[i] >= table_lookup_count) - continue; - hb_ot_map_t::lookup_map_t *lookup = lookups[table_index].push (); - if (unlikely (!lookup)) - return; - lookup->mask = mask; - lookup->index = lookup_indices[i]; - lookup->auto_zwj = auto_zwj; - } - - offset += len; - } while (len == ARRAY_LENGTH (lookup_indices)); + for (unsigned int i = 0; i < lookups[table_index].len; i++) + hb_set_add (lookups_out, lookups[table_index][i].index); } + hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_, const hb_segment_properties_t *props_) { @@ -109,13 +78,48 @@ void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value, info->stage[1] = current_stage[1]; } - -void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const +void +hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m, + hb_face_t *face, + unsigned int table_index, + unsigned int feature_index, + unsigned int variations_index, + hb_mask_t mask, + bool auto_zwj) { - for (unsigned int i = 0; i < lookups[table_index].len; i++) - hb_set_add (lookups_out, lookups[table_index][i].index); + unsigned int lookup_indices[32]; + unsigned int offset, len; + unsigned int table_lookup_count; + + table_lookup_count = hb_ot_layout_table_get_lookup_count (face, table_tags[table_index]); + + offset = 0; + do { + len = ARRAY_LENGTH (lookup_indices); + hb_ot_layout_feature_with_variations_get_lookups (face, + table_tags[table_index], + feature_index, + variations_index, + offset, &len, + lookup_indices); + + for (unsigned int i = 0; i < len; i++) + { + if (lookup_indices[i] >= table_lookup_count) + continue; + hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push (); + if (unlikely (!lookup)) + return; + lookup->mask = mask; + lookup->index = lookup_indices[i]; + lookup->auto_zwj = auto_zwj; + } + + offset += len; + } while (len == ARRAY_LENGTH (lookup_indices)); } + void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func) { stage_info_t *s = stages[table_index].push (); @@ -128,7 +132,9 @@ void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::paus } void -hb_ot_map_builder_t::compile (hb_ot_map_t &m) +hb_ot_map_builder_t::compile (hb_ot_map_t &m, + const int *coords, + unsigned int num_coords) { m.global_mask = 1; @@ -193,7 +199,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m) /* Uses the global bit */ bits_needed = 0; else - bits_needed = _hb_bit_storage (info->max_value); + /* Limit to 8 bits per feature. */ + bits_needed = MIN(8u, _hb_bit_storage (info->max_value)); if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t)) continue; /* Feature disabled, or not enough bits. */ @@ -243,11 +250,11 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m) map->mask = 1; } else { map->shift = next_bit; - map->mask = (1 << (next_bit + bits_needed)) - (1 << next_bit); + map->mask = (1u << (next_bit + bits_needed)) - (1u << next_bit); next_bit += bits_needed; m.global_mask |= (info->default_value << map->shift) & map->mask; } - map->_1_mask = (1 << map->shift) & map->mask; + map->_1_mask = (1u << map->shift) & map->mask; map->needs_fallback = !found; } @@ -261,23 +268,32 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m) { /* Collect lookup indices for features */ + unsigned int variations_index; + hb_ot_layout_table_find_feature_variations (face, + table_tags[table_index], + coords, + num_coords, + &variations_index); + unsigned int stage_index = 0; unsigned int last_num_lookups = 0; for (unsigned stage = 0; stage < current_stage[table_index]; stage++) { if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX && required_feature_stage[table_index] == stage) - m.add_lookups (face, table_index, - required_feature_index[table_index], - 1 /* mask */, - true /* auto_zwj */); + add_lookups (m, face, table_index, + required_feature_index[table_index], + variations_index, + 1 /* mask */, + true /* auto_zwj */); for (unsigned i = 0; i < m.features.len; i++) if (m.features[i].stage[table_index] == stage) - m.add_lookups (face, table_index, - m.features[i].index[table_index], - m.features[i].mask, - m.features[i].auto_zwj); + add_lookups (m, face, table_index, + m.features[i].index[table_index], + variations_index, + m.features[i].mask, + m.features[i].auto_zwj); /* Sort lookups and merge duplicates */ if (last_num_lookups < m.lookups[table_index].len) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-math.h b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-math.h new file mode 100644 index 00000000000..3cbdb8b3e5d --- /dev/null +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-math.h @@ -0,0 +1,209 @@ +/* + * Copyright © 2016 Igalia S.L. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Igalia Author(s): Frédéric Wang + */ + +#ifndef HB_OT_H_IN +#error "Include instead." +#endif + +#ifndef HB_OT_MATH_H +#define HB_OT_MATH_H + +#include "hb.h" + +HB_BEGIN_DECLS + + +/* + * MATH + */ + +#define HB_OT_TAG_MATH HB_TAG('M','A','T','H') + +/* Use with hb_buffer_set_script() for math shaping. */ +#define HB_OT_MATH_SCRIPT HB_TAG('m','a','t','h') + +/* Types */ + +/** + * hb_ot_math_constant_t: + * + * Since: 1.3.3 + */ +typedef enum { + HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN = 0, + HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN = 1, + HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT = 2, + HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT = 3, + HB_OT_MATH_CONSTANT_MATH_LEADING = 4, + HB_OT_MATH_CONSTANT_AXIS_HEIGHT = 5, + HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT = 6, + HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT = 7, + HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN = 8, + HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX = 9, + HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN = 10, + HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP = 11, + HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED = 12, + HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN = 13, + HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX = 14, + HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN = 15, + HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT = 16, + HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT = 17, + HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN = 18, + HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN = 19, + HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN = 20, + HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN = 21, + HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP = 22, + HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP = 23, + HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN = 24, + HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN = 25, + HB_OT_MATH_CONSTANT_STACK_GAP_MIN = 26, + HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN = 27, + HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP = 28, + HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN = 29, + HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN = 30, + HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN = 31, + HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP = 32, + HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP = 33, + HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN = 34, + HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN = 35, + HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN = 36, + HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN = 37, + HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS = 38, + HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN = 39, + HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN = 40, + HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP = 41, + HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP = 42, + HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP = 43, + HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS = 44, + HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER = 45, + HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP = 46, + HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS = 47, + HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER = 48, + HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP = 49, + HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP = 50, + HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS = 51, + HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER = 52, + HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE = 53, + HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE = 54, + HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT = 55 +} hb_ot_math_constant_t; + +/** + * hb_ot_math_kern_t: + * + * Since: 1.3.3 + */ +typedef enum { + HB_OT_MATH_KERN_TOP_RIGHT = 0, + HB_OT_MATH_KERN_TOP_LEFT = 1, + HB_OT_MATH_KERN_BOTTOM_RIGHT = 2, + HB_OT_MATH_KERN_BOTTOM_LEFT = 3 +} hb_ot_math_kern_t; + +/** + * hb_ot_math_glyph_variant_t: + * + * Since: 1.3.3 + */ +typedef struct hb_ot_math_glyph_variant_t { + hb_codepoint_t glyph; + hb_position_t advance; +} hb_ot_math_glyph_variant_t; + +/** + * hb_ot_math_glyph_part_flags_t: + * + * Since: 1.3.3 + */ +typedef enum { /*< flags >*/ + HB_MATH_GLYPH_PART_FLAG_EXTENDER = 0x00000001u /* Extender glyph */ +} hb_ot_math_glyph_part_flags_t; + +/** + * hb_ot_math_glyph_part_t: + * + * Since: 1.3.3 + */ +typedef struct hb_ot_math_glyph_part_t { + hb_codepoint_t glyph; + hb_position_t start_connector_length; + hb_position_t end_connector_length; + hb_position_t full_advance; + hb_ot_math_glyph_part_flags_t flags; +} hb_ot_math_glyph_part_t; + +/* Methods */ + +HB_EXTERN hb_bool_t +hb_ot_math_has_data (hb_face_t *face); + +HB_EXTERN hb_position_t +hb_ot_math_get_constant (hb_font_t *font, + hb_ot_math_constant_t constant); + +HB_EXTERN hb_position_t +hb_ot_math_get_glyph_italics_correction (hb_font_t *font, + hb_codepoint_t glyph); + +HB_EXTERN hb_position_t +hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font, + hb_codepoint_t glyph); + +HB_EXTERN hb_bool_t +hb_ot_math_is_glyph_extended_shape (hb_face_t *face, + hb_codepoint_t glyph); + +HB_EXTERN hb_position_t +hb_ot_math_get_glyph_kerning (hb_font_t *font, + hb_codepoint_t glyph, + hb_ot_math_kern_t kern, + hb_position_t correction_height); + +HB_EXTERN unsigned int +hb_ot_math_get_glyph_variants (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + unsigned int start_offset, + unsigned int *variants_count, /* IN/OUT */ + hb_ot_math_glyph_variant_t *variants /* OUT */); + +HB_EXTERN hb_position_t +hb_ot_math_get_min_connector_overlap (hb_font_t *font, + hb_direction_t direction); + +HB_EXTERN unsigned int +hb_ot_math_get_glyph_assembly (hb_font_t *font, + hb_codepoint_t glyph, + hb_direction_t direction, + unsigned int start_offset, + unsigned int *parts_count, /* IN/OUT */ + hb_ot_math_glyph_part_t *parts, /* OUT */ + hb_position_t *italics_correction /* OUT */); + + +HB_END_DECLS + +#endif /* HB_OT_MATH_H */ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-arabic.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-arabic.cc index 80accdedd75..223a54af2b7 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-arabic.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-arabic.cc @@ -618,6 +618,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic = NULL, /* decompose */ NULL, /* compose */ setup_masks_arabic, + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-default.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-default.cc index be60e56feb8..42830ab6185 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-default.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-default.cc @@ -40,6 +40,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default = NULL, /* decompose */ NULL, /* compose */ NULL, /* setup_masks */ + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hangul.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hangul.cc index aa907390a84..82b038db0b1 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hangul.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hangul.cc @@ -419,6 +419,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul = NULL, /* decompose */ NULL, /* compose */ setup_masks_hangul, + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, false, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hebrew.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hebrew.cc index e6fde14dca6..60721d543a6 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hebrew.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hebrew.cc @@ -154,6 +154,18 @@ compose_hebrew (const hb_ot_shape_normalize_context_t *c, return found; } +static bool +disable_otl_hebrew (const hb_ot_shape_plan_t *plan) +{ + /* For Hebrew shaper, use fallback if GPOS does not have 'hebr' + * script. This matches Uniscribe better, and makes fonts like + * Arial that have GSUB/GPOS/GDEF but no data for Hebrew work. + * See: + * https://github.com/behdad/harfbuzz/issues/347#issuecomment-267838368 + */ + return plan->map.chosen_script[1] != HB_TAG ('h','e','b','r'); +} + const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew = { @@ -168,6 +180,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew = NULL, /* decompose */ compose_hebrew, NULL, /* setup_masks */ + disable_otl_hebrew, HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic-machine.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic-machine.hh index d3f0beea43a..18cf9d11a4d 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic-machine.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic-machine.hh @@ -34,1316 +34,1316 @@ #line 36 "hb-ot-shape-complex-indic-machine.hh" static const unsigned char _indic_syllable_machine_trans_keys[] = { - 8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, - 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, - 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, - 4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, - 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u, - 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, - 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, - 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, - 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, - 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, - 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, - 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, - 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, - 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, - 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, - 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, - 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, - 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, - 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 5u, 8u, 4u, 14u, 4u, 14u, 5u, 8u, - 5u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, - 5u, 7u, 7u, 7u, 8u, 8u, 1u, 16u, 8u, 13u, 4u, 8u, 6u, 6u, 16u, 16u, - 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, - 16u, 16u, 8u, 8u, 1u, 18u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, - 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, - 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, - 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, - 3u, 10u, 5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, - 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, - 5u, 14u, 3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, - 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, - 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, - 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, - 3u, 17u, 3u, 17u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, - 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, - 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, - 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, - 5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, - 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, - 3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, - 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, - 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, - 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, - 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, - 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, - 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u, - 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, - 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, - 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, - 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 3u, 17u, 4u, 14u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, - 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, - 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, - 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u, - 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, - 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, - 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, - 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 1u, 17u, 3u, 17u, - 1u, 17u, 4u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, - 5u, 10u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 3u, 17u, 3u, 17u, 1u, 16u, - 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, - 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, - 3u, 13u, 1u, 16u, 3u, 10u, 5u, 10u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, + 8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, + 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, + 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, + 4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, + 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u, + 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, + 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, + 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, + 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, + 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, + 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, + 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, + 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, + 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 8u, 8u, 1u, 16u, + 8u, 13u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, + 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, + 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, + 16u, 16u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, + 4u, 14u, 4u, 14u, 4u, 14u, 4u, 14u, 5u, 8u, 4u, 14u, 4u, 14u, 5u, 8u, + 5u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, + 5u, 7u, 7u, 7u, 8u, 8u, 1u, 16u, 8u, 13u, 4u, 8u, 6u, 6u, 16u, 16u, + 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, + 16u, 16u, 8u, 8u, 1u, 18u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, + 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, + 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, + 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, + 3u, 10u, 5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, + 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, + 5u, 14u, 3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, + 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, + 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, + 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, + 3u, 17u, 3u, 17u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, + 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, + 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, + 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, + 5u, 10u, 3u, 10u, 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, + 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, + 3u, 14u, 1u, 16u, 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, + 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, + 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, + 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 1u, 16u, + 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, + 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, + 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, + 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, + 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, + 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u, + 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, + 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, + 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, + 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 14u, 3u, 17u, 4u, 14u, + 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, + 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, + 3u, 17u, 3u, 17u, 4u, 17u, 5u, 14u, 5u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, + 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, + 3u, 13u, 3u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, + 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 1u, 16u, + 4u, 14u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, + 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, + 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, + 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 1u, 17u, 3u, 17u, + 1u, 17u, 4u, 14u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, + 5u, 10u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 3u, 17u, 3u, 17u, 1u, 16u, + 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 14u, 4u, 14u, + 5u, 14u, 3u, 14u, 4u, 14u, 5u, 14u, 3u, 13u, 3u, 10u, 5u, 10u, 3u, 10u, + 3u, 13u, 1u, 16u, 3u, 10u, 5u, 10u, 5u, 10u, 9u, 10u, 9u, 9u, 9u, 10u, 9u, 10u, 9u, 9u, 5u, 10u, 0 }; static const char _indic_syllable_machine_key_spans[] = { - 1, 16, 6, 4, 3, 1, 4, 3, - 1, 4, 3, 1, 4, 3, 1, 5, - 1, 1, 5, 1, 1, 5, 1, 1, - 5, 1, 1, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 1, 16, 6, - 4, 3, 1, 4, 3, 1, 4, 3, - 1, 4, 3, 1, 5, 1, 1, 5, - 1, 1, 5, 1, 1, 5, 1, 1, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 1, 16, 6, 4, 3, 1, - 4, 3, 1, 4, 3, 1, 4, 3, - 1, 5, 1, 1, 5, 1, 1, 5, - 1, 1, 5, 1, 1, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 1, 16, - 6, 4, 3, 1, 4, 3, 1, 4, - 3, 1, 4, 3, 1, 5, 1, 1, - 5, 1, 1, 5, 1, 1, 5, 1, - 1, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 4, 11, 11, 4, - 3, 4, 3, 1, 4, 3, 1, 4, - 3, 1, 1, 16, 6, 5, 1, 1, - 5, 1, 1, 5, 1, 1, 5, 1, - 1, 1, 18, 15, 15, 14, 16, 15, - 15, 14, 16, 15, 15, 14, 16, 15, - 15, 14, 16, 15, 15, 14, 10, 10, - 6, 2, 1, 2, 2, 1, 6, 11, - 8, 6, 8, 11, 12, 12, 11, 10, - 12, 11, 10, 12, 11, 10, 12, 11, - 10, 12, 16, 11, 15, 15, 16, 16, - 16, 16, 16, 15, 15, 16, 16, 16, - 16, 16, 15, 15, 16, 16, 16, 16, - 16, 15, 15, 16, 16, 16, 16, 16, - 15, 15, 15, 15, 14, 16, 15, 15, - 14, 16, 15, 15, 14, 16, 15, 15, - 14, 16, 15, 15, 14, 10, 10, 6, - 2, 1, 2, 2, 1, 6, 11, 8, - 6, 8, 11, 12, 12, 11, 10, 12, - 11, 10, 12, 11, 10, 12, 11, 10, - 12, 16, 11, 15, 15, 16, 16, 16, - 16, 16, 15, 15, 16, 16, 16, 16, - 16, 15, 15, 16, 16, 16, 16, 16, - 15, 15, 16, 16, 16, 16, 11, 16, - 15, 15, 14, 16, 15, 15, 14, 16, - 15, 15, 14, 16, 15, 15, 14, 16, - 15, 15, 14, 10, 10, 6, 2, 1, - 2, 2, 1, 6, 11, 8, 6, 8, - 11, 12, 12, 11, 10, 12, 11, 10, - 12, 11, 10, 12, 11, 10, 12, 16, - 11, 15, 15, 16, 16, 16, 16, 16, - 15, 15, 16, 16, 16, 16, 16, 15, - 15, 16, 16, 16, 16, 16, 15, 15, - 16, 16, 16, 16, 16, 11, 15, 11, - 15, 15, 14, 16, 15, 15, 14, 16, - 15, 15, 14, 16, 15, 15, 14, 16, - 15, 15, 14, 10, 10, 6, 2, 1, - 2, 2, 1, 6, 11, 8, 6, 8, - 11, 12, 12, 11, 10, 12, 11, 10, - 12, 11, 10, 12, 11, 10, 12, 16, - 11, 15, 15, 16, 16, 16, 16, 16, - 15, 15, 16, 16, 16, 16, 16, 15, - 15, 16, 16, 16, 16, 16, 15, 15, - 16, 16, 16, 16, 16, 15, 17, 15, - 17, 11, 6, 2, 1, 2, 2, 1, - 6, 16, 15, 15, 14, 15, 15, 16, - 12, 11, 10, 12, 11, 10, 12, 11, - 10, 12, 11, 10, 11, 8, 6, 8, - 11, 16, 8, 6, 6, 2, 1, 2, + 1, 16, 6, 4, 3, 1, 4, 3, + 1, 4, 3, 1, 4, 3, 1, 5, + 1, 1, 5, 1, 1, 5, 1, 1, + 5, 1, 1, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 1, 16, 6, + 4, 3, 1, 4, 3, 1, 4, 3, + 1, 4, 3, 1, 5, 1, 1, 5, + 1, 1, 5, 1, 1, 5, 1, 1, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 1, 16, 6, 4, 3, 1, + 4, 3, 1, 4, 3, 1, 4, 3, + 1, 5, 1, 1, 5, 1, 1, 5, + 1, 1, 5, 1, 1, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 1, 16, + 6, 4, 3, 1, 4, 3, 1, 4, + 3, 1, 4, 3, 1, 5, 1, 1, + 5, 1, 1, 5, 1, 1, 5, 1, + 1, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 4, 11, 11, 4, + 3, 4, 3, 1, 4, 3, 1, 4, + 3, 1, 1, 16, 6, 5, 1, 1, + 5, 1, 1, 5, 1, 1, 5, 1, + 1, 1, 18, 15, 15, 14, 16, 15, + 15, 14, 16, 15, 15, 14, 16, 15, + 15, 14, 16, 15, 15, 14, 10, 10, + 6, 2, 1, 2, 2, 1, 6, 11, + 8, 6, 8, 11, 12, 12, 11, 10, + 12, 11, 10, 12, 11, 10, 12, 11, + 10, 12, 16, 11, 15, 15, 16, 16, + 16, 16, 16, 15, 15, 16, 16, 16, + 16, 16, 15, 15, 16, 16, 16, 16, + 16, 15, 15, 16, 16, 16, 16, 16, + 15, 15, 15, 15, 14, 16, 15, 15, + 14, 16, 15, 15, 14, 16, 15, 15, + 14, 16, 15, 15, 14, 10, 10, 6, + 2, 1, 2, 2, 1, 6, 11, 8, + 6, 8, 11, 12, 12, 11, 10, 12, + 11, 10, 12, 11, 10, 12, 11, 10, + 12, 16, 11, 15, 15, 16, 16, 16, + 16, 16, 15, 15, 16, 16, 16, 16, + 16, 15, 15, 16, 16, 16, 16, 16, + 15, 15, 16, 16, 16, 16, 11, 16, + 15, 15, 14, 16, 15, 15, 14, 16, + 15, 15, 14, 16, 15, 15, 14, 16, + 15, 15, 14, 10, 10, 6, 2, 1, + 2, 2, 1, 6, 11, 8, 6, 8, + 11, 12, 12, 11, 10, 12, 11, 10, + 12, 11, 10, 12, 11, 10, 12, 16, + 11, 15, 15, 16, 16, 16, 16, 16, + 15, 15, 16, 16, 16, 16, 16, 15, + 15, 16, 16, 16, 16, 16, 15, 15, + 16, 16, 16, 16, 16, 11, 15, 11, + 15, 15, 14, 16, 15, 15, 14, 16, + 15, 15, 14, 16, 15, 15, 14, 16, + 15, 15, 14, 10, 10, 6, 2, 1, + 2, 2, 1, 6, 11, 8, 6, 8, + 11, 12, 12, 11, 10, 12, 11, 10, + 12, 11, 10, 12, 11, 10, 12, 16, + 11, 15, 15, 16, 16, 16, 16, 16, + 15, 15, 16, 16, 16, 16, 16, 15, + 15, 16, 16, 16, 16, 16, 15, 15, + 16, 16, 16, 16, 16, 15, 17, 15, + 17, 11, 6, 2, 1, 2, 2, 1, + 6, 16, 15, 15, 14, 15, 15, 16, + 12, 11, 10, 12, 11, 10, 12, 11, + 10, 12, 11, 10, 11, 8, 6, 8, + 11, 16, 8, 6, 6, 2, 1, 2, 2, 1, 6 }; static const short _indic_syllable_machine_index_offsets[] = { - 0, 2, 19, 26, 31, 35, 37, 42, - 46, 48, 53, 57, 59, 64, 68, 70, - 76, 78, 80, 86, 88, 90, 96, 98, - 100, 106, 108, 110, 122, 134, 146, 158, - 170, 182, 194, 206, 218, 230, 232, 249, - 256, 261, 265, 267, 272, 276, 278, 283, - 287, 289, 294, 298, 300, 306, 308, 310, - 316, 318, 320, 326, 328, 330, 336, 338, - 340, 352, 364, 376, 388, 400, 412, 424, - 436, 448, 460, 462, 479, 486, 491, 495, - 497, 502, 506, 508, 513, 517, 519, 524, - 528, 530, 536, 538, 540, 546, 548, 550, - 556, 558, 560, 566, 568, 570, 582, 594, - 606, 618, 630, 642, 654, 666, 678, 680, - 697, 704, 709, 713, 715, 720, 724, 726, - 731, 735, 737, 742, 746, 748, 754, 756, - 758, 764, 766, 768, 774, 776, 778, 784, - 786, 788, 800, 812, 824, 836, 848, 860, - 872, 884, 896, 908, 920, 925, 937, 949, - 954, 958, 963, 967, 969, 974, 978, 980, - 985, 989, 991, 993, 1010, 1017, 1023, 1025, - 1027, 1033, 1035, 1037, 1043, 1045, 1047, 1053, - 1055, 1057, 1059, 1078, 1094, 1110, 1125, 1142, - 1158, 1174, 1189, 1206, 1222, 1238, 1253, 1270, - 1286, 1302, 1317, 1334, 1350, 1366, 1381, 1392, - 1403, 1410, 1413, 1415, 1418, 1421, 1423, 1430, - 1442, 1451, 1458, 1467, 1479, 1492, 1505, 1517, - 1528, 1541, 1553, 1564, 1577, 1589, 1600, 1613, - 1625, 1636, 1649, 1666, 1678, 1694, 1710, 1727, - 1744, 1761, 1778, 1795, 1811, 1827, 1844, 1861, - 1878, 1895, 1912, 1928, 1944, 1961, 1978, 1995, - 2012, 2029, 2045, 2061, 2078, 2095, 2112, 2129, - 2146, 2162, 2178, 2194, 2210, 2225, 2242, 2258, - 2274, 2289, 2306, 2322, 2338, 2353, 2370, 2386, - 2402, 2417, 2434, 2450, 2466, 2481, 2492, 2503, - 2510, 2513, 2515, 2518, 2521, 2523, 2530, 2542, - 2551, 2558, 2567, 2579, 2592, 2605, 2617, 2628, - 2641, 2653, 2664, 2677, 2689, 2700, 2713, 2725, - 2736, 2749, 2766, 2778, 2794, 2810, 2827, 2844, - 2861, 2878, 2895, 2911, 2927, 2944, 2961, 2978, - 2995, 3012, 3028, 3044, 3061, 3078, 3095, 3112, - 3129, 3145, 3161, 3178, 3195, 3212, 3229, 3241, - 3258, 3274, 3290, 3305, 3322, 3338, 3354, 3369, - 3386, 3402, 3418, 3433, 3450, 3466, 3482, 3497, - 3514, 3530, 3546, 3561, 3572, 3583, 3590, 3593, - 3595, 3598, 3601, 3603, 3610, 3622, 3631, 3638, - 3647, 3659, 3672, 3685, 3697, 3708, 3721, 3733, - 3744, 3757, 3769, 3780, 3793, 3805, 3816, 3829, - 3846, 3858, 3874, 3890, 3907, 3924, 3941, 3958, - 3975, 3991, 4007, 4024, 4041, 4058, 4075, 4092, - 4108, 4124, 4141, 4158, 4175, 4192, 4209, 4225, - 4241, 4258, 4275, 4292, 4309, 4326, 4338, 4354, - 4366, 4382, 4398, 4413, 4430, 4446, 4462, 4477, - 4494, 4510, 4526, 4541, 4558, 4574, 4590, 4605, - 4622, 4638, 4654, 4669, 4680, 4691, 4698, 4701, - 4703, 4706, 4709, 4711, 4718, 4730, 4739, 4746, - 4755, 4767, 4780, 4793, 4805, 4816, 4829, 4841, - 4852, 4865, 4877, 4888, 4901, 4913, 4924, 4937, - 4954, 4966, 4982, 4998, 5015, 5032, 5049, 5066, - 5083, 5099, 5115, 5132, 5149, 5166, 5183, 5200, - 5216, 5232, 5249, 5266, 5283, 5300, 5317, 5333, - 5349, 5366, 5383, 5400, 5417, 5434, 5450, 5468, - 5484, 5502, 5514, 5521, 5524, 5526, 5529, 5532, - 5534, 5541, 5558, 5574, 5590, 5605, 5621, 5637, - 5654, 5667, 5679, 5690, 5703, 5715, 5726, 5739, - 5751, 5762, 5775, 5787, 5798, 5810, 5819, 5826, - 5835, 5847, 5864, 5873, 5880, 5887, 5890, 5892, + 0, 2, 19, 26, 31, 35, 37, 42, + 46, 48, 53, 57, 59, 64, 68, 70, + 76, 78, 80, 86, 88, 90, 96, 98, + 100, 106, 108, 110, 122, 134, 146, 158, + 170, 182, 194, 206, 218, 230, 232, 249, + 256, 261, 265, 267, 272, 276, 278, 283, + 287, 289, 294, 298, 300, 306, 308, 310, + 316, 318, 320, 326, 328, 330, 336, 338, + 340, 352, 364, 376, 388, 400, 412, 424, + 436, 448, 460, 462, 479, 486, 491, 495, + 497, 502, 506, 508, 513, 517, 519, 524, + 528, 530, 536, 538, 540, 546, 548, 550, + 556, 558, 560, 566, 568, 570, 582, 594, + 606, 618, 630, 642, 654, 666, 678, 680, + 697, 704, 709, 713, 715, 720, 724, 726, + 731, 735, 737, 742, 746, 748, 754, 756, + 758, 764, 766, 768, 774, 776, 778, 784, + 786, 788, 800, 812, 824, 836, 848, 860, + 872, 884, 896, 908, 920, 925, 937, 949, + 954, 958, 963, 967, 969, 974, 978, 980, + 985, 989, 991, 993, 1010, 1017, 1023, 1025, + 1027, 1033, 1035, 1037, 1043, 1045, 1047, 1053, + 1055, 1057, 1059, 1078, 1094, 1110, 1125, 1142, + 1158, 1174, 1189, 1206, 1222, 1238, 1253, 1270, + 1286, 1302, 1317, 1334, 1350, 1366, 1381, 1392, + 1403, 1410, 1413, 1415, 1418, 1421, 1423, 1430, + 1442, 1451, 1458, 1467, 1479, 1492, 1505, 1517, + 1528, 1541, 1553, 1564, 1577, 1589, 1600, 1613, + 1625, 1636, 1649, 1666, 1678, 1694, 1710, 1727, + 1744, 1761, 1778, 1795, 1811, 1827, 1844, 1861, + 1878, 1895, 1912, 1928, 1944, 1961, 1978, 1995, + 2012, 2029, 2045, 2061, 2078, 2095, 2112, 2129, + 2146, 2162, 2178, 2194, 2210, 2225, 2242, 2258, + 2274, 2289, 2306, 2322, 2338, 2353, 2370, 2386, + 2402, 2417, 2434, 2450, 2466, 2481, 2492, 2503, + 2510, 2513, 2515, 2518, 2521, 2523, 2530, 2542, + 2551, 2558, 2567, 2579, 2592, 2605, 2617, 2628, + 2641, 2653, 2664, 2677, 2689, 2700, 2713, 2725, + 2736, 2749, 2766, 2778, 2794, 2810, 2827, 2844, + 2861, 2878, 2895, 2911, 2927, 2944, 2961, 2978, + 2995, 3012, 3028, 3044, 3061, 3078, 3095, 3112, + 3129, 3145, 3161, 3178, 3195, 3212, 3229, 3241, + 3258, 3274, 3290, 3305, 3322, 3338, 3354, 3369, + 3386, 3402, 3418, 3433, 3450, 3466, 3482, 3497, + 3514, 3530, 3546, 3561, 3572, 3583, 3590, 3593, + 3595, 3598, 3601, 3603, 3610, 3622, 3631, 3638, + 3647, 3659, 3672, 3685, 3697, 3708, 3721, 3733, + 3744, 3757, 3769, 3780, 3793, 3805, 3816, 3829, + 3846, 3858, 3874, 3890, 3907, 3924, 3941, 3958, + 3975, 3991, 4007, 4024, 4041, 4058, 4075, 4092, + 4108, 4124, 4141, 4158, 4175, 4192, 4209, 4225, + 4241, 4258, 4275, 4292, 4309, 4326, 4338, 4354, + 4366, 4382, 4398, 4413, 4430, 4446, 4462, 4477, + 4494, 4510, 4526, 4541, 4558, 4574, 4590, 4605, + 4622, 4638, 4654, 4669, 4680, 4691, 4698, 4701, + 4703, 4706, 4709, 4711, 4718, 4730, 4739, 4746, + 4755, 4767, 4780, 4793, 4805, 4816, 4829, 4841, + 4852, 4865, 4877, 4888, 4901, 4913, 4924, 4937, + 4954, 4966, 4982, 4998, 5015, 5032, 5049, 5066, + 5083, 5099, 5115, 5132, 5149, 5166, 5183, 5200, + 5216, 5232, 5249, 5266, 5283, 5300, 5317, 5333, + 5349, 5366, 5383, 5400, 5417, 5434, 5450, 5468, + 5484, 5502, 5514, 5521, 5524, 5526, 5529, 5532, + 5534, 5541, 5558, 5574, 5590, 5605, 5621, 5637, + 5654, 5667, 5679, 5690, 5703, 5715, 5726, 5739, + 5751, 5762, 5775, 5787, 5798, 5810, 5819, 5826, + 5835, 5847, 5864, 5873, 5880, 5887, 5890, 5892, 5895, 5898, 5900 }; static const short _indic_syllable_machine_indicies[] = { - 1, 0, 2, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 2, 0, 1, 0, 0, 0, 0, - 4, 0, 5, 5, 6, 1, 0, 7, - 7, 6, 0, 6, 0, 8, 8, 9, - 1, 0, 10, 10, 9, 0, 9, 0, - 11, 11, 12, 1, 0, 13, 13, 12, - 0, 12, 0, 14, 14, 15, 1, 0, - 16, 16, 15, 0, 15, 0, 17, 0, - 0, 0, 1, 0, 18, 0, 19, 0, - 20, 14, 14, 15, 1, 0, 21, 0, - 22, 0, 23, 11, 11, 12, 1, 0, - 24, 0, 25, 0, 26, 8, 8, 9, - 1, 0, 27, 0, 28, 0, 29, 5, - 5, 6, 1, 0, 0, 0, 0, 0, - 29, 0, 29, 5, 5, 6, 1, 0, - 0, 0, 0, 30, 29, 0, 31, 5, - 5, 6, 1, 0, 0, 0, 0, 0, - 31, 0, 31, 5, 5, 6, 1, 0, - 0, 0, 0, 32, 31, 0, 33, 5, - 5, 6, 1, 0, 0, 0, 0, 0, - 33, 0, 33, 5, 5, 6, 1, 0, - 0, 0, 0, 34, 33, 0, 35, 5, - 5, 6, 1, 0, 0, 0, 0, 0, - 35, 0, 35, 5, 5, 6, 1, 0, - 0, 0, 0, 36, 35, 0, 37, 5, - 5, 6, 1, 0, 0, 0, 0, 0, - 37, 0, 37, 5, 5, 6, 1, 0, - 0, 0, 0, 38, 37, 0, 40, 39, - 41, 42, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 41, - 39, 40, 39, 39, 39, 39, 43, 39, - 44, 44, 45, 40, 39, 46, 46, 45, - 39, 45, 39, 47, 47, 48, 40, 39, - 49, 49, 48, 39, 48, 39, 50, 50, - 51, 40, 39, 52, 52, 51, 39, 51, - 39, 53, 53, 54, 40, 39, 55, 55, - 54, 39, 54, 39, 56, 39, 39, 39, - 40, 39, 57, 39, 58, 39, 59, 53, - 53, 54, 40, 39, 60, 39, 61, 39, - 62, 50, 50, 51, 40, 39, 63, 39, - 64, 39, 65, 47, 47, 48, 40, 39, - 66, 39, 67, 39, 68, 44, 44, 45, - 40, 39, 39, 39, 39, 39, 68, 39, - 68, 44, 44, 45, 40, 39, 39, 39, - 39, 69, 68, 39, 70, 44, 44, 45, - 40, 39, 39, 39, 39, 39, 70, 39, - 70, 44, 44, 45, 40, 39, 39, 39, - 39, 71, 70, 39, 72, 44, 44, 45, - 40, 39, 39, 39, 39, 39, 72, 39, - 72, 44, 44, 45, 40, 39, 39, 39, - 39, 73, 72, 39, 74, 44, 44, 45, - 40, 39, 39, 39, 39, 39, 74, 39, - 74, 44, 44, 45, 40, 39, 39, 39, - 39, 75, 74, 39, 76, 44, 44, 45, - 40, 39, 39, 39, 39, 39, 76, 39, - 76, 44, 44, 45, 40, 39, 39, 39, - 39, 77, 76, 39, 79, 78, 80, 81, - 78, 78, 78, 78, 78, 78, 78, 78, - 78, 78, 78, 78, 78, 80, 78, 79, - 78, 78, 78, 78, 82, 78, 83, 83, - 84, 79, 78, 86, 86, 84, 85, 84, - 85, 87, 87, 88, 79, 78, 89, 89, - 88, 78, 88, 78, 90, 90, 91, 79, - 78, 92, 92, 91, 78, 91, 78, 93, - 93, 94, 79, 78, 95, 95, 94, 78, - 94, 78, 96, 78, 78, 78, 79, 78, - 97, 78, 98, 78, 99, 93, 93, 94, - 79, 78, 100, 78, 101, 78, 102, 90, - 90, 91, 79, 78, 103, 78, 104, 78, - 105, 87, 87, 88, 79, 78, 106, 78, - 107, 78, 108, 83, 83, 84, 79, 78, - 78, 78, 78, 78, 108, 78, 108, 83, - 83, 84, 79, 78, 78, 78, 78, 109, - 108, 78, 110, 83, 83, 84, 79, 78, - 78, 78, 78, 78, 110, 78, 110, 83, - 83, 84, 79, 78, 78, 78, 78, 111, - 110, 78, 112, 83, 83, 84, 79, 78, - 78, 78, 78, 78, 112, 78, 112, 83, - 83, 84, 79, 78, 78, 78, 78, 113, - 112, 78, 114, 83, 83, 84, 79, 78, - 78, 78, 78, 78, 114, 78, 114, 83, - 83, 84, 79, 78, 78, 78, 78, 115, - 114, 78, 116, 83, 83, 84, 79, 78, - 78, 78, 78, 78, 116, 78, 118, 117, - 119, 120, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 119, - 117, 118, 117, 117, 117, 117, 121, 117, - 122, 122, 123, 118, 117, 124, 124, 123, - 117, 123, 117, 125, 125, 126, 118, 117, - 127, 127, 126, 117, 126, 117, 128, 128, - 129, 118, 117, 130, 130, 129, 117, 129, - 117, 131, 131, 132, 118, 117, 133, 133, - 132, 117, 132, 117, 134, 117, 117, 117, - 118, 117, 135, 117, 136, 117, 137, 131, - 131, 132, 118, 117, 138, 117, 139, 117, - 140, 128, 128, 129, 118, 117, 141, 117, - 142, 117, 143, 125, 125, 126, 118, 117, - 144, 117, 145, 117, 146, 122, 122, 123, - 118, 117, 117, 117, 117, 117, 146, 117, - 146, 122, 122, 123, 118, 117, 117, 117, - 117, 147, 146, 117, 148, 122, 122, 123, - 118, 117, 117, 117, 117, 117, 148, 117, - 148, 122, 122, 123, 118, 117, 117, 117, - 117, 149, 148, 117, 150, 122, 122, 123, - 118, 117, 117, 117, 117, 117, 150, 117, - 150, 122, 122, 123, 118, 117, 117, 117, - 117, 151, 150, 117, 152, 122, 122, 123, - 118, 117, 117, 117, 117, 117, 152, 117, - 152, 122, 122, 123, 118, 117, 117, 117, - 117, 153, 152, 117, 154, 122, 122, 123, - 118, 117, 117, 117, 117, 117, 154, 117, - 154, 122, 122, 123, 118, 117, 117, 117, - 117, 155, 154, 117, 116, 83, 83, 84, - 79, 78, 78, 78, 78, 156, 116, 78, - 86, 86, 84, 1, 0, 114, 83, 83, - 84, 157, 0, 0, 0, 0, 0, 114, - 0, 114, 83, 83, 84, 157, 0, 0, - 0, 0, 158, 114, 0, 159, 159, 160, - 1, 0, 7, 7, 160, 0, 161, 161, - 162, 157, 0, 163, 163, 162, 0, 162, - 0, 164, 164, 165, 157, 0, 166, 166, - 165, 0, 165, 0, 167, 167, 168, 157, - 0, 169, 169, 168, 0, 168, 0, 157, - 0, 170, 171, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 170, 0, 157, 0, 0, 0, 0, 172, - 0, 173, 0, 0, 0, 157, 0, 174, - 0, 175, 0, 176, 167, 167, 168, 157, - 0, 177, 0, 178, 0, 179, 164, 164, - 165, 157, 0, 180, 0, 181, 0, 182, - 161, 161, 162, 157, 0, 183, 0, 184, - 0, 186, 185, 188, 189, 190, 191, 192, - 193, 84, 79, 194, 195, 196, 196, 156, - 197, 198, 199, 200, 201, 187, 203, 204, - 205, 206, 6, 1, 207, 208, 202, 202, - 38, 209, 202, 202, 210, 202, 211, 204, - 212, 212, 6, 1, 207, 208, 202, 202, - 202, 209, 202, 202, 210, 202, 204, 212, - 212, 6, 1, 207, 208, 202, 202, 202, - 209, 202, 202, 210, 202, 213, 202, 202, - 202, 19, 214, 202, 1, 207, 208, 202, - 202, 202, 215, 202, 213, 202, 216, 217, - 218, 219, 6, 1, 207, 208, 202, 202, - 36, 220, 202, 202, 210, 202, 221, 217, - 222, 222, 6, 1, 207, 208, 202, 202, - 202, 220, 202, 202, 210, 202, 217, 222, - 222, 6, 1, 207, 208, 202, 202, 202, - 220, 202, 202, 210, 202, 223, 202, 202, - 202, 19, 224, 202, 1, 207, 208, 202, - 202, 202, 215, 202, 223, 202, 225, 226, - 227, 228, 6, 1, 207, 208, 202, 202, - 34, 229, 202, 202, 210, 202, 230, 226, - 231, 231, 6, 1, 207, 208, 202, 202, - 202, 229, 202, 202, 210, 202, 226, 231, - 231, 6, 1, 207, 208, 202, 202, 202, - 229, 202, 202, 210, 202, 232, 202, 202, - 202, 19, 233, 202, 1, 207, 208, 202, - 202, 202, 215, 202, 232, 202, 234, 235, - 236, 237, 6, 1, 207, 208, 202, 202, - 32, 238, 202, 202, 210, 202, 239, 235, - 240, 240, 6, 1, 207, 208, 202, 202, - 202, 238, 202, 202, 210, 202, 235, 240, - 240, 6, 1, 207, 208, 202, 202, 202, - 238, 202, 202, 210, 202, 241, 202, 202, - 202, 19, 242, 202, 1, 207, 208, 202, - 202, 202, 215, 202, 241, 202, 243, 244, - 245, 246, 6, 1, 207, 208, 202, 202, - 30, 247, 202, 202, 210, 202, 248, 244, - 249, 249, 6, 1, 207, 208, 202, 202, - 202, 247, 202, 202, 210, 202, 244, 249, - 249, 6, 1, 207, 208, 202, 202, 202, - 247, 202, 202, 210, 202, 19, 250, 202, - 1, 207, 208, 202, 202, 202, 215, 202, - 251, 251, 202, 1, 207, 208, 202, 202, - 202, 215, 202, 252, 202, 202, 253, 207, - 208, 202, 207, 208, 202, 254, 202, 207, - 255, 202, 207, 256, 202, 207, 202, 252, - 202, 202, 202, 207, 208, 202, 257, 202, - 258, 259, 202, 1, 207, 208, 202, 202, - 4, 202, 3, 202, 251, 251, 202, 1, - 207, 208, 202, 251, 251, 202, 1, 207, - 208, 202, 257, 202, 251, 251, 202, 1, - 207, 208, 202, 257, 202, 258, 251, 202, - 1, 207, 208, 202, 202, 4, 202, 19, - 202, 260, 260, 6, 1, 207, 208, 202, - 202, 202, 215, 202, 261, 28, 262, 263, - 9, 1, 207, 208, 202, 202, 202, 215, - 202, 28, 262, 263, 9, 1, 207, 208, - 202, 202, 202, 215, 202, 262, 262, 9, - 1, 207, 208, 202, 202, 202, 215, 202, - 264, 25, 265, 266, 12, 1, 207, 208, - 202, 202, 202, 215, 202, 25, 265, 266, - 12, 1, 207, 208, 202, 202, 202, 215, - 202, 265, 265, 12, 1, 207, 208, 202, - 202, 202, 215, 202, 267, 22, 268, 269, - 15, 1, 207, 208, 202, 202, 202, 215, - 202, 22, 268, 269, 15, 1, 207, 208, - 202, 202, 202, 215, 202, 268, 268, 15, - 1, 207, 208, 202, 202, 202, 215, 202, - 270, 19, 251, 271, 202, 1, 207, 208, - 202, 202, 202, 215, 202, 19, 251, 271, - 202, 1, 207, 208, 202, 202, 202, 215, - 202, 251, 272, 202, 1, 207, 208, 202, - 202, 202, 215, 202, 19, 202, 251, 251, - 202, 1, 207, 208, 202, 202, 202, 215, - 202, 2, 3, 202, 202, 19, 250, 202, - 1, 207, 208, 202, 202, 202, 215, 202, - 2, 202, 244, 249, 249, 6, 1, 207, - 208, 202, 202, 202, 247, 202, 243, 244, - 249, 249, 6, 1, 207, 208, 202, 202, - 202, 247, 202, 202, 210, 202, 243, 244, - 245, 249, 6, 1, 207, 208, 202, 202, - 30, 247, 202, 202, 210, 202, 241, 202, - 273, 202, 260, 260, 6, 1, 207, 208, - 202, 202, 202, 215, 202, 241, 202, 241, - 202, 202, 202, 251, 251, 202, 1, 207, - 208, 202, 202, 202, 215, 202, 241, 202, - 241, 202, 202, 202, 251, 274, 202, 1, - 207, 208, 202, 202, 202, 215, 202, 241, - 202, 241, 202, 273, 202, 251, 251, 202, - 1, 207, 208, 202, 202, 202, 215, 202, - 241, 202, 241, 3, 202, 202, 19, 242, - 202, 1, 207, 208, 202, 202, 202, 215, - 202, 241, 202, 234, 235, 240, 240, 6, - 1, 207, 208, 202, 202, 202, 238, 202, - 202, 210, 202, 234, 235, 236, 240, 6, - 1, 207, 208, 202, 202, 32, 238, 202, - 202, 210, 202, 232, 202, 275, 202, 260, - 260, 6, 1, 207, 208, 202, 202, 202, - 215, 202, 232, 202, 232, 202, 202, 202, - 251, 251, 202, 1, 207, 208, 202, 202, - 202, 215, 202, 232, 202, 232, 202, 202, - 202, 251, 276, 202, 1, 207, 208, 202, - 202, 202, 215, 202, 232, 202, 232, 202, - 275, 202, 251, 251, 202, 1, 207, 208, - 202, 202, 202, 215, 202, 232, 202, 232, - 3, 202, 202, 19, 233, 202, 1, 207, - 208, 202, 202, 202, 215, 202, 232, 202, - 225, 226, 231, 231, 6, 1, 207, 208, - 202, 202, 202, 229, 202, 202, 210, 202, - 225, 226, 227, 231, 6, 1, 207, 208, - 202, 202, 34, 229, 202, 202, 210, 202, - 223, 202, 277, 202, 260, 260, 6, 1, - 207, 208, 202, 202, 202, 215, 202, 223, - 202, 223, 202, 202, 202, 251, 251, 202, - 1, 207, 208, 202, 202, 202, 215, 202, - 223, 202, 223, 202, 202, 202, 251, 278, - 202, 1, 207, 208, 202, 202, 202, 215, - 202, 223, 202, 223, 202, 277, 202, 251, - 251, 202, 1, 207, 208, 202, 202, 202, - 215, 202, 223, 202, 223, 3, 202, 202, - 19, 224, 202, 1, 207, 208, 202, 202, - 202, 215, 202, 223, 202, 216, 217, 222, - 222, 6, 1, 207, 208, 202, 202, 202, - 220, 202, 202, 210, 202, 216, 217, 218, - 222, 6, 1, 207, 208, 202, 202, 36, - 220, 202, 202, 210, 202, 213, 202, 279, - 202, 260, 260, 6, 1, 207, 208, 202, - 202, 202, 215, 202, 213, 202, 213, 202, - 202, 202, 251, 251, 202, 1, 207, 208, - 202, 202, 202, 215, 202, 213, 202, 213, - 202, 202, 202, 251, 280, 202, 1, 207, - 208, 202, 202, 202, 215, 202, 213, 202, - 213, 202, 279, 202, 251, 251, 202, 1, - 207, 208, 202, 202, 202, 215, 202, 213, - 202, 213, 3, 202, 202, 19, 214, 202, - 1, 207, 208, 202, 202, 202, 215, 202, - 213, 202, 203, 204, 212, 212, 6, 1, - 207, 208, 202, 202, 202, 209, 202, 202, - 210, 202, 203, 204, 205, 212, 6, 1, - 207, 208, 202, 202, 38, 209, 202, 202, - 210, 202, 282, 283, 284, 285, 45, 40, - 286, 287, 281, 281, 77, 288, 281, 281, - 289, 281, 290, 283, 291, 285, 45, 40, - 286, 287, 281, 281, 281, 288, 281, 281, - 289, 281, 283, 291, 285, 45, 40, 286, - 287, 281, 281, 281, 288, 281, 281, 289, - 281, 292, 281, 281, 281, 58, 293, 281, - 40, 286, 287, 281, 281, 281, 294, 281, - 292, 281, 295, 296, 297, 298, 45, 40, - 286, 287, 281, 281, 75, 299, 281, 281, - 289, 281, 300, 296, 301, 301, 45, 40, - 286, 287, 281, 281, 281, 299, 281, 281, - 289, 281, 296, 301, 301, 45, 40, 286, - 287, 281, 281, 281, 299, 281, 281, 289, - 281, 302, 281, 281, 281, 58, 303, 281, - 40, 286, 287, 281, 281, 281, 294, 281, - 302, 281, 304, 305, 306, 307, 45, 40, - 286, 287, 281, 281, 73, 308, 281, 281, - 289, 281, 309, 305, 310, 310, 45, 40, - 286, 287, 281, 281, 281, 308, 281, 281, - 289, 281, 305, 310, 310, 45, 40, 286, - 287, 281, 281, 281, 308, 281, 281, 289, - 281, 311, 281, 281, 281, 58, 312, 281, - 40, 286, 287, 281, 281, 281, 294, 281, - 311, 281, 313, 314, 315, 316, 45, 40, - 286, 287, 281, 281, 71, 317, 281, 281, - 289, 281, 318, 314, 319, 319, 45, 40, - 286, 287, 281, 281, 281, 317, 281, 281, - 289, 281, 314, 319, 319, 45, 40, 286, - 287, 281, 281, 281, 317, 281, 281, 289, - 281, 320, 281, 281, 281, 58, 321, 281, - 40, 286, 287, 281, 281, 281, 294, 281, - 320, 281, 322, 323, 324, 325, 45, 40, - 286, 287, 281, 281, 69, 326, 281, 281, - 289, 281, 327, 323, 328, 328, 45, 40, - 286, 287, 281, 281, 281, 326, 281, 281, - 289, 281, 323, 328, 328, 45, 40, 286, - 287, 281, 281, 281, 326, 281, 281, 289, - 281, 58, 329, 281, 40, 286, 287, 281, - 281, 281, 294, 281, 330, 330, 281, 40, - 286, 287, 281, 281, 281, 294, 281, 331, - 281, 281, 332, 286, 287, 281, 286, 287, - 281, 333, 281, 286, 334, 281, 286, 335, - 281, 286, 281, 331, 281, 281, 281, 286, - 287, 281, 336, 281, 337, 338, 281, 40, - 286, 287, 281, 281, 43, 281, 42, 281, - 330, 330, 281, 40, 286, 287, 281, 330, - 330, 281, 40, 286, 287, 281, 336, 281, - 330, 330, 281, 40, 286, 287, 281, 336, - 281, 337, 330, 281, 40, 286, 287, 281, - 281, 43, 281, 58, 281, 339, 339, 45, - 40, 286, 287, 281, 281, 281, 294, 281, - 340, 67, 341, 342, 48, 40, 286, 287, - 281, 281, 281, 294, 281, 67, 341, 342, - 48, 40, 286, 287, 281, 281, 281, 294, - 281, 341, 341, 48, 40, 286, 287, 281, - 281, 281, 294, 281, 343, 64, 344, 345, - 51, 40, 286, 287, 281, 281, 281, 294, - 281, 64, 344, 345, 51, 40, 286, 287, - 281, 281, 281, 294, 281, 344, 344, 51, - 40, 286, 287, 281, 281, 281, 294, 281, - 346, 61, 347, 348, 54, 40, 286, 287, - 281, 281, 281, 294, 281, 61, 347, 348, - 54, 40, 286, 287, 281, 281, 281, 294, - 281, 347, 347, 54, 40, 286, 287, 281, - 281, 281, 294, 281, 349, 58, 330, 350, - 281, 40, 286, 287, 281, 281, 281, 294, - 281, 58, 330, 350, 281, 40, 286, 287, - 281, 281, 281, 294, 281, 330, 351, 281, - 40, 286, 287, 281, 281, 281, 294, 281, - 58, 281, 330, 330, 281, 40, 286, 287, - 281, 281, 281, 294, 281, 41, 42, 281, - 281, 58, 329, 281, 40, 286, 287, 281, - 281, 281, 294, 281, 41, 281, 323, 328, - 328, 45, 40, 286, 287, 281, 281, 281, - 326, 281, 322, 323, 328, 328, 45, 40, - 286, 287, 281, 281, 281, 326, 281, 281, - 289, 281, 322, 323, 324, 328, 45, 40, - 286, 287, 281, 281, 69, 326, 281, 281, - 289, 281, 320, 281, 352, 281, 339, 339, - 45, 40, 286, 287, 281, 281, 281, 294, - 281, 320, 281, 320, 281, 281, 281, 330, - 330, 281, 40, 286, 287, 281, 281, 281, - 294, 281, 320, 281, 320, 281, 281, 281, - 330, 353, 281, 40, 286, 287, 281, 281, - 281, 294, 281, 320, 281, 320, 281, 352, - 281, 330, 330, 281, 40, 286, 287, 281, - 281, 281, 294, 281, 320, 281, 320, 42, - 281, 281, 58, 321, 281, 40, 286, 287, - 281, 281, 281, 294, 281, 320, 281, 313, - 314, 319, 319, 45, 40, 286, 287, 281, - 281, 281, 317, 281, 281, 289, 281, 313, - 314, 315, 319, 45, 40, 286, 287, 281, - 281, 71, 317, 281, 281, 289, 281, 311, - 281, 354, 281, 339, 339, 45, 40, 286, - 287, 281, 281, 281, 294, 281, 311, 281, - 311, 281, 281, 281, 330, 330, 281, 40, - 286, 287, 281, 281, 281, 294, 281, 311, - 281, 311, 281, 281, 281, 330, 355, 281, - 40, 286, 287, 281, 281, 281, 294, 281, - 311, 281, 311, 281, 354, 281, 330, 330, - 281, 40, 286, 287, 281, 281, 281, 294, - 281, 311, 281, 311, 42, 281, 281, 58, - 312, 281, 40, 286, 287, 281, 281, 281, - 294, 281, 311, 281, 304, 305, 310, 310, - 45, 40, 286, 287, 281, 281, 281, 308, - 281, 281, 289, 281, 304, 305, 306, 310, - 45, 40, 286, 287, 281, 281, 73, 308, - 281, 281, 289, 281, 302, 281, 356, 281, - 339, 339, 45, 40, 286, 287, 281, 281, - 281, 294, 281, 302, 281, 302, 281, 281, - 281, 330, 330, 281, 40, 286, 287, 281, - 281, 281, 294, 281, 302, 281, 302, 281, - 281, 281, 330, 357, 281, 40, 286, 287, - 281, 281, 281, 294, 281, 302, 281, 302, - 281, 356, 281, 330, 330, 281, 40, 286, - 287, 281, 281, 281, 294, 281, 302, 281, - 302, 42, 281, 281, 58, 303, 281, 40, - 286, 287, 281, 281, 281, 294, 281, 302, - 281, 295, 296, 301, 301, 45, 40, 286, - 287, 281, 281, 281, 299, 281, 281, 289, - 281, 295, 296, 297, 301, 45, 40, 286, - 287, 281, 281, 75, 299, 281, 281, 289, - 281, 292, 281, 358, 281, 339, 339, 45, - 40, 286, 287, 281, 281, 281, 294, 281, - 292, 281, 292, 281, 281, 281, 330, 330, - 281, 40, 286, 287, 281, 281, 281, 294, - 281, 292, 281, 292, 281, 281, 281, 330, - 359, 281, 40, 286, 287, 281, 281, 281, - 294, 281, 292, 281, 292, 281, 358, 281, - 330, 330, 281, 40, 286, 287, 281, 281, - 281, 294, 281, 292, 281, 76, 44, 44, - 45, 40, 281, 281, 281, 281, 281, 76, - 281, 292, 42, 281, 281, 58, 293, 281, - 40, 286, 287, 281, 281, 281, 294, 281, - 292, 281, 282, 283, 291, 285, 45, 40, - 286, 287, 281, 281, 281, 288, 281, 281, - 289, 281, 361, 191, 362, 362, 84, 79, - 194, 195, 360, 360, 360, 197, 360, 360, - 200, 360, 191, 362, 362, 84, 79, 194, - 195, 360, 360, 360, 197, 360, 360, 200, - 360, 363, 360, 360, 360, 98, 364, 360, - 79, 194, 195, 360, 360, 360, 365, 360, - 363, 360, 366, 367, 368, 369, 84, 79, - 194, 195, 360, 360, 115, 370, 360, 360, - 200, 360, 371, 367, 372, 372, 84, 79, - 194, 195, 360, 360, 360, 370, 360, 360, - 200, 360, 367, 372, 372, 84, 79, 194, - 195, 360, 360, 360, 370, 360, 360, 200, - 360, 373, 360, 360, 360, 98, 374, 360, - 79, 194, 195, 360, 360, 360, 365, 360, - 373, 360, 375, 376, 377, 378, 84, 79, - 194, 195, 360, 360, 113, 379, 360, 360, - 200, 360, 380, 376, 381, 381, 84, 79, - 194, 195, 360, 360, 360, 379, 360, 360, - 200, 360, 376, 381, 381, 84, 79, 194, - 195, 360, 360, 360, 379, 360, 360, 200, - 360, 382, 360, 360, 360, 98, 383, 360, - 79, 194, 195, 360, 360, 360, 365, 360, - 382, 360, 384, 385, 386, 387, 84, 79, - 194, 195, 360, 360, 111, 388, 360, 360, - 200, 360, 389, 385, 390, 390, 84, 79, - 194, 195, 360, 360, 360, 388, 360, 360, - 200, 360, 385, 390, 390, 84, 79, 194, - 195, 360, 360, 360, 388, 360, 360, 200, - 360, 391, 360, 360, 360, 98, 392, 360, - 79, 194, 195, 360, 360, 360, 365, 360, - 391, 360, 393, 394, 395, 396, 84, 79, - 194, 195, 360, 360, 109, 397, 360, 360, - 200, 360, 398, 394, 399, 399, 84, 79, - 194, 195, 360, 360, 360, 397, 360, 360, - 200, 360, 394, 399, 399, 84, 79, 194, - 195, 360, 360, 360, 397, 360, 360, 200, - 360, 98, 400, 360, 79, 194, 195, 360, - 360, 360, 365, 360, 401, 401, 360, 79, - 194, 195, 360, 360, 360, 365, 360, 402, - 360, 360, 403, 194, 195, 360, 194, 195, - 360, 404, 360, 194, 405, 360, 194, 406, - 360, 194, 360, 402, 360, 360, 360, 194, - 195, 360, 407, 360, 408, 409, 360, 79, - 194, 195, 360, 360, 82, 360, 81, 360, - 401, 401, 360, 79, 194, 195, 360, 401, - 401, 360, 79, 194, 195, 360, 407, 360, - 401, 401, 360, 79, 194, 195, 360, 407, - 360, 408, 401, 360, 79, 194, 195, 360, - 360, 82, 360, 98, 360, 410, 410, 84, - 79, 194, 195, 360, 360, 360, 365, 360, - 411, 107, 412, 413, 88, 79, 194, 195, - 360, 360, 360, 365, 360, 107, 412, 413, - 88, 79, 194, 195, 360, 360, 360, 365, - 360, 412, 412, 88, 79, 194, 195, 360, - 360, 360, 365, 360, 414, 104, 415, 416, - 91, 79, 194, 195, 360, 360, 360, 365, - 360, 104, 415, 416, 91, 79, 194, 195, - 360, 360, 360, 365, 360, 415, 415, 91, - 79, 194, 195, 360, 360, 360, 365, 360, - 417, 101, 418, 419, 94, 79, 194, 195, - 360, 360, 360, 365, 360, 101, 418, 419, - 94, 79, 194, 195, 360, 360, 360, 365, - 360, 418, 418, 94, 79, 194, 195, 360, - 360, 360, 365, 360, 420, 98, 401, 421, - 360, 79, 194, 195, 360, 360, 360, 365, - 360, 98, 401, 421, 360, 79, 194, 195, - 360, 360, 360, 365, 360, 401, 422, 360, - 79, 194, 195, 360, 360, 360, 365, 360, - 98, 360, 401, 401, 360, 79, 194, 195, - 360, 360, 360, 365, 360, 80, 81, 360, - 360, 98, 400, 360, 79, 194, 195, 360, - 360, 360, 365, 360, 80, 360, 394, 399, - 399, 84, 79, 194, 195, 360, 360, 360, - 397, 360, 393, 394, 399, 399, 84, 79, - 194, 195, 360, 360, 360, 397, 360, 360, - 200, 360, 393, 394, 395, 399, 84, 79, - 194, 195, 360, 360, 109, 397, 360, 360, - 200, 360, 391, 360, 423, 360, 410, 410, - 84, 79, 194, 195, 360, 360, 360, 365, - 360, 391, 360, 391, 360, 360, 360, 401, - 401, 360, 79, 194, 195, 360, 360, 360, - 365, 360, 391, 360, 391, 360, 360, 360, - 401, 424, 360, 79, 194, 195, 360, 360, - 360, 365, 360, 391, 360, 391, 360, 423, - 360, 401, 401, 360, 79, 194, 195, 360, - 360, 360, 365, 360, 391, 360, 391, 81, - 360, 360, 98, 392, 360, 79, 194, 195, - 360, 360, 360, 365, 360, 391, 360, 384, - 385, 390, 390, 84, 79, 194, 195, 360, - 360, 360, 388, 360, 360, 200, 360, 384, - 385, 386, 390, 84, 79, 194, 195, 360, - 360, 111, 388, 360, 360, 200, 360, 382, - 360, 425, 360, 410, 410, 84, 79, 194, - 195, 360, 360, 360, 365, 360, 382, 360, - 382, 360, 360, 360, 401, 401, 360, 79, - 194, 195, 360, 360, 360, 365, 360, 382, - 360, 382, 360, 360, 360, 401, 426, 360, - 79, 194, 195, 360, 360, 360, 365, 360, - 382, 360, 382, 360, 425, 360, 401, 401, - 360, 79, 194, 195, 360, 360, 360, 365, - 360, 382, 360, 382, 81, 360, 360, 98, - 383, 360, 79, 194, 195, 360, 360, 360, - 365, 360, 382, 360, 375, 376, 381, 381, - 84, 79, 194, 195, 360, 360, 360, 379, - 360, 360, 200, 360, 375, 376, 377, 381, - 84, 79, 194, 195, 360, 360, 113, 379, - 360, 360, 200, 360, 373, 360, 427, 360, - 410, 410, 84, 79, 194, 195, 360, 360, - 360, 365, 360, 373, 360, 373, 360, 360, - 360, 401, 401, 360, 79, 194, 195, 360, - 360, 360, 365, 360, 373, 360, 373, 360, - 360, 360, 401, 428, 360, 79, 194, 195, - 360, 360, 360, 365, 360, 373, 360, 373, - 360, 427, 360, 401, 401, 360, 79, 194, - 195, 360, 360, 360, 365, 360, 373, 360, - 373, 81, 360, 360, 98, 374, 360, 79, - 194, 195, 360, 360, 360, 365, 360, 373, - 360, 366, 367, 372, 372, 84, 79, 194, - 195, 360, 360, 360, 370, 360, 360, 200, - 360, 366, 367, 368, 372, 84, 79, 194, - 195, 360, 360, 115, 370, 360, 360, 200, - 360, 363, 360, 429, 360, 410, 410, 84, - 79, 194, 195, 360, 360, 360, 365, 360, - 363, 360, 363, 360, 360, 360, 401, 401, - 360, 79, 194, 195, 360, 360, 360, 365, - 360, 363, 360, 363, 360, 360, 360, 401, - 430, 360, 79, 194, 195, 360, 360, 360, - 365, 360, 363, 360, 363, 360, 429, 360, - 401, 401, 360, 79, 194, 195, 360, 360, - 360, 365, 360, 363, 360, 363, 81, 360, - 360, 98, 364, 360, 79, 194, 195, 360, - 360, 360, 365, 360, 363, 360, 116, 83, - 83, 84, 79, 431, 431, 431, 431, 156, - 116, 431, 190, 191, 362, 362, 84, 79, - 194, 195, 360, 360, 360, 197, 360, 360, - 200, 360, 116, 83, 83, 84, 79, 431, - 431, 431, 431, 431, 116, 431, 433, 434, - 435, 436, 123, 118, 437, 438, 432, 432, - 155, 439, 432, 432, 440, 432, 441, 434, - 436, 436, 123, 118, 437, 438, 432, 432, - 432, 439, 432, 432, 440, 432, 434, 436, - 436, 123, 118, 437, 438, 432, 432, 432, - 439, 432, 432, 440, 432, 442, 432, 432, - 432, 136, 443, 432, 118, 437, 438, 432, - 432, 432, 444, 432, 442, 432, 445, 446, - 447, 448, 123, 118, 437, 438, 432, 432, - 153, 449, 432, 432, 440, 432, 450, 446, - 451, 451, 123, 118, 437, 438, 432, 432, - 432, 449, 432, 432, 440, 432, 446, 451, - 451, 123, 118, 437, 438, 432, 432, 432, - 449, 432, 432, 440, 432, 452, 432, 432, - 432, 136, 453, 432, 118, 437, 438, 432, - 432, 432, 444, 432, 452, 432, 454, 455, - 456, 457, 123, 118, 437, 438, 432, 432, - 151, 458, 432, 432, 440, 432, 459, 455, - 460, 460, 123, 118, 437, 438, 432, 432, - 432, 458, 432, 432, 440, 432, 455, 460, - 460, 123, 118, 437, 438, 432, 432, 432, - 458, 432, 432, 440, 432, 461, 432, 432, - 432, 136, 462, 432, 118, 437, 438, 432, - 432, 432, 444, 432, 461, 432, 463, 464, - 465, 466, 123, 118, 437, 438, 432, 432, - 149, 467, 432, 432, 440, 432, 468, 464, - 469, 469, 123, 118, 437, 438, 432, 432, - 432, 467, 432, 432, 440, 432, 464, 469, - 469, 123, 118, 437, 438, 432, 432, 432, - 467, 432, 432, 440, 432, 470, 432, 432, - 432, 136, 471, 432, 118, 437, 438, 432, - 432, 432, 444, 432, 470, 432, 472, 473, - 474, 475, 123, 118, 437, 438, 432, 432, - 147, 476, 432, 432, 440, 432, 477, 473, - 478, 478, 123, 118, 437, 438, 432, 432, - 432, 476, 432, 432, 440, 432, 473, 478, - 478, 123, 118, 437, 438, 432, 432, 432, - 476, 432, 432, 440, 432, 136, 479, 432, - 118, 437, 438, 432, 432, 432, 444, 432, - 480, 480, 432, 118, 437, 438, 432, 432, - 432, 444, 432, 481, 432, 432, 482, 437, - 438, 432, 437, 438, 432, 483, 432, 437, - 484, 432, 437, 485, 432, 437, 432, 481, - 432, 432, 432, 437, 438, 432, 486, 432, - 487, 488, 432, 118, 437, 438, 432, 432, - 121, 432, 120, 432, 480, 480, 432, 118, - 437, 438, 432, 480, 480, 432, 118, 437, - 438, 432, 486, 432, 480, 480, 432, 118, - 437, 438, 432, 486, 432, 487, 480, 432, - 118, 437, 438, 432, 432, 121, 432, 136, - 432, 489, 489, 123, 118, 437, 438, 432, - 432, 432, 444, 432, 490, 145, 491, 492, - 126, 118, 437, 438, 432, 432, 432, 444, - 432, 145, 491, 492, 126, 118, 437, 438, - 432, 432, 432, 444, 432, 491, 491, 126, - 118, 437, 438, 432, 432, 432, 444, 432, - 493, 142, 494, 495, 129, 118, 437, 438, - 432, 432, 432, 444, 432, 142, 494, 495, - 129, 118, 437, 438, 432, 432, 432, 444, - 432, 494, 494, 129, 118, 437, 438, 432, - 432, 432, 444, 432, 496, 139, 497, 498, - 132, 118, 437, 438, 432, 432, 432, 444, - 432, 139, 497, 498, 132, 118, 437, 438, - 432, 432, 432, 444, 432, 497, 497, 132, - 118, 437, 438, 432, 432, 432, 444, 432, - 499, 136, 480, 500, 432, 118, 437, 438, - 432, 432, 432, 444, 432, 136, 480, 500, - 432, 118, 437, 438, 432, 432, 432, 444, - 432, 480, 501, 432, 118, 437, 438, 432, - 432, 432, 444, 432, 136, 432, 480, 480, - 432, 118, 437, 438, 432, 432, 432, 444, - 432, 119, 120, 432, 432, 136, 479, 432, - 118, 437, 438, 432, 432, 432, 444, 432, - 119, 432, 473, 478, 478, 123, 118, 437, - 438, 432, 432, 432, 476, 432, 472, 473, - 478, 478, 123, 118, 437, 438, 432, 432, - 432, 476, 432, 432, 440, 432, 472, 473, - 474, 478, 123, 118, 437, 438, 432, 432, - 147, 476, 432, 432, 440, 432, 470, 432, - 502, 432, 489, 489, 123, 118, 437, 438, - 432, 432, 432, 444, 432, 470, 432, 470, - 432, 432, 432, 480, 480, 432, 118, 437, - 438, 432, 432, 432, 444, 432, 470, 432, - 470, 432, 432, 432, 480, 503, 432, 118, - 437, 438, 432, 432, 432, 444, 432, 470, - 432, 470, 432, 502, 432, 480, 480, 432, - 118, 437, 438, 432, 432, 432, 444, 432, - 470, 432, 470, 120, 432, 432, 136, 471, - 432, 118, 437, 438, 432, 432, 432, 444, - 432, 470, 432, 463, 464, 469, 469, 123, - 118, 437, 438, 432, 432, 432, 467, 432, - 432, 440, 432, 463, 464, 465, 469, 123, - 118, 437, 438, 432, 432, 149, 467, 432, - 432, 440, 432, 461, 432, 504, 432, 489, - 489, 123, 118, 437, 438, 432, 432, 432, - 444, 432, 461, 432, 461, 432, 432, 432, - 480, 480, 432, 118, 437, 438, 432, 432, - 432, 444, 432, 461, 432, 461, 432, 432, - 432, 480, 505, 432, 118, 437, 438, 432, - 432, 432, 444, 432, 461, 432, 461, 432, - 504, 432, 480, 480, 432, 118, 437, 438, - 432, 432, 432, 444, 432, 461, 432, 461, - 120, 432, 432, 136, 462, 432, 118, 437, - 438, 432, 432, 432, 444, 432, 461, 432, - 454, 455, 460, 460, 123, 118, 437, 438, - 432, 432, 432, 458, 432, 432, 440, 432, - 454, 455, 456, 460, 123, 118, 437, 438, - 432, 432, 151, 458, 432, 432, 440, 432, - 452, 432, 506, 432, 489, 489, 123, 118, - 437, 438, 432, 432, 432, 444, 432, 452, - 432, 452, 432, 432, 432, 480, 480, 432, - 118, 437, 438, 432, 432, 432, 444, 432, - 452, 432, 452, 432, 432, 432, 480, 507, - 432, 118, 437, 438, 432, 432, 432, 444, - 432, 452, 432, 452, 432, 506, 432, 480, - 480, 432, 118, 437, 438, 432, 432, 432, - 444, 432, 452, 432, 452, 120, 432, 432, - 136, 453, 432, 118, 437, 438, 432, 432, - 432, 444, 432, 452, 432, 445, 446, 451, - 451, 123, 118, 437, 438, 432, 432, 432, - 449, 432, 432, 440, 432, 445, 446, 447, - 451, 123, 118, 437, 438, 432, 432, 153, - 449, 432, 432, 440, 432, 442, 432, 508, - 432, 489, 489, 123, 118, 437, 438, 432, - 432, 432, 444, 432, 442, 432, 442, 432, - 432, 432, 480, 480, 432, 118, 437, 438, - 432, 432, 432, 444, 432, 442, 432, 442, - 432, 432, 432, 480, 509, 432, 118, 437, - 438, 432, 432, 432, 444, 432, 442, 432, - 442, 432, 508, 432, 480, 480, 432, 118, - 437, 438, 432, 432, 432, 444, 432, 442, - 432, 442, 120, 432, 432, 136, 443, 432, - 118, 437, 438, 432, 432, 432, 444, 432, - 442, 432, 433, 434, 436, 436, 123, 118, - 437, 438, 432, 432, 432, 439, 432, 432, - 440, 432, 188, 189, 190, 191, 510, 362, - 84, 79, 194, 195, 196, 196, 156, 197, - 360, 188, 200, 360, 203, 511, 205, 206, - 6, 1, 207, 208, 202, 202, 38, 209, - 202, 202, 210, 202, 213, 189, 190, 191, - 512, 513, 84, 157, 514, 515, 202, 196, - 156, 516, 202, 213, 200, 202, 116, 517, - 517, 84, 157, 207, 208, 202, 202, 156, - 518, 202, 519, 202, 202, 520, 514, 515, - 202, 514, 515, 202, 254, 202, 514, 521, - 202, 514, 522, 202, 514, 202, 519, 202, - 202, 202, 514, 515, 202, 523, 3, 360, - 360, 401, 430, 360, 79, 194, 195, 360, - 360, 360, 365, 360, 523, 360, 524, 367, - 525, 526, 84, 157, 514, 515, 202, 202, - 158, 370, 202, 202, 200, 202, 527, 367, - 528, 528, 84, 157, 514, 515, 202, 202, - 202, 370, 202, 202, 200, 202, 367, 528, - 528, 84, 157, 514, 515, 202, 202, 202, - 370, 202, 202, 200, 202, 524, 367, 528, - 528, 84, 157, 514, 515, 202, 202, 202, - 370, 202, 202, 200, 202, 524, 367, 525, - 528, 84, 157, 514, 515, 202, 202, 158, - 370, 202, 202, 200, 202, 213, 202, 279, - 116, 529, 529, 160, 157, 207, 208, 202, - 202, 202, 518, 202, 213, 202, 530, 184, - 531, 532, 162, 157, 514, 515, 202, 202, - 202, 533, 202, 184, 531, 532, 162, 157, - 514, 515, 202, 202, 202, 533, 202, 531, - 531, 162, 157, 514, 515, 202, 202, 202, - 533, 202, 534, 181, 535, 536, 165, 157, - 514, 515, 202, 202, 202, 533, 202, 181, - 535, 536, 165, 157, 514, 515, 202, 202, - 202, 533, 202, 535, 535, 165, 157, 514, - 515, 202, 202, 202, 533, 202, 537, 178, - 538, 539, 168, 157, 514, 515, 202, 202, - 202, 533, 202, 178, 538, 539, 168, 157, - 514, 515, 202, 202, 202, 533, 202, 538, - 538, 168, 157, 514, 515, 202, 202, 202, - 533, 202, 540, 175, 541, 542, 202, 157, - 514, 515, 202, 202, 202, 533, 202, 175, - 541, 542, 202, 157, 514, 515, 202, 202, - 202, 533, 202, 541, 541, 202, 157, 514, - 515, 202, 202, 202, 533, 202, 543, 202, - 544, 545, 202, 157, 514, 515, 202, 202, - 172, 202, 171, 202, 541, 541, 202, 157, - 514, 515, 202, 541, 541, 202, 157, 514, - 515, 202, 543, 202, 541, 541, 202, 157, - 514, 515, 202, 543, 202, 544, 541, 202, - 157, 514, 515, 202, 202, 172, 202, 523, - 171, 360, 360, 98, 364, 360, 79, 194, - 195, 360, 360, 360, 365, 360, 523, 360, - 547, 546, 548, 548, 546, 186, 549, 550, - 546, 548, 548, 546, 186, 549, 550, 546, - 551, 546, 546, 552, 549, 550, 546, 549, - 550, 546, 553, 546, 549, 554, 546, 549, - 555, 546, 549, 546, 551, 546, 546, 546, + 1, 0, 2, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 0, 1, 0, 0, 0, 0, + 4, 0, 5, 5, 6, 1, 0, 7, + 7, 6, 0, 6, 0, 8, 8, 9, + 1, 0, 10, 10, 9, 0, 9, 0, + 11, 11, 12, 1, 0, 13, 13, 12, + 0, 12, 0, 14, 14, 15, 1, 0, + 16, 16, 15, 0, 15, 0, 17, 0, + 0, 0, 1, 0, 18, 0, 19, 0, + 20, 14, 14, 15, 1, 0, 21, 0, + 22, 0, 23, 11, 11, 12, 1, 0, + 24, 0, 25, 0, 26, 8, 8, 9, + 1, 0, 27, 0, 28, 0, 29, 5, + 5, 6, 1, 0, 0, 0, 0, 0, + 29, 0, 29, 5, 5, 6, 1, 0, + 0, 0, 0, 30, 29, 0, 31, 5, + 5, 6, 1, 0, 0, 0, 0, 0, + 31, 0, 31, 5, 5, 6, 1, 0, + 0, 0, 0, 32, 31, 0, 33, 5, + 5, 6, 1, 0, 0, 0, 0, 0, + 33, 0, 33, 5, 5, 6, 1, 0, + 0, 0, 0, 34, 33, 0, 35, 5, + 5, 6, 1, 0, 0, 0, 0, 0, + 35, 0, 35, 5, 5, 6, 1, 0, + 0, 0, 0, 36, 35, 0, 37, 5, + 5, 6, 1, 0, 0, 0, 0, 0, + 37, 0, 37, 5, 5, 6, 1, 0, + 0, 0, 0, 38, 37, 0, 40, 39, + 41, 42, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 41, + 39, 40, 39, 39, 39, 39, 43, 39, + 44, 44, 45, 40, 39, 46, 46, 45, + 39, 45, 39, 47, 47, 48, 40, 39, + 49, 49, 48, 39, 48, 39, 50, 50, + 51, 40, 39, 52, 52, 51, 39, 51, + 39, 53, 53, 54, 40, 39, 55, 55, + 54, 39, 54, 39, 56, 39, 39, 39, + 40, 39, 57, 39, 58, 39, 59, 53, + 53, 54, 40, 39, 60, 39, 61, 39, + 62, 50, 50, 51, 40, 39, 63, 39, + 64, 39, 65, 47, 47, 48, 40, 39, + 66, 39, 67, 39, 68, 44, 44, 45, + 40, 39, 39, 39, 39, 39, 68, 39, + 68, 44, 44, 45, 40, 39, 39, 39, + 39, 69, 68, 39, 70, 44, 44, 45, + 40, 39, 39, 39, 39, 39, 70, 39, + 70, 44, 44, 45, 40, 39, 39, 39, + 39, 71, 70, 39, 72, 44, 44, 45, + 40, 39, 39, 39, 39, 39, 72, 39, + 72, 44, 44, 45, 40, 39, 39, 39, + 39, 73, 72, 39, 74, 44, 44, 45, + 40, 39, 39, 39, 39, 39, 74, 39, + 74, 44, 44, 45, 40, 39, 39, 39, + 39, 75, 74, 39, 76, 44, 44, 45, + 40, 39, 39, 39, 39, 39, 76, 39, + 76, 44, 44, 45, 40, 39, 39, 39, + 39, 77, 76, 39, 79, 78, 80, 81, + 78, 78, 78, 78, 78, 78, 78, 78, + 78, 78, 78, 78, 78, 80, 78, 79, + 78, 78, 78, 78, 82, 78, 83, 83, + 84, 79, 78, 86, 86, 84, 85, 84, + 85, 87, 87, 88, 79, 78, 89, 89, + 88, 78, 88, 78, 90, 90, 91, 79, + 78, 92, 92, 91, 78, 91, 78, 93, + 93, 94, 79, 78, 95, 95, 94, 78, + 94, 78, 96, 78, 78, 78, 79, 78, + 97, 78, 98, 78, 99, 93, 93, 94, + 79, 78, 100, 78, 101, 78, 102, 90, + 90, 91, 79, 78, 103, 78, 104, 78, + 105, 87, 87, 88, 79, 78, 106, 78, + 107, 78, 108, 83, 83, 84, 79, 78, + 78, 78, 78, 78, 108, 78, 108, 83, + 83, 84, 79, 78, 78, 78, 78, 109, + 108, 78, 110, 83, 83, 84, 79, 78, + 78, 78, 78, 78, 110, 78, 110, 83, + 83, 84, 79, 78, 78, 78, 78, 111, + 110, 78, 112, 83, 83, 84, 79, 78, + 78, 78, 78, 78, 112, 78, 112, 83, + 83, 84, 79, 78, 78, 78, 78, 113, + 112, 78, 114, 83, 83, 84, 79, 78, + 78, 78, 78, 78, 114, 78, 114, 83, + 83, 84, 79, 78, 78, 78, 78, 115, + 114, 78, 116, 83, 83, 84, 79, 78, + 78, 78, 78, 78, 116, 78, 118, 117, + 119, 120, 117, 117, 117, 117, 117, 117, + 117, 117, 117, 117, 117, 117, 117, 119, + 117, 118, 117, 117, 117, 117, 121, 117, + 122, 122, 123, 118, 117, 124, 124, 123, + 117, 123, 117, 125, 125, 126, 118, 117, + 127, 127, 126, 117, 126, 117, 128, 128, + 129, 118, 117, 130, 130, 129, 117, 129, + 117, 131, 131, 132, 118, 117, 133, 133, + 132, 117, 132, 117, 134, 117, 117, 117, + 118, 117, 135, 117, 136, 117, 137, 131, + 131, 132, 118, 117, 138, 117, 139, 117, + 140, 128, 128, 129, 118, 117, 141, 117, + 142, 117, 143, 125, 125, 126, 118, 117, + 144, 117, 145, 117, 146, 122, 122, 123, + 118, 117, 117, 117, 117, 117, 146, 117, + 146, 122, 122, 123, 118, 117, 117, 117, + 117, 147, 146, 117, 148, 122, 122, 123, + 118, 117, 117, 117, 117, 117, 148, 117, + 148, 122, 122, 123, 118, 117, 117, 117, + 117, 149, 148, 117, 150, 122, 122, 123, + 118, 117, 117, 117, 117, 117, 150, 117, + 150, 122, 122, 123, 118, 117, 117, 117, + 117, 151, 150, 117, 152, 122, 122, 123, + 118, 117, 117, 117, 117, 117, 152, 117, + 152, 122, 122, 123, 118, 117, 117, 117, + 117, 153, 152, 117, 154, 122, 122, 123, + 118, 117, 117, 117, 117, 117, 154, 117, + 154, 122, 122, 123, 118, 117, 117, 117, + 117, 155, 154, 117, 116, 83, 83, 84, + 79, 78, 78, 78, 78, 156, 116, 78, + 86, 86, 84, 1, 0, 114, 83, 83, + 84, 157, 0, 0, 0, 0, 0, 114, + 0, 114, 83, 83, 84, 157, 0, 0, + 0, 0, 158, 114, 0, 159, 159, 160, + 1, 0, 7, 7, 160, 0, 161, 161, + 162, 157, 0, 163, 163, 162, 0, 162, + 0, 164, 164, 165, 157, 0, 166, 166, + 165, 0, 165, 0, 167, 167, 168, 157, + 0, 169, 169, 168, 0, 168, 0, 157, + 0, 170, 171, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 170, 0, 157, 0, 0, 0, 0, 172, + 0, 173, 0, 0, 0, 157, 0, 174, + 0, 175, 0, 176, 167, 167, 168, 157, + 0, 177, 0, 178, 0, 179, 164, 164, + 165, 157, 0, 180, 0, 181, 0, 182, + 161, 161, 162, 157, 0, 183, 0, 184, + 0, 186, 185, 188, 189, 190, 191, 192, + 193, 84, 79, 194, 195, 196, 196, 156, + 197, 198, 199, 200, 201, 187, 203, 204, + 205, 206, 6, 1, 207, 208, 202, 202, + 38, 209, 202, 202, 210, 202, 211, 204, + 212, 212, 6, 1, 207, 208, 202, 202, + 202, 209, 202, 202, 210, 202, 204, 212, + 212, 6, 1, 207, 208, 202, 202, 202, + 209, 202, 202, 210, 202, 213, 202, 202, + 202, 19, 214, 202, 1, 207, 208, 202, + 202, 202, 215, 202, 213, 202, 216, 217, + 218, 219, 6, 1, 207, 208, 202, 202, + 36, 220, 202, 202, 210, 202, 221, 217, + 222, 222, 6, 1, 207, 208, 202, 202, + 202, 220, 202, 202, 210, 202, 217, 222, + 222, 6, 1, 207, 208, 202, 202, 202, + 220, 202, 202, 210, 202, 223, 202, 202, + 202, 19, 224, 202, 1, 207, 208, 202, + 202, 202, 215, 202, 223, 202, 225, 226, + 227, 228, 6, 1, 207, 208, 202, 202, + 34, 229, 202, 202, 210, 202, 230, 226, + 231, 231, 6, 1, 207, 208, 202, 202, + 202, 229, 202, 202, 210, 202, 226, 231, + 231, 6, 1, 207, 208, 202, 202, 202, + 229, 202, 202, 210, 202, 232, 202, 202, + 202, 19, 233, 202, 1, 207, 208, 202, + 202, 202, 215, 202, 232, 202, 234, 235, + 236, 237, 6, 1, 207, 208, 202, 202, + 32, 238, 202, 202, 210, 202, 239, 235, + 240, 240, 6, 1, 207, 208, 202, 202, + 202, 238, 202, 202, 210, 202, 235, 240, + 240, 6, 1, 207, 208, 202, 202, 202, + 238, 202, 202, 210, 202, 241, 202, 202, + 202, 19, 242, 202, 1, 207, 208, 202, + 202, 202, 215, 202, 241, 202, 243, 244, + 245, 246, 6, 1, 207, 208, 202, 202, + 30, 247, 202, 202, 210, 202, 248, 244, + 249, 249, 6, 1, 207, 208, 202, 202, + 202, 247, 202, 202, 210, 202, 244, 249, + 249, 6, 1, 207, 208, 202, 202, 202, + 247, 202, 202, 210, 202, 19, 250, 202, + 1, 207, 208, 202, 202, 202, 215, 202, + 251, 251, 202, 1, 207, 208, 202, 202, + 202, 215, 202, 252, 202, 202, 253, 207, + 208, 202, 207, 208, 202, 254, 202, 207, + 255, 202, 207, 256, 202, 207, 202, 252, + 202, 202, 202, 207, 208, 202, 257, 202, + 258, 259, 202, 1, 207, 208, 202, 202, + 4, 202, 3, 202, 251, 251, 202, 1, + 207, 208, 202, 251, 251, 202, 1, 207, + 208, 202, 257, 202, 251, 251, 202, 1, + 207, 208, 202, 257, 202, 258, 251, 202, + 1, 207, 208, 202, 202, 4, 202, 19, + 202, 260, 260, 6, 1, 207, 208, 202, + 202, 202, 215, 202, 261, 28, 262, 263, + 9, 1, 207, 208, 202, 202, 202, 215, + 202, 28, 262, 263, 9, 1, 207, 208, + 202, 202, 202, 215, 202, 262, 262, 9, + 1, 207, 208, 202, 202, 202, 215, 202, + 264, 25, 265, 266, 12, 1, 207, 208, + 202, 202, 202, 215, 202, 25, 265, 266, + 12, 1, 207, 208, 202, 202, 202, 215, + 202, 265, 265, 12, 1, 207, 208, 202, + 202, 202, 215, 202, 267, 22, 268, 269, + 15, 1, 207, 208, 202, 202, 202, 215, + 202, 22, 268, 269, 15, 1, 207, 208, + 202, 202, 202, 215, 202, 268, 268, 15, + 1, 207, 208, 202, 202, 202, 215, 202, + 270, 19, 251, 271, 202, 1, 207, 208, + 202, 202, 202, 215, 202, 19, 251, 271, + 202, 1, 207, 208, 202, 202, 202, 215, + 202, 251, 272, 202, 1, 207, 208, 202, + 202, 202, 215, 202, 19, 202, 251, 251, + 202, 1, 207, 208, 202, 202, 202, 215, + 202, 2, 3, 202, 202, 19, 250, 202, + 1, 207, 208, 202, 202, 202, 215, 202, + 2, 202, 244, 249, 249, 6, 1, 207, + 208, 202, 202, 202, 247, 202, 243, 244, + 249, 249, 6, 1, 207, 208, 202, 202, + 202, 247, 202, 202, 210, 202, 243, 244, + 245, 249, 6, 1, 207, 208, 202, 202, + 30, 247, 202, 202, 210, 202, 241, 202, + 273, 202, 260, 260, 6, 1, 207, 208, + 202, 202, 202, 215, 202, 241, 202, 241, + 202, 202, 202, 251, 251, 202, 1, 207, + 208, 202, 202, 202, 215, 202, 241, 202, + 241, 202, 202, 202, 251, 274, 202, 1, + 207, 208, 202, 202, 202, 215, 202, 241, + 202, 241, 202, 273, 202, 251, 251, 202, + 1, 207, 208, 202, 202, 202, 215, 202, + 241, 202, 241, 3, 202, 202, 19, 242, + 202, 1, 207, 208, 202, 202, 202, 215, + 202, 241, 202, 234, 235, 240, 240, 6, + 1, 207, 208, 202, 202, 202, 238, 202, + 202, 210, 202, 234, 235, 236, 240, 6, + 1, 207, 208, 202, 202, 32, 238, 202, + 202, 210, 202, 232, 202, 275, 202, 260, + 260, 6, 1, 207, 208, 202, 202, 202, + 215, 202, 232, 202, 232, 202, 202, 202, + 251, 251, 202, 1, 207, 208, 202, 202, + 202, 215, 202, 232, 202, 232, 202, 202, + 202, 251, 276, 202, 1, 207, 208, 202, + 202, 202, 215, 202, 232, 202, 232, 202, + 275, 202, 251, 251, 202, 1, 207, 208, + 202, 202, 202, 215, 202, 232, 202, 232, + 3, 202, 202, 19, 233, 202, 1, 207, + 208, 202, 202, 202, 215, 202, 232, 202, + 225, 226, 231, 231, 6, 1, 207, 208, + 202, 202, 202, 229, 202, 202, 210, 202, + 225, 226, 227, 231, 6, 1, 207, 208, + 202, 202, 34, 229, 202, 202, 210, 202, + 223, 202, 277, 202, 260, 260, 6, 1, + 207, 208, 202, 202, 202, 215, 202, 223, + 202, 223, 202, 202, 202, 251, 251, 202, + 1, 207, 208, 202, 202, 202, 215, 202, + 223, 202, 223, 202, 202, 202, 251, 278, + 202, 1, 207, 208, 202, 202, 202, 215, + 202, 223, 202, 223, 202, 277, 202, 251, + 251, 202, 1, 207, 208, 202, 202, 202, + 215, 202, 223, 202, 223, 3, 202, 202, + 19, 224, 202, 1, 207, 208, 202, 202, + 202, 215, 202, 223, 202, 216, 217, 222, + 222, 6, 1, 207, 208, 202, 202, 202, + 220, 202, 202, 210, 202, 216, 217, 218, + 222, 6, 1, 207, 208, 202, 202, 36, + 220, 202, 202, 210, 202, 213, 202, 279, + 202, 260, 260, 6, 1, 207, 208, 202, + 202, 202, 215, 202, 213, 202, 213, 202, + 202, 202, 251, 251, 202, 1, 207, 208, + 202, 202, 202, 215, 202, 213, 202, 213, + 202, 202, 202, 251, 280, 202, 1, 207, + 208, 202, 202, 202, 215, 202, 213, 202, + 213, 202, 279, 202, 251, 251, 202, 1, + 207, 208, 202, 202, 202, 215, 202, 213, + 202, 213, 3, 202, 202, 19, 214, 202, + 1, 207, 208, 202, 202, 202, 215, 202, + 213, 202, 203, 204, 212, 212, 6, 1, + 207, 208, 202, 202, 202, 209, 202, 202, + 210, 202, 203, 204, 205, 212, 6, 1, + 207, 208, 202, 202, 38, 209, 202, 202, + 210, 202, 282, 283, 284, 285, 45, 40, + 286, 287, 281, 281, 77, 288, 281, 281, + 289, 281, 290, 283, 291, 285, 45, 40, + 286, 287, 281, 281, 281, 288, 281, 281, + 289, 281, 283, 291, 285, 45, 40, 286, + 287, 281, 281, 281, 288, 281, 281, 289, + 281, 292, 281, 281, 281, 58, 293, 281, + 40, 286, 287, 281, 281, 281, 294, 281, + 292, 281, 295, 296, 297, 298, 45, 40, + 286, 287, 281, 281, 75, 299, 281, 281, + 289, 281, 300, 296, 301, 301, 45, 40, + 286, 287, 281, 281, 281, 299, 281, 281, + 289, 281, 296, 301, 301, 45, 40, 286, + 287, 281, 281, 281, 299, 281, 281, 289, + 281, 302, 281, 281, 281, 58, 303, 281, + 40, 286, 287, 281, 281, 281, 294, 281, + 302, 281, 304, 305, 306, 307, 45, 40, + 286, 287, 281, 281, 73, 308, 281, 281, + 289, 281, 309, 305, 310, 310, 45, 40, + 286, 287, 281, 281, 281, 308, 281, 281, + 289, 281, 305, 310, 310, 45, 40, 286, + 287, 281, 281, 281, 308, 281, 281, 289, + 281, 311, 281, 281, 281, 58, 312, 281, + 40, 286, 287, 281, 281, 281, 294, 281, + 311, 281, 313, 314, 315, 316, 45, 40, + 286, 287, 281, 281, 71, 317, 281, 281, + 289, 281, 318, 314, 319, 319, 45, 40, + 286, 287, 281, 281, 281, 317, 281, 281, + 289, 281, 314, 319, 319, 45, 40, 286, + 287, 281, 281, 281, 317, 281, 281, 289, + 281, 320, 281, 281, 281, 58, 321, 281, + 40, 286, 287, 281, 281, 281, 294, 281, + 320, 281, 322, 323, 324, 325, 45, 40, + 286, 287, 281, 281, 69, 326, 281, 281, + 289, 281, 327, 323, 328, 328, 45, 40, + 286, 287, 281, 281, 281, 326, 281, 281, + 289, 281, 323, 328, 328, 45, 40, 286, + 287, 281, 281, 281, 326, 281, 281, 289, + 281, 58, 329, 281, 40, 286, 287, 281, + 281, 281, 294, 281, 330, 330, 281, 40, + 286, 287, 281, 281, 281, 294, 281, 331, + 281, 281, 332, 286, 287, 281, 286, 287, + 281, 333, 281, 286, 334, 281, 286, 335, + 281, 286, 281, 331, 281, 281, 281, 286, + 287, 281, 336, 281, 337, 338, 281, 40, + 286, 287, 281, 281, 43, 281, 42, 281, + 330, 330, 281, 40, 286, 287, 281, 330, + 330, 281, 40, 286, 287, 281, 336, 281, + 330, 330, 281, 40, 286, 287, 281, 336, + 281, 337, 330, 281, 40, 286, 287, 281, + 281, 43, 281, 58, 281, 339, 339, 45, + 40, 286, 287, 281, 281, 281, 294, 281, + 340, 67, 341, 342, 48, 40, 286, 287, + 281, 281, 281, 294, 281, 67, 341, 342, + 48, 40, 286, 287, 281, 281, 281, 294, + 281, 341, 341, 48, 40, 286, 287, 281, + 281, 281, 294, 281, 343, 64, 344, 345, + 51, 40, 286, 287, 281, 281, 281, 294, + 281, 64, 344, 345, 51, 40, 286, 287, + 281, 281, 281, 294, 281, 344, 344, 51, + 40, 286, 287, 281, 281, 281, 294, 281, + 346, 61, 347, 348, 54, 40, 286, 287, + 281, 281, 281, 294, 281, 61, 347, 348, + 54, 40, 286, 287, 281, 281, 281, 294, + 281, 347, 347, 54, 40, 286, 287, 281, + 281, 281, 294, 281, 349, 58, 330, 350, + 281, 40, 286, 287, 281, 281, 281, 294, + 281, 58, 330, 350, 281, 40, 286, 287, + 281, 281, 281, 294, 281, 330, 351, 281, + 40, 286, 287, 281, 281, 281, 294, 281, + 58, 281, 330, 330, 281, 40, 286, 287, + 281, 281, 281, 294, 281, 41, 42, 281, + 281, 58, 329, 281, 40, 286, 287, 281, + 281, 281, 294, 281, 41, 281, 323, 328, + 328, 45, 40, 286, 287, 281, 281, 281, + 326, 281, 322, 323, 328, 328, 45, 40, + 286, 287, 281, 281, 281, 326, 281, 281, + 289, 281, 322, 323, 324, 328, 45, 40, + 286, 287, 281, 281, 69, 326, 281, 281, + 289, 281, 320, 281, 352, 281, 339, 339, + 45, 40, 286, 287, 281, 281, 281, 294, + 281, 320, 281, 320, 281, 281, 281, 330, + 330, 281, 40, 286, 287, 281, 281, 281, + 294, 281, 320, 281, 320, 281, 281, 281, + 330, 353, 281, 40, 286, 287, 281, 281, + 281, 294, 281, 320, 281, 320, 281, 352, + 281, 330, 330, 281, 40, 286, 287, 281, + 281, 281, 294, 281, 320, 281, 320, 42, + 281, 281, 58, 321, 281, 40, 286, 287, + 281, 281, 281, 294, 281, 320, 281, 313, + 314, 319, 319, 45, 40, 286, 287, 281, + 281, 281, 317, 281, 281, 289, 281, 313, + 314, 315, 319, 45, 40, 286, 287, 281, + 281, 71, 317, 281, 281, 289, 281, 311, + 281, 354, 281, 339, 339, 45, 40, 286, + 287, 281, 281, 281, 294, 281, 311, 281, + 311, 281, 281, 281, 330, 330, 281, 40, + 286, 287, 281, 281, 281, 294, 281, 311, + 281, 311, 281, 281, 281, 330, 355, 281, + 40, 286, 287, 281, 281, 281, 294, 281, + 311, 281, 311, 281, 354, 281, 330, 330, + 281, 40, 286, 287, 281, 281, 281, 294, + 281, 311, 281, 311, 42, 281, 281, 58, + 312, 281, 40, 286, 287, 281, 281, 281, + 294, 281, 311, 281, 304, 305, 310, 310, + 45, 40, 286, 287, 281, 281, 281, 308, + 281, 281, 289, 281, 304, 305, 306, 310, + 45, 40, 286, 287, 281, 281, 73, 308, + 281, 281, 289, 281, 302, 281, 356, 281, + 339, 339, 45, 40, 286, 287, 281, 281, + 281, 294, 281, 302, 281, 302, 281, 281, + 281, 330, 330, 281, 40, 286, 287, 281, + 281, 281, 294, 281, 302, 281, 302, 281, + 281, 281, 330, 357, 281, 40, 286, 287, + 281, 281, 281, 294, 281, 302, 281, 302, + 281, 356, 281, 330, 330, 281, 40, 286, + 287, 281, 281, 281, 294, 281, 302, 281, + 302, 42, 281, 281, 58, 303, 281, 40, + 286, 287, 281, 281, 281, 294, 281, 302, + 281, 295, 296, 301, 301, 45, 40, 286, + 287, 281, 281, 281, 299, 281, 281, 289, + 281, 295, 296, 297, 301, 45, 40, 286, + 287, 281, 281, 75, 299, 281, 281, 289, + 281, 292, 281, 358, 281, 339, 339, 45, + 40, 286, 287, 281, 281, 281, 294, 281, + 292, 281, 292, 281, 281, 281, 330, 330, + 281, 40, 286, 287, 281, 281, 281, 294, + 281, 292, 281, 292, 281, 281, 281, 330, + 359, 281, 40, 286, 287, 281, 281, 281, + 294, 281, 292, 281, 292, 281, 358, 281, + 330, 330, 281, 40, 286, 287, 281, 281, + 281, 294, 281, 292, 281, 76, 44, 44, + 45, 40, 281, 281, 281, 281, 281, 76, + 281, 292, 42, 281, 281, 58, 293, 281, + 40, 286, 287, 281, 281, 281, 294, 281, + 292, 281, 282, 283, 291, 285, 45, 40, + 286, 287, 281, 281, 281, 288, 281, 281, + 289, 281, 361, 191, 362, 362, 84, 79, + 194, 195, 360, 360, 360, 197, 360, 360, + 200, 360, 191, 362, 362, 84, 79, 194, + 195, 360, 360, 360, 197, 360, 360, 200, + 360, 363, 360, 360, 360, 98, 364, 360, + 79, 194, 195, 360, 360, 360, 365, 360, + 363, 360, 366, 367, 368, 369, 84, 79, + 194, 195, 360, 360, 115, 370, 360, 360, + 200, 360, 371, 367, 372, 372, 84, 79, + 194, 195, 360, 360, 360, 370, 360, 360, + 200, 360, 367, 372, 372, 84, 79, 194, + 195, 360, 360, 360, 370, 360, 360, 200, + 360, 373, 360, 360, 360, 98, 374, 360, + 79, 194, 195, 360, 360, 360, 365, 360, + 373, 360, 375, 376, 377, 378, 84, 79, + 194, 195, 360, 360, 113, 379, 360, 360, + 200, 360, 380, 376, 381, 381, 84, 79, + 194, 195, 360, 360, 360, 379, 360, 360, + 200, 360, 376, 381, 381, 84, 79, 194, + 195, 360, 360, 360, 379, 360, 360, 200, + 360, 382, 360, 360, 360, 98, 383, 360, + 79, 194, 195, 360, 360, 360, 365, 360, + 382, 360, 384, 385, 386, 387, 84, 79, + 194, 195, 360, 360, 111, 388, 360, 360, + 200, 360, 389, 385, 390, 390, 84, 79, + 194, 195, 360, 360, 360, 388, 360, 360, + 200, 360, 385, 390, 390, 84, 79, 194, + 195, 360, 360, 360, 388, 360, 360, 200, + 360, 391, 360, 360, 360, 98, 392, 360, + 79, 194, 195, 360, 360, 360, 365, 360, + 391, 360, 393, 394, 395, 396, 84, 79, + 194, 195, 360, 360, 109, 397, 360, 360, + 200, 360, 398, 394, 399, 399, 84, 79, + 194, 195, 360, 360, 360, 397, 360, 360, + 200, 360, 394, 399, 399, 84, 79, 194, + 195, 360, 360, 360, 397, 360, 360, 200, + 360, 98, 400, 360, 79, 194, 195, 360, + 360, 360, 365, 360, 401, 401, 360, 79, + 194, 195, 360, 360, 360, 365, 360, 402, + 360, 360, 403, 194, 195, 360, 194, 195, + 360, 404, 360, 194, 405, 360, 194, 406, + 360, 194, 360, 402, 360, 360, 360, 194, + 195, 360, 407, 360, 408, 409, 360, 79, + 194, 195, 360, 360, 82, 360, 81, 360, + 401, 401, 360, 79, 194, 195, 360, 401, + 401, 360, 79, 194, 195, 360, 407, 360, + 401, 401, 360, 79, 194, 195, 360, 407, + 360, 408, 401, 360, 79, 194, 195, 360, + 360, 82, 360, 98, 360, 410, 410, 84, + 79, 194, 195, 360, 360, 360, 365, 360, + 411, 107, 412, 413, 88, 79, 194, 195, + 360, 360, 360, 365, 360, 107, 412, 413, + 88, 79, 194, 195, 360, 360, 360, 365, + 360, 412, 412, 88, 79, 194, 195, 360, + 360, 360, 365, 360, 414, 104, 415, 416, + 91, 79, 194, 195, 360, 360, 360, 365, + 360, 104, 415, 416, 91, 79, 194, 195, + 360, 360, 360, 365, 360, 415, 415, 91, + 79, 194, 195, 360, 360, 360, 365, 360, + 417, 101, 418, 419, 94, 79, 194, 195, + 360, 360, 360, 365, 360, 101, 418, 419, + 94, 79, 194, 195, 360, 360, 360, 365, + 360, 418, 418, 94, 79, 194, 195, 360, + 360, 360, 365, 360, 420, 98, 401, 421, + 360, 79, 194, 195, 360, 360, 360, 365, + 360, 98, 401, 421, 360, 79, 194, 195, + 360, 360, 360, 365, 360, 401, 422, 360, + 79, 194, 195, 360, 360, 360, 365, 360, + 98, 360, 401, 401, 360, 79, 194, 195, + 360, 360, 360, 365, 360, 80, 81, 360, + 360, 98, 400, 360, 79, 194, 195, 360, + 360, 360, 365, 360, 80, 360, 394, 399, + 399, 84, 79, 194, 195, 360, 360, 360, + 397, 360, 393, 394, 399, 399, 84, 79, + 194, 195, 360, 360, 360, 397, 360, 360, + 200, 360, 393, 394, 395, 399, 84, 79, + 194, 195, 360, 360, 109, 397, 360, 360, + 200, 360, 391, 360, 423, 360, 410, 410, + 84, 79, 194, 195, 360, 360, 360, 365, + 360, 391, 360, 391, 360, 360, 360, 401, + 401, 360, 79, 194, 195, 360, 360, 360, + 365, 360, 391, 360, 391, 360, 360, 360, + 401, 424, 360, 79, 194, 195, 360, 360, + 360, 365, 360, 391, 360, 391, 360, 423, + 360, 401, 401, 360, 79, 194, 195, 360, + 360, 360, 365, 360, 391, 360, 391, 81, + 360, 360, 98, 392, 360, 79, 194, 195, + 360, 360, 360, 365, 360, 391, 360, 384, + 385, 390, 390, 84, 79, 194, 195, 360, + 360, 360, 388, 360, 360, 200, 360, 384, + 385, 386, 390, 84, 79, 194, 195, 360, + 360, 111, 388, 360, 360, 200, 360, 382, + 360, 425, 360, 410, 410, 84, 79, 194, + 195, 360, 360, 360, 365, 360, 382, 360, + 382, 360, 360, 360, 401, 401, 360, 79, + 194, 195, 360, 360, 360, 365, 360, 382, + 360, 382, 360, 360, 360, 401, 426, 360, + 79, 194, 195, 360, 360, 360, 365, 360, + 382, 360, 382, 360, 425, 360, 401, 401, + 360, 79, 194, 195, 360, 360, 360, 365, + 360, 382, 360, 382, 81, 360, 360, 98, + 383, 360, 79, 194, 195, 360, 360, 360, + 365, 360, 382, 360, 375, 376, 381, 381, + 84, 79, 194, 195, 360, 360, 360, 379, + 360, 360, 200, 360, 375, 376, 377, 381, + 84, 79, 194, 195, 360, 360, 113, 379, + 360, 360, 200, 360, 373, 360, 427, 360, + 410, 410, 84, 79, 194, 195, 360, 360, + 360, 365, 360, 373, 360, 373, 360, 360, + 360, 401, 401, 360, 79, 194, 195, 360, + 360, 360, 365, 360, 373, 360, 373, 360, + 360, 360, 401, 428, 360, 79, 194, 195, + 360, 360, 360, 365, 360, 373, 360, 373, + 360, 427, 360, 401, 401, 360, 79, 194, + 195, 360, 360, 360, 365, 360, 373, 360, + 373, 81, 360, 360, 98, 374, 360, 79, + 194, 195, 360, 360, 360, 365, 360, 373, + 360, 366, 367, 372, 372, 84, 79, 194, + 195, 360, 360, 360, 370, 360, 360, 200, + 360, 366, 367, 368, 372, 84, 79, 194, + 195, 360, 360, 115, 370, 360, 360, 200, + 360, 363, 360, 429, 360, 410, 410, 84, + 79, 194, 195, 360, 360, 360, 365, 360, + 363, 360, 363, 360, 360, 360, 401, 401, + 360, 79, 194, 195, 360, 360, 360, 365, + 360, 363, 360, 363, 360, 360, 360, 401, + 430, 360, 79, 194, 195, 360, 360, 360, + 365, 360, 363, 360, 363, 360, 429, 360, + 401, 401, 360, 79, 194, 195, 360, 360, + 360, 365, 360, 363, 360, 363, 81, 360, + 360, 98, 364, 360, 79, 194, 195, 360, + 360, 360, 365, 360, 363, 360, 116, 83, + 83, 84, 79, 431, 431, 431, 431, 156, + 116, 431, 190, 191, 362, 362, 84, 79, + 194, 195, 360, 360, 360, 197, 360, 360, + 200, 360, 116, 83, 83, 84, 79, 431, + 431, 431, 431, 431, 116, 431, 433, 434, + 435, 436, 123, 118, 437, 438, 432, 432, + 155, 439, 432, 432, 440, 432, 441, 434, + 436, 436, 123, 118, 437, 438, 432, 432, + 432, 439, 432, 432, 440, 432, 434, 436, + 436, 123, 118, 437, 438, 432, 432, 432, + 439, 432, 432, 440, 432, 442, 432, 432, + 432, 136, 443, 432, 118, 437, 438, 432, + 432, 432, 444, 432, 442, 432, 445, 446, + 447, 448, 123, 118, 437, 438, 432, 432, + 153, 449, 432, 432, 440, 432, 450, 446, + 451, 451, 123, 118, 437, 438, 432, 432, + 432, 449, 432, 432, 440, 432, 446, 451, + 451, 123, 118, 437, 438, 432, 432, 432, + 449, 432, 432, 440, 432, 452, 432, 432, + 432, 136, 453, 432, 118, 437, 438, 432, + 432, 432, 444, 432, 452, 432, 454, 455, + 456, 457, 123, 118, 437, 438, 432, 432, + 151, 458, 432, 432, 440, 432, 459, 455, + 460, 460, 123, 118, 437, 438, 432, 432, + 432, 458, 432, 432, 440, 432, 455, 460, + 460, 123, 118, 437, 438, 432, 432, 432, + 458, 432, 432, 440, 432, 461, 432, 432, + 432, 136, 462, 432, 118, 437, 438, 432, + 432, 432, 444, 432, 461, 432, 463, 464, + 465, 466, 123, 118, 437, 438, 432, 432, + 149, 467, 432, 432, 440, 432, 468, 464, + 469, 469, 123, 118, 437, 438, 432, 432, + 432, 467, 432, 432, 440, 432, 464, 469, + 469, 123, 118, 437, 438, 432, 432, 432, + 467, 432, 432, 440, 432, 470, 432, 432, + 432, 136, 471, 432, 118, 437, 438, 432, + 432, 432, 444, 432, 470, 432, 472, 473, + 474, 475, 123, 118, 437, 438, 432, 432, + 147, 476, 432, 432, 440, 432, 477, 473, + 478, 478, 123, 118, 437, 438, 432, 432, + 432, 476, 432, 432, 440, 432, 473, 478, + 478, 123, 118, 437, 438, 432, 432, 432, + 476, 432, 432, 440, 432, 136, 479, 432, + 118, 437, 438, 432, 432, 432, 444, 432, + 480, 480, 432, 118, 437, 438, 432, 432, + 432, 444, 432, 481, 432, 432, 482, 437, + 438, 432, 437, 438, 432, 483, 432, 437, + 484, 432, 437, 485, 432, 437, 432, 481, + 432, 432, 432, 437, 438, 432, 486, 432, + 487, 488, 432, 118, 437, 438, 432, 432, + 121, 432, 120, 432, 480, 480, 432, 118, + 437, 438, 432, 480, 480, 432, 118, 437, + 438, 432, 486, 432, 480, 480, 432, 118, + 437, 438, 432, 486, 432, 487, 480, 432, + 118, 437, 438, 432, 432, 121, 432, 136, + 432, 489, 489, 123, 118, 437, 438, 432, + 432, 432, 444, 432, 490, 145, 491, 492, + 126, 118, 437, 438, 432, 432, 432, 444, + 432, 145, 491, 492, 126, 118, 437, 438, + 432, 432, 432, 444, 432, 491, 491, 126, + 118, 437, 438, 432, 432, 432, 444, 432, + 493, 142, 494, 495, 129, 118, 437, 438, + 432, 432, 432, 444, 432, 142, 494, 495, + 129, 118, 437, 438, 432, 432, 432, 444, + 432, 494, 494, 129, 118, 437, 438, 432, + 432, 432, 444, 432, 496, 139, 497, 498, + 132, 118, 437, 438, 432, 432, 432, 444, + 432, 139, 497, 498, 132, 118, 437, 438, + 432, 432, 432, 444, 432, 497, 497, 132, + 118, 437, 438, 432, 432, 432, 444, 432, + 499, 136, 480, 500, 432, 118, 437, 438, + 432, 432, 432, 444, 432, 136, 480, 500, + 432, 118, 437, 438, 432, 432, 432, 444, + 432, 480, 501, 432, 118, 437, 438, 432, + 432, 432, 444, 432, 136, 432, 480, 480, + 432, 118, 437, 438, 432, 432, 432, 444, + 432, 119, 120, 432, 432, 136, 479, 432, + 118, 437, 438, 432, 432, 432, 444, 432, + 119, 432, 473, 478, 478, 123, 118, 437, + 438, 432, 432, 432, 476, 432, 472, 473, + 478, 478, 123, 118, 437, 438, 432, 432, + 432, 476, 432, 432, 440, 432, 472, 473, + 474, 478, 123, 118, 437, 438, 432, 432, + 147, 476, 432, 432, 440, 432, 470, 432, + 502, 432, 489, 489, 123, 118, 437, 438, + 432, 432, 432, 444, 432, 470, 432, 470, + 432, 432, 432, 480, 480, 432, 118, 437, + 438, 432, 432, 432, 444, 432, 470, 432, + 470, 432, 432, 432, 480, 503, 432, 118, + 437, 438, 432, 432, 432, 444, 432, 470, + 432, 470, 432, 502, 432, 480, 480, 432, + 118, 437, 438, 432, 432, 432, 444, 432, + 470, 432, 470, 120, 432, 432, 136, 471, + 432, 118, 437, 438, 432, 432, 432, 444, + 432, 470, 432, 463, 464, 469, 469, 123, + 118, 437, 438, 432, 432, 432, 467, 432, + 432, 440, 432, 463, 464, 465, 469, 123, + 118, 437, 438, 432, 432, 149, 467, 432, + 432, 440, 432, 461, 432, 504, 432, 489, + 489, 123, 118, 437, 438, 432, 432, 432, + 444, 432, 461, 432, 461, 432, 432, 432, + 480, 480, 432, 118, 437, 438, 432, 432, + 432, 444, 432, 461, 432, 461, 432, 432, + 432, 480, 505, 432, 118, 437, 438, 432, + 432, 432, 444, 432, 461, 432, 461, 432, + 504, 432, 480, 480, 432, 118, 437, 438, + 432, 432, 432, 444, 432, 461, 432, 461, + 120, 432, 432, 136, 462, 432, 118, 437, + 438, 432, 432, 432, 444, 432, 461, 432, + 454, 455, 460, 460, 123, 118, 437, 438, + 432, 432, 432, 458, 432, 432, 440, 432, + 454, 455, 456, 460, 123, 118, 437, 438, + 432, 432, 151, 458, 432, 432, 440, 432, + 452, 432, 506, 432, 489, 489, 123, 118, + 437, 438, 432, 432, 432, 444, 432, 452, + 432, 452, 432, 432, 432, 480, 480, 432, + 118, 437, 438, 432, 432, 432, 444, 432, + 452, 432, 452, 432, 432, 432, 480, 507, + 432, 118, 437, 438, 432, 432, 432, 444, + 432, 452, 432, 452, 432, 506, 432, 480, + 480, 432, 118, 437, 438, 432, 432, 432, + 444, 432, 452, 432, 452, 120, 432, 432, + 136, 453, 432, 118, 437, 438, 432, 432, + 432, 444, 432, 452, 432, 445, 446, 451, + 451, 123, 118, 437, 438, 432, 432, 432, + 449, 432, 432, 440, 432, 445, 446, 447, + 451, 123, 118, 437, 438, 432, 432, 153, + 449, 432, 432, 440, 432, 442, 432, 508, + 432, 489, 489, 123, 118, 437, 438, 432, + 432, 432, 444, 432, 442, 432, 442, 432, + 432, 432, 480, 480, 432, 118, 437, 438, + 432, 432, 432, 444, 432, 442, 432, 442, + 432, 432, 432, 480, 509, 432, 118, 437, + 438, 432, 432, 432, 444, 432, 442, 432, + 442, 432, 508, 432, 480, 480, 432, 118, + 437, 438, 432, 432, 432, 444, 432, 442, + 432, 442, 120, 432, 432, 136, 443, 432, + 118, 437, 438, 432, 432, 432, 444, 432, + 442, 432, 433, 434, 436, 436, 123, 118, + 437, 438, 432, 432, 432, 439, 432, 432, + 440, 432, 188, 189, 190, 191, 510, 362, + 84, 79, 194, 195, 196, 196, 156, 197, + 360, 188, 200, 360, 203, 511, 205, 206, + 6, 1, 207, 208, 202, 202, 38, 209, + 202, 202, 210, 202, 213, 189, 190, 191, + 512, 513, 84, 157, 514, 515, 202, 196, + 156, 516, 202, 213, 200, 202, 116, 517, + 517, 84, 157, 207, 208, 202, 202, 156, + 518, 202, 519, 202, 202, 520, 514, 515, + 202, 514, 515, 202, 254, 202, 514, 521, + 202, 514, 522, 202, 514, 202, 519, 202, + 202, 202, 514, 515, 202, 523, 3, 360, + 360, 401, 430, 360, 79, 194, 195, 360, + 360, 360, 365, 360, 523, 360, 524, 367, + 525, 526, 84, 157, 514, 515, 202, 202, + 158, 370, 202, 202, 200, 202, 527, 367, + 528, 528, 84, 157, 514, 515, 202, 202, + 202, 370, 202, 202, 200, 202, 367, 528, + 528, 84, 157, 514, 515, 202, 202, 202, + 370, 202, 202, 200, 202, 524, 367, 528, + 528, 84, 157, 514, 515, 202, 202, 202, + 370, 202, 202, 200, 202, 524, 367, 525, + 528, 84, 157, 514, 515, 202, 202, 158, + 370, 202, 202, 200, 202, 213, 202, 279, + 116, 529, 529, 160, 157, 207, 208, 202, + 202, 202, 518, 202, 213, 202, 530, 184, + 531, 532, 162, 157, 514, 515, 202, 202, + 202, 533, 202, 184, 531, 532, 162, 157, + 514, 515, 202, 202, 202, 533, 202, 531, + 531, 162, 157, 514, 515, 202, 202, 202, + 533, 202, 534, 181, 535, 536, 165, 157, + 514, 515, 202, 202, 202, 533, 202, 181, + 535, 536, 165, 157, 514, 515, 202, 202, + 202, 533, 202, 535, 535, 165, 157, 514, + 515, 202, 202, 202, 533, 202, 537, 178, + 538, 539, 168, 157, 514, 515, 202, 202, + 202, 533, 202, 178, 538, 539, 168, 157, + 514, 515, 202, 202, 202, 533, 202, 538, + 538, 168, 157, 514, 515, 202, 202, 202, + 533, 202, 540, 175, 541, 542, 202, 157, + 514, 515, 202, 202, 202, 533, 202, 175, + 541, 542, 202, 157, 514, 515, 202, 202, + 202, 533, 202, 541, 541, 202, 157, 514, + 515, 202, 202, 202, 533, 202, 543, 202, + 544, 545, 202, 157, 514, 515, 202, 202, + 172, 202, 171, 202, 541, 541, 202, 157, + 514, 515, 202, 541, 541, 202, 157, 514, + 515, 202, 543, 202, 541, 541, 202, 157, + 514, 515, 202, 543, 202, 544, 541, 202, + 157, 514, 515, 202, 202, 172, 202, 523, + 171, 360, 360, 98, 364, 360, 79, 194, + 195, 360, 360, 360, 365, 360, 523, 360, + 547, 546, 548, 548, 546, 186, 549, 550, + 546, 548, 548, 546, 186, 549, 550, 546, + 551, 546, 546, 552, 549, 550, 546, 549, + 550, 546, 553, 546, 549, 554, 546, 549, + 555, 546, 549, 546, 551, 546, 546, 546, 549, 550, 546, 0 }; static const short _indic_syllable_machine_trans_targs[] = { - 178, 200, 207, 209, 210, 4, 213, 5, - 7, 216, 8, 10, 219, 11, 13, 222, - 14, 16, 17, 199, 19, 20, 221, 22, - 23, 218, 25, 26, 215, 224, 228, 232, - 235, 239, 242, 246, 249, 253, 256, 178, - 279, 286, 288, 289, 41, 292, 42, 44, - 295, 45, 47, 298, 48, 50, 301, 51, - 53, 54, 278, 56, 57, 300, 59, 60, - 297, 62, 63, 294, 303, 307, 311, 314, - 318, 321, 325, 328, 332, 336, 178, 357, - 364, 366, 367, 78, 370, 178, 79, 81, - 373, 82, 84, 376, 85, 87, 379, 88, - 90, 91, 356, 93, 94, 378, 96, 97, - 375, 99, 100, 372, 381, 385, 389, 392, - 396, 399, 403, 406, 410, 178, 437, 444, - 446, 447, 114, 450, 115, 117, 453, 118, - 120, 456, 121, 123, 459, 124, 126, 127, - 436, 129, 130, 458, 132, 133, 455, 135, - 136, 452, 461, 465, 469, 472, 476, 479, - 483, 486, 490, 493, 414, 498, 509, 152, - 512, 154, 515, 155, 157, 518, 158, 160, - 521, 161, 524, 526, 527, 166, 167, 523, - 169, 170, 520, 172, 173, 517, 175, 176, - 514, 178, 532, 178, 179, 258, 337, 339, - 413, 415, 359, 360, 416, 412, 494, 495, - 384, 530, 178, 180, 182, 36, 257, 202, - 203, 255, 227, 181, 35, 183, 251, 1, - 184, 186, 34, 250, 248, 185, 33, 187, - 244, 188, 190, 32, 243, 241, 189, 31, - 191, 237, 192, 194, 30, 236, 234, 193, - 29, 195, 230, 196, 198, 28, 229, 226, - 197, 27, 212, 0, 201, 206, 178, 204, - 205, 208, 2, 211, 3, 214, 6, 24, - 217, 9, 21, 220, 12, 18, 223, 15, - 225, 231, 233, 238, 240, 245, 247, 252, - 254, 178, 259, 261, 73, 334, 281, 282, - 335, 306, 260, 72, 262, 330, 38, 263, - 265, 71, 329, 327, 264, 70, 266, 323, - 267, 269, 69, 322, 320, 268, 68, 270, - 316, 271, 273, 67, 315, 313, 272, 66, - 274, 309, 275, 277, 65, 308, 305, 276, - 64, 291, 37, 280, 285, 178, 283, 284, - 287, 39, 290, 40, 293, 43, 61, 296, - 46, 58, 299, 49, 55, 302, 52, 304, - 310, 312, 317, 319, 324, 326, 331, 333, - 178, 338, 109, 340, 408, 75, 341, 343, - 108, 407, 405, 342, 107, 344, 401, 345, - 347, 106, 400, 398, 346, 105, 348, 394, - 349, 351, 104, 393, 391, 350, 103, 352, - 387, 353, 355, 102, 386, 383, 354, 101, - 369, 74, 358, 363, 178, 361, 362, 365, - 76, 368, 77, 371, 80, 98, 374, 83, - 95, 377, 86, 92, 380, 89, 382, 388, - 390, 395, 397, 402, 404, 409, 411, 178, - 178, 417, 419, 146, 145, 439, 440, 492, - 464, 418, 420, 488, 111, 421, 423, 144, - 487, 485, 422, 143, 424, 481, 425, 427, - 142, 480, 478, 426, 141, 428, 474, 429, - 431, 140, 473, 471, 430, 139, 432, 467, - 433, 435, 138, 466, 463, 434, 137, 449, - 110, 438, 443, 178, 441, 442, 445, 112, - 448, 113, 451, 116, 134, 454, 119, 131, - 457, 122, 128, 460, 125, 462, 468, 470, - 475, 477, 482, 484, 489, 491, 147, 496, - 497, 511, 500, 501, 529, 148, 505, 499, - 504, 502, 503, 506, 507, 150, 510, 508, - 149, 151, 513, 153, 174, 163, 516, 156, - 171, 519, 159, 168, 522, 162, 165, 525, - 164, 528, 178, 531, 177, 534, 535, 533, + 178, 200, 207, 209, 210, 4, 213, 5, + 7, 216, 8, 10, 219, 11, 13, 222, + 14, 16, 17, 199, 19, 20, 221, 22, + 23, 218, 25, 26, 215, 224, 228, 232, + 235, 239, 242, 246, 249, 253, 256, 178, + 279, 286, 288, 289, 41, 292, 42, 44, + 295, 45, 47, 298, 48, 50, 301, 51, + 53, 54, 278, 56, 57, 300, 59, 60, + 297, 62, 63, 294, 303, 307, 311, 314, + 318, 321, 325, 328, 332, 336, 178, 357, + 364, 366, 367, 78, 370, 178, 79, 81, + 373, 82, 84, 376, 85, 87, 379, 88, + 90, 91, 356, 93, 94, 378, 96, 97, + 375, 99, 100, 372, 381, 385, 389, 392, + 396, 399, 403, 406, 410, 178, 437, 444, + 446, 447, 114, 450, 115, 117, 453, 118, + 120, 456, 121, 123, 459, 124, 126, 127, + 436, 129, 130, 458, 132, 133, 455, 135, + 136, 452, 461, 465, 469, 472, 476, 479, + 483, 486, 490, 493, 414, 498, 509, 152, + 512, 154, 515, 155, 157, 518, 158, 160, + 521, 161, 524, 526, 527, 166, 167, 523, + 169, 170, 520, 172, 173, 517, 175, 176, + 514, 178, 532, 178, 179, 258, 337, 339, + 413, 415, 359, 360, 416, 412, 494, 495, + 384, 530, 178, 180, 182, 36, 257, 202, + 203, 255, 227, 181, 35, 183, 251, 1, + 184, 186, 34, 250, 248, 185, 33, 187, + 244, 188, 190, 32, 243, 241, 189, 31, + 191, 237, 192, 194, 30, 236, 234, 193, + 29, 195, 230, 196, 198, 28, 229, 226, + 197, 27, 212, 0, 201, 206, 178, 204, + 205, 208, 2, 211, 3, 214, 6, 24, + 217, 9, 21, 220, 12, 18, 223, 15, + 225, 231, 233, 238, 240, 245, 247, 252, + 254, 178, 259, 261, 73, 334, 281, 282, + 335, 306, 260, 72, 262, 330, 38, 263, + 265, 71, 329, 327, 264, 70, 266, 323, + 267, 269, 69, 322, 320, 268, 68, 270, + 316, 271, 273, 67, 315, 313, 272, 66, + 274, 309, 275, 277, 65, 308, 305, 276, + 64, 291, 37, 280, 285, 178, 283, 284, + 287, 39, 290, 40, 293, 43, 61, 296, + 46, 58, 299, 49, 55, 302, 52, 304, + 310, 312, 317, 319, 324, 326, 331, 333, + 178, 338, 109, 340, 408, 75, 341, 343, + 108, 407, 405, 342, 107, 344, 401, 345, + 347, 106, 400, 398, 346, 105, 348, 394, + 349, 351, 104, 393, 391, 350, 103, 352, + 387, 353, 355, 102, 386, 383, 354, 101, + 369, 74, 358, 363, 178, 361, 362, 365, + 76, 368, 77, 371, 80, 98, 374, 83, + 95, 377, 86, 92, 380, 89, 382, 388, + 390, 395, 397, 402, 404, 409, 411, 178, + 178, 417, 419, 146, 145, 439, 440, 492, + 464, 418, 420, 488, 111, 421, 423, 144, + 487, 485, 422, 143, 424, 481, 425, 427, + 142, 480, 478, 426, 141, 428, 474, 429, + 431, 140, 473, 471, 430, 139, 432, 467, + 433, 435, 138, 466, 463, 434, 137, 449, + 110, 438, 443, 178, 441, 442, 445, 112, + 448, 113, 451, 116, 134, 454, 119, 131, + 457, 122, 128, 460, 125, 462, 468, 470, + 475, 477, 482, 484, 489, 491, 147, 496, + 497, 511, 500, 501, 529, 148, 505, 499, + 504, 502, 503, 506, 507, 150, 510, 508, + 149, 151, 513, 153, 174, 163, 516, 156, + 171, 519, 159, 168, 522, 162, 165, 525, + 164, 528, 178, 531, 177, 534, 535, 533, 538, 178, 536, 537 }; static const char _indic_syllable_machine_trans_actions[] = { - 1, 0, 2, 2, 2, 0, 2, 0, - 0, 2, 0, 0, 2, 0, 0, 2, - 0, 0, 0, 2, 0, 0, 2, 0, - 0, 2, 0, 0, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 3, - 0, 2, 2, 2, 0, 2, 0, 0, - 2, 0, 0, 2, 0, 0, 2, 0, - 0, 0, 2, 0, 0, 2, 0, 0, - 2, 0, 0, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 4, 0, - 2, 2, 2, 0, 2, 5, 0, 0, - 2, 0, 0, 2, 0, 0, 2, 0, - 0, 0, 2, 0, 0, 2, 0, 0, - 2, 0, 0, 2, 2, 6, 2, 6, - 2, 6, 2, 6, 2, 7, 0, 2, - 2, 2, 0, 2, 0, 0, 2, 0, - 0, 2, 0, 0, 2, 0, 0, 0, - 2, 0, 0, 2, 0, 0, 2, 0, - 0, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 6, 0, 8, 0, - 2, 0, 2, 0, 0, 2, 0, 0, - 2, 0, 2, 2, 2, 0, 0, 2, - 0, 0, 2, 0, 0, 2, 0, 0, - 2, 9, 0, 12, 2, 2, 6, 2, - 13, 13, 0, 0, 2, 2, 6, 2, - 6, 2, 14, 2, 2, 0, 2, 0, - 0, 2, 2, 2, 0, 2, 2, 0, - 2, 2, 0, 2, 2, 2, 0, 2, - 2, 2, 2, 0, 2, 2, 2, 0, - 2, 2, 2, 2, 0, 2, 2, 2, - 0, 2, 2, 2, 2, 0, 2, 2, - 2, 0, 2, 0, 0, 0, 15, 0, - 0, 2, 0, 2, 0, 2, 0, 0, - 2, 0, 0, 2, 0, 0, 2, 0, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 16, 2, 2, 0, 2, 0, 0, - 2, 2, 2, 0, 2, 2, 0, 2, - 2, 0, 2, 2, 2, 0, 2, 2, - 2, 2, 0, 2, 2, 2, 0, 2, - 2, 2, 2, 0, 2, 2, 2, 0, - 2, 2, 2, 2, 0, 2, 2, 2, - 0, 2, 0, 0, 0, 17, 0, 0, - 2, 0, 2, 0, 2, 0, 0, 2, - 0, 0, 2, 0, 0, 2, 0, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 18, 6, 0, 6, 6, 0, 6, 2, - 0, 6, 2, 6, 0, 6, 6, 6, - 2, 0, 6, 2, 6, 0, 6, 6, - 6, 2, 0, 6, 2, 6, 0, 6, - 6, 6, 2, 0, 6, 2, 6, 0, - 6, 0, 0, 0, 19, 0, 0, 2, - 0, 2, 0, 2, 0, 0, 2, 0, - 0, 2, 0, 0, 2, 0, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 20, - 21, 2, 2, 0, 0, 0, 0, 2, - 2, 2, 2, 2, 0, 2, 2, 0, - 2, 2, 2, 0, 2, 2, 2, 2, - 0, 2, 2, 2, 0, 2, 2, 2, - 2, 0, 2, 2, 2, 0, 2, 2, - 2, 2, 0, 2, 2, 2, 0, 2, - 0, 0, 0, 22, 0, 0, 2, 0, - 2, 0, 2, 0, 0, 2, 0, 0, - 2, 0, 0, 2, 0, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 0, 0, - 8, 2, 0, 0, 2, 0, 2, 0, - 0, 0, 0, 8, 8, 0, 8, 8, - 0, 0, 2, 0, 0, 0, 2, 0, - 0, 2, 0, 0, 2, 0, 0, 2, - 0, 2, 23, 2, 0, 0, 0, 0, + 1, 0, 2, 2, 2, 0, 2, 0, + 0, 2, 0, 0, 2, 0, 0, 2, + 0, 0, 0, 2, 0, 0, 2, 0, + 0, 2, 0, 0, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 3, + 0, 2, 2, 2, 0, 2, 0, 0, + 2, 0, 0, 2, 0, 0, 2, 0, + 0, 0, 2, 0, 0, 2, 0, 0, + 2, 0, 0, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 4, 0, + 2, 2, 2, 0, 2, 5, 0, 0, + 2, 0, 0, 2, 0, 0, 2, 0, + 0, 0, 2, 0, 0, 2, 0, 0, + 2, 0, 0, 2, 2, 6, 2, 6, + 2, 6, 2, 6, 2, 7, 0, 2, + 2, 2, 0, 2, 0, 0, 2, 0, + 0, 2, 0, 0, 2, 0, 0, 0, + 2, 0, 0, 2, 0, 0, 2, 0, + 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 6, 0, 8, 0, + 2, 0, 2, 0, 0, 2, 0, 0, + 2, 0, 2, 2, 2, 0, 0, 2, + 0, 0, 2, 0, 0, 2, 0, 0, + 2, 9, 0, 12, 2, 2, 6, 2, + 13, 13, 0, 0, 2, 2, 6, 2, + 6, 2, 14, 2, 2, 0, 2, 0, + 0, 2, 2, 2, 0, 2, 2, 0, + 2, 2, 0, 2, 2, 2, 0, 2, + 2, 2, 2, 0, 2, 2, 2, 0, + 2, 2, 2, 2, 0, 2, 2, 2, + 0, 2, 2, 2, 2, 0, 2, 2, + 2, 0, 2, 0, 0, 0, 15, 0, + 0, 2, 0, 2, 0, 2, 0, 0, + 2, 0, 0, 2, 0, 0, 2, 0, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 16, 2, 2, 0, 2, 0, 0, + 2, 2, 2, 0, 2, 2, 0, 2, + 2, 0, 2, 2, 2, 0, 2, 2, + 2, 2, 0, 2, 2, 2, 0, 2, + 2, 2, 2, 0, 2, 2, 2, 0, + 2, 2, 2, 2, 0, 2, 2, 2, + 0, 2, 0, 0, 0, 17, 0, 0, + 2, 0, 2, 0, 2, 0, 0, 2, + 0, 0, 2, 0, 0, 2, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 18, 6, 0, 6, 6, 0, 6, 2, + 0, 6, 2, 6, 0, 6, 6, 6, + 2, 0, 6, 2, 6, 0, 6, 6, + 6, 2, 0, 6, 2, 6, 0, 6, + 6, 6, 2, 0, 6, 2, 6, 0, + 6, 0, 0, 0, 19, 0, 0, 2, + 0, 2, 0, 2, 0, 0, 2, 0, + 0, 2, 0, 0, 2, 0, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 20, + 21, 2, 2, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 0, 2, 2, 0, + 2, 2, 2, 0, 2, 2, 2, 2, + 0, 2, 2, 2, 0, 2, 2, 2, + 2, 0, 2, 2, 2, 0, 2, 2, + 2, 2, 0, 2, 2, 2, 0, 2, + 0, 0, 0, 22, 0, 0, 2, 0, + 2, 0, 2, 0, 0, 2, 0, 0, + 2, 0, 0, 2, 0, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 0, + 8, 2, 0, 0, 2, 0, 2, 0, + 0, 0, 0, 8, 8, 0, 8, 8, + 0, 0, 2, 0, 0, 0, 2, 0, + 0, 2, 0, 0, 2, 0, 0, 2, + 0, 2, 23, 2, 0, 0, 0, 0, 0, 24, 0, 0 }; static const char _indic_syllable_machine_to_state_actions[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 10, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 10, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const char _indic_syllable_machine_from_state_actions[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 11, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const short _indic_syllable_machine_eof_trans[] = { - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 79, 79, 79, 79, 86, 86, - 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 79, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 186, 0, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 282, 282, 282, 282, 282, 282, 282, - 282, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 432, 361, 432, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 361, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 361, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, - 203, 361, 547, 547, 547, 547, 547, 547, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 79, 79, 79, 79, 86, 86, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 79, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 186, 0, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, + 282, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 361, 361, 361, + 361, 361, 361, 361, 361, 432, 361, 432, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 433, 433, + 433, 433, 433, 433, 433, 433, 361, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 361, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, + 203, 361, 547, 547, 547, 547, 547, 547, 547, 547, 547 }; @@ -1377,7 +1377,7 @@ find_syllables (hb_buffer_t *buffer) unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; int cs; hb_glyph_info_t *info = buffer->info; - + #line 1382 "hb-ot-shape-complex-indic-machine.hh" { cs = indic_syllable_machine_start; @@ -1394,7 +1394,7 @@ find_syllables (hb_buffer_t *buffer) unsigned int last = 0; unsigned int syllable_serial = 1; - + #line 1399 "hb-ot-shape-complex-indic-machine.hh" { int _slen; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic.cc index 6486e84f5d9..de0d177ba2e 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-indic.cc @@ -1713,33 +1713,28 @@ decompose_indic (const hb_ot_shape_normalize_context_t *c, switch (ab) { /* Don't decompose these. */ - case 0x0931u : return false; - case 0x0B94u : return false; + case 0x0931u : return false; /* DEVANAGARI LETTER RRA */ + case 0x0B94u : return false; /* TAMIL LETTER AU */ /* * Decompose split matras that don't have Unicode decompositions. */ - case 0x0F77u : *a = 0x0FB2u; *b= 0x0F81u; return true; - case 0x0F79u : *a = 0x0FB3u; *b= 0x0F81u; return true; + /* Khmer */ case 0x17BEu : *a = 0x17C1u; *b= 0x17BEu; return true; case 0x17BFu : *a = 0x17C1u; *b= 0x17BFu; return true; case 0x17C0u : *a = 0x17C1u; *b= 0x17C0u; return true; case 0x17C4u : *a = 0x17C1u; *b= 0x17C4u; return true; case 0x17C5u : *a = 0x17C1u; *b= 0x17C5u; return true; - case 0x1925u : *a = 0x1920u; *b= 0x1923u; return true; - case 0x1926u : *a = 0x1920u; *b= 0x1924u; return true; - case 0x1B3Cu : *a = 0x1B42u; *b= 0x1B3Cu; return true; - case 0x1112Eu : *a = 0x11127u; *b= 0x11131u; return true; - case 0x1112Fu : *a = 0x11127u; *b= 0x11132u; return true; + #if 0 + /* Gujarati */ /* This one has no decomposition in Unicode, but needs no decomposition either. */ /* case 0x0AC9u : return false; */ + + /* Oriya */ case 0x0B57u : *a = no decomp, -> RIGHT; return true; - case 0x1C29u : *a = no decomp, -> LEFT; return true; - case 0xA9C0u : *a = no decomp, -> RIGHT; return true; - case 0x111BuF : *a = no decomp, -> ABOVE; return true; #endif } @@ -1819,6 +1814,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic = decompose_indic, compose_indic, setup_masks_indic, + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, false, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar-machine.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar-machine.hh index c16b4fda39e..e2e91e73c2f 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar-machine.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar-machine.hh @@ -34,223 +34,223 @@ #line 36 "../../src/hb-ot-shape-complex-myanmar-machine.hh.tmp" static const unsigned char _myanmar_syllable_machine_trans_keys[] = { - 1u, 31u, 3u, 30u, 5u, 29u, 5u, 8u, 5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u, - 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 1u, 16u, 3u, 29u, 3u, 29u, 3u, 29u, - 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 5u, 29u, 5u, 8u, - 5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, - 3u, 30u, 3u, 29u, 1u, 30u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, + 1u, 31u, 3u, 30u, 5u, 29u, 5u, 8u, 5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u, + 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 1u, 16u, 3u, 29u, 3u, 29u, 3u, 29u, + 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 5u, 29u, 5u, 8u, + 5u, 29u, 3u, 25u, 5u, 25u, 5u, 25u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, + 3u, 30u, 3u, 29u, 1u, 30u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 3u, 29u, 8u, 8u, 0 }; static const char _myanmar_syllable_machine_key_spans[] = { - 31, 28, 25, 4, 25, 23, 21, 21, - 27, 27, 27, 27, 16, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 25, 4, - 25, 23, 21, 21, 27, 27, 27, 27, - 28, 27, 30, 27, 27, 27, 27, 27, + 31, 28, 25, 4, 25, 23, 21, 21, + 27, 27, 27, 27, 16, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 25, 4, + 25, 23, 21, 21, 27, 27, 27, 27, + 28, 27, 30, 27, 27, 27, 27, 27, 27, 27, 27, 27, 1 }; static const short _myanmar_syllable_machine_index_offsets[] = { - 0, 32, 61, 87, 92, 118, 142, 164, - 186, 214, 242, 270, 298, 315, 343, 371, - 399, 427, 455, 483, 511, 539, 567, 593, - 598, 624, 648, 670, 692, 720, 748, 776, - 804, 833, 861, 892, 920, 948, 976, 1004, + 0, 32, 61, 87, 92, 118, 142, 164, + 186, 214, 242, 270, 298, 315, 343, 371, + 399, 427, 455, 483, 511, 539, 567, 593, + 598, 624, 648, 670, 692, 720, 748, 776, + 804, 833, 861, 892, 920, 948, 976, 1004, 1032, 1060, 1088, 1116, 1144 }; static const char _myanmar_syllable_machine_indicies[] = { - 1, 1, 2, 3, 4, 4, 0, 5, - 0, 6, 1, 0, 0, 0, 0, 7, - 0, 8, 1, 0, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 0, - 21, 22, 23, 23, 20, 24, 20, 25, - 20, 20, 20, 20, 20, 20, 20, 26, - 20, 20, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 20, 23, 23, 20, - 24, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 37, 20, 20, 20, 20, 20, - 20, 31, 20, 20, 20, 35, 20, 23, - 23, 20, 24, 20, 23, 23, 20, 24, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 31, 20, 20, 20, 35, 20, 38, 20, - 23, 23, 20, 24, 20, 31, 20, 20, - 20, 20, 20, 20, 20, 39, 20, 20, - 20, 20, 20, 20, 31, 20, 23, 23, - 20, 24, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 39, 20, 20, 20, 20, - 20, 20, 31, 20, 23, 23, 20, 24, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 31, 20, 21, 20, 23, 23, 20, 24, - 20, 25, 20, 20, 20, 20, 20, 20, - 20, 40, 20, 20, 40, 20, 20, 20, - 31, 41, 20, 20, 35, 20, 21, 20, - 23, 23, 20, 24, 20, 25, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 31, 20, 20, 20, - 35, 20, 21, 20, 23, 23, 20, 24, - 20, 25, 20, 20, 20, 20, 20, 20, - 20, 40, 20, 20, 20, 20, 20, 20, - 31, 41, 20, 20, 35, 20, 21, 20, - 23, 23, 20, 24, 20, 25, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 31, 41, 20, 20, - 35, 20, 1, 1, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 1, 20, 21, 20, 23, 23, 20, - 24, 20, 25, 20, 20, 20, 20, 20, - 20, 20, 26, 20, 20, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 20, 21, - 20, 23, 23, 20, 24, 20, 25, 20, - 20, 20, 20, 20, 20, 20, 34, 20, - 20, 20, 20, 20, 20, 31, 32, 33, - 34, 35, 20, 21, 20, 23, 23, 20, - 24, 20, 25, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 31, 32, 33, 34, 35, 20, 21, - 20, 23, 23, 20, 24, 20, 25, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 31, 32, 33, - 20, 35, 20, 21, 20, 23, 23, 20, - 24, 20, 25, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 31, 20, 33, 20, 35, 20, 21, - 20, 23, 23, 20, 24, 20, 25, 20, - 20, 20, 20, 20, 20, 20, 34, 20, - 20, 27, 20, 29, 20, 31, 32, 33, - 34, 35, 20, 21, 20, 23, 23, 20, - 24, 20, 25, 20, 20, 20, 20, 20, - 20, 20, 34, 20, 20, 27, 20, 20, - 20, 31, 32, 33, 34, 35, 20, 21, - 20, 23, 23, 20, 24, 20, 25, 20, - 20, 20, 20, 20, 20, 20, 34, 20, - 20, 27, 28, 29, 20, 31, 32, 33, - 34, 35, 20, 21, 22, 23, 23, 20, - 24, 20, 25, 20, 20, 20, 20, 20, - 20, 20, 26, 20, 20, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 20, 3, - 3, 42, 5, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 43, 42, 42, 42, - 42, 42, 42, 13, 42, 42, 42, 17, - 42, 3, 3, 42, 5, 42, 3, 3, - 42, 5, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 13, 42, 42, 42, 17, 42, - 44, 42, 3, 3, 42, 5, 42, 13, - 42, 42, 42, 42, 42, 42, 42, 45, - 42, 42, 42, 42, 42, 42, 13, 42, - 3, 3, 42, 5, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 45, 42, 42, - 42, 42, 42, 42, 13, 42, 3, 3, - 42, 5, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 13, 42, 2, 42, 3, 3, - 42, 5, 42, 6, 42, 42, 42, 42, - 42, 42, 42, 46, 42, 42, 46, 42, - 42, 42, 13, 47, 42, 42, 17, 42, - 2, 42, 3, 3, 42, 5, 42, 6, - 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 13, 42, - 42, 42, 17, 42, 2, 42, 3, 3, - 42, 5, 42, 6, 42, 42, 42, 42, - 42, 42, 42, 46, 42, 42, 42, 42, - 42, 42, 13, 47, 42, 42, 17, 42, - 2, 42, 3, 3, 42, 5, 42, 6, - 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 13, 47, - 42, 42, 17, 42, 21, 22, 23, 23, - 20, 24, 20, 25, 20, 20, 20, 20, - 20, 20, 20, 48, 20, 20, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, - 20, 21, 49, 23, 23, 20, 24, 20, - 25, 20, 20, 20, 20, 20, 20, 20, - 26, 20, 20, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 20, 1, 1, 2, - 3, 3, 3, 42, 5, 42, 6, 1, - 42, 42, 42, 42, 1, 42, 8, 1, - 42, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 42, 2, 42, 3, 3, - 42, 5, 42, 6, 42, 42, 42, 42, - 42, 42, 42, 8, 42, 42, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 42, - 2, 42, 3, 3, 42, 5, 42, 6, - 42, 42, 42, 42, 42, 42, 42, 16, - 42, 42, 42, 42, 42, 42, 13, 14, - 15, 16, 17, 42, 2, 42, 3, 3, - 42, 5, 42, 6, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 13, 14, 15, 16, 17, 42, - 2, 42, 3, 3, 42, 5, 42, 6, - 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 13, 14, - 15, 42, 17, 42, 2, 42, 3, 3, - 42, 5, 42, 6, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 13, 42, 15, 42, 17, 42, - 2, 42, 3, 3, 42, 5, 42, 6, - 42, 42, 42, 42, 42, 42, 42, 16, - 42, 42, 9, 42, 11, 42, 13, 14, - 15, 16, 17, 42, 2, 42, 3, 3, - 42, 5, 42, 6, 42, 42, 42, 42, - 42, 42, 42, 16, 42, 42, 9, 42, - 42, 42, 13, 14, 15, 16, 17, 42, - 2, 42, 3, 3, 42, 5, 42, 6, - 42, 42, 42, 42, 42, 42, 42, 16, - 42, 42, 9, 10, 11, 42, 13, 14, - 15, 16, 17, 42, 2, 3, 3, 3, - 42, 5, 42, 6, 42, 42, 42, 42, - 42, 42, 42, 8, 42, 42, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 42, + 1, 1, 2, 3, 4, 4, 0, 5, + 0, 6, 1, 0, 0, 0, 0, 7, + 0, 8, 1, 0, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 0, + 21, 22, 23, 23, 20, 24, 20, 25, + 20, 20, 20, 20, 20, 20, 20, 26, + 20, 20, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 20, 23, 23, 20, + 24, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 37, 20, 20, 20, 20, 20, + 20, 31, 20, 20, 20, 35, 20, 23, + 23, 20, 24, 20, 23, 23, 20, 24, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 31, 20, 20, 20, 35, 20, 38, 20, + 23, 23, 20, 24, 20, 31, 20, 20, + 20, 20, 20, 20, 20, 39, 20, 20, + 20, 20, 20, 20, 31, 20, 23, 23, + 20, 24, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 39, 20, 20, 20, 20, + 20, 20, 31, 20, 23, 23, 20, 24, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 31, 20, 21, 20, 23, 23, 20, 24, + 20, 25, 20, 20, 20, 20, 20, 20, + 20, 40, 20, 20, 40, 20, 20, 20, + 31, 41, 20, 20, 35, 20, 21, 20, + 23, 23, 20, 24, 20, 25, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 31, 20, 20, 20, + 35, 20, 21, 20, 23, 23, 20, 24, + 20, 25, 20, 20, 20, 20, 20, 20, + 20, 40, 20, 20, 20, 20, 20, 20, + 31, 41, 20, 20, 35, 20, 21, 20, + 23, 23, 20, 24, 20, 25, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 31, 41, 20, 20, + 35, 20, 1, 1, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 1, 20, 21, 20, 23, 23, 20, + 24, 20, 25, 20, 20, 20, 20, 20, + 20, 20, 26, 20, 20, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 20, 21, + 20, 23, 23, 20, 24, 20, 25, 20, + 20, 20, 20, 20, 20, 20, 34, 20, + 20, 20, 20, 20, 20, 31, 32, 33, + 34, 35, 20, 21, 20, 23, 23, 20, + 24, 20, 25, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 31, 32, 33, 34, 35, 20, 21, + 20, 23, 23, 20, 24, 20, 25, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 31, 32, 33, + 20, 35, 20, 21, 20, 23, 23, 20, + 24, 20, 25, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 31, 20, 33, 20, 35, 20, 21, + 20, 23, 23, 20, 24, 20, 25, 20, + 20, 20, 20, 20, 20, 20, 34, 20, + 20, 27, 20, 29, 20, 31, 32, 33, + 34, 35, 20, 21, 20, 23, 23, 20, + 24, 20, 25, 20, 20, 20, 20, 20, + 20, 20, 34, 20, 20, 27, 20, 20, + 20, 31, 32, 33, 34, 35, 20, 21, + 20, 23, 23, 20, 24, 20, 25, 20, + 20, 20, 20, 20, 20, 20, 34, 20, + 20, 27, 28, 29, 20, 31, 32, 33, + 34, 35, 20, 21, 22, 23, 23, 20, + 24, 20, 25, 20, 20, 20, 20, 20, + 20, 20, 26, 20, 20, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 20, 3, + 3, 42, 5, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 43, 42, 42, 42, + 42, 42, 42, 13, 42, 42, 42, 17, + 42, 3, 3, 42, 5, 42, 3, 3, + 42, 5, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 13, 42, 42, 42, 17, 42, + 44, 42, 3, 3, 42, 5, 42, 13, + 42, 42, 42, 42, 42, 42, 42, 45, + 42, 42, 42, 42, 42, 42, 13, 42, + 3, 3, 42, 5, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 45, 42, 42, + 42, 42, 42, 42, 13, 42, 3, 3, + 42, 5, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 13, 42, 2, 42, 3, 3, + 42, 5, 42, 6, 42, 42, 42, 42, + 42, 42, 42, 46, 42, 42, 46, 42, + 42, 42, 13, 47, 42, 42, 17, 42, + 2, 42, 3, 3, 42, 5, 42, 6, + 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 13, 42, + 42, 42, 17, 42, 2, 42, 3, 3, + 42, 5, 42, 6, 42, 42, 42, 42, + 42, 42, 42, 46, 42, 42, 42, 42, + 42, 42, 13, 47, 42, 42, 17, 42, + 2, 42, 3, 3, 42, 5, 42, 6, + 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 13, 47, + 42, 42, 17, 42, 21, 22, 23, 23, + 20, 24, 20, 25, 20, 20, 20, 20, + 20, 20, 20, 48, 20, 20, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, + 20, 21, 49, 23, 23, 20, 24, 20, + 25, 20, 20, 20, 20, 20, 20, 20, + 26, 20, 20, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 20, 1, 1, 2, + 3, 3, 3, 42, 5, 42, 6, 1, + 42, 42, 42, 42, 1, 42, 8, 1, + 42, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 42, 2, 42, 3, 3, + 42, 5, 42, 6, 42, 42, 42, 42, + 42, 42, 42, 8, 42, 42, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 42, + 2, 42, 3, 3, 42, 5, 42, 6, + 42, 42, 42, 42, 42, 42, 42, 16, + 42, 42, 42, 42, 42, 42, 13, 14, + 15, 16, 17, 42, 2, 42, 3, 3, + 42, 5, 42, 6, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 13, 14, 15, 16, 17, 42, + 2, 42, 3, 3, 42, 5, 42, 6, + 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 13, 14, + 15, 42, 17, 42, 2, 42, 3, 3, + 42, 5, 42, 6, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 13, 42, 15, 42, 17, 42, + 2, 42, 3, 3, 42, 5, 42, 6, + 42, 42, 42, 42, 42, 42, 42, 16, + 42, 42, 9, 42, 11, 42, 13, 14, + 15, 16, 17, 42, 2, 42, 3, 3, + 42, 5, 42, 6, 42, 42, 42, 42, + 42, 42, 42, 16, 42, 42, 9, 42, + 42, 42, 13, 14, 15, 16, 17, 42, + 2, 42, 3, 3, 42, 5, 42, 6, + 42, 42, 42, 42, 42, 42, 42, 16, + 42, 42, 9, 10, 11, 42, 13, 14, + 15, 16, 17, 42, 2, 3, 3, 3, + 42, 5, 42, 6, 42, 42, 42, 42, + 42, 42, 42, 8, 42, 42, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 42, 51, 50, 0 }; static const char _myanmar_syllable_machine_trans_targs[] = { - 0, 1, 22, 0, 0, 23, 29, 32, - 35, 36, 40, 41, 42, 25, 38, 39, - 37, 28, 43, 44, 0, 2, 12, 0, - 3, 9, 13, 14, 18, 19, 20, 5, - 16, 17, 15, 8, 21, 4, 6, 7, - 10, 11, 0, 24, 26, 27, 30, 31, + 0, 1, 22, 0, 0, 23, 29, 32, + 35, 36, 40, 41, 42, 25, 38, 39, + 37, 28, 43, 44, 0, 2, 12, 0, + 3, 9, 13, 14, 18, 19, 20, 5, + 16, 17, 15, 8, 21, 4, 6, 7, + 10, 11, 0, 24, 26, 27, 30, 31, 33, 34, 0, 0 }; static const char _myanmar_syllable_machine_trans_actions[] = { - 3, 0, 0, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 6, 0, 0, 7, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8, 0, 0, 0, 0, 0, + 3, 0, 0, 4, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 0, 0, 7, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 9, 10 }; static const char _myanmar_syllable_machine_to_state_actions[] = { - 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const char _myanmar_syllable_machine_from_state_actions[] = { - 2, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const short _myanmar_syllable_machine_eof_trans[] = { - 0, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, - 21, 21, 43, 43, 43, 43, 43, 43, + 0, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, + 21, 21, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 51 }; @@ -284,7 +284,7 @@ find_syllables (hb_buffer_t *buffer) unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; int cs; hb_glyph_info_t *info = buffer->info; - + #line 289 "../../src/hb-ot-shape-complex-myanmar-machine.hh.tmp" { cs = myanmar_syllable_machine_start; @@ -301,7 +301,7 @@ find_syllables (hb_buffer_t *buffer) unsigned int last = 0; unsigned int syllable_serial = 1; - + #line 306 "../../src/hb-ot-shape-complex-myanmar-machine.hh.tmp" { int _slen; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar.cc index 6c6466275a6..0097a8e2b58 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-myanmar.cc @@ -521,6 +521,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_old = NULL, /* decompose */ NULL, /* compose */ NULL, /* setup_masks */ + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ }; @@ -538,6 +539,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar = NULL, /* decompose */ NULL, /* compose */ setup_masks_myanmar, + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, false, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-private.hh index c1d08dc7145..b374babebcc 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-private.hh @@ -146,6 +146,14 @@ struct hb_ot_complex_shaper_t hb_buffer_t *buffer, hb_font_t *font); + /* disable_otl() + * Called during shape(). + * If set and returns true, GDEF/GSUB/GPOS of the font are ignored + * and fallback operations used. + * May be NULL. + */ + bool (*disable_otl) (const hb_ot_shape_plan_t *plan); + hb_ot_shape_zero_width_marks_type_t zero_width_marks; bool fallback_position; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-thai.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-thai.cc index e4889d4eff6..b0117369a64 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-thai.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-thai.cc @@ -376,6 +376,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai = NULL, /* decompose */ NULL, /* compose */ NULL, /* setup_masks */ + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, false,/* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-tibetan.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-tibetan.cc index a77b531daa5..aadf59f5add 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-tibetan.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-tibetan.cc @@ -57,6 +57,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_tibetan = NULL, /* decompose */ NULL, /* compose */ NULL, /* setup_masks */ + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use-machine.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use-machine.hh index 97409f15b0f..ab8df0694ff 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use-machine.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use-machine.hh @@ -36,247 +36,247 @@ #line 38 "hb-ot-shape-complex-use-machine.hh" static const unsigned char _use_syllable_machine_trans_keys[] = { - 1u, 1u, 0u, 39u, 21u, 21u, 8u, 39u, 8u, 39u, 1u, 1u, 8u, 39u, 8u, 39u, - 8u, 39u, 8u, 26u, 8u, 26u, 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, - 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 13u, 21u, - 4u, 4u, 13u, 13u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 26u, 8u, 26u, - 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, - 8u, 39u, 8u, 39u, 8u, 39u, 1u, 1u, 1u, 39u, 8u, 39u, 21u, 42u, 41u, 42u, + 1u, 1u, 0u, 39u, 21u, 21u, 8u, 39u, 8u, 39u, 1u, 1u, 8u, 39u, 8u, 39u, + 8u, 39u, 8u, 26u, 8u, 26u, 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, + 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 13u, 21u, + 4u, 4u, 13u, 13u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 26u, 8u, 26u, + 8u, 26u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, 8u, 39u, + 8u, 39u, 8u, 39u, 8u, 39u, 1u, 1u, 1u, 39u, 8u, 39u, 21u, 42u, 41u, 42u, 42u, 42u, 0 }; static const char _use_syllable_machine_key_spans[] = { - 1, 40, 1, 32, 32, 1, 32, 32, - 32, 19, 19, 19, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 9, - 1, 1, 32, 32, 32, 32, 19, 19, - 19, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 1, 39, 32, 22, 2, + 1, 40, 1, 32, 32, 1, 32, 32, + 32, 19, 19, 19, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 9, + 1, 1, 32, 32, 32, 32, 19, 19, + 19, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 1, 39, 32, 22, 2, 1 }; static const short _use_syllable_machine_index_offsets[] = { - 0, 2, 43, 45, 78, 111, 113, 146, - 179, 212, 232, 252, 272, 305, 338, 371, - 404, 437, 470, 503, 536, 569, 602, 635, - 645, 647, 649, 682, 715, 748, 781, 801, - 821, 841, 874, 907, 940, 973, 1006, 1039, - 1072, 1105, 1138, 1171, 1173, 1213, 1246, 1269, + 0, 2, 43, 45, 78, 111, 113, 146, + 179, 212, 232, 252, 272, 305, 338, 371, + 404, 437, 470, 503, 536, 569, 602, 635, + 645, 647, 649, 682, 715, 748, 781, 801, + 821, 841, 874, 907, 940, 973, 1006, 1039, + 1072, 1105, 1138, 1171, 1173, 1213, 1246, 1269, 1272 }; static const char _use_syllable_machine_indicies[] = { - 1, 0, 2, 3, 4, 2, 5, 3, - 4, 4, 6, 4, 4, 1, 7, 4, - 4, 4, 2, 2, 8, 9, 4, 4, - 10, 11, 12, 13, 14, 15, 16, 10, - 17, 18, 19, 20, 21, 22, 4, 23, - 24, 25, 4, 27, 26, 29, 28, 28, - 30, 31, 28, 28, 28, 28, 28, 28, - 28, 28, 32, 33, 34, 35, 36, 37, - 38, 39, 33, 40, 32, 41, 42, 43, - 44, 28, 45, 46, 47, 28, 29, 28, - 28, 30, 31, 28, 28, 28, 28, 28, - 28, 28, 28, 48, 33, 34, 35, 36, - 37, 38, 39, 33, 40, 41, 41, 42, - 43, 44, 28, 45, 46, 47, 28, 30, - 49, 29, 28, 28, 30, 31, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 33, - 34, 35, 36, 37, 38, 39, 33, 40, - 41, 41, 42, 43, 44, 28, 45, 46, - 47, 28, 29, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 33, 34, 35, 36, 37, 28, 28, 28, - 28, 28, 28, 42, 43, 44, 28, 45, - 46, 47, 28, 29, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 34, 35, 36, 37, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 45, 46, 47, 28, 29, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 35, 36, 37, 28, - 29, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 36, 37, 28, 29, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 37, 28, - 29, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 35, 36, 37, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 45, 46, 47, - 28, 29, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 35, 36, 37, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 46, - 47, 28, 29, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 35, 36, 37, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 47, 28, 29, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 34, 35, 36, 37, 28, 28, - 28, 28, 28, 28, 42, 43, 44, 28, - 45, 46, 47, 28, 29, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 34, 35, 36, 37, 28, - 28, 28, 28, 28, 28, 28, 43, 44, - 28, 45, 46, 47, 28, 29, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 34, 35, 36, 37, - 28, 28, 28, 28, 28, 28, 28, 28, - 44, 28, 45, 46, 47, 28, 29, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 33, 34, 35, 36, - 37, 28, 39, 33, 28, 28, 28, 42, - 43, 44, 28, 45, 46, 47, 28, 29, - 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 33, 34, 35, - 36, 37, 28, 28, 33, 28, 28, 28, - 42, 43, 44, 28, 45, 46, 47, 28, - 29, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 33, 34, - 35, 36, 37, 38, 39, 33, 28, 28, - 28, 42, 43, 44, 28, 45, 46, 47, - 28, 29, 28, 28, 30, 31, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 33, - 34, 35, 36, 37, 38, 39, 33, 40, - 28, 41, 42, 43, 44, 28, 45, 46, - 47, 28, 29, 28, 28, 30, 31, 28, - 28, 28, 28, 28, 28, 28, 28, 28, - 33, 34, 35, 36, 37, 38, 39, 33, - 40, 32, 41, 42, 43, 44, 28, 45, - 46, 47, 28, 51, 50, 50, 50, 50, - 50, 50, 50, 52, 50, 5, 53, 51, - 50, 6, 54, 54, 1, 55, 54, 54, - 54, 54, 54, 54, 54, 54, 56, 10, - 11, 12, 13, 14, 15, 16, 10, 17, - 19, 19, 20, 21, 22, 54, 23, 24, - 25, 54, 6, 54, 54, 1, 55, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 10, 11, 12, 13, 14, 15, 16, 10, - 17, 19, 19, 20, 21, 22, 54, 23, - 24, 25, 54, 6, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 10, 11, 12, 13, 14, 54, 54, - 54, 54, 54, 54, 20, 21, 22, 54, - 23, 24, 25, 54, 6, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 11, 12, 13, 14, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 23, 24, 25, 54, 6, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 12, 13, 14, - 54, 6, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 13, 14, 54, 6, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 14, - 54, 6, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 12, 13, 14, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 23, 24, - 25, 54, 6, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 12, 13, 14, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 24, 25, 54, 6, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 12, 13, 14, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 25, 54, 6, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 11, 12, 13, 14, 54, - 54, 54, 54, 54, 54, 20, 21, 22, - 54, 23, 24, 25, 54, 6, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 11, 12, 13, 14, - 54, 54, 54, 54, 54, 54, 54, 21, - 22, 54, 23, 24, 25, 54, 6, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 11, 12, 13, - 14, 54, 54, 54, 54, 54, 54, 54, - 54, 22, 54, 23, 24, 25, 54, 6, - 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 10, 11, 12, - 13, 14, 54, 16, 10, 54, 54, 54, - 20, 21, 22, 54, 23, 24, 25, 54, - 6, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 10, 11, - 12, 13, 14, 54, 54, 10, 54, 54, - 54, 20, 21, 22, 54, 23, 24, 25, - 54, 6, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 10, - 11, 12, 13, 14, 15, 16, 10, 54, - 54, 54, 20, 21, 22, 54, 23, 24, - 25, 54, 6, 54, 54, 1, 55, 54, - 54, 54, 54, 54, 54, 54, 54, 54, - 10, 11, 12, 13, 14, 15, 16, 10, - 17, 54, 19, 20, 21, 22, 54, 23, - 24, 25, 54, 1, 57, 3, 54, 54, - 54, 3, 54, 54, 6, 54, 54, 1, - 55, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 10, 11, 12, 13, 14, 15, - 16, 10, 17, 18, 19, 20, 21, 22, - 54, 23, 24, 25, 54, 6, 54, 54, - 1, 55, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 10, 11, 12, 13, 14, - 15, 16, 10, 17, 18, 19, 20, 21, - 22, 54, 23, 24, 25, 54, 59, 58, - 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 58, - 58, 58, 59, 60, 58, 59, 60, 58, + 1, 0, 2, 3, 4, 2, 5, 3, + 4, 4, 6, 4, 4, 1, 7, 4, + 4, 4, 2, 2, 8, 9, 4, 4, + 10, 11, 12, 13, 14, 15, 16, 10, + 17, 18, 19, 20, 21, 22, 4, 23, + 24, 25, 4, 27, 26, 29, 28, 28, + 30, 31, 28, 28, 28, 28, 28, 28, + 28, 28, 32, 33, 34, 35, 36, 37, + 38, 39, 33, 40, 32, 41, 42, 43, + 44, 28, 45, 46, 47, 28, 29, 28, + 28, 30, 31, 28, 28, 28, 28, 28, + 28, 28, 28, 48, 33, 34, 35, 36, + 37, 38, 39, 33, 40, 41, 41, 42, + 43, 44, 28, 45, 46, 47, 28, 30, + 49, 29, 28, 28, 30, 31, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 33, + 34, 35, 36, 37, 38, 39, 33, 40, + 41, 41, 42, 43, 44, 28, 45, 46, + 47, 28, 29, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 33, 34, 35, 36, 37, 28, 28, 28, + 28, 28, 28, 42, 43, 44, 28, 45, + 46, 47, 28, 29, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 34, 35, 36, 37, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 45, 46, 47, 28, 29, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 35, 36, 37, 28, + 29, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 36, 37, 28, 29, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 37, 28, + 29, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 35, 36, 37, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 45, 46, 47, + 28, 29, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 35, 36, 37, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 46, + 47, 28, 29, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 35, 36, 37, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 47, 28, 29, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 34, 35, 36, 37, 28, 28, + 28, 28, 28, 28, 42, 43, 44, 28, + 45, 46, 47, 28, 29, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 34, 35, 36, 37, 28, + 28, 28, 28, 28, 28, 28, 43, 44, + 28, 45, 46, 47, 28, 29, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 34, 35, 36, 37, + 28, 28, 28, 28, 28, 28, 28, 28, + 44, 28, 45, 46, 47, 28, 29, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 33, 34, 35, 36, + 37, 28, 39, 33, 28, 28, 28, 42, + 43, 44, 28, 45, 46, 47, 28, 29, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 33, 34, 35, + 36, 37, 28, 28, 33, 28, 28, 28, + 42, 43, 44, 28, 45, 46, 47, 28, + 29, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 33, 34, + 35, 36, 37, 38, 39, 33, 28, 28, + 28, 42, 43, 44, 28, 45, 46, 47, + 28, 29, 28, 28, 30, 31, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 33, + 34, 35, 36, 37, 38, 39, 33, 40, + 28, 41, 42, 43, 44, 28, 45, 46, + 47, 28, 29, 28, 28, 30, 31, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 33, 34, 35, 36, 37, 38, 39, 33, + 40, 32, 41, 42, 43, 44, 28, 45, + 46, 47, 28, 51, 50, 50, 50, 50, + 50, 50, 50, 52, 50, 5, 53, 51, + 50, 6, 54, 54, 1, 55, 54, 54, + 54, 54, 54, 54, 54, 54, 56, 10, + 11, 12, 13, 14, 15, 16, 10, 17, + 19, 19, 20, 21, 22, 54, 23, 24, + 25, 54, 6, 54, 54, 1, 55, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 10, 11, 12, 13, 14, 15, 16, 10, + 17, 19, 19, 20, 21, 22, 54, 23, + 24, 25, 54, 6, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 10, 11, 12, 13, 14, 54, 54, + 54, 54, 54, 54, 20, 21, 22, 54, + 23, 24, 25, 54, 6, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 11, 12, 13, 14, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 23, 24, 25, 54, 6, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 12, 13, 14, + 54, 6, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 13, 14, 54, 6, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 14, + 54, 6, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 12, 13, 14, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 23, 24, + 25, 54, 6, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 12, 13, 14, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 24, 25, 54, 6, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 12, 13, 14, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 25, 54, 6, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 11, 12, 13, 14, 54, + 54, 54, 54, 54, 54, 20, 21, 22, + 54, 23, 24, 25, 54, 6, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 11, 12, 13, 14, + 54, 54, 54, 54, 54, 54, 54, 21, + 22, 54, 23, 24, 25, 54, 6, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 11, 12, 13, + 14, 54, 54, 54, 54, 54, 54, 54, + 54, 22, 54, 23, 24, 25, 54, 6, + 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 10, 11, 12, + 13, 14, 54, 16, 10, 54, 54, 54, + 20, 21, 22, 54, 23, 24, 25, 54, + 6, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 10, 11, + 12, 13, 14, 54, 54, 10, 54, 54, + 54, 20, 21, 22, 54, 23, 24, 25, + 54, 6, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 10, + 11, 12, 13, 14, 15, 16, 10, 54, + 54, 54, 20, 21, 22, 54, 23, 24, + 25, 54, 6, 54, 54, 1, 55, 54, + 54, 54, 54, 54, 54, 54, 54, 54, + 10, 11, 12, 13, 14, 15, 16, 10, + 17, 54, 19, 20, 21, 22, 54, 23, + 24, 25, 54, 1, 57, 3, 54, 54, + 54, 3, 54, 54, 6, 54, 54, 1, + 55, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 10, 11, 12, 13, 14, 15, + 16, 10, 17, 18, 19, 20, 21, 22, + 54, 23, 24, 25, 54, 6, 54, 54, + 1, 55, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 10, 11, 12, 13, 14, + 15, 16, 10, 17, 18, 19, 20, 21, + 22, 54, 23, 24, 25, 54, 59, 58, + 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 59, 60, 58, 59, 60, 58, 60, 58, 0 }; static const char _use_syllable_machine_trans_targs[] = { - 1, 26, 2, 3, 1, 23, 1, 43, - 44, 46, 28, 29, 30, 31, 32, 39, - 40, 41, 45, 42, 36, 37, 38, 33, - 34, 35, 1, 1, 1, 1, 4, 5, - 22, 7, 8, 9, 10, 11, 18, 19, - 20, 21, 15, 16, 17, 12, 13, 14, - 6, 1, 1, 24, 25, 1, 1, 0, + 1, 26, 2, 3, 1, 23, 1, 43, + 44, 46, 28, 29, 30, 31, 32, 39, + 40, 41, 45, 42, 36, 37, 38, 33, + 34, 35, 1, 1, 1, 1, 4, 5, + 22, 7, 8, 9, 10, 11, 18, 19, + 20, 21, 15, 16, 17, 12, 13, 14, + 6, 1, 1, 24, 25, 1, 1, 0, 27, 1, 1, 47, 48 }; static const char _use_syllable_machine_trans_actions[] = { - 1, 2, 0, 0, 5, 0, 6, 0, - 2, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 2, 0, 0, 0, 0, - 0, 0, 7, 8, 9, 10, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 11, 12, 0, 0, 13, 14, 0, + 1, 2, 0, 0, 5, 0, 6, 0, + 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 2, 0, 0, 0, 0, + 0, 0, 7, 8, 9, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 11, 12, 0, 0, 13, 14, 0, 2, 15, 16, 0, 0 }; static const char _use_syllable_machine_to_state_actions[] = { - 0, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const char _use_syllable_machine_from_state_actions[] = { - 0, 4, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const short _use_syllable_machine_eof_trans[] = { - 1, 0, 27, 29, 29, 50, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 51, - 54, 51, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 58, 55, 55, 59, 59, + 1, 0, 27, 29, 29, 50, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 51, + 54, 51, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 58, 55, 55, 59, 59, 59 }; @@ -310,7 +310,7 @@ find_syllables (hb_buffer_t *buffer) unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED; int cs; hb_glyph_info_t *info = buffer->info; - + #line 315 "hb-ot-shape-complex-use-machine.hh" { cs = use_syllable_machine_start; @@ -327,7 +327,7 @@ find_syllables (hb_buffer_t *buffer) unsigned int last = 0; unsigned int syllable_serial = 1; - + #line 332 "hb-ot-shape-complex-use-machine.hh" { int _slen; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use.cc index eeca79ae443..9488d1a2c8b 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-use.cc @@ -558,6 +558,47 @@ reorder (const hb_ot_shape_plan_t *plan, HB_BUFFER_DEALLOCATE_VAR (buffer, use_category); } +static bool +decompose_use (const hb_ot_shape_normalize_context_t *c, + hb_codepoint_t ab, + hb_codepoint_t *a, + hb_codepoint_t *b) +{ + switch (ab) + { + /* Chakma: + * Special case where the Unicode decomp gives matras in the wrong order + * for cluster validation. + */ + case 0x1112Eu : *a = 0x11127u; *b= 0x11131u; return true; + case 0x1112Fu : *a = 0x11127u; *b= 0x11132u; return true; + + /* + * Decompose split matras that don't have Unicode decompositions. + */ + + /* Limbu */ + case 0x1925u : *a = 0x1920u; *b= 0x1923u; return true; + case 0x1926u : *a = 0x1920u; *b= 0x1924u; return true; + + /* Balinese */ + case 0x1B3Cu : *a = 0x1B42u; *b= 0x1B3Cu; return true; + +#if 0 + /* Lepcha */ + case 0x1C29u : *a = no decomp, -> LEFT; return true; + + /* Javanese */ + case 0xA9C0u : *a = no decomp, -> RIGHT; return true; + + /* Sharada */ + case 0x111BFu : *a = no decomp, -> ABOVE; return true; +#endif + } + + return (bool) c->unicode->decompose (ab, a, b); +} + static bool compose_use (const hb_ot_shape_normalize_context_t *c, hb_codepoint_t a, @@ -582,9 +623,10 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_use = NULL, /* preprocess_text */ NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, - NULL, /* decompose */ + decompose_use, compose_use, setup_masks_use, + NULL, /* disable_otl */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, false, /* fallback_position */ }; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-private.hh index 3734827ef58..775417de85c 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-private.hh @@ -77,11 +77,13 @@ struct hb_ot_shape_planner_t map (face, &props) {} ~hb_ot_shape_planner_t (void) { map.finish (); } - inline void compile (hb_ot_shape_plan_t &plan) + inline void compile (hb_ot_shape_plan_t &plan, + const int *coords, + unsigned int num_coords) { plan.props = props; plan.shaper = shaper; - map.compile (plan.map); + map.compile (plan.map, coords, num_coords); plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc index 35f2097d7ec..9e9b3fa3025 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc @@ -69,6 +69,9 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, { hb_ot_map_builder_t *map = &planner->map; + map->add_global_bool_feature (HB_TAG('r','v','r','n')); + map->add_gsub_pause (NULL); + switch (props->direction) { case HB_DIRECTION_LTR: map->add_global_bool_feature (HB_TAG ('l','t','r','a')); @@ -163,7 +166,9 @@ _hb_ot_shaper_font_data_destroy (hb_ot_shaper_font_data_t *data) hb_ot_shaper_shape_plan_data_t * _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan, const hb_feature_t *user_features, - unsigned int num_user_features) + unsigned int num_user_features, + const int *coords, + unsigned int num_coords) { hb_ot_shape_plan_t *plan = (hb_ot_shape_plan_t *) calloc (1, sizeof (hb_ot_shape_plan_t)); if (unlikely (!plan)) @@ -173,9 +178,10 @@ _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan, planner.shaper = hb_ot_shape_complex_categorize (&planner); - hb_ot_shape_collect_features (&planner, &shape_plan->props, user_features, num_user_features); + hb_ot_shape_collect_features (&planner, &shape_plan->props, + user_features, num_user_features); - planner.compile (*plan); + planner.compile (*plan, coords, num_coords); if (plan->shaper->data_create) { plan->data = plan->shaper->data_create (plan); @@ -212,6 +218,8 @@ struct hb_ot_shape_context_t unsigned int num_user_features; /* Transient stuff */ + bool fallback_positioning; + bool fallback_glyph_classes; hb_direction_t target_direction; }; @@ -523,6 +531,32 @@ hb_ot_map_glyphs_fast (hb_buffer_t *buffer) buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; } +static inline void +hb_synthesize_glyph_classes (hb_ot_shape_context_t *c) +{ + unsigned int count = c->buffer->len; + hb_glyph_info_t *info = c->buffer->info; + for (unsigned int i = 0; i < count; i++) + { + hb_ot_layout_glyph_props_flags_t klass; + + /* Never mark default-ignorables as marks. + * They won't get in the way of lookups anyway, + * but having them as mark will cause them to be skipped + * over if the lookup-flag says so, but at least for the + * Mongolian variation selectors, looks like Uniscribe + * marks them as non-mark. Some Mongolian fonts without + * GDEF rely on this. Another notable character that + * this applies to is COMBINING GRAPHEME JOINER. */ + klass = (_hb_glyph_info_get_general_category (&info[i]) != + HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK || + _hb_glyph_info_is_default_ignorable (&info[i])) ? + HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : + HB_OT_LAYOUT_GLYPH_PROPS_MARK; + _hb_glyph_info_set_glyph_props (&info[i], klass); + } +} + static inline void hb_ot_substitute_default (hb_ot_shape_context_t *c) { @@ -539,7 +573,7 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c) hb_ot_shape_setup_masks (c); /* This is unfortunate to go here, but necessary... */ - if (!hb_ot_layout_has_positioning (c->face)) + if (c->fallback_positioning) _hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, buffer); hb_ot_map_glyphs_fast (buffer); @@ -554,6 +588,9 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c) hb_ot_layout_substitute_start (c->font, buffer); + if (!hb_ot_layout_has_glyph_classes (c->face)) + hb_synthesize_glyph_classes (c); + c->plan->substitute (c->font, buffer); return; @@ -632,14 +669,12 @@ hb_ot_position_default (hb_ot_shape_context_t *c) _hb_ot_shape_fallback_spaces (c->plan, c->font, c->buffer); } -static inline bool +static inline void hb_ot_position_complex (hb_ot_shape_context_t *c) { hb_ot_layout_position_start (c->font, c->buffer); - bool ret = false; unsigned int count = c->buffer->len; - bool has_positioning = (bool) hb_ot_layout_has_positioning (c->face); /* If the font has no GPOS, AND, no fallback positioning will * happen, AND, direction is forward, then when zeroing mark @@ -650,8 +685,9 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) * If fallback positinoing happens or GPOS is present, we don't * care. */ - bool adjust_offsets_when_zeroing = !(has_positioning || c->plan->shaper->fallback_position || - HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction)); + bool adjust_offsets_when_zeroing = c->fallback_positioning && + !c->plan->shaper->fallback_position && + HB_DIRECTION_IS_FORWARD (c->buffer->props.direction); switch (c->plan->shaper->zero_width_marks) { @@ -665,7 +701,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) break; } - if (has_positioning) + if (likely (!c->fallback_positioning)) { hb_glyph_info_t *info = c->buffer->info; hb_glyph_position_t *pos = c->buffer->pos; @@ -688,7 +724,6 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) &pos[i].x_offset, &pos[i].y_offset); - ret = true; } switch (c->plan->shaper->zero_width_marks) @@ -707,8 +742,6 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) hb_ot_layout_position_finish_advances (c->font, c->buffer); hb_ot_zero_width_default_ignorables (c); hb_ot_layout_position_finish_offsets (c->font, c->buffer); - - return ret; } static inline void @@ -718,9 +751,9 @@ hb_ot_position (hb_ot_shape_context_t *c) hb_ot_position_default (c); - hb_bool_t fallback = !hb_ot_position_complex (c); + hb_ot_position_complex (c); - if (fallback && c->plan->shaper->fallback_position) + if (c->fallback_positioning && c->plan->shaper->fallback_position) _hb_ot_shape_fallback_position (c->plan, c->font, c->buffer); if (HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction)) @@ -728,7 +761,7 @@ hb_ot_position (hb_ot_shape_context_t *c) /* Visual fallback goes here. */ - if (fallback) + if (c->fallback_positioning) _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer); _hb_buffer_deallocate_gsubgpos_vars (c->buffer); @@ -748,6 +781,11 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) (unsigned) HB_BUFFER_MAX_LEN_MIN); } + bool disable_otl = c->plan->shaper->disable_otl && c->plan->shaper->disable_otl (c->plan); + //c->fallback_substitute = disable_otl || !hb_ot_layout_has_substitution (c->face); + c->fallback_positioning = disable_otl || !hb_ot_layout_has_positioning (c->face); + c->fallback_glyph_classes = disable_otl || !hb_ot_layout_has_glyph_classes (c->face); + /* Save the original direction, we use it later. */ c->target_direction = c->buffer->props.direction; diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-tag.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-tag.cc index c790888d4c3..5989fb26a33 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-tag.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-tag.cc @@ -826,16 +826,19 @@ static const LangTag ot_languages[] = { }; typedef struct { - char language[8]; + char language[11]; hb_tag_t tag; } LangTagLong; static const LangTagLong ot_languages_zh[] = { + /* Store longest-first, if one is a prefix of another. */ {"zh-cn", HB_TAG('Z','H','S',' ')}, /* Chinese (China) */ {"zh-hk", HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */ - {"zh-mo", HB_TAG('Z','H','T',' ')}, /* Chinese (Macao) */ + {"zh-mo", HB_TAG('Z','H','H',' ')}, /* Chinese (Macao) */ {"zh-sg", HB_TAG('Z','H','S',' ')}, /* Chinese (Singapore) */ {"zh-tw", HB_TAG('Z','H','T',' ')}, /* Chinese (Taiwan) */ {"zh-hans", HB_TAG('Z','H','S',' ')}, /* Chinese (Simplified) */ + {"zh-hant-hk",HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */ + {"zh-hant-mo",HB_TAG('Z','H','H',' ')}, /* Chinese (Macao) */ {"zh-hant", HB_TAG('Z','H','T',' ')}, /* Chinese (Traditional) */ }; @@ -889,13 +892,21 @@ hb_ot_tag_from_language (hb_language_t language) } /* - * The International Phonetic Alphabet is a variant tag in BCP-47, - * which can be applied to any language. + * "fonipa" is a variant tag in BCP-47, meaning the International Phonetic Alphabet. + * It can be applied to any language. */ if (strstr (lang_str, "-fonipa")) { return HB_TAG('I','P','P','H'); /* Phonetic transcription—IPA conventions */ } + /* + * "fonnapa" is a variant tag in BCP-47, meaning the North American Phonetic Alphabet + * also known as Americanist Phonetic Notation. It can be applied to any language. + */ + if (strstr (lang_str, "-fonnapa")) { + return HB_TAG('A','P','P','H'); /* Phonetic transcription—Americanist conventions */ + } + /* Find a language matching in the first component */ { const LangTag *lang_tag; @@ -937,7 +948,7 @@ hb_ot_tag_from_language (hb_language_t language) /** * hb_ot_tag_to_language: * - * + * * * Return value: (transfer none): * @@ -967,6 +978,8 @@ hb_ot_tag_to_language (hb_tag_t tag) /* struct LangTag has only room for 3-letter language tags. */ switch (tag) { + case HB_TAG('A','P','P','H'): /* Phonetic transcription—Americanist conventions */ + return hb_language_from_string ("und-fonnapa", -1); case HB_TAG('I','P','P','H'): /* Phonetic transcription—IPA conventions */ return hb_language_from_string ("und-fonipa", -1); } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot.h b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot.h index 47c92a58e4b..113e37b08ab 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot.h @@ -32,6 +32,7 @@ #include "hb-ot-font.h" #include "hb-ot-layout.h" +#include "hb-ot-math.h" #include "hb-ot-tag.h" #include "hb-ot-shape.h" diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh index 1f270ee698c..a71665ba76b 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh @@ -689,17 +689,20 @@ _hb_debug_msg_va (const char *what, fprintf (stderr, " %*s ", (unsigned int) (2 * sizeof (void *)), ""); if (indented) { -/* One may want to add ASCII version of these. See: - * https://bugs.freedesktop.org/show_bug.cgi?id=50970 */ #define VBAR "\342\224\202" /* U+2502 BOX DRAWINGS LIGHT VERTICAL */ #define VRBAR "\342\224\234" /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ #define DLBAR "\342\225\256" /* U+256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT */ #define ULBAR "\342\225\257" /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */ #define LBAR "\342\225\264" /* U+2574 BOX DRAWINGS LIGHT LEFT */ - static const char bars[] = VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR; + static const char bars[] = + VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR + VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR + VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR + VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR + VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR; fprintf (stderr, "%2u %s" VRBAR "%s", level, - bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars), (unsigned int) (sizeof (VBAR) - 1) * level), + bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars) - 1, (unsigned int) (sizeof (VBAR) - 1) * level), level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR); } else fprintf (stderr, " " VRBAR LBAR); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-private.hh index 6c0199c7b55..d4eee0e47fa 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set-private.hh @@ -313,7 +313,7 @@ struct hb_set_t for (unsigned int i = 0; i < ELTS; i++) if (elts[i]) for (unsigned int j = 0; j < BITS; j++) - if (elts[i] & (1 << j)) + if (elts[i] & (1u << j)) return i * BITS + j; return INVALID; } @@ -322,7 +322,7 @@ struct hb_set_t for (unsigned int i = ELTS; i; i--) if (elts[i - 1]) for (unsigned int j = BITS; j; j--) - if (elts[i - 1] & (1 << (j - 1))) + if (elts[i - 1] & (1u << (j - 1))) return (i - 1) * BITS + (j - 1); return INVALID; } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set.cc index beb2910407b..766c18bd4ec 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-set.cc @@ -143,9 +143,9 @@ hb_set_get_user_data (hb_set_t *set, * hb_set_allocation_successful: * @set: a set. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -159,7 +159,7 @@ hb_set_allocation_successful (const hb_set_t *set HB_UNUSED) * hb_set_clear: * @set: a set. * - * + * * * Since: 0.9.2 **/ @@ -173,9 +173,9 @@ hb_set_clear (hb_set_t *set) * hb_set_is_empty: * @set: a set. * + * * - * - * Return value: + * Return value: * * Since: 0.9.7 **/ @@ -188,11 +188,11 @@ hb_set_is_empty (const hb_set_t *set) /** * hb_set_has: * @set: a set. - * @codepoint: + * @codepoint: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -206,9 +206,9 @@ hb_set_has (const hb_set_t *set, /** * hb_set_add: * @set: a set. - * @codepoint: - * + * @codepoint: * + * * * Since: 0.9.2 **/ @@ -222,10 +222,10 @@ hb_set_add (hb_set_t *set, /** * hb_set_add_range: * @set: a set. - * @first: - * @last: - * + * @first: + * @last: * + * * * Since: 0.9.7 **/ @@ -240,9 +240,9 @@ hb_set_add_range (hb_set_t *set, /** * hb_set_del: * @set: a set. - * @codepoint: - * + * @codepoint: * + * * * Since: 0.9.2 **/ @@ -256,10 +256,10 @@ hb_set_del (hb_set_t *set, /** * hb_set_del_range: * @set: a set. - * @first: - * @last: - * + * @first: + * @last: * + * * * Since: 0.9.7 **/ @@ -274,11 +274,11 @@ hb_set_del_range (hb_set_t *set, /** * hb_set_is_equal: * @set: a set. - * @other: + * @other: * + * * - * - * Return value: + * Return value: * * Since: 0.9.7 **/ @@ -292,9 +292,9 @@ hb_set_is_equal (const hb_set_t *set, /** * hb_set_set: * @set: a set. - * @other: - * + * @other: * + * * * Since: 0.9.2 **/ @@ -308,9 +308,9 @@ hb_set_set (hb_set_t *set, /** * hb_set_union: * @set: a set. - * @other: - * + * @other: * + * * * Since: 0.9.2 **/ @@ -324,9 +324,9 @@ hb_set_union (hb_set_t *set, /** * hb_set_intersect: * @set: a set. - * @other: - * + * @other: * + * * * Since: 0.9.2 **/ @@ -340,9 +340,9 @@ hb_set_intersect (hb_set_t *set, /** * hb_set_subtract: * @set: a set. - * @other: - * + * @other: * + * * * Since: 0.9.2 **/ @@ -356,9 +356,9 @@ hb_set_subtract (hb_set_t *set, /** * hb_set_symmetric_difference: * @set: a set. - * @other: - * + * @other: * + * * * Since: 0.9.2 **/ @@ -373,7 +373,7 @@ hb_set_symmetric_difference (hb_set_t *set, * hb_set_invert: * @set: a set. * - * + * * * Since: 0.9.10 **/ @@ -436,7 +436,7 @@ hb_set_get_max (const hb_set_t *set) * @set: a set. * @codepoint: (inout): * - * + * * * Return value: whether there was a next value. * diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan-private.hh b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan-private.hh index 5ecc96c74ba..6af20ced581 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan-private.hh +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan-private.hh @@ -47,12 +47,17 @@ struct hb_shape_plan_t hb_feature_t *user_features; unsigned int num_user_features; + int *coords; + unsigned int num_coords; + struct hb_shaper_data_t shaper_data; }; #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \ - , const hb_feature_t *user_features \ - , unsigned int num_user_features + , const hb_feature_t *user_features \ + , unsigned int num_user_features \ + , const int *coords \ + , unsigned int num_coords #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, shape_plan); #include "hb-shaper-list.hh" #undef HB_SHAPER_IMPLEMENT diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc index d20912e8073..ac473b84d4d 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.cc @@ -46,11 +46,14 @@ static void hb_shape_plan_plan (hb_shape_plan_t *shape_plan, const hb_feature_t *user_features, unsigned int num_user_features, + const int *coords, + unsigned int num_coords, const char * const *shaper_list) { DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan, - "num_features=%d shaper_list=%p", + "num_features=%d num_coords=%d shaper_list=%p", num_user_features, + num_coords, shaper_list); const hb_shaper_pair_t *shapers = _hb_shapers_get (); @@ -59,7 +62,9 @@ hb_shape_plan_plan (hb_shape_plan_t *shape_plan, HB_STMT_START { \ if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) { \ HB_SHAPER_DATA (shaper, shape_plan) = \ - HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, user_features, num_user_features); \ + HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, \ + user_features, num_user_features, \ + coords, num_coords); \ shape_plan->shaper_func = _hb_##shaper##_shape; \ shape_plan->shaper_name = #shaper; \ return; \ @@ -96,13 +101,13 @@ hb_shape_plan_plan (hb_shape_plan_t *shape_plan, /** * hb_shape_plan_create: (Xconstructor) - * @face: - * @props: + * @face: + * @props: * @user_features: (array length=num_user_features): - * @num_user_features: + * @num_user_features: * @shaper_list: (array zero-terminated=1): * - * + * * * Return value: (transfer full): * @@ -114,15 +119,32 @@ hb_shape_plan_create (hb_face_t *face, const hb_feature_t *user_features, unsigned int num_user_features, const char * const *shaper_list) +{ + return hb_shape_plan_create2 (face, props, + user_features, num_user_features, + NULL, 0, + shaper_list); +} + +hb_shape_plan_t * +hb_shape_plan_create2 (hb_face_t *face, + const hb_segment_properties_t *props, + const hb_feature_t *user_features, + unsigned int num_user_features, + const int *orig_coords, + unsigned int num_coords, + const char * const *shaper_list) { DEBUG_MSG_FUNC (SHAPE_PLAN, NULL, - "face=%p num_features=%d shaper_list=%p", + "face=%p num_features=%d num_coords=%d shaper_list=%p", face, num_user_features, + num_coords, shaper_list); hb_shape_plan_t *shape_plan; hb_feature_t *features = NULL; + int *coords = NULL; if (unlikely (!face)) face = hb_face_get_empty (); @@ -130,7 +152,14 @@ hb_shape_plan_create (hb_face_t *face, return hb_shape_plan_get_empty (); if (num_user_features && !(features = (hb_feature_t *) calloc (num_user_features, sizeof (hb_feature_t)))) return hb_shape_plan_get_empty (); - if (!(shape_plan = hb_object_create ())) { + if (num_coords && !(coords = (int *) calloc (num_coords, sizeof (int)))) + { + free (features); + return hb_shape_plan_get_empty (); + } + if (!(shape_plan = hb_object_create ())) + { + free (coords); free (features); return hb_shape_plan_get_empty (); } @@ -145,8 +174,15 @@ hb_shape_plan_create (hb_face_t *face, shape_plan->user_features = features; if (num_user_features) memcpy (features, user_features, num_user_features * sizeof (hb_feature_t)); + shape_plan->num_coords = num_coords; + shape_plan->coords = coords; + if (num_coords) + memcpy (coords, orig_coords, num_coords * sizeof (int)); - hb_shape_plan_plan (shape_plan, user_features, num_user_features, shaper_list); + hb_shape_plan_plan (shape_plan, + user_features, num_user_features, + coords, num_coords, + shaper_list); return shape_plan; } @@ -154,7 +190,7 @@ hb_shape_plan_create (hb_face_t *face, /** * hb_shape_plan_get_empty: * - * + * * * Return value: (transfer full): * @@ -176,6 +212,9 @@ hb_shape_plan_get_empty (void) NULL, /* user_features */ 0, /* num_user_featurs */ + NULL, /* coords */ + 0, /* num_coords */ + { #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, #include "hb-shaper-list.hh" @@ -190,7 +229,7 @@ hb_shape_plan_get_empty (void) * hb_shape_plan_reference: (skip) * @shape_plan: a shape plan. * - * + * * * Return value: (transfer full): * @@ -206,7 +245,7 @@ hb_shape_plan_reference (hb_shape_plan_t *shape_plan) * hb_shape_plan_destroy: (skip) * @shape_plan: a shape plan. * - * + * * * Since: 0.9.7 **/ @@ -220,6 +259,7 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan) #undef HB_SHAPER_IMPLEMENT free (shape_plan->user_features); + free (shape_plan->coords); free (shape_plan); } @@ -227,14 +267,14 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan) /** * hb_shape_plan_set_user_data: (skip) * @shape_plan: a shape plan. - * @key: - * @data: - * @destroy: - * @replace: + * @key: + * @data: + * @destroy: + * @replace: * + * * - * - * Return value: + * Return value: * * Since: 0.9.7 **/ @@ -251,9 +291,9 @@ hb_shape_plan_set_user_data (hb_shape_plan_t *shape_plan, /** * hb_shape_plan_get_user_data: (skip) * @shape_plan: a shape plan. - * @key: - * + * @key: * + * * * Return value: (transfer none): * @@ -273,11 +313,11 @@ hb_shape_plan_get_user_data (hb_shape_plan_t *shape_plan, * @font: a font. * @buffer: a buffer. * @features: (array length=num_features): - * @num_features: + * @num_features: * + * * - * - * Return value: + * Return value: * * Since: 0.9.7 **/ @@ -289,9 +329,10 @@ hb_shape_plan_execute (hb_shape_plan_t *shape_plan, unsigned int num_features) { DEBUG_MSG_FUNC (SHAPE_PLAN, shape_plan, - "num_features=%d shaper_func=%p", + "num_features=%d shaper_func=%p, shaper_name=%s", num_features, - shape_plan->shaper_func); + shape_plan->shaper_func, + shape_plan->shaper_name); if (unlikely (!buffer->len)) return true; @@ -350,6 +391,8 @@ struct hb_shape_plan_proposal_t const char * const *shaper_list; const hb_feature_t *user_features; unsigned int num_user_features; + const int *coords; + unsigned int num_coords; hb_shape_func_t *shaper_func; }; @@ -357,12 +400,26 @@ static inline hb_bool_t hb_shape_plan_user_features_match (const hb_shape_plan_t *shape_plan, const hb_shape_plan_proposal_t *proposal) { - if (proposal->num_user_features != shape_plan->num_user_features) return false; + if (proposal->num_user_features != shape_plan->num_user_features) + return false; for (unsigned int i = 0, n = proposal->num_user_features; i < n; i++) if (proposal->user_features[i].tag != shape_plan->user_features[i].tag || proposal->user_features[i].value != shape_plan->user_features[i].value || proposal->user_features[i].start != shape_plan->user_features[i].start || - proposal->user_features[i].end != shape_plan->user_features[i].end) return false; + proposal->user_features[i].end != shape_plan->user_features[i].end) + return false; + return true; +} + +static inline hb_bool_t +hb_shape_plan_coords_match (const hb_shape_plan_t *shape_plan, + const hb_shape_plan_proposal_t *proposal) +{ + if (proposal->num_coords != shape_plan->num_coords) + return false; + for (unsigned int i = 0, n = proposal->num_coords; i < n; i++) + if (proposal->coords[i] != shape_plan->coords[i]) + return false; return true; } @@ -372,6 +429,7 @@ hb_shape_plan_matches (const hb_shape_plan_t *shape_plan, { return hb_segment_properties_equal (&shape_plan->props, &proposal->props) && hb_shape_plan_user_features_match (shape_plan, proposal) && + hb_shape_plan_coords_match (shape_plan, proposal) && ((shape_plan->default_shaper_list && proposal->shaper_list == NULL) || (shape_plan->shaper_func == proposal->shaper_func)); } @@ -388,15 +446,22 @@ hb_non_global_user_features_present (const hb_feature_t *user_features, return false; } +static inline hb_bool_t +hb_coords_present (const int *coords, + unsigned int num_coords) +{ + return num_coords != 0; +} + /** * hb_shape_plan_create_cached: - * @face: - * @props: + * @face: + * @props: * @user_features: (array length=num_user_features): - * @num_user_features: + * @num_user_features: * @shaper_list: (array zero-terminated=1): * - * + * * * Return value: (transfer full): * @@ -408,6 +473,21 @@ hb_shape_plan_create_cached (hb_face_t *face, const hb_feature_t *user_features, unsigned int num_user_features, const char * const *shaper_list) +{ + return hb_shape_plan_create_cached2 (face, props, + user_features, num_user_features, + NULL, 0, + shaper_list); +} + +hb_shape_plan_t * +hb_shape_plan_create_cached2 (hb_face_t *face, + const hb_segment_properties_t *props, + const hb_feature_t *user_features, + unsigned int num_user_features, + const int *coords, + unsigned int num_coords, + const char * const *shaper_list) { DEBUG_MSG_FUNC (SHAPE_PLAN, NULL, "face=%p num_features=%d shaper_list=%p", @@ -455,16 +535,21 @@ retry: /* Not found. */ - hb_shape_plan_t *shape_plan = hb_shape_plan_create (face, props, user_features, num_user_features, shaper_list); + hb_shape_plan_t *shape_plan = hb_shape_plan_create2 (face, props, + user_features, num_user_features, + coords, num_coords, + shaper_list); /* Don't add to the cache if face is inert. */ if (unlikely (hb_object_is_inert (face))) return shape_plan; /* Don't add the plan to the cache if there were user features with non-global ranges */ - if (hb_non_global_user_features_present (user_features, num_user_features)) return shape_plan; + /* Don't add the plan to the cache if there were variation coordinates XXX Fix me. */ + if (hb_coords_present (coords, num_coords)) + return shape_plan; hb_face_t::plan_node_t *node = (hb_face_t::plan_node_t *) calloc (1, sizeof (hb_face_t::plan_node_t)); if (unlikely (!node)) @@ -487,7 +572,7 @@ retry: * hb_shape_plan_get_shaper: * @shape_plan: a shape plan. * - * + * * * Return value: (transfer none): * diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.h b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.h index a86d468181e..3fc6703fe90 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape-plan.h @@ -52,6 +52,25 @@ hb_shape_plan_create_cached (hb_face_t *face, unsigned int num_user_features, const char * const *shaper_list); +HB_EXTERN hb_shape_plan_t * +hb_shape_plan_create2 (hb_face_t *face, + const hb_segment_properties_t *props, + const hb_feature_t *user_features, + unsigned int num_user_features, + const int *coords, + unsigned int num_coords, + const char * const *shaper_list); + +HB_EXTERN hb_shape_plan_t * +hb_shape_plan_create_cached2 (hb_face_t *face, + const hb_segment_properties_t *props, + const hb_feature_t *user_features, + unsigned int num_user_features, + const int *coords, + unsigned int num_coords, + const char * const *shaper_list); + + HB_EXTERN hb_shape_plan_t * hb_shape_plan_get_empty (void); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape.cc index 2fbaf405a56..1feacaa8a35 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-shape.cc @@ -373,7 +373,10 @@ hb_shape_full (hb_font_t *font, unsigned int num_features, const char * const *shaper_list) { - hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, features, num_features, shaper_list); + hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached2 (font->face, &buffer->props, + features, num_features, + font->coords, font->num_coords, + shaper_list); hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num_features); hb_shape_plan_destroy (shape_plan); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-unicode.cc b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-unicode.cc index 81a474edcbd..91b4aa384ca 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-unicode.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-unicode.cc @@ -131,12 +131,12 @@ hb_unicode_funcs_get_default (void) #define HB_UNICODE_FUNCS_IMPLEMENT(set) \ return hb_##set##_get_unicode_funcs (); -#ifdef HAVE_GLIB +#if defined(HAVE_UCDN) + HB_UNICODE_FUNCS_IMPLEMENT(ucdn) +#elif defined(HAVE_GLIB) HB_UNICODE_FUNCS_IMPLEMENT(glib) #elif defined(HAVE_ICU) && defined(HAVE_ICU_BUILTIN) HB_UNICODE_FUNCS_IMPLEMENT(icu) -#elif defined(HAVE_UCDN) - HB_UNICODE_FUNCS_IMPLEMENT(ucdn) #else #define HB_UNICODE_FUNCS_NIL 1 HB_UNICODE_FUNCS_IMPLEMENT(nil) @@ -154,7 +154,7 @@ hb_unicode_funcs_get_default (void) * hb_unicode_funcs_create: (Xconstructor) * @parent: (nullable): * - * + * * * Return value: (transfer full): * @@ -200,7 +200,7 @@ const hb_unicode_funcs_t _hb_unicode_funcs_nil = { /** * hb_unicode_funcs_get_empty: * - * + * * * Return value: (transfer full): * @@ -216,7 +216,7 @@ hb_unicode_funcs_get_empty (void) * hb_unicode_funcs_reference: (skip) * @ufuncs: Unicode functions. * - * + * * * Return value: (transfer full): * @@ -232,7 +232,7 @@ hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs) * hb_unicode_funcs_destroy: (skip) * @ufuncs: Unicode functions. * - * + * * * Since: 0.9.2 **/ @@ -254,14 +254,14 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs) /** * hb_unicode_funcs_set_user_data: (skip) * @ufuncs: Unicode functions. - * @key: - * @data: - * @destroy: - * @replace: + * @key: + * @data: + * @destroy: + * @replace: * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -278,9 +278,9 @@ hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs, /** * hb_unicode_funcs_get_user_data: (skip) * @ufuncs: Unicode functions. - * @key: - * + * @key: * + * * * Return value: (transfer none): * @@ -298,7 +298,7 @@ hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs, * hb_unicode_funcs_make_immutable: * @ufuncs: Unicode functions. * - * + * * * Since: 0.9.2 **/ @@ -315,9 +315,9 @@ hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs) * hb_unicode_funcs_is_immutable: * @ufuncs: Unicode functions. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -331,9 +331,9 @@ hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs) * hb_unicode_funcs_get_parent: * @ufuncs: Unicode functions. * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -387,13 +387,13 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE /** * hb_unicode_compose: * @ufuncs: Unicode functions. - * @a: - * @b: + * @a: + * @b: * @ab: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -409,13 +409,13 @@ hb_unicode_compose (hb_unicode_funcs_t *ufuncs, /** * hb_unicode_decompose: * @ufuncs: Unicode functions. - * @ab: + * @ab: * @a: (out): * @b: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ @@ -431,12 +431,12 @@ hb_unicode_decompose (hb_unicode_funcs_t *ufuncs, /** * hb_unicode_decompose_compatibility: * @ufuncs: Unicode functions. - * @u: + * @u: * @decomposed: (out): * + * * - * - * Return value: + * Return value: * * Since: 0.9.2 **/ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-version.h b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-version.h index 5bcd33c61a6..90d91c74988 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-version.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-version.h @@ -37,10 +37,10 @@ HB_BEGIN_DECLS #define HB_VERSION_MAJOR 1 -#define HB_VERSION_MINOR 3 -#define HB_VERSION_MICRO 0 +#define HB_VERSION_MINOR 4 +#define HB_VERSION_MICRO 1 -#define HB_VERSION_STRING "1.3.0" +#define HB_VERSION_STRING "1.4.1" #define HB_VERSION_ATLEAST(major,minor,micro) \ ((major)*10000+(minor)*100+(micro) <= \ diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index 2e41293a08f..8d817243038 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -49,7 +49,7 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, JNIEnv* env = jdkFontInfo->env; jobject font2D = jdkFontInfo->font2D; hb_codepoint_t u = (variation_selector==0) ? unicode : variation_selector; - + *glyph = (hb_codepoint_t) env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u); return (*glyph != 0); @@ -61,7 +61,7 @@ hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - + float fadv = 0.0f; if ((glyph & 0xfffe) == 0xfffe) { return 0; // JDK uses this glyph code. @@ -72,7 +72,7 @@ hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, jobject fontStrike = jdkFontInfo->fontStrike; jobject pt = env->CallObjectMethod(fontStrike, sunFontIDs.getGlyphMetricsMID, glyph); - + if (pt == NULL) { return 0; } @@ -89,7 +89,7 @@ hb_jdk_get_glyph_v_advance (hb_font_t *font HB_UNUSED, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - + float fadv = 0.0f; if ((glyph & 0xfffe) == 0xfffe) { return 0; // JDK uses this glyph code. @@ -100,7 +100,7 @@ hb_jdk_get_glyph_v_advance (hb_font_t *font HB_UNUSED, jobject fontStrike = jdkFontInfo->fontStrike; jobject pt = env->CallObjectMethod(fontStrike, sunFontIDs.getGlyphMetricsMID, glyph); - + if (pt == NULL) { return 0; } @@ -108,7 +108,7 @@ hb_jdk_get_glyph_v_advance (hb_font_t *font HB_UNUSED, env->DeleteLocalRef(pt); return HBFloatToFixed(fadv); - + } static hb_bool_t @@ -196,7 +196,7 @@ hb_jdk_get_glyph_contour_point (hb_font_t *font HB_UNUSED, jobject pt = env->CallObjectMethod(fontStrike, sunFontIDs.getGlyphPointMID, glyph, point_index); - + if (pt == NULL) { *x = 0; *y = 0; return true; @@ -238,8 +238,8 @@ _hb_jdk_get_font_funcs (void) hb_font_funcs_t *ff; if (!jdk_ffuncs) { - ff = hb_font_funcs_create(); - + ff = hb_font_funcs_create(); + hb_font_funcs_set_glyph_func(ff, hb_jdk_get_glyph, NULL, NULL); hb_font_funcs_set_glyph_h_advance_func(ff, hb_jdk_get_glyph_h_advance, NULL, NULL); @@ -278,7 +278,7 @@ reference_table(hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) { jobject font2D = jdkFontInfo->font2D; jsize length; jbyte* buffer; - + // HB_TAG_NONE is 0 and is used to get the whole font file. // It is not expected not be needed for JDK. if (tag == 0) { From f82a7d2bdd0f44089aad7ecd1f4726f2e524a2d1 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 18 Jan 2017 08:02:53 +0800 Subject: [PATCH 114/154] 8172529: Use PKIXValidator in jarsigner Reviewed-by: xuelei, mullan, alanb --- .../java.base/share/classes/module-info.java | 2 + .../sun/security/tools/jarsigner/Main.java | 87 ++++++++++--------- .../tools/jarsigner/concise_jarsigner.sh | 45 ++++++++-- 3 files changed, 84 insertions(+), 50 deletions(-) diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index 0c455f827a7..2fd479eb925 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -290,6 +290,8 @@ module java.base { jdk.crypto.token, jdk.jartool, jdk.security.auth; + exports sun.security.validator to + jdk.jartool; exports sun.text.resources to jdk.localedata; exports sun.util.cldr to diff --git a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java index 846be10405c..a42dfe21882 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java +++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java @@ -26,6 +26,8 @@ package sun.security.tools.jarsigner; import java.io.*; +import java.security.cert.CertPathValidatorException; +import java.security.cert.PKIXBuilderParameters; import java.util.*; import java.util.zip.*; import java.util.jar.*; @@ -40,11 +42,9 @@ import java.security.*; import java.net.SocketTimeoutException; import java.net.URL; import java.security.cert.CertPath; -import java.security.cert.CertPathValidator; import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateFactory; import java.security.cert.CertificateNotYetValidException; -import java.security.cert.PKIXParameters; import java.security.cert.TrustAnchor; import java.util.Map.Entry; @@ -54,6 +54,8 @@ import sun.security.pkcs.PKCS7; import sun.security.pkcs.SignerInfo; import sun.security.timestamp.TimestampToken; import sun.security.tools.KeyStoreUtil; +import sun.security.validator.Validator; +import sun.security.validator.ValidatorException; import sun.security.x509.*; import sun.security.util.*; @@ -177,9 +179,7 @@ public class Main { private boolean seeWeak = false; - CertificateFactory certificateFactory; - CertPathValidator validator; - PKIXParameters pkixParameters; + PKIXBuilderParameters pkixParameters; public void run(String args[]) { try { @@ -1623,19 +1623,10 @@ public class Main { try { validateCertChain(certs); } catch (Exception e) { - if (debug) { - e.printStackTrace(); - } - if (e.getCause() != null && - (e.getCause() instanceof CertificateExpiredException || - e.getCause() instanceof CertificateNotYetValidException)) { - // No more warning, we alreay have hasExpiredCert or notYetValidCert - } else { - chainNotValidated = true; - chainNotValidatedReason = e; - sb.append(tab).append(rb.getString(".CertPath.not.validated.")) - .append(e.getLocalizedMessage()).append("]\n"); // TODO - } + chainNotValidated = true; + chainNotValidatedReason = e; + sb.append(tab).append(rb.getString(".CertPath.not.validated.")) + .append(e.getLocalizedMessage()).append("]\n"); // TODO } if (certs.size() == 1 && KeyStoreUtil.isSelfSigned((X509Certificate)certs.get(0))) { @@ -1654,9 +1645,6 @@ public class Main { } try { - - certificateFactory = CertificateFactory.getInstance("X.509"); - validator = CertPathValidator.getInstance("PKIX"); Set tas = new HashSet<>(); try { KeyStore caks = KeyStoreUtil.getCacertsKeyStore(); @@ -1732,7 +1720,7 @@ public class Main { } } finally { try { - pkixParameters = new PKIXParameters(tas); + pkixParameters = new PKIXBuilderParameters(tas, null); pkixParameters.setRevocationEnabled(false); } catch (InvalidAlgorithmParameterException ex) { // Only if tas is empty @@ -1899,17 +1887,8 @@ public class Main { try { validateCertChain(Arrays.asList(certChain)); } catch (Exception e) { - if (debug) { - e.printStackTrace(); - } - if (e.getCause() != null && - (e.getCause() instanceof CertificateExpiredException || - e.getCause() instanceof CertificateNotYetValidException)) { - // No more warning, we already have hasExpiredCert or notYetValidCert - } else { - chainNotValidated = true; - chainNotValidatedReason = e; - } + chainNotValidated = true; + chainNotValidatedReason = e; } if (KeyStoreUtil.isSelfSigned(certChain[0])) { @@ -1966,18 +1945,40 @@ public class Main { } void validateCertChain(List certs) throws Exception { - int cpLen = 0; - out: for (; cpLen 0) { - CertPath cp = certificateFactory.generateCertPath( - (cpLen == certs.size())? certs: certs.subList(0, cpLen)); - validator.validate(cp, pkixParameters); + throw e; } } diff --git a/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh b/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh index 013f90c58c1..b9ec9e83232 100644 --- a/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh +++ b/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh @@ -22,7 +22,7 @@ # # @test -# @bug 6802846 +# @bug 6802846 8172529 # @summary jarsigner needs enhanced cert validation(options) # # @run shell/timeout=240 concise_jarsigner.sh @@ -52,7 +52,7 @@ TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US" KS=js.ks KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa -keysize 1024" JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}" -JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}" +JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -debug" JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}" rm $KS @@ -138,7 +138,7 @@ LINES=`$JARSIGNER -verify a.jar -verbose:summary -certs | grep "more)" | wc -l` [ $LINES = 4 ] || exit $LINENO # ========================================================== -# Second part: exit code 2, 4, 8 +# Second part: exit code 2, 4, 8. # 16 and 32 already covered in the first part # ========================================================== @@ -174,11 +174,14 @@ $JARSIGNER -strict -keystore $KS -storepass changeit a.jar goodku $JARSIGNER -strict -keystore $KS -storepass changeit a.jar goodeku [ $? = 0 ] || exit $LINENO -# badchain signed by ca, but ca is removed later +# badchain signed by ca1, but ca1 is removed later $KT -genkeypair -alias badchain -dname CN=badchain -validity 365 -$KT -certreq -alias badchain | $KT -gencert -alias ca -validity 365 | \ +$KT -genkeypair -alias ca1 -dname CN=ca1 -ext bc -validity 365 +$KT -certreq -alias badchain | $KT -gencert -alias ca1 -validity 365 | \ $KT -importcert -alias badchain -$KT -delete -alias ca +# save ca1.cert for easy replay +$KT -exportcert -file ca1.cert -alias ca1 +$KT -delete -alias ca1 $JARSIGNER -strict -keystore $KS -storepass changeit a.jar badchain [ $? = 4 ] || exit $LINENO @@ -204,13 +207,41 @@ $JARSIGNER -strict -keystore $KS -storepass changeit a.jar altchain $JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain [ $? = 0 ] || exit $LINENO -# but if ca2 is removed, -certchain does not work +# if ca2 is removed, -certchain still work because altchain is a self-signed entry and +# it is trusted by jarsigner +# save ca2.cert for easy replay +$KT -exportcert -file ca2.cert -alias ca2 $KT -delete -alias ca2 $JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain +[ $? = 0 ] || exit $LINENO + +# if cert is imported, -certchain won't work because this certificate entry is not trusted +$KT -importcert -file certchain -alias altchain -noprompt +$JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain [ $? = 4 ] || exit $LINENO $JARSIGNER -verify a.jar [ $? = 0 ] || exit $LINENO +# ========================================================== +# 8172529 +# ========================================================== + +$KT -genkeypair -alias ee -dname CN=ee +$KT -genkeypair -alias caone -dname CN=caone +$KT -genkeypair -alias catwo -dname CN=catwo + +$KT -certreq -alias ee | $KT -gencert -alias catwo -rfc > ee.cert +$KT -certreq -alias catwo | $KT -gencert -alias caone -sigalg MD5withRSA -rfc > catwo.cert + +# This certchain contains a cross-signed weak catwo.cert +cat ee.cert catwo.cert | $KT -importcert -alias ee + +$JAR cvf a.jar A1.class +$JARSIGNER -strict -keystore $KS -storepass changeit a.jar ee +[ $? = 0 ] || exit $LINENO +$JARSIGNER -strict -keystore $KS -storepass changeit -verify a.jar +[ $? = 0 ] || exit $LINENO + echo OK exit 0 From 140b10aedb1a2d03863f9628695a44a9a46e39b3 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 18 Jan 2017 11:35:31 +0530 Subject: [PATCH 115/154] 8172012: [TEST_BUG] delays needed in javax/swing/JTree/4633594/bug4633594.java Reviewed-by: yan, serb --- .../swing/JTree/4633594/JTreeFocusTest.java | 232 ++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java diff --git a/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java b/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java new file mode 100644 index 00000000000..800bf10be4d --- /dev/null +++ b/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 4633594 8172012 + @summary No way to pass focus from a JTree to a GUI placed inside the tree node + @run main JTreeFocusTest +*/ +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.util.EventObject; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.border.BevelBorder; +import javax.swing.border.CompoundBorder; +import javax.swing.border.LineBorder; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellEditor; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; + +public class JTreeFocusTest { + + private static DefaultMutableTreeNode root; + Robot robot; + static boolean passed = false; + boolean rootSelected = false; + boolean keysTyped = false; + private volatile Point p = null; + private static JFrame fr; + private static volatile JTree tree = null; + + public static void main(String[] args) throws Exception{ + new JTreeFocusTest(); + } + + void blockTillDisplayed(JComponent comp) throws Exception { + while (p == null) { + try { + SwingUtilities.invokeAndWait(() -> { + p = comp.getLocationOnScreen(); + }); + } catch (IllegalStateException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + } + } + } + } + + public JTreeFocusTest() throws Exception { + SwingUtilities.invokeAndWait(() -> { + fr = new JFrame("Test"); + + root = new DefaultMutableTreeNode("root"); + JPanel p = new JPanel(); + p.setBorder(new CompoundBorder(new BevelBorder(BevelBorder.RAISED), + new LineBorder(UIManager.getColor("control"), 7))); + p.setLayout(new GridLayout(2,2)); + p.add(new JLabel("one")); + JTextField tf1 = new JTextField(10); + p.add(tf1); + p.add(new JLabel("two")); + p.add(new JTextField(10)); + root.add(new DefaultMutableTreeNode(p)); + + tf1.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + setPassed(true); + } + }); + + DefaultTreeModel model = new DefaultTreeModel(root); + tree = new JTree(model) { + public void processKeyEvent(KeyEvent e) { + super.processKeyEvent(e); + if (e.getKeyCode()==KeyEvent.VK_F2) { + synchronized (JTreeFocusTest.this) { + keysTyped = true; + JTreeFocusTest.this.notifyAll(); + } + } + } + }; + + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + if ( root.equals(e.getPath().getLastPathComponent()) ) { + synchronized (JTreeFocusTest.this) { + rootSelected = true; + JTreeFocusTest.this.notifyAll(); + } + } + } + }); + + tree.setEditable(true); + DefaultTreeCellRenderer renderer = new FormRenderer(); + tree.setCellRenderer(renderer); + DefaultTreeCellEditor editor = new FormEditor(tree, renderer); + tree.setCellEditor(editor); + fr.getContentPane().add(tree); + + fr.setSize(300,400); + fr.setVisible(true); + }); + blockTillDisplayed(tree); + SwingUtilities.invokeAndWait(() -> { + tree.requestFocus(); + tree.setSelectionRow(0); + }); + + try { + synchronized (this) { + while (!rootSelected) { + JTreeFocusTest.this.wait(); + } + } + + robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(150); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_RIGHT); + robot.keyRelease(KeyEvent.VK_RIGHT); + robot.keyPress(KeyEvent.VK_F2); + robot.keyRelease(KeyEvent.VK_F2); + + synchronized (this) { + while (!keysTyped) { + JTreeFocusTest.this.wait(); + } + } + Thread.sleep(3000); + } catch(Throwable t) { + t.printStackTrace(); + } + destroy(); + } + + public void destroy() throws Exception { + SwingUtilities.invokeAndWait(()->fr.dispose()); + if ( !isPassed() ) { + throw new RuntimeException("Focus wasn't transferred to the proper component"); + } + } + + synchronized void setPassed(boolean passed) { + this.passed = passed; + } + + synchronized boolean isPassed() { + return passed; + } + + static JTree createTree() { + return tree; + } + + class FormRenderer extends DefaultTreeCellRenderer { + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean sel, + boolean expanded, + boolean leaf, int row, + boolean hasFocus) { + Object obj = ((DefaultMutableTreeNode)value).getUserObject(); + if (obj instanceof Component){ + return (Component)((DefaultMutableTreeNode)value).getUserObject(); + } + return super.getTreeCellRendererComponent(tree, value, sel, + expanded, leaf, row, + hasFocus); + } + } + + class FormEditor extends DefaultTreeCellEditor { + public FormEditor(JTree tree, DefaultTreeCellRenderer renderer) { + super(tree, renderer); + } + + public Component getTreeCellEditorComponent(JTree tree, Object value, + boolean sel, + boolean expanded, + boolean leaf, int row) { + Object obj = ((DefaultMutableTreeNode)value).getUserObject(); + if (obj instanceof Component){ + return (Component)((DefaultMutableTreeNode)value).getUserObject(); + } + return super.getTreeCellEditorComponent(tree, value, sel, + expanded, leaf, row); + } + + public boolean shouldSelectCell(EventObject anEvent) { + //return super.shouldSelectCell(anEvent); + return true; + } + } +} From 85b40fde0b30c1eed6766a4ac9e81891d3c69161 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 18 Jan 2017 10:24:47 +0100 Subject: [PATCH 116/154] 8037325: Class.getConstructor() performance regression Co-authored-by: Sean Mullan Reviewed-by: mchung --- .../share/classes/java/lang/Class.java | 256 ++++++++++-------- .../classes/sun/reflect/misc/ReflectUtil.java | 55 +++- 2 files changed, 184 insertions(+), 127 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java index 589ba51089c..b0e3d3af0cd 100644 --- a/jdk/src/java.base/share/classes/java/lang/Class.java +++ b/jdk/src/java.base/share/classes/java/lang/Class.java @@ -508,8 +508,9 @@ public final class Class implements java.io.Serializable, public T newInstance() throws InstantiationException, IllegalAccessException { - if (System.getSecurityManager() != null) { - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false); } // NOTE: the following code may not be strictly correct under @@ -1223,38 +1224,27 @@ public final class Class implements java.io.Serializable, // Perform access check final Class enclosingCandidate = enclosingInfo.getEnclosingClass(); - enclosingCandidate.checkMemberAccess(Member.DECLARED, - Reflection.getCallerClass(), true); - // Client is ok to access declared methods but j.l.Class might not be. - Method[] candidates = AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public Method[] run() { - return enclosingCandidate.getDeclaredMethods(); - } - }); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + enclosingCandidate.checkMemberAccess(sm, Member.DECLARED, + Reflection.getCallerClass(), true); + } + Method[] candidates = enclosingCandidate.privateGetDeclaredMethods(false); + /* * Loop over all declared methods; match method name, * number of and type of parameters, *and* return * type. Matching return type is also necessary * because of covariant returns, etc. */ - for(Method m: candidates) { - if (m.getName().equals(enclosingInfo.getName()) ) { - Class[] candidateParamClasses = m.getParameterTypes(); - if (candidateParamClasses.length == parameterClasses.length) { - boolean matches = true; - for(int i = 0; i < candidateParamClasses.length; i++) { - if (!candidateParamClasses[i].equals(parameterClasses[i])) { - matches = false; - break; - } - } - - if (matches) { // finally, check return type - if (m.getReturnType().equals(returnType) ) - return m; - } + ReflectionFactory fact = getReflectionFactory(); + for (Method m : candidates) { + if (m.getName().equals(enclosingInfo.getName()) && + arrayContentsEq(parameterClasses, + fact.getExecutableSharedParameterTypes(m))) { + // finally, check return type + if (m.getReturnType().equals(returnType)) { + return fact.copyMethod(m); } } } @@ -1390,33 +1380,23 @@ public final class Class implements java.io.Serializable, // Perform access check final Class enclosingCandidate = enclosingInfo.getEnclosingClass(); - enclosingCandidate.checkMemberAccess(Member.DECLARED, - Reflection.getCallerClass(), true); - // Client is ok to access declared methods but j.l.Class might not be. - Constructor[] candidates = AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public Constructor[] run() { - return enclosingCandidate.getDeclaredConstructors(); - } - }); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + enclosingCandidate.checkMemberAccess(sm, Member.DECLARED, + Reflection.getCallerClass(), true); + } + + Constructor[] candidates = enclosingCandidate + .privateGetDeclaredConstructors(false); /* * Loop over all declared constructors; match number * of and type of parameters. */ - for(Constructor c: candidates) { - Class[] candidateParamClasses = c.getParameterTypes(); - if (candidateParamClasses.length == parameterClasses.length) { - boolean matches = true; - for(int i = 0; i < candidateParamClasses.length; i++) { - if (!candidateParamClasses[i].equals(parameterClasses[i])) { - matches = false; - break; - } - } - - if (matches) - return c; + ReflectionFactory fact = getReflectionFactory(); + for (Constructor c : candidates) { + if (arrayContentsEq(parameterClasses, + fact.getExecutableSharedParameterTypes(c))) { + return fact.copyConstructor(c); } } @@ -1446,9 +1426,13 @@ public final class Class implements java.io.Serializable, public Class getDeclaringClass() throws SecurityException { final Class candidate = getDeclaringClass0(); - if (candidate != null) - candidate.checkPackageAccess( + if (candidate != null) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + candidate.checkPackageAccess(sm, ClassLoader.getClassLoader(Reflection.getCallerClass()), true); + } + } return candidate; } @@ -1496,9 +1480,13 @@ public final class Class implements java.io.Serializable, enclosingCandidate = enclosingClass; } - if (enclosingCandidate != null) - enclosingCandidate.checkPackageAccess( + if (enclosingCandidate != null) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + enclosingCandidate.checkPackageAccess(sm, ClassLoader.getClassLoader(Reflection.getCallerClass()), true); + } + } return enclosingCandidate; } @@ -1688,7 +1676,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Class[] getClasses() { - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false); + } // Privileged so this implementation can look at DECLARED classes, // something the caller might not have privilege to do. The code here @@ -1754,7 +1745,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Field[] getFields() throws SecurityException { - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); + } return copyFields(privateGetPublicFields(null)); } @@ -1841,7 +1835,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Method[] getMethods() throws SecurityException { - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); + } return copyMethods(privateGetPublicMethods()); } @@ -1877,7 +1874,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Constructor[] getConstructors() throws SecurityException { - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); + } return copyConstructors(privateGetDeclaredConstructors(true)); } @@ -1928,7 +1928,10 @@ public final class Class implements java.io.Serializable, public Field getField(String name) throws NoSuchFieldException, SecurityException { Objects.requireNonNull(name); - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); + } Field field = getField0(name); if (field == null) { throw new NoSuchFieldException(name); @@ -2034,10 +2037,13 @@ public final class Class implements java.io.Serializable, public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException { Objects.requireNonNull(name); - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); + } Method method = getMethod0(name, parameterTypes); if (method == null) { - throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); + throw new NoSuchMethodException(methodToString(name, parameterTypes)); } return getReflectionFactory().copyMethod(method); } @@ -2092,8 +2098,12 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Constructor getConstructor(Class... parameterTypes) - throws NoSuchMethodException, SecurityException { - checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); + throws NoSuchMethodException, SecurityException + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); + } return getReflectionFactory().copyConstructor( getConstructor0(parameterTypes, Member.PUBLIC)); } @@ -2136,7 +2146,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Class[] getDeclaredClasses() throws SecurityException { - checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), false); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), false); + } return getDeclaredClasses0(); } @@ -2185,7 +2198,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Field[] getDeclaredFields() throws SecurityException { - checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); + } return copyFields(privateGetDeclaredFields(false)); } @@ -2244,7 +2260,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Method[] getDeclaredMethods() throws SecurityException { - checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); + } return copyMethods(privateGetDeclaredMethods(false)); } @@ -2289,7 +2308,10 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Constructor[] getDeclaredConstructors() throws SecurityException { - checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); + } return copyConstructors(privateGetDeclaredConstructors(false)); } @@ -2338,7 +2360,10 @@ public final class Class implements java.io.Serializable, public Field getDeclaredField(String name) throws NoSuchFieldException, SecurityException { Objects.requireNonNull(name); - checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); + } Field field = searchFields(privateGetDeclaredFields(false), name); if (field == null) { throw new NoSuchFieldException(name); @@ -2399,10 +2424,13 @@ public final class Class implements java.io.Serializable, public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException { Objects.requireNonNull(name); - checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); + } Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes); if (method == null) { - throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); + throw new NoSuchMethodException(methodToString(name, parameterTypes)); } return getReflectionFactory().copyMethod(method); } @@ -2448,8 +2476,13 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Constructor getDeclaredConstructor(Class... parameterTypes) - throws NoSuchMethodException, SecurityException { - checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); + throws NoSuchMethodException, SecurityException + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); + } + return getReflectionFactory().copyConstructor( getConstructor0(parameterTypes, Member.DECLARED)); } @@ -2697,51 +2730,49 @@ public final class Class implements java.io.Serializable, * *

Default policy: allow all clients access with normal Java access * control. + * + *

NOTE: should only be called if a SecurityManager is installed */ - private void checkMemberAccess(int which, Class caller, boolean checkProxyInterfaces) { - final SecurityManager s = System.getSecurityManager(); - if (s != null) { - /* Default policy allows access to all {@link Member#PUBLIC} members, - * as well as access to classes that have the same class loader as the caller. - * In all other cases, it requires RuntimePermission("accessDeclaredMembers") - * permission. - */ - final ClassLoader ccl = ClassLoader.getClassLoader(caller); + private void checkMemberAccess(SecurityManager sm, int which, + Class caller, boolean checkProxyInterfaces) { + /* Default policy allows access to all {@link Member#PUBLIC} members, + * as well as access to classes that have the same class loader as the caller. + * In all other cases, it requires RuntimePermission("accessDeclaredMembers") + * permission. + */ + final ClassLoader ccl = caller.getClassLoader0(); + if (which != Member.PUBLIC) { final ClassLoader cl = getClassLoader0(); - if (which != Member.PUBLIC) { - if (ccl != cl) { - s.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION); - } + if (ccl != cl) { + sm.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION); } - this.checkPackageAccess(ccl, checkProxyInterfaces); } + this.checkPackageAccess(sm, ccl, checkProxyInterfaces); } /* * Checks if a client loaded in ClassLoader ccl is allowed to access this * class under the current package access policy. If access is denied, * throw a SecurityException. + * + * NOTE: this method should only be called if a SecurityManager is active */ - private void checkPackageAccess(final ClassLoader ccl, boolean checkProxyInterfaces) { - final SecurityManager s = System.getSecurityManager(); - if (s != null) { - final ClassLoader cl = getClassLoader0(); + private void checkPackageAccess(SecurityManager sm, final ClassLoader ccl, + boolean checkProxyInterfaces) { + final ClassLoader cl = getClassLoader0(); - if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) { - String name = this.getName(); - int i = name.lastIndexOf('.'); - if (i != -1) { - // skip the package access check on a proxy class in default proxy package - String pkg = name.substring(0, i); - if (!Proxy.isProxyClass(this) || ReflectUtil.isNonPublicProxyClass(this)) { - s.checkPackageAccess(pkg); - } + if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) { + String pkg = this.getPackageName(); + if (pkg != null && !pkg.isEmpty()) { + // skip the package access check on a proxy class in default proxy package + if (!Proxy.isProxyClass(this) || ReflectUtil.isNonPublicProxyClass(this)) { + sm.checkPackageAccess(pkg); } } - // check package access on the proxy interfaces - if (checkProxyInterfaces && Proxy.isProxyClass(this)) { - ReflectUtil.checkProxyPackageAccess(ccl, this.getInterfaces()); - } + } + // check package access on the proxy interfaces + if (checkProxyInterfaces && Proxy.isProxyClass(this)) { + ReflectUtil.checkProxyPackageAccess(ccl, this.getInterfaces()); } } @@ -2755,11 +2786,9 @@ public final class Class implements java.io.Serializable, while (c.isArray()) { c = c.getComponentType(); } - String baseName = c.getName(); - int index = baseName.lastIndexOf('.'); - if (index != -1) { - name = baseName.substring(0, index).replace('.', '/') - +"/"+name; + String baseName = c.getPackageName(); + if (baseName != null && !baseName.isEmpty()) { + name = baseName.replace('.', '/') + "/" + name; } } else { name = name.substring(1); @@ -3233,7 +3262,7 @@ public final class Class implements java.io.Serializable, return constructor; } } - throw new NoSuchMethodException(getName() + "." + argumentTypesToString(parameterTypes)); + throw new NoSuchMethodException(methodToString("", parameterTypes)); } // @@ -3294,8 +3323,11 @@ public final class Class implements java.io.Serializable, private native Constructor[] getDeclaredConstructors0(boolean publicOnly); private native Class[] getDeclaredClasses0(); - private static String argumentTypesToString(Class[] argTypes) { - StringJoiner sj = new StringJoiner(", ", "(", ")"); + /** + * Helper method to get the method name from arguments. + */ + private String methodToString(String name, Class[] argTypes) { + StringJoiner sj = new StringJoiner(", ", getName() + "." + name + "(", ")"); if (argTypes != null) { for (int i = 0; i < argTypes.length; i++) { Class c = argTypes[i]; diff --git a/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java index c275b0b91a6..738abcb9426 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java +++ b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java @@ -96,7 +96,7 @@ public final class ReflectUtil { final Class declaringClass = m.getDeclaringClass(); - checkPackageAccess(declaringClass); + privateCheckPackageAccess(sm, declaringClass); if (Modifier.isPublic(m.getModifiers()) && Modifier.isPublic(declaringClass.getModifiers())) @@ -114,9 +114,27 @@ public final class ReflectUtil { * also check the package access on the proxy interfaces. */ public static void checkPackageAccess(Class clazz) { - checkPackageAccess(clazz.getName()); + SecurityManager s = System.getSecurityManager(); + if (s != null) { + privateCheckPackageAccess(s, clazz); + } + } + + /** + * NOTE: should only be called if a SecurityManager is installed + */ + private static void privateCheckPackageAccess(SecurityManager s, Class clazz) { + while (clazz.isArray()) { + clazz = clazz.getComponentType(); + } + + String pkg = clazz.getPackageName(); + if (pkg != null && !pkg.isEmpty()) { + s.checkPackageAccess(pkg); + } + if (isNonPublicProxyClass(clazz)) { - checkProxyPackageAccess(clazz); + privateCheckProxyPackageAccess(s, clazz); } } @@ -195,15 +213,21 @@ public final class ReflectUtil { public static void checkProxyPackageAccess(Class clazz) { SecurityManager s = System.getSecurityManager(); if (s != null) { - // check proxy interfaces if the given class is a proxy class - if (Proxy.isProxyClass(clazz)) { - for (Class intf : clazz.getInterfaces()) { - checkPackageAccess(intf); - } - } + privateCheckProxyPackageAccess(s, clazz); } } + /** + * NOTE: should only be called if a SecurityManager is installed + */ + private static void privateCheckProxyPackageAccess(SecurityManager s, Class clazz) { + // check proxy interfaces if the given class is a proxy class + if (Proxy.isProxyClass(clazz)) { + for (Class intf : clazz.getInterfaces()) { + privateCheckPackageAccess(s, intf); + } + } + } /** * Access check on the interfaces that a proxy class implements and throw * {@code SecurityException} if it accesses a restricted package from @@ -220,7 +244,7 @@ public final class ReflectUtil { for (Class intf : interfaces) { ClassLoader cl = intf.getClassLoader(); if (needsPackageAccessCheck(ccl, cl)) { - checkPackageAccess(intf); + privateCheckPackageAccess(sm, intf); } } } @@ -236,10 +260,11 @@ public final class ReflectUtil { * package that bypasses checkPackageAccess. */ public static boolean isNonPublicProxyClass(Class cls) { - String name = cls.getName(); - int i = name.lastIndexOf('.'); - String pkg = (i != -1) ? name.substring(0, i) : ""; - return Proxy.isProxyClass(cls) && !pkg.startsWith(PROXY_PACKAGE); + if (!Proxy.isProxyClass(cls)) { + return false; + } + String pkg = cls.getPackageName(); + return pkg == null || !pkg.startsWith(PROXY_PACKAGE); } /** @@ -255,7 +280,7 @@ public final class ReflectUtil { // check if it is a valid proxy instance if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) { throw new IllegalArgumentException("Not a Proxy instance"); -} + } if (Modifier.isStatic(method.getModifiers())) { throw new IllegalArgumentException("Can't handle static method"); } From 208954cc4eb8b8d55877554873420ae9557f256e Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 18 Jan 2017 09:36:24 +0000 Subject: [PATCH 117/154] 8171380: Remove all exports from jdk.jlink Reviewed-by: alanb, mchung, sundar --- jdk/src/jdk.jlink/share/classes/module-info.java | 2 -- jdk/test/ProblemList.txt | 2 ++ jdk/test/TEST.ROOT | 4 ++-- jdk/test/tools/jlink/DefaultProviderTest.java | 1 + jdk/test/tools/jlink/ImageFileCreatorTest.java | 1 + jdk/test/tools/jlink/ImageFilePoolTest.java | 1 + jdk/test/tools/jlink/IntegrationTest.java | 1 + jdk/test/tools/jlink/JLink2Test.java | 1 + jdk/test/tools/jlink/JLinkOptionsTest.java | 1 + jdk/test/tools/jlink/JLinkPostProcessingTest.java | 1 + jdk/test/tools/jlink/JLinkTest.java | 1 + jdk/test/tools/jlink/ResourcePoolTest.java | 1 + jdk/test/tools/jlink/plugins/CompressorPluginTest.java | 1 + jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java | 1 + jdk/test/tools/jlink/plugins/ExcludePluginTest.java | 1 + jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java | 1 + jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java | 1 + jdk/test/tools/jlink/plugins/LastSorterTest.java | 5 +++-- jdk/test/tools/jlink/plugins/PluginsNegativeTest.java | 5 +++-- jdk/test/tools/jlink/plugins/PrevisitorTest.java | 5 +++-- jdk/test/tools/jlink/plugins/StringSharingPluginTest.java | 1 + jdk/test/tools/jlink/plugins/StripDebugPluginTest.java | 1 + jdk/test/tools/pack200/Utils.java | 1 + 23 files changed, 30 insertions(+), 10 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/module-info.java b/jdk/src/jdk.jlink/share/classes/module-info.java index 69c4ae9952e..00140adb802 100644 --- a/jdk/src/jdk.jlink/share/classes/module-info.java +++ b/jdk/src/jdk.jlink/share/classes/module-info.java @@ -24,8 +24,6 @@ */ module jdk.jlink { - exports jdk.tools.jlink.plugin; - requires jdk.internal.opt; requires jdk.jdeps; diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 18cc959c84e..b0d21d7f918 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -258,6 +258,8 @@ tools/jimage/JImageVerifyTest.java 8169713 generic- tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java 8169971 windows-x64 +tools/jlink/CustomPluginTest.java 8172864 generic-all + ############################################################################ # jdk_jdi diff --git a/jdk/test/TEST.ROOT b/jdk/test/TEST.ROOT index c61b9bca4e1..e822c4f2aae 100644 --- a/jdk/test/TEST.ROOT +++ b/jdk/test/TEST.ROOT @@ -26,8 +26,8 @@ groups=TEST.groups [closed/TEST.groups] # Allow querying of various System properties in @requires clauses requires.properties=sun.arch.data.model java.runtime.name -# Tests using jtreg 4.2 b04 features -requiredVersion=4.2 b04 +# Tests using jtreg 4.2 b05 features +requiredVersion=4.2 b05 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them diff --git a/jdk/test/tools/jlink/DefaultProviderTest.java b/jdk/test/tools/jlink/DefaultProviderTest.java index eb27d570301..47ad9c4b043 100644 --- a/jdk/test/tools/jlink/DefaultProviderTest.java +++ b/jdk/test/tools/jlink/DefaultProviderTest.java @@ -44,6 +44,7 @@ import tests.Helper; * @modules java.base/jdk.internal.jimage * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler diff --git a/jdk/test/tools/jlink/ImageFileCreatorTest.java b/jdk/test/tools/jlink/ImageFileCreatorTest.java index c88ae4bada1..84f77340f42 100644 --- a/jdk/test/tools/jlink/ImageFileCreatorTest.java +++ b/jdk/test/tools/jlink/ImageFileCreatorTest.java @@ -48,6 +48,7 @@ import jdk.tools.jlink.plugin.ResourcePool; * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.builder + * jdk.jlink/jdk.tools.jlink.plugin * java.base/jdk.internal.jimage * @run main/othervm -verbose:gc -Xmx1g ImageFileCreatorTest */ diff --git a/jdk/test/tools/jlink/ImageFilePoolTest.java b/jdk/test/tools/jlink/ImageFilePoolTest.java index 2c1b80f439e..9f7687eb4b5 100644 --- a/jdk/test/tools/jlink/ImageFilePoolTest.java +++ b/jdk/test/tools/jlink/ImageFilePoolTest.java @@ -26,6 +26,7 @@ * @summary Test a pool containing external files. * @author Andrei Eremeev * @modules jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * @run build ImageFilePoolTest * @run main ImageFilePoolTest */ diff --git a/jdk/test/tools/jlink/IntegrationTest.java b/jdk/test/tools/jlink/IntegrationTest.java index e9666676b25..9bf019069ba 100644 --- a/jdk/test/tools/jlink/IntegrationTest.java +++ b/jdk/test/tools/jlink/IntegrationTest.java @@ -62,6 +62,7 @@ import tests.JImageGenerator; * jdk.jlink/jdk.tools.jlink.builder * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler diff --git a/jdk/test/tools/jlink/JLink2Test.java b/jdk/test/tools/jlink/JLink2Test.java index 8106fadee32..df2873a28b2 100644 --- a/jdk/test/tools/jlink/JLink2Test.java +++ b/jdk/test/tools/jlink/JLink2Test.java @@ -29,6 +29,7 @@ * @modules java.base/jdk.internal.jimage * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler diff --git a/jdk/test/tools/jlink/JLinkOptionsTest.java b/jdk/test/tools/jlink/JLinkOptionsTest.java index d38de3a0488..5fcadd6d598 100644 --- a/jdk/test/tools/jlink/JLinkOptionsTest.java +++ b/jdk/test/tools/jlink/JLinkOptionsTest.java @@ -39,6 +39,7 @@ import tests.Helper; * @modules java.base/jdk.internal.jimage * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler diff --git a/jdk/test/tools/jlink/JLinkPostProcessingTest.java b/jdk/test/tools/jlink/JLinkPostProcessingTest.java index 61bf3463cee..b04b3b84286 100644 --- a/jdk/test/tools/jlink/JLinkPostProcessingTest.java +++ b/jdk/test/tools/jlink/JLinkPostProcessingTest.java @@ -46,6 +46,7 @@ import tests.Helper; * @modules java.base/jdk.internal.jimage * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler diff --git a/jdk/test/tools/jlink/JLinkTest.java b/jdk/test/tools/jlink/JLinkTest.java index 874c9dfef32..e137ce426f6 100644 --- a/jdk/test/tools/jlink/JLinkTest.java +++ b/jdk/test/tools/jlink/JLinkTest.java @@ -48,6 +48,7 @@ import tests.JImageGenerator; * @modules java.base/jdk.internal.jimage * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jimage * jdk.compiler * @build tests.* diff --git a/jdk/test/tools/jlink/ResourcePoolTest.java b/jdk/test/tools/jlink/ResourcePoolTest.java index 2eda43333f3..3002161eee3 100644 --- a/jdk/test/tools/jlink/ResourcePoolTest.java +++ b/jdk/test/tools/jlink/ResourcePoolTest.java @@ -26,6 +26,7 @@ * @summary Test a pool containing jimage resources and classes. * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * @run build ResourcePoolTest * @run main ResourcePoolTest */ diff --git a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java index df3b7f7a49d..aea5c21424f 100644 --- a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java +++ b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java @@ -28,6 +28,7 @@ * @modules java.base/jdk.internal.jimage.decompressor * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * @run main CompressorPluginTest */ import java.net.URI; diff --git a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java index 01c31699e87..29ee71ff522 100644 --- a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java @@ -27,6 +27,7 @@ * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * @run main ExcludeFilesPluginTest */ diff --git a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java index b45a453187c..fee21c97e43 100644 --- a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java +++ b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java @@ -27,6 +27,7 @@ * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * @run main ExcludePluginTest */ diff --git a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java index 48947c1f50e..f581e9bad90 100644 --- a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java +++ b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java @@ -27,6 +27,7 @@ * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * @run main ExcludeVMPluginTest */ import java.io.ByteArrayInputStream; diff --git a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java index 6e6b57f89dd..6766a1df256 100644 --- a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java @@ -48,6 +48,7 @@ import tests.Result; * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler diff --git a/jdk/test/tools/jlink/plugins/LastSorterTest.java b/jdk/test/tools/jlink/plugins/LastSorterTest.java index 0415a431eef..276ce50bf01 100644 --- a/jdk/test/tools/jlink/plugins/LastSorterTest.java +++ b/jdk/test/tools/jlink/plugins/LastSorterTest.java @@ -25,8 +25,9 @@ * @test * @summary Test last sorter property * @author Jean-Francois Denise - * @modules jdk.jlink/jdk.tools.jlink.internal - * jdk.jlink/jdk.tools.jlink + * @modules jdk.jlink/jdk.tools.jlink + * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * @run main/othervm LastSorterTest */ diff --git a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java index 7c7dc268697..6119fe41d92 100644 --- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java +++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java @@ -25,8 +25,9 @@ * @test * @summary Negative test for ImagePluginStack. * @author Andrei Eremeev - * @modules jdk.jlink/jdk.tools.jlink.internal - * jdk.jlink/jdk.tools.jlink + * @modules jdk.jlink/jdk.tools.jlink + * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * @run main/othervm PluginsNegativeTest */ import java.lang.reflect.Layer; diff --git a/jdk/test/tools/jlink/plugins/PrevisitorTest.java b/jdk/test/tools/jlink/plugins/PrevisitorTest.java index 8c42075d6c3..2545e88160a 100644 --- a/jdk/test/tools/jlink/plugins/PrevisitorTest.java +++ b/jdk/test/tools/jlink/plugins/PrevisitorTest.java @@ -25,8 +25,9 @@ * @test * @summary Test previsitor * @author Andrei Eremeev - * @modules jdk.jlink/jdk.tools.jlink.internal - * jdk.jlink/jdk.tools.jlink + * @modules jdk.jlink/jdk.tools.jlink + * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * @run main/othervm PrevisitorTest */ import java.nio.ByteOrder; diff --git a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java index 9cd1da6f0e7..8919129bbc3 100644 --- a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java +++ b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java @@ -30,6 +30,7 @@ * java.base/jdk.internal.jimage.decompressor * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.jdeps/com.sun.tools.classfile diff --git a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java index 73028bd031d..5cfed46e2a2 100644 --- a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java +++ b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java @@ -30,6 +30,7 @@ * @modules java.base/jdk.internal.jimage * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins + * jdk.jlink/jdk.tools.jlink.plugin * jdk.jlink/jdk.tools.jimage * jdk.jlink/jdk.tools.jmod * jdk.jdeps/com.sun.tools.classfile diff --git a/jdk/test/tools/pack200/Utils.java b/jdk/test/tools/pack200/Utils.java index 76ab9aaba44..c0fe317ce84 100644 --- a/jdk/test/tools/pack200/Utils.java +++ b/jdk/test/tools/pack200/Utils.java @@ -111,6 +111,7 @@ class Utils { compiler("-d", XCLASSES.getName(), + "--add-modules=jdk.jdeps", "--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", "@" + tmpFile.getAbsolutePath()); From 433cd91ee2c75f2ec5def748fd1eee89609855e3 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 18 Jan 2017 11:47:36 +0000 Subject: [PATCH 118/154] 8172886: Add a test that shows how the LogManager can be implemented by a module Reviewed-by: mchung --- .../LogManagerInModuleTest.java | 87 +++++++++++++++++++ .../LogManagerInModule/logging.properties | 56 ++++++++++++ .../test.config/module-info.java | 31 +++++++ .../test.config/test/config/LogConfig.java | 51 +++++++++++ .../test.handlers/module-info.java | 31 +++++++ .../test/handlers/TestHandler.java | 47 ++++++++++ .../test.logmanager/module-info.java | 31 +++++++ .../test/logmanager/TestLogManager.java | 34 ++++++++ 8 files changed, 368 insertions(+) create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/LogManagerInModuleTest.java create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/logging.properties create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/test.config/module-info.java create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/test.config/test/config/LogConfig.java create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/module-info.java create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/test/handlers/TestHandler.java create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/module-info.java create mode 100644 jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/test/logmanager/TestLogManager.java diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/LogManagerInModuleTest.java b/jdk/test/java/util/logging/modules/LogManagerInModule/LogManagerInModuleTest.java new file mode 100644 index 00000000000..7dbe5213704 --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/LogManagerInModuleTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.nio.file.Paths; +import java.util.logging.Handler; +import java.util.logging.LogManager; +import java.util.logging.Logger; + +/** + * @test + * @bug 8172886 + * @summary Verifies that a custom LogManager or custom Handler can be + * instantiated by the logging system if they are in a package + * that is exported to java.logging by a module. + * @build test.logmanager/test.logmanager.TestLogManager + * test.handlers/test.handlers.TestHandler + * test.config/test.config.LogConfig + * LogManagerInModuleTest + * @run main/othervm --add-modules test.logmanager,test.handlers + * -Djava.util.logging.manager=test.logmanager.TestLogManager + * LogManagerInModuleTest + * @run main/othervm --add-modules test.logmanager,test.handlers,test.config + * -Djava.util.logging.manager=test.logmanager.TestLogManager + * -Djava.util.logging.config.class=test.config.LogConfig + * LogManagerInModuleTest + * + * @author danielfuchs + */ +public class LogManagerInModuleTest { + + public static void main(String[] args) throws Exception { + if (System.getProperty("java.util.logging.config.class", null) == null) { + System.setProperty("java.util.logging.config.file", + Paths.get(System.getProperty("test.src", "src"), + "logging.properties").toString()); + } + // sanity check + if (LogManagerInModuleTest.class.getModule().isNamed()) { + throw new RuntimeException("Unexpected named module for " + + LogManagerInModuleTest.class + ": " + + LogManagerInModuleTest.class.getModule().getName()); + } + + // now check that the LogManager was correctly instantiated. + LogManager manager = LogManager.getLogManager(); + System.out.println("LogManager: " + manager); + Class logManagerClass = manager.getClass(); + if (!"test.logmanager".equals(logManagerClass.getModule().getName())) { + throw new RuntimeException("Bad module for log manager: " + + logManagerClass.getModule() + "; class is: " + + logManagerClass.getName()); + } + + Logger logger = Logger.getLogger("com.xyz.foo"); + Handler[] handlers = logger.getHandlers(); + if (handlers.length != 1) { + throw new RuntimeException("Expected 1 handler, found " + handlers.length); + } + Class handlerClass = handlers[0].getClass(); + if (!"test.handlers".equals(handlerClass.getModule().getName())) { + throw new RuntimeException("Bad module for handler: " + + handlerClass.getModule() + "; class is: " + + handlerClass.getName()); + } + } + +} diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/logging.properties b/jdk/test/java/util/logging/modules/LogManagerInModule/logging.properties new file mode 100644 index 00000000000..6b4bd6dbdf2 --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/logging.properties @@ -0,0 +1,56 @@ +############################################################ +# Global properties +############################################################ + +# "handlers" specifies a comma separated list of log Handler +# classes. These handlers will be installed during VM startup. +# Note that these classes must be on the system classpath. +# By default we only configure a ConsoleHandler, which will only +# show messages at the INFO and above levels. +handlers= java.util.logging.ConsoleHandler + +# To also add the FileHandler, use the following line instead. +#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler + +# Default global logging level. +# This specifies which kinds of events are logged across +# all loggers. For any given facility this global level +# can be overriden by a facility specific level +# Note that the ConsoleHandler also has a separate level +# setting to limit messages printed to the console. +.level= INFO + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +# default file output is in user's home directory. +java.util.logging.FileHandler.pattern = %h/java%u.log +java.util.logging.FileHandler.limit = 50000 +java.util.logging.FileHandler.count = 1 +# Default number of locks FileHandler can obtain synchronously. +# This specifies maximum number of attempts to obtain lock file by FileHandler +# implemented by incrementing the unique field %u as per FileHandler API documentation. +java.util.logging.FileHandler.maxLocks = 100 +java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter + +# Limit the message that are printed on the console to INFO and above. +java.util.logging.ConsoleHandler.level = INFO +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + +# Example to customize the SimpleFormatter output format +# to print one-line log message like this: +# : [] +# +# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +# For example, set the com.xyz.foo logger to only log SEVERE +# messages: +com.xyz.foo.level = SEVERE +com.xyz.foo.handlers = test.handlers.TestHandler diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/module-info.java b/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/module-info.java new file mode 100644 index 00000000000..fb7cde07f6a --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/module-info.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +module test.config { + requires java.logging; + requires test.handlers; + // makes it possible for java.logging to instantiate test.config.LogConfig; + // this doesn't need to be a qualified export, but making it so will prevent + // any other module from being able to instantiate the provided classes. + exports test.config to java.logging; +} diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/test/config/LogConfig.java b/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/test/config/LogConfig.java new file mode 100644 index 00000000000..51e6281245b --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.config/test/config/LogConfig.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.LogManager; +import java.util.logging.Logger; +import test.handlers.TestHandler; + +/** + * A dummy class that configures the logging system. + * @author danielfuchs + */ +public class LogConfig { + private static final List LOGGERS = new ArrayList<>(); + public LogConfig() { + LogManager manager = LogManager.getLogManager(); + Logger logger = Logger.getLogger("com.xyz.foo"); + if (logger.getHandlers().length > 0) { + System.err.println(this.getClass().getName() + ": " + + "Unexpected handlers: " + + List.of(logger.getHandlers())); + throw new RuntimeException("Unexpected handlers: " + + List.of(logger.getHandlers())); + } + logger.addHandler(new TestHandler()); + LOGGERS.add(logger); + } +} diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/module-info.java b/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/module-info.java new file mode 100644 index 00000000000..dd839738b48 --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/module-info.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +module test.handlers { + requires transitive java.logging; + // makes it possible for java.logging and test.config to instantiate + // test.handlers.TestHandler; + // this doesn't need to be a qualified export, but making it so will prevent + // any other module from being able to instantiate the provided classes. + exports test.handlers to java.logging, test.config; +} diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/test/handlers/TestHandler.java b/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/test/handlers/TestHandler.java new file mode 100644 index 00000000000..7a0442b57c6 --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.handlers/test/handlers/TestHandler.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test.handlers; + +import java.util.logging.Handler; +import java.util.logging.LogRecord; + +/** + * A dummy Handler that does nothing. + * @author danielfuchs + */ +public class TestHandler extends Handler { + + @Override + public void publish(LogRecord record) { + } + + @Override + public void flush() { + } + + @Override + public void close() throws SecurityException { + } + +} diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/module-info.java b/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/module-info.java new file mode 100644 index 00000000000..db70f293f98 --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/module-info.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +module test.logmanager { + requires java.logging; + // makes it possible for java.logging to instantiate + // test.logmanager.TestLogManager; + // this doesn't need to be a qualified export, but making it so will prevent + // any other module from being able to instantiate the provided classes. + exports test.logmanager to java.logging; +} diff --git a/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/test/logmanager/TestLogManager.java b/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/test/logmanager/TestLogManager.java new file mode 100644 index 00000000000..5be0edcedd4 --- /dev/null +++ b/jdk/test/java/util/logging/modules/LogManagerInModule/test.logmanager/test/logmanager/TestLogManager.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test.logmanager; + +import java.util.logging.LogManager; + +/** + * A dummy LogManager that simply extends the standard class. + * @author danielfuchs + */ +public class TestLogManager extends LogManager { + +} From fc2d5da4d8c401c52edb9ab43708f2398e723eba Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 18 Jan 2017 19:35:41 +0530 Subject: [PATCH 119/154] 8168254: Detect duplicated resources in packaged modules Reviewed-by: mchung, jlaskey --- .../jlink/builder/DefaultImageBuilder.java | 43 ++++++---- .../jlink/ResourceDuplicateCheckTest.java | 84 +++++++++++++++++++ 2 files changed, 109 insertions(+), 18 deletions(-) create mode 100644 jdk/test/tools/jlink/ResourceDuplicateCheckTest.java diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java index 27f79dd74d1..fccb913f4fa 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java @@ -165,18 +165,9 @@ public final class DefaultImageBuilder implements ImageBuilder { throw new PluginException("TargetPlatform attribute is missing for java.base module"); } - Path bin = root.resolve(BIN_DIRNAME); + checkResourcePool(files); - // check any duplicated resource files - Map> duplicates = new HashMap<>(); - files.entries() - .filter(f -> f.type() != ResourcePoolEntry.Type.CLASS_OR_RESOURCE) - .collect(groupingBy(this::entryToImagePath, - mapping(ResourcePoolEntry::moduleName, toSet()))) - .entrySet() - .stream() - .filter(e -> e.getValue().size() > 1) - .forEach(e -> duplicates.put(e.getKey(), e.getValue())); + Path bin = root.resolve(BIN_DIRNAME); // write non-classes resource files to the image files.entries() @@ -185,13 +176,8 @@ public final class DefaultImageBuilder implements ImageBuilder { try { accept(f); } catch (FileAlreadyExistsException e) { - // error for duplicated entries - Path path = entryToImagePath(f); - UncheckedIOException x = - new UncheckedIOException(path + " duplicated in " + - duplicates.get(path), e); - x.addSuppressed(e); - throw x; + // Should not happen! Duplicates checking already done! + throw new AssertionError("Duplicate entry!", e); } catch (IOException ioExp) { throw new UncheckedIOException(ioExp); } @@ -242,6 +228,27 @@ public final class DefaultImageBuilder implements ImageBuilder { } } + private void checkResourcePool(ResourcePool pool) { + // For now, only duplicate resources check. Add more checks here (if any) + checkDuplicateResources(pool); + } + + private void checkDuplicateResources(ResourcePool pool) { + // check any duplicated resources + Map> duplicates = new HashMap<>(); + pool.entries() + .filter(f -> f.type() != ResourcePoolEntry.Type.CLASS_OR_RESOURCE) + .collect(groupingBy(this::entryToImagePath, + mapping(ResourcePoolEntry::moduleName, toSet()))) + .entrySet() + .stream() + .filter(e -> e.getValue().size() > 1) + .forEach(e -> duplicates.put(e.getKey(), e.getValue())); + if (!duplicates.isEmpty()) { + throw new PluginException("Duplicate resources: " + duplicates); + } + } + /** * Generates launcher scripts. * diff --git a/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java b/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java new file mode 100644 index 00000000000..3997ed18e83 --- /dev/null +++ b/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8168254 + * @summary Detect duplicated resources in packaged modules + * @modules jdk.jlink/jdk.tools.jlink.builder + * jdk.jlink/jdk.tools.jlink.internal + * @run build ResourceDuplicateCheckTest + * @run main ResourceDuplicateCheckTest + */ + +import java.net.URI; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import jdk.tools.jlink.builder.DefaultImageBuilder; +import jdk.tools.jlink.internal.ResourcePoolEntryFactory; +import jdk.tools.jlink.internal.ResourcePoolManager; +import jdk.tools.jlink.plugin.PluginException; +import jdk.tools.jlink.plugin.ResourcePoolEntry; + +public class ResourceDuplicateCheckTest { + public static void main(String[] args) throws Exception { + new ResourceDuplicateCheckTest().test(); + } + + public void test() throws Exception { + ResourcePoolManager input = new ResourcePoolManager(); + // need java.base module info because OS name is retrieved from it from storeFiles + input.add(ResourcePoolEntryFactory.create("/java.base/module-info.class", + ResourcePoolEntry.Type.CLASS_OR_RESOURCE, getJavaBaseModuleInfo())); + + // same NATIVE_CMD from two different modules + input.add(newInMemoryImageFile("/com.acme/bin/myexec", + ResourcePoolEntry.Type.NATIVE_CMD, "mylib")); + input.add(newInMemoryImageFile("/com.foo/bin/myexec", + ResourcePoolEntry.Type.NATIVE_CMD, "mylib")); + Path root = Paths.get(System.getProperty("test.classes")); + DefaultImageBuilder writer = new DefaultImageBuilder(root, Collections.emptyMap()); + try { + writer.storeFiles(input.resourcePool()); + } catch (PluginException pe) { + if (! pe.getMessage().contains("Duplicate resources:")) { + throw new AssertionError("expected duplicate resources message"); + } + } + } + + private byte[] getJavaBaseModuleInfo() throws Exception { + Path path = FileSystems. + getFileSystem(URI.create("jrt:/")). + getPath("/modules/java.base/module-info.class"); + return Files.readAllBytes(path); + } + + private static ResourcePoolEntry newInMemoryImageFile(String path, + ResourcePoolEntry.Type type, String content) { + return ResourcePoolEntryFactory.create(path, type, content.getBytes()); + } +} From 35864e236ce535afc8bebe2518a187eb6bdd07c7 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 18 Jan 2017 13:56:50 +0000 Subject: [PATCH 120/154] 8172973: Remove add exports from ModuleSummary build Reviewed-by: ihse, redestad --- jdk/make/ModuleTools.gmk | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/make/ModuleTools.gmk b/jdk/make/ModuleTools.gmk index 30cf959e174..71ca1cf8eaa 100644 --- a/jdk/make/ModuleTools.gmk +++ b/jdk/make/ModuleTools.gmk @@ -39,7 +39,6 @@ TOOL_GENGRAPHS := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \ build.tools.jigsaw.GenGraphs TOOL_MODULESUMMARY := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \ - --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \ build.tools.jigsaw.ModuleSummary TOOL_ADD_PACKAGES_ATTRIBUTE := $(BUILD_JAVA) $(JAVA_FLAGS_SMALL) \ From f66de31c2467927ac90a1dcea756a9908c5dd125 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 18 Jan 2017 08:03:04 -0800 Subject: [PATCH 121/154] 8171140: Re-examine ResourceBundle::clearCache method Reviewed-by: mchung, dfuchs --- .../classes/java/util/ResourceBundle.java | 38 ++++--------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java index a1f2779deef..d49ae25ee01 100644 --- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java +++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2134,7 +2134,7 @@ public abstract class ResourceBundle { /** * Removes all resource bundles from the cache that have been loaded - * by the caller's module using the caller's class loader. + * by the caller's module. * * @since 1.6 * @see ResourceBundle.Control#getTimeToLive(String,Locale) @@ -2142,50 +2142,26 @@ public abstract class ResourceBundle { @CallerSensitive public static final void clearCache() { Class caller = Reflection.getCallerClass(); - clearCacheImpl(caller.getModule(), caller.getClassLoader()); + cacheList.keySet().removeIf( + key -> key.getCallerModule() == caller.getModule() + ); } /** * Removes all resource bundles from the cache that have been loaded - * by the caller's module using the given class loader. + * by the given class loader. * * @param loader the class loader * @exception NullPointerException if loader is null * @since 1.6 * @see ResourceBundle.Control#getTimeToLive(String,Locale) */ - @CallerSensitive public static final void clearCache(ClassLoader loader) { Objects.requireNonNull(loader); - Class caller = Reflection.getCallerClass(); - clearCacheImpl(caller.getModule(), loader); - } - - /** - * Removes all resource bundles from the cache that have been loaded by the - * given {@code module}. - * - * @param module the module - * @throws NullPointerException - * if {@code module} is {@code null} - * @throws SecurityException - * if the caller doesn't have the permission to - * {@linkplain Module#getClassLoader() get the class loader} - * of the given {@code module} - * @since 9 - * @see ResourceBundle.Control#getTimeToLive(String,Locale) - */ - public static final void clearCache(Module module) { - Objects.requireNonNull(module); - clearCacheImpl(module, module.getClassLoader()); - } - - private static void clearCacheImpl(Module callerModule, ClassLoader loader) { cacheList.keySet().removeIf( key -> { Module m; - return key.getCallerModule() == callerModule && - (m = key.getModule()) != null && + return (m = key.getModule()) != null && getLoader(m) == loader; } ); From f1fa73dc65613fae211a164dff019ab57417c921 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Wed, 18 Jan 2017 20:39:08 +0300 Subject: [PATCH 122/154] 8071566: Improve testing for multi-version JAR file maker tool Reviewed-by: chegar --- .../jar/multiRelease/ApiValidatorTest.java | 193 +++++++ jdk/test/tools/jar/multiRelease/Basic.java | 481 +++++++----------- jdk/test/tools/jar/multiRelease/Basic1.java | 207 ++------ .../tools/jar/multiRelease/MRTestBase.java | 130 +++++ .../data/test04/v9/version/Version.java | 2 +- 5 files changed, 554 insertions(+), 459 deletions(-) create mode 100644 jdk/test/tools/jar/multiRelease/ApiValidatorTest.java create mode 100644 jdk/test/tools/jar/multiRelease/MRTestBase.java diff --git a/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java b/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java new file mode 100644 index 00000000000..b861321bceb --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Tests for API validator. + * @library /test/lib /lib/testlibrary + * @modules java.base/jdk.internal.misc + * jdk.compiler + * jdk.jartool + * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.* + * @build jdk.testlibrary.FileUtils + * @build MRTestBase + * @run testng ApiValidatorTest + */ + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.testlibrary.FileUtils; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class ApiValidatorTest extends MRTestBase { + + @Test(dataProvider = "signatureChange") + public void changeMethodSignature(String sigBase, String sigV10, + boolean isAcceptable, + Method method) throws Throwable { + Path root = Paths.get(method.getName()); + Path classes = root.resolve("classes"); + + String METHOD_SIG = "#SIG"; + String classTemplate = + "public class C { \n" + + " " + METHOD_SIG + "{ throw new RuntimeException(); };\n" + + "}\n"; + String base = classTemplate.replace(METHOD_SIG, sigBase); + String v10 = classTemplate.replace(METHOD_SIG, sigV10); + + compileTemplate(classes.resolve("base"), base); + compileTemplate(classes.resolve("v10"), v10); + + String jarfile = root.resolve("test.jar").toString(); + OutputAnalyzer result = jar("cf", jarfile, + "-C", classes.resolve("base").toString(), ".", + "--release", "10", "-C", classes.resolve("v10").toString(), + "."); + if (isAcceptable) { + result.shouldHaveExitValue(SUCCESS) + .shouldBeEmpty(); + } else { + result.shouldNotHaveExitValue(SUCCESS) + .shouldContain("contains a class with different api from earlier version"); + } + + FileUtils.deleteFileTreeWithRetry(root); + } + + @DataProvider + Object[][] signatureChange() { + return new Object[][]{ + {"public int m()", "protected int m()", false}, + {"protected int m()", "public int m()", false}, + {"public int m()", "int m()", false}, + {"protected int m()", "private int m()", false}, + {"private int m()", "int m()", true}, + {"int m()", "private int m()", true}, + {"int m()", "private int m(boolean b)", true}, + {"public int m()", "public int m(int i)", false}, + {"public int m()", "public int k()", false}, + {"public int m()", "private int k()", false}, +// @ignore JDK-8172147 {"public int m()", "public boolean m()", false}, +// @ignore JDK-8172147 {"public boolean", "public Boolean", false}, +// @ignore JDK-8172147 {"public T", "public T", false}, + }; + } + + @Test(dataProvider = "publicAPI") + public void introducingPublicMembers(String publicAPI, + Method method) throws Throwable { + Path root = Paths.get(method.getName()); + Path classes = root.resolve("classes"); + + String API = "#API"; + String classTemplate = + "public class C { \n" + + " " + API + "\n" + + " public void method(){ };\n" + + "}\n"; + String base = classTemplate.replace(API, ""); + String v10 = classTemplate.replace(API, publicAPI); + + compileTemplate(classes.resolve("base"), base); + compileTemplate(classes.resolve("v10"), v10); + + String jarfile = root.resolve("test.jar").toString(); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "10", "-C", classes.resolve("v10").toString(), ".") + .shouldNotHaveExitValue(SUCCESS) + .shouldContain("contains a class with different api from earlier version"); + + FileUtils.deleteFileTreeWithRetry(root); + } + + @DataProvider + Object[][] publicAPI() { + return new Object[][]{ +// @ignore JDK-8172148 {"protected class Inner { public void m(){ } } "}, // protected inner class +// @ignore JDK-8172148 {"public class Inner { public void m(){ } }"}, // public inner class +// @ignore JDK-8172148 {"public enum E { A; }"}, // public enum + {"public void m(){ }"}, // public method + {"protected void m(){ }"}, // protected method + }; + } + + @Test(dataProvider = "privateAPI") + public void introducingPrivateMembers(String privateAPI, + Method method) throws Throwable { + Path root = Paths.get(method.getName()); + Path classes = root.resolve("classes"); + + String API = "#API"; + String classTemplate = + "public class C { \n" + + " " + API + "\n" + + " public void method(){ };\n" + + "}\n"; + String base = classTemplate.replace(API, ""); + String v10 = classTemplate.replace(API, privateAPI); + + compileTemplate(classes.resolve("base"), base); + compileTemplate(classes.resolve("v10"), v10); + + String jarfile = root.resolve("test.jar").toString(); + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "10", "-C", classes.resolve("v10").toString(), ".") + .shouldHaveExitValue(SUCCESS); + // add release + jar("uf", jarfile, + "--release", "11", "-C", classes.resolve("v10").toString(), ".") + .shouldHaveExitValue(SUCCESS); + // replace release + jar("uf", jarfile, + "--release", "11", "-C", classes.resolve("v10").toString(), ".") + .shouldHaveExitValue(SUCCESS); + + FileUtils.deleteFileTreeWithRetry(root); + } + + @DataProvider + Object[][] privateAPI() { + return new Object[][]{ + {"private class Inner { public void m(){ } } "}, // private inner class + {"class Inner { public void m(){ } }"}, // package private inner class + {"enum E { A; }"}, // package private enum + // Local class and private method + {"private void m(){ class Inner { public void m(){} } Inner i = null; }"}, + {"void m(){ }"}, // package private method + }; + } + + private void compileTemplate(Path classes, String template) throws Throwable { + Path classSourceFile = Files.createDirectories( + classes.getParent().resolve("src").resolve(classes.getFileName())) + .resolve("C.java"); + Files.write(classSourceFile, template.getBytes()); + javac(classes, classSourceFile); + } +} \ No newline at end of file diff --git a/jdk/test/tools/jar/multiRelease/Basic.java b/jdk/test/tools/jar/multiRelease/Basic.java index 1d559ad1262..80f37950591 100644 --- a/jdk/test/tools/jar/multiRelease/Basic.java +++ b/jdk/test/tools/jar/multiRelease/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,69 +23,59 @@ /* * @test - * @library /test/lib + * @library /test/lib /lib/testlibrary * @modules java.base/jdk.internal.misc * jdk.compiler * jdk.jartool - * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils + * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.* + * @build jdk.testlibrary.FileUtils + * @build MRTestBase * @run testng Basic */ import static org.testng.Assert.*; +import jdk.testlibrary.FileUtils; import org.testng.annotations.*; -import java.io.*; +import java.io.File; import java.nio.file.*; -import java.nio.file.attribute.*; import java.util.*; -import java.util.function.Consumer; -import java.util.jar.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.zip.*; +import java.util.jar.JarFile; +import java.util.zip.ZipFile; -import jdk.test.lib.JDKToolFinder; -import jdk.test.lib.Utils; - - -import static java.lang.String.format; -import static java.lang.System.out; - -public class Basic { - private final String src = System.getProperty("test.src", "."); - private final String usr = System.getProperty("user.dir", "."); +public class Basic extends MRTestBase { @Test // create a regular, non-multi-release jar - public void test00() throws IOException { + public void test00() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 Path classes = Paths.get("classes"); jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".") - .assertSuccess(); + .shouldHaveExitValue(SUCCESS); checkMultiRelease(jarfile, false); - Map names = Map.of( + Map names = Map.of( "version/Main.class", - new String[] {"base", "version", "Main.class"}, + new String[]{"base", "version", "Main.class"}, "version/Version.class", - new String[] {"base", "version", "Version.class"} + new String[]{"base", "version", "Version.class"} ); compare(jarfile, names); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // create a multi-release jar - public void test01() throws IOException { + public void test01() throws Throwable { String jarfile = "test.jar"; compile("test01"); @@ -94,68 +84,96 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".", "--release", "10", "-C", classes.resolve("v10").toString(), ".") - .assertSuccess(); + .shouldHaveExitValue(SUCCESS); checkMultiRelease(jarfile, true); - Map names = Map.of( + Map names = Map.of( "version/Main.class", - new String[] {"base", "version", "Main.class"}, + new String[]{"base", "version", "Main.class"}, "version/Version.class", - new String[] {"base", "version", "Version.class"}, + new String[]{"base", "version", "Version.class"}, "META-INF/versions/9/version/Version.class", - new String[] {"v9", "version", "Version.class"}, + new String[]{"v9", "version", "Version.class"}, "META-INF/versions/10/version/Version.class", - new String[] {"v10", "version", "Version.class"} + new String[]{"v10", "version", "Version.class"} ); compare(jarfile, names); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); + } + + @Test + public void versionFormat() throws Throwable { + String jarfile = "test.jar"; + + compile("test01"); + + Path classes = Paths.get("classes"); + + // valid + for (String release : List.of("10000", "09", "00010", "10")) { + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", release, "-C", classes.resolve("v10").toString(), ".") + .shouldHaveExitValue(SUCCESS) + .shouldBeEmpty(); + } + // invalid + for (String release : List.of("9.0", "8", "v9", + "9v", "0", "-10")) { + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", release, "-C", classes.resolve("v10").toString(), ".") + .shouldNotHaveExitValue(SUCCESS) + .shouldContain("release " + release + " not valid"); + } + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // update a regular jar to a multi-release jar - public void test02() throws IOException { + public void test02() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 Path classes = Paths.get("classes"); jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".") - .assertSuccess(); + .shouldHaveExitValue(SUCCESS); checkMultiRelease(jarfile, false); - jar("uf", jarfile, "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertSuccess(); + jar("uf", jarfile, + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .shouldHaveExitValue(SUCCESS); checkMultiRelease(jarfile, true); - Map names = Map.of( + Map names = Map.of( "version/Main.class", - new String[] {"base", "version", "Main.class"}, + new String[]{"base", "version", "Main.class"}, "version/Version.class", - new String[] {"base", "version", "Version.class"}, + new String[]{"base", "version", "Version.class"}, "META-INF/versions/9/version/Version.class", - new String[] {"v9", "version", "Version.class"} + new String[]{"v9", "version", "Version.class"} ); compare(jarfile, names); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // replace a base entry and a versioned entry - public void test03() throws IOException { + public void test03() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -163,19 +181,19 @@ public class Basic { Path classes = Paths.get("classes"); jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertSuccess(); + .shouldHaveExitValue(SUCCESS); checkMultiRelease(jarfile, true); - Map names = Map.of( + Map names = Map.of( "version/Main.class", - new String[] {"base", "version", "Main.class"}, + new String[]{"base", "version", "Main.class"}, "version/Version.class", - new String[] {"base", "version", "Version.class"}, + new String[]{"base", "version", "Version.class"}, "META-INF/versions/9/version/Version.class", - new String[] {"v9", "version", "Version.class"} + new String[]{"v9", "version", "Version.class"} ); compare(jarfile, names); @@ -184,25 +202,25 @@ public class Basic { // version/Version.class entry in versions/9 section jar("uf", jarfile, "-C", classes.resolve("v9").toString(), "version", "--release", "9", "-C", classes.resolve("v10").toString(), ".") - .assertSuccess(); + .shouldHaveExitValue(SUCCESS); checkMultiRelease(jarfile, true); names = Map.of( "version/Main.class", - new String[] {"base", "version", "Main.class"}, + new String[]{"base", "version", "Main.class"}, "version/Version.class", - new String[] {"v9", "version", "Version.class"}, + new String[]{"v9", "version", "Version.class"}, "META-INF/versions/9/version/Version.class", - new String[] {"v10", "version", "Version.class"} + new String[]{"v10", "version", "Version.class"} ); compare(jarfile, names); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } /* @@ -211,7 +229,7 @@ public class Basic { @Test // META-INF/versions/9 class has different api than base class - public void test04() throws IOException { + public void test04() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -224,18 +242,16 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertFailure() - .resultChecker(r -> - assertTrue(r.output.contains("different api from earlier"), r.output) - ); + .shouldNotHaveExitValue(SUCCESS) + .shouldContain("different api from earlier"); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // META-INF/versions/9 contains an extra public class - public void test05() throws IOException { + public void test05() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -248,18 +264,16 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertFailure() - .resultChecker(r -> - assertTrue(r.output.contains("contains a new public class"), r.output) - ); + .shouldNotHaveExitValue(SUCCESS) + .shouldContain("contains a new public class"); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // META-INF/versions/9 contains an extra package private class -- this is okay - public void test06() throws IOException { + public void test06() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -272,16 +286,16 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertSuccess(); + .shouldHaveExitValue(SUCCESS); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // META-INF/versions/9 contains an identical class to base entry class // this is okay but produces warning - public void test07() throws IOException { + public void test07() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -294,19 +308,42 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertSuccess() - .resultChecker(r -> - assertTrue(r.outputContains("contains a class that is identical"), r.output) - ); + .shouldHaveExitValue(SUCCESS) + .shouldContain("contains a class that") + .shouldContain("is identical"); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); + } + + @Test + // META-INF/versions/9 contains an identical class to previous version entry class + // this is okay but produces warning + public void identicalClassToPreviousVersion() throws Throwable { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .shouldHaveExitValue(SUCCESS) + .shouldBeEmpty(); + jar("uf", jarfile, + "--release", "10", "-C", classes.resolve("v9").toString(), ".") + .shouldHaveExitValue(SUCCESS) + .shouldContain("contains a class that") + .shouldContain("is identical"); + + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // resources with same name in different versions // this is okay but produces warning - public void test08() throws IOException { + public void test08() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -320,10 +357,8 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertSuccess() - .resultChecker(r -> - assertTrue(r.output.isEmpty(), r.output) - ); + .shouldHaveExitValue(SUCCESS) + .shouldBeEmpty(); // now add a different resource with same name to META-INF/version/9 Files.copy(source.resolve("Main.java"), classes.resolve("v9") @@ -331,18 +366,16 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertSuccess() - .resultChecker(r -> - assertTrue(r.output.contains("multiple resources with same name"), r.output) - ); + .shouldHaveExitValue(SUCCESS) + .shouldContain("multiple resources with same name"); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // a class with an internal name different from the external name - public void test09() throws IOException { + public void test09() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -355,18 +388,16 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertFailure() - .resultChecker(r -> - assertTrue(r.output.contains("names do not match"), r.output) - ); + .shouldNotHaveExitValue(SUCCESS) + .shouldContain("names do not match"); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // assure that basic nested classes are acceptable - public void test10() throws IOException { + public void test10() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -383,15 +414,15 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertSuccess(); + .shouldHaveExitValue(SUCCESS); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // a base entry contains a nested class that doesn't have a matching top level class - public void test11() throws IOException { + public void test11() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -409,30 +440,29 @@ public class Basic { source = Paths.get(src, "data", "test10", "v9", "version"); javac(classes.resolve("v9"), source.resolve("Nested.java")); - jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + List output = jar("cf", jarfile, + "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertFailure() - .resultChecker(r -> { - String[] msg = r.output.split("\\R"); - // There should be 3 error messages, cascading from the first. Once we - // remove the base top level class, the base nested class becomes isolated, - // also the versioned top level class becomes a new public class, thus ignored - // for subsequent checks, leading to the associated versioned nested class - // becoming an isolated nested class - assertTrue(msg.length == 4); - assertTrue(msg[0].contains("an isolated nested class"), msg[0]); - assertTrue(msg[1].contains("contains a new public class"), msg[1]); - assertTrue(msg[2].contains("an isolated nested class"), msg[2]); - assertTrue(msg[3].contains("invalid multi-release jar file"), msg[3]); - }); + .shouldNotHaveExitValue(SUCCESS) + .asLines(); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + assertTrue(output.size() == 4); + assertTrue(output.get(0).contains("an isolated nested class"), + output.get(0)); + assertTrue(output.get(1).contains("contains a new public class"), + output.get(1)); + assertTrue(output.get(2).contains("an isolated nested class"), + output.get(2)); + assertTrue(output.get(3).contains("invalid multi-release jar file"), + output.get(3)); + + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } @Test // a versioned entry contains a nested class that doesn't have a matching top level class - public void test12() throws IOException { + public void test12() throws Throwable { String jarfile = "test.jar"; compile("test01"); //use same data as test01 @@ -452,178 +482,59 @@ public class Basic { jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", "--release", "9", "-C", classes.resolve("v9").toString(), ".") - .assertFailure() - .resultChecker(r -> - assertTrue(r.outputContains("an isolated nested class"), r.output) - ); + .shouldNotHaveExitValue(SUCCESS) + .shouldContain("an isolated nested class"); - delete(jarfile); - deleteDir(Paths.get(usr, "classes")); + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } - /* - * Test Infrastructure - */ - private void compile(String test) throws IOException { - Path classes = Paths.get(usr, "classes", "base"); - Files.createDirectories(classes); - Path source = Paths.get(src, "data", test, "base", "version"); - javac(classes, source.resolve("Main.java"), source.resolve("Version.java")); + @Test + public void testCustomManifest() throws Throwable { + String jarfile = "test.jar"; - classes = Paths.get(usr, "classes", "v9"); - Files.createDirectories(classes); - source = Paths.get(src, "data", test, "v9", "version"); - javac(classes, source.resolve("Version.java")); + compile("test01"); - classes = Paths.get(usr, "classes", "v10"); - Files.createDirectories(classes); - source = Paths.get(src, "data", test, "v10", "version"); - javac(classes, source.resolve("Version.java")); - } + Path classes = Paths.get("classes"); + Path manifest = Paths.get("Manifest.txt"); - private void checkMultiRelease(String jarFile, boolean expected) throws IOException { - try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ, - JarFile.runtimeVersion())) { - assertEquals(jf.isMultiRelease(), expected); - } - } + // create + Files.write(manifest, "Class-Path: MyUtils.jar\n".getBytes()); - // compares the bytes found in the jar entries with the bytes found in the - // corresponding data files used to create the entries - private void compare(String jarfile, Map names) throws IOException { - try (JarFile jf = new JarFile(jarfile)) { - for (String name : names.keySet()) { - Path path = Paths.get("classes", names.get(name)); - byte[] b1 = Files.readAllBytes(path); - byte[] b2; - JarEntry je = jf.getJarEntry(name); - try (InputStream is = jf.getInputStream(je)) { - b2 = is.readAllBytes(); - } - assertEquals(b1,b2); - } - } - } + jar("cfm", jarfile, manifest.toString(), + "-C", classes.resolve("base").toString(), ".", + "--release", "10", "-C", classes.resolve("v10").toString(), ".") + .shouldHaveExitValue(SUCCESS) + .shouldBeEmpty(); - private void delete(String name) throws IOException { - Files.deleteIfExists(Paths.get(usr, name)); - } - - private void deleteDir(Path dir) throws IOException { - Files.walkFileTree(dir, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - Files.delete(dir); - return FileVisitResult.CONTINUE; - } - }); - } - - /* - * The following methods were taken from modular jar and other jar tests - */ - - void javac(Path dest, Path... sourceFiles) throws IOException { - String javac = JDKToolFinder.getJDKTool("javac"); - - List commands = new ArrayList<>(); - commands.add(javac); - String opts = System.getProperty("test.compiler.opts"); - if (!opts.isEmpty()) { - commands.addAll(Arrays.asList(opts.split(" +"))); - } - commands.add("-d"); - commands.add(dest.toString()); - Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x)); - - quickFail(run(new ProcessBuilder(commands))); - } - - Result jarWithStdin(File stdinSource, String... args) { - String jar = JDKToolFinder.getJDKTool("jar"); - List commands = new ArrayList<>(); - commands.add(jar); - commands.addAll(Utils.getForwardVmOptions()); - Stream.of(args).forEach(x -> commands.add(x)); - ProcessBuilder p = new ProcessBuilder(commands); - if (stdinSource != null) - p.redirectInput(stdinSource); - return run(p); - } - - Result jar(String... args) { - return jarWithStdin(null, args); - } - - void quickFail(Result r) { - if (r.ec != 0) - throw new RuntimeException(r.output); - } - - Result run(ProcessBuilder pb) { - Process p; - out.printf("Running: %s%n", pb.command()); - try { - p = pb.start(); - } catch (IOException e) { - throw new RuntimeException( - format("Couldn't start process '%s'", pb.command()), e); + try (JarFile jf = new JarFile(new File(jarfile), true, + ZipFile.OPEN_READ, JarFile.runtimeVersion())) { + assertTrue(jf.isMultiRelease(), "Not multi-release jar"); + assertEquals(jf.getManifest() + .getMainAttributes() + .getValue("Class-Path"), + "MyUtils.jar"); } - String output; - try { - output = toString(p.getInputStream(), p.getErrorStream()); - } catch (IOException e) { - throw new RuntimeException( - format("Couldn't read process output '%s'", pb.command()), e); + // update + Files.write(manifest, "Multi-release: false\n".getBytes()); + + jar("ufm", jarfile, manifest.toString(), + "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v10").toString(), ".") + .shouldHaveExitValue(SUCCESS) + .shouldContain("WARNING: Duplicate name in Manifest: Multi-release."); + + try (JarFile jf = new JarFile(new File(jarfile), true, + ZipFile.OPEN_READ, JarFile.runtimeVersion())) { + assertTrue(jf.isMultiRelease(), "Not multi-release jar"); + assertEquals(jf.getManifest() + .getMainAttributes() + .getValue("Class-Path"), + "MyUtils.jar"); } - try { - p.waitFor(); - } catch (InterruptedException e) { - throw new RuntimeException( - format("Process hasn't finished '%s'", pb.command()), e); - } - return new Result(p.exitValue(), output); - } - - String toString(InputStream in1, InputStream in2) throws IOException { - try (ByteArrayOutputStream dst = new ByteArrayOutputStream(); - InputStream concatenated = new SequenceInputStream(in1, in2)) { - concatenated.transferTo(dst); - return new String(dst.toByteArray(), "UTF-8"); - } - } - - static class Result { - final int ec; - final String output; - - private Result(int ec, String output) { - this.ec = ec; - this.output = output; - } - - boolean outputContains(String msg) { - return Arrays.stream(output.split("\\R")) - .collect(Collectors.joining(" ")) - .contains(msg); - } - - Result assertSuccess() { - assertTrue(ec == 0, format("ec: %d, output: %s", ec, output)); - return this; - } - Result assertFailure() { - assertTrue(ec != 0, format("ec: %d, output: %s", ec, output)); - return this; - } - Result resultChecker(Consumer r) { r.accept(this); return this; } + FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile)); + FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes")); } } diff --git a/jdk/test/tools/jar/multiRelease/Basic1.java b/jdk/test/tools/jar/multiRelease/Basic1.java index 8c3788085ee..e01ce8fe2f8 100644 --- a/jdk/test/tools/jar/multiRelease/Basic1.java +++ b/jdk/test/tools/jar/multiRelease/Basic1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,76 +28,65 @@ * jdk.compiler * jdk.jartool * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils + * @build MRTestBase * @run testng Basic1 */ -import static org.testng.Assert.*; - import org.testng.annotations.*; -import java.io.*; import java.nio.file.*; import java.util.*; -import java.util.function.Consumer; -import java.util.jar.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.zip.*; -import jdk.test.lib.JDKToolFinder; -import jdk.test.lib.Utils; - - -import static java.lang.String.format; -import static java.lang.System.out; - -public class Basic1 { - private final String src = System.getProperty("test.src", "."); +public class Basic1 extends MRTestBase { @BeforeTest - public void setup() throws IOException { + public void setup() throws Throwable { String test = "test01"; - Path classes = Paths.get("classes", "base"); - Files.createDirectories(classes); - Path source = Paths.get(src, "data", test, "base", "version"); - javac(classes, source.resolve("Main.java"), source.resolve("Version.java")); + Path classes = Paths.get("classes"); - Path v9 = Paths.get("v9"); + Path base = classes.resolve("base"); + Files.createDirectories(base); + Path source = Paths.get(src, "data", test, "base", "version"); + javac(base, source.resolve("Main.java"), source.resolve("Version.java")); + + Path v9 = classes.resolve("v9"); Files.createDirectories(v9); source = Paths.get(src, "data", test, "v9", "version"); javac(v9, source.resolve("Version.java")); - Path v10 = Paths.get("v10"); + Path v10 = classes.resolve("v10"); Files.createDirectories(v10); source = Paths.get(src, "data", test, "v10", "version"); javac(v10, source.resolve("Version.java")); - Path v10_1 = Paths.get("v10_1").resolve("META-INF").resolve("versions").resolve("v10"); + Path v10_1 = classes.resolve("v10_1").resolve("META-INF").resolve("versions").resolve("v10"); Files.createDirectories(v10_1); source = Paths.get(src, "data", test, "v10", "version"); javac(v10_1, source.resolve("Version.java")); } @Test - public void test() throws IOException { + public void test() throws Throwable { String jarfile = "test.jar"; Path classes = Paths.get("classes"); - Path v9 = Paths.get("v9"); - Path v10 = Paths.get("v10"); - jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", - "--release", "9", "-C", v9.toString(), ".", - "--release", "10", "-C", v10.toString(), ".") - .assertSuccess(); + Path base = classes.resolve("base"); + Path v9 = classes.resolve("v9"); + Path v10 = classes.resolve("v10"); + + jar("cf", jarfile, "-C", base.toString(), ".", + "--release", "9", "-C", v9.toString(), ".", + "--release", "10", "-C", v10.toString(), ".") + .shouldHaveExitValue(SUCCESS); checkMultiRelease(jarfile, true); - Map names = Map.of( - "version/Main.class", - new String[] {"classes", "base", "version", "Main.class"}, + Map names = Map.of( + "version/Main.class", + new String[]{"base", "version", "Main.class"}, - "version/Version.class", - new String[] {"classes", "base", "version", "Version.class"}, + "version/Version.class", + new String[]{"base", "version", "Version.class"}, "META-INF/versions/9/version/Version.class", new String[] {"v9", "version", "Version.class"}, @@ -109,144 +98,16 @@ public class Basic1 { compare(jarfile, names); } - @Test - public void testFail() throws IOException { + public void testFail() throws Throwable { String jarfile = "test.jar"; Path classes = Paths.get("classes"); - Path v10 = Paths.get("v10_1"); + Path base = classes.resolve("base"); + Path v10 = classes.resolve("v10_1"); - jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", - "--release", "10", "-C", v10.toString(), ".") - .assertFailure() - .outputContains("unexpected versioned entry META-INF/versions/"); - } - - - - private void checkMultiRelease(String jarFile, boolean expected) throws IOException { - try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ, - JarFile.runtimeVersion())) { - assertEquals(jf.isMultiRelease(), expected); - } - } - - // compares the bytes found in the jar entries with the bytes found in the - // corresponding data files used to create the entries - private void compare(String jarfile, Map names) throws IOException { - try (JarFile jf = new JarFile(jarfile)) { - for (String name : names.keySet()) { - Path path = Paths.get("", names.get(name)); - byte[] b1 = Files.readAllBytes(path); - byte[] b2; - JarEntry je = jf.getJarEntry(name); - try (InputStream is = jf.getInputStream(je)) { - b2 = is.readAllBytes(); - } - assertEquals(b1,b2); - } - } - } - - /* - * The following methods were taken from modular jar and other jar tests - */ - - void javac(Path dest, Path... sourceFiles) throws IOException { - String javac = JDKToolFinder.getJDKTool("javac"); - - List commands = new ArrayList<>(); - commands.add(javac); - String opts = System.getProperty("test.compiler.opts"); - if (!opts.isEmpty()) { - commands.addAll(Arrays.asList(opts.split(" +"))); - } - commands.add("-d"); - commands.add(dest.toString()); - Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x)); - - quickFail(run(new ProcessBuilder(commands))); - } - - Result jarWithStdin(File stdinSource, String... args) { - String jar = JDKToolFinder.getJDKTool("jar"); - List commands = new ArrayList<>(); - commands.add(jar); - commands.addAll(Utils.getForwardVmOptions()); - Stream.of(args).forEach(x -> commands.add(x)); - ProcessBuilder p = new ProcessBuilder(commands); - if (stdinSource != null) - p.redirectInput(stdinSource); - return run(p); - } - - Result jar(String... args) { - return jarWithStdin(null, args); - } - - void quickFail(Result r) { - if (r.ec != 0) - throw new RuntimeException(r.output); - } - - Result run(ProcessBuilder pb) { - Process p; - out.printf("Running: %s%n", pb.command()); - try { - p = pb.start(); - } catch (IOException e) { - throw new RuntimeException( - format("Couldn't start process '%s'", pb.command()), e); - } - - String output; - try { - output = toString(p.getInputStream(), p.getErrorStream()); - } catch (IOException e) { - throw new RuntimeException( - format("Couldn't read process output '%s'", pb.command()), e); - } - - try { - p.waitFor(); - } catch (InterruptedException e) { - throw new RuntimeException( - format("Process hasn't finished '%s'", pb.command()), e); - } - return new Result(p.exitValue(), output); - } - - String toString(InputStream in1, InputStream in2) throws IOException { - try (ByteArrayOutputStream dst = new ByteArrayOutputStream(); - InputStream concatenated = new SequenceInputStream(in1, in2)) { - concatenated.transferTo(dst); - return new String(dst.toByteArray(), "UTF-8"); - } - } - - static class Result { - final int ec; - final String output; - - private Result(int ec, String output) { - this.ec = ec; - this.output = output; - } - - boolean outputContains(String msg) { - return Arrays.stream(output.split("\\R")) - .collect(Collectors.joining(" ")) - .contains(msg); - } - - Result assertSuccess() { - assertTrue(ec == 0, format("ec: %d, output: %s", ec, output)); - return this; - } - Result assertFailure() { - assertTrue(ec != 0, format("ec: %d, output: %s", ec, output)); - return this; - } - Result resultChecker(Consumer r) { r.accept(this); return this; } + jar("cf", jarfile, "-C", base.toString(), ".", + "--release", "10", "-C", v10.toString(), ".") + .shouldNotHaveExitValue(SUCCESS) + .shouldContain("unexpected versioned entry META-INF/versions/"); } } diff --git a/jdk/test/tools/jar/multiRelease/MRTestBase.java b/jdk/test/tools/jar/multiRelease/MRTestBase.java new file mode 100644 index 00000000000..248498e386c --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/MRTestBase.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import java.io.*; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Stream; +import java.util.zip.ZipFile; + +import static org.testng.Assert.assertEquals; + +public class MRTestBase { + + public static final int SUCCESS = 0; + + protected final String src = System.getProperty("test.src", "."); + protected final String usr = System.getProperty("user.dir", "."); + + protected void compile(String test) throws Throwable { + Path classes = Paths.get(usr, "classes", "base"); + Files.createDirectories(classes); + Path source = Paths.get(src, "data", test, "base", "version"); + javac(classes, source.resolve("Main.java"), source.resolve("Version.java")); + + classes = Paths.get(usr, "classes", "v9"); + Files.createDirectories(classes); + source = Paths.get(src, "data", test, "v9", "version"); + javac(classes, source.resolve("Version.java")); + + classes = Paths.get(usr, "classes", "v10"); + Files.createDirectories(classes); + source = Paths.get(src, "data", test, "v10", "version"); + javac(classes, source.resolve("Version.java")); + } + + protected void checkMultiRelease(String jarFile, + boolean expected) throws IOException { + try (JarFile jf = new JarFile(new File(jarFile), true, + ZipFile.OPEN_READ, JarFile.runtimeVersion())) { + assertEquals(jf.isMultiRelease(), expected); + } + } + + // compares the bytes found in the jar entries with the bytes found in the + // corresponding data files used to create the entries + protected void compare(String jarfile, + Map names) throws IOException { + try (JarFile jf = new JarFile(jarfile)) { + for (String name : names.keySet()) { + Path path = Paths.get("classes", names.get(name)); + byte[] b1 = Files.readAllBytes(path); + byte[] b2; + JarEntry je = jf.getJarEntry(name); + try (InputStream is = jf.getInputStream(je)) { + b2 = is.readAllBytes(); + } + assertEquals(b1, b2); + } + } + } + + void javac(Path dest, Path... sourceFiles) throws Throwable { + String javac = JDKToolFinder.getJDKTool("javac"); + + List commands = new ArrayList<>(); + commands.add(javac); + String opts = System.getProperty("test.compiler.opts"); + if (!opts.isEmpty()) { + commands.addAll(Arrays.asList(opts.split(" +"))); + } + commands.addAll(Utils.getForwardVmOptions()); + commands.add("-d"); + commands.add(dest.toString()); + Stream.of(sourceFiles) + .map(Object::toString) + .forEach(x -> commands.add(x)); + + ProcessTools.executeCommand(new ProcessBuilder(commands)) + .shouldHaveExitValue(SUCCESS); + } + + OutputAnalyzer jarWithStdin(File stdinSource, + String... args) throws Throwable { + + String jar = JDKToolFinder.getJDKTool("jar"); + List commands = new ArrayList<>(); + commands.add(jar); + commands.addAll(Utils.getForwardVmOptions()); + Stream.of(args).forEach(x -> commands.add(x)); + ProcessBuilder p = new ProcessBuilder(commands); + if (stdinSource != null) + p.redirectInput(stdinSource); + return ProcessTools.executeCommand(p); + } + + OutputAnalyzer jar(String... args) throws Throwable { + return jarWithStdin(null, args); + } +} \ No newline at end of file diff --git a/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java b/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java index c4731163178..d4ea69b3b05 100644 --- a/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java +++ b/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java @@ -8,7 +8,7 @@ public class Version { protected void doNothing() { } - // extra publc method + // extra public method public void anyName() { } } From 7f74bcf6bcda9015acfb65856106706cb367c55f Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 18 Jan 2017 17:43:10 +0000 Subject: [PATCH 123/154] 8172982: tools/jlink/ResourceDuplicateCheckTest.java requires jdk.tools.jlink.plugin to be exported Reviewed-by: mchung, sundar --- jdk/test/tools/jlink/ResourceDuplicateCheckTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java b/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java index 3997ed18e83..25d4d83718a 100644 --- a/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java +++ b/jdk/test/tools/jlink/ResourceDuplicateCheckTest.java @@ -27,6 +27,7 @@ * @summary Detect duplicated resources in packaged modules * @modules jdk.jlink/jdk.tools.jlink.builder * jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.plugin * @run build ResourceDuplicateCheckTest * @run main ResourceDuplicateCheckTest */ From 2d8d08a8e519bd6c2af75f95e37d07c51ed69375 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 18 Jan 2017 19:07:09 +0000 Subject: [PATCH 124/154] 8172957: Problem list JmodTest.java on windows until JDK-8172870 is fixed Reviewed-by: mchung --- jdk/test/ProblemList.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 18cc959c84e..1f0a73a3a01 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -258,6 +258,8 @@ tools/jimage/JImageVerifyTest.java 8169713 generic- tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java 8169971 windows-x64 +tools/jmod/JmodTest.java 8172870 windows-all + ############################################################################ # jdk_jdi From ded129adbf0624f2535f256594f23262a7de2e7b Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 18 Jan 2017 11:08:46 -0800 Subject: [PATCH 125/154] 8172870: test/tools/jmod/JmodTest.java fails on windows with AccessDeniedException Reviewed-by: alanb, chegar --- jdk/test/tools/jmod/JmodTest.java | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/jdk/test/tools/jmod/JmodTest.java b/jdk/test/tools/jmod/JmodTest.java index f253b491af9..ccf333511cb 100644 --- a/jdk/test/tools/jmod/JmodTest.java +++ b/jdk/test/tools/jmod/JmodTest.java @@ -29,7 +29,7 @@ * @modules jdk.compiler * jdk.jlink * @build jdk.testlibrary.FileUtils CompilerUtils - * @run testng JmodTest + * @run testng/othervm -Djava.io.tmpdir=. JmodTest */ import java.io.*; @@ -40,8 +40,10 @@ import java.util.*; import java.util.function.Consumer; import java.util.regex.Pattern; import java.util.spi.ToolProvider; +import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.testlibrary.FileUtils; +import jdk.testlibrary.JDKToolFinder; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -593,9 +595,7 @@ public class JmodTest { findTmpFiles(filename).forEach(tmp -> { try { FileUtils.deleteFileIfExistsWithRetry(tmp); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + } catch (IOException e) {} }); String cp = EXPLODED_DIR.resolve("foo").resolve("classes") + File.pathSeparator + @@ -608,17 +608,25 @@ public class JmodTest { .assertFailure() .resultChecker(r -> { assertContains(r.output, "unnamed package"); - Set tmpfiles = findTmpFiles(filename).collect(toSet()); + List tmpfiles = findTmpFiles(filename); assertTrue(tmpfiles.isEmpty(), "Unexpected tmp file:" + tmpfiles); }); } - private Stream findTmpFiles(String prefix) { - try { - Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir")); - return Files.find(tmpdir, 1, (p, attrs) -> - p.getFileName().toString().startsWith(prefix) - && p.getFileName().toString().endsWith(".tmp")); + /* + * Returns the list of writeable tmp files with the given prefix. + * + * Ignore the non-writeable tmp files because this test is possibly + * running by another user. + */ + private List findTmpFiles(String prefix) { + Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir")); + try (Stream stream = Files.list(tmpdir)) { + return stream.filter(p -> { + String fn = p.getFileName().toString(); + return Files.isWritable(p) + && fn.startsWith(prefix) && fn.endsWith(".tmp"); + }).collect(Collectors.toList()); } catch (IOException e) { throw new UncheckedIOException(e); } From 95a45889e9e52dfeed37689ca5bd06b6a81222aa Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Wed, 18 Jan 2017 11:18:13 -0800 Subject: [PATCH 126/154] 8172921: Zip filesystem performance improvement and code cleanup Reviewed-by: redestad --- .../classes/jdk/nio/zipfs/JarFileSystem.java | 6 +- .../share/classes/jdk/nio/zipfs/ZipCoder.java | 128 +++++++------ .../classes/jdk/nio/zipfs/ZipFileSystem.java | 174 ++++++------------ .../share/classes/jdk/nio/zipfs/ZipPath.java | 96 +++++----- jdk/test/jdk/nio/zipfs/PathOps.java | 33 +++- 5 files changed, 207 insertions(+), 230 deletions(-) diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java index 2826f96f4ff..4c0dcc97f7a 100644 --- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java +++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java @@ -135,7 +135,7 @@ class JarFileSystem extends ZipFileSystem { TreeMap map = new TreeMap<>(); IndexNode child = metaInfVersions.child; while (child != null) { - Integer key = getVersion(child.name, metaInfVersions.name.length); + Integer key = getVersion(child.name, metaInfVersions.name.length + 1); if (key != null && key <= version) { map.put(key, child); } @@ -149,7 +149,7 @@ class JarFileSystem extends ZipFileSystem { */ private Integer getVersion(byte[] name, int offset) { try { - return Integer.parseInt(getString(Arrays.copyOfRange(name, offset, name.length-1))); + return Integer.parseInt(getString(Arrays.copyOfRange(name, offset, name.length))); } catch (NumberFormatException x) { // ignore this even though it might indicate issues with the JAR structure return null; @@ -176,7 +176,7 @@ class JarFileSystem extends ZipFileSystem { * returns foo/bar.class */ private byte[] getRootName(IndexNode prefix, IndexNode inode) { - int offset = prefix.name.length - 1; + int offset = prefix.name.length; byte[] fullName = inode.name; return Arrays.copyOfRange(fullName, offset, fullName.length); } diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java index 08f97cc61b1..77bfa5b81e0 100644 --- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java +++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,33 +34,64 @@ import java.nio.charset.CoderResult; import java.nio.charset.CodingErrorAction; import java.util.Arrays; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.nio.charset.StandardCharsets.ISO_8859_1; + /** * Utility class for zipfile name and comment decoding and encoding * * @author Xueming Shen */ -final class ZipCoder { +class ZipCoder { - String toString(byte[] ba, int length) { - CharsetDecoder cd = decoder().reset(); - int len = (int)(length * cd.maxCharsPerByte()); - char[] ca = new char[len]; - if (len == 0) - return new String(ca); - ByteBuffer bb = ByteBuffer.wrap(ba, 0, length); - CharBuffer cb = CharBuffer.wrap(ca); - CoderResult cr = cd.decode(bb, cb, true); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - cr = cd.flush(cb); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - return new String(ca, 0, cb.position()); + static class UTF8 extends ZipCoder { + UTF8() { + super(UTF_8); + } + + @Override + byte[] getBytes(String s) { // fast pass for ascii + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) > 0x7f) return super.getBytes(s); + } + return s.getBytes(ISO_8859_1); + } + + @Override + String toString(byte[] ba) { + for (byte b : ba) { + if (b < 0) return super.toString(ba); + } + return new String(ba, ISO_8859_1); + } + } + + private static ZipCoder utf8 = new UTF8(); + + public static ZipCoder get(String csn) { + Charset cs = Charset.forName(csn); + if (cs.name().equals("UTF-8")) { + return utf8; + } + return new ZipCoder(cs); } String toString(byte[] ba) { - return toString(ba, ba.length); + CharsetDecoder cd = decoder().reset(); + int clen = (int)(ba.length * cd.maxCharsPerByte()); + char[] ca = new char[clen]; + if (clen == 0) + return new String(ca); + ByteBuffer bb = ByteBuffer.wrap(ba, 0, ba.length); + CharBuffer cb = CharBuffer.wrap(ca); + CoderResult cr = cd.decode(bb, cb, true); + if (!cr.isUnderflow()) + throw new IllegalArgumentException(cr.toString()); + cr = cd.flush(cb); + if (!cr.isUnderflow()) + throw new IllegalArgumentException(cr.toString()); + return new String(ca, 0, cb.position()); } byte[] getBytes(String s) { @@ -69,62 +100,29 @@ final class ZipCoder { int len = (int)(ca.length * ce.maxBytesPerChar()); byte[] ba = new byte[len]; if (len == 0) - return ba; + return ba; ByteBuffer bb = ByteBuffer.wrap(ba); CharBuffer cb = CharBuffer.wrap(ca); CoderResult cr = ce.encode(cb, bb, true); if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); + throw new IllegalArgumentException(cr.toString()); cr = ce.flush(bb); if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); + throw new IllegalArgumentException(cr.toString()); if (bb.position() == ba.length) // defensive copy? - return ba; + return ba; else - return Arrays.copyOf(ba, bb.position()); - } - - // assume invoked only if "this" is not utf8 - byte[] getBytesUTF8(String s) { - if (isutf8) - return getBytes(s); - if (utf8 == null) - utf8 = new ZipCoder(Charset.forName("UTF-8")); - return utf8.getBytes(s); - } - - String toStringUTF8(byte[] ba, int len) { - if (isutf8) - return toString(ba, len); - if (utf8 == null) - utf8 = new ZipCoder(Charset.forName("UTF-8")); - return utf8.toString(ba, len); + return Arrays.copyOf(ba, bb.position()); } boolean isUTF8() { - return isutf8; + return cs == UTF_8; } private Charset cs; - private boolean isutf8; - private ZipCoder utf8; private ZipCoder(Charset cs) { this.cs = cs; - this.isutf8 = cs.name().equals("UTF-8"); - } - - static ZipCoder get(Charset charset) { - return new ZipCoder(charset); - } - - static ZipCoder get(String csn) { - try { - return new ZipCoder(Charset.forName(csn)); - } catch (Throwable t) { - t.printStackTrace(); - } - return new ZipCoder(Charset.defaultCharset()); } private final ThreadLocal decTL = new ThreadLocal<>(); @@ -133,10 +131,10 @@ final class ZipCoder { private CharsetDecoder decoder() { CharsetDecoder dec = decTL.get(); if (dec == null) { - dec = cs.newDecoder() - .onMalformedInput(CodingErrorAction.REPORT) - .onUnmappableCharacter(CodingErrorAction.REPORT); - decTL.set(dec); + dec = cs.newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT); + decTL.set(dec); } return dec; } @@ -144,10 +142,10 @@ final class ZipCoder { private CharsetEncoder encoder() { CharsetEncoder enc = encTL.get(); if (enc == null) { - enc = cs.newEncoder() - .onMalformedInput(CodingErrorAction.REPORT) - .onUnmappableCharacter(CodingErrorAction.REPORT); - encTL.set(enc); + enc = cs.newEncoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT); + encTL.set(enc); } return enc; } diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java index 3d9f82ba77c..0aac8a3f14f 100644 --- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -314,8 +314,8 @@ class ZipFileSystem extends FileSystem { IndexNode inode = getInode(path); if (inode == null) return null; - e = new Entry(inode.name); // pseudo directory - e.method = METHOD_STORED; // STORED for dir + e = new Entry(inode.name, inode.isdir); // pseudo directory + e.method = METHOD_STORED; // STORED for dir e.mtime = e.atime = e.ctime = zfsDefaultTimeStamp; } } finally { @@ -400,7 +400,8 @@ class ZipFileSystem extends FileSystem { List list = new ArrayList<>(); IndexNode child = inode.child; while (child != null) { - ZipPath zp = new ZipPath(this, child.name); + // assume all path from zip file itself is "normalized" + ZipPath zp = new ZipPath(this, child.name, true); if (filter == null || filter.accept(zp)) list.add(zp); child = child.sibling; @@ -415,14 +416,14 @@ class ZipFileSystem extends FileSystem { throws IOException { checkWritable(); - dir = toDirectoryPath(dir); + // dir = toDirectoryPath(dir); beginWrite(); try { ensureOpen(); if (dir.length == 0 || exists(dir)) // root dir, or exiting dir throw new FileAlreadyExistsException(getString(dir)); checkParents(dir); - Entry e = new Entry(dir, Entry.NEW); + Entry e = new Entry(dir, Entry.NEW, true); e.method = METHOD_STORED; // STORED for dir update(e); } finally { @@ -463,7 +464,7 @@ class ZipFileSystem extends FileSystem { } else { checkParents(dst); } - Entry u = new Entry(eSrc, Entry.COPY); // copy eSrc entry + Entry u = new Entry(eSrc, Entry.COPY); // copy eSrc entry u.name(dst); // change name if (eSrc.type == Entry.NEW || eSrc.type == Entry.FILECH) { @@ -533,7 +534,7 @@ class ZipFileSystem extends FileSystem { if (!hasCreate && !hasCreateNew) throw new NoSuchFileException(getString(path)); checkParents(path); - return getOutputStream(new Entry(path, Entry.NEW)); + return getOutputStream(new Entry(path, Entry.NEW, false)); } } finally { endRead(); @@ -887,7 +888,7 @@ class ZipFileSystem extends FileSystem { int off = getParentOff(path); if (off <= 1) return ROOTPATH; - return Arrays.copyOf(path, off + 1); + return Arrays.copyOf(path, off); } private static int getParentOff(byte[] path) { @@ -1075,11 +1076,9 @@ class ZipFileSystem extends FileSystem { if (pos + CENHDR + nlen > limit) { zerror("invalid CEN header (bad header size)"); } - byte[] name = new byte[nlen + 1]; - System.arraycopy(cen, pos + CENHDR, name, 1, nlen); - name[0] = '/'; - IndexNode inode = new IndexNode(name, pos); + IndexNode inode = new IndexNode(cen, pos + CENHDR, nlen, pos); inodes.put(inode, inode); + // skip ext and comment pos += (CENHDR + nlen + elen + clen); } @@ -1112,7 +1111,7 @@ class ZipFileSystem extends FileSystem { private boolean hasUpdate = false; // shared key. consumer guarantees the "writeLock" before use it. - private final IndexNode LOOKUPKEY = IndexNode.keyOf(null); + private final IndexNode LOOKUPKEY = new IndexNode(null, -1); private void updateDelete(IndexNode inode) { beginWrite(); @@ -1312,16 +1311,7 @@ class ZipFileSystem extends FileSystem { IndexNode getInode(byte[] path) { if (path == null) throw new NullPointerException("path"); - IndexNode key = IndexNode.keyOf(path); - IndexNode inode = inodes.get(key); - if (inode == null && - (path.length == 0 || path[path.length -1] != '/')) { - // if does not ends with a slash - path = Arrays.copyOf(path, path.length + 1); - path[path.length - 1] = '/'; - inode = inodes.get(key.as(path)); - } - return inode; + return inodes.get(IndexNode.keyOf(path)); } Entry getEntry(byte[] path) throws IOException { @@ -1782,8 +1772,11 @@ class ZipFileSystem extends FileSystem { int hashcode; // node is hashable/hashed by its name int pos = -1; // position in cen table, -1 menas the // entry does not exists in zip file - IndexNode(byte[] name) { + boolean isdir; + + IndexNode(byte[] name, boolean isdir) { name(name); + this.isdir = isdir; this.pos = -1; } @@ -1792,8 +1785,28 @@ class ZipFileSystem extends FileSystem { this.pos = pos; } + // constructor for cenInit() + IndexNode(byte[] cen, int noff, int nlen, int pos) { + if (cen[noff + nlen - 1] == '/') { + isdir = true; + nlen--; + } + name = new byte[nlen + 1]; + System.arraycopy(cen, pos + CENHDR, name, 1, nlen); + name[0] = '/'; + name(name); + this.pos = pos; + } + + private static final ThreadLocal cachedKey = new ThreadLocal<>(); + final static IndexNode keyOf(byte[] name) { // get a lookup key; - return new IndexNode(name, -1); + IndexNode key = cachedKey.get(); + if (key == null) { + key = new IndexNode(name, -1); + cachedKey.set(key); + } + return key.as(name); } final void name(byte[] name) { @@ -1807,8 +1820,7 @@ class ZipFileSystem extends FileSystem { } boolean isDir() { - return name != null && - (name.length == 0 || name[name.length - 1] == '/'); + return isdir; } public boolean equals(Object other) { @@ -1865,8 +1877,9 @@ class ZipFileSystem extends FileSystem { Entry() {} - Entry(byte[] name) { + Entry(byte[] name, boolean isdir) { name(name); + this.isdir = isdir; this.mtime = this.ctime = this.atime = System.currentTimeMillis(); this.crc = 0; this.size = 0; @@ -1874,13 +1887,14 @@ class ZipFileSystem extends FileSystem { this.method = METHOD_DEFLATED; } - Entry(byte[] name, int type) { - this(name); + Entry(byte[] name, int type, boolean isdir) { + this(name, isdir); this.type = type; } Entry (Entry e, int type) { name(e.name); + this.isdir = e.isdir; this.version = e.version; this.ctime = e.ctime; this.atime = e.atime; @@ -1902,7 +1916,7 @@ class ZipFileSystem extends FileSystem { } Entry (byte[] name, Path file, int type) { - this(name, type); + this(name, type, false); this.file = file; this.method = METHOD_STORED; } @@ -1948,6 +1962,7 @@ class ZipFileSystem extends FileSystem { locoff = CENOFF(cen, pos); pos += CENHDR; this.name = inode.name; + this.isdir = inode.isdir; this.hashcode = inode.hashcode; pos += nlen; @@ -1974,9 +1989,10 @@ class ZipFileSystem extends FileSystem { int elenEXTT = 0; // extra for Extended Timestamp boolean foundExtraTime = false; // if time stamp NTFS, EXTT present - // confirm size/length + byte[] zname = isdir ? toDirectoryPath(name) : name; - int nlen = (name != null) ? name.length - 1 : 0; // name has [0] as "slash" + // confirm size/length + int nlen = (zname != null) ? zname.length - 1 : 0; // name has [0] as "slash" int elen = (extra != null) ? extra.length : 0; int eoff = 0; int clen = (comment != null) ? comment.length : 0; @@ -2037,7 +2053,7 @@ class ZipFileSystem extends FileSystem { writeShort(os, 0); // internal file attributes (unused) writeInt(os, 0); // external file attributes (unused) writeInt(os, locoff0); // relative offset of local header - writeBytes(os, name, 1, nlen); + writeBytes(os, zname, 1, nlen); if (elen64 != 0) { writeShort(os, EXTID_ZIP64);// Zip64 extra writeShort(os, elen64 - 4); // size of "this" extra block @@ -2075,87 +2091,13 @@ class ZipFileSystem extends FileSystem { } ///////////////////// LOC ////////////////////// - static Entry readLOC(ZipFileSystem zipfs, long pos) - throws IOException - { - return readLOC(zipfs, pos, new byte[1024]); - } - - static Entry readLOC(ZipFileSystem zipfs, long pos, byte[] buf) - throws IOException - { - return new Entry().loc(zipfs, pos, buf); - } - - Entry loc(ZipFileSystem zipfs, long pos, byte[] buf) - throws IOException - { - assert (buf.length >= LOCHDR); - if (zipfs.readFullyAt(buf, 0, LOCHDR , pos) != LOCHDR) - throw new ZipException("loc: reading failed"); - if (!locSigAt(buf, 0)) - throw new ZipException("loc: wrong sig ->" - + Long.toString(getSig(buf, 0), 16)); - //startPos = pos; - version = LOCVER(buf); - flag = LOCFLG(buf); - method = LOCHOW(buf); - mtime = dosToJavaTime(LOCTIM(buf)); - crc = LOCCRC(buf); - csize = LOCSIZ(buf); - size = LOCLEN(buf); - int nlen = LOCNAM(buf); - int elen = LOCEXT(buf); - - name = new byte[nlen + 1]; - name[0] = '/'; - if (zipfs.readFullyAt(name, 1, nlen, pos + LOCHDR) != nlen) { - throw new ZipException("loc: name reading failed"); - } - if (elen > 0) { - extra = new byte[elen]; - if (zipfs.readFullyAt(extra, 0, elen, pos + LOCHDR + nlen) - != elen) { - throw new ZipException("loc: ext reading failed"); - } - } - pos += (LOCHDR + nlen + elen); - if ((flag & FLAG_DATADESCR) != 0) { - // Data Descriptor - Entry e = zipfs.getEntry(name); // get the size/csize from cen - if (e == null) - throw new ZipException("loc: name not found in cen"); - size = e.size; - csize = e.csize; - pos += (method == METHOD_STORED ? size : csize); - if (size >= ZIP64_MINVAL || csize >= ZIP64_MINVAL) - pos += 24; - else - pos += 16; - } else { - if (extra != null && - (size == ZIP64_MINVAL || csize == ZIP64_MINVAL)) { - // zip64 ext: must include both size and csize - int off = 0; - while (off + 20 < elen) { // HeaderID+DataSize+Data - int sz = SH(extra, off + 2); - if (SH(extra, off) == EXTID_ZIP64 && sz == 16) { - size = LL(extra, off + 4); - csize = LL(extra, off + 12); - break; - } - off += (sz + 4); - } - } - pos += (method == METHOD_STORED ? size : csize); - } - return this; - } int writeLOC(OutputStream os) throws IOException { writeInt(os, LOCSIG); // LOC header signature int version = version(); - int nlen = (name != null) ? name.length - 1 : 0; // [0] is slash + + byte[] zname = isdir ? toDirectoryPath(name) : name; + int nlen = (zname != null) ? zname.length - 1 : 0; // [0] is slash int elen = (extra != null) ? extra.length : 0; boolean foundExtraTime = false; // if extra timestamp present int eoff = 0; @@ -2214,7 +2156,7 @@ class ZipFileSystem extends FileSystem { } writeShort(os, nlen); writeShort(os, elen + elen64 + elenNTFS + elenEXTT); - writeBytes(os, name, 1, nlen); + writeBytes(os, zname, 1, nlen); if (elen64 != 0) { writeShort(os, EXTID_ZIP64); writeShort(os, 16); @@ -2551,7 +2493,7 @@ class ZipFileSystem extends FileSystem { private void buildNodeTree() throws IOException { beginWrite(); try { - IndexNode root = new IndexNode(ROOTPATH); + IndexNode root = new IndexNode(ROOTPATH, true); IndexNode[] nodes = inodes.keySet().toArray(new IndexNode[0]); inodes.put(root, root); ParentLookup lookup = new ParentLookup(); @@ -2564,7 +2506,7 @@ class ZipFileSystem extends FileSystem { root.child = node; break; } - lookup = lookup.as(node.name, off + 1); + lookup = lookup.as(node.name, off); if (inodes.containsKey(lookup)) { parent = inodes.get(lookup); node.sibling = parent.child; @@ -2572,7 +2514,7 @@ class ZipFileSystem extends FileSystem { break; } // add new pseudo directory entry - parent = new IndexNode(Arrays.copyOf(node.name, off + 1)); + parent = new IndexNode(Arrays.copyOf(node.name, off), true); inodes.put(parent, parent); node.sibling = parent.child; parent.child = node; diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java index 120017d78e2..75a58bacd66 100644 --- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java +++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,8 +59,7 @@ final class ZipPath implements Path { } else { if (zfs.zc.isUTF8()) { this.path = normalize(path); - } else { - // see normalize(String); + } else { // see normalize(String); this.path = normalize(zfs.getString(path)); } } @@ -68,12 +67,7 @@ final class ZipPath implements Path { ZipPath(ZipFileSystem zfs, String path) { this.zfs = zfs; - if (zfs.zc.isUTF8()) { - this.path = normalize(zfs.getBytes(path)); - } else { - // see normalize(String); - this.path = normalize(path); - } + this.path = normalize(path); } @Override @@ -84,33 +78,31 @@ final class ZipPath implements Path { return null; } - @Override + @Override public Path getFileName() { - initOffsets(); - int count = offsets.length; - if (count == 0) - return null; // no elements so no name - if (count == 1 && path[0] != '/') + int off = path.length; + if (off == 0 || off == 1 && path[0] == '/') + return null; + while (--off >= 0 && path[off] != '/') {} + if (off < 0) return this; - int lastOffset = offsets[count-1]; - int len = path.length - lastOffset; - byte[] result = new byte[len]; - System.arraycopy(path, lastOffset, result, 0, len); - return new ZipPath(zfs, result); + off++; + byte[] result = new byte[path.length - off]; + System.arraycopy(path, off, result, 0, result.length); + return new ZipPath(getFileSystem(), result, true); } @Override public ZipPath getParent() { - initOffsets(); - int count = offsets.length; - if (count == 0) // no elements so no parent + int off = path.length; + if (off == 0 || off == 1 && path[0] == '/') return null; - int len = offsets[count-1] - 1; - if (len <= 0) // parent is root only (may be null) + while (--off >= 0 && path[off] != '/') {} + if (off <= 0) return getRoot(); - byte[] result = new byte[len]; - System.arraycopy(path, 0, result, 0, len); - return new ZipPath(zfs, result); + byte[] result = new byte[off]; + System.arraycopy(path, 0, result, 0, off); + return new ZipPath(getFileSystem(), result, true); } @Override @@ -277,30 +269,36 @@ final class ZipPath implements Path { @Override public boolean isAbsolute() { - return (this.path.length > 0 && path[0] == '/'); + return path.length > 0 && path[0] == '/'; } @Override public ZipPath resolve(Path other) { - final ZipPath o = checkPath(other); - int tlen = this.path.length; - if (tlen == 0 || o.isAbsolute()) - return o; - int olen = o.path.length; - if (olen == 0) + ZipPath o = checkPath(other); + if (o.path.length == 0) return this; + if (o.isAbsolute() || this.path.length == 0) + return o; + return resolve(o.path); + } + + // opath is normalized, just concat + private ZipPath resolve(byte[] opath) { byte[] resolved = null; - if (this.path[tlen - 1] == '/') { + byte[] tpath = this.path; + int tlen = tpath.length; + int olen = opath.length; + if (path[tlen - 1] == '/') { resolved = new byte[tlen + olen]; - System.arraycopy(path, 0, resolved, 0, tlen); - System.arraycopy(o.path, 0, resolved, tlen, olen); + System.arraycopy(tpath, 0, resolved, 0, tlen); + System.arraycopy(opath, 0, resolved, tlen, olen); } else { resolved = new byte[tlen + 1 + olen]; - System.arraycopy(path, 0, resolved, 0, tlen); + System.arraycopy(tpath, 0, resolved, 0, tlen); resolved[tlen] = '/'; - System.arraycopy(o.path, 0, resolved, tlen + 1, olen); + System.arraycopy(opath, 0, resolved, tlen + 1, olen); } - return new ZipPath(zfs, resolved); + return new ZipPath(zfs, resolved, true); } @Override @@ -351,7 +349,12 @@ final class ZipPath implements Path { @Override public ZipPath resolve(String other) { - return resolve(zfs.getPath(other)); + byte[] opath = normalize(other); + if (opath.length == 0) + return this; + if (opath[0] == '/' || this.path.length == 0) + return new ZipPath(zfs, opath, true); + return resolve(opath); } @Override @@ -455,8 +458,9 @@ final class ZipPath implements Path { return normalize(path, i - 1); prevC = c; } - if (len > 1 && prevC == '/') + if (len > 1 && prevC == '/') { return Arrays.copyOf(path, len - 1); + } return path; } @@ -490,6 +494,8 @@ final class ZipPath implements Path { // to avoid incorrectly normalizing byte '0x5c' (as '\') // to '/'. private byte[] normalize(String path) { + if (zfs.zc.isUTF8()) + return normalize(zfs.getBytes(path)); int len = path.length(); if (len == 0) return new byte[0]; @@ -533,7 +539,8 @@ final class ZipPath implements Path { // Remove DotSlash(./) and resolve DotDot (..) components private byte[] getResolved() { for (int i = 0; i < path.length; i++) { - if (path[i] == (byte)'.') { + if (path[i] == (byte)'.' && + (i + 1 == path.length || path[i + 1] == '/')) { return resolve0(); } } @@ -976,5 +983,4 @@ final class ZipPath implements Path { } return sb.toString(); } - } diff --git a/jdk/test/jdk/nio/zipfs/PathOps.java b/jdk/test/jdk/nio/zipfs/PathOps.java index 1bd72f7bf9c..271aa97e383 100644 --- a/jdk/test/jdk/nio/zipfs/PathOps.java +++ b/jdk/test/jdk/nio/zipfs/PathOps.java @@ -31,7 +31,7 @@ import java.nio.file.Path; /** * * @test - * @bug 8038500 8040059 8139956 8146754 + * @bug 8038500 8040059 8139956 8146754 8172921 * @summary Tests path operations for zip provider. * * @run main PathOps @@ -180,6 +180,13 @@ public class PathOps { return this; } + PathOps resolvePath(String other, String expected) { + out.format("test resolve %s\n", other); + checkPath(); + check(path.resolve(fs.getPath(other)), expected); + return this; + } + PathOps resolveSibling(String other, String expected) { out.format("test resolveSibling %s\n", other); checkPath(); @@ -384,6 +391,30 @@ public class PathOps { .resolve("", "") .resolve("foo", "foo") .resolve("/foo", "/foo"); + test("/") + .resolve("", "/") + .resolve("foo", "/foo") + .resolve("/foo", "/foo") + .resolve("/foo/", "/foo"); + + // resolve(Path) + test("/tmp") + .resolvePath("foo", "/tmp/foo") + .resolvePath("/foo", "/foo") + .resolvePath("", "/tmp"); + test("tmp") + .resolvePath("foo", "tmp/foo") + .resolvePath("/foo", "/foo") + .resolvePath("", "tmp"); + test("") + .resolvePath("", "") + .resolvePath("foo", "foo") + .resolvePath("/foo", "/foo"); + test("/") + .resolvePath("", "/") + .resolvePath("foo", "/foo") + .resolvePath("/foo", "/foo") + .resolvePath("/foo/", "/foo"); // resolveSibling test("foo") From ced9c19693461e2b0312432e445cea26dec637d6 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 19 Jan 2017 13:37:05 +0100 Subject: [PATCH 127/154] 8172905: Minor startup cleanup of CallSite and MethodType Reviewed-by: psandoz, jrose --- .../classes/java/lang/invoke/CallSite.java | 55 +++++++++++++------ .../classes/java/lang/invoke/MethodType.java | 4 +- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java b/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java index c24f94951f0..53899611f59 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/CallSite.java @@ -28,6 +28,8 @@ package java.lang.invoke; import static java.lang.invoke.MethodHandleStatics.*; import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; +import jdk.internal.vm.annotation.Stable; + /** * A {@code CallSite} is a holder for a variable {@link MethodHandle}, * which is called its {@code target}. @@ -215,19 +217,36 @@ public class CallSite { public abstract MethodHandle dynamicInvoker(); /*non-public*/ MethodHandle makeDynamicInvoker() { - MethodHandle getTarget = GET_TARGET.bindArgumentL(0, this); + MethodHandle getTarget = getTargetHandle().bindArgumentL(0, this); MethodHandle invoker = MethodHandles.exactInvoker(this.type()); return MethodHandles.foldArguments(invoker, getTarget); } - private static final MethodHandle GET_TARGET; - private static final MethodHandle THROW_UCS; - static { + private static @Stable MethodHandle GET_TARGET; + private static MethodHandle getTargetHandle() { + MethodHandle handle = GET_TARGET; + if (handle != null) { + return handle; + } try { - GET_TARGET = IMPL_LOOKUP. - findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class)); - THROW_UCS = IMPL_LOOKUP. - findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Object.class, Object[].class)); + return GET_TARGET = IMPL_LOOKUP. + findVirtual(CallSite.class, "getTarget", + MethodType.methodType(MethodHandle.class)); + } catch (ReflectiveOperationException e) { + throw newInternalError(e); + } + } + + private static @Stable MethodHandle THROW_UCS; + private static MethodHandle uninitializedCallSiteHandle() { + MethodHandle handle = THROW_UCS; + if (handle != null) { + return handle; + } + try { + return THROW_UCS = IMPL_LOOKUP. + findStatic(CallSite.class, "uninitializedCallSite", + MethodType.methodType(Object.class, Object[].class)); } catch (ReflectiveOperationException e) { throw newInternalError(e); } @@ -242,7 +261,7 @@ public class CallSite { MethodType basicType = targetType.basicType(); MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS); if (invoker == null) { - invoker = THROW_UCS.asType(basicType); + invoker = uninitializedCallSiteHandle().asType(basicType); invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker); } // unchecked view is OK since no values will be received or returned @@ -250,12 +269,16 @@ public class CallSite { } // unsafe stuff: - private static final long TARGET_OFFSET; - private static final long CONTEXT_OFFSET; - static { + private static @Stable long TARGET_OFFSET; + private static long getTargetOffset() { + long offset = TARGET_OFFSET; + if (offset > 0) { + return offset; + } try { - TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target")); - CONTEXT_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("context")); + offset = TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target")); + assert(offset > 0); + return offset; } catch (Exception ex) { throw newInternalError(ex); } } @@ -265,7 +288,7 @@ public class CallSite { } /*package-private*/ MethodHandle getTargetVolatile() { - return (MethodHandle) UNSAFE.getObjectVolatile(this, TARGET_OFFSET); + return (MethodHandle) UNSAFE.getObjectVolatile(this, getTargetOffset()); } /*package-private*/ void setTargetVolatile(MethodHandle newTarget) { @@ -324,7 +347,7 @@ public class CallSite { final int NON_SPREAD_ARG_COUNT = 3; // (caller, name, type) if (NON_SPREAD_ARG_COUNT + argv.length > MethodType.MAX_MH_ARITY) throw new BootstrapMethodError("too many bootstrap method arguments"); - MethodType bsmType = bootstrapMethod.type(); + MethodType invocationType = MethodType.genericMethodType(NON_SPREAD_ARG_COUNT + argv.length); MethodHandle typedBSM = bootstrapMethod.asType(invocationType); MethodHandle spreader = invocationType.invokers().spreadInvoker(NON_SPREAD_ARG_COUNT); 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 ffb8a6a7859..53e88de34f2 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 @@ -1128,7 +1128,7 @@ class MethodType implements java.io.Serializable { public String toMethodDescriptorString() { String desc = methodDescriptor; if (desc == null) { - desc = BytecodeDescriptor.unparse(this); + desc = BytecodeDescriptor.unparseMethod(this.rtype, this.ptypes); methodDescriptor = desc; } return desc; @@ -1256,7 +1256,7 @@ s.writeObject(this.parameterArray()); private final ReferenceQueue stale; public ConcurrentWeakInternSet() { - this.map = new ConcurrentHashMap<>(); + this.map = new ConcurrentHashMap<>(512); this.stale = new ReferenceQueue<>(); } From 8f93cf0a46e0256c22f84f398cdff53d7679dfad Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Thu, 19 Jan 2017 12:06:58 -0500 Subject: [PATCH 128/154] 8172350: Typo in Timestamp.toString() Reviewed-by: dfuchs --- jdk/src/java.sql/share/classes/java/sql/Timestamp.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.sql/share/classes/java/sql/Timestamp.java b/jdk/src/java.sql/share/classes/java/sql/Timestamp.java index 9192ed7df1b..8421f955db6 100644 --- a/jdk/src/java.sql/share/classes/java/sql/Timestamp.java +++ b/jdk/src/java.sql/share/classes/java/sql/Timestamp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -259,7 +259,7 @@ public class Timestamp extends java.util.Date { /** * Formats a timestamp in JDBC timestamp escape format. * {@code yyyy-mm-dd hh:mm:ss.fffffffff}, - * where {@code ffffffffff} indicates nanoseconds. + * where {@code fffffffff} indicates nanoseconds. * * @return a {@code String} object in * {@code yyyy-mm-dd hh:mm:ss.fffffffff} format From 6b84b1d30ab89b7af907f202ad82cce0669370f4 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 19 Jan 2017 09:27:24 -0800 Subject: [PATCH 129/154] 8160710: Enable Thread to grant VarHandle field access to ThreadLocalRandom/Striped64 Reviewed-by: martin, dl, chegar --- .../java/lang/invoke/MethodHandles.java | 9 +- .../util/concurrent/ForkJoinWorkerThread.java | 10 +- .../util/concurrent/ThreadLocalRandom.java | 111 ++++++++---------- .../util/concurrent/atomic/Striped64.java | 29 +++-- .../util/concurrent/locks/LockSupport.java | 42 ++++--- 5 files changed, 107 insertions(+), 94 deletions(-) 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 d195d3d3db8..16a9e8a941d 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, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -846,8 +846,11 @@ public class MethodHandles { // that does not bluntly restrict classes under packages within // java.base from looking up MethodHandles or VarHandles. if (allowedModes == ALL_MODES && lookupClass.getClassLoader() == null) { - if ((name.startsWith("java.") && !name.startsWith("java.util.concurrent.")) || - (name.startsWith("sun.") && !name.startsWith("sun.invoke."))) { + if ((name.startsWith("java.") && + !name.equals("java.lang.Thread") && + !name.startsWith("java.util.concurrent.")) || + (name.startsWith("sun.") && + !name.startsWith("sun.invoke."))) { throw newIllegalArgumentException("illegal lookupClass: " + lookupClass); } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index 5e56fe1b05e..93bb08dd48f 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -185,7 +185,14 @@ public class ForkJoinWorkerThread extends Thread { static final class InnocuousForkJoinWorkerThread extends ForkJoinWorkerThread { /** The ThreadGroup for all InnocuousForkJoinWorkerThreads */ private static final ThreadGroup innocuousThreadGroup = - ThreadLocalRandom.createThreadGroup("InnocuousForkJoinWorkerThreadGroup"); + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction<>() { + public ThreadGroup run() { + ThreadGroup group = Thread.currentThread().getThreadGroup(); + for (ThreadGroup p; (p = group.getParent()) != null; ) + group = p; + return new ThreadGroup(group, "InnocuousForkJoinWorkerThreadGroup"); + }}); /** An AccessControlContext supporting no privileges */ private static final AccessControlContext INNOCUOUS_ACC = @@ -215,6 +222,5 @@ public class ForkJoinWorkerThread extends Thread { public void setContextClassLoader(ClassLoader cl) { throw new SecurityException("setContextClassLoader"); } - } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java index cb1b4f260f5..e42d041a033 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java @@ -36,6 +36,8 @@ package java.util.concurrent; import java.io.ObjectStreamField; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; import java.security.AccessControlContext; import java.util.Random; import java.util.Spliterator; @@ -48,7 +50,6 @@ import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.StreamSupport; -import jdk.internal.misc.Unsafe; /** * A random number generator isolated to the current thread. Like the @@ -108,7 +109,7 @@ public class ThreadLocalRandom extends Random { * though, we use only a single 64bit gamma. * * Because this class is in a different package than class Thread, - * field access methods use Unsafe to bypass access control rules. + * field access methods use VarHandles to bypass access control rules. * To conform to the requirements of the Random superclass * constructor, the common static ThreadLocalRandom maintains an * "initialized" field for the sake of rejecting user calls to @@ -163,8 +164,8 @@ public class ThreadLocalRandom extends Random { int probe = (p == 0) ? 1 : p; // skip 0 long seed = mix64(seeder.getAndAdd(SEEDER_INCREMENT)); Thread t = Thread.currentThread(); - U.putLong(t, SEED, seed); - U.putInt(t, PROBE, probe); + SEED.set(t, seed); + PROBE.set(t, probe); } /** @@ -173,7 +174,7 @@ public class ThreadLocalRandom extends Random { * @return the current thread's {@code ThreadLocalRandom} */ public static ThreadLocalRandom current() { - if (U.getInt(Thread.currentThread(), PROBE) == 0) + if ((int) PROBE.get(Thread.currentThread()) == 0) localInit(); return instance; } @@ -192,8 +193,8 @@ public class ThreadLocalRandom extends Random { final long nextSeed() { Thread t; long r; // read and update per-thread seed - U.putLong(t = Thread.currentThread(), SEED, - r = U.getLong(t, SEED) + GAMMA); + SEED.set(t = Thread.currentThread(), + (r = (long) SEED.get(t)) + GAMMA); return r; } @@ -938,7 +939,7 @@ public class ThreadLocalRandom extends Random { * can be used to force initialization on zero return. */ static final int getProbe() { - return U.getInt(Thread.currentThread(), PROBE); + return (int) PROBE.get(Thread.currentThread()); } /** @@ -949,7 +950,7 @@ public class ThreadLocalRandom extends Random { probe ^= probe << 13; // xorshift probe ^= probe >>> 17; probe ^= probe << 5; - U.putInt(Thread.currentThread(), PROBE, probe); + PROBE.set(Thread.currentThread(), probe); return probe; } @@ -959,14 +960,14 @@ public class ThreadLocalRandom extends Random { static final int nextSecondarySeed() { int r; Thread t = Thread.currentThread(); - if ((r = U.getInt(t, SECONDARY)) != 0) { + if ((r = (int) SECONDARY.get(t)) != 0) { r ^= r << 13; // xorshift r ^= r >>> 17; r ^= r << 5; } else if ((r = mix32(seeder.getAndAdd(SEEDER_INCREMENT))) == 0) r = 1; // avoid zero - U.putInt(t, SECONDARY, r); + SECONDARY.set(t, r); return r; } @@ -976,41 +977,13 @@ public class ThreadLocalRandom extends Random { * Erases ThreadLocals by nulling out Thread maps. */ static final void eraseThreadLocals(Thread thread) { - U.putObject(thread, THREADLOCALS, null); - U.putObject(thread, INHERITABLETHREADLOCALS, null); + THREADLOCALS.set(thread, null); + INHERITABLETHREADLOCALS.set(thread, null); } static final void setInheritedAccessControlContext(Thread thread, AccessControlContext acc) { - U.putObjectRelease(thread, INHERITEDACCESSCONTROLCONTEXT, acc); - } - - /** - * Returns a new group with the system ThreadGroup (the - * topmost, parent-less group) as parent. Uses Unsafe to - * traverse Thread.group and ThreadGroup.parent fields. - */ - static final ThreadGroup createThreadGroup(String name) { - if (name == null) - throw new NullPointerException(); - try { - long tg = U.objectFieldOffset - (Thread.class.getDeclaredField("group")); - long gp = U.objectFieldOffset - (ThreadGroup.class.getDeclaredField("parent")); - ThreadGroup group = (ThreadGroup) - U.getObject(Thread.currentThread(), tg); - while (group != null) { - ThreadGroup parent = (ThreadGroup)U.getObject(group, gp); - if (parent == null) - return new ThreadGroup(group, name); - group = parent; - } - } catch (ReflectiveOperationException e) { - throw new Error(e); - } - // fall through if null as cannot-happen safeguard - throw new Error("Cannot create ThreadGroup"); + INHERITEDACCESSCONTROLCONTEXT.setRelease(thread, acc); } // Serialization support @@ -1037,7 +1010,7 @@ public class ThreadLocalRandom extends Random { throws java.io.IOException { java.io.ObjectOutputStream.PutField fields = s.putFields(); - fields.put("rnd", U.getLong(Thread.currentThread(), SEED)); + fields.put("rnd", (long) SEED.get(Thread.currentThread())); fields.put("initialized", true); s.writeFields(); } @@ -1076,28 +1049,38 @@ public class ThreadLocalRandom extends Random { static final String BAD_RANGE = "bound must be greater than origin"; static final String BAD_SIZE = "size must be non-negative"; - // Unsafe mechanics - private static final Unsafe U = Unsafe.getUnsafe(); - private static final long SEED; - private static final long PROBE; - private static final long SECONDARY; - private static final long THREADLOCALS; - private static final long INHERITABLETHREADLOCALS; - private static final long INHERITEDACCESSCONTROLCONTEXT; + // VarHandle mechanics + private static final VarHandle SEED; + private static final VarHandle PROBE; + private static final VarHandle SECONDARY; + private static final VarHandle THREADLOCALS; + private static final VarHandle INHERITABLETHREADLOCALS; + private static final VarHandle INHERITEDACCESSCONTROLCONTEXT; static { try { - SEED = U.objectFieldOffset - (Thread.class.getDeclaredField("threadLocalRandomSeed")); - PROBE = U.objectFieldOffset - (Thread.class.getDeclaredField("threadLocalRandomProbe")); - SECONDARY = U.objectFieldOffset - (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed")); - THREADLOCALS = U.objectFieldOffset - (Thread.class.getDeclaredField("threadLocals")); - INHERITABLETHREADLOCALS = U.objectFieldOffset - (Thread.class.getDeclaredField("inheritableThreadLocals")); - INHERITEDACCESSCONTROLCONTEXT = U.objectFieldOffset - (Thread.class.getDeclaredField("inheritedAccessControlContext")); + MethodHandles.Lookup l = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction<>() { + public MethodHandles.Lookup run() { + try { + return MethodHandles.privateLookupIn(Thread.class, + MethodHandles.lookup()); + } catch (ReflectiveOperationException e) { + throw new Error(e); + } + }}); + SEED = l.findVarHandle(Thread.class, + "threadLocalRandomSeed", long.class); + PROBE = l.findVarHandle(Thread.class, + "threadLocalRandomProbe", int.class); + SECONDARY = l.findVarHandle(Thread.class, + "threadLocalRandomSecondarySeed", int.class); + Class tlm = Class.forName("java.lang.ThreadLocal$ThreadLocalMap"); + THREADLOCALS = l.findVarHandle(Thread.class, + "threadLocals", tlm); + INHERITABLETHREADLOCALS = l.findVarHandle(Thread.class, + "inheritableThreadLocals", tlm); + INHERITEDACCESSCONTROLCONTEXT = l.findVarHandle(Thread.class, + "inheritedAccessControlContext", AccessControlContext.class); } catch (ReflectiveOperationException e) { throw new Error(e); } @@ -1123,7 +1106,7 @@ public class ThreadLocalRandom extends Random { // at end of to survive static initialization circularity static { if (java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { + new java.security.PrivilegedAction<>() { public Boolean run() { return Boolean.getBoolean("java.util.secureRandomSeed"); }})) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java index a70094e3623..95030782a71 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java @@ -41,7 +41,6 @@ import java.util.Arrays; import java.util.concurrent.ThreadLocalRandom; import java.util.function.DoubleBinaryOperator; import java.util.function.LongBinaryOperator; -import jdk.internal.misc.Unsafe; /** * A package-local class holding common representation and mechanics @@ -191,7 +190,7 @@ abstract class Striped64 extends Number { * Duplicated from ThreadLocalRandom because of packaging restrictions. */ static final int getProbe() { - return U.getInt(Thread.currentThread(), PROBE); + return (int) THREAD_PROBE.get(Thread.currentThread()); } /** @@ -203,7 +202,7 @@ abstract class Striped64 extends Number { probe ^= probe << 13; // xorshift probe ^= probe >>> 17; probe ^= probe << 5; - U.putInt(Thread.currentThread(), PROBE, probe); + THREAD_PROBE.set(Thread.currentThread(), probe); return probe; } @@ -373,18 +372,28 @@ abstract class Striped64 extends Number { } } - // Unsafe and VarHandle mechanics - private static final Unsafe U = Unsafe.getUnsafe(); + // VarHandle mechanics private static final VarHandle BASE; private static final VarHandle CELLSBUSY; - private static final long PROBE; + private static final VarHandle THREAD_PROBE; static { try { MethodHandles.Lookup l = MethodHandles.lookup(); - BASE = l.findVarHandle(Striped64.class, "base", long.class); - CELLSBUSY = l.findVarHandle(Striped64.class, "cellsBusy", int.class); - PROBE = U.objectFieldOffset - (Thread.class.getDeclaredField("threadLocalRandomProbe")); + BASE = l.findVarHandle(Striped64.class, + "base", long.class); + CELLSBUSY = l.findVarHandle(Striped64.class, + "cellsBusy", int.class); + l = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction<>() { + public MethodHandles.Lookup run() { + try { + return MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup()); + } catch (ReflectiveOperationException e) { + throw new Error(e); + } + }}); + THREAD_PROBE = l.findVarHandle(Thread.class, + "threadLocalRandomProbe", int.class); } catch (ReflectiveOperationException e) { throw new Error(e); } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java index 7bf6e8a54cd..772318496f7 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java @@ -37,6 +37,9 @@ package java.util.concurrent.locks; import jdk.internal.misc.Unsafe; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + /** * Basic thread blocking primitives for creating locks and other * synchronization classes. @@ -139,7 +142,7 @@ public class LockSupport { private static void setBlocker(Thread t, Object arg) { // Even though volatile, hotspot doesn't need a write barrier here. - U.putObject(t, PARKBLOCKER, arg); + THREAD_PARKBLOCKER.set(t, arg); } /** @@ -289,7 +292,7 @@ public class LockSupport { public static Object getBlocker(Thread t) { if (t == null) throw new NullPointerException(); - return U.getObjectVolatile(t, PARKBLOCKER); + return THREAD_PARKBLOCKER.getVolatile(t); } /** @@ -396,14 +399,14 @@ public class LockSupport { static final int nextSecondarySeed() { int r; Thread t = Thread.currentThread(); - if ((r = U.getInt(t, SECONDARY)) != 0) { + if ((r = (int) THREAD_SECONDARY.get(t)) != 0) { r ^= r << 13; // xorshift r ^= r >>> 17; r ^= r << 5; } else if ((r = java.util.concurrent.ThreadLocalRandom.current().nextInt()) == 0) r = 1; // avoid zero - U.putInt(t, SECONDARY, r); + THREAD_SECONDARY.set(t, r); return r; } @@ -414,23 +417,32 @@ public class LockSupport { * ways that do not preserve unique mappings. */ static final long getThreadId(Thread thread) { - return U.getLongVolatile(thread, TID); + return (long) THREAD_TID.getVolatile(thread); } // Hotspot implementation via intrinsics API private static final Unsafe U = Unsafe.getUnsafe(); - private static final long PARKBLOCKER; - private static final long SECONDARY; - private static final long TID; + // VarHandle mechanics + private static final VarHandle THREAD_PARKBLOCKER; + private static final VarHandle THREAD_SECONDARY; + private static final VarHandle THREAD_TID; static { try { - PARKBLOCKER = U.objectFieldOffset - (Thread.class.getDeclaredField("parkBlocker")); - SECONDARY = U.objectFieldOffset - (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed")); - TID = U.objectFieldOffset - (Thread.class.getDeclaredField("tid")); - + MethodHandles.Lookup l = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction<>() { + public MethodHandles.Lookup run() { + try { + return MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup()); + } catch (ReflectiveOperationException e) { + throw new Error(e); + } + }}); + THREAD_PARKBLOCKER = l.findVarHandle(Thread.class, + "parkBlocker", Object.class); + THREAD_SECONDARY = l.findVarHandle(Thread.class, + "threadLocalRandomSecondarySeed", int.class); + THREAD_TID = l.findVarHandle(Thread.class, + "tid", long.class); } catch (ReflectiveOperationException e) { throw new Error(e); } From 69369c305a2996b1bfd8d11cb0bab78bb25e74b1 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Thu, 19 Jan 2017 18:03:24 +0000 Subject: [PATCH 130/154] 8173066: More verbose debug output for selection of X509 certs Reviewed-by: coffeys --- .../classes/sun/security/ssl/X509KeyManagerImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java index 256720a7b93..b6ed37cc5a3 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -818,6 +818,11 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager checker.init(false); } catch (CertPathValidatorException cpve) { // unlikely to happen + if (useDebug) { + debug.println( + "Cannot initialize algorithm constraints checker: " + cpve); + } + return false; } @@ -828,6 +833,11 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager // We don't care about the unresolved critical extensions. checker.check(cert, Collections.emptySet()); } catch (CertPathValidatorException cpve) { + if (useDebug) { + debug.println("Certificate (" + cert + + ") does not conform to algorithm constraints: " + cpve); + } + return false; } } From d9d9d8701a2089cf744ccd9e0c9afb7ab10efd3f Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Thu, 19 Jan 2017 13:50:02 -0500 Subject: [PATCH 131/154] 8055206: Update SecurityManager::checkPackageAccess to restrict non-exported JDK packages by default Reviewed-by: mchung --- .../classes/java/lang/SecurityManager.java | 196 +++++++++++++----- .../share/classes/java/lang/System.java | 15 +- .../java.base/share/classes/module-info.java | 1 - .../share/conf/security/java.security | 111 ++-------- .../share/lib/security/default.policy | 17 ++ .../com/sun/rowset/CachedRowSetImpl.java | 17 +- .../Cipher/AES/TestAESCiphers/testAES.policy | 6 +- .../LdapLoginModule/CheckConfigs.policy | 4 +- .../SecurityManager/CheckPackageAccess.java | 187 ++++++++++++----- .../SecurityManager/CheckPackageMatching.java | 51 +++-- .../SecurityManager/RestrictedPackages.java | 155 -------------- .../lambda/LogGeneratedClassesTest.java | 9 +- .../java/security/KeyRep/SerialOld.policy | 4 +- .../8146975/jtreg.test.policy | 29 +-- .../PortableRemoteObject/jtreg.test.policy | 23 +- 15 files changed, 377 insertions(+), 448 deletions(-) delete mode 100644 jdk/test/java/lang/SecurityManager/RestrictedPackages.java diff --git a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java index f004feea821..8a819ee6db7 100644 --- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java +++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,18 +25,30 @@ package java.lang; -import java.security.*; +import java.lang.RuntimePermission; +import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleDescriptor.Exports; +import java.lang.module.ModuleDescriptor.Opens; +import java.lang.reflect.Layer; +import java.lang.reflect.Member; +import java.lang.reflect.Module; import java.io.FileDescriptor; import java.io.File; import java.io.FilePermission; -import java.util.PropertyPermission; -import java.lang.RuntimePermission; -import java.net.SocketPermission; -import java.net.NetPermission; -import java.util.Hashtable; import java.net.InetAddress; -import java.lang.reflect.*; -import java.net.URL; +import java.net.SocketPermission; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.Permission; +import java.security.PrivilegedAction; +import java.security.Security; +import java.security.SecurityPermission; +import java.util.HashSet; +import java.util.Objects; +import java.util.PropertyPermission; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import jdk.internal.reflect.CallerSensitive; import sun.security.util.SecurityConstants; @@ -1415,46 +1427,108 @@ class SecurityManager { } } - if (packages == null) + if (packages == null) { packages = new String[0]; + } return packages; } + // The non-exported packages of the modules in the boot layer that are + // loaded by the platform class loader or its ancestors. A non-exported + // package is a package that either is not exported at all by its containing + // module or is exported in a qualified fashion by its containing module. + private static final Set nonExportedPkgs; + + static { + // Get the modules in the boot layer + Stream bootLayerModules = Layer.boot().modules().stream(); + + // Filter out the modules loaded by the boot or platform loader + PrivilegedAction> pa = () -> + bootLayerModules.filter(SecurityManager::isBootOrPlatformModule) + .collect(Collectors.toSet()); + Set modules = AccessController.doPrivileged(pa); + + // Filter out the non-exported packages + nonExportedPkgs = modules.stream() + .map(Module::getDescriptor) + .map(SecurityManager::nonExportedPkgs) + .flatMap(Set::stream) + .collect(Collectors.toSet()); + } + /** - * Throws a SecurityException if the - * calling thread is not allowed to access the package specified by - * the argument. + * Returns true if the module's loader is the boot or platform loader. + */ + private static boolean isBootOrPlatformModule(Module m) { + return m.getClassLoader() == null || + m.getClassLoader() == ClassLoader.getPlatformClassLoader(); + } + + /** + * Returns the non-exported packages of the specified module. + */ + private static Set nonExportedPkgs(ModuleDescriptor md) { + // start with all packages in the module + Set pkgs = new HashSet<>(md.packages()); + + // remove the non-qualified exported packages + md.exports().stream() + .filter(p -> !p.isQualified()) + .map(Exports::source) + .forEach(pkgs::remove); + + // remove the non-qualified open packages + md.opens().stream() + .filter(p -> !p.isQualified()) + .map(Opens::source) + .forEach(pkgs::remove); + + return pkgs; + } + + /** + * Throws a {@code SecurityException} if the calling thread is not allowed + * to access the specified package. *

- * This method is used by the loadClass method of class - * loaders. + * This method is called by the {@code loadClass} method of class loaders. *

- * This method first gets a list of - * restricted packages by obtaining a comma-separated list from - * a call to - * java.security.Security.getProperty("package.access"), - * and checks to see if pkg starts with or equals - * any of the restricted packages. If it does, then - * checkPermission gets called with the - * RuntimePermission("accessClassInPackage."+pkg) - * permission. + * This method checks if the specified package starts with or equals + * any of the packages in the {@code package.access} Security Property. + * An implementation may also check the package against an additional + * list of restricted packages as noted below. If the package is restricted, + * {@link #checkPermission(Permission)} is called with a + * {@code RuntimePermission("accessClassInPackage."+pkg)} permission. *

- * If this method is overridden, then - * super.checkPackageAccess should be called - * as the first line in the overridden method. + * If this method is overridden, then {@code super.checkPackageAccess} + * should be called as the first line in the overridden method. + * + * @implNote + * This implementation also restricts all non-exported packages of modules + * loaded by {@linkplain ClassLoader#getPlatformClassLoader + * the platform class loader} or its ancestors. A "non-exported package" + * refers to a package that is not exported to all modules. Specifically, + * it refers to a package that either is not exported at all by its + * containing module or is exported in a qualified fashion by its + * containing module. * * @param pkg the package name. - * @exception SecurityException if the calling thread does not have + * @throws SecurityException if the calling thread does not have * permission to access the specified package. - * @exception NullPointerException if the package name argument is - * null. - * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) - * loadClass + * @throws NullPointerException if the package name argument is + * {@code null}. + * @see java.lang.ClassLoader#loadClass(String, boolean) loadClass * @see java.security.Security#getProperty getProperty - * @see #checkPermission(java.security.Permission) checkPermission + * @see #checkPermission(Permission) checkPermission */ public void checkPackageAccess(String pkg) { - if (pkg == null) { - throw new NullPointerException("package name can't be null"); + Objects.requireNonNull(pkg, "package name can't be null"); + + // check if pkg is not exported to all modules + if (nonExportedPkgs.contains(pkg)) { + checkPermission( + new RuntimePermission("accessClassInPackage." + pkg)); + return; } String[] restrictedPkgs; @@ -1512,36 +1586,48 @@ class SecurityManager { } /** - * Throws a SecurityException if the - * calling thread is not allowed to define classes in the package - * specified by the argument. + * Throws a {@code SecurityException} if the calling thread is not + * allowed to define classes in the specified package. *

- * This method is used by the loadClass method of some + * This method is called by the {@code loadClass} method of some * class loaders. *

- * This method first gets a list of restricted packages by - * obtaining a comma-separated list from a call to - * java.security.Security.getProperty("package.definition"), - * and checks to see if pkg starts with or equals - * any of the restricted packages. If it does, then - * checkPermission gets called with the - * RuntimePermission("defineClassInPackage."+pkg) - * permission. + * This method checks if the specified package starts with or equals + * any of the packages in the {@code package.definition} Security + * Property. An implementation may also check the package against an + * additional list of restricted packages as noted below. If the package + * is restricted, {@link #checkPermission(Permission)} is called with a + * {@code RuntimePermission("defineClassInPackage."+pkg)} permission. *

- * If this method is overridden, then - * super.checkPackageDefinition should be called - * as the first line in the overridden method. + * If this method is overridden, then {@code super.checkPackageDefinition} + * should be called as the first line in the overridden method. + * + * @implNote + * This implementation also restricts all non-exported packages of modules + * loaded by {@linkplain ClassLoader#getPlatformClassLoader + * the platform class loader} or its ancestors. A "non-exported package" + * refers to a package that is not exported to all modules. Specifically, + * it refers to a package that either is not exported at all by its + * containing module or is exported in a qualified fashion by its + * containing module. * * @param pkg the package name. - * @exception SecurityException if the calling thread does not have + * @throws SecurityException if the calling thread does not have * permission to define classes in the specified package. - * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) + * @throws NullPointerException if the package name argument is + * {@code null}. + * @see java.lang.ClassLoader#loadClass(String, boolean) * @see java.security.Security#getProperty getProperty - * @see #checkPermission(java.security.Permission) checkPermission + * @see #checkPermission(Permission) checkPermission */ public void checkPackageDefinition(String pkg) { - if (pkg == null) { - throw new NullPointerException("package name can't be null"); + Objects.requireNonNull(pkg, "package name can't be null"); + + // check if pkg is not exported to all modules + if (nonExportedPkgs.contains(pkg)) { + checkPermission( + new RuntimePermission("defineClassInPackage." + pkg)); + return; } String[] pkgs; diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java index 18620771d20..1577e215e35 100644 --- a/jdk/src/java.base/share/classes/java/lang/System.java +++ b/jdk/src/java.base/share/classes/java/lang/System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -310,12 +310,13 @@ public final class System { * @see SecurityManager#checkPermission * @see java.lang.RuntimePermission */ - public static - void setSecurityManager(final SecurityManager s) { - try { - s.checkPackageAccess("java.lang"); - } catch (Exception e) { - // no-op + public static void setSecurityManager(final SecurityManager s) { + if (s != null) { + try { + s.checkPackageAccess("java.lang"); + } catch (Exception e) { + // no-op + } } setSecurityManager0(s); } diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index 1f62f7e6751..1114d513687 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -249,7 +249,6 @@ module java.base { jdk.crypto.token; exports sun.security.jca to java.smartcardio, - java.xml.crypto, jdk.crypto.ec, jdk.crypto.token, jdk.naming.dns; diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index 61a5169322c..5e778810bb7 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -298,111 +298,24 @@ keystore.type.compat=true # # List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.dom3.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.sun.tools.script.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - jdk.tools.jimage.,\ - com.sun.activation.registries.,\ - com.sun.java.accessibility.util.internal.,\ -#ifdef windows - com.sun.java.accessibility.internal.,\ -#endif -#ifdef macosx - apple.,\ -#endif +# will cause a security exception to be thrown when passed to the +# SecurityManager::checkPackageAccess method unless the corresponding +# RuntimePermission("accessClassInPackage."+package) has been granted. +# +package.access=sun.misc.,\ + sun.reflect.,\ # # List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. +# will cause a security exception to be thrown when passed to the +# SecurityManager::checkPackageDefinition method unless the corresponding +# RuntimePermission("defineClassInPackage."+package) has been granted. # -# by default, none of the class loaders supplied with the JDK call +# By default, none of the class loaders supplied with the JDK call # checkPackageDefinition. # -package.definition=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.dom3.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.sun.tools.script.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - jdk.tools.jimage.,\ - com.sun.activation.registries.,\ - com.sun.java.accessibility.util.internal.,\ -#ifdef windows - com.sun.java.accessibility.internal.,\ -#endif -#ifdef macosx - apple.,\ -#endif +package.definition=sun.misc.,\ + sun.reflect.,\ # # Determines whether this properties file can be appended to diff --git a/jdk/src/java.base/share/lib/security/default.policy b/jdk/src/java.base/share/lib/security/default.policy index 1f445078c6b..4d890704195 100644 --- a/jdk/src/java.base/share/lib/security/default.policy +++ b/jdk/src/java.base/share/lib/security/default.policy @@ -93,9 +93,19 @@ grant codeBase "jrt:/java.xml.crypto" { "com.sun.org.apache.xml.internal.security.register"; permission java.security.SecurityPermission "getProperty.jdk.xml.dsig.secureValidationPolicy"; + permission java.lang.RuntimePermission + "accessClassInPackage.com.sun.org.apache.xml.internal.*"; + permission java.lang.RuntimePermission + "accessClassInPackage.com.sun.org.apache.xpath.internal"; + permission java.lang.RuntimePermission + "accessClassInPackage.com.sun.org.apache.xpath.internal.*"; }; grant codeBase "jrt:/java.xml.ws" { + permission java.lang.RuntimePermission + "accessClassInPackage.com.sun.org.apache.xml.internal.resolver"; + permission java.lang.RuntimePermission + "accessClassInPackage.com.sun.org.apache.xml.internal.resolver.tools"; permission java.lang.RuntimePermission "accessClassInPackage.com.sun.xml.internal.*"; permission java.lang.RuntimePermission @@ -188,3 +198,10 @@ grant codeBase "jrt:/jdk.zipfs" { permission java.util.PropertyPermission "os.name", "read"; }; +grant codeBase "jrt:/jdk.accessibility" { + permission java.lang.RuntimePermission "accessClassInPackage.sun.awt"; +}; + +grant codeBase "jrt:/jdk.desktop" { + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.awt"; +}; diff --git a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java index 0326f57639c..37d7f8d4f3f 100644 --- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java +++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,9 @@ import java.io.*; import java.math.*; import java.util.*; import java.text.*; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import javax.sql.rowset.*; import javax.sql.rowset.spi.*; @@ -357,8 +360,16 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern } // set the Reader, this maybe overridden latter - provider = - SyncFactory.getInstance(DEFAULT_SYNC_PROVIDER); + try { + provider = AccessController.doPrivileged(new PrivilegedExceptionAction<>() { + @Override + public SyncProvider run() throws SyncFactoryException { + return SyncFactory.getInstance(DEFAULT_SYNC_PROVIDER); + } + }, null, new RuntimePermission("accessClassInPackage.com.sun.rowset.providers")); + } catch (PrivilegedActionException pae) { + throw (SyncFactoryException) pae.getException(); + } if (!(provider instanceof RIOptimisticProvider)) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidp").toString()); diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy index a138a577ff7..175e9cb86e5 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy +++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy @@ -1,6 +1,6 @@ -grant -{ +grant codeBase "file:${test.classes}/*" { permission java.security.SecurityPermission "removeProvider.SunJCE"; permission java.security.SecurityPermission "insertProvider.SunJCE"; - permission java.security.SecurityPermission "putProviderProperty.SunJCE"; + permission java.lang.RuntimePermission + "accessClassInPackage.com.sun.crypto.provider"; }; diff --git a/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.policy b/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.policy index 71362da17dc..87f7b627fdd 100644 --- a/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.policy +++ b/jdk/test/com/sun/security/auth/module/LdapLoginModule/CheckConfigs.policy @@ -1,9 +1,9 @@ - -grant { +grant codeBase "file:${test.classes}/*" { // The following permissions are not required because the test is // not expected to connect to an LDAP server // //permission java.net.SocketPermission "*:389", "connect"; //permission java.net.SocketPermission "*:636", "connect"; //permission javax.security.auth.AuthPermission "modifyPrincipals"; + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jndi.ldap"; }; diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java index b6f8a096db7..61d07b40d58 100644 --- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java +++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,87 +23,174 @@ /* * @test - * @bug 6741606 7146431 8000450 8019830 8022945 8027144 8041633 8078427 - * @summary Make sure all restricted packages listed in the package.access + * @bug 6741606 7146431 8000450 8019830 8022945 8027144 8041633 8078427 8055206 + * @summary Check that various restricted packages that are supposed to be + * restricted by default or are listed in the package.access * property in the java.security file are blocked + * @modules java.xml.ws java.corba * @run main/othervm CheckPackageAccess */ -import java.util.Collections; -import java.util.ArrayList; +import java.lang.module.ModuleFinder; +import java.lang.module.ModuleReference; +import java.util.Arrays; import java.util.List; +import java.util.Optional; -/* - * The main benefit of this test is to catch merge errors or other types - * of issues where one or more of the packages are accidentally - * removed. This is why the packages that are known to be restricted have to - * be explicitly listed below. - */ public class CheckPackageAccess { - public static void main(String[] args) throws Exception { - // get expected list of restricted packages - List pkgs = RestrictedPackages.expected(); + private static final SecurityManager sm = new SecurityManager(); + private static final ModuleFinder mf = ModuleFinder.ofSystem(); - // get actual list of restricted packages - List jspkgs = RestrictedPackages.actual(); + /* + * The expected list of restricted packages of the package.access property. + * + * This array should be updated whenever new packages are added to the + * package.access property in the java.security file + * NOTE: it should be in the same order as the java.security file + */ + private static final String[] EXPECTED = { + "sun.misc.", + "sun.reflect.", + }; - if (!isOpenJDKOnly()) { - String lastPkg = pkgs.get(pkgs.size() - 1); + /** + * Tests access to various packages of a module. + */ + private static class Test { + String moduleName; // name of module + ModuleReference moduleRef; // module reference + String exports; // exported pkg + Optional opens; // opened pkg + String conceals; // concealed pkg + Optional qualExports; // qualified export pkg + Optional qualOpens; // qualified open pkg + // qual open and non-qualified export pkg + Optional qualOpensAndExports; + Test(String module, String exports, String opens, String conceals, + String qualExports, String qualOpens, String qualOpensAndExports) { + this.moduleName = module; + this.moduleRef = mf.find(moduleName).get(); + this.exports = exports; + this.opens = Optional.ofNullable(opens); + this.conceals = conceals; + this.qualExports = Optional.ofNullable(qualExports); + this.qualOpens = Optional.ofNullable(qualOpens); + this.qualOpensAndExports = Optional.ofNullable(qualOpensAndExports); + } - // Remove any closed packages from list before comparing - int index = jspkgs.indexOf(lastPkg); - if (index != -1 && index != jspkgs.size() - 1) { - jspkgs.subList(index + 1, jspkgs.size()).clear(); + void test() { + System.out.println("Testing module " + moduleName); + + // access to exported pkg should pass + testNonRestricted(exports); + + // access to opened pkg should pass + opens.ifPresent(Test::testNonRestricted); + + // access to concealed pkg should fail + testRestricted(conceals); + + // access to qualified export pkg should fail + qualExports.ifPresent(Test::testRestricted); + + // access to qualified open pkg should fail + qualOpens.ifPresent(Test::testRestricted); + + // access to qualified opened pkg that is also exported should pass + qualOpensAndExports.ifPresent(Test::testNonRestricted); + } + + private static void testRestricted(String pkg) { + try { + sm.checkPackageAccess(pkg); + throw new RuntimeException("Able to access restricted package: " + + pkg); + } catch (SecurityException se) {} + try { + sm.checkPackageDefinition(pkg); + throw new RuntimeException("Able to access restricted package: " + + pkg); + } catch (SecurityException se) {} + } + + private static void testNonRestricted(String pkg) { + try { + sm.checkPackageAccess(pkg); + } catch (SecurityException se) { + throw new RuntimeException("Unable to access exported package: " + + pkg, se); + } + try { + sm.checkPackageDefinition(pkg); + } catch (SecurityException se) { + throw new RuntimeException("Unable to access exported package: " + + pkg, se); } } + } - // Sort to ensure lists are comparable - Collections.sort(pkgs); - Collections.sort(jspkgs); + private static final Test[] tests = new Test[] { + // java.base module loaded by boot loader + new Test("java.base", "java.security", null, "jdk.internal.jrtfs", + "jdk.internal.loader", null, null), + // java.desktop module loaded by boot loader and has an openQual pkg + // that is exported + new Test("java.desktop", "java.applet", null, "sun.applet", + "sun.awt", "com.sun.java.swing.plaf.windows", + "javax.swing.plaf.basic"), + // java.security.jgss module loaded by platform loader + new Test("java.security.jgss", "org.ietf.jgss", null, + "sun.security.krb5.internal.crypto", "sun.security.krb5", + null, null), + // java.xml.ws module loaded by platform loader but needs to be added + // and has an openQual pkg that is exported + new Test("java.xml.ws", "javax.xml.soap", null, + "com.sun.xml.internal.stream.buffer", + "com.sun.xml.internal.ws.api", null, + "javax.xml.ws.wsaddressing"), + // java.xml.ws module loaded by platform loader but needs to be added + // and has an openQual pkg + new Test("java.corba", "javax.rmi", null, "sun.corba", + "com.sun.corba.se.impl.util", "com.sun.jndi.cosnaming", null), + }; - if (!pkgs.equals(jspkgs)) { - for (String p : pkgs) - if (!jspkgs.contains(p)) - System.out.println("In golden set, but not in j.s file: " + p); - for (String p : jspkgs) - if (!pkgs.contains(p)) - System.out.println("In j.s file, but not in golden set: " + p); + public static void main(String[] args) throws Exception { + // check expected list of restricted packages in java.security file + checkPackages(Arrays.asList(EXPECTED)); - throw new RuntimeException("restricted packages are not " + - "consistent with java.security file"); + // check access to each module's packages + for (Test test : tests) { + test.test(); } - System.setSecurityManager(new SecurityManager()); - SecurityManager sm = System.getSecurityManager(); + + System.out.println("Test passed"); + } + + private static void checkPackages(List pkgs) { for (String pkg : pkgs) { - String subpkg = pkg + "foo"; try { sm.checkPackageAccess(pkg); throw new RuntimeException("Able to access " + pkg + " package"); } catch (SecurityException se) { } - try { - sm.checkPackageAccess(subpkg); - throw new RuntimeException("Able to access " + subpkg + - " package"); - } catch (SecurityException se) { } try { sm.checkPackageDefinition(pkg); throw new RuntimeException("Able to define class in " + pkg + " package"); } catch (SecurityException se) { } + String subpkg = pkg + "foo"; try { - sm.checkPackageDefinition(subpkg); - throw new RuntimeException("Able to define class in " + subpkg + + sm.checkPackageAccess(subpkg); + throw new RuntimeException("Able to access " + subpkg + " package"); } catch (SecurityException se) { } + try { + sm.checkPackageDefinition(subpkg); + throw new RuntimeException("Able to define class in " + + subpkg + " package"); + } catch (SecurityException se) { } } - System.out.println("Test passed"); - } - - private static boolean isOpenJDKOnly() { - String prop = System.getProperty("java.runtime.name"); - return prop != null && prop.startsWith("OpenJDK"); } } diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java b/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java index 915ea7995ab..418a04a6857 100644 --- a/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java +++ b/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,11 +28,13 @@ * @run main/othervm CheckPackageMatching */ +import java.security.Security; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.StringTokenizer; /* * The purpose of this test is not to verify the content of the package @@ -46,10 +48,23 @@ public class CheckPackageMatching { * The restricted packages listed in the package.access property of the * java.security file. */ - private static final String[] packages = - RestrictedPackages.actual().toArray(new String[0]); + private static final String[] packages = actual().toArray(new String[0]); - private static final boolean OPEN_JDK = isOpenJDKOnly(); + /** + * Returns the list of restricted packages in the package.access property. + */ + private static List actual() { + String prop = Security.getProperty("package.access"); + List packages = new ArrayList<>(); + if (prop != null && !prop.equals("")) { + StringTokenizer tok = new StringTokenizer(prop, ","); + while (tok.hasMoreElements()) { + String s = tok.nextToken().trim(); + packages.add(s); + } + } + return packages; + } /** * PackageMatcher implements a state machine that matches package @@ -326,13 +341,8 @@ public class CheckPackageMatching { System.getSecurityManager().checkPackageAccess("com.sun.jmxa"); System.getSecurityManager().checkPackageAccess("jmx"); List actual = Arrays.asList(packages); - for (String p : actual) { - if (!actual.contains(p)) { - System.err.println("Warning: '" + p + " not in package.access"); - } - } - if (!actual.contains("sun.")) { - throw new Error("package.access does not contain 'sun.'"); + if (!actual.contains("sun.misc.")) { + throw new Error("package.access does not contain 'sun.misc.'"); } } @@ -447,17 +457,15 @@ public class CheckPackageMatching { // These should not match. for (String pkg : new String[] {"gloups.machin", "su", - "org.jcp.xml.dsig.interna", + "org.jcp.xml.dsig.inter", "com.sun.jm", "com.sun.jmxa"}) { testMatch(matcher, pkg, false, true); } // These should match. for (String pkg : Arrays.asList( - new String[] {"sun.gloups.machin", "sun", "sun.com", - "com.sun.jmx", "com.sun.jmx.a", - "org.jcp.xml.dsig.internal", - "org.jcp.xml.dsig.internal.foo"})) { + new String[] {"sun.misc.gloups.machin", "sun.misc", + "sun.reflect"})) { testMatch(matcher, pkg, true, true); } @@ -486,12 +494,6 @@ public class CheckPackageMatching { } for (String pkg : pkgs) { - if (!OPEN_JDK && pkg.equals("com.sun.media.sound.")) { - // don't test com.sun.media.sound since there is an entry - // for com.sun.media in non OpenJDK builds. Otherwise, - // the test for this package will fail unexpectedly. - continue; - } String candidate = pkg.substring(0, pkg.length() - 2); boolean expected = pkglist.contains(candidate + "."); testMatch(matcher, candidate, expected, @@ -537,9 +539,4 @@ public class CheckPackageMatching { } } } - - private static boolean isOpenJDKOnly() { - String prop = System.getProperty("java.runtime.name"); - return prop != null && prop.startsWith("OpenJDK"); - } } diff --git a/jdk/test/java/lang/SecurityManager/RestrictedPackages.java b/jdk/test/java/lang/SecurityManager/RestrictedPackages.java deleted file mode 100644 index 546df6b1661..00000000000 --- a/jdk/test/java/lang/SecurityManager/RestrictedPackages.java +++ /dev/null @@ -1,155 +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. - */ - -import java.security.Security; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.StringTokenizer; - -/** - * A collection of utility methods and constants for testing the package - * access and package definition security checks. - */ -final class RestrictedPackages { - - /* - * The expected list of restricted packages. - * - * This array should be updated whenever new packages are added to the - * package.access property in the java.security file - * NOTE: it should be in the same order as the java.security file - */ - static final String[] EXPECTED = { - "sun.", - "com.sun.xml.internal.", - "com.sun.imageio.", - "com.sun.istack.internal.", - "com.sun.jmx.", - "com.sun.media.sound.", - "com.sun.naming.internal.", - "com.sun.proxy.", - "com.sun.corba.se.", - "com.sun.org.apache.bcel.internal.", - "com.sun.org.apache.regexp.internal.", - "com.sun.org.apache.xerces.internal.", - "com.sun.org.apache.xpath.internal.", - "com.sun.org.apache.xalan.internal.extensions.", - "com.sun.org.apache.xalan.internal.lib.", - "com.sun.org.apache.xalan.internal.res.", - "com.sun.org.apache.xalan.internal.templates.", - "com.sun.org.apache.xalan.internal.utils.", - "com.sun.org.apache.xalan.internal.xslt.", - "com.sun.org.apache.xalan.internal.xsltc.cmdline.", - "com.sun.org.apache.xalan.internal.xsltc.compiler.", - "com.sun.org.apache.xalan.internal.xsltc.trax.", - "com.sun.org.apache.xalan.internal.xsltc.util.", - "com.sun.org.apache.xml.internal.res.", - "com.sun.org.apache.xml.internal.security.", - "com.sun.org.apache.xml.internal.serializer.dom3.", - "com.sun.org.apache.xml.internal.serializer.utils.", - "com.sun.org.apache.xml.internal.utils.", - "com.sun.org.glassfish.", - "com.sun.tools.script.", - "com.oracle.xmlns.internal.", - "com.oracle.webservices.internal.", - "org.jcp.xml.dsig.internal.", - "jdk.internal.", - "jdk.nashorn.internal.", - "jdk.nashorn.tools.", - "jdk.tools.jimage.", - "com.sun.activation.registries.", - "com.sun.java.accessibility.util.internal." - }; - - /* - * A non-exhaustive list of restricted packages. - * - * Contrary to what is in the EXPECTED list, this list does not need - * to be exhaustive. - */ - static final String[] EXPECTED_NONEXHAUSTIVE = { - "sun.", - "com.sun.xml.internal.", - "com.sun.imageio.", - "com.sun.istack.internal.", - "com.sun.jmx.", - "com.sun.proxy.", - "com.sun.org.apache.bcel.internal.", - "com.sun.org.apache.regexp.internal.", - "com.sun.org.apache.xerces.internal.", - "com.sun.org.apache.xpath.internal.", - "com.sun.org.apache.xalan.internal.extensions.", - "com.sun.org.apache.xalan.internal.lib.", - "com.sun.org.apache.xalan.internal.res.", - "com.sun.org.apache.xalan.internal.templates.", - "com.sun.org.apache.xalan.internal.utils.", - "com.sun.org.apache.xalan.internal.xslt.", - "com.sun.org.apache.xalan.internal.xsltc.cmdline.", - "com.sun.org.apache.xalan.internal.xsltc.compiler.", - "com.sun.org.apache.xalan.internal.xsltc.trax.", - "com.sun.org.apache.xalan.internal.xsltc.util.", - "com.sun.org.apache.xml.internal.res.", - "com.sun.org.apache.xml.internal.serializer.utils.", - "com.sun.org.apache.xml.internal.utils.", - "com.sun.org.apache.xml.internal.security.", - "com.sun.org.glassfish.", - "org.jcp.xml.dsig.internal." - }; - - private static final String OS_NAME = System.getProperty("os.name"); - - /** - * Returns a list of expected restricted packages, including any - * OS specific packages. The returned list is mutable. - */ - static List expected() { - List pkgs = new ArrayList<>(Arrays.asList(EXPECTED)); - if (OS_NAME.contains("OS X")) { - pkgs.add("apple."); // add apple package for OS X - } - if (OS_NAME.contains("Win")) { - pkgs.add("com.sun.java.accessibility.internal."); // add Win only package - } - return pkgs; - } - - /** - * Returns a list of actual restricted packages. The returned list - * is mutable. - */ - static List actual() { - String prop = Security.getProperty("package.access"); - List packages = new ArrayList<>(); - if (prop != null && !prop.equals("")) { - StringTokenizer tok = new StringTokenizer(prop, ","); - while (tok.hasMoreElements()) { - String s = tok.nextToken().trim(); - packages.add(s); - } - } - return packages; - } - - private RestrictedPackages() { } -} diff --git a/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java b/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java index dc088b374bc..047c128e9d5 100644 --- a/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java +++ b/jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,6 +63,7 @@ public class LogGeneratedClassesTest extends LUtils { scratch.add(" int foo();"); scratch.add(" }"); scratch.add(" public static void main(String[] args) {"); + scratch.add(" System.setSecurityManager(new SecurityManager());"); scratch.add(" I lam = () -> 10;"); scratch.add(" Runnable r = () -> {"); scratch.add(" System.out.println(\"Runnable\");"); @@ -114,7 +115,6 @@ public class LogGeneratedClassesTest extends LUtils { public void testNotLogging() { TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), "-cp", ".", - "-Djava.security.manager", "com.example.TestLambda"); tr.assertZero("Should still return 0"); } @@ -125,7 +125,6 @@ public class LogGeneratedClassesTest extends LUtils { TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), "-cp", ".", "-Djdk.internal.lambda.dumpProxyClasses=dump", - "-Djava.security.manager", "com.example.TestLambda"); // 2 our own class files. We don't care about the others assertEquals(Files.find( @@ -143,7 +142,6 @@ public class LogGeneratedClassesTest extends LUtils { TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), "-cp", ".", "-Djdk.internal.lambda.dumpProxyClasses=notExist", - "-Djava.security.manager", "com.example.TestLambda"); assertEquals(tr.testOutput.stream() .filter(s -> s.startsWith("WARNING")) @@ -159,7 +157,6 @@ public class LogGeneratedClassesTest extends LUtils { TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), "-cp", ".", "-Djdk.internal.lambda.dumpProxyClasses=file", - "-Djava.security.manager", "com.example.TestLambda"); assertEquals(tr.testOutput.stream() .filter(s -> s.startsWith("WARNING")) @@ -218,7 +215,6 @@ public class LogGeneratedClassesTest extends LUtils { TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), "-cp", ".", "-Djdk.internal.lambda.dumpProxyClasses=readOnly", - "-Djava.security.manager", "com.example.TestLambda"); assertEquals(tr.testOutput.stream() .filter(s -> s.startsWith("WARNING")) @@ -237,7 +233,6 @@ public class LogGeneratedClassesTest extends LUtils { TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), "-cp", ".", "-Djdk.internal.lambda.dumpProxyClasses=dumpLong", - "-Djava.security.manager", longFQCN); assertEquals(tr.testOutput.stream() .filter(s -> s.startsWith("WARNING: Exception")) diff --git a/jdk/test/java/security/KeyRep/SerialOld.policy b/jdk/test/java/security/KeyRep/SerialOld.policy index e029d09a4e9..4ab31832721 100644 --- a/jdk/test/java/security/KeyRep/SerialOld.policy +++ b/jdk/test/java/security/KeyRep/SerialOld.policy @@ -1,4 +1,4 @@ -grant { +grant codeBase "file:${test.classes}/*" { permission java.io.FilePermission "${test.src}${file.separator}*", "read"; permission java.util.PropertyPermission "test.src", "read"; @@ -11,4 +11,6 @@ grant { "accessClassInPackage.sun.security.x509"; permission java.lang.RuntimePermission "accessClassInPackage.sun.security.rsa"; + permission java.lang.RuntimePermission + "accessClassInPackage.com.sun.crypto.provider"; }; diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy b/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy index 52d9247b846..d2a3b1a4e42 100644 --- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/jtreg.test.policy @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,25 +21,12 @@ * questions. */ -grant codeBase "jrt:/java.corba" { - permission java.security.AllPermission; -}; - - - grant { - permission java.io.FilePermission "./-", "read,write,execute"; - permission java.io.FilePermission "*", "read"; - permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve"; - permission java.util.PropertyPermission "*", "read, write"; - permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; - permission java.io.SerializablePermission "enableSubclassImplementation"; - permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc"; - permission java.lang.RuntimePermission "accessClassInPackage.sun.corba"; - permission java.lang.RuntimePermission "defineClassInPackage.sun.corba"; - permission java.lang.RuntimePermission "reflectionFactoryAccess"; - permission sun.corba.BridgePermission "getBridge"; - permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect"; - permission java.util.PropertyPermission "*", "read, write"; - permission java.io.FilePermission "<>", "read,write,execute"; + permission java.util.PropertyPermission "*", "read"; + permission java.io.FilePermission "<>", "read, execute"; +}; + +grant codeBase "file:${test.classes}/*" { + permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve"; + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jndi.cosnaming"; }; diff --git a/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy b/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy index 73477e5d250..d2a3b1a4e42 100644 --- a/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy +++ b/jdk/test/javax/rmi/PortableRemoteObject/jtreg.test.policy @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,23 +21,12 @@ * questions. */ -grant codeBase "jrt:/java.corba" { - permission java.security.AllPermission; +grant { + permission java.util.PropertyPermission "*", "read"; + permission java.io.FilePermission "<>", "read, execute"; }; -grant { - permission java.io.FilePermission "./-", "read,write,execute"; - permission java.io.FilePermission "*", "read"; +grant codeBase "file:${test.classes}/*" { permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve"; - permission java.util.PropertyPermission "*", "read, write"; - permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; - permission java.io.SerializablePermission "enableSubclassImplementation"; - permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc"; - permission java.lang.RuntimePermission "accessClassInPackage.sun.corba"; - permission java.lang.RuntimePermission "defineClassInPackage.sun.corba"; - permission java.lang.RuntimePermission "reflectionFactoryAccess"; - permission sun.corba.BridgePermission "getBridge"; - permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect"; - permission java.util.PropertyPermission "*", "read, write"; - permission java.io.FilePermission "<>", "read,write,execute"; + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jndi.cosnaming"; }; From 5aa0f30214646ade5ce2656c1667ed8f6816e9e6 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 19 Jan 2017 13:46:45 -0800 Subject: [PATCH 132/154] 8172547: (se) Selector.select(Long.MAX_VALUE) fires repeatedly Clamp the jlong-valued select() timeout to INT_MAX for struct timeval Reviewed-by: rriggs, clanger, alanb --- .../native/libnio/ch/WindowsSelectorImpl.c | 17 +++- .../nio/channels/Selector/SelectTimeout.java | 82 +++++++++++-------- 2 files changed, 63 insertions(+), 36 deletions(-) diff --git a/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c b/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c index 7d5e1e77875..4d9432845ea 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c +++ b/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ #define FD_SETSIZE 1024 +#include #include #include @@ -75,8 +76,18 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject tv = NULL; } else { tv = &timevalue; - tv->tv_sec = (long)(timeout / 1000); - tv->tv_usec = (long)((timeout % 1000) * 1000); + jlong sec = timeout / 1000; + // + // struct timeval members are signed 32-bit integers so the + // signed 64-bit jlong needs to be clamped + // + if (sec > INT_MAX) { + tv->tv_sec = INT_MAX; + tv->tv_usec = 0; + } else { + tv->tv_sec = (long)sec; + tv->tv_usec = (long)((timeout % 1000) * 1000); + } } /* Set FD_SET structures required for select */ diff --git a/jdk/test/java/nio/channels/Selector/SelectTimeout.java b/jdk/test/java/nio/channels/Selector/SelectTimeout.java index aaeff367d84..797a36386ae 100644 --- a/jdk/test/java/nio/channels/Selector/SelectTimeout.java +++ b/jdk/test/java/nio/channels/Selector/SelectTimeout.java @@ -1,46 +1,50 @@ /* -* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License version 2 only, as -* published by the Free Software Foundation. -* -* This code is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -* version 2 for more details (a copy is included in the LICENSE file that -* accompanied this code). -* -* You should have received a copy of the GNU General Public License version -* 2 along with this work; if not, write to the Free Software Foundation, -* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -* -* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -* or visit www.oracle.com if you need additional information or have any -* questions. -*/ + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8165000 - * @summary Verify no IOException on OS X for large timeout value in select(). - * @requires (os.family == "mac") + * @bug 8165000 8172547 + * @summary Verify no IOException on OS X for large timeout value in select() + * and that timeout does not occur too early on Windows. + * @requires (os.family == "mac" | os.family == "windows") */ import java.io.IOException; import java.nio.channels.Selector; public class SelectTimeout { - private static final long HUGE_TIMEOUT = 100000001000L; - private static final long SLEEP_MILLIS = 10000; + private static final long BIG_TIMEOUT = 100_000_001_000L; // 8165000 + private static final long BIGGER_TIMEOUT = 850_000_000_000_000L; // 8172547 + private static final long SLEEP_MILLIS = 10000; - private static Exception theException; + private static volatile Exception theException; + private static volatile boolean isTimedOut; public static void main(String[] args) throws IOException, InterruptedException { int failures = 0; long[] timeouts = - new long[] {0, HUGE_TIMEOUT/2, HUGE_TIMEOUT - 1, HUGE_TIMEOUT}; + new long[] {1, BIG_TIMEOUT/2, BIG_TIMEOUT - 1, BIG_TIMEOUT, + BIGGER_TIMEOUT}; for (long t : timeouts) { if (!test(t)) { failures++; @@ -61,23 +65,35 @@ public class SelectTimeout { Thread t = new Thread(() -> { try { + isTimedOut = false; selector.select(timeout); + isTimedOut = true; } catch (IOException ioe) { theException = ioe; } }); t.start(); - Thread.currentThread().sleep(SLEEP_MILLIS); - t.interrupt(); + t.join(SLEEP_MILLIS); + boolean result; if (theException == null) { - System.out.printf("Test succeeded with timeout %d%n", timeout); - return true; + if (timeout > SLEEP_MILLIS && isTimedOut) { + System.err.printf("Test timed out early with timeout %d%n", + timeout); + result = false; + } else { + System.out.printf("Test succeeded with timeout %d%n", timeout); + result = true; + } } else { System.err.printf("Test failed with timeout %d%n", timeout); theException.printStackTrace(); - return false; + result = false; } + + t.interrupt(); + + return result; } } From 82c66a5178fe169b5655194ef9474c5fca0c962d Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:06 +0000 Subject: [PATCH 133/154] Added tag jdk-9+153 for changeset 32d7aa6c6a4a --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 56e00db59ee..e54c4180d63 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -395,3 +395,4 @@ b119012d1c2ab2570fe8718633840d0c1f1f441d jdk-9+149 6234069ff9789f7582e1faa32cb6283cbd1a5a2d jdk-9+150 71a766d4c18041a7f833ee22823125b02e1a7f1e jdk-9+151 ef056360ddf3977d7d2ddbeb456a4d612d19ea05 jdk-9+152 +816a6d03a7c44edfbd8780110529f1bdc3964fb9 jdk-9+153 From 689cb8978ed128c3c00bd9fdd09976ef24fd0fe6 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:06 +0000 Subject: [PATCH 134/154] Added tag jdk-9+153 for changeset 6fd8396f2160 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 73926ce02dd..49bf178f515 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -395,3 +395,4 @@ f95cc86b6ac22ec1ade5d4f825dc7782adeea228 jdk-9+148 9205e980062a5c4530b51021c6e274025f4ccbdf jdk-9+150 77f827f5bbad3ef795664bc675f72d98d156b9f8 jdk-9+151 ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152 +68a8e8658511093b322a46ed04b2a321e1da2a43 jdk-9+153 From 69f59c6c1660217370a9690e4cc73aaf4824ff6b Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:07 +0000 Subject: [PATCH 135/154] Added tag jdk-9+153 for changeset 57498dec29b2 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index f83cfd06fef..de59ae64925 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -555,3 +555,4 @@ a82cb5350cad96a0b4de496afebe3ded89f27efa jdk-9+146 98fe046473c90204cbc9b34c512b9fc10dfb8479 jdk-9+150 2a2ac7d9f52c8cb2b80077e515b5840b947e640c jdk-9+151 31f1d26c60df7b2e516a4f84160d76ba017d4e09 jdk-9+152 +217ba81b9a4ce8698200370175aa2db86a39f66c jdk-9+153 From daf172a09faa0a1b1292a5cf1470c982321b34f9 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:08 +0000 Subject: [PATCH 136/154] Added tag jdk-9+153 for changeset a65111f63f2e --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index f1e4cc0eb8c..a73fb2ebf2a 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -395,3 +395,4 @@ c41140100bf1e5c10c7b8f3bde91c16eff7485f5 jdk-9+147 71e198ef3839045e829a879af1d709be16ab0f88 jdk-9+150 d27bab22ff62823902d93d1d35ca397cfd50d059 jdk-9+151 a20f2cf90762673e1bc4980fd6597e70a2578045 jdk-9+152 +1c4411322327aea3f91011ec3977a12a05b09629 jdk-9+153 From c3299a2008e282985120df778ccf78262ad6ba28 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:08 +0000 Subject: [PATCH 137/154] Added tag jdk-9+153 for changeset dd12865718f3 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index c476846b6a9..17b1b7612c8 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -395,3 +395,4 @@ c45db75bfe8bc20bb80b4a009ae3f69c9cd2d885 jdk-9+148 f85154af719f99a3b4d81b67a8b4c18a650d10f9 jdk-9+150 13c6906bfc861d99dc35a19c80b7a99f0b0ac58d jdk-9+151 7e3da313b1746578da648155e37dd8526e83153d jdk-9+152 +1384504d2cd0e55c5e0becaeaf40ab05cae959d6 jdk-9+153 From cb67101315df7a941a6a26872767f431257dbd62 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:08 +0000 Subject: [PATCH 138/154] Added tag jdk-9+153 for changeset ab25a1c23fef --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 14b31ffc1ad..2b9c99ea42a 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -398,3 +398,4 @@ c8c9c334743caf8155c9809b6b4ac315d3a66476 jdk-9+148 77e4e30d9d111272cd4a45a2203e8f570d40b12e jdk-9+150 c48b4d4768b1c2b8fe5d1a844ca13732e5dfbe2a jdk-9+151 6f8fb1cf7e5f61c40dcc3654f9a623c505f6de1f jdk-9+152 +7a532a9a227137155b905341d4b99939db51220e jdk-9+153 From eb1242d56a9b5228f85e2c71fba066b4512ddde2 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:09 +0000 Subject: [PATCH 139/154] Added tag jdk-9+153 for changeset 047a57b0839a --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index a9baa97862f..649e286be02 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -395,3 +395,4 @@ cb9e896265ef45295fdd09986dee76624e4d41e4 jdk-9+145 e5a42ddaf633fde14b983f740ae0e7e490741fd1 jdk-9+150 4f348bd05341581df84ff1510d5b3a9b5b488367 jdk-9+151 5b6f12de6f9167a582fa2c6ac54e69c591b09e68 jdk-9+152 +03f48cd283f5dd6b7153fd7e0cf2df8582b14391 jdk-9+153 From a371c25de1111dd08d813bdf010729b43589c5bb Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 Jan 2017 22:31:10 +0000 Subject: [PATCH 140/154] Added tag jdk-9+153 for changeset be8643ebe865 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 285e632fd15..7fe9710ae5c 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -386,3 +386,4 @@ c281306d33d83c92e0d870ace385d5f99678d7e7 jdk-9+149 ace1d994bca775d6545a4c874ae73d1dfc9ec18b jdk-9+150 2a0437036a64853334e538044eb68d2df70075fa jdk-9+151 ddc52e72757086a75a54371e8e7f56a3f89f1e55 jdk-9+152 +19aaaf2d02b7d6986538cd9a8c46901ecb50eebf jdk-9+153 From be58d38ea38caab4cbecfa4e0f6bf055be84f61e Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Thu, 19 Jan 2017 15:45:36 -0800 Subject: [PATCH 141/154] 8173085: Warning module name in --add-exports not found: jdk.jdeps when compiling for BUILD_JIGSAW_TOOLS Reviewed-by: jjg --- jdk/make/CompileModuleTools.gmk | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/make/CompileModuleTools.gmk b/jdk/make/CompileModuleTools.gmk index b366182e507..2bfe520b233 100644 --- a/jdk/make/CompileModuleTools.gmk +++ b/jdk/make/CompileModuleTools.gmk @@ -37,6 +37,5 @@ $(eval $(call SetupJavaCompilation,BUILD_JIGSAW_TOOLS, \ build/tools/jigsaw, \ BIN := $(TOOLS_CLASSES_DIR), \ ADD_JAVAC_FLAGS := \ - --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \ --add-exports java.base/jdk.internal.module=ALL-UNNAMED \ )) From 248778d27a5f8a16e4c90a4f5a6632a7ca8e9a89 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Thu, 19 Jan 2017 16:38:24 -0800 Subject: [PATCH 142/154] 8173072: zipfs fails to handle incorrect info-zip "extended timestamp extra field" Reviewed-by: redestad --- .../share/classes/jdk/nio/zipfs/ZipCoder.java | 18 +++++++++--------- .../classes/jdk/nio/zipfs/ZipFileSystem.java | 7 ++++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java index 77bfa5b81e0..ea5ca6a4f63 100644 --- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java +++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java @@ -67,7 +67,7 @@ class ZipCoder { } } - private static ZipCoder utf8 = new UTF8(); + private static final ZipCoder utf8 = new UTF8(); public static ZipCoder get(String csn) { Charset cs = Charset.forName(csn); @@ -82,15 +82,15 @@ class ZipCoder { int clen = (int)(ba.length * cd.maxCharsPerByte()); char[] ca = new char[clen]; if (clen == 0) - return new String(ca); + return new String(ca); ByteBuffer bb = ByteBuffer.wrap(ba, 0, ba.length); CharBuffer cb = CharBuffer.wrap(ca); CoderResult cr = cd.decode(bb, cb, true); if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); + throw new IllegalArgumentException(cr.toString()); cr = cd.flush(cb); if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); + throw new IllegalArgumentException(cr.toString()); return new String(ca, 0, cb.position()); } @@ -100,19 +100,19 @@ class ZipCoder { int len = (int)(ca.length * ce.maxBytesPerChar()); byte[] ba = new byte[len]; if (len == 0) - return ba; + return ba; ByteBuffer bb = ByteBuffer.wrap(ba); CharBuffer cb = CharBuffer.wrap(ca); CoderResult cr = ce.encode(cb, bb, true); if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); + throw new IllegalArgumentException(cr.toString()); cr = ce.flush(bb); if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); + throw new IllegalArgumentException(cr.toString()); if (bb.position() == ba.length) // defensive copy? - return ba; + return ba; else - return Arrays.copyOf(ba, bb.position()); + return Arrays.copyOf(ba, bb.position()); } boolean isUTF8() { diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java index 0aac8a3f14f..498a93dc902 100644 --- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -2294,16 +2294,17 @@ class ZipFileSystem extends FileSystem { locPos += locSZ; continue; } + int end = locPos + locSZ - 4; int flag = CH(buf, locPos++); - if ((flag & 0x1) != 0) { + if ((flag & 0x1) != 0 && locPos <= end) { mtime = unixToJavaTime(LG(buf, locPos)); locPos += 4; } - if ((flag & 0x2) != 0) { + if ((flag & 0x2) != 0 && locPos <= end) { atime = unixToJavaTime(LG(buf, locPos)); locPos += 4; } - if ((flag & 0x4) != 0) { + if ((flag & 0x4) != 0 && locPos <= end) { ctime = unixToJavaTime(LG(buf, locPos)); locPos += 4; } From 4b9bc4ffe63ae9019e3f9daf9085a5749acae434 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 20 Jan 2017 19:12:46 +0530 Subject: [PATCH 143/154] 8172659: PluginException("TargetPlatform attribute is missing ...") - should be ModuleTarget Reviewed-by: alanb, jlaskey --- .../classes/jdk/tools/jlink/builder/DefaultImageBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java index fccb913f4fa..3c2cfbd8e90 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java @@ -162,7 +162,7 @@ public final class DefaultImageBuilder implements ImageBuilder { }); if (this.targetOsName == null) { - throw new PluginException("TargetPlatform attribute is missing for java.base module"); + throw new PluginException("ModuleTarget attribute is missing for java.base module"); } checkResourcePool(files); From bef071156dfa68b816143f69ee0cb53045a1525d Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Fri, 20 Jan 2017 08:01:43 -0800 Subject: [PATCH 144/154] 8173083: VarHandle usages in LockSupport and ThreadLocalRandom result in circularity issues Reviewed-by: martin --- .../util/concurrent/ThreadLocalRandom.java | 81 ++++++++----------- .../util/concurrent/locks/LockSupport.java | 42 ++++------ 2 files changed, 50 insertions(+), 73 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java index e42d041a033..e76f2d10597 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java @@ -36,8 +36,6 @@ package java.util.concurrent; import java.io.ObjectStreamField; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; import java.security.AccessControlContext; import java.util.Random; import java.util.Spliterator; @@ -50,6 +48,7 @@ import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.StreamSupport; +import jdk.internal.misc.Unsafe; /** * A random number generator isolated to the current thread. Like the @@ -109,7 +108,7 @@ public class ThreadLocalRandom extends Random { * though, we use only a single 64bit gamma. * * Because this class is in a different package than class Thread, - * field access methods use VarHandles to bypass access control rules. + * field access methods use Unsafe to bypass access control rules. * To conform to the requirements of the Random superclass * constructor, the common static ThreadLocalRandom maintains an * "initialized" field for the sake of rejecting user calls to @@ -164,8 +163,8 @@ public class ThreadLocalRandom extends Random { int probe = (p == 0) ? 1 : p; // skip 0 long seed = mix64(seeder.getAndAdd(SEEDER_INCREMENT)); Thread t = Thread.currentThread(); - SEED.set(t, seed); - PROBE.set(t, probe); + U.putLong(t, SEED, seed); + U.putInt(t, PROBE, probe); } /** @@ -174,7 +173,7 @@ public class ThreadLocalRandom extends Random { * @return the current thread's {@code ThreadLocalRandom} */ public static ThreadLocalRandom current() { - if ((int) PROBE.get(Thread.currentThread()) == 0) + if (U.getInt(Thread.currentThread(), PROBE) == 0) localInit(); return instance; } @@ -193,8 +192,8 @@ public class ThreadLocalRandom extends Random { final long nextSeed() { Thread t; long r; // read and update per-thread seed - SEED.set(t = Thread.currentThread(), - (r = (long) SEED.get(t)) + GAMMA); + U.putLong(t = Thread.currentThread(), SEED, + r = U.getLong(t, SEED) + GAMMA); return r; } @@ -939,7 +938,7 @@ public class ThreadLocalRandom extends Random { * can be used to force initialization on zero return. */ static final int getProbe() { - return (int) PROBE.get(Thread.currentThread()); + return U.getInt(Thread.currentThread(), PROBE); } /** @@ -950,7 +949,7 @@ public class ThreadLocalRandom extends Random { probe ^= probe << 13; // xorshift probe ^= probe >>> 17; probe ^= probe << 5; - PROBE.set(Thread.currentThread(), probe); + U.putInt(Thread.currentThread(), PROBE, probe); return probe; } @@ -960,14 +959,14 @@ public class ThreadLocalRandom extends Random { static final int nextSecondarySeed() { int r; Thread t = Thread.currentThread(); - if ((r = (int) SECONDARY.get(t)) != 0) { + if ((r = U.getInt(t, SECONDARY)) != 0) { r ^= r << 13; // xorshift r ^= r >>> 17; r ^= r << 5; } else if ((r = mix32(seeder.getAndAdd(SEEDER_INCREMENT))) == 0) r = 1; // avoid zero - SECONDARY.set(t, r); + U.putInt(t, SECONDARY, r); return r; } @@ -977,13 +976,13 @@ public class ThreadLocalRandom extends Random { * Erases ThreadLocals by nulling out Thread maps. */ static final void eraseThreadLocals(Thread thread) { - THREADLOCALS.set(thread, null); - INHERITABLETHREADLOCALS.set(thread, null); + U.putObject(thread, THREADLOCALS, null); + U.putObject(thread, INHERITABLETHREADLOCALS, null); } static final void setInheritedAccessControlContext(Thread thread, AccessControlContext acc) { - INHERITEDACCESSCONTROLCONTEXT.setRelease(thread, acc); + U.putObjectRelease(thread, INHERITEDACCESSCONTROLCONTEXT, acc); } // Serialization support @@ -1010,7 +1009,7 @@ public class ThreadLocalRandom extends Random { throws java.io.IOException { java.io.ObjectOutputStream.PutField fields = s.putFields(); - fields.put("rnd", (long) SEED.get(Thread.currentThread())); + fields.put("rnd", U.getLong(Thread.currentThread(), SEED)); fields.put("initialized", true); s.writeFields(); } @@ -1049,38 +1048,28 @@ public class ThreadLocalRandom extends Random { static final String BAD_RANGE = "bound must be greater than origin"; static final String BAD_SIZE = "size must be non-negative"; - // VarHandle mechanics - private static final VarHandle SEED; - private static final VarHandle PROBE; - private static final VarHandle SECONDARY; - private static final VarHandle THREADLOCALS; - private static final VarHandle INHERITABLETHREADLOCALS; - private static final VarHandle INHERITEDACCESSCONTROLCONTEXT; + // Unsafe mechanics + private static final Unsafe U = Unsafe.getUnsafe(); + private static final long SEED; + private static final long PROBE; + private static final long SECONDARY; + private static final long THREADLOCALS; + private static final long INHERITABLETHREADLOCALS; + private static final long INHERITEDACCESSCONTROLCONTEXT; static { try { - MethodHandles.Lookup l = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public MethodHandles.Lookup run() { - try { - return MethodHandles.privateLookupIn(Thread.class, - MethodHandles.lookup()); - } catch (ReflectiveOperationException e) { - throw new Error(e); - } - }}); - SEED = l.findVarHandle(Thread.class, - "threadLocalRandomSeed", long.class); - PROBE = l.findVarHandle(Thread.class, - "threadLocalRandomProbe", int.class); - SECONDARY = l.findVarHandle(Thread.class, - "threadLocalRandomSecondarySeed", int.class); - Class tlm = Class.forName("java.lang.ThreadLocal$ThreadLocalMap"); - THREADLOCALS = l.findVarHandle(Thread.class, - "threadLocals", tlm); - INHERITABLETHREADLOCALS = l.findVarHandle(Thread.class, - "inheritableThreadLocals", tlm); - INHERITEDACCESSCONTROLCONTEXT = l.findVarHandle(Thread.class, - "inheritedAccessControlContext", AccessControlContext.class); + SEED = U.objectFieldOffset + (Thread.class.getDeclaredField("threadLocalRandomSeed")); + PROBE = U.objectFieldOffset + (Thread.class.getDeclaredField("threadLocalRandomProbe")); + SECONDARY = U.objectFieldOffset + (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed")); + THREADLOCALS = U.objectFieldOffset + (Thread.class.getDeclaredField("threadLocals")); + INHERITABLETHREADLOCALS = U.objectFieldOffset + (Thread.class.getDeclaredField("inheritableThreadLocals")); + INHERITEDACCESSCONTROLCONTEXT = U.objectFieldOffset + (Thread.class.getDeclaredField("inheritedAccessControlContext")); } catch (ReflectiveOperationException e) { throw new Error(e); } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java index 772318496f7..b1e40a338b9 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java @@ -37,9 +37,6 @@ package java.util.concurrent.locks; import jdk.internal.misc.Unsafe; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; - /** * Basic thread blocking primitives for creating locks and other * synchronization classes. @@ -142,7 +139,7 @@ public class LockSupport { private static void setBlocker(Thread t, Object arg) { // Even though volatile, hotspot doesn't need a write barrier here. - THREAD_PARKBLOCKER.set(t, arg); + U.putObject(t, PARKBLOCKER, arg); } /** @@ -292,7 +289,7 @@ public class LockSupport { public static Object getBlocker(Thread t) { if (t == null) throw new NullPointerException(); - return THREAD_PARKBLOCKER.getVolatile(t); + return U.getObjectVolatile(t, PARKBLOCKER); } /** @@ -399,14 +396,14 @@ public class LockSupport { static final int nextSecondarySeed() { int r; Thread t = Thread.currentThread(); - if ((r = (int) THREAD_SECONDARY.get(t)) != 0) { + if ((r = U.getInt(t, SECONDARY)) != 0) { r ^= r << 13; // xorshift r ^= r >>> 17; r ^= r << 5; } else if ((r = java.util.concurrent.ThreadLocalRandom.current().nextInt()) == 0) r = 1; // avoid zero - THREAD_SECONDARY.set(t, r); + U.putInt(t, SECONDARY, r); return r; } @@ -417,32 +414,23 @@ public class LockSupport { * ways that do not preserve unique mappings. */ static final long getThreadId(Thread thread) { - return (long) THREAD_TID.getVolatile(thread); + return U.getLongVolatile(thread, TID); } // Hotspot implementation via intrinsics API private static final Unsafe U = Unsafe.getUnsafe(); - // VarHandle mechanics - private static final VarHandle THREAD_PARKBLOCKER; - private static final VarHandle THREAD_SECONDARY; - private static final VarHandle THREAD_TID; + private static final long PARKBLOCKER; + private static final long SECONDARY; + private static final long TID; static { try { - MethodHandles.Lookup l = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public MethodHandles.Lookup run() { - try { - return MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup()); - } catch (ReflectiveOperationException e) { - throw new Error(e); - } - }}); - THREAD_PARKBLOCKER = l.findVarHandle(Thread.class, - "parkBlocker", Object.class); - THREAD_SECONDARY = l.findVarHandle(Thread.class, - "threadLocalRandomSecondarySeed", int.class); - THREAD_TID = l.findVarHandle(Thread.class, - "tid", long.class); + PARKBLOCKER = U.objectFieldOffset + (Thread.class.getDeclaredField("parkBlocker")); + SECONDARY = U.objectFieldOffset + (Thread.class.getDeclaredField("threadLocalRandomSecondarySeed")); + TID = U.objectFieldOffset + (Thread.class.getDeclaredField("tid")); + } catch (ReflectiveOperationException e) { throw new Error(e); } From 45be416036506b1d731cb9bf61dbd43567129505 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 20 Jan 2017 18:41:12 +0000 Subject: [PATCH 145/154] 8172971: java.management could use System.Logger Java.management is updated to use System.Logger instead of java.util.logging.Logger. Reviewed-by: mchung, rriggs --- .../com/sun/jmx/defaults/JmxProperties.java | 20 +- .../DefaultMBeanServerInterceptor.java | 127 ++-- .../ClassLoaderRepositorySupport.java | 43 +- .../sun/jmx/mbeanserver/JmxMBeanServer.java | 14 +- .../jmx/mbeanserver/MBeanInstantiator.java | 28 +- .../mbeanserver/MBeanServerDelegateImpl.java | 10 +- .../com/sun/jmx/mbeanserver/Repository.java | 26 +- .../com/sun/jmx/remote/util/ClassLogger.java | 160 ++--- .../javax/management/MBeanServerDelegate.java | 6 +- .../javax/management/MBeanServerFactory.java | 17 +- .../javax/management/StandardMBean.java | 19 +- .../loading/DefaultLoaderRepository.java | 12 +- .../javax/management/loading/MLet.java | 167 +++--- .../javax/management/loading/MLetParser.java | 29 +- .../modelmbean/DescriptorSupport.java | 282 ++++----- .../modelmbean/ModelMBeanAttributeInfo.java | 62 +- .../modelmbean/ModelMBeanConstructorInfo.java | 73 +-- .../modelmbean/ModelMBeanInfoSupport.java | 173 ++---- .../ModelMBeanNotificationInfo.java | 51 +- .../modelmbean/ModelMBeanOperationInfo.java | 75 +-- .../modelmbean/RequiredModelMBean.java | 567 ++++++------------ .../management/monitor/CounterMonitor.java | 19 +- .../management/monitor/GaugeMonitor.java | 16 +- .../javax/management/monitor/Monitor.java | 107 ++-- .../management/monitor/StringMonitor.java | 7 +- .../MBeanServerNotificationFilter.java | 61 +- .../management/relation/RelationService.java | 322 ++++------ .../management/relation/RelationSupport.java | 137 ++--- .../relation/RelationTypeSupport.java | 34 +- .../classes/javax/management/timer/Timer.java | 76 +-- .../management/timer/TimerAlarmClock.java | 6 +- .../share/classes/module-info.java | 4 +- .../management/LoggingTest/LoggingTest.java | 109 ++++ .../LoggingTest/LoggingWithJULTest.java | 51 ++ .../LoggingWithLoggerFinderTest.java | 46 ++ .../management/LoggingTest/logging.properties | 55 ++ .../test.loggerfinder/module-info.java | 28 + .../test/loggerfinder/TestLoggerFinder.java | 177 ++++++ 38 files changed, 1500 insertions(+), 1716 deletions(-) create mode 100644 jdk/test/sun/management/LoggingTest/LoggingTest.java create mode 100644 jdk/test/sun/management/LoggingTest/LoggingWithJULTest.java create mode 100644 jdk/test/sun/management/LoggingTest/LoggingWithLoggerFinderTest.java create mode 100644 jdk/test/sun/management/LoggingTest/logging.properties create mode 100644 jdk/test/sun/management/LoggingTest/test.loggerfinder/module-info.java create mode 100644 jdk/test/sun/management/LoggingTest/test.loggerfinder/test/loggerfinder/TestLoggerFinder.java diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java b/jdk/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java index 5c7f7dc3f2d..566d0f9d5cd 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/defaults/JmxProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package com.sun.jmx.defaults; -import java.util.logging.Logger; +import java.lang.System.Logger; /** * This contains the property list defined for this @@ -120,7 +120,7 @@ public class JmxProperties { * Logger for MBean Server information. */ public static final Logger MBEANSERVER_LOGGER = - Logger.getLogger(MBEANSERVER_LOGGER_NAME); + System.getLogger(MBEANSERVER_LOGGER_NAME); /** * Logger name for MLet service information. @@ -132,7 +132,7 @@ public class JmxProperties { * Logger for MLet service information. */ public static final Logger MLET_LOGGER = - Logger.getLogger(MLET_LOGGER_NAME); + System.getLogger(MLET_LOGGER_NAME); /** * Logger name for Monitor information. @@ -144,7 +144,7 @@ public class JmxProperties { * Logger for Monitor information. */ public static final Logger MONITOR_LOGGER = - Logger.getLogger(MONITOR_LOGGER_NAME); + System.getLogger(MONITOR_LOGGER_NAME); /** * Logger name for Timer information. @@ -156,7 +156,7 @@ public class JmxProperties { * Logger for Timer information. */ public static final Logger TIMER_LOGGER = - Logger.getLogger(TIMER_LOGGER_NAME); + System.getLogger(TIMER_LOGGER_NAME); /** * Logger name for Event Management information. @@ -168,7 +168,7 @@ public class JmxProperties { * Logger for Event Management information. */ public static final Logger NOTIFICATION_LOGGER = - Logger.getLogger(NOTIFICATION_LOGGER_NAME); + System.getLogger(NOTIFICATION_LOGGER_NAME); /** * Logger name for Relation Service. @@ -180,7 +180,7 @@ public class JmxProperties { * Logger for Relation Service. */ public static final Logger RELATION_LOGGER = - Logger.getLogger(RELATION_LOGGER_NAME); + System.getLogger(RELATION_LOGGER_NAME); /** * Logger name for Model MBean. @@ -192,7 +192,7 @@ public class JmxProperties { * Logger for Model MBean. */ public static final Logger MODELMBEAN_LOGGER = - Logger.getLogger(MODELMBEAN_LOGGER_NAME); + System.getLogger(MODELMBEAN_LOGGER_NAME); /** * Logger name for all other JMX classes. @@ -204,5 +204,5 @@ public class JmxProperties { * Logger for all other JMX classes. */ public static final Logger MISC_LOGGER = - Logger.getLogger(MISC_LOGGER_NAME); + System.getLogger(MISC_LOGGER_NAME); } diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java index 350eb0218a0..b6a5b53b703 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.WeakHashMap; -import java.util.logging.Level; +import java.lang.System.Logger.Level; // JMX import import javax.management.Attribute; @@ -258,19 +258,16 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { /* Load the appropriate class. */ if (withDefaultLoaderRepository) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "createMBean", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ClassName = " + className + ", ObjectName = " + name); } theClass = instantiator.findClassWithDefaultLoaderRepository(className); } else if (loaderName == null) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "createMBean", "ClassName = " + className + + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + "ClassName = " + className + ", ObjectName = " + name + ", Loader name = null"); } @@ -279,10 +276,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { } else { loaderName = nonDefaultDomain(loaderName); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "createMBean", "ClassName = " + className + + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + "ClassName = " + className + ", ObjectName = " + name + ", Loader name = " + loaderName); } @@ -633,10 +629,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { name = nonDefaultDomain(name); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "getAttribute", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "Attribute = " + attribute + ", ObjectName = " + name); } @@ -670,10 +664,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { name = nonDefaultDomain(name); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "getAttributes", "ObjectName = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name); } final DynamicMBean instance = getMBean(name); @@ -732,10 +724,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { name = nonDefaultDomain(name); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "setAttribute", "ObjectName = " + name + + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name + ", Attribute = " + attribute.getName()); } @@ -910,10 +900,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { name = nonDefaultDomain(name); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "registerMBean", "ObjectName = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + "ObjectName = " + name); } ObjectName logicalName = preRegister(mbean, server, name); @@ -1023,14 +1012,14 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { if (mbean instanceof MBeanRegistration) ((MBeanRegistration) mbean).postRegister(registrationDone); } catch (RuntimeException e) { - MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+ + MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+ "]: " + "Exception thrown by postRegister: " + "rethrowing <"+e+">, but keeping the MBean registered"); throw new RuntimeMBeanException(e, "RuntimeException thrown in postRegister method: "+ "rethrowing <"+e+">, but keeping the MBean registered"); } catch (Error er) { - MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+ + MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+ "]: " + "Error thrown by postRegister: " + "rethrowing <"+er+">, but keeping the MBean registered"); throw new RuntimeErrorException(er, @@ -1053,7 +1042,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { try { moi.postDeregister(); } catch (RuntimeException e) { - MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+ + MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+ "]: " + "Exception thrown by postDeregister: " + "rethrowing <"+e+">, although the MBean is succesfully " + "unregistered"); @@ -1062,7 +1051,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { "rethrowing <"+e+ ">, although the MBean is sucessfully unregistered"); } catch (Error er) { - MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+ + MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+ "]: " + "Error thrown by postDeregister: " + "rethrowing <"+er+">, although the MBean is succesfully " + "unregistered"); @@ -1087,10 +1076,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { } DynamicMBean obj = repository.retrieve(name); if (obj == null) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "getMBean", name + " : Found no object"); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + name + " : Found no object"); } throw new InstanceNotFoundException(name.toString()); } @@ -1176,10 +1164,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { // ------------------------------ // ------------------------------ - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "addNotificationListener", "ObjectName = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name); } DynamicMBean instance = getMBean(name); @@ -1226,10 +1212,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { // ---------------- // Add a listener on an MBean // ---------------- - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "addNotificationListener", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name + ", Listener = " + listener); } server.addNotificationListener(name,(NotificationListener) resource, @@ -1255,10 +1239,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener instance = getListener(listener); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "removeNotificationListener", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance); @@ -1272,10 +1254,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { NotificationListener instance = getListener(listener); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "removeNotificationListener", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance, filter, handback); @@ -1313,10 +1293,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { boolean removeAll) throws InstanceNotFoundException, ListenerNotFoundException { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "removeNotificationListener", "ObjectName = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name); } DynamicMBean instance = getMBean(name); @@ -1421,10 +1399,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { return classNameClass.isAssignableFrom(resourceClass); } catch (Exception x) { /* Could be SecurityException or ClassNotFoundException */ - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - DefaultMBeanServerInterceptor.class.getName(), - "isInstanceOf", "Exception calling isInstanceOf", x); + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, + "Exception calling isInstanceOf", x); } return false; } @@ -1489,10 +1466,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { MBeanServerNotification notif = new MBeanServerNotification( NotifType,MBeanServerDelegate.DELEGATE_NAME,0,name); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "sendNotification", NotifType + " " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, NotifType + " " + name); } delegate.sendNotification(notif); @@ -1594,10 +1569,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { try { return getClassName(mbean); } catch (Exception e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - DefaultMBeanServerInterceptor.class.getName(), - "safeGetClassName", + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, "Exception getting MBean class name", e); } return null; @@ -1885,10 +1858,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { // --------------------- // Send create event // --------------------- - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "addObject", "Send create notification of object " + + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + "Send create notification of object " + logicalName.getCanonicalName()); } @@ -1926,10 +1898,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { // --------------------- // Send deletion event // --------------------- - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - DefaultMBeanServerInterceptor.class.getName(), - "unregisterMBean", "Send delete notification of object " + + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + "Send delete notification of object " + logicalName.getCanonicalName()); } diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java index 1d76705e581..9cc7721659d 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import java.util.Arrays; import java.util.Hashtable; import java.util.List; import java.util.Map; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.MBeanPermission; import javax.management.ObjectName; @@ -148,10 +148,9 @@ final class ClassLoaderRepositorySupport // from javax.management.loading.DefaultLoaderRepository public final Class loadClassWithout(ClassLoader without, String className) throws ClassNotFoundException { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - ClassLoaderRepositorySupport.class.getName(), - "loadClassWithout", className + " without " + without); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + className + " without " + without); } // without is null => just behave as loadClass @@ -172,10 +171,9 @@ final class ClassLoaderRepositorySupport public final Class loadClassBefore(ClassLoader stop, String className) throws ClassNotFoundException { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - ClassLoaderRepositorySupport.class.getName(), - "loadClassBefore", className + " before " + stop); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + className + " before " + stop); } if (stop == null) @@ -206,10 +204,8 @@ final class ClassLoaderRepositorySupport continue; if (cl == stop) break; - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - ClassLoaderRepositorySupport.class.getName(), - "loadClass", "Trying loader = " + cl); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "Trying loader = " + cl); } /* We used to have a special case for "instanceof MLet" here, where we invoked the method @@ -239,10 +235,9 @@ final class ClassLoaderRepositorySupport // List excluded = search.get(className); if ((excluded!= null) && (excluded.contains(aloader))) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - ClassLoaderRepositorySupport.class.getName(), - "startValidSearch", "Already requested loader = " + + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, + "Already requested loader = " + aloader + " class = " + className); } throw new ClassNotFoundException(className); @@ -255,10 +250,8 @@ final class ClassLoaderRepositorySupport search.put(className, excluded); } excluded.add(aloader); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - ClassLoaderRepositorySupport.class.getName(), - "startValidSearch", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "loader = " + aloader + " class = " + className); } } @@ -271,10 +264,8 @@ final class ClassLoaderRepositorySupport List excluded = search.get(className); if (excluded != null) { excluded.remove(aloader); - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, - ClassLoaderRepositorySupport.class.getName(), - "stopValidSearch", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "loader = " + aloader + " class = " + className); } } diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java index b7f1444acaf..4e63cb36d0e 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; import java.util.List; import java.util.Set; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Attribute; import javax.management.AttributeList; @@ -1229,16 +1229,14 @@ public final class JmxMBeanServer } }); } catch (SecurityException e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - JmxMBeanServer.class.getName(), "initialize", + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, "Unexpected security exception occurred", e); } throw e; } catch (Exception e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - JmxMBeanServer.class.getName(), "initialize", + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, "Unexpected exception occurred", e); } throw new diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java index 38740044f76..2a99a3b9b0a 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ import java.security.Permissions; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import java.util.Map; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.InstanceNotFoundException; import javax.management.MBeanException; @@ -186,19 +186,15 @@ public class MBeanInstantiator { } } } catch (ClassNotFoundException e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - MBeanInstantiator.class.getName(), - "findSignatureClasses", + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, "The parameter class could not be found", e); } throw new ReflectionException(e, "The parameter class could not be found"); } catch (RuntimeException e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - MBeanInstantiator.class.getName(), - "findSignatureClasses", + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, "Unexpected exception", e); } throw e; @@ -696,19 +692,15 @@ public class MBeanInstantiator { tab[i] = Class.forName(signature[i], false, aLoader); } } catch (ClassNotFoundException e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - MBeanInstantiator.class.getName(), - "findSignatureClasses", + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, "The parameter class could not be found", e); } throw new ReflectionException(e, "The parameter class could not be found"); } catch (RuntimeException e) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - MBeanInstantiator.class.getName(), - "findSignatureClasses", + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { + MBEANSERVER_LOGGER.log(Level.DEBUG, "Unexpected exception", e); } throw e; diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanServerDelegateImpl.java b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanServerDelegateImpl.java index f4fdc827be5..fc9a4ad10f4 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanServerDelegateImpl.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/MBeanServerDelegateImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ */ package com.sun.jmx.mbeanserver; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Attribute; import javax.management.AttributeList; @@ -244,10 +244,8 @@ final class MBeanServerDelegateImpl } catch (Exception x) { // Skip the attribute that couldn't be obtained. // - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { - MBEANSERVER_LOGGER.logp(Level.FINEST, - MBeanServerDelegateImpl.class.getName(), - "getAttributes", + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "Attribute " + attn[i] + " not found"); } } diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java index 4693a44ae11..bbab04fc880 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import java.util.Map; import java.util.Set; import javax.management.DynamicMBean; @@ -264,7 +264,7 @@ public class Repository { context.unregistered(); } catch (Exception x) { // shouldn't come here... - MBEANSERVER_LOGGER.log(Level.FINE, + MBEANSERVER_LOGGER.log(Level.DEBUG, "Unexpected exception while unregistering "+name, x); } @@ -385,9 +385,8 @@ public class Repository { final RegistrationContext context) throws InstanceAlreadyExistsException { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(), - "addMBean", "name = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name); } // Extract the domain name. @@ -456,9 +455,8 @@ public class Repository { * false otherwise. */ public boolean contains(ObjectName name) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(), - "contains", " name = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name); } lock.readLock().lock(); try { @@ -478,9 +476,8 @@ public class Repository { * null otherwise. */ public DynamicMBean retrieve(ObjectName name) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(), - "retrieve", "name = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name); } // Calls internal retrieve method to get the named object @@ -609,9 +606,8 @@ public class Repository { throws InstanceNotFoundException { // Debugging stuff - if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { - MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(), - "remove", "name = " + name); + if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { + MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name); } // Extract domain name. diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLogger.java b/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLogger.java index a0f7a4c1c8e..91d8cbc9de3 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLogger.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/util/ClassLogger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,222 +25,188 @@ package com.sun.jmx.remote.util; -import java.util.logging.Logger; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; +import java.util.ResourceBundle; -public class ClassLogger { +public class ClassLogger implements System.Logger { - private static final boolean ok; private final String className; private final Logger logger; - static { - /* We attempt to work even if we are running in J2SE 1.3, where - there is no java.util.logging. The technique we use here is - not strictly portable, but it does work with Sun's J2SE 1.3 - at least. This is just a best effort: the Right Thing is for - people to use at least J2SE 1.4. */ - boolean loaded = false; - try { - Class c = java.util.logging.Logger.class; - loaded = true; - } catch (Error e) { - // OK. - // java.util.logger package is not available in this jvm. - } - ok = loaded; - } - public ClassLogger(String subsystem, String className) { - if (ok) - logger = Logger.getLogger(subsystem); - else - logger = null; + logger = System.getLogger(subsystem); this.className = className; } public final boolean traceOn() { - return finerOn(); + return logger.isLoggable(Level.TRACE); } public final boolean debugOn() { - return finestOn(); + return logger.isLoggable(Level.DEBUG); } public final boolean warningOn() { - return ok && logger.isLoggable(java.util.logging.Level.WARNING); + return logger.isLoggable(Level.WARNING); } public final boolean infoOn() { - return ok && logger.isLoggable(java.util.logging.Level.INFO); + return logger.isLoggable(Level.INFO); } public final boolean configOn() { - return ok && logger.isLoggable(java.util.logging.Level.CONFIG); + return logger.isLoggable(Level.DEBUG); } public final boolean fineOn() { - return ok && logger.isLoggable(java.util.logging.Level.FINE); + return logger.isLoggable(Level.DEBUG); } public final boolean finerOn() { - return ok && logger.isLoggable(java.util.logging.Level.FINER); + return logger.isLoggable(Level.TRACE); } public final boolean finestOn() { - return ok && logger.isLoggable(java.util.logging.Level.FINEST); + return logger.isLoggable(Level.TRACE); } public final void debug(String func, String msg) { - finest(func,msg); + logger.log(Level.DEBUG, msg); } public final void debug(String func, Throwable t) { - finest(func,t); + logger.log(Level.DEBUG, className + "::" + func, t); } public final void debug(String func, String msg, Throwable t) { - finest(func,msg,t); + logger.log(Level.DEBUG, msg, t); } public final void trace(String func, String msg) { - finer(func,msg); + logger.log(Level.TRACE, msg); } public final void trace(String func, Throwable t) { - finer(func,t); + logger.log(Level.TRACE, className + "::" + func, t); } public final void trace(String func, String msg, Throwable t) { - finer(func,msg,t); + logger.log(Level.TRACE, msg, t); } public final void error(String func, String msg) { - severe(func,msg); + logger.log(Level.ERROR, msg); } public final void error(String func, Throwable t) { - severe(func,t); + logger.log(Level.ERROR, className + "::" + func, t); } public final void error(String func, String msg, Throwable t) { - severe(func,msg,t); + logger.log(Level.ERROR, msg, t); } public final void finest(String func, String msg) { - if (ok) - logger.logp(java.util.logging.Level.FINEST, className, func, msg); + logger.log(Level.TRACE, msg); } public final void finest(String func, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.FINEST, className, func, - t.toString(), t); + logger.log(Level.TRACE, className + "::" + func, t); } public final void finest(String func, String msg, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.FINEST, className, func, msg, - t); + logger.log(Level.TRACE, msg, t); } public final void finer(String func, String msg) { - if (ok) - logger.logp(java.util.logging.Level.FINER, className, func, msg); + logger.log(Level.TRACE, msg); } public final void finer(String func, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.FINER, className, func, - t.toString(), t); + logger.log(Level.TRACE, className + "::" + func, t); } public final void finer(String func, String msg, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.FINER, className, func, msg,t); + logger.log(Level.DEBUG, msg, t); } public final void fine(String func, String msg) { - if (ok) - logger.logp(java.util.logging.Level.FINE, className, func, msg); + logger.log(Level.DEBUG, msg); } public final void fine(String func, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.FINE, className, func, - t.toString(), t); + logger.log(Level.DEBUG, className + "::" + func, t); } public final void fine(String func, String msg, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.FINE, className, func, msg, - t); + logger.log(Level.DEBUG, msg, t); } public final void config(String func, String msg) { - if (ok) - logger.logp(java.util.logging.Level.CONFIG, className, func, msg); + logger.log(Level.DEBUG, msg); } public final void config(String func, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.CONFIG, className, func, - t.toString(), t); + logger.log(Level.DEBUG, className + "::" + func, t); } public final void config(String func, String msg, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.CONFIG, className, func, msg, - t); + logger.log(Level.DEBUG, msg, t); } public final void info(String func, String msg) { - if (ok) - logger.logp(java.util.logging.Level.INFO, className, func, msg); + logger.log(Level.INFO, msg); } public final void info(String func, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.INFO, className, func, - t.toString(), t); + logger.log(Level.INFO, className + "::" + func, t); } public final void info(String func, String msg, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.INFO, className, func, msg, - t); + logger.log(Level.INFO, msg, t); } public final void warning(String func, String msg) { - if (ok) - logger.logp(java.util.logging.Level.WARNING, className, func, msg); + logger.log(Level.WARNING, msg); } public final void warning(String func, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.WARNING, className, func, - t.toString(), t); + logger.log(Level.WARNING, className + "::" + func, t); } public final void warning(String func, String msg, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.WARNING, className, func, msg, - t); + logger.log(Level.WARNING, msg, t); } public final void severe(String func, String msg) { - if (ok) - logger.logp(java.util.logging.Level.SEVERE, className, func, msg); + logger.log(Level.ERROR, msg); } public final void severe(String func, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.SEVERE, className, func, - t.toString(), t); + logger.log(Level.ERROR, className + "::" + func, t); } public final void severe(String func, String msg, Throwable t) { - if (ok) - logger.logp(java.util.logging.Level.SEVERE, className, func, msg, - t); + logger.log(Level.ERROR, msg, t); } + + public final String getName() { + return logger.getName(); + } + + public final boolean isLoggable(Level level) { + return logger.isLoggable(level); + } + + public final void log(Level level, ResourceBundle bundle, String msg, + Throwable thrown) { + logger.log(level, bundle, msg, thrown); + } + + public final void log(Level level, ResourceBundle bundle, String format, + Object... params) { + logger.log(level, bundle, format, params); + } + } diff --git a/jdk/src/java.management/share/classes/javax/management/MBeanServerDelegate.java b/jdk/src/java.management/share/classes/javax/management/MBeanServerDelegate.java index b9db8a1b7f0..443e9a7a06c 100644 --- a/jdk/src/java.management/share/classes/javax/management/MBeanServerDelegate.java +++ b/jdk/src/java.management/share/classes/javax/management/MBeanServerDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package javax.management; +import java.lang.System.Logger.Level; import com.sun.jmx.defaults.JmxProperties; import com.sun.jmx.defaults.ServiceName; import com.sun.jmx.mbeanserver.Util; @@ -84,7 +85,8 @@ public class MBeanServerDelegate implements MBeanServerDelegateMBean, try { localHost = java.net.InetAddress.getLocalHost().getHostName(); } catch (java.net.UnknownHostException e) { - JmxProperties.MISC_LOGGER.finest("Can't get local host name, " + + JmxProperties.MISC_LOGGER.log(Level.TRACE, + "Can't get local host name, " + "using \"localhost\" instead. Cause is: "+e); localHost = "localhost"; } diff --git a/jdk/src/java.management/share/classes/javax/management/MBeanServerFactory.java b/jdk/src/java.management/share/classes/javax/management/MBeanServerFactory.java index 756811a072f..1d4fc131169 100644 --- a/jdk/src/java.management/share/classes/javax/management/MBeanServerFactory.java +++ b/jdk/src/java.management/share/classes/javax/management/MBeanServerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ import com.sun.jmx.mbeanserver.GetPropertyAction; import java.security.AccessController; import java.security.Permission; import java.util.ArrayList; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.loading.ClassLoaderRepository; import sun.reflect.misc.ReflectUtil; @@ -399,7 +399,7 @@ public class MBeanServerFactory { return (String) mbs.getAttribute(MBeanServerDelegate.DELEGATE_NAME, "MBeanServerId"); } catch (JMException e) { - JmxProperties.MISC_LOGGER.finest( + JmxProperties.MISC_LOGGER.log(Level.TRACE, "Ignoring exception while getting MBeanServerId: "+e); return null; } @@ -421,9 +421,7 @@ public class MBeanServerFactory { private static synchronized void removeMBeanServer(MBeanServer mbs) { boolean removed = mBeanServerList.remove(mbs); if (!removed) { - MBEANSERVER_LOGGER.logp(Level.FINER, - MBeanServerFactory.class.getName(), - "removeMBeanServer(MBeanServer)", + MBEANSERVER_LOGGER.log(Level.TRACE, "MBeanServer was not in list!"); throw new IllegalArgumentException("MBeanServer was not in list!"); } @@ -504,15 +502,12 @@ public class MBeanServerFactory { throw new JMRuntimeException(msg, x); } } catch (RuntimeException x) { - if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) { + if (MBEANSERVER_LOGGER.isLoggable(Level.DEBUG)) { StringBuilder strb = new StringBuilder() .append("Failed to instantiate MBeanServerBuilder: ").append(x) .append("\n\t\tCheck the value of the ") .append(JMX_INITIAL_BUILDER).append(" property."); - MBEANSERVER_LOGGER.logp(Level.FINEST, - MBeanServerFactory.class.getName(), - "checkMBeanServerBuilder", - strb.toString()); + MBEANSERVER_LOGGER.log(Level.DEBUG, strb::toString); } throw x; } diff --git a/jdk/src/java.management/share/classes/javax/management/StandardMBean.java b/jdk/src/java.management/share/classes/javax/management/StandardMBean.java index 42affd8b96e..e908836b0b8 100644 --- a/jdk/src/java.management/share/classes/javax/management/StandardMBean.java +++ b/jdk/src/java.management/share/classes/javax/management/StandardMBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.openmbean.OpenMBeanAttributeInfo; import javax.management.openmbean.OpenMBeanAttributeInfoSupport; import javax.management.openmbean.OpenMBeanConstructorInfo; @@ -432,16 +432,14 @@ public class StandardMBean implements DynamicMBean, MBeanRegistration { final MBeanInfo cached = getCachedMBeanInfo(); if (cached != null) return cached; } catch (RuntimeException x) { - if (MISC_LOGGER.isLoggable(Level.FINEST)) { - MISC_LOGGER.logp(Level.FINEST, - MBeanServerFactory.class.getName(), "getMBeanInfo", + if (MISC_LOGGER.isLoggable(Level.DEBUG)) { + MISC_LOGGER.log(Level.DEBUG, "Failed to get cached MBeanInfo", x); } } - if (MISC_LOGGER.isLoggable(Level.FINER)) { - MISC_LOGGER.logp(Level.FINER, - MBeanServerFactory.class.getName(), "getMBeanInfo", + if (MISC_LOGGER.isLoggable(Level.TRACE)) { + MISC_LOGGER.log(Level.TRACE, "Building MBeanInfo for " + getImplementationClass().getName()); } @@ -465,9 +463,8 @@ public class StandardMBean implements DynamicMBean, MBeanRegistration { try { cacheMBeanInfo(nmbi); } catch (RuntimeException x) { - if (MISC_LOGGER.isLoggable(Level.FINEST)) { - MISC_LOGGER.logp(Level.FINEST, - MBeanServerFactory.class.getName(), "getMBeanInfo", + if (MISC_LOGGER.isLoggable(Level.DEBUG)) { + MISC_LOGGER.log(Level.DEBUG, "Failed to cache MBeanInfo", x); } } diff --git a/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java b/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java index 5cf3ad143b2..b7cee08cbe7 100644 --- a/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java +++ b/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ package javax.management.loading; import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER; import java.util.Iterator; import java.util.List; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; @@ -71,9 +71,7 @@ public class DefaultLoaderRepository { */ public static Class loadClass(String className) throws ClassNotFoundException { - MBEANSERVER_LOGGER.logp(Level.FINEST, - DefaultLoaderRepository.class.getName(), - "loadClass", className); + MBEANSERVER_LOGGER.log(Level.TRACE, className); return load(null, className); } @@ -96,9 +94,7 @@ public class DefaultLoaderRepository { public static Class loadClassWithout(ClassLoader loader, String className) throws ClassNotFoundException { - MBEANSERVER_LOGGER.logp(Level.FINEST, - DefaultLoaderRepository.class.getName(), - "loadClassWithout", className); + MBEANSERVER_LOGGER.log(Level.TRACE, className); return load(loader, className); } diff --git a/jdk/src/java.management/share/classes/javax/management/loading/MLet.java b/jdk/src/java.management/share/classes/javax/management/loading/MLet.java index 1a3fb18527b..500b773abf7 100644 --- a/jdk/src/java.management/share/classes/javax/management/loading/MLet.java +++ b/jdk/src/java.management/share/classes/javax/management/loading/MLet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; @@ -412,9 +412,8 @@ public class MLet extends java.net.URLClassLoader if (!Arrays.asList(getURLs()).contains(ur)) super.addURL(ur); } catch (MalformedURLException e) { - if (MLET_LOGGER.isLoggable(Level.FINEST)) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "addUrl", "Malformed URL: " + url, e); + if (MLET_LOGGER.isLoggable(Level.DEBUG)) { + MLET_LOGGER.log(Level.DEBUG, "Malformed URL: " + url, e); } throw new ServiceNotFoundException("The specified URL is malformed"); @@ -481,23 +480,19 @@ public class MLet extends java.net.URLClassLoader public Set getMBeansFromURL(String url) throws ServiceNotFoundException { - String mth = "getMBeansFromURL"; - if (server == null) { throw new IllegalStateException("This MLet MBean is not " + "registered with an MBeanServer."); } // Parse arguments if (url == null) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), - mth, "URL is null"); + MLET_LOGGER.log(Level.TRACE, "URL is null"); throw new ServiceNotFoundException("The specified URL is null"); } else { url = url.replace(File.separatorChar,'/'); } - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), - mth, ""); + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, ""); } // Parse URL @@ -508,7 +503,7 @@ public class MLet extends java.net.URLClassLoader final String msg = "Problems while parsing URL [" + url + "], got exception [" + e.toString() + "]"; - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg); + MLET_LOGGER.log(Level.TRACE, msg); throw EnvHelp.initCause(new ServiceNotFoundException(msg), e); } @@ -516,7 +511,7 @@ public class MLet extends java.net.URLClassLoader if (mletList.size() == 0) { final String msg = "File " + url + " not found or MLET tag not defined in file"; - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg); + MLET_LOGGER.log(Level.TRACE, msg); throw new ServiceNotFoundException(msg); } @@ -538,7 +533,7 @@ public class MLet extends java.net.URLClassLoader URL documentBase = elmt.getDocumentBase(); // Display debug information - if (MLET_LOGGER.isLoggable(Level.FINER)) { + if (MLET_LOGGER.isLoggable(Level.TRACE)) { final StringBuilder strb = new StringBuilder() .append("\n\tMLET TAG = ").append(elmt.getAttributes()) .append("\n\tCODEBASE = ").append(codebase) @@ -548,16 +543,15 @@ public class MLet extends java.net.URLClassLoader .append("\n\tNAME = ").append(name) .append("\n\tVERSION = ").append(version) .append("\n\tDOCUMENT URL = ").append(documentBase); - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), - mth, strb.toString()); + MLET_LOGGER.log(Level.TRACE, strb::toString); } // Load classes from JAR files StringTokenizer st = new StringTokenizer(jarFiles, ",", false); while (st.hasMoreTokens()) { String tok = st.nextToken().trim(); - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "Load archive for codebase <" + codebase + ">, file <" + tok + ">"); } @@ -570,8 +564,8 @@ public class MLet extends java.net.URLClassLoader try { codebase = check(version, codebase, tok, elmt); } catch (Exception ex) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - mth, "Got unexpected exception", ex); + MLET_LOGGER.log(Level.DEBUG, + "Got unexpected exception", ex); mbeans.add(ex); continue; } @@ -599,7 +593,7 @@ public class MLet extends java.net.URLClassLoader final String msg = "CODE and OBJECT parameters cannot be specified at the " + "same time in tag MLET"; - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg); + MLET_LOGGER.log(Level.TRACE, msg); mbeans.add(new Error(msg)); continue; } @@ -607,7 +601,7 @@ public class MLet extends java.net.URLClassLoader final String msg = "Either CODE or OBJECT parameter must be specified in " + "tag MLET"; - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, msg); + MLET_LOGGER.log(Level.TRACE, msg); mbeans.add(new Error(msg)); continue; } @@ -635,7 +629,7 @@ public class MLet extends java.net.URLClassLoader Object[] parms = objectPars.toArray(); String[] signature = new String[signat.size()]; signat.toArray(signature); - if (MLET_LOGGER.isLoggable(Level.FINEST)) { + if (MLET_LOGGER.isLoggable(Level.TRACE)) { final StringBuilder strb = new StringBuilder(); for (int i = 0; i < signature.length; i++) { strb.append("\n\tSignature = ") @@ -643,9 +637,7 @@ public class MLet extends java.net.URLClassLoader .append("\t\nParams = ") .append(parms[i]); } - MLET_LOGGER.logp(Level.FINEST, - MLet.class.getName(), - mth, strb.toString()); + MLET_LOGGER.log(Level.TRACE, strb::toString); } if (name == null) { objInst = @@ -668,53 +660,46 @@ public class MLet extends java.net.URLClassLoader objInst = new ObjectInstance(name, o.getClass().getName()); } } catch (ReflectionException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, - "ReflectionException", ex); + MLET_LOGGER.log(Level.TRACE, "ReflectionException", ex); mbeans.add(ex); continue; } catch (InstanceAlreadyExistsException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + MLET_LOGGER.log(Level.TRACE, "InstanceAlreadyExistsException", ex); mbeans.add(ex); continue; } catch (MBeanRegistrationException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, - "MBeanRegistrationException", ex); + MLET_LOGGER.log(Level.TRACE, "MBeanRegistrationException", ex); mbeans.add(ex); continue; } catch (MBeanException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, - "MBeanException", ex); + MLET_LOGGER.log(Level.TRACE, "MBeanException", ex); mbeans.add(ex); continue; } catch (NotCompliantMBeanException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + MLET_LOGGER.log(Level.TRACE, "NotCompliantMBeanException", ex); mbeans.add(ex); continue; } catch (InstanceNotFoundException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + MLET_LOGGER.log(Level.TRACE, "InstanceNotFoundException", ex); mbeans.add(ex); continue; } catch (IOException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, - "IOException", ex); + MLET_LOGGER.log(Level.TRACE, "IOException", ex); mbeans.add(ex); continue; } catch (SecurityException ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, - "SecurityException", ex); + MLET_LOGGER.log(Level.TRACE, "SecurityException", ex); mbeans.add(ex); continue; } catch (Exception ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, - "Exception", ex); + MLET_LOGGER.log(Level.TRACE, "Exception", ex); mbeans.add(ex); continue; } catch (Error ex) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, - "Error", ex); + MLET_LOGGER.log(Level.TRACE, "Error", ex); mbeans.add(ex); continue; } @@ -937,20 +922,18 @@ public class MLet extends java.net.URLClassLoader Class findClass(String name, ClassLoaderRepository clr) throws ClassNotFoundException { Class c = null; - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), "findClass", name); + MLET_LOGGER.log(Level.TRACE, name); // Try looking in the JAR: try { c = super.findClass(name); - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), - "findClass", + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "Class " + name + " loaded through MLet classloader"); } } catch (ClassNotFoundException e) { // Drop through - if (MLET_LOGGER.isLoggable(Level.FINEST)) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "findClass", + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "Class " + name + " not found locally"); } } @@ -959,32 +942,28 @@ public class MLet extends java.net.URLClassLoader // Try the classloader repository: // try { - if (MLET_LOGGER.isLoggable(Level.FINEST)) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "findClass", + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "Class " + name + " : looking in CLR"); } c = clr.loadClassBefore(this, name); // The loadClassBefore method never returns null. // If the class is not found we get an exception. - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), - "findClass", + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "Class " + name + " loaded through " + "the default classloader repository"); } } catch (ClassNotFoundException e) { // Drop through - if (MLET_LOGGER.isLoggable(Level.FINEST)) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "findClass", + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "Class " + name + " not found in CLR"); } } } if (c == null) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "findClass", "Failed to load class " + name); + MLET_LOGGER.log(Level.TRACE, "Failed to load class " + name); throw new ClassNotFoundException(name); } return c; @@ -1041,8 +1020,8 @@ public class MLet extends java.net.URLClassLoader // // See if the native library is accessible as a resource through the JAR file. // - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "Search " + libname + " in all JAR files"); } @@ -1051,14 +1030,14 @@ public class MLet extends java.net.URLClassLoader // for "foo" on Solaris SPARC 5.7 we try to load "libfoo.so" // from the JAR file. // - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "loadLibraryAsResource(" + nativelibname + ")"); } abs_path = loadLibraryAsResource(nativelibname); if (abs_path != null) { - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, nativelibname + " loaded, absolute path = " + abs_path); } return abs_path; @@ -1073,15 +1052,15 @@ public class MLet extends java.net.URLClassLoader removeSpace(System.getProperty("os.arch")) + File.separator + removeSpace(System.getProperty("os.version")) + File.separator + "lib" + File.separator + nativelibname; - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, "loadLibraryAsResource(" + nativelibname + ")"); } abs_path = loadLibraryAsResource(nativelibname); if (abs_path != null) { - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, nativelibname + " loaded, absolute path = " + abs_path); } return abs_path; @@ -1091,10 +1070,10 @@ public class MLet extends java.net.URLClassLoader // All paths exhausted, library not found in JAR file. // - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, libname + " not found in any JAR file"); - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), mth, + MLET_LOGGER.log(Level.TRACE, "Search " + libname + " along the path " + "specified as the java.library.path property"); } @@ -1127,8 +1106,8 @@ public class MLet extends java.net.URLClassLoader if (tmpDirFile == null) return null; return tmpDirFile.getAbsolutePath(); } catch (Exception x) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "getTmpDir", "Failed to determine system temporary dir"); + MLET_LOGGER.log(Level.DEBUG, + "Failed to determine system temporary dir"); return null; } finally { // Cleanup ... @@ -1136,12 +1115,12 @@ public class MLet extends java.net.URLClassLoader try { boolean deleted = tmpFile.delete(); if (!deleted) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "getTmpDir", "Failed to delete temp file"); + MLET_LOGGER.log(Level.DEBUG, + "Failed to delete temp file"); } } catch (Exception x) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "getTmpDir", "Failed to delete temporary file", x); + MLET_LOGGER.log(Level.DEBUG, + "Failed to delete temporary file", x); } } } @@ -1183,8 +1162,7 @@ public class MLet extends java.net.URLClassLoader } } } catch (Exception e) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "loadLibraryAsResource", + MLET_LOGGER.log(Level.DEBUG, "Failed to load library : " + libname, e); return null; } @@ -1248,9 +1226,8 @@ public class MLet extends java.net.URLClassLoader if (filename != null) { filename = filename.replace(File.separatorChar,'/'); } - if (MLET_LOGGER.isLoggable(Level.FINER)) { - MLET_LOGGER.logp(Level.FINER, MLet.class.getName(), - "loadSerializedObject", codebase.toString() + filename); + if (MLET_LOGGER.isLoggable(Level.TRACE)) { + MLET_LOGGER.log(Level.TRACE, codebase.toString() + filename); } InputStream is = getResourceAsStream(filename); if (is != null) { @@ -1260,24 +1237,21 @@ public class MLet extends java.net.URLClassLoader ois.close(); return serObject; } catch (IOException e) { - if (MLET_LOGGER.isLoggable(Level.FINEST)) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "loadSerializedObject", + if (MLET_LOGGER.isLoggable(Level.DEBUG)) { + MLET_LOGGER.log(Level.DEBUG, "Exception while deserializing " + filename, e); } throw e; } catch (ClassNotFoundException e) { - if (MLET_LOGGER.isLoggable(Level.FINEST)) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "loadSerializedObject", + if (MLET_LOGGER.isLoggable(Level.DEBUG)) { + MLET_LOGGER.log(Level.DEBUG, "Exception while deserializing " + filename, e); } throw e; } } else { - if (MLET_LOGGER.isLoggable(Level.FINEST)) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "loadSerializedObject", "Error: File " + filename + + if (MLET_LOGGER.isLoggable(Level.DEBUG)) { + MLET_LOGGER.log(Level.DEBUG, "Error: File " + filename + " containing serialized object not found"); } throw new Error("File " + filename + " containing serialized object not found"); @@ -1300,8 +1274,7 @@ public class MLet extends java.net.URLClassLoader return(cons.newInstance(oo)); } catch (Exception e) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "constructParameter", "Got unexpected exception", e); + MLET_LOGGER.log(Level.DEBUG, "Got unexpected exception", e); } } if (type.compareTo("java.lang.Boolean") == 0) 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 ff261f39235..a067a281403 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, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.logging.Level; +import java.lang.System.Logger.Level; /** * This class is used for parsing URLs. @@ -153,7 +153,6 @@ class MLetParser { * Scan an html file for {@literal } tags. */ public List parse(URL url) throws IOException { - String mth = "parse"; // Warning Messages String requiresTypeWarning = " tag requires type parameter."; String requiresValueWarning = " tag requires value parameter."; @@ -204,33 +203,25 @@ class MLetParser { Map t = scanTag(in); String att = t.get("type"); if (att == null) { - MLET_LOGGER.logp(Level.FINER, - MLetParser.class.getName(), - mth, requiresTypeWarning); + MLET_LOGGER.log(Level.TRACE, requiresTypeWarning); throw new IOException(requiresTypeWarning); } else { if (atts != null) { types.add(att); } else { - MLET_LOGGER.logp(Level.FINER, - MLetParser.class.getName(), - mth, paramOutsideWarning); + MLET_LOGGER.log(Level.TRACE, paramOutsideWarning); throw new IOException(paramOutsideWarning); } } String val = t.get("value"); if (val == null) { - MLET_LOGGER.logp(Level.FINER, - MLetParser.class.getName(), - mth, requiresValueWarning); + MLET_LOGGER.log(Level.TRACE, requiresValueWarning); throw new IOException(requiresValueWarning); } else { if (atts != null) { values.add(val); } else { - MLET_LOGGER.logp(Level.FINER, - MLetParser.class.getName(), - mth, paramOutsideWarning); + MLET_LOGGER.log(Level.TRACE, paramOutsideWarning); throw new IOException(paramOutsideWarning); } } @@ -238,15 +229,11 @@ class MLetParser { if (nm.equalsIgnoreCase(tag)) { atts = scanTag(in); if (atts.get("code") == null && atts.get("object") == null) { - MLET_LOGGER.logp(Level.FINER, - MLetParser.class.getName(), - mth, requiresCodeWarning); + MLET_LOGGER.log(Level.TRACE, requiresCodeWarning); throw new IOException(requiresCodeWarning); } if (atts.get("archive") == null) { - MLET_LOGGER.logp(Level.FINER, - MLetParser.class.getName(), - mth, requiresJarsWarning); + MLET_LOGGER.log(Level.TRACE, requiresJarsWarning); throw new IOException(requiresJarsWarning); } } 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 8499be40cc8..769a6159d1d 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, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ import java.util.Set; import java.util.SortedMap; import java.util.StringTokenizer; import java.util.TreeMap; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Descriptor; import javax.management.ImmutableDescriptor; @@ -164,10 +164,8 @@ public class DescriptorSupport * (the method {@link #isValid isValid} returns false) */ public DescriptorSupport() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "DescriptorSupport()" , "Constructor"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Constructor"); } init(null); } @@ -188,17 +186,14 @@ public class DescriptorSupport */ public DescriptorSupport(int initNumFields) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(initNumFields = " + initNumFields + ")", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(initNumFields = " + initNumFields + ") " + "Constructor"); } if (initNumFields <= 0) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(initNumFields)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Illegal arguments: initNumFields <= 0"); } final String msg = @@ -219,10 +214,9 @@ public class DescriptorSupport * fields, an empty Descriptor will be created. */ public DescriptorSupport(DescriptorSupport inDescr) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(Descriptor)", "Constructor"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(Descriptor) Constructor"); } if (inDescr == null) init(null); @@ -268,16 +262,14 @@ public class DescriptorSupport XMLParseException { /* parse an XML-formatted string and populate internal * structure with it */ - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(String = '" + inStr + "')", "Constructor"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(String = '" + inStr + "') Constructor"); } if (inStr == null) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(String = null)", "Illegal arguments"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(String = null) Illegal arguments"); } final String msg = "String in parameter is null"; final RuntimeException iae = new IllegalArgumentException(msg); @@ -350,10 +342,9 @@ public class DescriptorSupport } } } // while tokens - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(XMLString)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(XMLString) Exit"); } } @@ -380,19 +371,17 @@ public class DescriptorSupport */ public DescriptorSupport(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(fieldNames,fieldObjects)", "Constructor"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(fieldNames,fieldObjects) Constructor"); } if ((fieldNames == null) || (fieldValues == null) || (fieldNames.length != fieldValues.length)) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(fieldNames,fieldObjects)", - "Illegal arguments"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(fieldNames,fieldObjects)" + + " Illegal arguments"); } final String msg = @@ -408,10 +397,9 @@ public class DescriptorSupport // the fieldName and fieldValue will be validated in setField. setField(fieldNames[i], fieldValues[i]); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(fieldNames,fieldObjects)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(fieldNames,fieldObjects) Exit"); } } @@ -444,10 +432,9 @@ public class DescriptorSupport */ public DescriptorSupport(String... fields) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(String... fields)", "Constructor"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(String... fields) Constructor"); } init(null); if (( fields == null ) || ( fields.length == 0)) @@ -462,10 +449,9 @@ public class DescriptorSupport int eq_separator = fields[i].indexOf('='); if (eq_separator < 0) { // illegal if no = or is first character - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(String... fields)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(String... fields) " + "Illegal arguments: field does not have " + "'=' as a name and value separator"); } @@ -482,10 +468,9 @@ public class DescriptorSupport } if (fieldName.equals("")) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(String... fields)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(String... fields) " + "Illegal arguments: fieldName is empty"); } @@ -496,10 +481,9 @@ public class DescriptorSupport setField(fieldName,fieldValue); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "Descriptor(String... fields)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor(String... fields) Exit"); } } @@ -517,10 +501,8 @@ public class DescriptorSupport throws RuntimeOperationsException { if ((fieldName == null) || (fieldName.equals(""))) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldValue(String fieldName)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Illegal arguments: null field name"); } final String msg = "Fieldname requested is null"; @@ -528,10 +510,9 @@ public class DescriptorSupport throw new RuntimeOperationsException(iae, msg); } Object retValue = descriptorMap.get(fieldName); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldValue(String fieldName = " + fieldName + ")", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "getFieldValue(String fieldName = " + fieldName + ") " + "Returns '" + retValue + "'"); } return(retValue); @@ -542,10 +523,8 @@ public class DescriptorSupport // field name cannot be null or empty if ((fieldName == null) || (fieldName.equals(""))) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "setField(fieldName,fieldValue)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Illegal arguments: null or empty field name"); } @@ -555,10 +534,8 @@ public class DescriptorSupport } if (!validateField(fieldName, fieldValue)) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "setField(fieldName,fieldValue)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Illegal arguments"); } @@ -568,10 +545,8 @@ public class DescriptorSupport throw new RuntimeOperationsException(iae, msg); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "setField(fieldName,fieldValue)", "Entry: setting '" + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry: setting '" + fieldName + "' to '" + fieldValue + "'"); } @@ -582,10 +557,8 @@ public class DescriptorSupport } public synchronized String[] getFields() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFields()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } int numberOfEntries = descriptorMap.size(); @@ -594,20 +567,18 @@ public class DescriptorSupport int i = 0; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFields()", "Returning " + numberOfEntries + " fields"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Returning " + numberOfEntries + " fields"); } for (Iterator> iter = returnedSet.iterator(); iter.hasNext(); i++) { Map.Entry currElement = iter.next(); if (currElement == null) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFields()", "Element is null"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Element is null"); } } else { Object currValue = currElement.getValue(); @@ -626,20 +597,16 @@ public class DescriptorSupport } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFields()", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return responseFields; } public synchronized String[] getFieldNames() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldNames()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } int numberOfEntries = descriptorMap.size(); @@ -648,10 +615,8 @@ public class DescriptorSupport int i = 0; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldNames()", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Returning " + numberOfEntries + " fields"); } @@ -660,20 +625,16 @@ public class DescriptorSupport Map.Entry currElement = iter.next(); if (( currElement == null ) || (currElement.getKey() == null)) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldNames()", "Field is null"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Field is null"); } } else { responseFields[i] = currElement.getKey().toString(); } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldNames()", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return responseFields; @@ -681,10 +642,8 @@ public class DescriptorSupport public synchronized Object[] getFieldValues(String... fieldNames) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldValues(String... fieldNames)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } // if fieldNames == null return all values // if fieldNames is String[0] return no values @@ -695,10 +654,8 @@ public class DescriptorSupport int i = 0; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldValues(String... fieldNames)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Returning " + numberOfEntries + " fields"); } @@ -715,10 +672,8 @@ public class DescriptorSupport } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "getFieldValues(String... fieldNames)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return responseFields; @@ -728,18 +683,14 @@ public class DescriptorSupport Object[] fieldValues) throws RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "setFields(fieldNames,fieldValues)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if ((fieldNames == null) || (fieldValues == null) || (fieldNames.length != fieldValues.length)) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "setFields(fieldNames,fieldValues)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Illegal arguments"); } @@ -750,10 +701,8 @@ public class DescriptorSupport for (int i=0; i < fieldNames.length; i++) { if (( fieldNames[i] == null) || (fieldNames[i].equals(""))) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "setFields(fieldNames,fieldValues)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Null field name encountered at element " + i); } final String msg = "fieldNames is null or invalid"; @@ -762,10 +711,8 @@ public class DescriptorSupport } setField(fieldNames[i], fieldValues[i]); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "setFields(fieldNames,fieldValues)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -779,10 +726,8 @@ public class DescriptorSupport @Override public synchronized Object clone() throws RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "clone()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new DescriptorSupport(this)); } @@ -898,20 +843,17 @@ public class DescriptorSupport */ public synchronized boolean isValid() throws RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "isValid()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } // verify that the descriptor is valid, by iterating over each field... Set> returnedSet = descriptorMap.entrySet(); if (returnedSet == null) { // null descriptor, not valid - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "isValid()", "Returns false (null set)"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "isValid() Returns false (null set)"); } return false; } @@ -934,10 +876,8 @@ public class DescriptorSupport (currElement.getValue()).toString())) { continue; } else { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "isValid()", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Field " + currElement.getKey() + "=" + currElement.getValue() + " is not valid"); } @@ -948,10 +888,9 @@ public class DescriptorSupport } // fell through, all fields OK - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "isValid()", "Returns true"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "isValid() Returns true"); } return true; } @@ -1287,28 +1226,23 @@ public class DescriptorSupport */ @Override public synchronized String toString() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "toString()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } String respStr = ""; String[] fields = getFields(); if ((fields == null) || (fields.length == 0)) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "toString()", "Empty Descriptor"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Empty Descriptor"); } return respStr; } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "toString()", "Printing " + fields.length + " fields"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Printing " + fields.length + " fields"); } for (int i=0; i < fields.length; i++) { @@ -1319,10 +1253,8 @@ public class DescriptorSupport } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { - MODELMBEAN_LOGGER.logp(Level.FINEST, - DescriptorSupport.class.getName(), - "toString()", "Exit returning " + respStr); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit returning " + respStr); } return respStr; diff --git a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java index b1a68c42722..447273ed9be 100644 --- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java +++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.lang.reflect.Method; import java.security.AccessController; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Descriptor; import javax.management.DescriptorKey; @@ -201,12 +201,11 @@ public class ModelMBeanAttributeInfo throws javax.management.IntrospectionException { super(name, description, getter, setter); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanAttributeInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanAttributeInfo(" + - "String,String,Method,Method)", - "Entry", name); + "String,String,Method,Method) " + + "Entry " + name); } attrDescriptor = validDescriptor(null); @@ -251,12 +250,11 @@ public class ModelMBeanAttributeInfo super(name, description, getter, setter); // put getter and setter methods in operations list - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanAttributeInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanAttributeInfo(" + - "String,String,Method,Method,Descriptor)", - "Entry", name); + "String,String,Method,Method,Descriptor) " + + "Entry " + name); } attrDescriptor = validDescriptor(descriptor); } @@ -282,8 +280,8 @@ public class ModelMBeanAttributeInfo super(name, type, description, isReadable, isWritable, isIs); // create default descriptor - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, ModelMBeanAttributeInfo.class.getName(), "ModelMBeanAttributeInfo(" + "String,String,String,boolean,boolean,boolean)", @@ -321,12 +319,11 @@ public class ModelMBeanAttributeInfo Descriptor descriptor) { super(name, type, description, isReadable, isWritable, isIs); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanAttributeInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanAttributeInfo(String,String,String," + - "boolean,boolean,boolean,Descriptor)", - "Entry", name); + "boolean,boolean,boolean,Descriptor)" + + "Entry " + name); } attrDescriptor = validDescriptor(descriptor); } @@ -347,10 +344,9 @@ public class ModelMBeanAttributeInfo inInfo.isReadable(), inInfo.isWritable(), inInfo.isIs()); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanAttributeInfo.class.getName(), - "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo) " + "Entry"); } Descriptor newDesc = inInfo.getDescriptor(); @@ -368,10 +364,8 @@ public class ModelMBeanAttributeInfo */ public Descriptor getDescriptor() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanAttributeInfo.class.getName(), - "getDescriptor()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (attrDescriptor == null) { attrDescriptor = validDescriptor(null); @@ -411,10 +405,8 @@ public class ModelMBeanAttributeInfo @Override public Object clone() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanAttributeInfo.class.getName(), - "clone()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanAttributeInfo(this)); } @@ -454,7 +446,7 @@ public class ModelMBeanAttributeInfo boolean defaulted = (in == null); if (defaulted) { clone = new DescriptorSupport(); - MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); + MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new."); } else { clone = (Descriptor) in.clone(); } @@ -462,15 +454,15 @@ public class ModelMBeanAttributeInfo //Setting defaults. if (defaulted && clone.getFieldValue("name")==null) { clone.setField("name", this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName()); } if (defaulted && clone.getFieldValue("descriptorType")==null) { clone.setField("descriptorType", "attribute"); - MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"attribute\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"attribute\""); } if (clone.getFieldValue("displayName") == null) { clone.setField("displayName",this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName()); } //Checking validity diff --git a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java index 24f6b12091f..9bec078f6f3 100644 --- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java +++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.lang.reflect.Constructor; import java.security.AccessController; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Descriptor; import javax.management.DescriptorAccess; @@ -164,10 +164,9 @@ public class ModelMBeanConstructorInfo Constructor constructorMethod) { super(description, constructorMethod); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), - "ModelMBeanConstructorInfo(String,Constructor)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "ModelMBeanConstructorInfo(String,Constructor) " + "Entry"); } consDescriptor = validDescriptor(null); @@ -209,11 +208,10 @@ public class ModelMBeanConstructorInfo super(description, constructorMethod); // put getter and setter methods in constructors list - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanConstructorInfo(" + - "String,Constructor,Descriptor)", "Entry"); + "String,Constructor,Descriptor) Entry"); } consDescriptor = validDescriptor(descriptor); } @@ -232,11 +230,10 @@ public class ModelMBeanConstructorInfo super(name, description, signature); // create default descriptor - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanConstructorInfo(" + - "String,String,MBeanParameterInfo[])", "Entry"); + "String,String,MBeanParameterInfo[]) Entry"); } consDescriptor = validDescriptor(null); } @@ -265,11 +262,10 @@ public class ModelMBeanConstructorInfo Descriptor descriptor) { super(name, description, signature); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanConstructorInfo(" + - "String,String,MBeanParameterInfo[],Descriptor)", + "String,String,MBeanParameterInfo[],Descriptor) " + "Entry"); } consDescriptor = validDescriptor(descriptor); @@ -284,11 +280,10 @@ public class ModelMBeanConstructorInfo ModelMBeanConstructorInfo(ModelMBeanConstructorInfo old) { super(old.getName(), old.getDescription(), old.getSignature()); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanConstructorInfo(" + - "ModelMBeanConstructorInfo)", "Entry"); + "ModelMBeanConstructorInfo) Entry"); } consDescriptor = validDescriptor(consDescriptor); } @@ -300,10 +295,8 @@ public class ModelMBeanConstructorInfo @Override public Object clone () { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), - "clone()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanConstructorInfo(this)) ; } @@ -321,10 +314,8 @@ public class ModelMBeanConstructorInfo @Override public Descriptor getDescriptor() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), - "getDescriptor()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (consDescriptor == null){ consDescriptor = validDescriptor(null); @@ -356,10 +347,8 @@ public class ModelMBeanConstructorInfo */ public void setDescriptor(Descriptor inDescriptor) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), - "setDescriptor()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } consDescriptor = validDescriptor(inDescriptor); } @@ -370,10 +359,8 @@ public class ModelMBeanConstructorInfo @Override public String toString() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanConstructorInfo.class.getName(), - "toString()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } String retStr = "ModelMBeanConstructorInfo: " + this.getName() + @@ -408,7 +395,7 @@ public class ModelMBeanConstructorInfo boolean defaulted = (in == null); if (defaulted) { clone = new DescriptorSupport(); - MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); + MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new."); } else { clone = (Descriptor) in.clone(); } @@ -416,19 +403,19 @@ public class ModelMBeanConstructorInfo //Setting defaults. if (defaulted && clone.getFieldValue("name")==null) { clone.setField("name", this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName()); } if (defaulted && clone.getFieldValue("descriptorType")==null) { clone.setField("descriptorType", "operation"); - MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"operation\""); } if (clone.getFieldValue("displayName") == null) { clone.setField("displayName",this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName()); } if (clone.getFieldValue("role") == null) { clone.setField("role","constructor"); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor role field to \"constructor\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor role field to \"constructor\""); } //Checking validity diff --git a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java index 4adcbf1273c..b5ae6ca08b9 100644 --- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java +++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.security.AccessController; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Descriptor; import javax.management.MBeanAttributeInfo; @@ -231,19 +231,16 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { modelMBeanDescriptor = validDescriptor(mbeandescriptor); } catch (MBeanException mbe) { modelMBeanDescriptor = validDescriptor(null); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "ModelMBeanInfo(ModelMBeanInfo)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "ModelMBeanInfo(ModelMBeanInfo) " + "Could not get a valid modelMBeanDescriptor, " + "setting a default Descriptor"); } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "ModelMBeanInfo(ModelMBeanInfo)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -330,12 +327,11 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { modelMBeanOperations = operations; modelMBeanNotifications = notifications; modelMBeanDescriptor = validDescriptor(mbeandescriptor); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanInfoSupport(String,String,ModelMBeanAttributeInfo[]," + "ModelMBeanConstructorInfo[],ModelMBeanOperationInfo[]," + - "ModelMBeanNotificationInfo[],Descriptor)", + "ModelMBeanNotificationInfo[],Descriptor) " + "Exit"); } } @@ -367,10 +363,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public Descriptor[] getDescriptors(String inDescriptorType) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getDescriptors(String)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if ((inDescriptorType == null) || (inDescriptorType.equals(""))) { @@ -474,10 +468,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { " the descriptors of the MBean"; throw new RuntimeOperationsException(iae,msg); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getDescriptors(String)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return retList; @@ -486,10 +478,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public void setDescriptors(Descriptor[] inDescriptors) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setDescriptors(Descriptor[])", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inDescriptors==null) { // throw RuntimeOperationsException - invalid descriptor @@ -504,10 +494,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { for (int j=0; j < inDescriptors.length; j++) { setDescriptor(inDescriptors[j],null); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setDescriptors(Descriptor[])", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -530,10 +518,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public Descriptor getDescriptor(String inDescriptorName) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getDescriptor(String)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(getDescriptor(inDescriptorName, null)); } @@ -606,10 +592,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { throws MBeanException, RuntimeOperationsException { final String excMsg = "Exception occurred trying to set the descriptors of the MBean"; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setDescriptor(Descriptor,String)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inDescriptor==null) { @@ -621,10 +605,9 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { (String) inDescriptor.getFieldValue("descriptorType"); if (inDescriptorType == null) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setDescriptor(Descriptor,String)", - "descriptorType null in both String parameter and Descriptor, defaulting to "+ MMB); + MODELMBEAN_LOGGER.log(Level.TRACE, + "descriptorType null in both String parameter " + + "and Descriptor, defaulting to "+ MMB); inDescriptorType = MMB; } } @@ -632,10 +615,9 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { String inDescriptorName = (String) inDescriptor.getFieldValue("name"); if (inDescriptorName == null) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setDescriptor(Descriptor,String)", - "descriptor name null, defaulting to "+ this.getClassName()); + MODELMBEAN_LOGGER.log(Level.TRACE, + "descriptor name null, defaulting to " + + this.getClassName()); inDescriptorName = this.getClassName(); } boolean found = false; @@ -653,17 +635,14 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { ModelMBeanAttributeInfo mmbai = (ModelMBeanAttributeInfo) attrList[i]; mmbai.setDescriptor(inDescriptor); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { StringBuilder strb = new StringBuilder() .append("Setting descriptor to ").append(inDescriptor) .append("\t\n local: AttributeInfo descriptor is ") .append(mmbai.getDescriptor()) .append("\t\n modelMBeanInfo: AttributeInfo descriptor is ") .append(this.getDescriptor(inDescriptorName,"attribute")); - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setDescriptor(Descriptor,String)", - strb.toString()); + MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString); } } } @@ -720,10 +699,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { "; name=" + inDescriptorName); throw new RuntimeOperationsException(iae, excMsg); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setDescriptor(Descriptor,String)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -732,10 +709,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public ModelMBeanAttributeInfo getAttribute(String inName) throws MBeanException, RuntimeOperationsException { ModelMBeanAttributeInfo retInfo = null; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getAttribute(String)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inName == null) { throw new RuntimeOperationsException( @@ -748,7 +723,7 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { if (attrList != null) numAttrs = attrList.length; for (int i=0; (i < numAttrs) && (retInfo == null); i++) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { final StringBuilder strb = new StringBuilder() .append("\t\n this.getAttributes() MBeanAttributeInfo Array ") .append(i).append(":") @@ -756,18 +731,14 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { .append("\t\n this.modelMBeanAttributes MBeanAttributeInfo Array ") .append(i).append(":") .append(((ModelMBeanAttributeInfo)modelMBeanAttributes[i]).getDescriptor()); - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getAttribute(String)", strb.toString()); + MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString); } if (inName.equals(attrList[i].getName())) { retInfo = ((ModelMBeanAttributeInfo)attrList[i].clone()); } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getAttribute(String)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return retInfo; @@ -778,10 +749,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public ModelMBeanOperationInfo getOperation(String inName) throws MBeanException, RuntimeOperationsException { ModelMBeanOperationInfo retInfo = null; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getOperation(String)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inName == null) { throw new RuntimeOperationsException( @@ -798,10 +767,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { retInfo = ((ModelMBeanOperationInfo) operList[i].clone()); } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getOperation(String)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return retInfo; @@ -824,10 +791,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public ModelMBeanConstructorInfo getConstructor(String inName) throws MBeanException, RuntimeOperationsException { ModelMBeanConstructorInfo retInfo = null; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getConstructor(String)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inName == null) { throw new RuntimeOperationsException( @@ -844,10 +809,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { retInfo = ((ModelMBeanConstructorInfo) consList[i].clone()); } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getConstructor(String)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return retInfo; @@ -857,10 +820,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public ModelMBeanNotificationInfo getNotification(String inName) throws MBeanException, RuntimeOperationsException { ModelMBeanNotificationInfo retInfo = null; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getNotification(String)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inName == null) { throw new RuntimeOperationsException( @@ -877,10 +838,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone()); } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getNotification(String)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return retInfo; @@ -901,19 +860,15 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { } private Descriptor getMBeanDescriptorNoException() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getMBeanDescriptorNoException()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (modelMBeanDescriptor == null) modelMBeanDescriptor = validDescriptor(null); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "getMBeanDescriptorNoException()", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit, returning: " + modelMBeanDescriptor); } return (Descriptor) modelMBeanDescriptor.clone(); @@ -921,10 +876,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { public void setMBeanDescriptor(Descriptor inMBeanDescriptor) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanInfoSupport.class.getName(), - "setMBeanDescriptor(Descriptor)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } modelMBeanDescriptor = validDescriptor(inMBeanDescriptor); } @@ -948,7 +901,7 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { boolean defaulted = (in == null); if (defaulted) { clone = new DescriptorSupport(); - MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); + MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new."); } else { clone = (Descriptor) in.clone(); } @@ -956,27 +909,27 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { //Setting defaults. if (defaulted && clone.getFieldValue("name")==null) { clone.setField("name", this.getClassName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getClassName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getClassName()); } if (defaulted && clone.getFieldValue("descriptorType")==null) { clone.setField("descriptorType", MMB); - MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"" + MMB + "\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"" + MMB + "\""); } if (clone.getFieldValue("displayName") == null) { clone.setField("displayName",this.getClassName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getClassName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getClassName()); } if (clone.getFieldValue("persistPolicy") == null) { clone.setField("persistPolicy","never"); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor persistPolicy to \"never\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor persistPolicy to \"never\""); } if (clone.getFieldValue("log") == null) { clone.setField("log","F"); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor \"log\" field to \"F\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor \"log\" field to \"F\""); } if (clone.getFieldValue("visibility") == null) { clone.setField("visibility","1"); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor visibility to 1"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor visibility to 1"); } //Checking validity diff --git a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java index a05d82d5e99..507ba1a34a6 100644 --- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java +++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.security.AccessController; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Descriptor; import javax.management.DescriptorAccess; @@ -199,10 +199,8 @@ public class ModelMBeanNotificationInfo String description, Descriptor descriptor) { super(notifTypes, name, description); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanNotificationInfo.class.getName(), - "ModelMBeanNotificationInfo", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } notificationDescriptor = validDescriptor(descriptor); } @@ -225,10 +223,8 @@ public class ModelMBeanNotificationInfo * duplicate of this ModelMBeanNotificationInfo. **/ public Object clone () { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanNotificationInfo.class.getName(), - "clone()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanNotificationInfo(this)); } @@ -243,18 +239,15 @@ public class ModelMBeanNotificationInfo * @see #setDescriptor **/ public Descriptor getDescriptor() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanNotificationInfo.class.getName(), - "getDescriptor()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (notificationDescriptor == null) { // Dead code. Should never happen. - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanNotificationInfo.class.getName(), - "getDescriptor()", "Descriptor value is null, " + + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Descriptor value is null, " + "setting descriptor to default values"); } notificationDescriptor = validDescriptor(null); @@ -281,10 +274,8 @@ public class ModelMBeanNotificationInfo * @see #getDescriptor **/ public void setDescriptor(Descriptor inDescriptor) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanNotificationInfo.class.getName(), - "setDescriptor(Descriptor)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } notificationDescriptor = validDescriptor(inDescriptor); } @@ -296,10 +287,8 @@ public class ModelMBeanNotificationInfo * @return a string describing this object. **/ public String toString() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanNotificationInfo.class.getName(), - "toString()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } final StringBuilder retStr = new StringBuilder(); @@ -342,7 +331,7 @@ public class ModelMBeanNotificationInfo boolean defaulted = (in == null); if (defaulted) { clone = new DescriptorSupport(); - MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); + MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new."); } else { clone = (Descriptor) in.clone(); } @@ -350,19 +339,19 @@ public class ModelMBeanNotificationInfo //Setting defaults. if (defaulted && clone.getFieldValue("name")==null) { clone.setField("name", this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName()); } if (defaulted && clone.getFieldValue("descriptorType")==null) { clone.setField("descriptorType", "notification"); - MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"notification\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"notification\""); } if (clone.getFieldValue("displayName") == null) { clone.setField("displayName",this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName()); } if (clone.getFieldValue("severity") == null) { clone.setField("severity", "6"); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor severity field to 6"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor severity field to 6"); } //Checking validity diff --git a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java index ba047efde93..a0541b678f3 100644 --- a/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java +++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.lang.reflect.Method; import java.security.AccessController; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Descriptor; import javax.management.DescriptorAccess; @@ -185,10 +185,9 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo { super(description, operationMethod); // create default descriptor - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), - "ModelMBeanOperationInfo(String,Method)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "ModelMBeanOperationInfo(String,Method) " + "Entry"); } operationDescriptor = validDescriptor(null); @@ -228,11 +227,10 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo { super(description, operationMethod); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), - "ModelMBeanOperationInfo(String,Method,Descriptor)", - "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "ModelMBeanOperationInfo(String,Method,Descriptor) " + + "Entry"); } operationDescriptor = validDescriptor(descriptor); } @@ -258,11 +256,10 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo super(name, description, signature, type, impact); // create default descriptor - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanOperationInfo(" + - "String,String,MBeanParameterInfo[],String,int)", + "String,String,MBeanParameterInfo[],String,int) " + "Entry"); } operationDescriptor = validDescriptor(null); @@ -302,11 +299,10 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo Descriptor descriptor) { super(name, description, signature, type, impact); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanOperationInfo(String,String," + - "MBeanParameterInfo[],String,int,Descriptor)", + "MBeanParameterInfo[],String,int,Descriptor) " + "Entry"); } operationDescriptor = validDescriptor(descriptor); @@ -327,10 +323,9 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo inInfo.getSignature(), inInfo.getReturnType(), inInfo.getImpact()); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), - "ModelMBeanOperationInfo(ModelMBeanOperationInfo)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "ModelMBeanOperationInfo(ModelMBeanOperationInfo)" + "Entry"); } Descriptor newDesc = inInfo.getDescriptor(); @@ -345,10 +340,8 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo public Object clone () { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), - "clone()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanOperationInfo(this)) ; } @@ -365,10 +358,8 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo public Descriptor getDescriptor() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), - "getDescriptor()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (operationDescriptor == null) { operationDescriptor = validDescriptor(null); @@ -396,10 +387,8 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo */ public void setDescriptor(Descriptor inDescriptor) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), - "setDescriptor(Descriptor)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } operationDescriptor = validDescriptor(inDescriptor); } @@ -410,10 +399,8 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo */ public String toString() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - ModelMBeanOperationInfo.class.getName(), - "toString()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } String retStr = "ModelMBeanOperationInfo: " + this.getName() + @@ -449,7 +436,7 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo boolean defaulted = (in == null); if (defaulted) { clone = new DescriptorSupport(); - MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); + MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new."); } else { clone = (Descriptor) in.clone(); } @@ -457,19 +444,19 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo //Setting defaults. if (defaulted && clone.getFieldValue("name")==null) { clone.setField("name", this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName()); } if (defaulted && clone.getFieldValue("descriptorType")==null) { clone.setField("descriptorType", "operation"); - MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"operation\""); } if (clone.getFieldValue("displayName") == null) { clone.setField("displayName",this.getName()); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName()); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName()); } if (clone.getFieldValue("role") == null) { clone.setField("role","operation"); - MODELMBEAN_LOGGER.finer("Defaulting Descriptor role field to \"operation\""); + MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor role field to \"operation\""); } //Checking validity diff --git a/jdk/src/java.management/share/classes/javax/management/modelmbean/RequiredModelMBean.java b/jdk/src/java.management/share/classes/javax/management/modelmbean/RequiredModelMBean.java index 9f50196219b..a757876c245 100644 --- a/jdk/src/java.management/share/classes/javax/management/modelmbean/RequiredModelMBean.java +++ b/jdk/src/java.management/share/classes/javax/management/modelmbean/RequiredModelMBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ import java.security.PrivilegedAction; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import java.util.Map; import java.util.Set; @@ -166,16 +166,12 @@ public class RequiredModelMBean **/ public RequiredModelMBean() throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "RequiredModelMBean()", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } modelMBeanInfo = createDefaultModelMBeanInfo(); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "RequiredModelMBean()", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -202,17 +198,13 @@ public class RequiredModelMBean public RequiredModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "RequiredModelMBean(MBeanInfo)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } setModelMBeanInfo(mbi); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "RequiredModelMBean(MBeanInfo)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -257,17 +249,13 @@ public class RequiredModelMBean public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setModelMBeanInfo(ModelMBeanInfo)","Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (mbi == null) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setModelMBeanInfo(ModelMBeanInfo)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanInfo is null: Raising exception."); } final RuntimeException x = new @@ -279,10 +267,8 @@ public class RequiredModelMBean } if (registered) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setModelMBeanInfo(ModelMBeanInfo)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "RequiredMBean is registered: Raising exception."); } final String exceptionText = @@ -293,32 +279,24 @@ public class RequiredModelMBean throw new RuntimeOperationsException(x,exceptionText); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setModelMBeanInfo(ModelMBeanInfo)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Setting ModelMBeanInfo to " + printModelMBeanInfo(mbi)); int noOfNotifications = 0; if (mbi.getNotifications() != null) { noOfNotifications = mbi.getNotifications().length; } - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setModelMBeanInfo(ModelMBeanInfo)", + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanInfo notifications has " + noOfNotifications + " elements"); } modelMBeanInfo = (ModelMBeanInfo)mbi.clone(); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setModelMBeanInfo(ModelMBeanInfo)","set mbeanInfo to: "+ + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "set mbeanInfo to: "+ printModelMBeanInfo(modelMBeanInfo)); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setModelMBeanInfo(ModelMBeanInfo)","Exit"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -346,37 +324,29 @@ public class RequiredModelMBean public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setManagedResource(Object,String)","Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } // check that the mr_type is supported by this JMXAgent // only "objectReference" is supported if ((mr_type == null) || (! mr_type.equalsIgnoreCase("objectReference"))) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setManagedResource(Object,String)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Managed Resource Type is not supported: " + mr_type); } throw new InvalidTargetObjectTypeException(mr_type); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setManagedResource(Object,String)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Managed Resource is valid"); } managedResource = mr; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setManagedResource(Object, String)", "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -482,11 +452,9 @@ public class RequiredModelMBean private Object resolveForCacheValue(Descriptor descr) throws MBeanException, RuntimeOperationsException { - final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER); - final String mth = "resolveForCacheValue(Descriptor)"; + final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth,"Entry"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } Object response = null; @@ -495,25 +463,22 @@ public class RequiredModelMBean if (descr == null) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "Input Descriptor is null"); } return response; } if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "descriptor is " + descr); + MODELMBEAN_LOGGER.log(Level.TRACE, + "descriptor is " + descr); } final Descriptor mmbDescr = modelMBeanInfo.getMBeanDescriptor(); if (mmbDescr == null) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth,"MBean Descriptor is null"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "MBean Descriptor is null"); } //return response; } @@ -538,9 +503,8 @@ public class RequiredModelMBean if (expTime != null) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth,"currencyTimeLimit: " + expTime); + MODELMBEAN_LOGGER.log(Level.TRACE, + "currencyTimeLimit: " + expTime); } // convert seconds to milliseconds for time comparison @@ -550,8 +514,7 @@ public class RequiredModelMBean returnCachedValue = false; resetValue = true; if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, currencyPeriod + ": never Cached"); } } else if (currencyPeriod == 0) { @@ -559,9 +522,7 @@ public class RequiredModelMBean returnCachedValue = true; resetValue = false; if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, - "always valid Cache"); + MODELMBEAN_LOGGER.log(Level.TRACE, "always valid Cache"); } } else { Object objtStamp = @@ -572,8 +533,7 @@ public class RequiredModelMBean else tStamp = null; if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "lastUpdatedTimeStamp: " + tStamp); } @@ -583,8 +543,7 @@ public class RequiredModelMBean long lastTime = Long.parseLong(tStamp); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "currencyPeriod:" + currencyPeriod + " lastUpdatedTimeStamp:" + lastTime); } @@ -595,8 +554,7 @@ public class RequiredModelMBean returnCachedValue = true; resetValue = false; if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, " timed valid Cache for " + now + " < " + (lastTime + currencyPeriod)); } @@ -604,16 +562,14 @@ public class RequiredModelMBean returnCachedValue = false; resetValue = true; if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "timed expired cache for " + now + " > " + (lastTime + currencyPeriod)); } } } if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "returnCachedValue:" + returnCachedValue + " resetValue: " + resetValue); } @@ -625,17 +581,15 @@ public class RequiredModelMBean response = currValue; /* need to cast string cached value to type */ if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "valid Cache value: " + currValue); } } else { response = null; if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth,"no Cached value"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "no Cached value"); } } } @@ -647,16 +601,14 @@ public class RequiredModelMBean response = null; modelMBeanInfo.setDescriptor(descr,null); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth,"reset cached value to null"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "reset cached value to null"); } } } if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth,"Exit"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return response; @@ -672,31 +624,24 @@ public class RequiredModelMBean **/ public MBeanInfo getMBeanInfo() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getMBeanInfo()","Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (modelMBeanInfo == null) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getMBeanInfo()","modelMBeanInfo is null"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "modelMBeanInfo is null"); } modelMBeanInfo = createDefaultModelMBeanInfo(); //return new ModelMBeanInfo(" ", "", null, null, null, null); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getMBeanInfo()","ModelMBeanInfo is " + + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanInfo is " + modelMBeanInfo.getClassName() + " for " + modelMBeanInfo.getDescription()); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getMBeanInfo()",printModelMBeanInfo(modelMBeanInfo)); + MODELMBEAN_LOGGER.log(Level.TRACE, + printModelMBeanInfo(modelMBeanInfo)); } return((MBeanInfo) modelMBeanInfo.clone()); @@ -705,10 +650,8 @@ public class RequiredModelMBean private String printModelMBeanInfo(ModelMBeanInfo info) { final StringBuilder retStr = new StringBuilder(); if (info == null) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "printModelMBeanInfo(ModelMBeanInfo)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanInfo to print is null, " + "printing local ModelMBeanInfo"); } @@ -909,12 +852,10 @@ public class RequiredModelMBean public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException { - final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER); - final String mth = "invoke(String, Object[], String[])"; + final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Entry"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (opName == null) { @@ -943,9 +884,8 @@ public class RequiredModelMBean opMethodName = opMethodName.substring(0,opSplitter); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "Finding operation " + opName + " as " + opMethodName); + MODELMBEAN_LOGGER.log(Level.TRACE, + "Finding operation " + opName + " as " + opMethodName); } ModelMBeanOperationInfo opInfo = @@ -965,10 +905,7 @@ public class RequiredModelMBean final Object cached = resolveForCacheValue(opDescr); if (cached != null) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, - "Returning cached value"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Returning cached value"); } return cached; } @@ -996,9 +933,8 @@ public class RequiredModelMBean final Object targetObjectField = opDescr.getFieldValue("targetObject"); if (tracing && targetObjectField != null) - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "Found target object in descriptor"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "Found target object in descriptor"); /* Now look for the method, either in RequiredModelMBean itself or in the target object. Set "method" and "targetObject" @@ -1013,9 +949,8 @@ public class RequiredModelMBean targetObject = this; else { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "looking for method in managedResource class"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "looking for method in managedResource class"); } if (targetObjectField != null) targetObject = targetObjectField; @@ -1071,18 +1006,15 @@ public class RequiredModelMBean } if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "found " + opMethodName + ", now invoking"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "found " + opMethodName + ", now invoking"); } final Object result = invokeMethod(opName, method, targetObject, opArgs); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "successfully invoked method"); + MODELMBEAN_LOGGER.log(Level.TRACE, "successfully invoked method"); } if (result != null) @@ -1095,12 +1027,11 @@ public class RequiredModelMBean String opMethodName, final String[] sig) throws ReflectionException { - final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER); + final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),"resolveMethod", - "resolving " + targetClass.getName() + "." + opMethodName); + MODELMBEAN_LOGGER.log(Level.TRACE, + "resolving " + targetClass.getName() + "." + opMethodName); } final Class[] argClasses; @@ -1119,8 +1050,7 @@ public class RequiredModelMBean public Void run() { for (int i = 0; i < sig.length; i++) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),"resolveMethod", + MODELMBEAN_LOGGER.log(Level.TRACE, "resolve type " + sig[i]); } argClasses[i] = (Class) primitiveClassMap.get(sig[i]); @@ -1131,9 +1061,7 @@ public class RequiredModelMBean Class.forName(sig[i], false, targetClassLoader); } catch (ClassNotFoundException e) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "resolveMethod", + MODELMBEAN_LOGGER.log(Level.TRACE, "class not found"); } final String msg = "Parameter class not found"; @@ -1182,12 +1110,10 @@ public class RequiredModelMBean Object targetObjectField, String opClassName, String[] sig) { - final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER); + final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "invoke(String, Object[], String[])", + MODELMBEAN_LOGGER.log(Level.TRACE, "looking for method in RequiredModelMBean class"); } @@ -1340,10 +1266,8 @@ public class RequiredModelMBean modelMBeanInfo.setDescriptor(opDescr, "operation"); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "invoke(String,Object[],Object[])", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "new descriptor is " + opDescr); } } @@ -1495,12 +1419,9 @@ public class RequiredModelMBean IllegalArgumentException("attributeName must not be null"), "Exception occurred trying to get attribute of a " + "RequiredModelMBean"); - final String mth = "getAttribute(String)"; - final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER); + final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "Entry with " + attrName); + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry with " + attrName); } /* Check attributeDescriptor for getMethod */ @@ -1530,16 +1451,14 @@ public class RequiredModelMBean /* return current cached value */ if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, - "*** cached value is " + response); + MODELMBEAN_LOGGER.log(Level.TRACE, + "*** cached value is " + response); } if (response == null) { /* no cached value, run getMethod */ if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "**** cached value is null - getting getMethod"); } String attrGetMethod = @@ -1548,9 +1467,8 @@ public class RequiredModelMBean if (attrGetMethod != null) { /* run method from operations descriptor */ if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "invoking a getMethod for " + attrName); + MODELMBEAN_LOGGER.log(Level.TRACE, + "invoking a getMethod for " + attrName); } Object getResponse = @@ -1560,9 +1478,8 @@ public class RequiredModelMBean if (getResponse != null) { // error/validity check return value here if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "got a non-null response " + + MODELMBEAN_LOGGER.log(Level.TRACE, + "got a non-null response " + "from getMethod\n"); } @@ -1585,9 +1502,7 @@ public class RequiredModelMBean if ((ctl != null) && !(ctl.equals("-1"))) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "setting cached value and " + "lastUpdatedTime in descriptor"); } @@ -1600,19 +1515,15 @@ public class RequiredModelMBean modelMBeanInfo.setDescriptor(attrDescr, "attribute"); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth,"new descriptor is " +attrDescr); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth,"AttributeInfo descriptor is " + + MODELMBEAN_LOGGER.log(Level.TRACE, + "new descriptor is " +attrDescr); + MODELMBEAN_LOGGER.log(Level.TRACE, + "AttributeInfo descriptor is " + attrInfo.getDescriptor()); final String attStr = modelMBeanInfo. getDescriptor(attrName,"attribute"). toString(); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "modelMBeanInfo: AttributeInfo " + "descriptor is " + attStr); } @@ -1620,8 +1531,7 @@ public class RequiredModelMBean } else { // response was invalid or really returned null if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "got a null response from getMethod\n"); } response = null; @@ -1635,8 +1545,7 @@ public class RequiredModelMBean response = attrDescr.getFieldValue("default"); } if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "could not find getMethod for " +attrName + ", returning descriptor " +qualifier + "value"); } @@ -1698,9 +1607,8 @@ public class RequiredModelMBean subtype = false; if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - mth, "Exception: ",e); + MODELMBEAN_LOGGER.log(Level.TRACE, + "Exception: ", e); } } if (!subtype) @@ -1708,9 +1616,8 @@ public class RequiredModelMBean } if (wrongType) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, - "Wrong response type '" + respType + "'"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "Wrong response type '" + respType + "'"); } // throw exception, didn't get // back right attribute type @@ -1724,8 +1631,7 @@ public class RequiredModelMBean } } else { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "getMethod failed " + attrName + " not in attributeDescriptor\n"); } @@ -1743,8 +1649,7 @@ public class RequiredModelMBean throw t; } catch (Exception e) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "getMethod failed with " + e.getMessage() + " exception type " + (e.getClass()).toString()); } @@ -1753,8 +1658,7 @@ public class RequiredModelMBean } if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Exit"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return response; @@ -1777,10 +1681,9 @@ public class RequiredModelMBean * @see #setAttributes(javax.management.AttributeList) */ public AttributeList getAttributes(String[] attrNames) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getAttributes(String[])","Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + RequiredModelMBean.class.getName(), "Entry"); } if (attrNames == null) @@ -1797,19 +1700,15 @@ public class RequiredModelMBean } catch (Exception e) { // eat exceptions because interface doesn't have an // exception on it - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getAttributes(String[])", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Failed to get \"" + attrNames[i] + "\": ", e); } } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getAttributes(String[])","Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return responseList; @@ -1894,11 +1793,9 @@ public class RequiredModelMBean public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { - final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.FINER); + final boolean tracing = MODELMBEAN_LOGGER.isLoggable(Level.TRACE); if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute()","Entry"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (attribute == null) @@ -1958,11 +1855,9 @@ public class RequiredModelMBean attrValue.getClass().getName() + " received."); } catch (ClassNotFoundException x) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute(Attribute)","Class " + - attrType + " for attribute " + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Class " + attrType + " for attribute " + attrName + " not found: ", x); } } @@ -1996,9 +1891,7 @@ public class RequiredModelMBean if (updateCache || updateDescriptor) { if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute(Attribute)", + MODELMBEAN_LOGGER.log(Level.TRACE, "setting cached value of " + attrName + " to " + attrValue); } @@ -2022,26 +1915,22 @@ public class RequiredModelMBean .append(attrInfo.getDescriptor()) .append(". AttributeInfo descriptor is ") .append(modelMBeanInfo.getDescriptor(attrName,"attribute")); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute(Attribute)",strb.toString()); + MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString); } } if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute(Attribute)","sending sendAttributeNotification"); + MODELMBEAN_LOGGER.log(Level.TRACE, + "sending sendAttributeNotification"); } sendAttributeChangeNotification(oldAttr,attribute); } else { // if descriptor ... else no descriptor if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute(Attribute)","setMethod failed "+attrName+ + MODELMBEAN_LOGGER.log(Level.TRACE, + "setMethod failed " + attrName + " not in attributeDescriptor\n"); } @@ -2051,9 +1940,7 @@ public class RequiredModelMBean } // else no descriptor if (tracing) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute(Attribute)", "Exit"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -2076,10 +1963,8 @@ public class RequiredModelMBean **/ public AttributeList setAttributes(AttributeList attributes) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "setAttribute(Attribute)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (attributes == null) @@ -2118,17 +2003,13 @@ public class RequiredModelMBean private synchronized void writeToLog(String logFileName, String logEntry) throws Exception { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "writeToLog(String, String)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Notification Logging to " + logFileName + ": " + logEntry); } if ((logFileName == null) || (logEntry == null)) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "writeToLog(String, String)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Bad input parameters, will not log this entry."); } return; @@ -2139,17 +2020,13 @@ public class RequiredModelMBean PrintStream logOut = new PrintStream(fos); logOut.println(logEntry); logOut.close(); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "writeToLog(String, String)","Successfully opened log " + - logFileName); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + "Successfully opened log " + logFileName); } } catch (Exception e) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "writeToLog(String, String)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exception " + e.toString() + " trying to write to the Notification log file " + logFileName); @@ -2184,11 +2061,8 @@ public class RequiredModelMBean NotificationFilter filter, Object handback) throws java.lang.IllegalArgumentException { - final String mth = "addNotificationListener(" + - "NotificationListener, NotificationFilter, Object)"; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (listener == null) @@ -2200,12 +2074,10 @@ public class RequiredModelMBean generalBroadcaster.addNotificationListener(listener, filter, handback); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "NotificationListener added"); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Exit"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -2227,10 +2099,8 @@ public class RequiredModelMBean throw new ListenerNotFoundException( "Notification listener is null"); - final String mth="removeNotificationListener(NotificationListener)"; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (generalBroadcaster == null) @@ -2239,9 +2109,8 @@ public class RequiredModelMBean generalBroadcaster.removeNotificationListener(listener); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -2255,12 +2124,8 @@ public class RequiredModelMBean throw new ListenerNotFoundException( "Notification listener is null"); - final String mth = "removeNotificationListener(" + - "NotificationListener, NotificationFilter, Object)"; - - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (generalBroadcaster == null) @@ -2271,19 +2136,16 @@ public class RequiredModelMBean generalBroadcaster.removeNotificationListener(listener,filter, handback); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } public void sendNotification(Notification ntfyObj) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "sendNotification(Notification)", "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (ntfyObj == null) @@ -2324,10 +2186,8 @@ public class RequiredModelMBean ntfyObj.getMessage() + " Severity = " + (String)ntfyDesc.getFieldValue("severity")); } catch (Exception e) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINE)) { - MODELMBEAN_LOGGER.logp(Level.FINE, - RequiredModelMBean.class.getName(), - "sendNotification(Notification)", + if (MODELMBEAN_LOGGER.isLoggable(Level.DEBUG)) { + MODELMBEAN_LOGGER.log(Level.DEBUG, "Failed to log " + ntfyObj.getType() + " notification: ", e); } @@ -2339,14 +2199,10 @@ public class RequiredModelMBean generalBroadcaster.sendNotification(ntfyObj); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "sendNotification(Notification)", + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "sendNotification sent provided notification object"); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "sendNotification(Notification)"," Exit"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -2354,10 +2210,8 @@ public class RequiredModelMBean public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "sendNotification(String)","Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (ntfyText == null) @@ -2370,13 +2224,9 @@ public class RequiredModelMBean Notification myNtfyObj = new Notification("jmx.modelmbean.generic", this, 1, ntfyText); sendNotification(myNtfyObj); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "sendNotification(String)","Notification sent"); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "sendNotification(String)","Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Notification sent"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -2456,10 +2306,8 @@ public class RequiredModelMBean * **/ public MBeanNotificationInfo[] getNotificationInfo() { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getNotificationInfo()","Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } // Using hasNotification() is not optimal, but shouldn't really @@ -2518,10 +2366,8 @@ public class RequiredModelMBean respInfo[offset+j] = currInfo[j]; } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), - "getNotificationInfo()","Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return respInfo; @@ -2535,12 +2381,8 @@ public class RequiredModelMBean Object inhandback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException { - final String mth="addAttributeChangeNotificationListener(" + - "NotificationListener, String, Object)"; - - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth,"Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inlistener == null) @@ -2581,24 +2423,21 @@ public class RequiredModelMBean } } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { Vector enabledAttrs = currFilter.getEnabledAttributes(); String s = (enabledAttrs.size() > 1) ? "[" + enabledAttrs.firstElement() + ", ...]" : enabledAttrs.toString(); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(), mth, + MODELMBEAN_LOGGER.log(Level.TRACE, "Set attribute change filter to " + s); } attributeBroadcaster.addNotificationListener(inlistener,currFilter, inhandback); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Notification listener added for " + inAttributeName); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth,"Exit"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } @@ -2609,12 +2448,9 @@ public class RequiredModelMBean if (inlistener == null) throw new ListenerNotFoundException("Notification listener is null"); - final String mth = "removeAttributeChangeNotificationListener(" + - "NotificationListener, String)"; - - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth,"Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, + RequiredModelMBean.class.getName(), "Entry"); } @@ -2648,21 +2484,17 @@ public class RequiredModelMBean attributeBroadcaster.removeNotificationListener(inlistener); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth,"Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException { - final String mth = "sendAttributeChangeNotification(" + - "AttributeChangeNotification)"; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth,"Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (ntfyObj == null) @@ -2678,9 +2510,8 @@ public class RequiredModelMBean if (oldv == null) oldv = "null"; if (newv == null) newv = "null"; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Sending AttributeChangeNotification with " + ntfyObj.getAttributeName() + ntfyObj.getAttributeType() + ntfyObj.getNewValue() + ntfyObj.getOldValue()); @@ -2718,9 +2549,8 @@ public class RequiredModelMBean " Old value = " + oldv + " New value = " + newv); } catch (Exception e) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINE)) { - MODELMBEAN_LOGGER.logp(Level.FINE, - RequiredModelMBean.class.getName(),mth, + if (MODELMBEAN_LOGGER.isLoggable(Level.DEBUG)) { + MODELMBEAN_LOGGER.log(Level.DEBUG, "Failed to log " + ntfyObj.getType() + " notification: ", e); } @@ -2744,9 +2574,8 @@ public class RequiredModelMBean " Old value = " + oldv + " New value = " + newv); } catch (Exception e) { - if (MODELMBEAN_LOGGER.isLoggable(Level.FINE)) { - MODELMBEAN_LOGGER.logp(Level.FINE, - RequiredModelMBean.class.getName(),mth, + if (MODELMBEAN_LOGGER.isLoggable(Level.DEBUG)) { + MODELMBEAN_LOGGER.log(Level.DEBUG, "Failed to log " + ntfyObj.getType() + " notification: ", e); } @@ -2768,25 +2597,17 @@ public class RequiredModelMBean generalBroadcaster.sendNotification(ntfyObj); } - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, - "sent notification"); - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, - "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "sent notification"); + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException { - final String mth = - "sendAttributeChangeNotification(Attribute, Attribute)"; - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, - "Entry"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } // do we really want to do this? @@ -2824,10 +2645,8 @@ public class RequiredModelMBean sendAttributeChangeNotification(myNtfyObj); - if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { - MODELMBEAN_LOGGER.logp(Level.FINER, - RequiredModelMBean.class.getName(),mth, - "Exit"); + if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { + MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } } diff --git a/jdk/src/java.management/share/classes/javax/management/monitor/CounterMonitor.java b/jdk/src/java.management/share/classes/javax/management/monitor/CounterMonitor.java index f025e98fdaf..4b5db2cb087 100644 --- a/jdk/src/java.management/share/classes/javax/management/monitor/CounterMonitor.java +++ b/jdk/src/java.management/share/classes/javax/management/monitor/CounterMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package javax.management.monitor; import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.ObjectName; import javax.management.MBeanNotificationInfo; import static javax.management.monitor.Monitor.NumericalType.*; @@ -228,8 +228,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean { */ public synchronized void start() { if (isActive()) { - MONITOR_LOGGER.logp(Level.FINER, CounterMonitor.class.getName(), - "start", "the monitor is already active"); + MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active"); return; } // Reset values. @@ -696,7 +695,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean { } } } else { - if (MONITOR_LOGGER.isLoggable(Level.FINER)) { + if (MONITOR_LOGGER.isLoggable(Level.TRACE)) { final StringBuilder strb = new StringBuilder() .append("The notification:") .append("\n\tNotification observed object = ") @@ -708,8 +707,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean { .append("\n\tNotification derived gauge = ") .append(o.getDerivedGauge()) .append("\nhas already been sent"); - MONITOR_LOGGER.logp(Level.FINER, CounterMonitor.class.getName(), - "updateNotifications", strb.toString()); + MONITOR_LOGGER.log(Level.TRACE, strb::toString); } } @@ -756,9 +754,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean { break; default: // Should never occur... - MONITOR_LOGGER.logp(Level.FINEST, - CounterMonitor.class.getName(), - "updateThreshold", + MONITOR_LOGGER.log(Level.TRACE, "the threshold type is invalid"); break; } @@ -819,8 +815,7 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean { case LONG: o.setDerivedGauge(Long.valueOf(derived)); break; default: // Should never occur... - MONITOR_LOGGER.logp(Level.FINEST, CounterMonitor.class.getName(), - "setDerivedGaugeWithDifference", + MONITOR_LOGGER.log(Level.TRACE, "the threshold type is invalid"); break; } diff --git a/jdk/src/java.management/share/classes/javax/management/monitor/GaugeMonitor.java b/jdk/src/java.management/share/classes/javax/management/monitor/GaugeMonitor.java index 926cc4e0a8d..9c050c6f408 100644 --- a/jdk/src/java.management/share/classes/javax/management/monitor/GaugeMonitor.java +++ b/jdk/src/java.management/share/classes/javax/management/monitor/GaugeMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package javax.management.monitor; import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.MBeanNotificationInfo; import javax.management.ObjectName; import static javax.management.monitor.Monitor.NumericalType.*; @@ -224,8 +224,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean { */ public synchronized void start() { if (isActive()) { - MONITOR_LOGGER.logp(Level.FINER, GaugeMonitor.class.getName(), - "start", "the monitor is already active"); + MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active"); return; } // Reset values. @@ -664,8 +663,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean { break; default: // Should never occur... - MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(), - "setDerivedGaugeWithDifference", + MONITOR_LOGGER.log(Level.TRACE, "the threshold type is invalid"); return; } @@ -698,8 +696,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean { return (greater.doubleValue() >= less.doubleValue()); default: // Should never occur... - MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(), - "isFirstGreaterThanLast", + MONITOR_LOGGER.log(Level.TRACE, "the threshold type is invalid"); return false; } @@ -733,8 +730,7 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean { } else { // Should never occur... - MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(), - "isFirstStrictlyGreaterThanLast", + MONITOR_LOGGER.log(Level.TRACE, "the threshold type is invalid"); return false; } diff --git a/jdk/src/java.management/share/classes/javax/management/monitor/Monitor.java b/jdk/src/java.management/share/classes/javax/management/monitor/Monitor.java index eb2a59ac14a..db4907b9e94 100644 --- a/jdk/src/java.management/share/classes/javax/management/monitor/Monitor.java +++ b/jdk/src/java.management/share/classes/javax/management/monitor/Monitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.AttributeNotFoundException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; @@ -205,13 +205,11 @@ public abstract class Monitor try { maximumPoolSizeTmp = Integer.parseInt(maximumPoolSizeStr); } catch (NumberFormatException e) { - if (MONITOR_LOGGER.isLoggable(Level.FINER)) { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "", + if (MONITOR_LOGGER.isLoggable(Level.TRACE)) { + MONITOR_LOGGER.log(Level.TRACE, "Wrong value for " + maximumPoolSizeSysProp + " system property", e); - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "", + MONITOR_LOGGER.log(Level.TRACE, maximumPoolSizeSysProp + " defaults to 10"); } maximumPoolSizeTmp = 10; @@ -391,8 +389,7 @@ public abstract class Monitor public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "preRegister(MBeanServer, ObjectName)", + MONITOR_LOGGER.log(Level.TRACE, "initialize the reference on the MBean server"); this.server = server; @@ -419,8 +416,7 @@ public abstract class Monitor */ public void preDeregister() throws Exception { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "preDeregister()", "stop the monitor"); + MONITOR_LOGGER.log(Level.TRACE, "stop the monitor"); // Stop the Monitor. // @@ -693,13 +689,11 @@ public abstract class Monitor * Starts the monitor. */ void doStart() { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "doStart()", "start the monitor"); + MONITOR_LOGGER.log(Level.TRACE, "start the monitor"); synchronized (this) { if (isActive()) { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "doStart()", "the monitor is already active"); + MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active"); return; } @@ -729,13 +723,11 @@ public abstract class Monitor * Stops the monitor. */ void doStop() { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "doStop()", "stop the monitor"); + MONITOR_LOGGER.log(Level.TRACE, "stop the monitor"); synchronized (this) { if (!isActive()) { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "doStop()", "the monitor is not active"); + MONITOR_LOGGER.log(Level.TRACE, "the monitor is not active"); return; } @@ -1089,9 +1081,8 @@ public abstract class Monitor if (!isActive()) return; - if (MONITOR_LOGGER.isLoggable(Level.FINER)) { - MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), - "sendNotification", "send notification: " + + if (MONITOR_LOGGER.isLoggable(Level.TRACE)) { + MONITOR_LOGGER.log(Level.TRACE, "send notification: " + "\n\tNotification observed object = " + object + "\n\tNotification observed attribute = " + observedAttribute + "\n\tNotification derived gauge = " + derGauge); @@ -1163,8 +1154,7 @@ public abstract class Monitor setAlreadyNotified( o, index, OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED, an); msg = "The observed attribute value is null."; - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); + MONITOR_LOGGER.log(Level.TRACE, msg); } } catch (NullPointerException np_ex) { if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) @@ -1176,10 +1166,8 @@ public abstract class Monitor "The monitor must be registered in the MBean " + "server or an MBeanServerConnection must be " + "explicitly supplied."; - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", np_ex.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, np_ex::toString); } } catch (InstanceNotFoundException inf_ex) { if (isAlreadyNotified(o, OBSERVED_OBJECT_ERROR_NOTIFIED)) @@ -1191,10 +1179,8 @@ public abstract class Monitor msg = "The observed object must be accessible in " + "the MBeanServerConnection."; - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", inf_ex.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, inf_ex::toString); } } catch (AttributeNotFoundException anf_ex) { if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED)) @@ -1206,10 +1192,8 @@ public abstract class Monitor msg = "The observed attribute must be accessible in " + "the observed object."; - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", anf_ex.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, anf_ex::toString); } } catch (MBeanException mb_ex) { if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) @@ -1218,10 +1202,8 @@ public abstract class Monitor notifType = RUNTIME_ERROR; setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); msg = mb_ex.getMessage() == null ? "" : mb_ex.getMessage(); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", mb_ex.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, mb_ex::toString); } } catch (ReflectionException ref_ex) { if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) { @@ -1230,10 +1212,8 @@ public abstract class Monitor notifType = RUNTIME_ERROR; setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); msg = ref_ex.getMessage() == null ? "" : ref_ex.getMessage(); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", ref_ex.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, ref_ex::toString); } } catch (IOException io_ex) { if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) @@ -1242,10 +1222,8 @@ public abstract class Monitor notifType = RUNTIME_ERROR; setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); msg = io_ex.getMessage() == null ? "" : io_ex.getMessage(); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", io_ex.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, io_ex::toString); } } catch (RuntimeException rt_ex) { if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) @@ -1254,10 +1232,8 @@ public abstract class Monitor notifType = RUNTIME_ERROR; setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); msg = rt_ex.getMessage() == null ? "" : rt_ex.getMessage(); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), - "monitor", rt_ex.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, rt_ex::toString); } } @@ -1297,10 +1273,8 @@ public abstract class Monitor msg = "The observed attribute value does not " + "implement the Comparable interface."; - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", e.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, e::toString); } } catch (AttributeNotFoundException e) { if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED)) @@ -1312,10 +1286,8 @@ public abstract class Monitor msg = "The observed attribute must be accessible in " + "the observed object."; - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", e.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, e::toString); } } catch (RuntimeException e) { if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) @@ -1325,10 +1297,8 @@ public abstract class Monitor setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); msg = e.getMessage() == null ? "" : e.getMessage(); - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", msg); - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", e.toString()); + MONITOR_LOGGER.log(Level.TRACE, msg); + MONITOR_LOGGER.log(Level.TRACE, e::toString); } } } @@ -1346,8 +1316,7 @@ public abstract class Monitor setAlreadyNotified(o, index, OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED, an); msg = "The observed attribute type is not valid."; - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", msg); + MONITOR_LOGGER.log(Level.TRACE, msg); } } } @@ -1363,8 +1332,7 @@ public abstract class Monitor setAlreadyNotified(o, index, THRESHOLD_ERROR_NOTIFIED, an); msg = "The threshold type is not valid."; - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", msg); + MONITOR_LOGGER.log(Level.TRACE, msg); } } } @@ -1381,8 +1349,7 @@ public abstract class Monitor notifType = RUNTIME_ERROR; setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); - MONITOR_LOGGER.logp(Level.FINEST, - Monitor.class.getName(), "monitor", msg); + MONITOR_LOGGER.log(Level.TRACE, msg); } } } diff --git a/jdk/src/java.management/share/classes/javax/management/monitor/StringMonitor.java b/jdk/src/java.management/share/classes/javax/management/monitor/StringMonitor.java index cf47fa16af3..f92e29673c0 100644 --- a/jdk/src/java.management/share/classes/javax/management/monitor/StringMonitor.java +++ b/jdk/src/java.management/share/classes/javax/management/monitor/StringMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package javax.management.monitor; import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.ObjectName; import javax.management.MBeanNotificationInfo; import static javax.management.monitor.MonitorNotification.*; @@ -151,8 +151,7 @@ public class StringMonitor extends Monitor implements StringMonitorMBean { */ public synchronized void start() { if (isActive()) { - MONITOR_LOGGER.logp(Level.FINER, StringMonitor.class.getName(), - "start", "the monitor is already active"); + MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active"); return; } // Reset values. diff --git a/jdk/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java b/jdk/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java index b3997964961..545712a0287 100644 --- a/jdk/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java +++ b/jdk/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ import javax.management.NotificationFilterSupport; import javax.management.ObjectName; import java.util.List; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import java.util.Vector; /** @@ -160,14 +160,12 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { public MBeanServerNotificationFilter() { super(); - RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(), - "MBeanServerNotificationFilter"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION); enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION); - RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(), - "MBeanServerNotificationFilter"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -181,14 +179,12 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { */ public synchronized void disableAllObjectNames() { - RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(), - "disableAllObjectNames"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); selectedNames = new Vector(); deselectedNames = null; - RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(), - "disableAllObjectNames"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -207,8 +203,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(), - "disableObjectName", objectName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}" + objectName); // Removes from selected ObjectNames, if present if (selectedNames != null) { @@ -226,8 +221,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { } } - RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(), - "disableObjectName"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -236,14 +230,12 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { */ public synchronized void enableAllObjectNames() { - RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(), - "enableAllObjectNames"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); selectedNames = null; deselectedNames = new Vector(); - RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(), - "enableAllObjectNames"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -262,8 +254,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(), - "enableObjectName", objectName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", objectName); // Removes from deselected ObjectNames, if present if (deselectedNames != null) { @@ -281,8 +272,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { } } - RELATION_LOGGER.exiting(MBeanServerNotificationFilter.class.getName(), - "enableObjectName"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -349,16 +339,13 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(), - "isNotificationEnabled", notif); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", notif); // Checks the type first String ntfType = notif.getType(); Vector enabledTypes = getEnabledTypes(); if (!(enabledTypes.contains(ntfType))) { - RELATION_LOGGER.logp(Level.FINER, - MBeanServerNotificationFilter.class.getName(), - "isNotificationEnabled", + RELATION_LOGGER.log(Level.TRACE, "Type not selected, exiting"); return false; } @@ -375,9 +362,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { // checks for explicit selection if (selectedNames.size() == 0) { // All are explicitly not selected - RELATION_LOGGER.logp(Level.FINER, - MBeanServerNotificationFilter.class.getName(), - "isNotificationEnabled", + RELATION_LOGGER.log(Level.TRACE, "No ObjectNames selected, exiting"); return false; } @@ -385,9 +370,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { isSelectedFlg = selectedNames.contains(objName); if (!isSelectedFlg) { // Not in the explicit selected list - RELATION_LOGGER.logp(Level.FINER, - MBeanServerNotificationFilter.class.getName(), - "isNotificationEnabled", + RELATION_LOGGER.log(Level.TRACE, "ObjectName not in selected list, exiting"); return false; } @@ -399,26 +382,20 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { if (deselectedNames == null) { // All are implicitly deselected and it is not explicitly // selected - RELATION_LOGGER.logp(Level.FINER, - MBeanServerNotificationFilter.class.getName(), - "isNotificationEnabled", + RELATION_LOGGER.log(Level.TRACE, "ObjectName not selected, and all " + "names deselected, exiting"); return false; } else if (deselectedNames.contains(objName)) { // Explicitly deselected - RELATION_LOGGER.logp(Level.FINER, - MBeanServerNotificationFilter.class.getName(), - "isNotificationEnabled", + RELATION_LOGGER.log(Level.TRACE, "ObjectName explicitly not selected, exiting"); return false; } } - RELATION_LOGGER.logp(Level.FINER, - MBeanServerNotificationFilter.class.getName(), - "isNotificationEnabled", + RELATION_LOGGER.log(Level.TRACE, "ObjectName selected, exiting"); return true; } diff --git a/jdk/src/java.management/share/classes/javax/management/relation/RelationService.java b/jdk/src/java.management/share/classes/javax/management/relation/RelationService.java index 44d93e9baad..e6e3c56fcd6 100644 --- a/jdk/src/java.management/share/classes/javax/management/relation/RelationService.java +++ b/jdk/src/java.management/share/classes/javax/management/relation/RelationService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import javax.management.Attribute; import javax.management.AttributeNotFoundException; @@ -157,13 +157,11 @@ public class RelationService extends NotificationBroadcasterSupport */ public RelationService(boolean immediatePurgeFlag) { - RELATION_LOGGER.entering(RelationService.class.getName(), - "RelationService"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); setPurgeFlag(immediatePurgeFlag); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "RelationService"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -286,8 +284,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "createRelationType", relationTypeName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); // Can throw an InvalidRelationTypeException RelationType relType = @@ -295,8 +292,7 @@ public class RelationService extends NotificationBroadcasterSupport addRelationTypeInt(relType); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "createRelationType"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -325,8 +321,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "addRelationType"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); // Checks the role infos List roleInfoList = relationTypeObj.getRoleInfos(); @@ -346,8 +341,7 @@ public class RelationService extends NotificationBroadcasterSupport addRelationTypeInt(relationTypeObj); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "addRelationType"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -385,14 +379,12 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRoleInfos", relationTypeName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); // Can throw a RelationTypeNotFoundException RelationType relType = getRelationType(relationTypeName); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getRoleInfos"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return relType.getRoleInfos(); } @@ -421,8 +413,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRoleInfo", new Object[] {relationTypeName, roleInfoName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + relationTypeName, roleInfoName); // Can throw a RelationTypeNotFoundException RelationType relType = getRelationType(relationTypeName); @@ -430,8 +422,7 @@ public class RelationService extends NotificationBroadcasterSupport // Can throw a RoleInfoNotFoundException RoleInfo roleInfo = relType.getRoleInfo(roleInfoName); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getRoleInfo"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return roleInfo; } @@ -461,8 +452,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "removeRelationType", relationTypeName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); // Checks if the relation type to be removed exists // Can throw a RelationTypeNotFoundException @@ -504,8 +494,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "removeRelationType"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -566,9 +555,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "createRelation", - new Object[] {relationId, relationTypeName, roleList}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + relationId, relationTypeName, roleList); // Creates RelationSupport object // Can throw InvalidRoleValueException @@ -588,8 +576,7 @@ public class RelationService extends NotificationBroadcasterSupport relationId, relationTypeName, roleList); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "createRelation"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -654,8 +641,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "addRelation", relationObjectName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationObjectName); // Can throw RelationServiceNotRegisteredException isActive(); @@ -791,8 +777,7 @@ public class RelationService extends NotificationBroadcasterSupport newRefList.add(relationObjectName); updateUnregistrationListener(newRefList, null); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "addRelation"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -819,8 +804,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "isRelationMBean", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // Can throw RelationNotFoundException Object result = getRelation(relationId); @@ -850,8 +834,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "isRelation", objectName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", objectName); String result = null; synchronized(myRelMBeanObjName2RelIdMap) { @@ -881,8 +864,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "hasRelation", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); try { // Can throw RelationNotFoundException @@ -933,8 +915,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "checkRoleReading", new Object[] {roleName, relationTypeName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + roleName, relationTypeName); Integer result; @@ -956,8 +938,7 @@ public class RelationService extends NotificationBroadcasterSupport result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME); } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleReading"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -995,9 +976,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "checkRoleWriting", - new Object[] {role, relationTypeName, initFlag}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + role, relationTypeName, initFlag); // Can throw a RelationTypeNotFoundException RelationType relType = getRelationType(relationTypeName); @@ -1013,8 +993,7 @@ public class RelationService extends NotificationBroadcasterSupport try { roleInfo = relType.getRoleInfo(roleName); } catch (RoleInfoNotFoundException exc) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleWriting"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME); } @@ -1024,8 +1003,7 @@ public class RelationService extends NotificationBroadcasterSupport roleInfo, writeChkFlag); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleWriting"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1055,8 +1033,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "sendRelationCreationNotification", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // Message StringBuilder ntfMsg = new StringBuilder("Creation of relation "); @@ -1071,8 +1048,7 @@ public class RelationService extends NotificationBroadcasterSupport null, null); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "sendRelationCreationNotification"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1114,9 +1090,8 @@ public class RelationService extends NotificationBroadcasterSupport if (!(oldValue instanceof ArrayList)) oldValue = new ArrayList(oldValue); - RELATION_LOGGER.entering(RelationService.class.getName(), - "sendRoleUpdateNotification", - new Object[] {relationId, newRole, oldValue}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + relationId, newRole, oldValue); String roleName = newRole.getRoleName(); List newRoleVal = newRole.getRoleValue(); @@ -1140,8 +1115,7 @@ public class RelationService extends NotificationBroadcasterSupport newRoleVal, oldValue); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "sendRoleUpdateNotification"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); } /** @@ -1172,9 +1146,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "sendRelationRemovalNotification", - new Object[] {relationId, unregMBeanList}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + relationId, unregMBeanList); // Can throw RelationNotFoundException sendNotificationInt(3, @@ -1186,8 +1159,7 @@ public class RelationService extends NotificationBroadcasterSupport null); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "sendRelationRemovalNotification"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1226,8 +1198,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "updateRoleMap", new Object[] {relationId, newRole, oldValue}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + relationId, newRole, oldValue); // Can throw RelationServiceNotRegisteredException isActive(); @@ -1303,8 +1275,7 @@ public class RelationService extends NotificationBroadcasterSupport // all ObjectNames of interest updateUnregistrationListener(newRefList, obsRefList); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "updateRoleMap"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1338,8 +1309,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "removeRelation", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // Checks there is a relation with this id // Can throw RelationNotFoundException @@ -1442,8 +1412,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "removeRelation"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1476,8 +1445,7 @@ public class RelationService extends NotificationBroadcasterSupport public void purgeRelations() throws RelationServiceNotRegisteredException { - RELATION_LOGGER.entering(RelationService.class.getName(), - "purgeRelations"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); // Can throw RelationServiceNotRegisteredException isActive(); @@ -1574,8 +1542,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "purgeRelations"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1610,9 +1577,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "findReferencingRelations", - new Object[] {mbeanName, relationTypeName, roleName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + mbeanName, relationTypeName, roleName); Map> result = new HashMap>(); @@ -1684,8 +1650,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "findReferencingRelations"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1720,9 +1685,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "findAssociatedMBeans", - new Object[] {mbeanName, relationTypeName, roleName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + mbeanName, relationTypeName, roleName); // Retrieves the map -> for those // criterias @@ -1769,8 +1733,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "findAssociatedMBeans"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1794,8 +1757,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "findRelationsOfType"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); // Can throw RelationTypeNotFoundException RelationType relType = getRelationType(relationTypeName); @@ -1809,8 +1771,7 @@ public class RelationService extends NotificationBroadcasterSupport result = new ArrayList(result1); } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "findRelationsOfType"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1845,8 +1806,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRole", new Object[] {relationId, roleName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + relationId, roleName); // Can throw RelationServiceNotRegisteredException isActive(); @@ -1899,7 +1860,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), "getRole"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1931,8 +1892,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRoles", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // Can throw RelationServiceNotRegisteredException isActive(); @@ -1976,7 +1936,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -2004,8 +1964,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRoles", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); @@ -2028,7 +1987,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -2055,8 +2014,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRoleCardinality", new Object[] {relationId, roleName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + relationId, roleName); // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); @@ -2098,8 +2057,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getRoleCardinality"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -2147,8 +2105,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "setRole", new Object[] {relationId, role}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + relationId, role); // Can throw RelationServiceNotRegisteredException isActive(); @@ -2211,7 +2169,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), "setRole"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -2247,8 +2205,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "setRoles", new Object[] {relationId, roleList}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + relationId, roleList); // Can throw RelationServiceNotRegisteredException isActive(); @@ -2296,7 +2254,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), "setRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -2322,8 +2280,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getReferencedMBeans", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", + relationId); // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); @@ -2346,8 +2304,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getReferencedMBeans"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -2371,8 +2328,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRelationTypeName", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); @@ -2395,8 +2351,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getRelationTypeName"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -2421,8 +2376,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "handleNotification", notif); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", notif); if (notif instanceof MBeanServerNotification) { @@ -2480,8 +2434,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "handleNotification"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -2495,8 +2448,7 @@ public class RelationService extends NotificationBroadcasterSupport */ public MBeanNotificationInfo[] getNotificationInfo() { - RELATION_LOGGER.entering(RelationService.class.getName(), - "getNotificationInfo"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); String ntfClass = "javax.management.relation.RelationNotification"; @@ -2514,8 +2466,7 @@ public class RelationService extends NotificationBroadcasterSupport MBeanNotificationInfo ntfInfo = new MBeanNotificationInfo(ntfTypes, ntfClass, ntfDesc); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getNotificationInfo"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return new MBeanNotificationInfo[] {ntfInfo}; } @@ -2539,8 +2490,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "addRelationTypeInt"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); String relTypeName = relationTypeObj.getRelationTypeName(); @@ -2570,8 +2520,7 @@ public class RelationService extends NotificationBroadcasterSupport ((RelationTypeSupport)relationTypeObj).setRelationServiceFlag(true); } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "addRelationTypeInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -2595,8 +2544,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRelationType", relationTypeName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); // No null relation type accepted, so can use get() RelationType relType; @@ -2611,8 +2559,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new RelationTypeNotFoundException(excMsgStrB.toString()); } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getRelationType"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return relType; } @@ -2639,8 +2586,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "getRelation", relationId); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // No null relation accepted, so can use get() Object rel; @@ -2653,8 +2599,7 @@ public class RelationService extends NotificationBroadcasterSupport throw new RelationNotFoundException(excMsg); } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "getRelation"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return rel; } @@ -2684,9 +2629,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "addNewMBeanReference", - new Object[] {objectName, relationId, roleName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + objectName, relationId, roleName); boolean isNewFlag = false; @@ -2739,8 +2683,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "addNewMBeanReference"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return isNewFlag; } @@ -2772,9 +2715,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "removeMBeanReference", - new Object[] {objectName, relationId, roleName, allRolesFlag}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}", + objectName, relationId, roleName, allRolesFlag); boolean noLongerRefFlag = false; @@ -2790,8 +2732,7 @@ public class RelationService extends NotificationBroadcasterSupport if (mbeanRefMap == null) { // The MBean is no longer referenced - RELATION_LOGGER.exiting(RelationService.class.getName(), - "removeMBeanReference"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return true; } @@ -2824,8 +2765,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "removeMBeanReference"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return noLongerRefFlag; } @@ -2850,9 +2790,8 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.entering(RelationService.class.getName(), - "updateUnregistrationListener", - new Object[] {newRefList, obsoleteRefList}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", + newRefList, obsoleteRefList); // Can throw RelationServiceNotRegisteredException isActive(); @@ -2936,8 +2875,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "updateUnregistrationListener"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -3003,9 +2941,10 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "addRelationInt", new Object[] {relationBaseFlag, relationObj, - relationObjName, relationId, relationTypeName, roleList}); + RELATION_LOGGER.log(Level.TRACE, + "ENTRY {0} {1} {2} {3} {4} {5}", + relationBaseFlag, relationObj, relationObjName, + relationId, relationTypeName, roleList); // Can throw RelationServiceNotRegisteredException isActive(); @@ -3144,8 +3083,7 @@ public class RelationService extends NotificationBroadcasterSupport // OK : The Relation could not be found. } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "addRelationInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -3185,15 +3123,13 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "checkRoleInt", new Object[] {chkType, roleName, - roleValue, roleInfo, writeChkFlag}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4}", + chkType, roleName, roleValue, roleInfo, writeChkFlag); // Compares names String expName = roleInfo.getName(); if (!(roleName.equals(expName))) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME); } @@ -3201,13 +3137,11 @@ public class RelationService extends NotificationBroadcasterSupport if (chkType == 1) { boolean isReadable = roleInfo.isReadable(); if (!isReadable) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE); } else { // End of check :) - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return 0; } } @@ -3216,8 +3150,7 @@ public class RelationService extends NotificationBroadcasterSupport if (writeChkFlag) { boolean isWritable = roleInfo.isWritable(); if (!isWritable) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return RoleStatus.ROLE_NOT_WRITABLE; } } @@ -3227,16 +3160,14 @@ public class RelationService extends NotificationBroadcasterSupport // Checks minimum cardinality boolean chkMinFlag = roleInfo.checkMinDegree(refNbr); if (!chkMinFlag) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return RoleStatus.LESS_THAN_MIN_ROLE_DEGREE; } // Checks maximum cardinality boolean chkMaxFlag = roleInfo.checkMaxDegree(refNbr); if (!chkMaxFlag) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return RoleStatus.MORE_THAN_MAX_ROLE_DEGREE; } @@ -3252,8 +3183,7 @@ public class RelationService extends NotificationBroadcasterSupport // Checks it is registered if (currObjName == null) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return RoleStatus.REF_MBEAN_NOT_REGISTERED; } @@ -3263,20 +3193,17 @@ public class RelationService extends NotificationBroadcasterSupport boolean classSts = myMBeanServer.isInstanceOf(currObjName, expClassName); if (!classSts) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS; } } catch (InstanceNotFoundException exc) { - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return RoleStatus.REF_MBEAN_NOT_REGISTERED; } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "checkRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return 0; } @@ -3328,10 +3255,9 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "initializeMissingRoles", new Object[] {relationBaseFlag, - relationObj, relationObjName, relationId, relationTypeName, - roleInfoList}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4} {5}", + relationBaseFlag, relationObj, relationObjName, + relationId, relationTypeName, roleInfoList); // Can throw RelationServiceNotRegisteredException isActive(); @@ -3410,8 +3336,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "initializeMissingRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -3528,9 +3453,9 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "sendNotificationInt", new Object[] {intNtfType, message, - relationId, unregMBeanList, roleName, roleNewValue, oldValue}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4} {5} {6}", + intNtfType, message, relationId, unregMBeanList, + roleName, roleNewValue, oldValue); // Relation type name // Note: do not use getRelationTypeName() as if it is a relation MBean @@ -3616,8 +3541,7 @@ public class RelationService extends NotificationBroadcasterSupport sendNotification(ntf); - RELATION_LOGGER.exiting(RelationService.class.getName(), - "sendNotificationInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -3654,9 +3578,8 @@ public class RelationService extends NotificationBroadcasterSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationService.class.getName(), - "handleReferenceUnregistration", - new Object[] {relationId, objectName, roleNameList}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + relationId, objectName, roleNameList); // Can throw RelationServiceNotRegisteredException isActive(); @@ -3782,8 +3705,7 @@ public class RelationService extends NotificationBroadcasterSupport } } - RELATION_LOGGER.exiting(RelationService.class.getName(), - "handleReferenceUnregistration"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } } diff --git a/jdk/src/java.management/share/classes/javax/management/relation/RelationSupport.java b/jdk/src/java.management/share/classes/javax/management/relation/RelationSupport.java index 09f8b93e754..30a6ec50309 100644 --- a/jdk/src/java.management/share/classes/javax/management/relation/RelationSupport.java +++ b/jdk/src/java.management/share/classes/javax/management/relation/RelationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ package javax.management.relation; +import java.lang.System.Logger.Level; import java.util.ArrayList; - import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -162,8 +162,7 @@ public class RelationSupport super(); - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "RelationSupport"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); // Can throw InvalidRoleValueException and IllegalArgumentException initMembers(relationId, @@ -172,8 +171,7 @@ public class RelationSupport relationTypeName, list); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "RelationSupport"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); } /** @@ -239,8 +237,7 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "RelationSupport"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); // Can throw InvalidRoleValueException and // IllegalArgumentException @@ -250,8 +247,7 @@ public class RelationSupport relationTypeName, list); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "RelationSupport"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); } // @@ -286,15 +282,14 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "getRole", roleName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName); // Can throw RoleNotFoundException and // RelationServiceNotRegisteredException List result = cast( getRoleInt(roleName, false, null, false)); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRole"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -324,12 +319,12 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), "getRoles"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); // Can throw RelationServiceNotRegisteredException RoleResult result = getRolesInt(roleNameArray, false, null); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -346,8 +341,7 @@ public class RelationSupport public RoleResult getAllRoles() throws RelationServiceNotRegisteredException { - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "getAllRoles"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); RoleResult result = null; try { @@ -356,7 +350,7 @@ public class RelationSupport // OK : Invalid parameters, ignore... } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getAllRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -367,8 +361,7 @@ public class RelationSupport */ public RoleList retrieveAllRoles() { - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "retrieveAllRoles"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); RoleList result; synchronized(myRoleName2ValueMap) { @@ -376,8 +369,7 @@ public class RelationSupport new RoleList(new ArrayList(myRoleName2ValueMap.values())); } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "retrieveAllRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -400,8 +392,7 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "getRoleCardinality", roleName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName); // Try to retrieve the role Role role; @@ -426,8 +417,7 @@ public class RelationSupport List roleValue = role.getRoleValue(); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "getRoleCardinality"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return roleValue.size(); } @@ -476,13 +466,12 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "setRole", role); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", role); // Will return null :) Object result = setRoleInt(role, false, null, false); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRole"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -521,12 +510,11 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "setRoles", list); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", list); RoleResult result = setRolesInt(list, false, null); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoles"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -570,9 +558,7 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "handleMBeanUnregistration", - new Object[]{objectName, roleName}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", objectName, roleName); // Can throw RoleNotFoundException, InvalidRoleValueException, // or RelationTypeNotFoundException @@ -581,8 +567,7 @@ public class RelationSupport false, null); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "handleMBeanUnregistration"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -594,8 +579,7 @@ public class RelationSupport */ public Map> getReferencedMBeans() { - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "getReferencedMBeans"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); Map> refMBeanMap = new HashMap>(); @@ -628,8 +612,7 @@ public class RelationSupport } } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "getReferencedMBeans"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return refMBeanMap; } @@ -779,8 +762,7 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "getRoleInt", roleName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName); int pbType = 0; @@ -885,7 +867,7 @@ public class RelationSupport } } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -921,8 +903,7 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "getRolesInt"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); RoleList roleList = new RoleList(); RoleUnresolvedList roleUnresList = new RoleUnresolvedList(); @@ -966,8 +947,7 @@ public class RelationSupport } RoleResult result = new RoleResult(roleList, roleUnresList); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "getRolesInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -991,8 +971,7 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "getAllRolesInt"); + RELATION_LOGGER.log(Level.TRACE, "ENTRY"); List roleNameList; synchronized(myRoleName2ValueMap) { @@ -1006,8 +985,7 @@ public class RelationSupport relationServCallFlg, relationServ); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "getAllRolesInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1083,9 +1061,9 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "setRoleInt", new Object[] {aRole, relationServCallFlg, - relationServ, multiRoleFlg}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}", + aRole, relationServCallFlg, relationServ, + multiRoleFlg); String roleName = aRole.getRoleName(); int pbType = 0; @@ -1244,7 +1222,7 @@ public class RelationSupport } } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoleInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1286,9 +1264,9 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "sendRoleUpdateNotification", new Object[] {newRole, - oldRoleValue, relationServCallFlg, relationServ}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}", + newRole, oldRoleValue, relationServCallFlg, + relationServ); if (relationServCallFlg) { // Direct call to the Relation Service @@ -1341,8 +1319,7 @@ public class RelationSupport } } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "sendRoleUpdateNotification"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1383,9 +1360,9 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "updateRelationServiceMap", new Object[] {newRole, - oldRoleValue, relationServCallFlg, relationServ}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}", + newRole, oldRoleValue, relationServCallFlg, + relationServ); if (relationServCallFlg) { // Direct call to the Relation Service @@ -1433,8 +1410,7 @@ public class RelationSupport } } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "updateRelationServiceMap"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1484,9 +1460,8 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "setRolesInt", - new Object[] {list, relationServCallFlg, relationServ}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}", + list, relationServCallFlg, relationServ); RoleList roleList = new RoleList(); RoleUnresolvedList roleUnresList = new RoleUnresolvedList(); @@ -1534,7 +1509,7 @@ public class RelationSupport RoleResult result = new RoleResult(roleList, roleUnresList); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRolesInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -1578,9 +1553,9 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "initMembers", new Object[] {relationId, relationServiceName, - relationServiceMBeanServer, relationTypeName, list}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4}", + relationId, relationServiceName, + relationServiceMBeanServer, relationTypeName, list); myRelId = relationId; myRelServiceName = relationServiceName; @@ -1589,7 +1564,7 @@ public class RelationSupport // Can throw InvalidRoleValueException initRoleMap(list); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1608,8 +1583,7 @@ public class RelationSupport return; } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "initRoleMap", list); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", list); synchronized(myRoleName2ValueMap) { @@ -1632,7 +1606,7 @@ public class RelationSupport } } - RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initRoleMap"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -1692,9 +1666,9 @@ public class RelationSupport throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationSupport.class.getName(), - "handleMBeanUnregistrationInt", new Object[] {objectName, - roleName, relationServCallFlg, relationServ}); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}", + objectName, roleName, relationServCallFlg, + relationServ); // Retrieves current role value Role role; @@ -1723,8 +1697,7 @@ public class RelationSupport Object result = setRoleInt(newRole, relationServCallFlg, relationServ, false); - RELATION_LOGGER.exiting(RelationSupport.class.getName(), - "handleMBeanUnregistrationInt"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } diff --git a/jdk/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java b/jdk/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java index b6fb9c459b2..60e3612278b 100644 --- a/jdk/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java +++ b/jdk/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; +import java.lang.System.Logger.Level; /** * A RelationTypeSupport object implements the RelationType interface. @@ -173,15 +173,13 @@ public class RelationTypeSupport implements RelationType { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationTypeSupport.class.getName(), - "RelationTypeSupport", relationTypeName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); // Can throw InvalidRelationTypeException, ClassNotFoundException // and NotCompliantMBeanException initMembers(relationTypeName, roleInfoArray); - RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(), - "RelationTypeSupport"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -199,13 +197,11 @@ public class RelationTypeSupport implements RelationType { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationTypeSupport.class.getName(), - "RelationTypeSupport", relationTypeName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); typeName = relationTypeName; - RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(), - "RelationTypeSupport"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -251,8 +247,7 @@ public class RelationTypeSupport implements RelationType { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationTypeSupport.class.getName(), - "getRoleInfo", roleInfoName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleInfoName); // No null RoleInfo allowed, so use get() RoleInfo result = roleName2InfoMap.get(roleInfoName); @@ -265,8 +260,7 @@ public class RelationTypeSupport implements RelationType { throw new RoleInfoNotFoundException(excMsgStrB.toString()); } - RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(), - "getRoleInfo"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; } @@ -297,8 +291,7 @@ public class RelationTypeSupport implements RelationType { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationTypeSupport.class.getName(), - "addRoleInfo", roleInfo); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleInfo); if (isInRelationService) { // Trying to update a declared relation type @@ -319,8 +312,7 @@ public class RelationTypeSupport implements RelationType { roleName2InfoMap.put(roleName, new RoleInfo(roleInfo)); - RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(), - "addRoleInfo"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } @@ -351,8 +343,7 @@ public class RelationTypeSupport implements RelationType { throw new IllegalArgumentException(excMsg); } - RELATION_LOGGER.entering(RelationTypeSupport.class.getName(), - "initMembers", relationTypeName); + RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); typeName = relationTypeName; @@ -366,8 +357,7 @@ public class RelationTypeSupport implements RelationType { new RoleInfo(currRoleInfo)); } - RELATION_LOGGER.exiting(RelationTypeSupport.class.getName(), - "initMembers"); + RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; } diff --git a/jdk/src/java.management/share/classes/javax/management/timer/Timer.java b/jdk/src/java.management/share/classes/javax/management/timer/Timer.java index b199e8e258a..edbf85e8627 100644 --- a/jdk/src/java.management/share/classes/javax/management/timer/Timer.java +++ b/jdk/src/java.management/share/classes/javax/management/timer/Timer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.Vector; -import java.util.logging.Level; +import java.lang.System.Logger.Level; // jmx imports // @@ -221,8 +221,7 @@ public class Timer extends NotificationBroadcasterSupport */ public void preDeregister() throws java.lang.Exception { - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "preDeregister", "stop the timer"); + TIMER_LOGGER.log(Level.TRACE, "stop the timer"); // Stop the timer. // @@ -273,8 +272,7 @@ public class Timer extends NotificationBroadcasterSupport */ public synchronized void start() { - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "start", "starting the timer"); + TIMER_LOGGER.log(Level.TRACE, "starting the timer"); // Start the TimerAlarmClock. // @@ -323,11 +321,9 @@ public class Timer extends NotificationBroadcasterSupport // isActive = true; - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "start", "timer started"); + TIMER_LOGGER.log(Level.TRACE, "timer started"); } else { - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "start", "the timer is already activated"); + TIMER_LOGGER.log(Level.TRACE, "the timer is already activated"); } } @@ -336,8 +332,7 @@ public class Timer extends NotificationBroadcasterSupport */ public synchronized void stop() { - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "stop", "stopping the timer"); + TIMER_LOGGER.log(Level.TRACE, "stopping the timer"); // Stop the TimerAlarmClock. // @@ -370,11 +365,9 @@ public class Timer extends NotificationBroadcasterSupport // isActive = false; - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "stop", "timer stopped"); + TIMER_LOGGER.log(Level.TRACE, "timer stopped"); } else { - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "stop", "the timer is already deactivated"); + TIMER_LOGGER.log(Level.TRACE, "the timer is already deactivated"); } } @@ -444,9 +437,8 @@ public class Timer extends NotificationBroadcasterSupport if (currentDate.after(date)) { date.setTime(currentDate.getTime()); - if (TIMER_LOGGER.isLoggable(Level.FINER)) { - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "addNotification", + if (TIMER_LOGGER.isLoggable(Level.TRACE)) { + TIMER_LOGGER.log(Level.TRACE, "update timer notification to add with:" + "\n\tNotification date = " + date); } @@ -486,7 +478,7 @@ public class Timer extends NotificationBroadcasterSupport obj[ALARM_CLOCK_INDEX] = (Object)alarmClock; obj[FIXED_RATE_INDEX] = Boolean.valueOf(fixedRate); - if (TIMER_LOGGER.isLoggable(Level.FINER)) { + if (TIMER_LOGGER.isLoggable(Level.TRACE)) { StringBuilder strb = new StringBuilder() .append("adding timer notification:\n\t") .append("Notification source = ") @@ -503,8 +495,7 @@ public class Timer extends NotificationBroadcasterSupport .append(nbOccurences) .append("\n\tNotification executes at fixed rate = ") .append(fixedRate); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "addNotification", strb.toString()); + TIMER_LOGGER.log(Level.TRACE, strb::toString); } timerTable.put(notifID, obj); @@ -522,8 +513,7 @@ public class Timer extends NotificationBroadcasterSupport } } - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "addNotification", "timer notification added"); + TIMER_LOGGER.log(Level.TRACE, "timer notification added"); return notifID; } @@ -677,7 +667,7 @@ public class Timer extends NotificationBroadcasterSupport // Remove the timer notification from the timer table. // - if (TIMER_LOGGER.isLoggable(Level.FINER)) { + if (TIMER_LOGGER.isLoggable(Level.TRACE)) { StringBuilder strb = new StringBuilder() .append("removing timer notification:") .append("\n\tNotification source = ") @@ -694,14 +684,12 @@ public class Timer extends NotificationBroadcasterSupport .append(obj[TIMER_NB_OCCUR_INDEX]) .append("\n\tNotification executes at fixed rate = ") .append(obj[FIXED_RATE_INDEX]); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "removeNotification", strb.toString()); + TIMER_LOGGER.log(Level.TRACE, strb::toString); } timerTable.remove(id); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "removeNotification", "timer notification removed"); + TIMER_LOGGER.log(Level.TRACE, "timer notification removed"); } /** @@ -752,19 +740,16 @@ public class Timer extends NotificationBroadcasterSupport } // Remove all the timer notifications from the timer table. - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "removeAllNotifications", "removing all timer notifications"); + TIMER_LOGGER.log(Level.TRACE, "removing all timer notifications"); timerTable.clear(); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "removeAllNotifications", "all timer notifications removed"); + TIMER_LOGGER.log(Level.TRACE, "all timer notifications removed"); // Reset the counterID. // counterID = 0; - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "removeAllNotifications", "timer notification counter ID reset"); + TIMER_LOGGER.log(Level.TRACE, "timer notification counter ID reset"); } // GETTERS AND SETTERS @@ -1021,7 +1006,7 @@ public class Timer extends NotificationBroadcasterSupport while ( (currentDate.after(date)) && (timerTable.containsKey(notifID)) ) { if (currentFlag == true) { - if (TIMER_LOGGER.isLoggable(Level.FINER)) { + if (TIMER_LOGGER.isLoggable(Level.TRACE)) { StringBuilder strb = new StringBuilder() .append("sending past timer notification:") .append("\n\tNotification source = ") @@ -1038,13 +1023,11 @@ public class Timer extends NotificationBroadcasterSupport .append(obj[TIMER_NB_OCCUR_INDEX]) .append("\n\tNotification executes at fixed rate = ") .append(obj[FIXED_RATE_INDEX]); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "sendPastNotifications", strb.toString()); + TIMER_LOGGER.log(Level.TRACE, strb::toString); } sendNotification(date, notif); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "sendPastNotifications", "past timer notification sent"); + TIMER_LOGGER.log(Level.TRACE, "past timer notification sent"); } // Update the date and the number of occurrences of the timer notification. @@ -1107,7 +1090,7 @@ public class Timer extends NotificationBroadcasterSupport timer.schedule(alarmClock, alarmClock.timeout); } } - if (TIMER_LOGGER.isLoggable(Level.FINER)) { + if (TIMER_LOGGER.isLoggable(Level.TRACE)) { TimerNotification notif = (TimerNotification)obj[TIMER_NOTIF_INDEX]; StringBuilder strb = new StringBuilder() .append("update timer notification with:") @@ -1125,8 +1108,7 @@ public class Timer extends NotificationBroadcasterSupport .append(nbOccurences) .append("\n\tNotification executes at fixed rate = ") .append(fixedRate); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "updateTimerTable", strb.toString()); + TIMER_LOGGER.log(Level.TRACE, strb::toString); } } else { @@ -1211,7 +1193,7 @@ public class Timer extends NotificationBroadcasterSupport */ void sendNotification(Date timeStamp, TimerNotification notification) { - if (TIMER_LOGGER.isLoggable(Level.FINER)) { + if (TIMER_LOGGER.isLoggable(Level.TRACE)) { StringBuilder strb = new StringBuilder() .append("sending timer notification:") .append("\n\tNotification source = ") @@ -1222,8 +1204,7 @@ public class Timer extends NotificationBroadcasterSupport .append(notification.getNotificationID()) .append("\n\tNotification date = ") .append(timeStamp); - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "sendNotification", strb.toString()); + TIMER_LOGGER.log(Level.TRACE, strb::toString); } long curSeqNumber; synchronized(this) { @@ -1236,7 +1217,6 @@ public class Timer extends NotificationBroadcasterSupport this.sendNotification((TimerNotification)notification.cloneTimerNotification()); } - TIMER_LOGGER.logp(Level.FINER, Timer.class.getName(), - "sendNotification", "timer notification sent"); + TIMER_LOGGER.log(Level.TRACE, "timer notification sent"); } } diff --git a/jdk/src/java.management/share/classes/javax/management/timer/TimerAlarmClock.java b/jdk/src/java.management/share/classes/javax/management/timer/TimerAlarmClock.java index 9ae8080ab6a..06007415afe 100644 --- a/jdk/src/java.management/share/classes/javax/management/timer/TimerAlarmClock.java +++ b/jdk/src/java.management/share/classes/javax/management/timer/TimerAlarmClock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package javax.management.timer; import java.util.Date; -import java.util.logging.Level; +import java.lang.System.Logger.Level; import static com.sun.jmx.defaults.JmxProperties.TIMER_LOGGER; /** @@ -73,7 +73,7 @@ class TimerAlarmClock extends java.util.TimerTask { TimerAlarmClockNotification notif = new TimerAlarmClockNotification(this); listener.notifyAlarmClock(notif); } catch (Exception e) { - TIMER_LOGGER.logp(Level.FINEST, Timer.class.getName(), "run", + TIMER_LOGGER.log(Level.TRACE, "Got unexpected exception when sending a notification", e); } } diff --git a/jdk/src/java.management/share/classes/module-info.java b/jdk/src/java.management/share/classes/module-info.java index 705e3ef2098..c130350387a 100644 --- a/jdk/src/java.management/share/classes/module-info.java +++ b/jdk/src/java.management/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ */ module java.management { requires transitive java.rmi; - requires java.logging; requires java.naming; exports java.lang.management; @@ -55,4 +54,3 @@ module java.management { provides javax.security.auth.spi.LoginModule with com.sun.jmx.remote.security.FileLoginModule; } - diff --git a/jdk/test/sun/management/LoggingTest/LoggingTest.java b/jdk/test/sun/management/LoggingTest/LoggingTest.java new file mode 100644 index 00000000000..18f28526a23 --- /dev/null +++ b/jdk/test/sun/management/LoggingTest/LoggingTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.management.ManagementFactory; +import java.util.List; +import javax.management.MBeanServer; +import javax.management.ObjectName; + +public class LoggingTest { + + static class TestStream extends PrintStream { + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + private volatile boolean recording; + public TestStream(PrintStream wrapped) { + super(wrapped); + } + + void startRecording() { + recording = true; + } + + void stopRecording() { + recording = false; + } + + @Override + public void write(int b) { + if (recording) { + bos.write(b); + } + super.write(b); + } + + @Override + public void write(byte[] buf, int off, int len) { + if (recording) { + bos.write(buf, off, len); + } + super.write(buf, off, len); + } + + @Override + public void write(byte[] buf) throws IOException { + if (recording) { + bos.write(buf); + } + super.write(buf); + } + + } + + public void run(TestStream ts) { + + // start recording traces and trigger creation of the platform + // MBeanServer to produce some. This won't work if the platform + // MBeanServer was already initialized - so it's important to + // run this test in its own JVM. + ts.startRecording(); + MBeanServer platform = ManagementFactory.getPlatformMBeanServer(); + ts.stopRecording(); + String printed = ts.bos.toString(); + ts.bos.reset(); + + // Check that the Platform MBeanServer is emitting the expected + // log traces. This can be a bit fragile because debug traces + // could be changed without notice - in which case this test will + // need to be updated. + // For each registered MBean we expect to see three traces. + // If the messages logged by the MBeanServer change then these checks + // may need to be revisited. + List checkTraces = + List.of("ObjectName = %s", "name = %s", "JMX.mbean.registered %s"); + + for (ObjectName o : platform.queryNames(ObjectName.WILDCARD, null)) { + String n = o.toString(); + System.out.println("Checking log for: " + n); + for (String check : checkTraces) { + String s = String.format(check, n); + if (!printed.contains(s)) { + throw new RuntimeException("Trace not found: " + s); + } + } + } + } + +} diff --git a/jdk/test/sun/management/LoggingTest/LoggingWithJULTest.java b/jdk/test/sun/management/LoggingTest/LoggingWithJULTest.java new file mode 100644 index 00000000000..a15e5296ec7 --- /dev/null +++ b/jdk/test/sun/management/LoggingTest/LoggingWithJULTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.nio.file.Paths; + +/** + * @test + * @bug 8172971 + * @modules java.management java.logging + * @summary Smoke test to check that logging in java.management works as expected. + * @build LoggingTest LoggingWithJULTest + * @run main/othervm LoggingWithJULTest + * @author danielfuchs + */ +public class LoggingWithJULTest { + + public static void main(String[] args) { + // Replace System.err + LoggingTest.TestStream ts = new LoggingTest.TestStream(System.err); + System.setErr(ts); + + // activate the javax.management traces + String properties = Paths.get(System.getProperty("test.src", "src"), + "logging.properties").toString(); + System.setProperty("java.util.logging.config.file", properties); + + // run the test + new LoggingTest().run(ts); + } + +} diff --git a/jdk/test/sun/management/LoggingTest/LoggingWithLoggerFinderTest.java b/jdk/test/sun/management/LoggingTest/LoggingWithLoggerFinderTest.java new file mode 100644 index 00000000000..feec435db2b --- /dev/null +++ b/jdk/test/sun/management/LoggingTest/LoggingWithLoggerFinderTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8172971 + * @modules java.management + * @summary Smoke test to check that logging in java.management is performed + * through System.Logger. This test installs a LoggerFinder service + * provider and verifies that it gets the traces. + * @build test.loggerfinder/test.loggerfinder.TestLoggerFinder LoggingTest LoggingWithLoggerFinderTest + * @run main/othervm --add-modules test.loggerfinder LoggingWithLoggerFinderTest + * @author danielfuchs + */ +public class LoggingWithLoggerFinderTest { + + public static void main(String[] args) { + // Replace System.err + LoggingTest.TestStream ts = new LoggingTest.TestStream(System.err); + System.setErr(ts); + + // run the test + new LoggingTest().run(ts); + } + +} diff --git a/jdk/test/sun/management/LoggingTest/logging.properties b/jdk/test/sun/management/LoggingTest/logging.properties new file mode 100644 index 00000000000..b2b2ab67557 --- /dev/null +++ b/jdk/test/sun/management/LoggingTest/logging.properties @@ -0,0 +1,55 @@ +############################################################ +# Global properties +############################################################ + +# "handlers" specifies a comma separated list of log Handler +# classes. These handlers will be installed during VM startup. +# Note that these classes must be on the system classpath. +# By default we only configure a ConsoleHandler, which will only +# show messages at the INFO and above levels. +handlers= java.util.logging.ConsoleHandler + +# To also add the FileHandler, use the following line instead. +#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler + +# Default global logging level. +# This specifies which kinds of events are logged across +# all loggers. For any given facility this global level +# can be overriden by a facility specific level +# Note that the ConsoleHandler also has a separate level +# setting to limit messages printed to the console. +.level= INFO + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +# default file output is in user's home directory. +java.util.logging.FileHandler.pattern = %h/java%u.log +java.util.logging.FileHandler.limit = 50000 +java.util.logging.FileHandler.count = 1 +# Default number of locks FileHandler can obtain synchronously. +# This specifies maximum number of attempts to obtain lock file by FileHandler +# implemented by incrementing the unique field %u as per FileHandler API documentation. +java.util.logging.FileHandler.maxLocks = 100 +java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter + +# Limit the message that are printed on the console to INFO and above. +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + +# Example to customize the SimpleFormatter output format +# to print one-line log message like this: +# : [] +# +# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +# For example, set the com.xyz.foo logger to only log SEVERE +# messages: +javax.management.level = ALL diff --git a/jdk/test/sun/management/LoggingTest/test.loggerfinder/module-info.java b/jdk/test/sun/management/LoggingTest/test.loggerfinder/module-info.java new file mode 100644 index 00000000000..08fd6642169 --- /dev/null +++ b/jdk/test/sun/management/LoggingTest/test.loggerfinder/module-info.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +module test.loggerfinder { + // Install a LoggerFinder that will direct traces directly to System.err, + // without involving java.util.logging + provides java.lang.System.LoggerFinder with test.loggerfinder.TestLoggerFinder; +} diff --git a/jdk/test/sun/management/LoggingTest/test.loggerfinder/test/loggerfinder/TestLoggerFinder.java b/jdk/test/sun/management/LoggingTest/test.loggerfinder/test/loggerfinder/TestLoggerFinder.java new file mode 100644 index 00000000000..39c555eee9e --- /dev/null +++ b/jdk/test/sun/management/LoggingTest/test.loggerfinder/test/loggerfinder/TestLoggerFinder.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test.loggerfinder; + +import java.lang.System.Logger; +import java.lang.System.Logger.Level; +import java.lang.System.LoggerFinder; +import java.lang.reflect.Module; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Optional; +import java.util.ResourceBundle; +import java.util.function.Predicate; +import java.lang.StackWalker.StackFrame; +import java.text.MessageFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +/** + * A LoggerFinder that provides System.Logger which print directly + * on System.err, without involving java.logging. + * For the purpose of the test, loggers whose name start with java.management. + * will log all messages, and other loggers will only log level > INFO. + * @author danielfuchs + */ +public class TestLoggerFinder extends LoggerFinder { + + static class TestLogger implements Logger { + + final String name; + + public TestLogger(String name) { + this.name = name; + } + + + @Override + public String getName() { + return name; + } + + @Override + public boolean isLoggable(Level level) { + return name.equals("javax.management") + || name.startsWith("javax.management.") + || level.getSeverity() >= Level.INFO.getSeverity(); + } + + @Override + public void log(Level level, ResourceBundle bundle, String msg, Throwable thrown) { + if (!isLoggable(level)) return; + publish(level, bundle, msg, thrown); + } + + @Override + public void log(Level level, ResourceBundle bundle, String format, Object... params) { + if (!isLoggable(level)) return; + publish(level, bundle, format, params); + } + + static void publish(Level level, ResourceBundle bundle, String msg, Throwable thrown) { + StackFrame sf = new CallerFinder().get().get(); + + if (bundle != null && msg != null) { + msg = bundle.getString(msg); + } + if (msg == null) msg = ""; + LocalDateTime ldt = LocalDateTime.now(); + String date = DateTimeFormatter.ISO_DATE_TIME.format(ldt); + System.err.println(date + " " + + sf.getClassName() + " " + sf.getMethodName() + "\n" + + String.valueOf(level) + ": " + msg); + thrown.printStackTrace(System.err); + } + + static void publish(Level level, ResourceBundle bundle, String format, Object... params) { + StackFrame sf = new CallerFinder().get().get(); + if (bundle != null && format != null) { + format = bundle.getString(format); + } + String msg = format(format, params); + LocalDateTime ldt = LocalDateTime.now(); + String date = DateTimeFormatter.ISO_DATE_TIME.format(ldt); + System.err.println(date + " " + + sf.getClassName() + " " + sf.getMethodName() + "\n" + + String.valueOf(level) + ": " + msg); + } + + static String format(String format, Object... args) { + if (format == null) return ""; + int index = 0, len = format.length(); + while ((index = format.indexOf(index, '{')) >= 0) { + if (index >= len - 2) break; + char c = format.charAt(index+1); + if (c >= '0' && c <= '9') { + return MessageFormat.format(format, args); + } + index++; + } + return format; + } + + } + + /* + * CallerFinder is a stateful predicate. + */ + static final class CallerFinder implements Predicate { + private static final StackWalker WALKER; + static { + PrivilegedAction pa = + () -> StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); + WALKER = AccessController.doPrivileged(pa); + } + + /** + * Returns StackFrame of the caller's frame. + * @return StackFrame of the caller's frame. + */ + Optional get() { + return WALKER.walk((s) -> s.filter(this).findFirst()); + } + + private boolean lookingForLogger = true; + /** + * Returns true if we have found the caller's frame, false if the frame + * must be skipped. + * + * @param t The frame info. + * @return true if we have found the caller's frame, false if the frame + * must be skipped. + */ + @Override + public boolean test(StackWalker.StackFrame s) { + // We should skip all frames until we have found the logger, + // because these frames could be frames introduced by e.g. custom + // sub classes of Handler. + Class c = s.getDeclaringClass(); + boolean isLogger = System.Logger.class.isAssignableFrom(c); + if (lookingForLogger) { + // Skip all frames until we have found the first logger frame. + lookingForLogger = c != TestLogger.class; + return false; + } + // Continue walking until we've found the relevant calling frame. + // Skips logging/logger infrastructure. + return !isLogger; + } + } + + @Override + public Logger getLogger(String name, Module module) { + return new TestLogger(name); + } + +} From 1a27d2430d412e16871adbbacae3ddb62073c894 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Fri, 20 Jan 2017 14:11:08 -0500 Subject: [PATCH 146/154] 8173134: Add failing java/bean tests in JDK-8173082 to the ProblemList Reviewed-by: darcy --- jdk/test/ProblemList.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index b0d21d7f918..787ba9dcea3 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -118,6 +118,35 @@ java/beans/Introspector/8132566/OverridePropertyInfoTest.java 8132565 generic-all java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 generic-all +java/beans/PropertyEditor/TestBooleanClass.java 8173082 generic-all +java/beans/PropertyEditor/TestByteClass.java 8173082 generic-all +java/beans/PropertyEditor/TestColorClass.java 8173082 generic-all +java/beans/PropertyEditor/TestDoubleClass.java 8173082 generic-all +java/beans/PropertyEditor/TestFloatClass.java 8173082 generic-all +java/beans/PropertyEditor/TestFontClass.java 8173082 generic-all +java/beans/PropertyEditor/TestIntegerClass.java 8173082 generic-all +java/beans/PropertyEditor/TestLongClass.java 8173082 generic-all +java/beans/PropertyEditor/TestShortClass.java 8173082 generic-all +java/beans/PropertyEditor/TestStringClass.java 8173082 generic-all +java/beans/XMLEncoder/Test6570354.java 8173082 generic-all +java/beans/XMLDecoder/spec/TestObject.java 8173082 macosx-all +java/beans/XMLEncoder/Test4631471.java 8173082 macosx-all +java/beans/XMLEncoder/Test4652928.java 8173082 macosx-all +java/beans/XMLEncoder/Test4903007.java 8173082 macosx-all +java/beans/XMLEncoder/Test6437265.java 8173082 macosx-all +java/beans/XMLEncoder/Test6501431.java 8173082 macosx-all +java/beans/XMLEncoder/java_awt_BorderLayout.java 8173082 macosx-all +java/beans/XMLEncoder/java_awt_CardLayout.java 8173082 macosx-all +java/beans/XMLEncoder/java_awt_GridBagLayout.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_BoxLayout.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_DefaultCellEditor.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_JButton.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_JLayeredPane.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_JSplitPane.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_JTree.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_OverlayLayout.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_border_TitledBorder.java 8173082 macosx-all +java/beans/XMLEncoder/javax_swing_plaf_BorderUIResource_TitledBorderUIResource.java 8173082 macosx-all ############################################################################ From 8d7694562cc4a43ab978f8df272778af0f2e59be Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Sat, 21 Jan 2017 08:38:51 +0800 Subject: [PATCH 147/154] 8172975: SecurityTools.keytool() needs to accept user input Reviewed-by: asmotrak --- .../sun/security/tools/keytool/Main.java | 5 +- .../security/tools/keytool/ImportPrompt.java | 88 +++++++++++++++++++ .../sun/security/tools/keytool/ReadJar.java | 9 +- 3 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 jdk/test/sun/security/tools/keytool/ImportPrompt.java diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java index 9730938c927..b73773f5711 100644 --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3522,7 +3522,8 @@ public final class Main { System.err.flush(); reply = (new BufferedReader(new InputStreamReader (System.in))).readLine(); - if (collator.compare(reply, "") == 0 || + if (reply == null || + collator.compare(reply, "") == 0 || collator.compare(reply, rb.getString("n")) == 0 || collator.compare(reply, rb.getString("no")) == 0) { reply = "NO"; diff --git a/jdk/test/sun/security/tools/keytool/ImportPrompt.java b/jdk/test/sun/security/tools/keytool/ImportPrompt.java new file mode 100644 index 00000000000..50bd690371e --- /dev/null +++ b/jdk/test/sun/security/tools/keytool/ImportPrompt.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.Asserts; +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.OutputAnalyzer; + +import java.io.File; +import java.security.KeyStore; + +/** + * @test + * @bug 8172975 + * @summary SecurityTools.keytool() needs to accept user input + * @library /test/lib + */ + +public class ImportPrompt { + + private static final String COMMON = + "-storetype jks -storepass changeit -keypass changeit -debug"; + + public static void main(String[] args) throws Throwable { + + kt("-keystore ks1 -genkeypair -alias a -dname CN=A"); + kt("-keystore ks1 -exportcert -alias a -file a.cert"); + + // Just create a keystore + kt("-keystore ks2 -genkeypair -alias b -dname CN=B"); + + // no response text, assume no + kt("-keystore ks2 -importcert -alias a -file a.cert"); + Asserts.assertFalse(hasA()); + + // no reply is no + SecurityTools.setResponse("no"); + kt("-keystore ks2 -importcert -alias a -file a.cert"); + Asserts.assertFalse(hasA()); + + // explicit yes + SecurityTools.setResponse("yes"); + kt("-keystore ks2 -importcert -alias a -file a.cert"); + Asserts.assertTrue(hasA()); + + // remove it + kt("-keystore ks2 -delete -alias a"); + Asserts.assertFalse(hasA()); + + // the previous "yes" will not be remembered + kt("-keystore ks2 -importcert -alias a -file a.cert"); + Asserts.assertFalse(hasA()); + + // add with -noprompt + SecurityTools.setResponse(""); + kt("-keystore ks2 -importcert -alias a -file a.cert -noprompt"); + Asserts.assertTrue(hasA()); + } + + private static OutputAnalyzer kt(String cmd) throws Throwable { + return SecurityTools.keytool(COMMON + " " + cmd) + .shouldHaveExitValue(0); + } + + private static boolean hasA() throws Exception { + return KeyStore.getInstance(new File("ks2"), "changeit".toCharArray()) + .containsAlias("a"); + } +} diff --git a/jdk/test/sun/security/tools/keytool/ReadJar.java b/jdk/test/sun/security/tools/keytool/ReadJar.java index 5400db17e31..644033cc1fa 100644 --- a/jdk/test/sun/security/tools/keytool/ReadJar.java +++ b/jdk/test/sun/security/tools/keytool/ReadJar.java @@ -57,16 +57,15 @@ public class ReadJar { System.out.println(out.getOutput()); out.shouldHaveExitValue(0); - out = SecurityTools.jarsigner("test_rsa.jar", "rsa_alias", - "-keystore keystore -storepass password "); + out = SecurityTools.jarsigner("-keystore keystore -storepass password " + + "test_rsa.jar rsa_alias"); System.out.println(out.getOutput()); out.shouldHaveExitValue(0); printCert("test_rsa.jar"); - out = SecurityTools.jarsigner("test_md5.jar", "rsa_alias", - "-keystore keystore -storepass password " - + "-sigalg MD5withRSA -digestalg MD5"); + out = SecurityTools.jarsigner("-keystore keystore -storepass password " + + "-sigalg MD5withRSA -digestalg MD5 test_md5.jar rsa_alias"); System.out.println(out.getOutput()); out.shouldHaveExitValue(0); From 46c45f49e2b1ef6be971f09b227ae5012c55a0cd Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 22:40:30 +0200 Subject: [PATCH 148/154] Added tag jdk-9+152 for changeset ab2c8b03c328 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 51b65df7123..70bb3a2ec16 100644 --- a/.hgtags +++ b/.hgtags @@ -394,3 +394,4 @@ f4e854a77aa38749bd90f722b06974a56e7233d5 jdk-9+147 cf139f925da04c8bd7efd33270a0315d72b338d3 jdk-9+149 17469f16fbb406ec9f0dd262ce776ab6efbc38f1 jdk-9+150 37b95df0042ae0687324e1f7dc4a2519e230e704 jdk-9+151 +ab2c8b03c3284fcbdd157551a66f807e3a182d9b jdk-9+152 From 44ec46e144b340a136f901f9071029c1e687094a Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 22:42:10 +0200 Subject: [PATCH 149/154] Added tag jdk-9+153 for changeset d7034ff7f8e2 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 70bb3a2ec16..cf17b470a4f 100644 --- a/.hgtags +++ b/.hgtags @@ -395,3 +395,4 @@ cf139f925da04c8bd7efd33270a0315d72b338d3 jdk-9+149 17469f16fbb406ec9f0dd262ce776ab6efbc38f1 jdk-9+150 37b95df0042ae0687324e1f7dc4a2519e230e704 jdk-9+151 ab2c8b03c3284fcbdd157551a66f807e3a182d9b jdk-9+152 +d7034ff7f8e257e81c9f95c7785dd4eaaa3c2afc jdk-9+153 From a5a732dbbd71a92ae7b440c0217a01a7181055c4 Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Sat, 21 Jan 2017 08:45:45 -0800 Subject: [PATCH 150/154] 8173159: Problem list java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java on Windows Reviewed-by: dfuchs --- jdk/test/ProblemList.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 0714babb88a..e86989d33df 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -228,6 +228,8 @@ java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 7191877 generic- java/rmi/activation/Activatable/extLoadedImpl/ext.sh 8062724 generic-all +java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java 8169569 windows-all + sun/rmi/rmic/newrmic/equivalence/run.sh 8145980 generic-all ############################################################################ From 20bcdb3a1c891d7a972f84b7302bbe42becdad15 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Sat, 21 Jan 2017 10:12:29 -0800 Subject: [PATCH 151/154] 8173156: Remove JmodTest.java from the probelm list on windows Reviewed-by: mchung --- jdk/test/ProblemList.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index e86989d33df..17ec47cc25e 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -291,8 +291,6 @@ tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java 8169971 windows- tools/jlink/CustomPluginTest.java 8172864 generic-all -tools/jmod/JmodTest.java 8172870 windows-all - ############################################################################ # jdk_jdi From ea6b99d73082d82628d23d0155dd44a7d922f3f3 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Sat, 21 Jan 2017 14:31:57 -0800 Subject: [PATCH 152/154] 8173096: jmod files are not world-readable Reviewed-by: alanb --- .../classes/jdk/tools/jmod/JmodTask.java | 32 +++++++------- jdk/test/tools/jmod/JmodTest.java | 44 ++++--------------- 2 files changed, 25 insertions(+), 51 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java index 31e76e294ec..3ed482b7d99 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java @@ -73,7 +73,6 @@ import java.util.ResourceBundle; import java.util.Set; import java.util.TreeSet; import java.util.function.Consumer; -import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.jar.JarEntry; @@ -395,25 +394,30 @@ public class JmodTask { // create jmod with temporary name to avoid it being examined // when scanning the module path Path target = options.jmodFile; - Path tempTarget = Files.createTempFile(target.getFileName().toString(), ".tmp"); + Path tempTarget = jmodTempFilePath(target); try { try (JmodOutputStream jos = JmodOutputStream.newOutputStream(tempTarget)) { jmod.write(jos); } Files.move(tempTarget, target); } catch (Exception e) { - if (Files.exists(tempTarget)) { - try { - Files.delete(tempTarget); - } catch (IOException ioe) { - e.addSuppressed(ioe); - } + try { + Files.deleteIfExists(tempTarget); + } catch (IOException ioe) { + e.addSuppressed(ioe); } throw e; } return true; } + /* + * Create a JMOD .tmp file for the given target JMOD file + */ + private static Path jmodTempFilePath(Path target) throws IOException { + return target.resolveSibling("." + target.getFileName() + ".tmp"); + } + private class JmodFileWriter { final List cmds = options.cmds; final List libs = options.libs; @@ -908,7 +912,7 @@ public class JmodTask { throws IOException { Path target = moduleToPath(name); - Path tempTarget = Files.createTempFile(target.getFileName().toString(), ".tmp"); + Path tempTarget = jmodTempFilePath(target); try { if (target.getFileName().toString().endsWith(".jmod")) { updateJmodFile(target, tempTarget, moduleHashes); @@ -916,12 +920,10 @@ public class JmodTask { updateModularJar(target, tempTarget, moduleHashes); } } catch (IOException|RuntimeException e) { - if (Files.exists(tempTarget)) { - try { - Files.delete(tempTarget); - } catch (IOException ioe) { - e.addSuppressed(ioe); - } + try { + Files.deleteIfExists(tempTarget); + } catch (IOException ioe) { + e.addSuppressed(ioe); } throw e; } diff --git a/jdk/test/tools/jmod/JmodTest.java b/jdk/test/tools/jmod/JmodTest.java index ccf333511cb..27dc8396e74 100644 --- a/jdk/test/tools/jmod/JmodTest.java +++ b/jdk/test/tools/jmod/JmodTest.java @@ -43,7 +43,6 @@ import java.util.spi.ToolProvider; import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.testlibrary.FileUtils; -import jdk.testlibrary.JDKToolFinder; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -587,17 +586,10 @@ public class JmodTest { // Ensure that it is removed in the event of a failure. // The failure in this case is a class in the unnamed package. - String filename = "testTmpFileRemoved.jmod"; - Path jmod = MODS_DIR.resolve(filename); - - // clean up files + Path jmod = MODS_DIR.resolve("testTmpFileRemoved.jmod"); + Path tmp = MODS_DIR.resolve(".testTmpFileRemoved.jmod.tmp"); FileUtils.deleteFileIfExistsWithRetry(jmod); - findTmpFiles(filename).forEach(tmp -> { - try { - FileUtils.deleteFileIfExistsWithRetry(tmp); - } catch (IOException e) {} - }); - + FileUtils.deleteFileIfExistsWithRetry(tmp); String cp = EXPLODED_DIR.resolve("foo").resolve("classes") + File.pathSeparator + EXPLODED_DIR.resolve("foo").resolve("classes") .resolve("jdk").resolve("test").resolve("foo").toString(); @@ -605,31 +597,11 @@ public class JmodTest { jmod("create", "--class-path", cp, jmod.toString()) - .assertFailure() - .resultChecker(r -> { - assertContains(r.output, "unnamed package"); - List tmpfiles = findTmpFiles(filename); - assertTrue(tmpfiles.isEmpty(), "Unexpected tmp file:" + tmpfiles); - }); - } - - /* - * Returns the list of writeable tmp files with the given prefix. - * - * Ignore the non-writeable tmp files because this test is possibly - * running by another user. - */ - private List findTmpFiles(String prefix) { - Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir")); - try (Stream stream = Files.list(tmpdir)) { - return stream.filter(p -> { - String fn = p.getFileName().toString(); - return Files.isWritable(p) - && fn.startsWith(prefix) && fn.endsWith(".tmp"); - }).collect(Collectors.toList()); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + .assertFailure() + .resultChecker(r -> { + assertContains(r.output, "unnamed package"); + assertTrue(Files.notExists(tmp), "Unexpected tmp file:" + tmp); + }); } // --- From 472c73df438dc130f152463cc5e819e3f1004f8d Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Mon, 23 Jan 2017 07:34:11 -0500 Subject: [PATCH 153/154] 8173082: java/bean/* tests fail since change of JDK-8055206 Reviewed-by: mchung, ahgross, alanb --- .../share/lib/security/default.policy | 8 +++++ jdk/test/ProblemList.txt | 29 ------------------- .../SecurityManager/CheckPackageAccess.java | 3 +- .../provider/PolicyFile/TokenStore.java | 7 ++--- 4 files changed, 12 insertions(+), 35 deletions(-) diff --git a/jdk/src/java.base/share/lib/security/default.policy b/jdk/src/java.base/share/lib/security/default.policy index 4d890704195..ae4a1e2db54 100644 --- a/jdk/src/java.base/share/lib/security/default.policy +++ b/jdk/src/java.base/share/lib/security/default.policy @@ -205,3 +205,11 @@ grant codeBase "jrt:/jdk.accessibility" { grant codeBase "jrt:/jdk.desktop" { permission java.lang.RuntimePermission "accessClassInPackage.com.sun.awt"; }; + +// permissions needed by applications using java.desktop module +grant { + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.beans"; + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.beans.*"; + permission java.lang.RuntimePermission "accessClassInPackage.com.sun.java.swing.plaf.*"; + permission java.lang.RuntimePermission "accessClassInPackage.com.apple.*"; +}; diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 17ec47cc25e..12aeaade647 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -118,35 +118,6 @@ java/beans/Introspector/8132566/OverridePropertyInfoTest.java 8132565 generic-all java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 generic-all -java/beans/PropertyEditor/TestBooleanClass.java 8173082 generic-all -java/beans/PropertyEditor/TestByteClass.java 8173082 generic-all -java/beans/PropertyEditor/TestColorClass.java 8173082 generic-all -java/beans/PropertyEditor/TestDoubleClass.java 8173082 generic-all -java/beans/PropertyEditor/TestFloatClass.java 8173082 generic-all -java/beans/PropertyEditor/TestFontClass.java 8173082 generic-all -java/beans/PropertyEditor/TestIntegerClass.java 8173082 generic-all -java/beans/PropertyEditor/TestLongClass.java 8173082 generic-all -java/beans/PropertyEditor/TestShortClass.java 8173082 generic-all -java/beans/PropertyEditor/TestStringClass.java 8173082 generic-all -java/beans/XMLEncoder/Test6570354.java 8173082 generic-all -java/beans/XMLDecoder/spec/TestObject.java 8173082 macosx-all -java/beans/XMLEncoder/Test4631471.java 8173082 macosx-all -java/beans/XMLEncoder/Test4652928.java 8173082 macosx-all -java/beans/XMLEncoder/Test4903007.java 8173082 macosx-all -java/beans/XMLEncoder/Test6437265.java 8173082 macosx-all -java/beans/XMLEncoder/Test6501431.java 8173082 macosx-all -java/beans/XMLEncoder/java_awt_BorderLayout.java 8173082 macosx-all -java/beans/XMLEncoder/java_awt_CardLayout.java 8173082 macosx-all -java/beans/XMLEncoder/java_awt_GridBagLayout.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_BoxLayout.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_DefaultCellEditor.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_JButton.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_JLayeredPane.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_JSplitPane.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_JTree.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_OverlayLayout.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_border_TitledBorder.java 8173082 macosx-all -java/beans/XMLEncoder/javax_swing_plaf_BorderUIResource_TitledBorderUIResource.java 8173082 macosx-all ############################################################################ diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java index 61d07b40d58..1cf7c484f29 100644 --- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java +++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java @@ -137,8 +137,7 @@ public class CheckPackageAccess { // java.desktop module loaded by boot loader and has an openQual pkg // that is exported new Test("java.desktop", "java.applet", null, "sun.applet", - "sun.awt", "com.sun.java.swing.plaf.windows", - "javax.swing.plaf.basic"), + "sun.awt", null, "javax.swing.plaf.basic"), // java.security.jgss module loaded by platform loader new Test("java.security.jgss", "org.ietf.jgss", null, "sun.security.krb5.internal.crypto", "sun.security.krb5", diff --git a/jdk/test/sun/security/provider/PolicyFile/TokenStore.java b/jdk/test/sun/security/provider/PolicyFile/TokenStore.java index ac2d70b5e18..67c8205b1ad 100644 --- a/jdk/test/sun/security/provider/PolicyFile/TokenStore.java +++ b/jdk/test/sun/security/provider/PolicyFile/TokenStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -250,10 +250,9 @@ public class TokenStore { Enumeration perms = p.getPermissions(pd).elements(); while (perms.hasMoreElements()) { Permission perm = (Permission)perms.nextElement(); - if (!(perm instanceof AllPermission)) { - throw new SecurityException("expected AllPermission"); - } else { + if (perm instanceof AllPermission) { foundIt = true; + break; } } if (!foundIt) { From eedfb7acfdc97fb616b6bf9ab68d51fa4f4394f7 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 23 Jan 2017 14:04:44 +0100 Subject: [PATCH 154/154] 8173197: (se) WindowsSelectorImpl.c does not compile with VS2010 Reviewed-by: alanb, chegar --- .../java.base/windows/native/libnio/ch/WindowsSelectorImpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c b/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c index 4d9432845ea..c6b5fa9b368 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c +++ b/jdk/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c @@ -75,8 +75,8 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject } else if (timeout < 0) { tv = NULL; } else { - tv = &timevalue; jlong sec = timeout / 1000; + tv = &timevalue; // // struct timeval members are signed 32-bit integers so the // signed 64-bit jlong needs to be clamped