diff --git a/.hgtags b/.hgtags index 001205086b5..cc30bedcf44 100644 --- a/.hgtags +++ b/.hgtags @@ -399,3 +399,18 @@ d7034ff7f8e257e81c9f95c7785dd4eaaa3c2afc jdk-9+153 8c70d170e62c0c58b5bc3ba666bd140399b98c9c jdk-10+0 45b751afd11e6c05991cf4913c5a0ac3304fcc4e jdk-9+154 f4aff695ffe05cfdb69d8af25a4ddc6a029754ea jdk-9+155 +06bce0388880b5ff8e040e4a9d72a3ea11dac321 jdk-9+156 +fa3e76b477829afc4476f0b725cfaa440a6fd917 jdk-9+157 +b5015f742ba648184bb7fc547197bd33ebfde30d jdk-9+158 +fd1497902bbe3aa24b21f270ecdcb8de5f7aa9ac jdk-9+159 +6aa8be0c4e054fe8b3ab016ae00d16d680f92145 jdk-9+160 +f6883b1a5a6478437cd4181c4bd45328ab24feaf jdk-9+161 +d16aebbb56d37f12e0c0b0a4fb427db65e1fb1a8 jdk-9+162 +18c41483a082e097ac2f5f983c1226ed94aa4215 jdk-9+163 +32db52c675e7d5bc413605d2e89b68b608b19be0 jdk-9+164 +3965b747cfe1e6cbd66b8739da5a1ea6ec6985e9 jdk-9+165 +d3e973f1809606c67412361041ad197e50fe8cec jdk-9+166 +8fd0a4569191f33c98ee90c2709174a342fefb0d jdk-9+167 +fcabc74bd44e56c7419d111d59b95669ecb33c55 jdk-9+168 +c7efde2b60fc1ec04630be769d9ad60efb39c39c jdk-9+169 +898cbe31fbdae2d25d141384fac746cc244a730c jdk-9+170 diff --git a/corba/.hgtags b/corba/.hgtags index 7a24e3f5f23..6dde9ab35df 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -398,3 +398,17 @@ ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152 68a8e8658511093b322a46ed04b2a321e1da2a43 jdk-9+153 078ebe23b584466dc8346e620d7821d91751e5a9 jdk-9+154 a545f54babfa31aa7eb611f36031609acd617cbc jdk-9+155 +907c26240cd481579e919bfd23740797ff8ce1c8 jdk-9+156 +9383da04b385cca46b7ca67f3a39ac1b673e09fe jdk-9+157 +de6bdf38935fa753183ca288bed5c06a23c0bb12 jdk-9+158 +6feea77d2083c99e44aa3e272d07b7fb3b801683 jdk-9+159 +c7688f2fa07936b089ca0e9a0a0eff68ff37a542 jdk-9+160 +18f02bc43fe96aef36791d0df7aca748485210cc jdk-9+161 +18ffcf99a3b4a10457853d94190e825bdf07e39b jdk-9+162 +493011dee80e51c2a2b064d049183c047df36d80 jdk-9+163 +965bbae3072702f7c0d95c240523b65e6bb19261 jdk-9+164 +a510b2201154abdd12ede42788086b5283bfb9a6 jdk-9+165 +934c18145915b06d3fcc0de1a30f91f5aab8a192 jdk-9+166 +43de67f51801b9e16507865fcb7e8344f4ca4aa9 jdk-9+167 +03a2cc9c8a1e8f87924c9863e917bc8b91770d5f jdk-9+168 +b2218d41edef02ee8f94bb438f885b2ba79bfa08 jdk-9+169 diff --git a/corba/README b/corba/README deleted file mode 100644 index 56825f5ca08..00000000000 --- a/corba/README +++ /dev/null @@ -1,14 +0,0 @@ -README: - This file should be located at the top of the corba Mercurial repository. - - See http://openjdk.java.net/ for more information about the OpenJDK. - - See ../README-builds.html for complete details on build machine requirements. - -Simple Build Instructions: - - cd make && gnumake - - The files that will be imported into the jdk build will be in the "dist" - directory. - diff --git a/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html b/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html index 4a72719c0cf..f73b0cbb907 100644 --- a/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html +++ b/corba/src/java.corba/share/classes/com/sun/corba/se/spi/monitoring/package.html @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ package - -Provides the mapping of the OMG CORBA APIs to the JavaTM + +Provides the mapping of the OMG CORBA APIs to the Java™ programming language, including the class ORB, which is implemented so that a programmer can use it as a fully-functional Object Request Broker (ORB). @@ -427,7 +427,7 @@ will contain the static methods needed for manipulating instances of the type, in this case, Account objects. - +

The narrow Method

When an object is the return value for a method, it is returned in the form of a generic object, either an org.omg.CORBA.Object object @@ -465,7 +465,7 @@ tutorial uses a narrow method that looks like this: helloImpl = HelloHelper.narrow(ncRef.resolve_str(name)); - +

Example of a Basic Helper Class

A basic helper class, for purposes of this explanation, is one with the methods that are provided by every helper class, plus a narrow @@ -671,7 +671,7 @@ abstract public class AddressHelper      WStringSeqHelper      WStringValueHelper - +

Other Classes

The other classes and interfaces in the CORBA package, which are @@ -868,17 +868,17 @@ For overviews, guides, and a tutorial, please see: -

+

CORBA Features Not Implemented in Java IDL

Some of the API included in org.omg subpackages is provided for conformance with the current OMG CORBA specification but is not implemented -in Sun's release of the JDKTM. This enables +in Sun's release of the JDK™. This enables other JDK licensees to provide implementations of this API in standard extensions and products. -

+

Features That Throw NO_IMPLEMENT

Some of the API included in org.omg subpackages throw diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html b/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html index c8f6b33ae37..e0f5cbb0372 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html +++ b/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html @@ -1,8 +1,8 @@ - + - + Provides a portability layer, that is, a set of ORB APIs that makes it possible for code generated @@ -38,7 +38,7 @@ can call into these ORB APIs.

- +


CORBA Features Throwing NO_IMPLEMENT() Exceptions


diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html index c1869b1c512..7a82edb9275 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html +++ b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ package - + The CORBA_2_3 package defines additions to existing CORBA interfaces in the Java[tm] Standard Edition 6.   These changes occurred in recent revisions to the CORBA API defined by the OMG.  The new methods were @@ -46,7 +46,7 @@ the Java[tm] Platform, Standard Edition 6, ORB complies, see Official Specifications for CORBA support in Java[tm] SE 6.

- + The following methods in the abstract class org.omg.CORBA_2_3.ORB are unimplemented:

* * @since 9 + * @spec JPMS */ @CallerSensitive public static Class forName(Module module, String name) { @@ -724,18 +724,23 @@ public final class Class implements java.io.Serializable, * one or more '{@code [}' characters representing the depth of the array * nesting. The encoding of element type names is as follows: * - *
- * + * + * + * + * + * + * + * + * + * + * + *
Element Type     Encoding - *
boolean     Z - *
byte     B - *
char     C + *
+ * + * + * + * + * *
Element types and encodings
Element Type Encoding + *
boolean Z + *
byte B + *
char C *
class or interface - *     Lclassname; - *
double     D - *
float     F - *
int     I - *
long     J - *
short     S + * Lclassname; + *
double D + *
float F + *
int I + *
long J + *
short S + *
* *

The class or interface name classname is the binary name of @@ -819,6 +824,7 @@ public final class Class implements java.io.Serializable, * @return the module that this class or interface is a member of * * @since 9 + * @spec JPMS */ public Module getModule() { return module; @@ -924,6 +930,8 @@ public final class Class implements java.io.Serializable, * this method returns {@code null}. * * @return the package of this class. + * @revised 9 + * @spec JPMS */ public Package getPackage() { if (isPrimitive() || isArray()) { @@ -951,20 +959,30 @@ public final class Class implements java.io.Serializable, * declaring class} of the {@link #getEnclosingMethod enclosing method} or * {@link #getEnclosingConstructor enclosing constructor}. * - *

This method returns {@code null} if this class represents an array type, - * a primitive type or void. + *

If this class represents an array type then this method returns the + * package name of the element type. If this class represents a primitive + * type or void then the package name "{@code java.lang}" is returned. * * @return the fully qualified package name * * @since 9 + * @spec JPMS * @jls 6.7 Fully Qualified Names */ public String getPackageName() { String pn = this.packageName; - if (pn == null && !isArray() && !isPrimitive()) { - String cn = getName(); - int dot = cn.lastIndexOf('.'); - pn = (dot != -1) ? cn.substring(0, dot).intern() : ""; + if (pn == null) { + Class c = this; + while (c.isArray()) { + c = c.getComponentType(); + } + if (c.isPrimitive()) { + pn = "java.lang"; + } else { + String cn = c.getName(); + int dot = cn.lastIndexOf('.'); + pn = (dot != -1) ? cn.substring(0, dot).intern() : ""; + } this.packageName = pn; } return pn; @@ -2491,10 +2509,16 @@ public final class Class implements java.io.Serializable, * Finds a resource with a given name. * *

If this class is in a named {@link Module Module} then this method - * will attempt to find the resource in the module by means of the absolute - * resource name, subject to the rules for encapsulation specified in the - * {@code Module} {@link Module#getResourceAsStream getResourceAsStream} - * method. + * will attempt to find the resource in the module. This is done by + * delegating to the module's class loader {@link + * ClassLoader#findResource(String,String) findResource(String,String)} + * method, invoking it with the module name and the absolute name of the + * resource. Resources in named modules are subject to the rules for + * encapsulation specified in the {@code Module} {@link + * Module#getResourceAsStream getResourceAsStream} method and so this + * method returns {@code null} when the resource is a + * non-"{@code .class}" resource in a package that is not open to the + * caller's module. * *

Otherwise, if this class is not in a named module then the rules for * searching resources associated with a given class are implemented by the @@ -2503,9 +2527,8 @@ public final class Class implements java.io.Serializable, * the bootstrap class loader, the method delegates to {@link * ClassLoader#getSystemResourceAsStream}. * - *

Before finding a resource in the caller's module or delegation to a - * class loader, an absolute resource name is constructed from the given - * resource name using this algorithm: + *

Before delegation, an absolute resource name is constructed from the + * given resource name using this algorithm: * *

    * @@ -2532,27 +2555,26 @@ public final class Class implements java.io.Serializable, * least the caller module, or access to the resource is denied * by the security manager. * @throws NullPointerException If {@code name} is {@code null} + * + * @see Module#getResourceAsStream(String) * @since 1.1 + * @revised 9 + * @spec JPMS */ @CallerSensitive public InputStream getResourceAsStream(String name) { name = resolveName(name); - Module module = getModule(); - if (module.isNamed()) { - if (!ResourceHelper.isSimpleResource(name)) { - Module caller = Reflection.getCallerClass().getModule(); - if (caller != module) { - Set packages = module.getDescriptor().packages(); - String pn = ResourceHelper.getPackageName(name); - if (packages.contains(pn) && !module.isOpen(pn, caller)) { - // resource is in package not open to caller - return null; - } - } + Module thisModule = getModule(); + if (thisModule.isNamed()) { + // check if resource can be located by caller + if (Resources.canEncapsulate(name) + && !isOpenToCaller(name, Reflection.getCallerClass())) { + return null; } - String mn = module.getName(); + // resource not encapsulated or in package open to caller + String mn = thisModule.getName(); ClassLoader cl = getClassLoader0(); try { @@ -2585,10 +2607,16 @@ public final class Class implements java.io.Serializable, * Finds a resource with a given name. * *

    If this class is in a named {@link Module Module} then this method - * will attempt to find the resource in the module by means of the absolute - * resource name, subject to the rules for encapsulation specified in the - * {@code Module} {@link Module#getResourceAsStream getResourceAsStream} - * method. + * will attempt to find the resource in the module. This is done by + * delegating to the module's class loader {@link + * ClassLoader#findResource(String,String) findResource(String,String)} + * method, invoking it with the module name and the absolute name of the + * resource. Resources in named modules are subject to the rules for + * encapsulation specified in the {@code Module} {@link + * Module#getResourceAsStream getResourceAsStream} method and so this + * method returns {@code null} when the resource is a + * non-"{@code .class}" resource in a package that is not open to the + * caller's module. * *

    Otherwise, if this class is not in a named module then the rules for * searching resources associated with a given class are implemented by the @@ -2627,25 +2655,23 @@ public final class Class implements java.io.Serializable, * manager. * @throws NullPointerException If {@code name} is {@code null} * @since 1.1 + * @revised 9 + * @spec JPMS */ @CallerSensitive public URL getResource(String name) { name = resolveName(name); - Module module = getModule(); - if (module.isNamed()) { - if (!ResourceHelper.isSimpleResource(name)) { - Module caller = Reflection.getCallerClass().getModule(); - if (caller != module) { - Set packages = module.getDescriptor().packages(); - String pn = ResourceHelper.getPackageName(name); - if (packages.contains(pn) && !module.isOpen(pn, caller)) { - // resource is in package not open to caller - return null; - } - } + Module thisModule = getModule(); + if (thisModule.isNamed()) { + // check if resource can be located by caller + if (Resources.canEncapsulate(name) + && !isOpenToCaller(name, Reflection.getCallerClass())) { + return null; } - String mn = getModule().getName(); + + // resource not encapsulated or in package open to caller + String mn = thisModule.getName(); ClassLoader cl = getClassLoader0(); try { if (cl == null) { @@ -2667,10 +2693,36 @@ public final class Class implements java.io.Serializable, } } + /** + * Returns true if a resource with the given name can be located by the + * given caller. All resources in a module can be located by code in + * the module. For other callers, then the package needs to be open to + * the caller. + */ + private boolean isOpenToCaller(String name, Class caller) { + // assert getModule().isNamed(); + Module thisModule = getModule(); + Module callerModule = (caller != null) ? caller.getModule() : null; + if (callerModule != thisModule) { + String pn = Resources.toPackageName(name); + if (thisModule.getDescriptor().packages().contains(pn)) { + if (callerModule == null && !thisModule.isOpen(pn)) { + // no caller, package not open + return false; + } + if (!thisModule.isOpen(pn, callerModule)) { + // package not open to caller + return false; + } + } + } + return true; + } + + /** protection domain returned when the internal domain is null */ private static java.security.ProtectionDomain allPermDomain; - /** * Returns the {@code ProtectionDomain} of this class. If there is a * security manager installed, this method first calls the security @@ -2740,7 +2792,7 @@ public final class Class implements java.io.Serializable, * In all other cases, it requires RuntimePermission("accessDeclaredMembers") * permission. */ - final ClassLoader ccl = caller.getClassLoader0(); + final ClassLoader ccl = ClassLoader.getClassLoader(caller); if (which != Member.PUBLIC) { final ClassLoader cl = getClassLoader0(); if (ccl != cl) { diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java index fb771c29a10..fb9660f6072 100644 --- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java @@ -31,7 +31,6 @@ import java.io.UncheckedIOException; import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.lang.reflect.Module; import java.net.URL; import java.security.AccessController; import java.security.AccessControlContext; @@ -115,23 +114,29 @@ import sun.security.util.SecurityConstants; * duration of the class loading process (see {@link #loadClass * loadClass} methods). * - *

    Run-time Built-in Class Loaders

    + *

    Run-time Built-in Class Loaders

    * * The Java run-time has the following built-in class loaders: * *
      - *
    • Bootstrap class loader. + *
    • Bootstrap class loader. * It is the virtual machine's built-in class loader, typically represented * as {@code null}, and does not have a parent.

    • - *
    • {@linkplain #getPlatformClassLoader() Platform class loader}. + *
    • {@linkplain #getPlatformClassLoader() Platform class loader}. * All platform classes are visible to the platform class loader * that can be used as the parent of a {@code ClassLoader} instance. * Platform classes include Java SE platform APIs, their implementation * classes and JDK-specific run-time classes that are defined by the - * platform class loader or its ancestors.

    • - *
    • {@linkplain #getSystemClassLoader() System class loader}. - * It is also known as application class - * loader and is distinct from the platform class loader. + * platform class loader or its ancestors. + *

      To allow for upgrading/overriding of modules defined to the platform + * class loader, and where classes in the upgraded version link to + * classes in modules defined to the application class loader, the + * platform class loader may delegate to the application class loader. + * In other words, classes in named modules defined to the application + * class loader may be visible to the platform class loader.

    • + *
    • {@linkplain #getSystemClassLoader() System class loader}. + * It is also known as application class loader and is distinct + * from the platform class loader. * The system class loader is typically used to define classes on the * application class path, module path, and JDK-specific tools. * The platform class loader is a parent or an ancestor of the system class @@ -184,7 +189,7 @@ import sun.security.util.SecurityConstants; * } * * - *

      Binary names

      + *

      Binary names

      * *

      Any class name provided as a {@code String} parameter to methods in * {@code ClassLoader} must be a binary name as defined by @@ -207,6 +212,8 @@ import sun.security.util.SecurityConstants; * @jls 13.1 The Form of a Binary * @see #resolveClass(Class) * @since 1.0 + * @revised 9 + * @spec JPMS */ public abstract class ClassLoader { @@ -350,9 +357,7 @@ public abstract class ClassLoader { private ClassLoader(Void unused, String name, ClassLoader parent) { this.name = name; this.parent = parent; - this.unnamedModule - = SharedSecrets.getJavaLangReflectModuleAccess() - .defineUnnamedModule(this); + this.unnamedModule = new Module(this); if (ParallelLoaders.isRegistered(this.getClass())) { parallelLockMap = new ConcurrentHashMap<>(); package2certs = new ConcurrentHashMap<>(); @@ -369,6 +374,10 @@ public abstract class ClassLoader { * Creates a new class loader of the specified name and using the * specified parent class loader for delegation. * + * @apiNote If the parent is specified as {@code null} (for the + * bootstrap class loader) then there is no guarantee that all platform + * classes are visible. + * * @param name class loader name; or {@code null} if not named * @param parent the parent class loader * @@ -380,20 +389,23 @@ public abstract class ClassLoader { * method doesn't allow creation of a new class loader. * * @since 9 + * @spec JPMS */ protected ClassLoader(String name, ClassLoader parent) { this(checkCreateClassLoader(name), name, parent); } - /** * Creates a new class loader using the specified parent class loader for * delegation. * *

      If there is a security manager, its {@link - * SecurityManager#checkCreateClassLoader() - * checkCreateClassLoader} method is invoked. This may result in - * a security exception.

      + * SecurityManager#checkCreateClassLoader() checkCreateClassLoader} method + * is invoked. This may result in a security exception.

      + * + * @apiNote If the parent is specified as {@code null} (for the + * bootstrap class loader) then there is no guarantee that all platform + * classes are visible. * * @param parent * The parent class loader @@ -440,6 +452,7 @@ public abstract class ClassLoader { * this class loader is not named. * * @since 9 + * @spec JPMS */ public String getName() { return name; @@ -710,6 +723,7 @@ public abstract class ClassLoader { * if the class could not be found. * * @since 9 + * @spec JPMS */ protected Class findClass(String moduleName, String name) { if (moduleName == null) { @@ -834,6 +848,8 @@ public abstract class ClassLoader { * @see java.security.SecureClassLoader * * @since 1.1 + * @revised 9 + * @spec JPMS */ protected final Class defineClass(String name, byte[] b, int off, int len) throws ClassFormatError @@ -967,6 +983,9 @@ public abstract class ClassLoader { * certificates than this class, or if {@code name} begins with * "{@code java.}" and this class loader is not the platform * class loader or its ancestor. + * + * @revised 9 + * @spec JPMS */ protected final Class defineClass(String name, byte[] b, int off, int len, ProtectionDomain protectionDomain) @@ -974,7 +993,7 @@ public abstract class ClassLoader { { protectionDomain = preDefineClass(name, protectionDomain); String source = defineClassSourceLocation(protectionDomain); - Class c = defineClass1(name, b, off, len, protectionDomain, source); + Class c = defineClass1(this, name, b, off, len, protectionDomain, source); postDefineClass(c, protectionDomain); return c; } @@ -1041,6 +1060,8 @@ public abstract class ClassLoader { * @see #defineClass(String, byte[], int, int, ProtectionDomain) * * @since 1.5 + * @revised 9 + * @spec JPMS */ protected final Class defineClass(String name, java.nio.ByteBuffer b, ProtectionDomain protectionDomain) @@ -1064,17 +1085,17 @@ public abstract class ClassLoader { protectionDomain = preDefineClass(name, protectionDomain); String source = defineClassSourceLocation(protectionDomain); - Class c = defineClass2(name, b, b.position(), len, protectionDomain, source); + Class c = defineClass2(this, name, b, b.position(), len, protectionDomain, source); postDefineClass(c, protectionDomain); return c; } - private native Class defineClass1(String name, byte[] b, int off, int len, - ProtectionDomain pd, String source); + static native Class defineClass1(ClassLoader loader, String name, byte[] b, int off, int len, + ProtectionDomain pd, String source); - private native Class defineClass2(String name, java.nio.ByteBuffer b, - int off, int len, ProtectionDomain pd, - String source); + static native Class defineClass2(ClassLoader loader, String name, java.nio.ByteBuffer b, + int off, int len, ProtectionDomain pd, + String source); // true if the name is null or has the potential to be a valid binary name private boolean checkName(String name) { @@ -1264,11 +1285,11 @@ public abstract class ClassLoader { * Class loader implementations that support the loading from modules * should override this method. * - * @apiNote This method is the basis for the {@code Class} {@link - * Class#getResource getResource} and {@link Class#getResourceAsStream - * getResourceAsStream} methods. It is not subject to the rules for - * encapsulation specified by {@code Module} {@link - * Module#getResourceAsStream getResourceAsStream}. + * @apiNote This method is the basis for the {@link + * Class#getResource Class.getResource}, {@link Class#getResourceAsStream + * Class.getResourceAsStream}, and {@link Module#getResourceAsStream + * Module.getResourceAsStream} methods. It is not subject to the rules for + * encapsulation specified by {@code Module.getResourceAsStream}. * * @implSpec The default implementation attempts to find the resource by * invoking {@link #findResource(String)} when the {@code moduleName} is @@ -1292,6 +1313,7 @@ public abstract class ClassLoader { * * @see java.lang.module.ModuleReader#find(String) * @since 9 + * @spec JPMS */ protected URL findResource(String moduleName, String name) throws IOException { if (moduleName == null) { @@ -1342,6 +1364,8 @@ public abstract class ClassLoader { * @throws NullPointerException If {@code name} is {@code null} * * @since 1.1 + * @revised 9 + * @spec JPMS */ public URL getResource(String name) { Objects.requireNonNull(name); @@ -1403,6 +1427,8 @@ public abstract class ClassLoader { * @see #findResources(String) * * @since 1.2 + * @revised 9 + * @spec JPMS */ public Enumeration getResources(String name) throws IOException { Objects.requireNonNull(name); @@ -1499,6 +1525,8 @@ public abstract class ClassLoader { * denied by the security manager. * * @since 1.2 + * @revised 9 + * @spec JPMS */ protected URL findResource(String name) { return null; @@ -1531,6 +1559,8 @@ public abstract class ClassLoader { * If I/O errors occur * * @since 1.2 + * @revised 9 + * @spec JPMS */ protected Enumeration findResources(String name) throws IOException { return Collections.emptyEnumeration(); @@ -1601,6 +1631,8 @@ public abstract class ClassLoader { * denied by the security manager. * * @since 1.1 + * @revised 9 + * @spec JPMS */ public static URL getSystemResource(String name) { return getSystemClassLoader().getResource(name); @@ -1636,6 +1668,8 @@ public abstract class ClassLoader { * If I/O errors occur * * @since 1.2 + * @revised 9 + * @spec JPMS */ public static Enumeration getSystemResources(String name) throws IOException @@ -1667,6 +1701,8 @@ public abstract class ClassLoader { * @throws NullPointerException If {@code name} is {@code null} * * @since 1.1 + * @revised 9 + * @spec JPMS */ public InputStream getResourceAsStream(String name) { Objects.requireNonNull(name); @@ -1699,6 +1735,8 @@ public abstract class ClassLoader { * denied by the security manager. * * @since 1.1 + * @revised 9 + * @spec JPMS */ public static InputStream getSystemResourceAsStream(String name) { URL url = getSystemResource(name); @@ -1749,6 +1787,7 @@ public abstract class ClassLoader { * * @see Module#isNamed() * @since 9 + * @spec JPMS */ public final Module getUnnamedModule() { return unnamedModule; @@ -1772,6 +1811,7 @@ public abstract class ClassLoader { * {@link RuntimePermission}{@code ("getClassLoader")} * * @since 9 + * @spec JPMS */ @CallerSensitive public static ClassLoader getPlatformClassLoader() { @@ -1847,6 +1887,8 @@ public abstract class ClassLoader { * {@link Throwable#getCause()} method. * * @revised 1.4 + * @revised 9 + * @spec JPMS */ @CallerSensitive public static ClassLoader getSystemClassLoader() { @@ -2101,6 +2143,8 @@ public abstract class ClassLoader { * defined by this class loader * * @since 1.2 + * @revised 9 + * @spec JPMS * * @see * The JAR File Specification: Package Versioning @@ -2138,6 +2182,7 @@ public abstract class ClassLoader { * if {@code name} is {@code null}. * * @since 9 + * @spec JPMS */ public final Package getDefinedPackage(String name) { Objects.requireNonNull(name, "name cannot be null"); @@ -2160,6 +2205,7 @@ public abstract class ClassLoader { * or an zero length array if no package has been defined by this class loader. * * @since 9 + * @spec JPMS */ public final Package[] getDefinedPackages() { return packages().toArray(Package[]::new); @@ -2173,6 +2219,12 @@ public abstract class ClassLoader { * this class loader are searched recursively (parent by parent) * for a {@code Package} of the given name. * + * @apiNote The {@link #getPlatformClassLoader() platform class loader} + * may delegate to the application class loader but the application class + * loader is not its ancestor. When invoked on the platform class loader, + * this method will not find packages defined to the application + * class loader. + * * @param name * The package name * @@ -2196,6 +2248,8 @@ public abstract class ClassLoader { * a {@code Package} for the specified class loader. * * @since 1.2 + * @revised 9 + * @spec JPMS */ @Deprecated(since="9") protected Package getPackage(String name) { @@ -2216,10 +2270,20 @@ public abstract class ClassLoader { * {@code Package} object of the same package name, each defined by * a different class loader in the class loader hierarchy. * + * @apiNote The {@link #getPlatformClassLoader() platform class loader} + * may delegate to the application class loader. In other words, + * packages in modules defined to the application class loader may be + * visible to the platform class loader. On the other hand, + * the application class loader is not its ancestor and hence + * when invoked on the platform class loader, this method will not + * return any packages defined to the application class loader. + * * @return The array of {@code Package} objects defined by this * class loader and its ancestors * * @since 1.2 + * @revised 9 + * @spec JPMS */ protected Package[] getPackages() { Stream pkgs = packages(); @@ -2308,6 +2372,7 @@ public abstract class ClassLoader { this.isBuiltin = isBuiltin; } + @SuppressWarnings("deprecation") protected void finalize() { synchronized (loadedLibraryNames) { if (fromClass.getClassLoader() != null && loaded) { diff --git a/jdk/src/java.base/share/classes/java/lang/Comparable.java b/jdk/src/java.base/share/classes/java/lang/Comparable.java index ff8892caacf..f9be4c440ca 100644 --- a/jdk/src/java.base/share/classes/java/lang/Comparable.java +++ b/jdk/src/java.base/share/classes/java/lang/Comparable.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 @@ -84,7 +84,7 @@ import java.util.*; * {(x, y) such that x.equals(y)}.

      * * This interface is a member of the - * + * * Java Collections Framework. * * @param the type of objects that this object may be compared to @@ -124,7 +124,7 @@ public interface Comparable { * {@code sgn(}expression{@code )} designates the mathematical * signum function, which is defined to return one of {@code -1}, * {@code 0}, or {@code 1} according to whether the value of - * expression is negative, zero or positive. + * expression is negative, zero, or positive, respectively. * * @param o the object to be compared. * @return a negative integer, zero, or a positive integer as this object diff --git a/jdk/src/java.base/share/classes/java/lang/Double.java b/jdk/src/java.base/share/classes/java/lang/Double.java index 75a227e5282..a7aa0a0f626 100644 --- a/jdk/src/java.base/share/classes/java/lang/Double.java +++ b/jdk/src/java.base/share/classes/java/lang/Double.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 @@ -255,9 +255,12 @@ public final class Double extends Number implements Comparable { * *

    * - * + *
    * + * * + * + * * * * @@ -272,6 +275,7 @@ public final class Double extends Number implements Comparable { * * * + * *
    Examples
    Floating-point ValueHexadecimal String
    {@code 1.0} {@code 0x1.0p0}
    {@code -1.0} {@code -0x1.0p0}
    {@code 2.0} {@code 0x1.0p1}{@code 0x0.fffffffffffffp-1022}
    {@code Double.MIN_VALUE}{@code 0x0.0000000000001p-1022}
    * @param d the {@code double} to be converted. * @return a hex string representation of the argument. diff --git a/jdk/src/java.base/share/classes/java/lang/Enum.java b/jdk/src/java.base/share/classes/java/lang/Enum.java index 9a98f30bbbd..ac912f5ca65 100644 --- a/jdk/src/java.base/share/classes/java/lang/Enum.java +++ b/jdk/src/java.base/share/classes/java/lang/Enum.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, 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 @@ -243,6 +243,7 @@ public abstract class Enum> /** * enum classes cannot have finalize methods. */ + @SuppressWarnings("deprecation") protected final void finalize() { } /** diff --git a/jdk/src/java.base/share/classes/java/lang/Float.java b/jdk/src/java.base/share/classes/java/lang/Float.java index 60e08db7ad5..77c1d1671d5 100644 --- a/jdk/src/java.base/share/classes/java/lang/Float.java +++ b/jdk/src/java.base/share/classes/java/lang/Float.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 @@ -256,9 +256,12 @@ public final class Float extends Number implements Comparable { * *
* - * + *
* + * * + * + * * * * @@ -273,6 +276,7 @@ public final class Float extends Number implements Comparable { * * * + * *
Examples
Floating-point ValueHexadecimal String
{@code 1.0} {@code 0x1.0p0}
{@code -1.0} {@code -0x1.0p0}
{@code 2.0} {@code 0x1.0p1}{@code 0x0.fffffep-126}
{@code Float.MIN_VALUE}{@code 0x0.000002p-126}
* @param f the {@code float} to be converted. * @return a hex string representation of the argument. diff --git a/jdk/src/java.base/share/classes/java/lang/IllegalCallerException.java b/jdk/src/java.base/share/classes/java/lang/IllegalCallerException.java new file mode 100644 index 00000000000..f882fb21591 --- /dev/null +++ b/jdk/src/java.base/share/classes/java/lang/IllegalCallerException.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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that a method has been called by an inappropriate caller. + * + * @since 9 + * @spec JPMS + * @see StackWalker#getCallerClass + */ +public class IllegalCallerException extends RuntimeException { + /** + * Constructs an IllegalCallerException with no detail message. + */ + public IllegalCallerException() { + super(); + } + + /** + * Constructs an IllegalCallerException with the specified detail + * message. + * + * @param s the String that contains a detailed message (can be null) + */ + public IllegalCallerException(String s) { + super(s); + } + + /** + * Constructs a new exception with the specified detail message and + * cause. + * + * @param message the detail message (can be null) + * @param cause the cause (can be null) + */ + public IllegalCallerException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of {@code (cause==null ? null : cause.toString())} (which + * typically contains the class and detail message of {@code cause}). + * + * @param cause the cause (can be null) + */ + public IllegalCallerException(Throwable cause) { + super(cause); + } + + static final long serialVersionUID = -2349421918363102232L; +} diff --git a/jdk/src/java.base/share/classes/java/lang/Integer.java b/jdk/src/java.base/share/classes/java/lang/Integer.java index 8164b20d77e..685d77c8968 100644 --- a/jdk/src/java.base/share/classes/java/lang/Integer.java +++ b/jdk/src/java.base/share/classes/java/lang/Integer.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 @@ -386,7 +386,7 @@ public final class Integer extends Number implements Comparable { } /** byte[]/UTF16 version */ - static void formatUnsignedIntUTF16(int val, int shift, byte[] buf, int offset, int len) { + private static void formatUnsignedIntUTF16(int val, int shift, byte[] buf, int offset, int len) { int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; @@ -442,7 +442,7 @@ public final class Integer extends Number implements Comparable { return new String(buf, LATIN1); } else { byte[] buf = new byte[size * 2]; - getCharsUTF16(i, size, buf); + StringUTF16.getChars(i, size, buf); return new String(buf, UTF16); } } @@ -516,49 +516,6 @@ public final class Integer extends Number implements Comparable { return charPos; } - /** - * This is a variant of {@link #getChars(int, int, byte[])}, but for - * UTF-16 coder. - * - * @param i value to convert - * @param index next index, after the least significant digit - * @param buf target buffer, UTF16-coded. - * @return index of the most significant digit or minus sign, if present - */ - static int getCharsUTF16(int i, int index, byte[] buf) { - int q, r; - int charPos = index; - - boolean negative = (i < 0); - if (!negative) { - i = -i; - } - - // Get 2 digits/iteration using ints - while (i <= -100) { - q = i / 100; - r = (q * 100) - i; - i = q; - StringUTF16.putChar(buf, --charPos, DigitOnes[r]); - StringUTF16.putChar(buf, --charPos, DigitTens[r]); - } - - // We know there are at most two digits left at this point. - q = i / 10; - r = (q * 10) - i; - StringUTF16.putChar(buf, --charPos, '0' + r); - - // Whatever left is the remaining digit. - if (q < 0) { - StringUTF16.putChar(buf, --charPos, '0' - q); - } - - if (negative) { - StringUTF16.putChar(buf, --charPos, '-'); - } - return charPos; - } - // Left here for compatibility reasons, see JDK-8143900. static final int [] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE }; diff --git a/jdk/src/java.base/share/classes/java/lang/Iterable.java b/jdk/src/java.base/share/classes/java/lang/Iterable.java index 89059022905..a58faa4b250 100644 --- a/jdk/src/java.base/share/classes/java/lang/Iterable.java +++ b/jdk/src/java.base/share/classes/java/lang/Iterable.java @@ -31,16 +31,13 @@ import java.util.Spliterators; import java.util.function.Consumer; /** - * Implementing this interface allows an object to be the target of - * the "for-each loop" statement. See - * - * For-each Loop - * + * Implementing this interface allows an object to be the target of the enhanced + * {@code for} statement (sometimes called the "for-each loop" statement). * * @param the type of elements returned by the iterator * * @since 1.5 - * @jls 14.14.2 The enhanced for statement + * @jls 14.14.2 The enhanced {@code for} statement */ public interface Iterable { /** diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java b/jdk/src/java.base/share/classes/java/lang/LayerInstantiationException.java similarity index 92% rename from jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java rename to jdk/src/java.base/share/classes/java/lang/LayerInstantiationException.java index ff61c41590f..4c64fe071a8 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/LayerInstantiationException.java +++ b/jdk/src/java.base/share/classes/java/lang/LayerInstantiationException.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,14 +23,14 @@ * questions. */ -package java.lang.reflect; +package java.lang; /** - * Thrown when creating a Layer fails. - * - * @see Layer + * Thrown when creating a {@linkplain ModuleLayer module layer} fails. * + * @see ModuleLayer * @since 9 + * @spec JPMS */ public class LayerInstantiationException extends RuntimeException { private static final long serialVersionUID = -906239691613568347L; diff --git a/jdk/src/java.base/share/classes/java/lang/LiveStackFrame.java b/jdk/src/java.base/share/classes/java/lang/LiveStackFrame.java index 5be48729d5a..13dfa34be8f 100644 --- a/jdk/src/java.base/share/classes/java/lang/LiveStackFrame.java +++ b/jdk/src/java.base/share/classes/java/lang/LiveStackFrame.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 @@ -55,14 +55,36 @@ interface LiveStackFrame extends StackFrame { * *

A single local variable can hold a value of type boolean, byte, char, * short, int, float, reference or returnAddress. A pair of local variables - * can hold a value of type long or double. In other words, - * a value of type long or type double occupies two consecutive local - * variables. For a value of primitive type, the element in the - * local variable array is an {@link PrimitiveValue} object; - * otherwise, the element is an {@code Object}. + * can hold a value of type long or double (JVMS section 2.6.1). Primitive + * locals are represented in the returned array as {@code PrimitiveSlot}s, + * with longs and doubles occupying a pair of consecutive + * {@code PrimitiveSlot}s. * - *

The returned array may contain null entries if a local variable is not - * live. + *

The current VM implementation does not provide specific type + * information for primitive locals. This method simply returns the raw + * contents of the VM's primitive locals on a best-effort basis, without + * indicating a specific type. + * + *

The returned array may contain null entries for local variables that + * are not live. + * + * @implNote + *

The specific subclass of {@code PrimitiveSlot} will reflect the + * underlying architecture, and will be either {@code PrimitiveSlot32} or + * {@code PrimitiveSlot64}. + * + *

How a long or double value is stored in the pair of + * {@code PrimitiveSlot}s can vary based on the underlying architecture and + * VM implementation. On 32-bit architectures, long/double values are split + * between the two {@code PrimitiveSlot32}s. + * On 64-bit architectures, the entire value may be stored in one of the + * {@code PrimitiveSlot64}s, with the other {@code PrimitiveSlot64} being + * unused. + * + *

The contents of the unused, high-order portion of a + * {@code PrimitiveSlot64} (when storing a primitive other than a long or + * double) is unspecified. In particular, the unused bits are not + * necessarily zeroed out. * * @return the local variable array of this stack frame. */ @@ -78,7 +100,7 @@ interface LiveStackFrame extends StackFrame { *

Each entry on the operand stack can hold a value of any Java Virtual * Machine Type. * For a value of primitive type, the element in the returned array is - * an {@link PrimitiveValue} object; otherwise, the element is the {@code Object} + * a {@link PrimitiveSlot} object; otherwise, the element is the {@code Object} * on the operand stack. * * @return the operand stack of this stack frame. @@ -87,107 +109,37 @@ interface LiveStackFrame extends StackFrame { /** * UNSUPPORTED This interface is intended to be package-private - * or move to an internal package.

+ * or moved to an internal package.

* - * Represents a local variable or an entry on the operand whose value is + * Represents a local variable or an entry on the operand stack whose value is * of primitive type. */ - public abstract class PrimitiveValue { + public abstract class PrimitiveSlot { /** - * Returns the base type of this primitive value, one of - * {@code B, D, C, F, I, J, S, Z}. - * - * @return Name of a base type - * @jvms table 4.3-A + * Returns the size, in bytes, of the slot. */ - abstract char type(); + public abstract int size(); /** - * Returns the boolean value if this primitive value is of type boolean. - * @return the boolean value if this primitive value is of type boolean. + * Returns the int value if this primitive value is of size 4 + * @return the int value if this primitive value is of size 4 * * @throws UnsupportedOperationException if this primitive value is not - * of type boolean. - */ - public boolean booleanValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); - } - - /** - * Returns the int value if this primitive value is of type int. - * @return the int value if this primitive value is of type int. - * - * @throws UnsupportedOperationException if this primitive value is not - * of type int. + * of size 4. */ public int intValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); + throw new UnsupportedOperationException("this " + size() + "-byte primitive"); } /** - * Returns the long value if this primitive value is of type long. - * @return the long value if this primitive value is of type long. + * Returns the long value if this primitive value is of size 8 + * @return the long value if this primitive value is of size 8 * * @throws UnsupportedOperationException if this primitive value is not - * of type long. + * of size 8. */ public long longValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); - } - - /** - * Returns the char value if this primitive value is of type char. - * @return the char value if this primitive value is of type char. - * - * @throws UnsupportedOperationException if this primitive value is not - * of type char. - */ - public char charValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); - } - - /** - * Returns the byte value if this primitive value is of type byte. - * @return the byte value if this primitive value is of type byte. - * - * @throws UnsupportedOperationException if this primitive value is not - * of type byte. - */ - public byte byteValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); - } - - /** - * Returns the short value if this primitive value is of type short. - * @return the short value if this primitive value is of type short. - * - * @throws UnsupportedOperationException if this primitive value is not - * of type short. - */ - public short shortValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); - } - - /** - * Returns the float value if this primitive value is of type float. - * @return the float value if this primitive value is of type float. - * - * @throws UnsupportedOperationException if this primitive value is not - * of type float. - */ - public float floatValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); - } - - /** - * Returns the double value if this primitive value is of type double. - * @return the double value if this primitive value is of type double. - * - * @throws UnsupportedOperationException if this primitive value is not - * of type double. - */ - public double doubleValue() { - throw new UnsupportedOperationException("this primitive of type " + type()); + throw new UnsupportedOperationException("this " + size() + "-byte primitive"); } } @@ -217,7 +169,7 @@ interface LiveStackFrame extends StackFrame { * it denies access to {@code RuntimePermission("liveStackFrames")}; or * or if the given {@code options} contains * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE} - * and it denies access to {@code StackFramePermission("retainClassReference")}. + * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}. */ public static StackWalker getStackWalker(Set options) { SecurityManager sm = System.getSecurityManager(); diff --git a/jdk/src/java.base/share/classes/java/lang/LiveStackFrameInfo.java b/jdk/src/java.base/share/classes/java/lang/LiveStackFrameInfo.java index db8901ea731..b6583adf559 100644 --- a/jdk/src/java.base/share/classes/java/lang/LiveStackFrameInfo.java +++ b/jdk/src/java.base/share/classes/java/lang/LiveStackFrameInfo.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,15 +24,13 @@ */ package java.lang; -import java.lang.StackWalker.Option; -import java.util.EnumSet; -import java.util.Set; - -import static java.lang.StackWalker.ExtendedOption.*; - final class LiveStackFrameInfo extends StackFrameInfo implements LiveStackFrame { private static Object[] EMPTY_ARRAY = new Object[0]; + // These flags must match the values maintained in the VM + private static final int MODE_INTERPRETED = 0x01; + private static final int MODE_COMPILED = 0x02; + LiveStackFrameInfo(StackWalker walker) { super(walker); } @@ -41,6 +39,7 @@ final class LiveStackFrameInfo extends StackFrameInfo implements LiveStackFrame private Object[] monitors = EMPTY_ARRAY; private Object[] locals = EMPTY_ARRAY; private Object[] operands = EMPTY_ARRAY; + private int mode = 0; @Override public Object[] getMonitors() { @@ -57,51 +56,44 @@ final class LiveStackFrameInfo extends StackFrameInfo implements LiveStackFrame return operands; } + @Override + public String toString() { + StringBuilder retVal = new StringBuilder(super.toString()); + if (mode != 0) { + retVal.append("("); + if ((mode & MODE_INTERPRETED) == MODE_INTERPRETED) { + retVal.append(" interpreted "); + } + if ((mode & MODE_COMPILED) == MODE_COMPILED) { + retVal.append(" compiled "); + } + retVal.append(")"); + } + return retVal.toString(); + } + /* - * Convert primitive value to {@code Primitive} object to represent + * Convert primitive value to {@code PrimitiveSlot} object to represent * a local variable or an element on the operand stack of primitive type. */ - static PrimitiveValue asPrimitive(boolean value) { - return new BooleanPrimitive(value); + + static PrimitiveSlot asPrimitive(int value) { + return new PrimitiveSlot32(value); } - static PrimitiveValue asPrimitive(int value) { - return new IntPrimitive(value); + static PrimitiveSlot asPrimitive(long value) { + return new PrimitiveSlot64(value); } - static PrimitiveValue asPrimitive(short value) { - return new ShortPrimitive(value); - } - - static PrimitiveValue asPrimitive(char value) { - return new CharPrimitive(value); - } - - static PrimitiveValue asPrimitive(byte value) { - return new BytePrimitive(value); - } - - static PrimitiveValue asPrimitive(long value) { - return new LongPrimitive(value); - } - - static PrimitiveValue asPrimitive(float value) { - return new FloatPrimitive(value); - } - - static PrimitiveValue asPrimitive(double value) { - return new DoublePrimitive(value); - } - - private static class IntPrimitive extends PrimitiveValue { + private static class PrimitiveSlot32 extends PrimitiveSlot { final int value; - IntPrimitive(int value) { + PrimitiveSlot32(int value) { this.value = value; } @Override - public char type() { - return 'I'; + public int size() { + return 4; } @Override @@ -115,103 +107,15 @@ final class LiveStackFrameInfo extends StackFrameInfo implements LiveStackFrame } } - private static class ShortPrimitive extends PrimitiveValue { - final short value; - ShortPrimitive(short value) { - this.value = value; - } - - @Override - public char type() { - return 'S'; - } - - @Override - public short shortValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } - - private static class BooleanPrimitive extends PrimitiveValue { - final boolean value; - BooleanPrimitive(boolean value) { - this.value = value; - } - - @Override - public char type() { - return 'Z'; - } - - @Override - public boolean booleanValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } - - private static class CharPrimitive extends PrimitiveValue { - final char value; - CharPrimitive(char value) { - this.value = value; - } - - @Override - public char type() { - return 'C'; - } - - @Override - public char charValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } - - private static class BytePrimitive extends PrimitiveValue { - final byte value; - BytePrimitive(byte value) { - this.value = value; - } - - @Override - public char type() { - return 'B'; - } - - @Override - public byte byteValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } - - private static class LongPrimitive extends PrimitiveValue { + private static class PrimitiveSlot64 extends PrimitiveSlot { final long value; - LongPrimitive(long value) { + PrimitiveSlot64(long value) { this.value = value; } @Override - public char type() { - return 'J'; + public int size() { + return 8; } @Override @@ -224,48 +128,4 @@ final class LiveStackFrameInfo extends StackFrameInfo implements LiveStackFrame return String.valueOf(value); } } - - private static class FloatPrimitive extends PrimitiveValue { - final float value; - FloatPrimitive(float value) { - this.value = value; - } - - @Override - public char type() { - return 'F'; - } - - @Override - public float floatValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } - - private static class DoublePrimitive extends PrimitiveValue { - final double value; - DoublePrimitive(double value) { - this.value = value; - } - - @Override - public char type() { - return 'D'; - } - - @Override - public double doubleValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } } diff --git a/jdk/src/java.base/share/classes/java/lang/Long.java b/jdk/src/java.base/share/classes/java/lang/Long.java index 103389c99fe..9d298cae439 100644 --- a/jdk/src/java.base/share/classes/java/lang/Long.java +++ b/jdk/src/java.base/share/classes/java/lang/Long.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 @@ -414,7 +414,7 @@ public final class Long extends Number implements Comparable { } /** byte[]/UTF16 version */ - static void formatUnsignedLong0UTF16(long val, int shift, byte[] buf, int offset, int len) { + private static void formatUnsignedLong0UTF16(long val, int shift, byte[] buf, int offset, int len) { int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; @@ -475,7 +475,7 @@ public final class Long extends Number implements Comparable { return new String(buf, LATIN1); } else { byte[] buf = new byte[size * 2]; - getCharsUTF16(i, size, buf); + StringUTF16.getChars(i, size, buf); return new String(buf, UTF16); } } @@ -561,61 +561,6 @@ public final class Long extends Number implements Comparable { return charPos; } - /** - * This is a variant of {@link #getChars(long, int, byte[])}, but for - * UTF-16 coder. - * - * @param i value to convert - * @param index next index, after the least significant digit - * @param buf target buffer, UTF16-coded. - * @return index of the most significant digit or minus sign, if present - */ - static int getCharsUTF16(long i, int index, byte[] buf) { - long q; - int r; - int charPos = index; - - boolean negative = (i < 0); - if (!negative) { - i = -i; - } - - // Get 2 digits/iteration using longs until quotient fits into an int - while (i <= Integer.MIN_VALUE) { - q = i / 100; - r = (int)((q * 100) - i); - i = q; - StringUTF16.putChar(buf, --charPos, Integer.DigitOnes[r]); - StringUTF16.putChar(buf, --charPos, Integer.DigitTens[r]); - } - - // Get 2 digits/iteration using ints - int q2; - int i2 = (int)i; - while (i2 <= -100) { - q2 = i2 / 100; - r = (q2 * 100) - i2; - i2 = q2; - StringUTF16.putChar(buf, --charPos, Integer.DigitOnes[r]); - StringUTF16.putChar(buf, --charPos, Integer.DigitTens[r]); - } - - // We know there are at most two digits left at this point. - q2 = i2 / 10; - r = (q2 * 10) - i2; - StringUTF16.putChar(buf, --charPos, '0' + r); - - // Whatever left is the remaining digit. - if (q2 < 0) { - StringUTF16.putChar(buf, --charPos, '0' - q2); - } - - if (negative) { - StringUTF16.putChar(buf, --charPos, '-'); - } - return charPos; - } - /** * Returns the string representation size for a given long value. * diff --git a/jdk/src/java.base/share/classes/java/lang/Math.java b/jdk/src/java.base/share/classes/java/lang/Math.java index 911267d5956..40e8926e052 100644 --- a/jdk/src/java.base/share/classes/java/lang/Math.java +++ b/jdk/src/java.base/share/classes/java/lang/Math.java @@ -1079,6 +1079,7 @@ public final class Math { * @param x the first value * @param y the second value * @return the result + * @since 9 */ public static long multiplyFull(int x, int y) { return (long)x * (long)y; @@ -1091,6 +1092,7 @@ public final class Math { * @param x the first value * @param y the second value * @return the result + * @since 9 */ public static long multiplyHigh(long x, long y) { if (x < 0 || y < 0) { @@ -1275,7 +1277,7 @@ public final class Math { } /** - * Returns the floor modulus of the {@code long} and {@int} arguments. + * Returns the floor modulus of the {@code long} and {@code int} arguments. *

* The floor modulus is {@code x - (floorDiv(x, y) * y)}, * has the same sign as the divisor {@code y}, and diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java b/jdk/src/java.base/share/classes/java/lang/Module.java similarity index 75% rename from jdk/src/java.base/share/classes/java/lang/reflect/Module.java rename to jdk/src/java.base/share/classes/java/lang/Module.java index 5134b64caf8..f6ab49b4519 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/Module.java +++ b/jdk/src/java.base/share/classes/java/lang/Module.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 @@ -23,7 +23,7 @@ * questions. */ -package java.lang.reflect; +package java.lang; import java.io.IOException; import java.io.InputStream; @@ -35,6 +35,7 @@ import java.lang.module.ModuleDescriptor.Exports; import java.lang.module.ModuleDescriptor.Opens; import java.lang.module.ModuleDescriptor.Version; import java.lang.module.ResolvedModule; +import java.lang.reflect.AnnotatedElement; import java.net.URI; import java.net.URL; import java.security.AccessController; @@ -42,21 +43,23 @@ import java.security.PrivilegedAction; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; +import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.internal.loader.BuiltinClassLoader; import jdk.internal.loader.BootLoader; -import jdk.internal.loader.ResourceHelper; import jdk.internal.misc.JavaLangAccess; -import jdk.internal.misc.JavaLangReflectModuleAccess; import jdk.internal.misc.SharedSecrets; +import jdk.internal.module.ModuleLoaderMap; import jdk.internal.module.ServicesCatalog; +import jdk.internal.module.Resources; import jdk.internal.org.objectweb.asm.AnnotationVisitor; import jdk.internal.org.objectweb.asm.Attribute; import jdk.internal.org.objectweb.asm.ClassReader; @@ -72,18 +75,17 @@ import sun.security.util.SecurityConstants; * *

Named modules have a {@link #getName() name} and are constructed by the * Java Virtual Machine when a graph of modules is defined to the Java virtual - * machine to create a module {@link Layer Layer}.

+ * machine to create a {@linkplain ModuleLayer module layer}.

* - *

An unnamed module does not have a name. There is an unnamed module - * per {@link ClassLoader ClassLoader} that is obtained by invoking the class - * loader's {@link ClassLoader#getUnnamedModule() getUnnamedModule} method. The - * {@link Class#getModule() getModule} method of all types defined by a class - * loader that are not in a named module return the class loader's unnamed + *

An unnamed module does not have a name. There is an unnamed module for + * each {@link ClassLoader ClassLoader}, obtained by invoking its {@link + * ClassLoader#getUnnamedModule() getUnnamedModule} method. All types that are + * not in a named module are members of their defining class loader's unnamed * module.

* *

The package names that are parameters or returned by methods defined in * this class are the fully-qualified names of the packages as defined in - * section 6.5.3 of The Java™ Language Specification , for + * section 6.5.3 of The Java™ Language Specification, for * example, {@code "java.lang"}.

* *

Unless otherwise specified, passing a {@code null} argument to a method @@ -91,13 +93,14 @@ import sun.security.util.SecurityConstants; * be thrown.

* * @since 9 - * @see java.lang.Class#getModule + * @spec JPMS + * @see Class#getModule() */ public final class Module implements AnnotatedElement { // the layer that contains this module, can be null - private final Layer layer; + private final ModuleLayer layer; // module name and loader, these fields are read by VM private final String name; @@ -112,10 +115,10 @@ public final class Module implements AnnotatedElement { * VM but will not read any other modules, will not have any exports setup * and will not be registered in the service catalog. */ - private Module(Layer layer, - ClassLoader loader, - ModuleDescriptor descriptor, - URI uri) + Module(ModuleLayer layer, + ClassLoader loader, + ModuleDescriptor descriptor, + URI uri) { this.layer = layer; this.name = descriptor.name(); @@ -138,7 +141,7 @@ public final class Module implements AnnotatedElement { * * @see ClassLoader#getUnnamedModule */ - private Module(ClassLoader loader) { + Module(ClassLoader loader) { this.layer = null; this.name = null; this.loader = loader; @@ -213,32 +216,31 @@ public final class Module implements AnnotatedElement { } /** - * Returns the layer that contains this module or {@code null} if this - * module is not in a layer. + * Returns the module layer that contains this module or {@code null} if + * this module is not in a module layer. * - * A module {@code Layer} contains named modules and therefore this - * method always returns {@code null} when invoked on an unnamed module. + * A module layer contains named modules and therefore this method always + * returns {@code null} when invoked on an unnamed module. * - *

Dynamic modules are named - * modules that are generated at runtime. A dynamic module may or may - * not be in a module Layer.

+ *

Dynamic modules are + * named modules that are generated at runtime. A dynamic module may or may + * not be in a module layer.

* - * @return The layer that contains this module + * @return The module layer that contains this module * - * @see Proxy + * @see java.lang.reflect.Proxy */ - public Layer getLayer() { + public ModuleLayer getLayer() { if (isNamed()) { - Layer layer = this.layer; + ModuleLayer layer = this.layer; if (layer != null) return layer; - // special-case java.base as it is created before the boot Layer + // special-case java.base as it is created before the boot layer if (loader == null && name.equals("java.base")) { - return SharedSecrets.getJavaLangAccess().getBootLayer(); + return ModuleLayer.boot(); } } - return null; } @@ -327,8 +329,9 @@ public final class Module implements AnnotatedElement { * * @return this module * - * @throws IllegalStateException - * If this is a named module and the caller is not this module + * @throws IllegalCallerException + * If this is a named module and the caller's module is not this + * module * * @see #canRead */ @@ -336,9 +339,9 @@ public final class Module implements AnnotatedElement { public Module addReads(Module other) { Objects.requireNonNull(other); if (this.isNamed()) { - Module caller = Reflection.getCallerClass().getModule(); + Module caller = getCallerModule(Reflection.getCallerClass()); if (caller != this) { - throw new IllegalStateException(caller + " != " + this); + throw new IllegalCallerException(caller + " != " + this); } implAddReads(other, true); } @@ -348,12 +351,21 @@ public final class Module implements AnnotatedElement { /** * Updates this module to read another module. * - * @apiNote This method is for Proxy use and white-box testing. + * @apiNote Used by the --add-reads command line option. */ void implAddReads(Module other) { implAddReads(other, true); } + /** + * Updates this module to read all unnamed modules. + * + * @apiNote Used by the --add-reads command line option. + */ + void implAddReadsAllUnnamed() { + implAddReads(Module.ALL_UNNAMED_MODULE, true); + } + /** * Updates this module to read another module without notifying the VM. * @@ -370,27 +382,19 @@ public final class Module implements AnnotatedElement { */ private void implAddReads(Module other, boolean syncVM) { Objects.requireNonNull(other); - - // nothing to do - if (other == this || !this.isNamed()) - return; - - // check if we already read this module - Set reads = this.reads; - if (reads != null && reads.contains(other)) - return; - - // update VM first, just in case it fails - if (syncVM) { - if (other == ALL_UNNAMED_MODULE) { - addReads0(this, null); - } else { - addReads0(this, other); + if (!canRead(other)) { + // update VM first, just in case it fails + if (syncVM) { + if (other == ALL_UNNAMED_MODULE) { + addReads0(this, null); + } else { + addReads0(this, other); + } } - } - // add reflective read - reflectivelyReads.putIfAbsent(this, other, Boolean.TRUE); + // add reflective read + reflectivelyReads.putIfAbsent(this, other, Boolean.TRUE); + } } @@ -533,8 +537,8 @@ public final class Module implements AnnotatedElement { if (other == this && containsPackage(pn)) return true; - // all packages in open modules are open - if (descriptor.isOpen()) + // all packages in open and automatic modules are open + if (descriptor.isOpen() || descriptor.isAutomatic()) return containsPackage(pn); // exported/opened via module declaration/descriptor @@ -553,7 +557,7 @@ public final class Module implements AnnotatedElement { * Returns {@code true} if this module exports or opens a package to * the given module via its module declaration. */ - boolean isStaticallyExportedOrOpen(String pn, Module other, boolean open) { + private boolean isStaticallyExportedOrOpen(String pn, Module other, boolean open) { // package is open to everyone or Map> openPackages = this.openPackages; if (openPackages != null) { @@ -634,8 +638,7 @@ public final class Module implements AnnotatedElement { * the given package to the given module. * *

This method has no effect if the package is already exported (or - * open) to the given module. It also has no effect if - * invoked on an {@link ModuleDescriptor#isOpen open} module.

+ * open) to the given module.

* * @apiNote As specified in section 5.4.3 of the The Java™ * Virtual Machine Specification , if an attempt to resolve a @@ -653,8 +656,9 @@ public final class Module implements AnnotatedElement { * @throws IllegalArgumentException * If {@code pn} is {@code null}, or this is a named module and the * package {@code pn} is not a package in this module - * @throws IllegalStateException - * If this is a named module and the caller is not this module + * @throws IllegalCallerException + * If this is a named module and the caller's module is not this + * module * * @jvms 5.4.3 Resolution * @see #isExported(String,Module) @@ -665,10 +669,10 @@ public final class Module implements AnnotatedElement { throw new IllegalArgumentException("package is null"); Objects.requireNonNull(other); - if (isNamed() && !descriptor.isOpen()) { - Module caller = Reflection.getCallerClass().getModule(); + if (isNamed()) { + Module caller = getCallerModule(Reflection.getCallerClass()); if (caller != this) { - throw new IllegalStateException(caller + " != " + this); + throw new IllegalCallerException(caller + " != " + this); } implAddExportsOrOpens(pn, other, /*open*/false, /*syncVM*/true); } @@ -686,8 +690,14 @@ public final class Module implements AnnotatedElement { * access control checks. * *

This method has no effect if the package is already open - * to the given module. It also has no effect if invoked on an {@link - * ModuleDescriptor#isOpen open} module.

+ * to the given module.

+ * + * @apiNote This method can be used for cases where a consumer + * module uses a qualified opens to open a package to an API + * module but where the reflective access to the members of classes in + * the consumer module is delegated to code in another module. Code in the + * API module can use this method to open the package in the consumer module + * to the other module. * * @param pn * The package name @@ -699,9 +709,9 @@ public final class Module implements AnnotatedElement { * @throws IllegalArgumentException * If {@code pn} is {@code null}, or this is a named module and the * package {@code pn} is not a package in this module - * @throws IllegalStateException + * @throws IllegalCallerException * If this is a named module and this module has not opened the - * package to at least the caller + * package to at least the caller's module * * @see #isOpen(String,Module) * @see AccessibleObject#setAccessible(boolean) @@ -713,10 +723,10 @@ public final class Module implements AnnotatedElement { throw new IllegalArgumentException("package is null"); Objects.requireNonNull(other); - if (isNamed() && !descriptor.isOpen()) { - Module caller = Reflection.getCallerClass().getModule(); - if (caller != this && !isOpen(pn, caller)) - throw new IllegalStateException(pn + " is not open to " + caller); + if (isNamed()) { + Module caller = getCallerModule(Reflection.getCallerClass()); + if (caller != this && (caller == null || !isOpen(pn, caller))) + throw new IllegalCallerException(pn + " is not open to " + caller); implAddExportsOrOpens(pn, other, /*open*/true, /*syncVM*/true); } @@ -725,36 +735,80 @@ public final class Module implements AnnotatedElement { /** - * Updates the exports so that package {@code pn} is exported to module - * {@code other} but without notifying the VM. + * Updates this module to export a package unconditionally. * - * @apiNote This method is for VM white-box testing. + * @apiNote This method is for JDK tests only. */ - void implAddExportsNoSync(String pn, Module other) { - if (other == null) - other = EVERYONE_MODULE; - implAddExportsOrOpens(pn.replace('/', '.'), other, false, false); + void implAddExports(String pn) { + implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true); } /** - * Updates the exports so that package {@code pn} is exported to module - * {@code other}. + * Updates this module to export a package to another module. * - * @apiNote This method is for white-box testing. + * @apiNote Used by Instrumentation::redefineModule and --add-exports */ void implAddExports(String pn, Module other) { implAddExportsOrOpens(pn, other, false, true); } /** - * Updates the module to open package {@code pn} to module {@code other}. + * Updates this module to export a package to all unnamed modules. * - * @apiNote This method is for white-box tests and jtreg + * @apiNote Used by the --add-exports command line option. + */ + void implAddExportsToAllUnnamed(String pn) { + implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true); + } + + /** + * Updates this export to export a package unconditionally without + * notifying the VM. + * + * @apiNote This method is for VM white-box testing. + */ + void implAddExportsNoSync(String pn) { + implAddExportsOrOpens(pn.replace('/', '.'), Module.EVERYONE_MODULE, false, false); + } + + /** + * Updates a module to export a package to another module without + * notifying the VM. + * + * @apiNote This method is for VM white-box testing. + */ + void implAddExportsNoSync(String pn, Module other) { + implAddExportsOrOpens(pn.replace('/', '.'), other, false, false); + } + + /** + * Updates this module to open a package unconditionally. + * + * @apiNote This method is for JDK tests only. + */ + void implAddOpens(String pn) { + implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true); + } + + /** + * Updates this module to open a package to another module. + * + * @apiNote Used by Instrumentation::redefineModule and --add-opens */ void implAddOpens(String pn, Module other) { implAddExportsOrOpens(pn, other, true, true); } + /** + * Updates this module to export a package to all unnamed modules. + * + * @apiNote Used by the --add-opens command line option. + */ + void implAddOpensToAllUnnamed(String pn) { + implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true); + } + + /** * Updates a module to export or open a module to another module. * @@ -767,8 +821,8 @@ public final class Module implements AnnotatedElement { Objects.requireNonNull(other); Objects.requireNonNull(pn); - // all packages are open in unnamed and open modules - if (!isNamed() || descriptor.isOpen()) + // all packages are open in unnamed, open, and automatic modules + if (!isNamed() || descriptor.isOpen() || descriptor.isAutomatic()) return; // nothing to do if already exported/open to other @@ -819,17 +873,17 @@ public final class Module implements AnnotatedElement { * passed a reference to the service type by other code. This method is * a no-op when invoked on an unnamed module or an automatic module. * - *

This method does not cause {@link - * Configuration#resolveRequiresAndUses resolveRequiresAndUses} to be - * re-run.

+ *

This method does not cause {@link Configuration#resolveAndBind + * resolveAndBind} to be re-run.

* * @param service * The service type * * @return this module * - * @throws IllegalStateException - * If this is a named module and the caller is not this module + * @throws IllegalCallerException + * If this is a named module and the caller's module is not this + * module * * @see #canUse(Class) * @see ModuleDescriptor#uses() @@ -839,9 +893,9 @@ public final class Module implements AnnotatedElement { Objects.requireNonNull(service); if (isNamed() && !descriptor.isAutomatic()) { - Module caller = Reflection.getCallerClass().getModule(); + Module caller = getCallerModule(Reflection.getCallerClass()); if (caller != this) { - throw new IllegalStateException(caller + " != " + this); + throw new IllegalCallerException(caller + " != " + this); } implAddUses(service); } @@ -894,49 +948,41 @@ public final class Module implements AnnotatedElement { // -- packages -- // Additional packages that are added to the module at run-time. - // The field is volatile as it may be replaced at run-time - private volatile Set extraPackages; + private volatile Map extraPackages; private boolean containsPackage(String pn) { if (descriptor.packages().contains(pn)) return true; - Set extraPackages = this.extraPackages; - if (extraPackages != null && extraPackages.contains(pn)) + Map extraPackages = this.extraPackages; + if (extraPackages != null && extraPackages.containsKey(pn)) return true; return false; } /** - * Returns an array of the package names of the packages in this module. + * Returns the set of package names for the packages in this module. * - *

For named modules, the returned array contains an element for each - * package in the module. It may contain elements corresponding to packages - * added to the module, dynamic modules - * for example, after it was loaded. + *

For named modules, the returned set contains an element for each + * package in the module.

* - *

For unnamed modules, this method is the equivalent of invoking the + *

For unnamed modules, this method is the equivalent to invoking the * {@link ClassLoader#getDefinedPackages() getDefinedPackages} method of - * this module's class loader and returning the array of package names.

+ * this module's class loader and returning the set of package names.

* - *

A package name appears at most once in the returned array.

- * - * @apiNote This method returns an array rather than a {@code Set} for - * consistency with other {@code java.lang.reflect} types. - * - * @return an array of the package names of the packages in this module + * @return the set of the package names of the packages in this module */ - public String[] getPackages() { + public Set getPackages() { if (isNamed()) { Set packages = descriptor.packages(); - Set extraPackages = this.extraPackages; + Map extraPackages = this.extraPackages; if (extraPackages == null) { - return packages.toArray(new String[0]); + return packages; } else { return Stream.concat(packages.stream(), - extraPackages.stream()) - .toArray(String[]::new); + extraPackages.keySet().stream()) + .collect(Collectors.toSet()); } } else { @@ -947,23 +993,10 @@ public final class Module implements AnnotatedElement { } else { packages = SharedSecrets.getJavaLangAccess().packages(loader); } - return packages.map(Package::getName).toArray(String[]::new); + return packages.map(Package::getName).collect(Collectors.toSet()); } } - /** - * Add a package to this module. - * - * @apiNote This method is for Proxy use. - * - * @apiNote This is an expensive operation, not expected to be used often. - * At this time then it does not validate that the package name is a - * valid java identifier. - */ - void addPackage(String pn) { - implAddPackage(pn, true); - } - /** * Add a package to this module without notifying the VM. * @@ -976,49 +1009,52 @@ public final class Module implements AnnotatedElement { /** * Add a package to this module. * - * If {@code syncVM} is {@code true} then the VM is notified. + * If {@code syncVM} is {@code true} then the VM is notified. This method is + * a no-op if this is an unnamed module or the module already contains the + * package. + * + * @throws IllegalArgumentException if the package name is not legal + * @throws IllegalStateException if the package is defined to another module */ private void implAddPackage(String pn, boolean syncVM) { + // no-op if unnamed module if (!isNamed()) - throw new InternalError("adding package to unnamed module?"); - if (descriptor.isOpen()) - throw new InternalError("adding package to open module?"); + return; + + // no-op if module contains the package + if (containsPackage(pn)) + return; + + // check package name is legal for named modules if (pn.isEmpty()) - throw new InternalError("adding package to module?"); - - if (descriptor.packages().contains(pn)) { - // already in module - return; - } - - Set extraPackages = this.extraPackages; - if (extraPackages != null && extraPackages.contains(pn)) { - // already added - return; - } - synchronized (this) { - // recheck under lock - extraPackages = this.extraPackages; - if (extraPackages != null) { - if (extraPackages.contains(pn)) { - // already added - return; - } - - // copy the set - extraPackages = new HashSet<>(extraPackages); - extraPackages.add(pn); - } else { - extraPackages = Collections.singleton(pn); + throw new IllegalArgumentException("Cannot add package"); + for (int i=0; i extraPackages = this.extraPackages; + if (extraPackages == null) { + synchronized (this) { + extraPackages = this.extraPackages; + if (extraPackages == null) + this.extraPackages = extraPackages = new ConcurrentHashMap<>(); + } + } + + // update VM first in case it fails. This is a no-op if another thread + // beats us to add the package first + if (syncVM) { + // throws IllegalStateException if defined to another module + addPackage0(this, pn); + if (descriptor.isOpen() || descriptor.isAutomatic()) { + addExportsToAll0(this, pn); + } + } + extraPackages.putIfAbsent(pn, Boolean.TRUE); } @@ -1034,12 +1070,12 @@ public final class Module implements AnnotatedElement { */ static Map defineModules(Configuration cf, Function clf, - Layer layer) + ModuleLayer layer) { Map nameToModule = new HashMap<>(); Map moduleToLoader = new HashMap<>(); - boolean isBootLayer = (Layer.boot() == null); + boolean isBootLayer = (ModuleLayer.boot() == null); Set loaders = new HashSet<>(); // map each module to a class loader @@ -1049,7 +1085,7 @@ public final class Module implements AnnotatedElement { if (loader != null) { moduleToLoader.put(name, loader); loaders.add(loader); - } else if (!isBootLayer) { + } else if (!(clf instanceof ModuleLoaderMap.Mapper)) { throw new IllegalArgumentException("loader can't be 'null'"); } } @@ -1083,20 +1119,28 @@ public final class Module implements AnnotatedElement { // reads Set reads = new HashSet<>(); + + // name -> source Module when in parent layer + Map nameToSource = Collections.emptyMap(); + for (ResolvedModule other : resolvedModule.reads()) { Module m2 = null; if (other.configuration() == cf) { - String dn = other.reference().descriptor().name(); - m2 = nameToModule.get(dn); + // this configuration + m2 = nameToModule.get(other.name()); + assert m2 != null; } else { - for (Layer parent: layer.parents()) { + // parent layer + for (ModuleLayer parent: layer.parents()) { m2 = findModule(parent, other); if (m2 != null) break; } + assert m2 != null; + if (nameToSource.isEmpty()) + nameToSource = new HashMap<>(); + nameToSource.put(other.name(), m2); } - assert m2 != null; - reads.add(m2); // update VM view @@ -1110,7 +1154,7 @@ public final class Module implements AnnotatedElement { } // exports and opens - initExportsAndOpens(descriptor, nameToModule, m); + initExportsAndOpens(m, nameToSource, nameToModule, layer.parents()); } // register the modules in the boot layer @@ -1146,7 +1190,8 @@ public final class Module implements AnnotatedElement { * Find the runtime Module corresponding to the given ResolvedModule * in the given parent layer (or its parents). */ - private static Module findModule(Layer parent, ResolvedModule resolvedModule) { + private static Module findModule(ModuleLayer parent, + ResolvedModule resolvedModule) { Configuration cf = resolvedModule.configuration(); String dn = resolvedModule.name(); return parent.layers() @@ -1162,15 +1207,18 @@ public final class Module implements AnnotatedElement { .orElse(null); } + /** * Initialize the maps of exported and open packages for module m. */ - private static void initExportsAndOpens(ModuleDescriptor descriptor, + private static void initExportsAndOpens(Module m, + Map nameToSource, Map nameToModule, - Module m) - { - // The VM doesn't know about open modules so need to export all packages - if (descriptor.isOpen()) { + List parents) { + // The VM doesn't special case open or automatic modules so need to + // export all packages + ModuleDescriptor descriptor = m.getDescriptor(); + if (descriptor.isOpen() || descriptor.isAutomatic()) { assert descriptor.opens().isEmpty(); for (String source : descriptor.packages()) { addExportsToAll0(m, source); @@ -1189,8 +1237,7 @@ public final class Module implements AnnotatedElement { // qualified opens Set targets = new HashSet<>(); for (String target : opens.targets()) { - // only open to modules that are in this configuration - Module m2 = nameToModule.get(target); + Module m2 = findModule(target, nameToSource, nameToModule, parents); if (m2 != null) { addExports0(m, source, m2); targets.add(m2); @@ -1219,8 +1266,7 @@ public final class Module implements AnnotatedElement { // qualified exports Set targets = new HashSet<>(); for (String target : exports.targets()) { - // only export to modules that are in this configuration - Module m2 = nameToModule.get(target); + Module m2 = findModule(target, nameToSource, nameToModule, parents); if (m2 != null) { // skip qualified export if already open to m2 if (openToTargets == null || !openToTargets.contains(m2)) { @@ -1246,6 +1292,32 @@ public final class Module implements AnnotatedElement { m.exportedPackages = exportedPackages; } + /** + * Find the runtime Module with the given name. The module name is the + * name of a target module in a qualified exports or opens directive. + * + * @param target The target module to find + * @param nameToSource The modules in parent layers that are read + * @param nameToModule The modules in the layer under construction + * @param parents The parent layers + */ + private static Module findModule(String target, + Map nameToSource, + Map nameToModule, + List parents) { + Module m = nameToSource.get(target); + if (m == null) { + m = nameToModule.get(target); + if (m == null) { + for (ModuleLayer parent : parents) { + m = parent.findModule(target).orElse(null); + if (m != null) break; + } + } + } + return m; + } + // -- annotations -- @@ -1375,35 +1447,44 @@ public final class Module implements AnnotatedElement { /** - * Returns an input stream for reading a resource in this module. The - * {@code name} parameter is a {@code '/'}-separated path name that - * identifies the resource. + * Returns an input stream for reading a resource in this module. + * The {@code name} parameter is a {@code '/'}-separated path name that + * identifies the resource. As with {@link Class#getResourceAsStream + * Class.getResourceAsStream}, this method delegates to the module's class + * loader {@link ClassLoader#findResource(String,String) + * findResource(String,String)} method, invoking it with the module name + * (or {@code null} when the module is unnamed) and the name of the + * resource. If the resource name has a leading slash then it is dropped + * before delegation. * - *

A resource in a named modules may be encapsulated so that + *

A resource in a named module may be encapsulated so that * it cannot be located by code in other modules. Whether a resource can be - * located or not is determined as follows: + * located or not is determined as follows:

* *
    - *
  • The package name of the resource is derived from the - * subsequence of characters that precedes the last {@code '/'} and then - * replacing each {@code '/'} character in the subsequence with - * {@code '.'}. For example, the package name derived for a resource - * named "{@code a/b/c/foo.properties}" is "{@code a.b.c}".
  • + *
  • If the resource name ends with "{@code .class}" then it is not + * encapsulated.
  • * - *
  • If the package name is a package in the module then the package - * must be {@link #isOpen open} the module of the caller of this method. - * If the package is not in the module then the resource is not - * encapsulated. Resources in the unnamed package or "{@code META-INF}", - * for example, are never encapsulated because they can never be - * packages in a named module.
  • - * - *
  • As a special case, resources ending with "{@code .class}" are - * never encapsulated.
  • + *
  • A package name is derived from the resource name. If + * the package name is a {@linkplain #getPackages() package} in the + * module then the resource can only be located by the caller of this + * method when the package is {@linkplain #isOpen(String,Module) open} + * to at least the caller's module. If the resource is not in a + * package in the module then the resource is not encapsulated.
  • *
* + *

In the above, the package name for a resource is derived + * from the subsequence of characters that precedes the last {@code '/'} in + * the name and then replacing each {@code '/'} character in the subsequence + * with {@code '.'}. A leading slash is ignored when deriving the package + * name. As an example, the package name derived for a resource named + * "{@code a/b/c/foo.properties}" is "{@code a.b.c}". A resource name + * with the name "{@code META-INF/MANIFEST.MF}" is never encapsulated + * because "{@code META-INF}" is not a legal package name.

+ * *

This method returns {@code null} if the resource is not in this * module, the resource is encapsulated and cannot be located by the caller, - * or access to the resource is denied by the security manager. + * or access to the resource is denied by the security manager.

* * @param name * The resource name @@ -1413,21 +1494,27 @@ public final class Module implements AnnotatedElement { * @throws IOException * If an I/O error occurs * - * @see java.lang.module.ModuleReader#open(String) + * @see Class#getResourceAsStream(String) */ @CallerSensitive public InputStream getResourceAsStream(String name) throws IOException { - Objects.requireNonNull(name); + if (name.startsWith("/")) { + name = name.substring(1); + } - if (isNamed() && !ResourceHelper.isSimpleResource(name)) { - Module caller = Reflection.getCallerClass().getModule(); + if (isNamed() && Resources.canEncapsulate(name)) { + Module caller = getCallerModule(Reflection.getCallerClass()); if (caller != this && caller != Object.class.getModule()) { - // ignore packages added for proxies via addPackage - Set packages = getDescriptor().packages(); - String pn = ResourceHelper.getPackageName(name); - if (packages.contains(pn) && !isOpen(pn, caller)) { - // resource is in package not open to caller - return null; + String pn = Resources.toPackageName(name); + if (getPackages().contains(pn)) { + if (caller == null && !isOpen(pn)) { + // no caller, package not open + return null; + } + if (!isOpen(pn, caller)) { + // package not open to caller + return null; + } } } } @@ -1442,8 +1529,7 @@ public final class Module implements AnnotatedElement { } // locate resource in module - JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); - URL url = jla.findResource(loader, mn, name); + URL url = loader.findResource(mn, name); if (url != null) { try { return url.openStream(); @@ -1472,6 +1558,14 @@ public final class Module implements AnnotatedElement { } } + /** + * Returns the module that a given caller class is a member of. Returns + * {@code null} if the caller is {@code null}. + */ + private Module getCallerModule(Class caller) { + return (caller != null) ? caller.getModule() : null; + } + // -- native methods -- @@ -1496,79 +1590,4 @@ public final class Module implements AnnotatedElement { // JVM_AddModulePackage private static native void addPackage0(Module m, String pn); - - /** - * Register shared secret to provide access to package-private methods - */ - static { - SharedSecrets.setJavaLangReflectModuleAccess( - new JavaLangReflectModuleAccess() { - @Override - public Module defineUnnamedModule(ClassLoader loader) { - return new Module(loader); - } - @Override - public Module defineModule(ClassLoader loader, - ModuleDescriptor descriptor, - URI uri) { - return new Module(null, loader, descriptor, uri); - } - @Override - public void addReads(Module m1, Module m2) { - m1.implAddReads(m2, true); - } - @Override - public void addReadsAllUnnamed(Module m) { - m.implAddReads(Module.ALL_UNNAMED_MODULE); - } - @Override - public void addExports(Module m, String pn, Module other) { - m.implAddExportsOrOpens(pn, other, false, true); - } - @Override - public void addOpens(Module m, String pn, Module other) { - m.implAddExportsOrOpens(pn, other, true, true); - } - @Override - public void addExportsToAll(Module m, String pn) { - m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, false, true); - } - @Override - public void addOpensToAll(Module m, String pn) { - m.implAddExportsOrOpens(pn, Module.EVERYONE_MODULE, true, true); - } - @Override - public void addExportsToAllUnnamed(Module m, String pn) { - m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, false, true); - } - @Override - public void addOpensToAllUnnamed(Module m, String pn) { - m.implAddExportsOrOpens(pn, Module.ALL_UNNAMED_MODULE, true, true); - } - @Override - public void addUses(Module m, Class service) { - m.implAddUses(service); - } - @Override - public void addPackage(Module m, String pn) { - m.implAddPackage(pn, true); - } - @Override - public ServicesCatalog getServicesCatalog(Layer layer) { - return layer.getServicesCatalog(); - } - @Override - public Stream layers(Layer layer) { - return layer.layers(); - } - @Override - public Stream layers(ClassLoader loader) { - return Layer.layers(loader); - } - @Override - public boolean isStaticallyExported(Module module, String pn, Module other) { - return module.isStaticallyExportedOrOpen(pn, other, false); - } - }); - } } diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java b/jdk/src/java.base/share/classes/java/lang/ModuleLayer.java similarity index 75% rename from jdk/src/java.base/share/classes/java/lang/reflect/Layer.java rename to jdk/src/java.base/share/classes/java/lang/ModuleLayer.java index 9eaf90d0ca8..70fbd8bce81 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java +++ b/jdk/src/java.base/share/classes/java/lang/ModuleLayer.java @@ -23,7 +23,7 @@ * questions. */ -package java.lang.reflect; +package java.lang; import java.lang.module.Configuration; import java.lang.module.ModuleDescriptor; @@ -47,8 +47,6 @@ import java.util.stream.Stream; import jdk.internal.loader.ClassLoaderValue; import jdk.internal.loader.Loader; import jdk.internal.loader.LoaderPool; -import jdk.internal.misc.SharedSecrets; -import jdk.internal.module.Modules; import jdk.internal.module.ServicesCatalog; import sun.security.util.SecurityConstants; @@ -56,46 +54,65 @@ import sun.security.util.SecurityConstants; /** * A layer of modules in the Java virtual machine. * - *

A layer is created from a graph of modules that is the {@link - * Configuration} and a function that maps each module to a {@link ClassLoader}. + *

A layer is created from a graph of modules in a {@link Configuration} + * and a function that maps each module to a {@link ClassLoader}. * Creating a layer informs the Java virtual machine about the classes that - * may be loaded from modules so that the Java virtual machine knows which - * module that each class is a member of. Each layer, except the {@link - * #empty() empty} layer, has at least one {@link #parents() parent}.

+ * may be loaded from the modules so that the Java virtual machine knows which + * module that each class is a member of.

* *

Creating a layer creates a {@link Module} object for each {@link * ResolvedModule} in the configuration. For each resolved module that is * {@link ResolvedModule#reads() read}, the {@code Module} {@link * Module#canRead reads} the corresponding run-time {@code Module}, which may - * be in the same layer or a parent layer. The {@code Module} {@link - * Module#isExported(String) exports} the packages described by its {@link - * ModuleDescriptor}.

+ * be in the same layer or a {@link #parents() parent} layer.

* *

The {@link #defineModulesWithOneLoader defineModulesWithOneLoader} and * {@link #defineModulesWithManyLoaders defineModulesWithManyLoaders} methods - * provide convenient ways to create a {@code Layer} where all modules are + * provide convenient ways to create a module layer where all modules are * mapped to a single class loader or where each module is mapped to its own * class loader. The {@link #defineModules defineModules} method is for more * advanced cases where modules are mapped to custom class loaders by means of * a function specified to the method. Each of these methods has an instance * and static variant. The instance methods create a layer with the receiver * as the parent layer. The static methods are for more advanced cases where - * there can be more than one parent layer or a {@link Layer.Controller - * Controller} is needed to control modules in the layer.

+ * there can be more than one parent layer or where a {@link + * ModuleLayer.Controller Controller} is needed to control modules in the layer + *

* *

A Java virtual machine has at least one non-empty layer, the {@link * #boot() boot} layer, that is created when the Java virtual machine is * started. The boot layer contains module {@code java.base} and is the only * layer in the Java virtual machine with a module named "{@code java.base}". * The modules in the boot layer are mapped to the bootstrap class loader and - * other class loaders that are + * other class loaders that are * built-in into the Java virtual machine. The boot layer will often be * the {@link #parents() parent} when creating additional layers.

* + *

Each {@code Module} in a layer is created so that it {@link + * Module#isExported(String) exports} and {@link Module#isOpen(String) opens} + * the packages described by its {@link ModuleDescriptor}. Qualified exports + * (where a package is exported to a set of target modules rather than all + * modules) are reified when creating the layer as follows:

+ *
    + *
  • If module {@code X} exports a package to {@code Y}, and if the + * runtime {@code Module} {@code X} reads {@code Module} {@code Y}, then + * the package is exported to {@code Module} {@code Y} (which may be in + * the same layer as {@code X} or a parent layer).
  • + * + *
  • If module {@code X} exports a package to {@code Y}, and if the + * runtime {@code Module} {@code X} does not read {@code Y} then target + * {@code Y} is located as if by invoking {@link #findModule(String) + * findModule} to find the module in the layer or its parent layers. If + * {@code Y} is found then the package is exported to the instance of + * {@code Y} that was found. If {@code Y} is not found then the qualified + * export is ignored.
  • + *
+ * + *

Qualified opens are handled in same way as qualified exports.

+ * *

As when creating a {@code Configuration}, - * {@link ModuleDescriptor#isAutomatic() automatic} modules receive - * special - * treatment when creating a layer. An automatic module is created in the + * {@link ModuleDescriptor#isAutomatic() automatic} modules receive special + * treatment when creating a layer. An automatic module is created in the * Java virtual machine as a {@code Module} that reads every unnamed {@code * Module} in the Java virtual machine.

* @@ -113,43 +130,43 @@ import sun.security.util.SecurityConstants; *
{@code
  *     ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
  *
- *     Layer parent = Layer.boot();
+ *     ModuleLayer parent = ModuleLayer.boot();
  *
- *     Configuration cf = parent.configuration()
- *         .resolveRequires(finder, ModuleFinder.of(), Set.of("myapp"));
+ *     Configuration cf = parent.configuration().resolve(finder, ModuleFinder.of(), Set.of("myapp"));
  *
  *     ClassLoader scl = ClassLoader.getSystemClassLoader();
  *
- *     Layer layer = parent.defineModulesWithOneLoader(cf, scl);
+ *     ModuleLayer layer = parent.defineModulesWithOneLoader(cf, scl);
  *
  *     Class c = layer.findLoader("myapp").loadClass("app.Main");
  * }
* * @since 9 + * @spec JPMS * @see Module#getLayer() */ -public final class Layer { +public final class ModuleLayer { - // the empty Layer - private static final Layer EMPTY_LAYER - = new Layer(Configuration.empty(), List.of(), null); + // the empty layer + private static final ModuleLayer EMPTY_LAYER + = new ModuleLayer(Configuration.empty(), List.of(), null); - // the configuration from which this Layer was created + // the configuration from which this ;ayer was created private final Configuration cf; // parent layers, empty in the case of the empty layer - private final List parents; + private final List parents; // maps module name to jlr.Module private final Map nameToModule; /** - * Creates a new Layer from the modules in the given configuration. + * Creates a new module layer from the modules in the given configuration. */ - private Layer(Configuration cf, - List parents, - Function clf) + private ModuleLayer(Configuration cf, + List parents, + Function clf) { this.cf = cf; this.parents = parents; // no need to do defensive copy @@ -164,33 +181,38 @@ public final class Layer { } /** - * Controls a layer. The static methods defined by {@link Layer} to create - * module layers return a {@code Controller} that can be used to control - * modules in the layer. + * Controls a module layer. The static methods defined by {@link ModuleLayer} + * to create module layers return a {@code Controller} that can be used to + * control modules in the layer. + * + *

Unless otherwise specified, passing a {@code null} argument to a + * method in this class causes a {@link NullPointerException + * NullPointerException} to be thrown.

* * @apiNote Care should be taken with {@code Controller} objects, they * should never be shared with untrusted code. * * @since 9 + * @spec JPMS */ public static final class Controller { - private final Layer layer; + private final ModuleLayer layer; - Controller(Layer layer) { + Controller(ModuleLayer layer) { this.layer = layer; } /** * Returns the layer that this object controls. * - * @return the layer + * @return the module layer */ - public Layer layer() { + public ModuleLayer layer() { return layer; } private void ensureInLayer(Module source) { - if (!layer.modules().contains(source)) + if (source.getLayer() != layer) throw new IllegalArgumentException(source + " not in layer"); } @@ -212,15 +234,13 @@ public final class Layer { * @return This controller * * @throws IllegalArgumentException - * If {@code source} is not in the layer + * If {@code source} is not in the module layer * * @see Module#addReads */ public Controller addReads(Module source, Module target) { - Objects.requireNonNull(source); - Objects.requireNonNull(target); ensureInLayer(source); - Modules.addReads(source, target); + source.implAddReads(target); return this; } @@ -239,23 +259,21 @@ public final class Layer { * @return This controller * * @throws IllegalArgumentException - * If {@code source} is not in the layer or the package is not - * in the source module + * If {@code source} is not in the module layer or the package + * is not in the source module * * @see Module#addOpens */ public Controller addOpens(Module source, String pn, Module target) { - Objects.requireNonNull(source); - Objects.requireNonNull(target); ensureInLayer(source); - Modules.addOpens(source, pn, target); + source.implAddOpens(pn, target); return this; } } /** - * Creates a new layer, with this layer as its parent, by defining the + * Creates a new module layer, with this layer as its parent, by defining the * modules in the given {@code Configuration} to the Java virtual machine. * This method creates one class loader and defines all modules to that * class loader. The {@link ClassLoader#getParent() parent} of each class @@ -266,7 +284,7 @@ public final class Layer { * parent. In other words, if this layer is {@code thisLayer} then this * method is equivalent to invoking: *
 {@code
-     *     Layer.defineModulesWithOneLoader(cf, List.of(thisLayer), parentLoader).layer();
+     *     ModuleLayer.defineModulesWithOneLoader(cf, List.of(thisLayer), parentLoader).layer();
      * }
* * @param cf @@ -281,10 +299,8 @@ public final class Layer { * If the parent of the given configuration is not the configuration * for this layer * @throws LayerInstantiationException - * If all modules cannot be defined to the same class loader for any - * of the reasons listed above or the layer cannot be created because - * the configuration contains a module named "{@code java.base}" or - * a module with a package name starting with "{@code java.}" + * If the layer cannot be created for any of the reasons specified + * by the static {@code defineModulesWithOneLoader} method * @throws SecurityException * If {@code RuntimePermission("createClassLoader")} or * {@code RuntimePermission("getClassLoader")} is denied by @@ -292,14 +308,14 @@ public final class Layer { * * @see #findLoader */ - public Layer defineModulesWithOneLoader(Configuration cf, - ClassLoader parentLoader) { + public ModuleLayer defineModulesWithOneLoader(Configuration cf, + ClassLoader parentLoader) { return defineModulesWithOneLoader(cf, List.of(this), parentLoader).layer(); } /** - * Creates a new layer, with this layer as its parent, by defining the + * Creates a new module layer, with this layer as its parent, by defining the * modules in the given {@code Configuration} to the Java virtual machine. * Each module is defined to its own {@link ClassLoader} created by this * method. The {@link ClassLoader#getParent() parent} of each class loader @@ -310,7 +326,7 @@ public final class Layer { * parent. In other words, if this layer is {@code thisLayer} then this * method is equivalent to invoking: *
 {@code
-     *     Layer.defineModulesWithManyLoaders(cf, List.of(thisLayer), parentLoader).layer();
+     *     ModuleLayer.defineModulesWithManyLoaders(cf, List.of(thisLayer), parentLoader).layer();
      * }
* * @param cf @@ -325,9 +341,8 @@ public final class Layer { * If the parent of the given configuration is not the configuration * for this layer * @throws LayerInstantiationException - * If the layer cannot be created because the configuration contains - * a module named "{@code java.base}" or a module with a package - * name starting with "{@code java.}" + * If the layer cannot be created for any of the reasons specified + * by the static {@code defineModulesWithManyLoaders} method * @throws SecurityException * If {@code RuntimePermission("createClassLoader")} or * {@code RuntimePermission("getClassLoader")} is denied by @@ -335,14 +350,14 @@ public final class Layer { * * @see #findLoader */ - public Layer defineModulesWithManyLoaders(Configuration cf, - ClassLoader parentLoader) { + public ModuleLayer defineModulesWithManyLoaders(Configuration cf, + ClassLoader parentLoader) { return defineModulesWithManyLoaders(cf, List.of(this), parentLoader).layer(); } /** - * Creates a new layer, with this layer as its parent, by defining the + * Creates a new module layer, with this layer as its parent, by defining the * modules in the given {@code Configuration} to the Java virtual machine. * Each module is mapped, by name, to its class loader by means of the * given function. This method works exactly as specified by the static @@ -351,7 +366,7 @@ public final class Layer { * this layer is {@code thisLayer} then this method is equivalent to * invoking: *
 {@code
-     *     Layer.defineModules(cf, List.of(thisLayer), clf).layer();
+     *     ModuleLayer.defineModules(cf, List.of(thisLayer), clf).layer();
      * }
* * @param cf @@ -365,25 +380,19 @@ public final class Layer { * If the parent of the given configuration is not the configuration * for this layer * @throws LayerInstantiationException - * If creating the {@code Layer} fails for any of the reasons - * listed above, the layer cannot be created because the - * configuration contains a module named "{@code java.base}", - * a module with a package name starting with "{@code java.}" is - * mapped to a class loader other than the {@link - * ClassLoader#getPlatformClassLoader() platform class loader}, - * or the function to map a module name to a class loader returns - * {@code null} + * If the layer cannot be created for any of the reasons specified + * by the static {@code defineModules} method * @throws SecurityException * If {@code RuntimePermission("getClassLoader")} is denied by * the security manager */ - public Layer defineModules(Configuration cf, - Function clf) { + public ModuleLayer defineModules(Configuration cf, + Function clf) { return defineModules(cf, List.of(this), clf).layer(); } /** - * Creates a new layer by defining the modules in the given {@code + * Creates a new module layer by defining the modules in the given {@code * Configuration} to the Java virtual machine. This method creates one * class loader and defines all modules to that class loader. * @@ -396,7 +405,6 @@ public final class Layer { * exported to one or more of the modules in this layer. The class * loader delegates to the class loader of the module, throwing {@code * ClassNotFoundException} if not found by that class loader. - * * When {@code loadClass} is invoked to load classes that do not map to a * module then it delegates to the parent class loader.

* @@ -414,6 +422,10 @@ public final class Layer { * * * + *

In addition, a layer cannot be created if the configuration contains + * a module named "{@code java.base}", or a module contains a package named + * "{@code java}" or a package with a name starting with "{@code java.}".

+ * *

If there is a security manager then the class loader created by * this method will load classes and resources with privileges that are * restricted by the calling context of this method.

@@ -421,7 +433,7 @@ public final class Layer { * @param cf * The configuration for the layer * @param parentLayers - * The list parent layers in search order + * The list of parent layers in search order * @param parentLoader * The parent class loader for the class loader created by this * method; may be {@code null} for the bootstrap class loader @@ -433,9 +445,7 @@ public final class Layer { * the parent layers, including order * @throws LayerInstantiationException * If all modules cannot be defined to the same class loader for any - * of the reasons listed above or the layer cannot be created because - * the configuration contains a module named "{@code java.base}" or - * a module with a package name starting with "{@code java.}" + * of the reasons listed above * @throws SecurityException * If {@code RuntimePermission("createClassLoader")} or * {@code RuntimePermission("getClassLoader")} is denied by @@ -444,10 +454,10 @@ public final class Layer { * @see #findLoader */ public static Controller defineModulesWithOneLoader(Configuration cf, - List parentLayers, + List parentLayers, ClassLoader parentLoader) { - List parents = new ArrayList<>(parentLayers); + List parents = new ArrayList<>(parentLayers); checkConfiguration(cf, parents); checkCreateClassLoaderPermission(); @@ -456,7 +466,7 @@ public final class Layer { try { Loader loader = new Loader(cf.modules(), parentLoader); loader.initRemotePackageMap(cf, parents); - Layer layer = new Layer(cf, parents, mn -> loader); + ModuleLayer layer = new ModuleLayer(cf, parents, mn -> loader); return new Controller(layer); } catch (IllegalArgumentException | IllegalStateException e) { throw new LayerInstantiationException(e.getMessage()); @@ -464,7 +474,7 @@ public final class Layer { } /** - * Creates a new layer by defining the modules in the given {@code + * Creates a new module layer by defining the modules in the given {@code * Configuration} to the Java virtual machine. Each module is defined to * its own {@link ClassLoader} created by this method. The {@link * ClassLoader#getParent() parent} of each class loader is the given parent @@ -480,7 +490,6 @@ public final class Layer { * module in a parent layer. The class loader delegates to the class loader * of the module, throwing {@code ClassNotFoundException} if not found by * that class loader. - * * When {@code loadClass} is invoked to load classes that do not map to a * module then it delegates to the parent class loader.

* @@ -491,7 +500,7 @@ public final class Layer { * @param cf * The configuration for the layer * @param parentLayers - * The list parent layers in search order + * The list of parent layers in search order * @param parentLoader * The parent class loader for each of the class loaders created by * this method; may be {@code null} for the bootstrap class loader @@ -503,8 +512,10 @@ public final class Layer { * the parent layers, including order * @throws LayerInstantiationException * If the layer cannot be created because the configuration contains - * a module named "{@code java.base}" or a module with a package - * name starting with "{@code java.}" + * a module named "{@code java.base}" or a module contains a package + * named "{@code java}" or a package with a name starting with + * "{@code java.}" + * * @throws SecurityException * If {@code RuntimePermission("createClassLoader")} or * {@code RuntimePermission("getClassLoader")} is denied by @@ -513,10 +524,10 @@ public final class Layer { * @see #findLoader */ public static Controller defineModulesWithManyLoaders(Configuration cf, - List parentLayers, + List parentLayers, ClassLoader parentLoader) { - List parents = new ArrayList<>(parentLayers); + List parents = new ArrayList<>(parentLayers); checkConfiguration(cf, parents); checkCreateClassLoaderPermission(); @@ -524,7 +535,7 @@ public final class Layer { LoaderPool pool = new LoaderPool(cf, parents, parentLoader); try { - Layer layer = new Layer(cf, parents, pool::loaderFor); + ModuleLayer layer = new ModuleLayer(cf, parents, pool::loaderFor); return new Controller(layer); } catch (IllegalArgumentException | IllegalStateException e) { throw new LayerInstantiationException(e.getMessage()); @@ -532,18 +543,22 @@ public final class Layer { } /** - * Creates a new layer by defining the modules in the given {@code - * Configuration} to the Java virtual machine. - * Each module is mapped, by name, to its class loader by means of the - * given function. The class loader delegation implemented by these class - * loaders must respect module readability. The class loaders should be + * Creates a new module layer by defining the modules in the given {@code + * Configuration} to the Java virtual machine. The given function maps each + * module in the configuration, by name, to a class loader. Creating the + * layer informs the Java virtual machine about the classes that may be + * loaded so that the Java virtual machine knows which module that each + * class is a member of. + * + *

The class loader delegation implemented by the class loaders must + * respect module readability. The class loaders should be * {@link ClassLoader#registerAsParallelCapable parallel-capable} so as to * avoid deadlocks during class loading. In addition, the entity creating - * a new layer with this method should arrange that the class loaders are + * a new layer with this method should arrange that the class loaders be * ready to load from these modules before there are any attempts to load - * classes or resources. + * classes or resources.

* - *

Creating a {@code Layer} can fail for the following reasons:

+ *

Creating a layer can fail for the following reasons:

* *
    * @@ -558,19 +573,27 @@ public final class Layer { * *
* + *

In addition, a layer cannot be created if the configuration contains + * a module named "{@code java.base}", a configuration contains a module + * with a package named "{@code java}" or a package name starting with + * "{@code java.}" and the module is mapped to a class loader other than + * the {@link ClassLoader#getPlatformClassLoader() platform class loader}, + * or the function to map a module name to a class loader returns + * {@code null}.

+ * *

If the function to map a module name to class loader throws an error * or runtime exception then it is propagated to the caller of this method. *

* - * @apiNote It is implementation specific as to whether creating a Layer + * @apiNote It is implementation specific as to whether creating a layer * with this method is an atomic operation or not. Consequentially it is * possible for this method to fail with some modules, but not all, defined - * to Java virtual machine. + * to the Java virtual machine. * * @param cf * The configuration for the layer * @param parentLayers - * The list parent layers in search order + * The list of parent layers in search order * @param clf * The function to map a module name to a class loader * @@ -580,23 +603,16 @@ public final class Layer { * If the parent configurations do not match the configuration of * the parent layers, including order * @throws LayerInstantiationException - * If creating the {@code Layer} fails for any of the reasons - * listed above, the layer cannot be created because the - * configuration contains a module named "{@code java.base}", - * a module with a package name starting with "{@code java.}" is - * mapped to a class loader other than the {@link - * ClassLoader#getPlatformClassLoader() platform class loader}, - * or the function to map a module name to a class loader returns - * {@code null} + * If creating the layer fails for any of the reasons listed above * @throws SecurityException * If {@code RuntimePermission("getClassLoader")} is denied by * the security manager */ public static Controller defineModules(Configuration cf, - List parentLayers, + List parentLayers, Function clf) { - List parents = new ArrayList<>(parentLayers); + List parents = new ArrayList<>(parentLayers); checkConfiguration(cf, parents); Objects.requireNonNull(clf); @@ -608,7 +624,7 @@ public final class Layer { } try { - Layer layer = new Layer(cf, parents, clf); + ModuleLayer layer = new ModuleLayer(cf, parents, clf); return new Controller(layer); } catch (IllegalArgumentException | IllegalStateException e) { throw new LayerInstantiationException(e.getMessage()); @@ -621,7 +637,7 @@ public final class Layer { * the parent layers. */ private static void checkConfiguration(Configuration cf, - List parentLayers) + List parentLayers) { Objects.requireNonNull(cf); @@ -630,7 +646,7 @@ public final class Layer { throw new IllegalArgumentException("wrong number of parents"); int index = 0; - for (Layer parent : parentLayers) { + for (ModuleLayer parent : parentLayers) { if (parent.configuration() != parentConfigurations.get(index)) { throw new IllegalArgumentException( "Parent of configuration != configuration of this Layer"); @@ -707,7 +723,7 @@ public final class Layer { * * @return The list of this layer's parents */ - public List parents() { + public List parents() { return parents; } @@ -719,24 +735,24 @@ public final class Layer { * @implNote For now, the assumption is that the number of elements will * be very low and so this method does not use a specialized spliterator. */ - Stream layers() { - List allLayers = this.allLayers; + Stream layers() { + List allLayers = this.allLayers; if (allLayers != null) return allLayers.stream(); allLayers = new ArrayList<>(); - Set visited = new HashSet<>(); - Deque stack = new ArrayDeque<>(); + Set visited = new HashSet<>(); + Deque stack = new ArrayDeque<>(); visited.add(this); stack.push(this); while (!stack.isEmpty()) { - Layer layer = stack.pop(); + ModuleLayer layer = stack.pop(); allLayers.add(layer); // push in reverse order for (int i = layer.parents.size() - 1; i >= 0; i--) { - Layer parent = layer.parents.get(i); + ModuleLayer parent = layer.parents.get(i); if (!visited.contains(parent)) { visited.add(parent); stack.push(parent); @@ -748,7 +764,7 @@ public final class Layer { return allLayers.stream(); } - private volatile List allLayers; + private volatile List allLayers; /** * Returns the set of the modules in this layer. @@ -756,14 +772,20 @@ public final class Layer { * @return A possibly-empty unmodifiable set of the modules in this layer */ public Set modules() { - return Collections.unmodifiableSet( - nameToModule.values().stream().collect(Collectors.toSet())); + Set modules = this.modules; + if (modules == null) { + this.modules = modules = + Collections.unmodifiableSet(new HashSet<>(nameToModule.values())); + } + return modules; } + private volatile Set modules; + /** * Returns the module with the given name in this layer, or if not in this - * layer, the {@linkplain #parents parents} layers. Finding a module in + * layer, the {@linkplain #parents parent} layers. Finding a module in * parent layers is equivalent to invoking {@code findModule} on each * parent, in search order, until the module is found or all parents have * been searched. In a tree of layers then this is equivalent to @@ -778,6 +800,8 @@ public final class Layer { */ public Optional findModule(String name) { Objects.requireNonNull(name); + if (this == EMPTY_LAYER) + return Optional.empty(); Module m = nameToModule.get(name); if (m != null) return Optional.of(m); @@ -828,9 +852,9 @@ public final class Layer { } /** - * Returns a string describing this layer. + * Returns a string describing this module layer. * - * @return A possibly empty string describing this layer + * @return A possibly empty string describing this module layer */ @Override public String toString() { @@ -845,7 +869,7 @@ public final class Layer { * * @return The empty layer */ - public static Layer empty() { + public static ModuleLayer empty() { return EMPTY_LAYER; } @@ -859,11 +883,10 @@ public final class Layer { * * @return The boot layer */ - public static Layer boot() { - return SharedSecrets.getJavaLangAccess().getBootLayer(); + public static ModuleLayer boot() { + return System.bootLayer; } - /** * Returns the ServicesCatalog for this Layer, creating it if not * already created. @@ -894,10 +917,10 @@ public final class Layer { */ void bindToLoader(ClassLoader loader) { // CLV.computeIfAbsent(loader, (cl, clv) -> new CopyOnWriteArrayList<>()) - List list = CLV.get(loader); + List list = CLV.get(loader); if (list == null) { list = new CopyOnWriteArrayList<>(); - List previous = CLV.putIfAbsent(loader, list); + List previous = CLV.putIfAbsent(loader, list); if (previous != null) list = previous; } list.add(this); @@ -907,8 +930,8 @@ public final class Layer { * Returns a stream of the layers that have at least one module defined to * the given class loader. */ - static Stream layers(ClassLoader loader) { - List list = CLV.get(loader); + static Stream layers(ClassLoader loader) { + List list = CLV.get(loader); if (list != null) { return list.stream(); } else { @@ -917,5 +940,5 @@ public final class Layer { } // the list of layers with modules defined to a class loader - private static final ClassLoaderValue> CLV = new ClassLoaderValue<>(); + private static final ClassLoaderValue> CLV = new ClassLoaderValue<>(); } diff --git a/jdk/src/java.base/share/classes/java/lang/NamedPackage.java b/jdk/src/java.base/share/classes/java/lang/NamedPackage.java index 5d86cc7fd9c..6234b949e65 100644 --- a/jdk/src/java.base/share/classes/java/lang/NamedPackage.java +++ b/jdk/src/java.base/share/classes/java/lang/NamedPackage.java @@ -26,7 +26,6 @@ package java.lang; import java.lang.module.Configuration; import java.lang.module.ModuleReference; -import java.lang.reflect.Module; import java.net.URI; /** diff --git a/jdk/src/java.base/share/classes/java/lang/Object.java b/jdk/src/java.base/share/classes/java/lang/Object.java index 0677aa5d234..e1cb6e0246d 100644 --- a/jdk/src/java.base/share/classes/java/lang/Object.java +++ b/jdk/src/java.base/share/classes/java/lang/Object.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2015, 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 @@ -561,10 +561,53 @@ public class Object { * the finalization of this object to be halted, but is otherwise * ignored. * + * @apiNote + * Classes that embed non-heap resources have many options + * for cleanup of those resources. The class must ensure that the + * lifetime of each instance is longer than that of any resource it embeds. + * {@link java.lang.ref.Reference#reachabilityFence} can be used to ensure that + * objects remain reachable while resources embedded in the object are in use. + *

+ * A subclass should avoid overriding the {@code finalize} method + * unless the subclass embeds non-heap resources that must be cleaned up + * before the instance is collected. + * Finalizer invocations are not automatically chained, unlike constructors. + * If a subclass overrides {@code finalize} it must invoke the superclass + * finalizer explicitly. + * To guard against exceptions prematurely terminating the finalize chain, + * the subclass should use a {@code try-finally} block to ensure + * {@code super.finalize()} is always invoked. For example, + *

{@code      @Override
+     *     protected void finalize() throws Throwable {
+     *         try {
+     *             ... // cleanup subclass state
+     *         } finally {
+     *             super.finalize();
+     *         }
+     *     }
+     * }
+ * + * @deprecated The finalization mechanism is inherently problematic. + * Finalization can lead to performance issues, deadlocks, and hangs. + * Errors in finalizers can lead to resource leaks; there is no way to cancel + * finalization if it is no longer necessary; and no ordering is specified + * among calls to {@code finalize} methods of different objects. + * Furthermore, there are no guarantees regarding the timing of finalization. + * The {@code finalize} method might be called on a finalizable object + * only after an indefinite delay, if at all. + * + * Classes whose instances hold non-heap resources should provide a method + * to enable explicit release of those resources, and they should also + * implement {@link AutoCloseable} if appropriate. + * The {@link java.lang.ref.Cleaner} and {@link java.lang.ref.PhantomReference} + * provide more flexible and efficient ways to release resources when an object + * becomes unreachable. + * * @throws Throwable the {@code Exception} raised by this method * @see java.lang.ref.WeakReference * @see java.lang.ref.PhantomReference * @jls 12.6 Finalization of Class Instances */ + @Deprecated(since="9") protected void finalize() throws Throwable { } } diff --git a/jdk/src/java.base/share/classes/java/lang/Package.java b/jdk/src/java.base/share/classes/java/lang/Package.java index 5a19f9771f1..25bf4a751fd 100644 --- a/jdk/src/java.base/share/classes/java/lang/Package.java +++ b/jdk/src/java.base/share/classes/java/lang/Package.java @@ -27,7 +27,6 @@ package java.lang; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Module; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -111,6 +110,8 @@ import jdk.internal.reflect.Reflection; * @see ClassLoader#definePackage(String, String, String, String, String, String, String, URL) * * @since 1.2 + * @revised 9 + * @spec JPMS */ public class Package extends NamedPackage implements java.lang.reflect.AnnotatedElement { /** @@ -207,6 +208,9 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated * is returned if it is not known. * @return the vendor that implemented this package, {@code null} * is returned if it is not known. + * + * @revised 9 + * @spec JPMS */ public String getImplementationVendor() { return versionInfo.implVendor; @@ -334,6 +338,9 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated * a {@code Package} for the specified class loader. * * @see ClassLoader#getDefinedPackage + * + * @revised 9 + * @spec JPMS */ @CallerSensitive @Deprecated(since="9") @@ -356,6 +363,9 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated * class loader and its ancestors * * @see ClassLoader#getDefinedPackages + * + * @revised 9 + * @spec JPMS */ @CallerSensitive public static Package[] getPackages() { diff --git a/jdk/src/java.base/share/classes/java/lang/Process.java b/jdk/src/java.base/share/classes/java/lang/Process.java index c4c5612e674..90ca41d0375 100644 --- a/jdk/src/java.base/share/classes/java/lang/Process.java +++ b/jdk/src/java.base/share/classes/java/lang/Process.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, 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 @@ -80,10 +80,10 @@ import java.util.stream.Stream; * *

Subclasses of Process should override the {@link #onExit()} and * {@link #toHandle()} methods to provide a fully functional Process including the - * {@link #getPid() process id}, - * {@link #info() information about the process}, - * {@link #children() direct children}, and - * {@link #descendants() direct children plus descendants of those children} of the process. + * {@linkplain #pid() process id}, + * {@linkplain #info() information about the process}, + * {@linkplain #children() direct children}, and + * {@linkplain #descendants() direct children plus descendants of those children} of the process. * Delegating to the underlying Process or ProcessHandle is typically * easiest and most efficient. * @@ -237,14 +237,14 @@ public abstract class Process { /** * Kills the process. * Whether the process represented by this {@code Process} object is - * {@link #supportsNormalTermination normally terminated} or not is + * {@linkplain #supportsNormalTermination normally terminated} or not is * implementation dependent. * Forcible process destruction is defined as the immediate termination of a * process, whereas normal termination allows the process to shut down cleanly. * If the process is not alive, no action is taken. *

* The {@link java.util.concurrent.CompletableFuture} from {@link #onExit} is - * {@link java.util.concurrent.CompletableFuture#complete completed} + * {@linkplain java.util.concurrent.CompletableFuture#complete completed} * when the process has terminated. */ public abstract void destroy(); @@ -257,7 +257,7 @@ public abstract class Process { * If the process is not alive, no action is taken. *

* The {@link java.util.concurrent.CompletableFuture} from {@link #onExit} is - * {@link java.util.concurrent.CompletableFuture#complete completed} + * {@linkplain java.util.concurrent.CompletableFuture#complete completed} * when the process has terminated. *

* Invoking this method on {@code Process} objects returned by @@ -335,15 +335,15 @@ public abstract class Process { * * @implSpec * The implementation of this method returns the process id as: - * {@link #toHandle toHandle().getPid()}. + * {@link #toHandle toHandle().pid()}. * * @return the native process id of the process * @throws UnsupportedOperationException if the Process implementation * does not support this operation * @since 9 */ - public long getPid() { - return toHandle().getPid(); + public long pid() { + return toHandle().pid(); } /** @@ -357,9 +357,9 @@ public abstract class Process { *

* Calling {@code onExit().get()} waits for the process to terminate and returns * the Process. The future can be used to check if the process is - * {@link java.util.concurrent.CompletableFuture#isDone done} or to - * {@link java.util.concurrent.CompletableFuture#get() wait} for it to terminate. - * {@link java.util.concurrent.CompletableFuture#cancel(boolean) Cancelling} + * {@linkplain java.util.concurrent.CompletableFuture#isDone done} or to + * {@linkplain java.util.concurrent.CompletableFuture#get() wait} for it to terminate. + * {@linkplain java.util.concurrent.CompletableFuture#cancel(boolean) Cancelling} * the CompletableFuture does not affect the Process. *

* Processes returned from {@link ProcessBuilder#start} override the @@ -389,7 +389,7 @@ public abstract class Process { * {@code waitFor} is interrupted, the thread's interrupt status is preserved. *

* When {@link #waitFor()} returns successfully the CompletableFuture is - * {@link java.util.concurrent.CompletableFuture#complete completed} regardless + * {@linkplain java.util.concurrent.CompletableFuture#complete completed} regardless * of the exit status of the process. * * This implementation may consume a lot of memory for thread stacks if a @@ -463,7 +463,7 @@ public abstract class Process { * This implementation throws an instance of * {@link java.lang.UnsupportedOperationException} and performs no other action. * Subclasses should override this method to provide a ProcessHandle for the - * process. The methods {@link #getPid}, {@link #info}, {@link #children}, + * process. The methods {@link #pid}, {@link #info}, {@link #children}, * and {@link #descendants}, unless overridden, operate on the ProcessHandle. * * @return Returns a ProcessHandle for the Process @@ -500,10 +500,10 @@ public abstract class Process { /** * Returns a snapshot of the direct children of the process. * The parent of a direct child process is the process. - * Typically, a process that is {@link #isAlive not alive} has no children. + * Typically, a process that is {@linkplain #isAlive not alive} has no children. *

* Note that processes are created and terminate asynchronously. - * There is no guarantee that a process is {@link #isAlive alive}. + * There is no guarantee that a process is {@linkplain #isAlive alive}. * * * @implSpec @@ -526,10 +526,10 @@ public abstract class Process { * Returns a snapshot of the descendants of the process. * The descendants of a process are the children of the process * plus the descendants of those children, recursively. - * Typically, a process that is {@link #isAlive not alive} has no children. + * Typically, a process that is {@linkplain #isAlive not alive} has no children. *

* Note that processes are created and terminate asynchronously. - * There is no guarantee that a process is {@link #isAlive alive}. + * There is no guarantee that a process is {@linkplain #isAlive alive}. * * * @implSpec diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java index 31406459d93..7adee534b81 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java @@ -71,7 +71,7 @@ import sun.security.action.GetPropertyAction; * working directory of the current process, usually the directory * named by the system property {@code user.dir}. * - *

  • a source of standard input. + *
  • a source of standard input. * By default, the subprocess reads input from a pipe. Java code * can access this pipe via the output stream returned by * {@link Process#getOutputStream()}. However, standard input may @@ -86,7 +86,7 @@ import sun.security.action.GetPropertyAction; *
  • the {@link OutputStream#close() close} method does nothing * * - *
  • a destination for standard output + *
  • a destination for standard output * and standard error. By default, the subprocess writes standard * output and standard error to pipes. Java code can access these pipes * via the input streams returned by {@link Process#getOutputStream()} and @@ -1251,6 +1251,7 @@ public final class ProcessBuilder * If the operating system does not support the creation of processes * * @throws IOException if an I/O error occurs + * @since 9 */ public static List startPipeline(List builders) throws IOException { // Accumulate and check the builders diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java b/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java index fbf5cfba252..7cd3b5dd96c 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, 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 @@ -104,7 +104,7 @@ public interface ProcessHandle extends Comparable { * @throws UnsupportedOperationException if the implementation * does not support this operation */ - long getPid(); + long pid(); /** * Returns an {@code Optional} for an existing native process. @@ -383,7 +383,7 @@ public interface ProcessHandle extends Comparable { /** * Returns a hash code value for this ProcessHandle. * The hashcode value follows the general contract for {@link Object#hashCode()}. - * The value is a function of the {@link #getPid getPid()} value and + * The value is a function of the {@link #pid pid()} value and * may be a function of additional information to uniquely identify the process. * If two ProcessHandles are equal according to the {@link #equals(Object) equals} * method, then calling the hashCode method on each of the two objects diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java index 15a2bd4c029..d634166a30a 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, 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 @@ -24,6 +24,7 @@ */ package java.lang; +import java.lang.annotation.Native; import java.security.PrivilegedAction; import java.time.Duration; import java.time.Instant; @@ -34,11 +35,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -56,6 +53,12 @@ final class ProcessHandleImpl implements ProcessHandle { */ private static long REAPER_DEFAULT_STACKSIZE = 128 * 1024; + /** + * Return value from waitForProcessExit0 indicating the process is not a child. + */ + @Native + private static final int NOT_A_CHILD = -2; + /** * Cache the ProcessHandle of this process. */ @@ -131,6 +134,29 @@ final class ProcessHandleImpl implements ProcessHandle { // spawn a thread to wait for and deliver the exit value processReaperExecutor.execute(() -> { int exitValue = waitForProcessExit0(pid, shouldReap); + if (exitValue == NOT_A_CHILD) { + // pid not alive or not a child of this process + // If it is alive wait for it to terminate + long sleep = 300; // initial milliseconds to sleep + int incr = 30; // increment to the sleep time + + long startTime = isAlive0(pid); + long origStart = startTime; + while (startTime >= 0) { + try { + Thread.sleep(Math.min(sleep, 5000L)); // no more than 5 sec + sleep += incr; + } catch (InterruptedException ie) { + // ignore and retry + } + startTime = isAlive0(pid); // recheck if is alive + if (origStart > 0 && startTime != origStart) { + // start time changed, pid is not the same process + break; + } + } + exitValue = 0; + } newCompletion.complete(exitValue); // remove from cache afterwards completions.remove(pid, newCompletion); @@ -146,7 +172,7 @@ final class ProcessHandleImpl implements ProcessHandle { throw new IllegalStateException("onExit for current process not allowed"); } - return ProcessHandleImpl.completion(getPid(), false) + return ProcessHandleImpl.completion(pid(), false) .handleAsync((exitStatus, unusedThrowable) -> this); } @@ -229,7 +255,7 @@ final class ProcessHandleImpl implements ProcessHandle { * @return the native process ID */ @Override - public long getPid() { + public long pid() { return pid; } diff --git a/jdk/src/java.base/share/classes/java/lang/Runtime.java b/jdk/src/java.base/share/classes/java/lang/Runtime.java index 84a599a4285..230d75a412d 100644 --- a/jdk/src/java.base/share/classes/java/lang/Runtime.java +++ b/jdk/src/java.base/share/classes/java/lang/Runtime.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 @@ -930,10 +930,9 @@ public class Runtime { } /** - * Returns the version of the Java Runtime Environment as a {@link - * Runtime.Version}. + * Returns the version of the Java Runtime Environment as a {@link Version}. * - * @return the {@link Runtime.Version} of the Java Runtime Environment + * @return the {@link Version} of the Java Runtime Environment * * @since 9 */ @@ -948,19 +947,19 @@ public class Runtime { /** * A representation of a version string for an implementation of the - * Java SE Platform. A version string contains a version number + * Java SE Platform. A version string consists of a version number * optionally followed by pre-release and build information. * - *

    Version numbers

    + *

    Version numbers

    * *

    A version number, {@code $VNUM}, is a non-empty sequence * of elements separated by period characters (U+002E). An element is - * either zero, or a unsigned integer numeral without leading zeros. The + * either zero, or an unsigned integer numeral without leading zeros. The * final element in a version number must not be zero. The format is: *

    * *
    -     *     ^[1-9][0-9]*(((\.0)*\.[1-9][0-9]*)*)*$
    +     *     [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
          * 
    * *

    The sequence may be of arbitrary length but the first three @@ -972,7 +971,7 @@ public class Runtime { * *

      * - *
    • {@code $MAJOR} --- The major version + *

    • {@code $MAJOR} --- The major version * number, incremented for a major release that contains significant new * features as specified in a new edition of the Java SE Platform * Specification, e.g.,

    • * - *
    • {@code $MINOR} --- The minor version + *

    • {@code $MINOR} --- The minor version * number, incremented for a minor update release that may contain * compatible bug fixes, revisions to standard APIs mandated by a * Maintenance Release @@ -993,7 +992,7 @@ public class Runtime { * additional service providers, new garbage collectors, and ports to new * hardware architectures.

    • * - *
    • {@code $SECURITY} --- The security + *

    • {@code $SECURITY} --- The security * level, incremented for a security update release that contains critical * fixes including those necessary to improve security. {@code $SECURITY} * is not reset when {@code $MINOR} is incremented. A @@ -1022,39 +1021,42 @@ public class Runtime { * sequence; e.g., {@code 9.1.2} is less than {@code 9.1.2.1}. *

      * - *

      Version strings

      + *

      Version strings

      * *

      A version string, {@code $VSTR}, consists of a version * number {@code $VNUM}, as described above, optionally followed by - * pre-release and build information, in the format

      + * pre-release and build information, in one of the following formats: + *

      * *
      -     *     $VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
      +     *     $VNUM(-$PRE)?\+$BUILD(-$OPT)?
      +     *     $VNUM-$PRE(-$OPT)?
      +     *     $VNUM(+-$OPT)?
            * 
      * *

      where:

      * *
        * - *
      • {@code $PRE}, matching {@code ([a-zA-Z0-9]+)} + *

      • {@code $PRE}, matching {@code ([a-zA-Z0-9]+)} * --- A pre-release identifier. Typically {@code ea}, for a * potentially unstable early-access release under active development, - * or {@code internal}, for an internal developer build. + * or {@code internal}, for an internal developer build.

      • * - *
      • {@code $BUILD}, matching {@code + *

      • {@code $BUILD}, matching {@code * (0|[1-9][0-9]*)} --- The build number, incremented for each promoted * build. {@code $BUILD} is reset to {@code 1} when any portion of {@code - * $VNUM} is incremented.

        + * $VNUM} is incremented.

      • * - *
      • {@code $OPT}, matching {@code - * ([-a-zA-Z0-9\.]+)} --- Additional build information, if desired. In + *

      • {@code $OPT}, matching {@code + * ([-a-zA-Z0-9.]+)} --- Additional build information, if desired. In * the case of an {@code internal} build this will often contain the date - * and time of the build.

        + * and time of the build.

      • * *
      * - *

      A version number {@code 10-ea} matches {@code $VNUM = "10"} and - * {@code $PRE = "ea"}. The version number {@code 10+-ea} matches + *

      A version string {@code 10-ea} matches {@code $VNUM = "10"} and + * {@code $PRE = "ea"}. The version string {@code 10+-ea} matches * {@code $VNUM = "10"} and {@code $OPT = "ea"}.

      * *

      When comparing two version strings, the value of {@code $OPT}, if @@ -1067,15 +1069,21 @@ public class Runtime { * *

      A short version string, {@code $SVSTR}, often useful in * less formal contexts, is a version number optionally followed by a - * pre-release identifier: + * pre-release identifier:

      * *
            *     $VNUM(-$PRE)?
            * 
      * + *

      This is a value-based + * class; use of identity-sensitive operations (including reference equality + * ({@code ==}), identity hash code, or synchronization) on instances of + * {@code Version} may have unpredictable results and should be avoided. + *

      + * * @since 9 */ - public static class Version + public static final class Version implements Comparable { private final List version; @@ -1083,9 +1091,18 @@ public class Runtime { private final Optional build; private final Optional optional; - Version(List version, Optional pre, - Optional build, Optional optional) { - this.version = Collections.unmodifiableList(version); + /* + * List of version number components passed to this constructor MUST + * be at least unmodifiable (ideally immutable). In the case on an + * unmodifiable list, the caller MUST hand the list over to this + * constructor and never change the underlying list. + */ + private Version(List unmodifiableListOfVersions, + Optional pre, + Optional build, + Optional optional) + { + this.version = unmodifiableListOfVersions; this.pre = pre; this.build = build; this.optional = optional; @@ -1129,9 +1146,11 @@ public class Runtime { + s + "'"); // $VNUM is a dot-separated list of integers of arbitrary length - List version = new ArrayList<>(); - for (String i : m.group(VersionPattern.VNUM_GROUP).split("\\.")) - version.add(Integer.parseInt(i)); + String[] split = m.group(VersionPattern.VNUM_GROUP).split("\\."); + Integer[] version = new Integer[split.length]; + for (int i = 0; i < split.length; i++) { + version[i] = Integer.parseInt(split[i]); + } Optional pre = Optional.ofNullable( m.group(VersionPattern.PRE_GROUP)); @@ -1158,7 +1177,7 @@ public class Runtime { + " build or optional components: '" + s + "'"); } } - return new Version(version, pre, build, optional); + return new Version(List.of(version), pre, build, optional); } private static boolean isSimpleNumber(String s) { @@ -1247,7 +1266,7 @@ public class Runtime { * Compares this version to another. * *

      Each of the components in the version is - * compared in the follow order of precedence: version numbers, + * compared in the following order of precedence: version numbers, * pre-release identifiers, build numbers, optional build information. *

      * @@ -1269,9 +1288,7 @@ public class Runtime { * During this comparison, a version with optional build information is * considered to be greater than a version without one.

      * - *

      A version is not comparable to any other type of object. - * - * @param ob + * @param obj * The object to be compared * * @return A negative integer, zero, or a positive integer if this @@ -1282,8 +1299,8 @@ public class Runtime { * If the given object is {@code null} */ @Override - public int compareTo(Version ob) { - return compare(ob, false); + public int compareTo(Version obj) { + return compare(obj, false); } /** @@ -1294,9 +1311,10 @@ public class Runtime { * described in {@link #compareTo(Version)} with the exception that the * optional build information is always ignored.

      * - *

      A version is not comparable to any other type of object. + *

      This method provides ordering which is consistent with + * {@code equalsIgnoreOptional()}.

      * - * @param ob + * @param obj * The object to be compared * * @return A negative integer, zero, or a positive integer if this @@ -1306,49 +1324,47 @@ public class Runtime { * @throws NullPointerException * If the given object is {@code null} */ - public int compareToIgnoreOptional(Version ob) { - return compare(ob, true); + public int compareToIgnoreOptional(Version obj) { + return compare(obj, true); } - private int compare(Version ob, boolean ignoreOpt) { - if (ob == null) - throw new NullPointerException("Invalid argument"); + private int compare(Version obj, boolean ignoreOpt) { + if (obj == null) + throw new NullPointerException(); - int ret = compareVersion(ob); + int ret = compareVersion(obj); if (ret != 0) return ret; - ret = comparePre(ob); + ret = comparePre(obj); if (ret != 0) return ret; - ret = compareBuild(ob); + ret = compareBuild(obj); if (ret != 0) return ret; if (!ignoreOpt) - return compareOptional(ob); + return compareOptional(obj); return 0; } - private int compareVersion(Version ob) { + private int compareVersion(Version obj) { int size = version.size(); - int oSize = ob.version().size(); + int oSize = obj.version().size(); int min = Math.min(size, oSize); for (int i = 0; i < min; i++) { - Integer val = version.get(i); - Integer oVal = ob.version().get(i); + int val = version.get(i); + int oVal = obj.version().get(i); if (val != oVal) return val - oVal; } - if (size != oSize) - return size - oSize; - return 0; + return size - oSize; } - private int comparePre(Version ob) { - Optional oPre = ob.pre(); + private int comparePre(Version obj) { + Optional oPre = obj.pre(); if (!pre.isPresent()) { if (oPre.isPresent()) return 1; @@ -1370,20 +1386,20 @@ public class Runtime { return 0; } - private int compareBuild(Version ob) { - Optional oBuild = ob.build(); + private int compareBuild(Version obj) { + Optional oBuild = obj.build(); if (oBuild.isPresent()) { return (build.isPresent() ? build.get().compareTo(oBuild.get()) - : 1); + : -1); } else if (build.isPresent()) { - return -1; + return 1; } return 0; } - private int compareOptional(Version ob) { - Optional oOpt = ob.optional(); + private int compareOptional(Version obj) { + Optional oOpt = obj.optional(); if (!optional.isPresent()) { if (oOpt.isPresent()) return -1; @@ -1429,10 +1445,7 @@ public class Runtime { *

      Two {@code Version}s are equal if and only if they represent the * same version string. * - *

      This method satisfies the general contract of the {@link - * Object#equals(Object) Object.equals} method.

      - * - * @param ob + * @param obj * The object to which this {@code Version} is to be compared * * @return {@code true} if, and only if, the given object is a {@code @@ -1440,12 +1453,12 @@ public class Runtime { * */ @Override - public boolean equals(Object ob) { - boolean ret = equalsIgnoreOptional(ob); + public boolean equals(Object obj) { + boolean ret = equalsIgnoreOptional(obj); if (!ret) return false; - Version that = (Version)ob; + Version that = (Version)obj; return (this.optional().equals(that.optional())); } @@ -1456,21 +1469,21 @@ public class Runtime { *

      Two {@code Version}s are equal if and only if they represent the * same version string disregarding the optional build information. * - * @param ob + * @param obj * The object to which this {@code Version} is to be compared * * @return {@code true} if, and only if, the given object is a {@code * Version} that is identical to this {@code Version} - * ignoring the optinal build information + * ignoring the optional build information * */ - public boolean equalsIgnoreOptional(Object ob) { - if (this == ob) + public boolean equalsIgnoreOptional(Object obj) { + if (this == obj) return true; - if (!(ob instanceof Version)) + if (!(obj instanceof Version)) return false; - Version that = (Version)ob; + Version that = (Version)obj; return (this.version().equals(that.version()) && this.pre().equals(that.pre()) && this.build().equals(that.build())); @@ -1479,9 +1492,6 @@ public class Runtime { /** * Returns the hash code of this version. * - *

      This method satisfies the general contract of the {@link - * Object#hashCode Object.hashCode} method. - * * @return The hashcode of this version */ @Override @@ -1509,8 +1519,7 @@ public class Runtime { private static final String BUILD = "(?:(?\\+)(?0|[1-9][0-9]*)?)?"; private static final String OPT = "(?:-(?[-a-zA-Z0-9.]+))?"; - private static final String VSTR_FORMAT - = "^" + VNUM + PRE + BUILD + OPT + "$"; + private static final String VSTR_FORMAT = VNUM + PRE + BUILD + OPT; static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT); diff --git a/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java b/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java index 46d8ef23c08..b1a4280498a 100644 --- a/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java +++ b/jdk/src/java.base/share/classes/java/lang/RuntimePermission.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 @@ -26,9 +26,7 @@ package java.lang; import java.security.*; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.StringTokenizer; +import java.lang.module.ModuleFinder; /** * This class is for runtime permissions. A {@code RuntimePermission} @@ -45,13 +43,17 @@ import java.util.StringTokenizer; * target names, and for each provides a description of what the permission * allows and a discussion of the risks of granting code the permission. * - * + *
      + * + * * * * * * + * + * * * * @@ -265,6 +267,16 @@ import java.util.StringTokenizer; * * * + * + * + * + * + * + * * * * * * + * + * + * + * + * + * * * @@ -359,6 +379,15 @@ import java.util.StringTokenizer; * * + * + * + * + * + * + * + * + * *
      permission target name, + * what the target allows, and associated risks
      Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
      createClassLoader
      defineClassDefine a class with + * {@link java.lang.invoke.MethodHandles.Lookup#defineClass(byte[]) + * Lookup.defineClass}.This grants code with a suitably privileged {@code Lookup} object + * permission to define classes in the same package as the {@code Lookup}'s + * lookup class.
      accessDeclaredMembersAccess to the declared members of a classThis grants code permission to query a class for its public, @@ -298,6 +310,14 @@ import java.util.StringTokenizer; *
      getStackWalkerWithClassReferenceGet a stack walker that can retrieve stack frames with class reference.This allows retrieval of Class objects from stack walking. + * This might allow malicious code to access Class objects on the stack + * outside its own context.
      setDefaultUncaughtExceptionHandlerSetting the default handler to be used when a thread * terminates abruptly due to an uncaught exceptionSee {@link java.lang.System.LoggerFinder java.lang.System.LoggerFinder} * for more information.
      accessSystemModulesAccess system modules in the runtime image.This grants the permission to access resources in the + * {@linkplain ModuleFinder#ofSystem system modules} in the runtime image.
      * * @implNote 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 8a819ee6db7..b60d63e5f02 100644 --- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java +++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java @@ -25,13 +25,11 @@ package java.lang; -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.module.ModuleReference; import java.lang.reflect.Member; -import java.lang.reflect.Module; import java.io.FileDescriptor; import java.io.File; import java.io.FilePermission; @@ -44,12 +42,15 @@ import java.security.PrivilegedAction; import java.security.Security; import java.security.SecurityPermission; import java.util.HashSet; +import java.util.Map; import java.util.Objects; import java.util.PropertyPermission; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import java.util.stream.Stream; +import jdk.internal.module.ModuleBootstrap; +import jdk.internal.module.ModuleLoaderMap; import jdk.internal.reflect.CallerSensitive; import sun.security.util.SecurityConstants; @@ -1433,36 +1434,40 @@ class SecurityManager { 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; - + // The non-exported packages in modules defined to the boot or platform + // class loaders. A non-exported package is a package that is not exported + // or is only exported to specific modules. + private static final Map nonExportedPkgs = new ConcurrentHashMap<>(); 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()); + addNonExportedPackages(ModuleLayer.boot()); } /** - * Returns true if the module's loader is the boot or platform loader. + * Record the non-exported packages of the modules in the given layer */ - private static boolean isBootOrPlatformModule(Module m) { - return m.getClassLoader() == null || - m.getClassLoader() == ClassLoader.getPlatformClassLoader(); + static void addNonExportedPackages(ModuleLayer layer) { + Set bootModules = ModuleLoaderMap.bootModules(); + Set platformModules = ModuleLoaderMap.platformModules(); + layer.modules().stream() + .map(Module::getDescriptor) + .filter(md -> bootModules.contains(md.name()) + || platformModules.contains(md.name())) + .map(SecurityManager::nonExportedPkgs) + .flatMap(Set::stream) + .forEach(pn -> nonExportedPkgs.put(pn, Boolean.TRUE)); + } + + + /** + * Called by java.security.Security + */ + static void invalidatePackageAccessCache() { + synchronized (packageAccessLock) { + packageAccessValid = false; + } + synchronized (packageDefinitionLock) { + packageDefinitionValid = false; + } } /** @@ -1525,7 +1530,7 @@ class SecurityManager { Objects.requireNonNull(pkg, "package name can't be null"); // check if pkg is not exported to all modules - if (nonExportedPkgs.contains(pkg)) { + if (nonExportedPkgs.containsKey(pkg)) { checkPermission( new RuntimePermission("accessClassInPackage." + pkg)); return; @@ -1624,7 +1629,7 @@ class SecurityManager { Objects.requireNonNull(pkg, "package name can't be null"); // check if pkg is not exported to all modules - if (nonExportedPkgs.contains(pkg)) { + if (nonExportedPkgs.containsKey(pkg)) { checkPermission( new RuntimePermission("defineClassInPackage." + pkg)); return; diff --git a/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java b/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java index 55976485d4f..00cec33e2a2 100644 --- a/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java +++ b/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java @@ -25,11 +25,13 @@ package java.lang; import jdk.internal.reflect.MethodAccessor; +import jdk.internal.reflect.ConstructorAccessor; import java.lang.StackWalker.Option; import java.lang.StackWalker.StackFrame; import java.lang.annotation.Native; import java.lang.reflect.Method; +import java.lang.reflect.Constructor; import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Objects; @@ -684,7 +686,7 @@ final class StackStreamFactory { frames[n++] = caller; } if (frames[1] == null) { - throw new IllegalStateException("no caller frame"); + throw new IllegalCallerException("no caller frame"); } return n; } @@ -922,7 +924,8 @@ final class StackStreamFactory { */ final void setBatch(int depth, int startIndex, int endIndex) { if (startIndex <= 0 || endIndex <= 0) - throw new IllegalArgumentException("startIndex=" + startIndex + " endIndex=" + endIndex); + throw new IllegalArgumentException("startIndex=" + startIndex + + " endIndex=" + endIndex); this.origin = startIndex; this.fence = endIndex; @@ -979,14 +982,12 @@ final class StackStreamFactory { } private static boolean isReflectionFrame(Class c) { - if (c.getName().startsWith("jdk.internal.reflect") && - !MethodAccessor.class.isAssignableFrom(c)) { - throw new InternalError("Not jdk.internal.reflect.MethodAccessor: " + c.toString()); - } // ## should filter all @Hidden frames? return c == Method.class || - MethodAccessor.class.isAssignableFrom(c) || - c.getName().startsWith("java.lang.invoke.LambdaForm"); + c == Constructor.class || + MethodAccessor.class.isAssignableFrom(c) || + ConstructorAccessor.class.isAssignableFrom(c) || + c.getName().startsWith("java.lang.invoke.LambdaForm"); } } diff --git a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java index d95ea5ef826..b96fb363559 100644 --- a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java +++ b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java @@ -33,8 +33,6 @@ import jdk.internal.module.ModuleReferenceImpl; import java.lang.module.ModuleDescriptor.Version; import java.lang.module.ModuleReference; import java.lang.module.ResolvedModule; -import java.lang.reflect.Layer; -import java.lang.reflect.Module; import java.util.HashSet; import java.util.Objects; import java.util.Optional; @@ -92,6 +90,8 @@ public final class StackTraceElement implements java.io.Serializable { * @throws NullPointerException if {@code declaringClass} or * {@code methodName} is null * @since 1.5 + * @revised 9 + * @spec JPMS */ public StackTraceElement(String declaringClass, String methodName, String fileName, int lineNumber) { @@ -128,6 +128,7 @@ public final class StackTraceElement implements java.io.Serializable { * or {@code methodName} is {@code null} * * @since 9 + * @spec JPMS */ public StackTraceElement(String classLoaderName, String moduleName, String moduleVersion, @@ -187,7 +188,8 @@ public final class StackTraceElement implements java.io.Serializable { * point represented by this stack trace element; {@code null} * if the module name is not available. * @since 9 - * @see java.lang.reflect.Module#getName() + * @spec JPMS + * @see Module#getName() */ public String getModuleName() { return moduleName; @@ -201,6 +203,7 @@ public final class StackTraceElement implements java.io.Serializable { * point represented by this stack trace element; {@code null} * if the module version is not available. * @since 9 + * @spec JPMS * @see java.lang.module.ModuleDescriptor.Version */ public String getModuleVersion() { @@ -216,6 +219,7 @@ public final class StackTraceElement implements java.io.Serializable { * if the class loader is not named. * * @since 9 + * @spec JPMS * @see java.lang.ClassLoader#getName() */ public String getClassLoaderName() { @@ -329,6 +333,8 @@ public final class StackTraceElement implements java.io.Serializable { * {@link java.lang.StackWalker.StackFrame}, where an implementation may * choose to omit some element in the returned string. * + * @revised 9 + * @spec JPMS * @see Throwable#printStackTrace() */ public String toString() { @@ -376,6 +382,9 @@ public final class StackTraceElement implements java.io.Serializable { * @return true if the specified object is another * {@code StackTraceElement} instance representing the same * execution point as this instance. + * + * @revised 9 + * @spec JPMS */ public boolean equals(Object obj) { if (obj==this) @@ -469,7 +478,7 @@ public final class StackTraceElement implements java.io.Serializable { if (!VM.isModuleSystemInited()) return true; - return Layer.boot() == m.getLayer() && HashedModules.contains(m); + return ModuleLayer.boot() == m.getLayer() && HashedModules.contains(m); } /* @@ -481,7 +490,7 @@ public final class StackTraceElement implements java.io.Serializable { static Set hashedModules() { - Optional resolvedModule = Layer.boot() + Optional resolvedModule = ModuleLayer.boot() .configuration() .findModule("java.base"); assert resolvedModule.isPresent(); diff --git a/jdk/src/java.base/share/classes/java/lang/StackWalker.java b/jdk/src/java.base/share/classes/java/lang/StackWalker.java index b5c43fd2d67..7e4bc1ebf88 100644 --- a/jdk/src/java.base/share/classes/java/lang/StackWalker.java +++ b/jdk/src/java.base/share/classes/java/lang/StackWalker.java @@ -29,6 +29,7 @@ import jdk.internal.reflect.CallerSensitive; import java.util.*; import java.util.function.Consumer; import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Stream; /** @@ -207,13 +208,23 @@ public final class StackWalker { /** * Shows all reflection frames. * - *

      By default, reflection frames are hidden. This includes the - * {@link java.lang.reflect.Method#invoke} method - * and the reflection implementation classes. A {@code StackWalker} with - * this {@code SHOW_REFLECT_FRAMES} option will show all reflection frames. - * The {@link #SHOW_HIDDEN_FRAMES} option can also be used to show all + *

      By default, reflection frames are hidden. A {@code StackWalker} + * configured with this {@code SHOW_REFLECT_FRAMES} option + * will show all reflection frames that + * include {@link java.lang.reflect.Method#invoke} and + * {@link java.lang.reflect.Constructor#newInstance(Object...)} + * and their reflection implementation classes. + * + *

      The {@link #SHOW_HIDDEN_FRAMES} option can also be used to show all * reflection frames and it will also show other hidden frames that * are implementation-specific. + * + * @apiNote + * This option includes the stack frames representing the invocation of + * {@code Method} and {@code Constructor}. Any utility methods that + * are equivalent to calling {@code Method.invoke} or + * {@code Constructor.newInstance} such as {@code Class.newInstance} + * are not filtered or controlled by any stack walking option. */ SHOW_REFLECT_FRAMES, /** @@ -268,7 +279,7 @@ public final class StackWalker { * If a security manager is present and the given {@code option} is * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}, * it calls its {@link SecurityManager#checkPermission checkPermission} - * method for {@code StackFramePermission("retainClassReference")}. + * method for {@code RuntimePermission("getStackWalkerWithClassReference")}. * * @param option {@link Option stack walking option} * @@ -292,7 +303,7 @@ public final class StackWalker { * If a security manager is present and the given {@code options} contains * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}, * it calls its {@link SecurityManager#checkPermission checkPermission} - * method for {@code StackFramePermission("retainClassReference")}. + * method for {@code RuntimePermission("getStackWalkerWithClassReference")}. * * @param options {@link Option stack walking option} * @@ -322,7 +333,7 @@ public final class StackWalker { * If a security manager is present and the given {@code options} contains * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}, * it calls its {@link SecurityManager#checkPermission checkPermission} - * method for {@code StackFramePermission("retainClassReference")}. + * method for {@code RuntimePermission("getStackWalkerWithClassReference")}. * *

      * The {@code estimateDepth} specifies the estimate number of stack frames @@ -365,7 +376,7 @@ public final class StackWalker { SecurityManager sm = System.getSecurityManager(); if (sm != null) { if (options.contains(Option.RETAIN_CLASS_REFERENCE)) { - sm.checkPermission(new StackFramePermission("retainClassReference")); + sm.checkPermission(new RuntimePermission("getStackWalkerWithClassReference")); } } } @@ -465,28 +476,31 @@ public final class StackWalker { } /** - * Gets the {@code Class} object of the caller invoking the method - * that calls this {@code getCallerClass} method. + * Gets the {@code Class} object of the caller who invoked the method + * that invoked {@code getCallerClass}. * - *

      Reflection frames, {@link java.lang.invoke.MethodHandle}, and - * hidden frames are filtered regardless of the + *

      This method filters {@linkplain Option#SHOW_REFLECT_FRAMES reflection + * frames}, {@link java.lang.invoke.MethodHandle}, and + * {@linkplain Option#SHOW_HIDDEN_FRAMES hidden frames} regardless of the * {@link Option#SHOW_REFLECT_FRAMES SHOW_REFLECT_FRAMES} * and {@link Option#SHOW_HIDDEN_FRAMES SHOW_HIDDEN_FRAMES} options * this {@code StackWalker} has been configured with. * + *

      This method should be called when a caller frame is present. If + * it is called from the bottom most frame on the stack, + * {@code IllegalCallerException} will be thrown. + * *

      This method throws {@code UnsupportedOperationException} * if this {@code StackWalker} is not configured with the * {@link Option#RETAIN_CLASS_REFERENCE RETAIN_CLASS_REFERENCE} option. - * This method should be called when a caller frame is present. If - * it is called from the last frame on the stack, - * {@code IllegalStateException} will be thrown. * * @apiNote * For example, {@code Util::getResourceBundle} loads a resource bundle - * on behalf of the caller. It calls this {@code getCallerClass} method - * to find the method calling {@code Util::getResourceBundle} and uses the caller's - * class loader to load the resource bundle. The caller class in this example - * is the {@code MyTool} class. + * on behalf of the caller. It invokes {@code getCallerClass} to identify + * the class whose method called {@code Util::getResourceBundle}. + * Then, it obtains the class loader of that class, and uses + * the class loader to load the resource bundle. The caller class + * in this example is {@code MyTool}. * *

      {@code
            * class Util {
      @@ -517,17 +531,17 @@ public final class StackWalker {
            * }
      * * When the {@code getCallerClass} method is called from a method that - * is the last frame on the stack, + * is the bottom most frame on the stack, * for example, {@code static public void main} method launched by the * {@code java} launcher, or a method invoked from a JNI attached thread, - * {@code IllegalStateException} is thrown. + * {@code IllegalCallerException} is thrown. * * @return {@code Class} object of the caller's caller invoking this method. * * @throws UnsupportedOperationException if this {@code StackWalker} * is not configured with {@link Option#RETAIN_CLASS_REFERENCE * Option.RETAIN_CLASS_REFERENCE}. - * @throws IllegalStateException if there is no caller frame, i.e. + * @throws IllegalCallerException if there is no caller frame, i.e. * when this {@code getCallerClass} method is called from a method * which is the last frame on the stack. */ diff --git a/jdk/src/java.base/share/classes/java/lang/StrictMath.java b/jdk/src/java.base/share/classes/java/lang/StrictMath.java index 63d895fa13c..400b3b25f34 100644 --- a/jdk/src/java.base/share/classes/java/lang/StrictMath.java +++ b/jdk/src/java.base/share/classes/java/lang/StrictMath.java @@ -975,7 +975,7 @@ public final class StrictMath { } /** - * Returns the floor modulus of the {@code long} and {@int} arguments. + * Returns the floor modulus of the {@code long} and {@code int} arguments. *

      * The floor modulus is {@code x - (floorDiv(x, y) * y)}, * has the same sign as the divisor {@code y}, and diff --git a/jdk/src/java.base/share/classes/java/lang/String.java b/jdk/src/java.base/share/classes/java/lang/String.java index 9bcc69963c7..7191669709e 100644 --- a/jdk/src/java.base/share/classes/java/lang/String.java +++ b/jdk/src/java.base/share/classes/java/lang/String.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 @@ -203,7 +203,7 @@ public final class String * Class String is special cased within the Serialization Stream Protocol. * * A String instance is written into an ObjectOutputStream according to - * + * * Object Serialization Specification, Section 6.2, "Stream Elements" */ private static final ObjectStreamField[] serialPersistentFields = @@ -335,7 +335,7 @@ public final class String * subarray. * *

      Each {@code byte} in the subarray is converted to a {@code char} as - * specified in the method above. + * specified in the {@link #String(byte[],int) String(byte[],int)} constructor. * * @deprecated This method does not properly convert bytes into characters. * As of JDK 1.1, the preferred way to do this is via the @@ -390,7 +390,7 @@ public final class String /** * Allocates a new {@code String} containing characters constructed from - * an array of 8-bit integer values. Each character cin the + * an array of 8-bit integer values. Each character c in the * resulting string is constructed from the corresponding component * b in the byte array such that: * @@ -1064,11 +1064,7 @@ public final class String if (!isLatin1()) { // utf16 str and latin1 abs can never be "equal" return false; } - for (int i = 0; i < len; i++) { - if ((char)(v1[i] & 0xff) != StringUTF16.getChar(v2, i)) { - return false; - } - } + return StringUTF16.contentEquals(v1, v2, len); } return true; } @@ -1120,10 +1116,8 @@ public final class String } } } else { - for (int i = 0; i < n; i++) { - if (StringUTF16.getChar(val, i) != cs.charAt(i)) { - return false; - } + if (!StringUTF16.contentEquals(val, cs, n)) { + return false; } } return true; @@ -1734,6 +1728,9 @@ public final class String if (tgtCount == 0) { return fromIndex; } + if (tgtCount > srcCount) { + return -1; + } if (srcCoder == tgtCoder) { return srcCoder == LATIN1 ? StringLatin1.indexOf(src, srcCount, tgt, tgtCount, fromIndex) @@ -1792,7 +1789,7 @@ public final class String * is the string being searched for. * * @param src the characters being searched. - * @param srcCoder coder handles the mapping between bytes/chars + * @param srcCoder coder handles the mapping between bytes/chars * @param srcCount count of the source string. * @param tgt the characters being searched for. * @param fromIndex the index to begin searching from. @@ -1807,12 +1804,12 @@ public final class String * consistency, don't check for null str. */ int rightIndex = srcCount - tgtCount; - if (fromIndex < 0) { - return -1; - } if (fromIndex > rightIndex) { fromIndex = rightIndex; } + if (fromIndex < 0) { + return -1; + } /* Empty string always matches. */ if (tgtCount == 0) { return fromIndex; @@ -1825,31 +1822,8 @@ public final class String if (srcCoder == LATIN1) { // && tgtCoder == UTF16 return -1; } - // srcCoder == UTF16 && tgtCoder == LATIN1 - int min = tgtCount - 1; - int i = min + fromIndex; - int strLastIndex = tgtCount - 1; - - char strLastChar = (char)(tgt[strLastIndex] & 0xff); - startSearchForLastChar: - while (true) { - while (i >= min && StringUTF16.getChar(src, i) != strLastChar) { - i--; - } - if (i < min) { - return -1; - } - int j = i - 1; - int start = j - strLastIndex; - int k = strLastIndex - 1; - while (j > start) { - if (StringUTF16.getChar(src, j--) != (tgt[k--] & 0xff)) { - i--; - continue startSearchForLastChar; - } - } - return start + 1; - } + // srcCoder == UTF16 && tgtCoder == LATIN1 + return StringUTF16.lastIndexOfLatin1(src, srcCount, tgt, tgtCount, fromIndex); } /** @@ -2229,30 +2203,35 @@ public final class String *

      The string {@code "boo:and:foo"}, for example, yields the * following results with these parameters: * - *

      + *
      + * + * * * * * * - * - * + * + * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * + * *
      Split example showing regex, limit, and result
      RegexLimitResult
      :2
      :2{@code { "boo", "and:foo" }}
      :5
      :5{@code { "boo", "and", "foo" }}
      :-2
      :-2{@code { "boo", "and", "foo" }}
      o5
      o5{@code { "b", "", ":and:f", "", "" }}
      o-2
      o-2{@code { "b", "", ":and:f", "", "" }}
      o0
      o0{@code { "b", "", ":and:f" }}
      * *

      An invocation of this method of the form @@ -2352,15 +2331,20 @@ public final class String *

      The string {@code "boo:and:foo"}, for example, yields the following * results with these expressions: * - *

      + *
      + * + * * * * * - * + * + * + * * - * + * * + * *
      Split examples showing regex and result
      RegexResult
      :
      :{@code { "boo", "and", "foo" }}
      o
      o{@code { "b", "", ":and:f" }}
      * * @@ -2471,13 +2455,17 @@ public final class String * {@code String} may be a different length than the original {@code String}. *

      * Examples of lowercase mappings are in the following table: - * + *
      + * + * * * * * * * + * + * * * * @@ -2506,6 +2494,7 @@ public final class String * sigma * * + * *
      Lowercase mapping examples showing language code of locale, upper case, lower case, and description
      Language Code of LocaleUpper CaseLower CaseDescription
      tr (Turkish)\u0130lowercased all chars in String
      * * @param locale use the case transformation rules for this locale @@ -2552,13 +2541,17 @@ public final class String *

      * Examples of locale-sensitive and 1:M case mappings are in the following table. * - * + *
      + * + * * * * * * * + * + * * * * @@ -2583,6 +2576,7 @@ public final class String * * * + * *
      Examples of locale-sensitive and 1:M case mappings. Shows Language code of locale, lower case, upper case, and description.
      Language Code of LocaleLower CaseUpper CaseDescription
      tr (Turkish)\u0069FAHRVERGNÜGEN
      * @param locale use the case transformation rules for this locale * @return the {@code String}, converted to uppercase. @@ -2672,7 +2666,6 @@ public final class String * point is passed through uninterpreted. * * @return an IntStream of char values from this sequence - * @since 9 */ @Override public IntStream chars() { @@ -2692,7 +2685,6 @@ public final class String * {@code int} values which are then passed to the stream. * * @return an IntStream of Unicode code points from this sequence - * @since 9 */ @Override public IntStream codePoints() { @@ -3080,7 +3072,8 @@ public final class String */ static void checkIndex(int index, int length) { if (index < 0 || index >= length) { - throw new StringIndexOutOfBoundsException("index " + index); + throw new StringIndexOutOfBoundsException("index " + index + + ",length " + length); } } @@ -3118,7 +3111,7 @@ public final class String * If {@code begin} is negative, {@code begin} is greater than * {@code end}, or {@code end} is greater than {@code length}. */ - private static void checkBoundsBeginEnd(int begin, int end, int length) { + static void checkBoundsBeginEnd(int begin, int end, int length) { if (begin < 0 || begin > end || end > length) { throw new StringIndexOutOfBoundsException( "begin " + begin + ", end " + end + ", length " + length); diff --git a/jdk/src/java.base/share/classes/java/lang/StringCoding.java b/jdk/src/java.base/share/classes/java/lang/StringCoding.java index ccbe6f24b43..7340fed04ca 100644 --- a/jdk/src/java.base/share/classes/java/lang/StringCoding.java +++ b/jdk/src/java.base/share/classes/java/lang/StringCoding.java @@ -46,9 +46,6 @@ import sun.nio.cs.ArrayEncoder; import static java.lang.String.LATIN1; import static java.lang.String.UTF16; import static java.lang.String.COMPACT_STRINGS; -import static java.nio.charset.StandardCharsets.ISO_8859_1; -import static java.nio.charset.StandardCharsets.US_ASCII; -import static java.nio.charset.StandardCharsets.UTF_8; /** * Utility class for string encoding and decoding. @@ -64,6 +61,10 @@ class StringCoding { private static final ThreadLocal> encoder = new ThreadLocal<>(); + private static final Charset ISO_8859_1 = Charset.forName("iso-8859-1"); + private static final Charset US_ASCII = Charset.forName("us-ascii"); + private static final Charset UTF_8 = Charset.forName("utf-8"); + private static boolean warnUnsupportedCharset = true; private static T deref(ThreadLocal> tl) { diff --git a/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.java b/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.java index f3f16088f7a..809fab8eed5 100644 --- a/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.java +++ b/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.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 @@ -293,7 +293,7 @@ final class StringConcatHelper { if (coder == String.LATIN1) { return Integer.getChars(value, index, buf); } else { - return Integer.getCharsUTF16(value, index, buf); + return StringUTF16.getChars(value, index, buf); } } @@ -311,7 +311,7 @@ final class StringConcatHelper { if (coder == String.LATIN1) { return Long.getChars(value, index, buf); } else { - return Long.getCharsUTF16(value, index, buf); + return StringUTF16.getChars(value, index, buf); } } diff --git a/jdk/src/java.base/share/classes/java/lang/StringLatin1.java b/jdk/src/java.base/share/classes/java/lang/StringLatin1.java index b307bee6d46..73a84eb91ce 100644 --- a/jdk/src/java.base/share/classes/java/lang/StringLatin1.java +++ b/jdk/src/java.base/share/classes/java/lang/StringLatin1.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 @@ -36,7 +36,6 @@ import jdk.internal.HotSpotIntrinsicCandidate; import static java.lang.String.LATIN1; import static java.lang.String.UTF16; import static java.lang.String.checkOffset; -import static java.lang.String.checkBoundsOffCount; final class StringLatin1 { @@ -566,11 +565,7 @@ final class StringLatin1 { // inflatedCopy byte[] -> byte[] @HotSpotIntrinsicCandidate public static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { - // We need a range check here because 'putChar' has no checks - checkBoundsOffCount(dstOff << 1, len << 1, dst.length); - for (int i = 0; i < len; i++) { - StringUTF16.putChar(dst, dstOff++, src[srcOff++] & 0xff); - } + StringUTF16.inflate(src, srcOff, dst, dstOff, len); } static class CharsSpliterator implements Spliterator.OfInt { diff --git a/jdk/src/java.base/share/classes/java/lang/StringUTF16.java b/jdk/src/java.base/share/classes/java/lang/StringUTF16.java index 2c0dd917a8f..e4a94d1bdf8 100644 --- a/jdk/src/java.base/share/classes/java/lang/StringUTF16.java +++ b/jdk/src/java.base/share/classes/java/lang/StringUTF16.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 @@ -30,12 +30,11 @@ import java.util.Locale; import java.util.Spliterator; import java.util.function.IntConsumer; import jdk.internal.HotSpotIntrinsicCandidate; +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.annotation.DontInline; import static java.lang.String.UTF16; import static java.lang.String.LATIN1; -import static java.lang.String.checkIndex; -import static java.lang.String.checkOffset; -import static java.lang.String.checkBoundsOffCount; final class StringUTF16 { @@ -51,33 +50,37 @@ final class StringUTF16 { } @HotSpotIntrinsicCandidate - public static void putChar(byte[] val, int index, int c) { + // intrinsic performs no bounds checks + static void putChar(byte[] val, int index, int c) { + assert index >= 0 && index < length(val) : "Trusted caller missed bounds check"; index <<= 1; val[index++] = (byte)(c >> HI_BYTE_SHIFT); val[index] = (byte)(c >> LO_BYTE_SHIFT); } @HotSpotIntrinsicCandidate - public static char getChar(byte[] val, int index) { + // intrinsic performs no bounds checks + static char getChar(byte[] val, int index) { + assert index >= 0 && index < length(val) : "Trusted caller missed bounds check"; index <<= 1; return (char)(((val[index++] & 0xff) << HI_BYTE_SHIFT) | ((val[index] & 0xff) << LO_BYTE_SHIFT)); } - public static char charAt(byte[] value, int index) { - if (index < 0 || index >= value.length >> 1) { - throw new StringIndexOutOfBoundsException(index); - } - return getChar(value, index); - } - public static int length(byte[] value) { return value.length >> 1; } - public static int codePointAt(byte[] value, int index, int end) { + private static int codePointAt(byte[] value, int index, int end, boolean checked) { + assert index < end; + if (checked) { + checkIndex(index, value); + } char c1 = getChar(value, index); if (Character.isHighSurrogate(c1) && ++index < end) { + if (checked) { + checkIndex(index, value); + } char c2 = getChar(value, index); if (Character.isLowSurrogate(c2)) { return Character.toCodePoint(c1, c2); @@ -86,10 +89,22 @@ final class StringUTF16 { return c1; } - public static int codePointBefore(byte[] value, int index) { - char c2 = getChar(value, --index); + public static int codePointAt(byte[] value, int index, int end) { + return codePointAt(value, index, end, false /* unchecked */); + } + + private static int codePointBefore(byte[] value, int index, boolean checked) { + --index; + if (checked) { + checkIndex(index, value); + } + char c2 = getChar(value, index); if (Character.isLowSurrogate(c2) && index > 0) { - char c1 = getChar(value, --index); + --index; + if (checked) { + checkIndex(index, value); + } + char c1 = getChar(value, index); if (Character.isHighSurrogate(c1)) { return Character.toCodePoint(c1, c2); } @@ -97,11 +112,19 @@ final class StringUTF16 { return c2; } - public static int codePointCount(byte[] value, int beginIndex, int endIndex) { + public static int codePointBefore(byte[] value, int index) { + return codePointBefore(value, index, false /* unchecked */); + } + + private static int codePointCount(byte[] value, int beginIndex, int endIndex, boolean checked) { + assert beginIndex <= endIndex; int count = endIndex - beginIndex; - for (int i = beginIndex; i < endIndex; ) { + int i = beginIndex; + if (checked && i < endIndex) { + checkBoundsBeginEnd(i, endIndex, value); + } + for (; i < endIndex - 1; ) { if (Character.isHighSurrogate(getChar(value, i++)) && - i < endIndex && Character.isLowSurrogate(getChar(value, i))) { count--; i++; @@ -110,6 +133,10 @@ final class StringUTF16 { return count; } + public static int codePointCount(byte[] value, int beginIndex, int endIndex) { + return codePointCount(value, beginIndex, endIndex, false /* unchecked */); + } + public static char[] toChars(byte[] value) { char[] dst = new char[value.length >> 1]; getChars(value, 0, dst.length, dst, 0); @@ -162,7 +189,7 @@ final class StringUTF16 { @HotSpotIntrinsicCandidate public static int compress(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { // We need a range check here because 'getChar' has no checks - checkBoundsOffCount(srcOff << 1, len << 1, src.length); + checkBoundsOffCount(srcOff, len, src); for (int i = 0; i < len; i++) { char c = getChar(src, srcOff); if (c > 0xFF) { @@ -212,7 +239,7 @@ final class StringUTF16 { public static void getChars(byte[] value, int srcBegin, int srcEnd, char dst[], int dstBegin) { // We need a range check here because 'getChar' has no checks if (srcBegin < srcEnd) { - checkBoundsOffCount(srcBegin << 1, (srcEnd - srcBegin) << 1, value.length); + checkBoundsOffCount(srcBegin, srcEnd - srcBegin, value); } for (int i = srcBegin; i < srcEnd; i++) { dst[dstBegin++] = getChar(value, i); @@ -319,14 +346,25 @@ final class StringUTF16 { if (str.length == 0) { return 0; } - if (value.length == 0) { + if (value.length < str.length) { return -1; } - return indexOf(value, length(value), str, length(str), 0); + return indexOfUnsafe(value, length(value), str, length(str), 0); } @HotSpotIntrinsicCandidate public static int indexOf(byte[] value, int valueCount, byte[] str, int strCount, int fromIndex) { + checkBoundsBeginEnd(fromIndex, valueCount, value); + checkBoundsBeginEnd(0, strCount, str); + return indexOfUnsafe(value, valueCount, str, strCount, fromIndex); + } + + + private static int indexOfUnsafe(byte[] value, int valueCount, byte[] str, int strCount, int fromIndex) { + assert fromIndex >= 0; + assert strCount > 0; + assert strCount <= length(str); + assert valueCount >= strCount; char first = getChar(str, 0); int max = (valueCount - strCount); for (int i = fromIndex; i <= max; i++) { @@ -348,6 +386,7 @@ final class StringUTF16 { return -1; } + /** * Handles indexOf Latin1 substring in UTF16 string. */ @@ -356,14 +395,24 @@ final class StringUTF16 { if (str.length == 0) { return 0; } - if (value.length == 0) { + if (length(value) < str.length) { return -1; } - return indexOfLatin1(value, length(value), str, str.length, 0); + return indexOfLatin1Unsafe(value, length(value), str, str.length, 0); } @HotSpotIntrinsicCandidate public static int indexOfLatin1(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex) { + checkBoundsBeginEnd(fromIndex, srcCount, src); + String.checkBoundsBeginEnd(0, tgtCount, tgt.length); + return indexOfLatin1Unsafe(src, srcCount, tgt, tgtCount, fromIndex); + } + + public static int indexOfLatin1Unsafe(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex) { + assert fromIndex >= 0; + assert tgtCount > 0; + assert tgtCount <= tgt.length; + assert srcCount >= tgtCount; char first = (char)(tgt[0] & 0xff); int max = (srcCount - tgtCount); for (int i = fromIndex; i <= max; i++) { @@ -389,6 +438,11 @@ final class StringUTF16 { @HotSpotIntrinsicCandidate private static int indexOfChar(byte[] value, int ch, int fromIndex, int max) { + checkBoundsBeginEnd(fromIndex, max, value); + return indexOfCharUnsafe(value, ch, fromIndex, max); + } + + private static int indexOfCharUnsafe(byte[] value, int ch, int fromIndex, int max) { for (int i = fromIndex; i < max; i++) { if (getChar(value, i) == ch) { return i; @@ -404,6 +458,7 @@ final class StringUTF16 { if (Character.isValidCodePoint(ch)) { final char hi = Character.highSurrogate(ch); final char lo = Character.lowSurrogate(ch); + checkBoundsBeginEnd(fromIndex, max, value); for (int i = fromIndex; i < max - 1; i++) { if (getChar(value, i) == hi && getChar(value, i + 1 ) == lo) { return i; @@ -413,13 +468,21 @@ final class StringUTF16 { return -1; } + // srcCoder == UTF16 && tgtCoder == UTF16 public static int lastIndexOf(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex) { + assert fromIndex >= 0; + assert tgtCount > 0; + assert tgtCount <= length(tgt); int min = tgtCount - 1; int i = min + fromIndex; int strLastIndex = tgtCount - 1; + + checkIndex(strLastIndex, tgt); char strLastChar = getChar(tgt, strLastIndex); + checkIndex(i, src); + startSearchForLastChar: while (true) { while (i >= min && getChar(src, i) != strLastChar) { @@ -509,6 +572,9 @@ final class StringUTF16 { public static boolean regionMatchesCI(byte[] value, int toffset, byte[] other, int ooffset, int len) { int last = toffset + len; + assert toffset >= 0 && ooffset >= 0; + assert ooffset + len <= length(other); + assert last <= length(value); while (toffset < last) { char c1 = getChar(value, toffset++); char c2 = getChar(other, ooffset++); @@ -599,6 +665,8 @@ final class StringUTF16 { private static String toLowerCaseEx(String str, byte[] value, byte[] result, int first, Locale locale, boolean localeDependent) { + assert(result.length == value.length); + assert(first >= 0); int resultOffset = first; int length = value.length >> 1; int srcCount; @@ -633,6 +701,8 @@ final class StringUTF16 { System.arraycopy(result, 0, result2, 0, resultOffset << 1); result = result2; } + assert resultOffset >= 0; + assert resultOffset + mapLen <= length(result); for (int x = 0; x < mapLen; ++x) { putChar(result, resultOffset++, lowerCharArray[x]); } @@ -697,6 +767,8 @@ final class StringUTF16 { byte[] result, int first, Locale locale, boolean localeDependent) { + assert(result.length == value.length); + assert(first >= 0); int resultOffset = first; int length = value.length >> 1; int srcCount; @@ -733,10 +805,12 @@ final class StringUTF16 { byte[] result2 = newBytesFor((result.length >> 1) + mapLen - srcCount); System.arraycopy(result, 0, result2, 0, resultOffset << 1); result = result2; - } - for (int x = 0; x < mapLen; ++x) { + } + assert resultOffset >= 0; + assert resultOffset + mapLen <= length(result); + for (int x = 0; x < mapLen; ++x) { putChar(result, resultOffset++, upperCharArray[x]); - } + } } } return newString(result, 0, resultOffset); @@ -757,7 +831,7 @@ final class StringUTF16 { null; } - public static void putChars(byte[] val, int index, char[] str, int off, int end) { + private static void putChars(byte[] val, int index, char[] str, int off, int end) { while (off < end) { putChar(val, index++, str[off++]); } @@ -927,35 +1001,172 @@ final class StringUTF16 { //////////////////////////////////////////////////////////////// public static void putCharSB(byte[] val, int index, int c) { - checkIndex(index, val.length >> 1); + checkIndex(index, val); putChar(val, index, c); } public static void putCharsSB(byte[] val, int index, char[] ca, int off, int end) { - checkOffset(index + end - off, val.length >> 1); + checkBoundsBeginEnd(index, index + end - off, val); putChars(val, index, ca, off, end); } public static void putCharsSB(byte[] val, int index, CharSequence s, int off, int end) { - checkOffset(index + end - off, val.length >> 1); + checkBoundsBeginEnd(index, index + end - off, val); for (int i = off; i < end; i++) { putChar(val, index++, s.charAt(i)); } } public static int codePointAtSB(byte[] val, int index, int end) { - checkOffset(end, val.length >> 1); - return codePointAt(val, index, end); + return codePointAt(val, index, end, true /* checked */); } public static int codePointBeforeSB(byte[] val, int index) { - checkOffset(index, val.length >> 1); - return codePointBefore(val, index); + return codePointBefore(val, index, true /* checked */); } public static int codePointCountSB(byte[] val, int beginIndex, int endIndex) { - checkOffset(endIndex, val.length >> 1); - return codePointCount(val, beginIndex, endIndex); + return codePointCount(val, beginIndex, endIndex, true /* checked */); + } + + public static int getChars(int i, int begin, int end, byte[] value) { + checkBoundsBeginEnd(begin, end, value); + int pos = getChars(i, end, value); + assert begin == pos; + return pos; + } + + public static int getChars(long l, int begin, int end, byte[] value) { + checkBoundsBeginEnd(begin, end, value); + int pos = getChars(l, end, value); + assert begin == pos; + return pos; + } + + public static boolean contentEquals(byte[] v1, byte[] v2, int len) { + checkBoundsOffCount(0, len, v2); + for (int i = 0; i < len; i++) { + if ((char)(v1[i] & 0xff) != getChar(v2, i)) { + return false; + } + } + return true; + } + + public static boolean contentEquals(byte[] value, CharSequence cs, int len) { + checkOffset(len, value); + for (int i = 0; i < len; i++) { + if (getChar(value, i) != cs.charAt(i)) { + return false; + } + } + return true; + } + + public static int putCharsAt(byte[] value, int i, char c1, char c2, char c3, char c4) { + int end = i + 4; + checkBoundsBeginEnd(i, end, value); + putChar(value, i++, c1); + putChar(value, i++, c2); + putChar(value, i++, c3); + putChar(value, i++, c4); + assert(i == end); + return end; + } + + public static int putCharsAt(byte[] value, int i, char c1, char c2, char c3, char c4, char c5) { + int end = i + 5; + checkBoundsBeginEnd(i, end, value); + putChar(value, i++, c1); + putChar(value, i++, c2); + putChar(value, i++, c3); + putChar(value, i++, c4); + putChar(value, i++, c5); + assert(i == end); + return end; + } + + public static char charAt(byte[] value, int index) { + checkIndex(index, value); + return getChar(value, index); + } + + public static void reverse(byte[] val, int count) { + checkOffset(count, val); + int n = count - 1; + boolean hasSurrogates = false; + for (int j = (n-1) >> 1; j >= 0; j--) { + int k = n - j; + char cj = getChar(val, j); + char ck = getChar(val, k); + putChar(val, j, ck); + putChar(val, k, cj); + if (Character.isSurrogate(cj) || + Character.isSurrogate(ck)) { + hasSurrogates = true; + } + } + if (hasSurrogates) { + reverseAllValidSurrogatePairs(val, count); + } + } + + /** Outlined helper method for reverse() */ + private static void reverseAllValidSurrogatePairs(byte[] val, int count) { + for (int i = 0; i < count - 1; i++) { + char c2 = getChar(val, i); + if (Character.isLowSurrogate(c2)) { + char c1 = getChar(val, i + 1); + if (Character.isHighSurrogate(c1)) { + putChar(val, i++, c1); + putChar(val, i, c2); + } + } + } + } + + // inflatedCopy byte[] -> byte[] + public static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { + // We need a range check here because 'putChar' has no checks + checkBoundsOffCount(dstOff, len, dst); + for (int i = 0; i < len; i++) { + putChar(dst, dstOff++, src[srcOff++] & 0xff); + } + } + + // srcCoder == UTF16 && tgtCoder == LATIN1 + public static int lastIndexOfLatin1(byte[] src, int srcCount, + byte[] tgt, int tgtCount, int fromIndex) { + assert fromIndex >= 0; + assert tgtCount > 0; + assert tgtCount <= tgt.length; + int min = tgtCount - 1; + int i = min + fromIndex; + int strLastIndex = tgtCount - 1; + + char strLastChar = (char)(tgt[strLastIndex] & 0xff); + + checkIndex(i, src); + + startSearchForLastChar: + while (true) { + while (i >= min && getChar(src, i) != strLastChar) { + i--; + } + if (i < min) { + return -1; + } + int j = i - 1; + int start = j - strLastIndex; + int k = strLastIndex - 1; + while (j > start) { + if (getChar(src, j--) != (tgt[k--] & 0xff)) { + i--; + continue startSearchForLastChar; + } + } + return start + 1; + } } //////////////////////////////////////////////////////////////// @@ -975,4 +1186,123 @@ final class StringUTF16 { } static final int MAX_LENGTH = Integer.MAX_VALUE >> 1; + + // Used by trusted callers. Assumes all necessary bounds checks have + // been done by the caller. + + /** + * This is a variant of {@link Integer#getChars(int, int, byte[])}, but for + * UTF-16 coder. + * + * @param i value to convert + * @param index next index, after the least significant digit + * @param buf target buffer, UTF16-coded. + * @return index of the most significant digit or minus sign, if present + */ + static int getChars(int i, int index, byte[] buf) { + int q, r; + int charPos = index; + + boolean negative = (i < 0); + if (!negative) { + i = -i; + } + + // Get 2 digits/iteration using ints + while (i <= -100) { + q = i / 100; + r = (q * 100) - i; + i = q; + putChar(buf, --charPos, Integer.DigitOnes[r]); + putChar(buf, --charPos, Integer.DigitTens[r]); + } + + // We know there are at most two digits left at this point. + q = i / 10; + r = (q * 10) - i; + putChar(buf, --charPos, '0' + r); + + // Whatever left is the remaining digit. + if (q < 0) { + putChar(buf, --charPos, '0' - q); + } + + if (negative) { + putChar(buf, --charPos, '-'); + } + return charPos; + } + + /** + * This is a variant of {@link Long#getChars(long, int, byte[])}, but for + * UTF-16 coder. + * + * @param i value to convert + * @param index next index, after the least significant digit + * @param buf target buffer, UTF16-coded. + * @return index of the most significant digit or minus sign, if present + */ + static int getChars(long i, int index, byte[] buf) { + long q; + int r; + int charPos = index; + + boolean negative = (i < 0); + if (!negative) { + i = -i; + } + + // Get 2 digits/iteration using longs until quotient fits into an int + while (i <= Integer.MIN_VALUE) { + q = i / 100; + r = (int)((q * 100) - i); + i = q; + putChar(buf, --charPos, Integer.DigitOnes[r]); + putChar(buf, --charPos, Integer.DigitTens[r]); + } + + // Get 2 digits/iteration using ints + int q2; + int i2 = (int)i; + while (i2 <= -100) { + q2 = i2 / 100; + r = (q2 * 100) - i2; + i2 = q2; + putChar(buf, --charPos, Integer.DigitOnes[r]); + putChar(buf, --charPos, Integer.DigitTens[r]); + } + + // We know there are at most two digits left at this point. + q2 = i2 / 10; + r = (q2 * 10) - i2; + putChar(buf, --charPos, '0' + r); + + // Whatever left is the remaining digit. + if (q2 < 0) { + putChar(buf, --charPos, '0' - q2); + } + + if (negative) { + putChar(buf, --charPos, '-'); + } + return charPos; + } + // End of trusted methods. + + public static void checkIndex(int off, byte[] val) { + String.checkIndex(off, length(val)); + } + + public static void checkOffset(int off, byte[] val) { + String.checkOffset(off, length(val)); + } + + public static void checkBoundsBeginEnd(int begin, int end, byte[] val) { + String.checkBoundsBeginEnd(begin, end, length(val)); + } + + public static void checkBoundsOffCount(int offset, int count, byte[] val) { + String.checkBoundsOffCount(offset, count, length(val)); + } + } 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 1577e215e35..10664819e4f 100644 --- a/jdk/src/java.base/share/classes/java/lang/System.java +++ b/jdk/src/java.base/share/classes/java/lang/System.java @@ -35,32 +35,31 @@ import java.io.InputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.lang.annotation.Annotation; +import java.lang.module.ModuleDescriptor; import java.lang.reflect.Constructor; import java.lang.reflect.Executable; -import java.lang.reflect.Layer; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.Module; -import java.net.URL; +import java.net.URI; import java.security.AccessControlContext; -import java.util.Properties; -import java.util.PropertyPermission; -import java.util.Map; +import java.security.ProtectionDomain; import java.security.AccessController; import java.security.PrivilegedAction; import java.nio.channels.Channel; import java.nio.channels.spi.SelectorProvider; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.PropertyPermission; +import java.util.ResourceBundle; +import java.util.function.Supplier; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; -import java.util.Objects; -import java.util.ResourceBundle; -import java.util.function.Supplier; -import sun.nio.ch.Interruptible; +import jdk.internal.module.ModuleBootstrap; +import jdk.internal.module.ServicesCatalog; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; -import sun.security.util.SecurityConstants; -import sun.reflect.annotation.AnnotationType; import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.misc.JavaLangAccess;; import jdk.internal.misc.SharedSecrets;; @@ -68,8 +67,9 @@ import jdk.internal.misc.VM; import jdk.internal.logger.LoggerFinderLoader; import jdk.internal.logger.LazyLoggers; import jdk.internal.logger.LocalizedLoggerWrapper; - -import jdk.internal.module.ModuleBootstrap; +import sun.reflect.annotation.AnnotationType; +import sun.nio.ch.Interruptible; +import sun.security.util.SecurityConstants; /** * The System class contains several useful class fields @@ -575,9 +575,13 @@ public final class System { * system properties, a set of system properties is first created and * initialized. This set of system properties always includes values * for the following keys: - * + *
      + * + * * * + * + * * * @@ -636,6 +640,7 @@ public final class System { * * * + * *
      Shows property keys and associated values
      KeyDescription of Associated Value
      java.versionJava Runtime Environment version which may be interpreted * as a {@link Runtime.Version}
      User's home directory
      user.dirUser's current working directory
      *

      * Multiple paths in a system property value are separated by the path @@ -647,9 +652,13 @@ public final class System { * * @implNote In addition to the standard system properties, the system * properties may include the following keys: - * + *
      + * + * * * + * + * * * * @@ -658,6 +667,7 @@ public final class System { * * * + * *
      Shows property keys and associated values
      KeyDescription of Associated Value
      {@code jdk.module.path}The application module path
      {@code jdk.module.upgrade.path}The module name of the initial/main module
      {@code jdk.module.main.class}The main class name of the initial module
      * * @return the system properties @@ -898,7 +908,7 @@ public final class System { * being thrown. If no exception is thrown the value of the * variable name is returned. * - *

      System + *

      System * properties and environment variables are both * conceptually mappings between names and values. Both * mechanisms can be used to pass user-defined information to a @@ -1159,7 +1169,7 @@ public final class System { * @param msg the string message (or a key in the message catalog, if * this logger is a {@link * LoggerFinder#getLocalizedLogger(java.lang.String, - * java.util.ResourceBundle, java.lang.reflect.Module) localized logger}); + * java.util.ResourceBundle, java.lang.Module) localized logger}); * can be {@code null}. * * @throws NullPointerException if {@code level} is {@code null}. @@ -1227,7 +1237,7 @@ public final class System { * @param msg the string message (or a key in the message catalog, if * this logger is a {@link * LoggerFinder#getLocalizedLogger(java.lang.String, - * java.util.ResourceBundle, java.lang.reflect.Module) localized logger}); + * java.util.ResourceBundle, java.lang.Module) localized logger}); * can be {@code null}. * @param thrown a {@code Throwable} associated with the log message; * can be {@code null}. @@ -1276,7 +1286,7 @@ public final class System { * java.text.MessageFormat} format, (or a key in the message * catalog, if this logger is a {@link * LoggerFinder#getLocalizedLogger(java.lang.String, - * java.util.ResourceBundle, java.lang.reflect.Module) localized logger}); + * java.util.ResourceBundle, java.lang.Module) localized logger}); * can be {@code null}. * @param params an optional list of parameters to the message (may be * none). @@ -1481,7 +1491,7 @@ public final class System { * message localization. * * @implSpec By default, this method calls {@link - * #getLogger(java.lang.String, java.lang.reflect.Module) + * #getLogger(java.lang.String, java.lang.Module) * this.getLogger(name, module)} to obtain a logger, then wraps that * logger in a {@link Logger} instance where all methods that do not * take a {@link ResourceBundle} as parameter are redirected to one @@ -1565,12 +1575,20 @@ public final class System { * @implSpec * Instances returned by this method route messages to loggers * obtained by calling {@link LoggerFinder#getLogger(java.lang.String, - * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where + * java.lang.Module) LoggerFinder.getLogger(name, module)}, where * {@code module} is the caller's module. + * In cases where {@code System.getLogger} is called from a context where + * there is no caller frame on the stack (e.g when called directly + * from a JNI attached thread), {@code IllegalCallerException} is thrown. + * To obtain a logger in such a context, use an auxiliary class that will + * implicitly be identified as the caller, or use the system {@link + * LoggerFinder#getLoggerFinder() LoggerFinder} to obtain a logger instead. + * Note that doing the latter may eagerly initialize the underlying + * logging system. * * @apiNote * This method may defer calling the {@link - * LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module) + * LoggerFinder#getLogger(java.lang.String, java.lang.Module) * LoggerFinder.getLogger} method to create an actual logger supplied by * the logging backend, for instance, to allow loggers to be obtained during * the system initialization time. @@ -1579,6 +1597,8 @@ public final class System { * @return an instance of {@link Logger} that can be used by the calling * class. * @throws NullPointerException if {@code name} is {@code null}. + * @throws IllegalCallerException if there is no Java caller frame on the + * stack. * * @since 9 */ @@ -1586,6 +1606,9 @@ public final class System { public static Logger getLogger(String name) { Objects.requireNonNull(name); final Class caller = Reflection.getCallerClass(); + if (caller == null) { + throw new IllegalCallerException("no caller frame"); + } return LazyLoggers.getLogger(name, caller.getModule()); } @@ -1598,9 +1621,17 @@ public final class System { * @implSpec * The returned logger will perform message localization as specified * by {@link LoggerFinder#getLocalizedLogger(java.lang.String, - * java.util.ResourceBundle, java.lang.reflect.Module) - * LoggerFinder.getLocalizedLogger(name, bundle, module}, where + * java.util.ResourceBundle, java.lang.Module) + * LoggerFinder.getLocalizedLogger(name, bundle, module)}, where * {@code module} is the caller's module. + * In cases where {@code System.getLogger} is called from a context where + * there is no caller frame on the stack (e.g when called directly + * from a JNI attached thread), {@code IllegalCallerException} is thrown. + * To obtain a logger in such a context, use an auxiliary class that + * will implicitly be identified as the caller, or use the system {@link + * LoggerFinder#getLoggerFinder() LoggerFinder} to obtain a logger instead. + * Note that doing the latter may eagerly initialize the underlying + * logging system. * * @apiNote * This method is intended to be used after the system is fully initialized. @@ -1619,6 +1650,8 @@ public final class System { * resource bundle for message localization. * @throws NullPointerException if {@code name} is {@code null} or * {@code bundle} is {@code null}. + * @throws IllegalCallerException if there is no Java caller frame on the + * stack. * * @since 9 */ @@ -1627,6 +1660,9 @@ public final class System { final ResourceBundle rb = Objects.requireNonNull(bundle); Objects.requireNonNull(name); final Class caller = Reflection.getCallerClass(); + if (caller == null) { + throw new IllegalCallerException("no caller frame"); + } final SecurityManager sm = System.getSecurityManager(); // We don't use LazyLoggers if a resource bundle is specified. // Bootstrap sensitive classes in the JDK do not use resource bundles @@ -1737,6 +1773,7 @@ public final class System { * @since 1.1 */ @Deprecated(since="1.2", forRemoval=true) + @SuppressWarnings("removal") public static void runFinalizersOnExit(boolean value) { Runtime.runFinalizersOnExit(value); } @@ -1844,6 +1881,39 @@ public final class System { return new PrintStream(new BufferedOutputStream(fos, 128), true); } + /** + * Logs an exception/error at initialization time to stdout or stderr. + * + * @param printToStderr to print to stderr rather than stdout + * @param printStackTrace to print the stack trace + * @param msg the message to print before the exception, can be {@code null} + * @param e the exception or error + */ + private static void logInitException(boolean printToStderr, + boolean printStackTrace, + String msg, + Throwable e) { + if (VM.initLevel() < 1) { + throw new InternalError("system classes not initialized"); + } + PrintStream log = (printToStderr) ? err : out; + if (msg != null) { + log.println(msg); + } + if (printStackTrace) { + e.printStackTrace(log); + } else { + log.println(e); + for (Throwable suppressed : e.getSuppressed()) { + log.println("Suppressed: " + suppressed); + } + Throwable cause = e.getCause(); + if (cause != null) { + log.println("Caused by: " + cause); + } + } + } + /** * Initialize the system class. Called after thread initialization. */ @@ -1917,18 +1987,30 @@ public final class System { } // @see #initPhase2() - private static Layer bootLayer; + static ModuleLayer bootLayer; /* * Invoked by VM. Phase 2 module system initialization. * Only classes in java.base can be loaded in this phase. + * + * @param printToStderr print exceptions to stderr rather than stdout + * @param printStackTrace print stack trace when exception occurs + * + * @return JNI_OK for success, JNI_ERR for failure */ - private static void initPhase2() { - // initialize the module system - System.bootLayer = ModuleBootstrap.boot(); + private static int initPhase2(boolean printToStderr, boolean printStackTrace) { + try { + bootLayer = ModuleBootstrap.boot(); + } catch (Exception | Error e) { + logInitException(printToStderr, printStackTrace, + "Error occurred during initialization of boot layer", e); + return -1; // JNI_ERR + } // module system initialized VM.initLevel(2); + + return 0; // JNI_OK } /* @@ -1942,10 +2024,6 @@ public final class System { * the application classpath or modulepath. */ private static void initPhase3() { - // Initialize publicLookup early, to avoid bootstrapping circularities - // with security manager using java.lang.invoke infrastructure. - java.lang.invoke.MethodHandles.publicLookup(); - // set security manager String cn = System.getProperty("java.security.manager"); if (cn != null) { @@ -2029,21 +2107,19 @@ public final class System { public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) { return new Thread(target, acc); } + @SuppressWarnings("deprecation") public void invokeFinalize(Object o) throws Throwable { o.finalize(); } - public Layer getBootLayer() { - return bootLayer; - } public ConcurrentHashMap createOrGetClassLoaderValueMap(ClassLoader cl) { return cl.createOrGetClassLoaderValueMap(); } + public Class defineClass(ClassLoader loader, String name, byte[] b, ProtectionDomain pd, String source) { + return ClassLoader.defineClass1(loader, name, b, 0, b.length, pd, source); + } public Class findBootstrapClassOrNull(ClassLoader cl, String name) { return cl.findBootstrapClassOrNull(name); } - public URL findResource(ClassLoader cl, String mn, String name) throws IOException { - return cl.findResource(mn, name); - } public Stream packages(ClassLoader cl) { return cl.packages(); } @@ -2053,6 +2129,50 @@ public final class System { public String fastUUID(long lsb, long msb) { return Long.fastUUID(lsb, msb); } + public void addNonExportedPackages(ModuleLayer layer) { + SecurityManager.addNonExportedPackages(layer); + } + public void invalidatePackageAccessCache() { + SecurityManager.invalidatePackageAccessCache(); + } + public Module defineModule(ClassLoader loader, + ModuleDescriptor descriptor, + URI uri) { + return new Module(null, loader, descriptor, uri); + } + public Module defineUnnamedModule(ClassLoader loader) { + return new Module(loader); + } + public void addReads(Module m1, Module m2) { + m1.implAddReads(m2); + } + public void addReadsAllUnnamed(Module m) { + m.implAddReadsAllUnnamed(); + } + public void addExports(Module m, String pn, Module other) { + m.implAddExports(pn, other); + } + public void addExportsToAllUnnamed(Module m, String pn) { + m.implAddExportsToAllUnnamed(pn); + } + public void addOpens(Module m, String pn, Module other) { + m.implAddOpens(pn, other); + } + public void addOpensToAllUnnamed(Module m, String pn) { + m.implAddOpensToAllUnnamed(pn); + } + public void addUses(Module m, Class service) { + m.implAddUses(service); + } + public ServicesCatalog getServicesCatalog(ModuleLayer layer) { + return layer.getServicesCatalog(); + } + public Stream layers(ModuleLayer layer) { + return layer.layers(); + } + public Stream layers(ClassLoader loader) { + return ModuleLayer.layers(loader); + } }); } } diff --git a/jdk/src/java.base/share/classes/java/lang/Thread.java b/jdk/src/java.base/share/classes/java/lang/Thread.java index a7fc391d540..8ecc90dd964 100644 --- a/jdk/src/java.base/share/classes/java/lang/Thread.java +++ b/jdk/src/java.base/share/classes/java/lang/Thread.java @@ -927,7 +927,7 @@ class Thread implements Runnable { * for example), the interrupt method should be used to * interrupt the wait. * For more information, see - * Why + * Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?. */ @Deprecated(since="1.2") @@ -960,7 +960,7 @@ class Thread implements Runnable { * could be used to generate exceptions that the target thread was * not prepared to handle. * For more information, see - * Why + * Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?. * This method is subject to removal in a future version of Java SE. */ @@ -1082,7 +1082,7 @@ class Thread implements Runnable { * If another thread ever attempted to lock this resource, deadlock * would result. Such deadlocks typically manifest themselves as * "frozen" processes. For more information, see - * + * * Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?. * This method is subject to removal in a future version of Java SE. * @throws NoSuchMethodError always @@ -1122,7 +1122,7 @@ class Thread implements Runnable { * monitor prior to calling resume, deadlock results. Such * deadlocks typically manifest themselves as "frozen" processes. * For more information, see - * Why + * Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?. */ @Deprecated(since="1.2") @@ -1148,7 +1148,7 @@ class Thread implements Runnable { * @deprecated This method exists solely for use with {@link #suspend}, * which has been deprecated because it is deadlock-prone. * For more information, see - * Why + * Why * are Thread.stop, Thread.suspend and Thread.resume Deprecated?. */ @Deprecated(since="1.2") diff --git a/jdk/src/java.base/share/classes/java/lang/UnsupportedOperationException.java b/jdk/src/java.base/share/classes/java/lang/UnsupportedOperationException.java index 2d9c7a00cbf..eebc580e6f1 100644 --- a/jdk/src/java.base/share/classes/java/lang/UnsupportedOperationException.java +++ b/jdk/src/java.base/share/classes/java/lang/UnsupportedOperationException.java @@ -29,7 +29,7 @@ package java.lang; * Thrown to indicate that the requested operation is not supported.

      * * This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template index 367103a13fc..53a9160c8ce 100644 --- a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template +++ b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template @@ -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 @@ -26,7 +26,7 @@ package java.lang; import java.io.PrintStream; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -77,21 +77,32 @@ class VersionProps { // This method is reflectively used by regression tests. static List parseVersionNumbers(String version) { - List verNumbers = new ArrayList<>(4); + // Let's find the size of an array required to hold $VNUM components + int size = 0; int prevIndex = 0; + do { + prevIndex = version.indexOf('.', prevIndex) + 1; + size++; + } while (prevIndex > 0); + Integer[] verNumbers = new Integer[size]; + + // Fill in the array with $VNUM components + int n = 0; + prevIndex = 0; int index = version.indexOf('.'); - while (index > 0) { - verNumbers.add(parseVersionNumber(version, prevIndex, index)); + while (index > -1) { + verNumbers[n] = parseVersionNumber(version, prevIndex, index); prevIndex = index + 1; // Skip the period index = version.indexOf('.', prevIndex); + n++; } - verNumbers.add(parseVersionNumber(version, prevIndex, version.length())); + verNumbers[n] = parseVersionNumber(version, prevIndex, version.length()); - if (verNumbers.get(0) == 0 || verNumbers.get(verNumbers.size() - 1) == 0) - throw new IllegalArgumentException("Leading/trailing zeros not supported (" + - verNumbers + ")"); + if (verNumbers[0] == 0 || verNumbers[n] == 0) + throw new IllegalArgumentException("Leading/trailing zeros not allowed (" + + Arrays.toString(verNumbers) + ")"); - return verNumbers; + return List.of(verNumbers); } static List versionNumbers() { diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java b/jdk/src/java.base/share/classes/java/lang/WeakPairMap.java similarity index 99% rename from jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java rename to jdk/src/java.base/share/classes/java/lang/WeakPairMap.java index 39a623a4704..1e4e12767b3 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/WeakPairMap.java +++ b/jdk/src/java.base/share/classes/java/lang/WeakPairMap.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package java.lang.reflect; +package java.lang; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; diff --git a/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java b/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java index 14780fe6827..bbab9cdacc2 100644 --- a/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.java +++ b/jdk/src/java.base/share/classes/java/lang/annotation/ElementType.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 @@ -28,7 +28,7 @@ package java.lang.annotation; /** * The constants of this enumerated type provide a simple classification of the * syntactic locations where annotations may appear in a Java program. These - * constants are used in {@link Target java.lang.annotation.Target} + * constants are used in {@link java.lang.annotation.Target Target} * meta-annotations to specify where it is legal to write annotations of a * given type. * diff --git a/jdk/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html b/jdk/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html new file mode 100644 index 00000000000..aa6ba4981f4 --- /dev/null +++ b/jdk/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html @@ -0,0 +1,364 @@ + + + + + Java Thread Primitive Deprecation + + + +

      Java Thread Primitive Deprecation

      +
      +

      Why is Thread.stop deprecated?

      +

      Because it is inherently unsafe. Stopping a thread causes it to +unlock all the monitors that it has locked. (The monitors are +unlocked as the ThreadDeath exception propagates up +the stack.) If any of the objects previously protected by these +monitors were in an inconsistent state, other threads may now view +these objects in an inconsistent state. Such objects are said to be +damaged. When threads operate on damaged objects, arbitrary +behavior can result. This behavior may be subtle and difficult to +detect, or it may be pronounced. Unlike other unchecked exceptions, +ThreadDeath kills threads silently; thus, the user has +no warning that his program may be corrupted. The corruption can +manifest itself at any time after the actual damage occurs, even +hours or days in the future.

      +
      +

      Couldn't I just catch the ThreadDeath exception +and fix the damaged object?

      +

      In theory, perhaps, but it would vastly complicate the +task of writing correct multithreaded code. The task would be +nearly insurmountable for two reasons:

      +
        +
      1. A thread can throw a ThreadDeath exception +almost anywhere. All synchronized methods and blocks would +have to be studied in great detail, with this in mind.
      2. +
      3. A thread can throw a second ThreadDeath exception +while cleaning up from the first (in the catch or +finally clause). Cleanup would have to be repeated till +it succeeded. The code to ensure this would be quite complex.
      4. +
      +In sum, it just isn't practical. +
      +

      What about Thread.stop(Throwable)?

      +

      In addition to all of the problems noted above, this method may +be used to generate exceptions that its target thread is unprepared +to handle (including checked exceptions that the thread could not +possibly throw, were it not for this method). For example, the +following method is behaviorally identical to Java's +throw operation, but circumvents the compiler's +attempts to guarantee that the calling method has declared all of +the checked exceptions that it may throw:

      +
      +    static void sneakyThrow(Throwable t) {
      +        Thread.currentThread().stop(t);
      +    }
      +
      +
      +

      What should I use instead of Thread.stop?

      +

      Most uses of stop should be replaced by code that +simply modifies some variable to indicate that the target thread +should stop running. The target thread should check this variable +regularly, and return from its run method in an orderly fashion if +the variable indicates that it is to stop running. To ensure prompt +communication of the stop-request, the variable must be +volatile (or access to the variable must be +synchronized).

      +

      For example, suppose your applet contains the following +start, stop and run +methods:

      +
      +    private Thread blinker;
      +
      +    public void start() {
      +        blinker = new Thread(this);
      +        blinker.start();
      +    }
      +
      +    public void stop() {
      +        blinker.stop();  // UNSAFE!
      +    }
      +
      +    public void run() {
      +        while (true) {
      +            try {
      +                Thread.sleep(interval);
      +            } catch (InterruptedException e){
      +            }
      +            repaint();
      +        }
      +    }
      +
      +You can avoid the use of Thread.stop by replacing the +applet's stop and run methods with: +
      +    private volatile Thread blinker;
      +
      +    public void stop() {
      +        blinker = null;
      +    }
      +
      +    public void run() {
      +        Thread thisThread = Thread.currentThread();
      +        while (blinker == thisThread) {
      +            try {
      +                Thread.sleep(interval);
      +            } catch (InterruptedException e){
      +            }
      +            repaint();
      +        }
      +    }
      +
      +
      +

      How do I stop a thread that waits for long periods (e.g., for +input)?

      +

      That's what the Thread.interrupt method is for. The +same "state based" signaling mechanism shown above can be used, but +the state change (blinker = null, in the previous +example) can be followed by a call to +Thread.interrupt, to interrupt the wait:

      +
      +    public void stop() {
      +        Thread moribund = waiter;
      +        waiter = null;
      +        moribund.interrupt();
      +    }
      +
      +For this technique to work, it's critical that any method that +catches an interrupt exception and is not prepared to deal with it +immediately reasserts the exception. We say reasserts +rather than rethrows, because it is not always possible to +rethrow the exception. If the method that catches the +InterruptedException is not declared to throw this +(checked) exception, then it should "reinterrupt itself" with the +following incantation: +
      +    Thread.currentThread().interrupt();
      +
      +This ensures that the Thread will reraise the +InterruptedException as soon as it is able. +
      +

      What if a thread doesn't respond to +Thread.interrupt?

      +

      In some cases, you can use application specific tricks. For +example, if a thread is waiting on a known socket, you can close +the socket to cause the thread to return immediately. +Unfortunately, there really isn't any technique that works in +general. It should be noted that in all situations where a +waiting thread doesn't respond to Thread.interrupt, it +wouldn't respond to Thread.stop either. Such +cases include deliberate denial-of-service attacks, and I/O +operations for which thread.stop and thread.interrupt do not work +properly.

      +
      +

      Why are Thread.suspend and +Thread.resume deprecated?

      +

      Thread.suspend is inherently deadlock-prone. If the +target thread holds a lock on the monitor protecting a critical +system resource when it is suspended, no thread can access this +resource until the target thread is resumed. If the thread that +would resume the target thread attempts to lock this monitor prior +to calling resume, deadlock results. Such deadlocks +typically manifest themselves as "frozen" processes.

      +
      +

      What should I use instead of Thread.suspend and +Thread.resume?

      +

      As with Thread.stop, the prudent approach is to +have the "target thread" poll a variable indicating the desired +state of the thread (active or suspended). When the desired state +is suspended, the thread waits using Object.wait. When +the thread is resumed, the target thread is notified using +Object.notify.

      +

      For example, suppose your applet contains the following +mousePressed event handler, which toggles the state of a thread +called blinker:

      +
      +    private boolean threadSuspended;
      +
      +    Public void mousePressed(MouseEvent e) {
      +        e.consume();
      +
      +        if (threadSuspended)
      +            blinker.resume();
      +        else
      +            blinker.suspend();  // DEADLOCK-PRONE!
      +
      +        threadSuspended = !threadSuspended;
      +    }
      +
      +You can avoid the use of Thread.suspend and +Thread.resume by replacing the event handler above +with: +
      +    public synchronized void mousePressed(MouseEvent e) {
      +        e.consume();
      +
      +        threadSuspended = !threadSuspended;
      +
      +        if (!threadSuspended)
      +            notify();
      +    }
      +
      +and adding the following code to the "run loop": +
      +                synchronized(this) {
      +                    while (threadSuspended)
      +                        wait();
      +                }
      +
      +The wait method throws the +InterruptedException, so it must be inside a try +... catch clause. It's fine to put it in the same clause as +the sleep. The check should follow (rather than +precede) the sleep so the window is immediately +repainted when the thread is "resumed." The resulting +run method follows: +
      +    public void run() {
      +        while (true) {
      +            try {
      +                Thread.sleep(interval);
      +
      +                synchronized(this) {
      +                    while (threadSuspended)
      +                        wait();
      +                }
      +            } catch (InterruptedException e){
      +            }
      +            repaint();
      +        }
      +    }
      +
      +Note that the notify in the mousePressed +method and the wait in the run method are +inside synchronized blocks. This is required by the +language, and ensures that wait and +notify are properly serialized. In practical terms, +this eliminates race conditions that could cause the "suspended" +thread to miss a notify and remain suspended +indefinitely. +

      While the cost of synchronization in Java is decreasing as the +platform matures, it will never be free. A simple trick can be used +to remove the synchronization that we've added to each iteration of +the "run loop." The synchronized block that was added is replaced +by a slightly more complex piece of code that enters a synchronized +block only if the thread has actually been suspended:

      +
      +                if (threadSuspended) {
      +                    synchronized(this) {
      +                        while (threadSuspended)
      +                            wait();
      +                    }
      +                }
      +
      +

      In the absence of explicit synchronization, +threadSuspended must be made volatile to ensure +prompt communication of the suspend-request.

      +The resulting run method is: +
      +    private volatile boolean threadSuspended;
      +
      +    public void run() {
      +        while (true) {
      +            try {
      +                Thread.sleep(interval);
      +
      +                if (threadSuspended) {
      +                    synchronized(this) {
      +                        while (threadSuspended)
      +                            wait();
      +                    }
      +                }
      +            } catch (InterruptedException e){
      +            }
      +            repaint();
      +        }
      +    }
      +
      +
      +

      Can I combine the two techniques to produce a thread that may +be safely "stopped" or "suspended"?

      +Yes, it's reasonably straightforward. The one subtlety is that the +target thread may already be suspended at the time that another +thread tries to stop it. If the stop method merely sets +the state variable (blinker) to null, the target thread +will remain suspended (waiting on the monitor), rather than exiting +gracefully as it should. If the applet is restarted, multiple +threads could end up waiting on the monitor at the same time, +resulting in erratic behavior. +

      To rectify this situation, the stop method must ensure +that the target thread resumes immediately if it is suspended. Once +the target thread resumes, it must recognize immediately that it +has been stopped, and exit gracefully. Here's how the resulting +run and stop methods look:

      +
      +    public void run() {
      +        Thread thisThread = Thread.currentThread();
      +        while (blinker == thisThread) {
      +            try {
      +                Thread.sleep(interval);
      +
      +                synchronized(this) {
      +                    while (threadSuspended && blinker==thisThread)
      +                        wait();
      +                }
      +            } catch (InterruptedException e){
      +            }
      +            repaint();
      +        }
      +    }
      +
      +    public synchronized void stop() {
      +        blinker = null;
      +        notify();
      +    }
      +
      +If the stop method calls Thread.interrupt, as +described above, it needn't call notify as well, but it +still must be synchronized. This ensures that the target thread +won't miss an interrupt due to a race condition. +
      +

      What about Thread.destroy?

      +Thread.destroy was never implemented and has been +deprecated. If it were implemented, it would be deadlock-prone in +the manner of Thread.suspend. (In fact, it is roughly +equivalent to Thread.suspend without the possibility +of a subsequent Thread.resume.) +
      +

      Why is Runtime.runFinalizersOnExit +deprecated?

      +Because it is inherently unsafe. It may result in finalizers being +called on live objects while other threads are concurrently +manipulating those objects, resulting in erratic behavior or +deadlock. While this problem could be prevented if the class whose +objects are being finalized were coded to "defend against" this +call, most programmers do not defend against it. They assume +that an object is dead at the time that its finalizer is called. +

      Further, the call is not "thread-safe" in the sense that it sets +a VM-global flag. This forces every class with a finalizer +to defend against the finalization of live objects!

      +

      + + diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java index 3f91060ccc8..a7172138ae8 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java @@ -26,6 +26,7 @@ package java.lang.invoke; import sun.invoke.util.Wrapper; +import static java.lang.invoke.MethodHandleInfo.*; import static sun.invoke.util.Wrapper.forPrimitiveType; import static sun.invoke.util.Wrapper.forWrapperType; import static sun.invoke.util.Wrapper.isWrapperType; @@ -56,11 +57,11 @@ import static sun.invoke.util.Wrapper.isWrapperType; final String samMethodName; // Name of the SAM method "foo" final MethodType samMethodType; // Type of the SAM method "(Object)Object" final MethodHandle implMethod; // Raw method handle for the implementation method + final MethodType implMethodType; // Type of the implMethod MethodHandle "(CC,int)String" final MethodHandleInfo implInfo; // Info about the implementation method handle "MethodHandleInfo[5 CC.impl(int)String]" final int implKind; // Invocation kind for implementation "5"=invokevirtual final boolean implIsInstanceMethod; // Is the implementation an instance method "true" - final Class implDefiningClass; // Type defining the implementation "class CC" - final MethodType implMethodType; // Type of the implementation method "(int)String" + final Class implClass; // Class for referencing the implementation method "class CC" final MethodType instantiatedMethodType; // Instantiated erased functional interface method type "(Integer)Object" final boolean isSerializable; // Should the returned instance be serializable final Class[] markerInterfaces; // Additional marker interfaces to be implemented @@ -128,19 +129,51 @@ import static sun.invoke.util.Wrapper.isWrapperType; this.samMethodType = samMethodType; this.implMethod = implMethod; + this.implMethodType = implMethod.type(); this.implInfo = caller.revealDirect(implMethod); - this.implKind = implInfo.getReferenceKind(); - this.implIsInstanceMethod = - implKind == MethodHandleInfo.REF_invokeVirtual || - implKind == MethodHandleInfo.REF_invokeSpecial || - implKind == MethodHandleInfo.REF_invokeInterface; - this.implDefiningClass = implInfo.getDeclaringClass(); - this.implMethodType = implInfo.getMethodType(); + switch (implInfo.getReferenceKind()) { + case REF_invokeVirtual: + case REF_invokeInterface: + this.implClass = implMethodType.parameterType(0); + // reference kind reported by implInfo may not match implMethodType's first param + // Example: implMethodType is (Cloneable)String, implInfo is for Object.toString + this.implKind = implClass.isInterface() ? REF_invokeInterface : REF_invokeVirtual; + this.implIsInstanceMethod = true; + break; + case REF_invokeSpecial: + // JDK-8172817: should use referenced class here, but we don't know what it was + this.implClass = implInfo.getDeclaringClass(); + this.implKind = REF_invokeSpecial; + this.implIsInstanceMethod = true; + break; + case REF_invokeStatic: + case REF_newInvokeSpecial: + // JDK-8172817: should use referenced class here for invokestatic, but we don't know what it was + this.implClass = implInfo.getDeclaringClass(); + this.implKind = implInfo.getReferenceKind(); + this.implIsInstanceMethod = false; + break; + default: + throw new LambdaConversionException(String.format("Unsupported MethodHandle kind: %s", implInfo)); + } + this.instantiatedMethodType = instantiatedMethodType; this.isSerializable = isSerializable; this.markerInterfaces = markerInterfaces; this.additionalBridges = additionalBridges; + if (samMethodName.isEmpty() || + samMethodName.indexOf('.') >= 0 || + samMethodName.indexOf(';') >= 0 || + samMethodName.indexOf('[') >= 0 || + samMethodName.indexOf('/') >= 0 || + samMethodName.indexOf('<') >= 0 || + samMethodName.indexOf('>') >= 0) { + throw new LambdaConversionException(String.format( + "Method name '%s' is not legal", + samMethodName)); + } + if (!samBase.isInterface()) { throw new LambdaConversionException(String.format( "Functional interface %s is not an interface", @@ -171,24 +204,12 @@ import static sun.invoke.util.Wrapper.isWrapperType; * @throws LambdaConversionException if there are improper conversions */ void validateMetafactoryArgs() throws LambdaConversionException { - switch (implKind) { - case MethodHandleInfo.REF_invokeInterface: - case MethodHandleInfo.REF_invokeVirtual: - case MethodHandleInfo.REF_invokeStatic: - case MethodHandleInfo.REF_newInvokeSpecial: - case MethodHandleInfo.REF_invokeSpecial: - break; - default: - throw new LambdaConversionException(String.format("Unsupported MethodHandle kind: %s", implInfo)); - } - - // Check arity: optional-receiver + captured + SAM == impl + // Check arity: captured + SAM == impl final int implArity = implMethodType.parameterCount(); - final int receiverArity = implIsInstanceMethod ? 1 : 0; final int capturedArity = invokedType.parameterCount(); final int samArity = samMethodType.parameterCount(); final int instantiatedArity = instantiatedMethodType.parameterCount(); - if (implArity + receiverArity != capturedArity + samArity) { + if (implArity != capturedArity + samArity) { throw new LambdaConversionException( String.format("Incorrect number of parameters for %s method %s; %d captured parameters, %d functional interface method parameters, %d implementation parameters", implIsInstanceMethod ? "instance" : "static", implInfo, @@ -209,8 +230,8 @@ import static sun.invoke.util.Wrapper.isWrapperType; } // If instance: first captured arg (receiver) must be subtype of class where impl method is defined - final int capturedStart; - final int samStart; + final int capturedStart; // index of first non-receiver capture parameter in implMethodType + final int samStart; // index of first non-receiver sam parameter in implMethodType if (implIsInstanceMethod) { final Class receiverClass; @@ -223,45 +244,36 @@ import static sun.invoke.util.Wrapper.isWrapperType; } else { // receiver is a captured variable capturedStart = 1; - samStart = 0; + samStart = capturedArity; receiverClass = invokedType.parameterType(0); } // check receiver type - if (!implDefiningClass.isAssignableFrom(receiverClass)) { + if (!implClass.isAssignableFrom(receiverClass)) { throw new LambdaConversionException( String.format("Invalid receiver type %s; not a subtype of implementation type %s", - receiverClass, implDefiningClass)); - } - - Class implReceiverClass = implMethod.type().parameterType(0); - if (implReceiverClass != implDefiningClass && !implReceiverClass.isAssignableFrom(receiverClass)) { - throw new LambdaConversionException( - String.format("Invalid receiver type %s; not a subtype of implementation receiver type %s", - receiverClass, implReceiverClass)); + receiverClass, implClass)); } } else { // no receiver capturedStart = 0; - samStart = 0; + samStart = capturedArity; } // Check for exact match on non-receiver captured arguments - final int implFromCaptured = capturedArity - capturedStart; - for (int i=0; i implParamType = implMethodType.parameterType(i); - Class capturedParamType = invokedType.parameterType(i + capturedStart); + Class capturedParamType = invokedType.parameterType(i); if (!capturedParamType.equals(implParamType)) { throw new LambdaConversionException( String.format("Type mismatch in captured lambda parameter %d: expecting %s, found %s", i, capturedParamType, implParamType)); } } - // Check for adaptation match on SAM arguments - final int samOffset = samStart - implFromCaptured; - for (int i=implFromCaptured; i implParamType = implMethodType.parameterType(i); - Class instantiatedParamType = instantiatedMethodType.parameterType(i + samOffset); + Class instantiatedParamType = instantiatedMethodType.parameterType(i - capturedArity); if (!isAdaptableTo(instantiatedParamType, implParamType, true)) { throw new LambdaConversionException( String.format("Type mismatch for lambda argument %d: %s is not convertible to %s", @@ -271,29 +283,40 @@ import static sun.invoke.util.Wrapper.isWrapperType; // Adaptation match: return type Class expectedType = instantiatedMethodType.returnType(); - Class actualReturnType = - (implKind == MethodHandleInfo.REF_newInvokeSpecial) - ? implDefiningClass - : implMethodType.returnType(); - Class samReturnType = samMethodType.returnType(); + Class actualReturnType = implMethodType.returnType(); if (!isAdaptableToAsReturn(actualReturnType, expectedType)) { throw new LambdaConversionException( String.format("Type mismatch for lambda return: %s is not convertible to %s", actualReturnType, expectedType)); } - if (!isAdaptableToAsReturnStrict(expectedType, samReturnType)) { - throw new LambdaConversionException( - String.format("Type mismatch for lambda expected return: %s is not convertible to %s", - expectedType, samReturnType)); - } + + // Check descriptors of generated methods + checkDescriptor(samMethodType); for (MethodType bridgeMT : additionalBridges) { - if (!isAdaptableToAsReturnStrict(expectedType, bridgeMT.returnType())) { - throw new LambdaConversionException( - String.format("Type mismatch for lambda expected return: %s is not convertible to %s", - expectedType, bridgeMT.returnType())); + checkDescriptor(bridgeMT); + } + } + + /** Validate that the given descriptor's types are compatible with {@code instantiatedMethodType} **/ + private void checkDescriptor(MethodType descriptor) throws LambdaConversionException { + for (int i = 0; i < instantiatedMethodType.parameterCount(); i++) { + Class instantiatedParamType = instantiatedMethodType.parameterType(i); + Class descriptorParamType = descriptor.parameterType(i); + if (!descriptorParamType.isAssignableFrom(instantiatedParamType)) { + String msg = String.format("Type mismatch for instantiated parameter %d: %s is not a subtype of %s", + i, instantiatedParamType, descriptorParamType); + throw new LambdaConversionException(msg); } } - } + + Class instantiatedReturnType = instantiatedMethodType.returnType(); + Class descriptorReturnType = descriptor.returnType(); + if (!isAdaptableToAsReturnStrict(instantiatedReturnType, descriptorReturnType)) { + String msg = String.format("Type mismatch for lambda expected return: %s is not convertible to %s", + instantiatedReturnType, descriptorReturnType); + throw new LambdaConversionException(msg); + } + } /** * Check type adaptability for parameter types. @@ -345,8 +368,8 @@ import static sun.invoke.util.Wrapper.isWrapperType; || !fromType.equals(void.class) && isAdaptableTo(fromType, toType, false); } private boolean isAdaptableToAsReturnStrict(Class fromType, Class toType) { - if (fromType.equals(void.class)) return toType.equals(void.class); - return isAdaptableTo(fromType, toType, true); + if (fromType.equals(void.class) || toType.equals(void.class)) return fromType.equals(toType); + else return isAdaptableTo(fromType, toType, true); } 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 53899611f59..031e18a759a 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 @@ -82,6 +82,7 @@ private static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String nam } } * @author John Rose, JSR 292 EG + * @since 1.7 */ abstract public class CallSite { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java b/jdk/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java index f27d0e7bbd2..f7d87ba45ac 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/ConstantCallSite.java @@ -30,6 +30,7 @@ package java.lang.invoke; * An {@code invokedynamic} instruction linked to a {@code ConstantCallSite} is permanently * bound to the call site's target. * @author John Rose, JSR 292 EG + * @since 1.7 */ public class ConstantCallSite extends CallSite { private final boolean isFrozen; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index 0c814bdd470..35f91cc243b 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -96,7 +96,6 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; private final String implMethodClassName; // Name of type containing implementation "CC" private final String implMethodName; // Name of implementation method "impl" private final String implMethodDesc; // Type descriptor for implementation methods "(I)Ljava/lang/String;" - private final Class implMethodReturnClass; // class for implementation method return type "Ljava/lang/String;" private final MethodType constructorType; // Generated class constructor type "(CC)void" private final ClassWriter cw; // ASM class writer private final String[] argNames; // Generated names for the constructor arguments @@ -153,12 +152,9 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; super(caller, invokedType, samMethodName, samMethodType, implMethod, instantiatedMethodType, isSerializable, markerInterfaces, additionalBridges); - implMethodClassName = implDefiningClass.getName().replace('.', '/'); + implMethodClassName = implClass.getName().replace('.', '/'); implMethodName = implInfo.getName(); - implMethodDesc = implMethodType.toMethodDescriptorString(); - implMethodReturnClass = (implKind == MethodHandleInfo.REF_newInvokeSpecial) - ? implDefiningClass - : implMethodType.returnType(); + implMethodDesc = implInfo.getMethodType().toMethodDescriptorString(); constructorType = invokedType.changeReturnType(Void.TYPE); lambdaClassName = targetClass.getName().replace('.', '/') + "$$Lambda$" + counter.incrementAndGet(); cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); @@ -467,13 +463,14 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; // Invoke the method we want to forward to visitMethodInsn(invocationOpcode(), implMethodClassName, implMethodName, implMethodDesc, - implDefiningClass.isInterface()); + implClass.isInterface()); // Convert the return value (if any) and return it // Note: if adapting from non-void to void, the 'return' // instruction will pop the unneeded result + Class implReturnClass = implMethodType.returnType(); Class samReturnClass = methodType.returnType(); - convertType(implMethodReturnClass, samReturnClass, samReturnClass); + convertType(implReturnClass, samReturnClass, samReturnClass); visitInsn(getReturnOpcode(samReturnClass)); // Maxs computed by ClassWriter.COMPUTE_MAXS,these arguments ignored visitMaxs(-1, -1); @@ -482,23 +479,13 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; private void convertArgumentTypes(MethodType samType) { int lvIndex = 0; - boolean samIncludesReceiver = implIsInstanceMethod && - invokedType.parameterCount() == 0; - int samReceiverLength = samIncludesReceiver ? 1 : 0; - if (samIncludesReceiver) { - // push receiver - Class rcvrType = samType.parameterType(0); - visitVarInsn(getLoadOpcode(rcvrType), lvIndex + 1); - lvIndex += getParameterSize(rcvrType); - convertType(rcvrType, implDefiningClass, instantiatedMethodType.parameterType(0)); - } int samParametersLength = samType.parameterCount(); - int argOffset = implMethodType.parameterCount() - samParametersLength; - for (int i = samReceiverLength; i < samParametersLength; i++) { + int captureArity = invokedType.parameterCount(); + for (int i = 0; i < samParametersLength; i++) { Class argType = samType.parameterType(i); visitVarInsn(getLoadOpcode(argType), lvIndex + 1); lvIndex += getParameterSize(argType); - convertType(argType, implMethodType.parameterType(argOffset + i), instantiatedMethodType.parameterType(i)); + convertType(argType, implMethodType.parameterType(captureArity + i), instantiatedMethodType.parameterType(i)); } } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaConversionException.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaConversionException.java index e1123da59d8..2dc8f22c01d 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaConversionException.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaConversionException.java @@ -27,6 +27,8 @@ package java.lang.invoke; /** * LambdaConversionException + * + * @since 1.8 */ public class LambdaConversionException extends Exception { private static final long serialVersionUID = 292L + 8L; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java index b6ef976c515..95719763b0f 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -149,8 +149,12 @@ import java.util.Arrays; * capture argument (corresponding to the receiver) must be non-null. * *

      A type Q is considered adaptable to S as follows: - * + *
      + * + * * + * + * * * * @@ -176,6 +180,7 @@ import java.util.Arrays; *
      for return types: none * * + * *
      adaptable types
      QSLink-time checksInvocation-time checks
      PrimitivePrimitiveQ can be converted to S via a primitive widening conversionCast from Q to S
      * * @apiNote These linkage methods are designed to support the evaluation @@ -211,8 +216,11 @@ import java.util.Arrays; * theory, any method handle could be used. Currently supported are direct method * handles representing invocation of virtual, interface, constructor and static * methods. + * @since 1.8 */ -public class LambdaMetafactory { +public final class LambdaMetafactory { + + private LambdaMetafactory() {} /** Flag for alternate metafactories indicating the lambda object * must be serializable */ diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java index 97efa4f1066..92ab77cedf4 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -33,7 +33,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.Module; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java index 6265b874175..6e913a84fd9 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java @@ -310,7 +310,7 @@ mh.invokeExact(System.out, "Hello, world."); * throwables locally, rethrowing only those which are legal in the context, * and wrapping ones which are illegal. * - *

      Signature polymorphism

      + *

      Signature polymorphism

      * The unusual compilation and linkage behavior of * {@code invokeExact} and plain {@code invoke} * is referenced by the term signature polymorphism. @@ -404,7 +404,7 @@ mh.invokeExact(System.out, "Hello, world."); * genericity with a Java type parameter.
    • *
    * - *

    Arity limits

    + *

    Arity limits

    * The JVM imposes on all methods and constructors of any kind an absolute * limit of 255 stacked arguments. This limit can appear more restrictive * in certain cases: @@ -423,6 +423,7 @@ mh.invokeExact(System.out, "Hello, world."); * @see MethodType * @see MethodHandles * @author John Rose, JSR 292 EG + * @since 1.7 */ public abstract class MethodHandle { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleInfo.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleInfo.java index ad6799acfc9..909f271c672 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleInfo.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -35,7 +35,7 @@ import static java.lang.invoke.MethodHandleStatics.*; * A symbolic reference obtained by cracking a direct method handle * into its consitutent symbolic parts. * To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}. - *

    Direct Method Handles

    + *

    Direct Method Handles

    * A direct method handle represents a method, constructor, or field without * any intervening argument bindings or other transformations. * The method, constructor, or field referred to by a direct method handle is called @@ -77,12 +77,16 @@ import static java.lang.invoke.MethodHandleStatics.*; * handle with symbolic information (or caller binding) from an unexpected scope. * Use {@link java.lang.invoke.MethodHandles#reflectAs} to override this limitation. * - *

    Reference kinds

    + *

    Reference kinds

    * The Lookup Factory Methods * correspond to all major use cases for methods, constructors, and fields. * These use cases may be distinguished using small integers as follows: - * + *
    + * + * * + * + * * * * @@ -119,6 +123,7 @@ import static java.lang.invoke.MethodHandleStatics.*; * * * + * *
    reference kinds
    reference kinddescriptive namescopememberbehavior
    {@code 1}{@code REF_getField}{@code class}{@code FT f;}{@code (T) this.f;}{@code 9}{@code REF_invokeInterface}{@code interface}{@code T m(A*);}{@code (T) this.m(arg*);}
    * @since 1.8 */ diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java index 09db4f93512..fce6e0fef01 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java @@ -38,6 +38,8 @@ import static java.lang.invoke.MethodHandleStatics.*; /** * This class consists exclusively of static methods that help adapt * method handles to other JVM types, such as interfaces. + * + * @since 1.7 */ public class MethodHandleProxies { 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 16a9e8a941d..d53d9d4ecca 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 @@ -25,8 +25,9 @@ package java.lang.invoke; -import jdk.internal.org.objectweb.asm.ClassWriter; -import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.misc.SharedSecrets; +import jdk.internal.module.IllegalAccessLogger; +import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; import jdk.internal.vm.annotation.ForceInline; @@ -42,9 +43,11 @@ import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.Module; import java.lang.reflect.ReflectPermission; import java.nio.ByteOrder; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; @@ -109,15 +112,32 @@ public class MethodHandles { return new Lookup(Reflection.getCallerClass()); } + /** + * This reflected$lookup method is the alternate implementation of + * the lookup method when being invoked by reflection. + */ + @CallerSensitive + private static Lookup reflected$lookup() { + Class caller = Reflection.getCallerClass(); + if (caller.getClassLoader() == null) { + throw newIllegalArgumentException("illegal lookupClass: "+caller); + } + return new Lookup(caller); + } + /** * Returns a {@link Lookup lookup object} which is trusted minimally. - * It can only be used to create method handles to public members in + * The lookup has the {@code PUBLIC} and {@code UNCONDITIONAL} modes. + * It can only be used to create method handles to public members of * public classes in packages that are exported unconditionally. *

    - * For now, the {@linkplain Lookup#lookupClass lookup class} of this lookup - * object is in an unnamed module. - * Consequently, the lookup context of this lookup object will be the bootstrap - * class loader, which means it cannot find user classes. + * As a matter of pure convention, the {@linkplain Lookup#lookupClass lookup class} + * of this lookup object will be {@link java.lang.Object}. + * + * @apiNote The use of Object is conventional, and because the lookup modes are + * limited, there is no special access provided to the internals of Object, its package + * or its module. Consequently, the lookup context of this lookup object will be the + * bootstrap class loader, which means it cannot find user classes. * *

    * Discussion: @@ -129,17 +149,12 @@ public class MethodHandles { * Also, it cannot access * caller sensitive methods. * @return a lookup object which is trusted minimally + * + * @revised 9 + * @spec JPMS */ public static Lookup publicLookup() { - // During VM startup then only classes in the java.base module can be - // loaded and linked. This is because java.base exports aren't setup until - // the module system is initialized, hence types in the unnamed module - // (or any named module) can't link to java/lang/Object. - if (!jdk.internal.misc.VM.isModuleSystemInited()) { - return new Lookup(Object.class, Lookup.PUBLIC); - } else { - return LookupHelper.PUBLIC_LOOKUP; - } + return Lookup.PUBLIC_LOOKUP; } /** @@ -172,6 +187,7 @@ public class MethodHandles { * @throws IllegalAccessException if the access check specified above fails * @throws SecurityException if denied by the security manager * @since 9 + * @spec JPMS * @see Lookup#dropLookupMode */ public static Lookup privateLookupIn(Class targetClass, Lookup lookup) throws IllegalAccessException { @@ -183,16 +199,22 @@ public class MethodHandles { throw new IllegalArgumentException(targetClass + " is an array class"); Module targetModule = targetClass.getModule(); Module callerModule = lookup.lookupClass().getModule(); - if (callerModule != targetModule && targetModule.isNamed()) { - if (!callerModule.canRead(targetModule)) - throw new IllegalAccessException(callerModule + " does not read " + targetModule); + if (!callerModule.canRead(targetModule)) + throw new IllegalAccessException(callerModule + " does not read " + targetModule); + if (targetModule.isNamed()) { String pn = targetClass.getPackageName(); - assert pn != null && pn.length() > 0 : "unnamed package cannot be in named module"; + assert pn.length() > 0 : "unnamed package cannot be in named module"; if (!targetModule.isOpen(pn, callerModule)) throw new IllegalAccessException(targetModule + " does not open " + pn + " to " + callerModule); } if ((lookup.lookupModes() & Lookup.MODULE) == 0) throw new IllegalAccessException("lookup does not have MODULE lookup mode"); + if (!callerModule.isNamed() && targetModule.isNamed()) { + IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger(); + if (logger != null) { + logger.logIfOpenedByBackdoor(lookup, targetClass); + } + } return new Lookup(targetClass); } @@ -248,7 +270,7 @@ public class MethodHandles { * This includes all methods, constructors, and fields which are allowed to the lookup class, * even private ones. * - *

    Lookup Factory Methods

    + *

    Lookup Factory Methods

    * The factory methods on a {@code Lookup} object correspond to all major * use cases for methods, constructors, and fields. * Each method handle created by a factory method is the functional @@ -256,12 +278,16 @@ public class MethodHandles { * (Bytecode behaviors are described in section 5.4.3.5 of the Java Virtual Machine Specification.) * Here is a summary of the correspondence between these factory methods and * the behavior of the resulting method handles: - * + *
    + * + * * - * + * * * * + * + * * * * @@ -318,6 +344,7 @@ public class MethodHandles { * * * + * *
    lookup method behaviors
    lookup expressionlookup expressionmemberbytecode behavior
    {@link java.lang.invoke.MethodHandles.Lookup#findGetter lookup.findGetter(C.class,"f",FT.class)}{@code FT f;}{@code (T) this.f;}{@link java.lang.invoke.MethodHandles.Lookup#findClass lookup.findClass("C")}{@code class C { ... }}{@code C.class;}
    * * Here, the type {@code C} is the class or interface being searched for a member, @@ -369,7 +396,7 @@ public class MethodHandles { * type having too many parameters. * * - *

    Access checking

    + *

    Access checking

    * Access checks are applied in the factory methods of {@code Lookup}, * when a method handle is created. * This is a key difference from the Core Reflection API, since @@ -474,7 +501,7 @@ public class MethodHandles { * with fewer access modes than the original lookup object. * *

    - * + * * Discussion of private access: * We say that a lookup has private access * if its {@linkplain #lookupModes lookup modes} @@ -497,7 +524,7 @@ public class MethodHandles { * whose bytecode behaviors and Java language access permissions * can be reliably determined and emulated by method handles. * - *

    Security manager interactions

    + *

    Security manager interactions

    * Although bytecode instructions can only refer to classes in * a related class loader, this API can search for methods in any * class, as long as a reference to its {@code Class} object is @@ -556,7 +583,7 @@ public class MethodHandles { * or else that is being accessed from a lookup class that has * rights to access the member or class. * - *

    Caller sensitive methods

    + *

    Caller sensitive methods

    * A small number of Java methods have a special property called caller sensitivity. * A caller-sensitive method can behave differently depending on the * identity of its immediate caller. @@ -601,6 +628,8 @@ public class MethodHandles { * so that there can be a secure foundation for lookups. * Nearly all other methods in the JSR 292 API rely on lookup * objects to check access requests. + * + * @revised 9 */ public static final class Lookup { @@ -647,15 +676,33 @@ public class MethodHandles { * lookup class and public types in packages exported by other modules * to the module of the lookup class. * @since 9 + * @spec JPMS */ public static final int MODULE = PACKAGE << 1; - private static final int ALL_MODES = (PUBLIC | PRIVATE | PROTECTED | PACKAGE | MODULE); + /** A single-bit mask representing {@code unconditional} access + * which may contribute to the result of {@link #lookupModes lookupModes}. + * The value is {@code 0x20}, which does not correspond meaningfully to + * any particular {@linkplain java.lang.reflect.Modifier modifier bit}. + * A {@code Lookup} with this lookup mode assumes {@linkplain + * java.lang.Module#canRead(java.lang.Module) readability}. + * In conjunction with the {@code PUBLIC} modifier bit, a {@code Lookup} + * with this lookup mode can access all public members of public types + * of all modules where the type is in a package that is {@link + * java.lang.Module#isExported(String) exported unconditionally}. + * @since 9 + * @spec JPMS + * @see #publicLookup() + */ + public static final int UNCONDITIONAL = PACKAGE << 2; + + private static final int ALL_MODES = (PUBLIC | PRIVATE | PROTECTED | PACKAGE | MODULE | UNCONDITIONAL); + private static final int FULL_POWER_MODES = (ALL_MODES & ~UNCONDITIONAL); private static final int TRUSTED = -1; private static int fixmods(int mods) { - mods &= (ALL_MODES - PACKAGE - MODULE); - return (mods != 0) ? mods : (PACKAGE | MODULE); + mods &= (ALL_MODES - PACKAGE - MODULE - UNCONDITIONAL); + return (mods != 0) ? mods : (PACKAGE | MODULE | UNCONDITIONAL); } /** Tells which class is performing the lookup. It is this class against @@ -682,13 +729,14 @@ public class MethodHandles { * {@linkplain #PRIVATE PRIVATE (0x02)}, * {@linkplain #PROTECTED PROTECTED (0x04)}, * {@linkplain #PACKAGE PACKAGE (0x08)}, - * and {@linkplain #MODULE MODULE (0x10)}. + * {@linkplain #MODULE MODULE (0x10)}, + * and {@linkplain #UNCONDITIONAL UNCONDITIONAL (0x20)}. *

    * A freshly-created lookup object - * on the {@linkplain java.lang.invoke.MethodHandles#lookup() caller's class} - * has all possible bits set, since the caller class can access all its own members, - * all public types in the caller's module, and all public types in packages exported - * by other modules to the caller's module. + * on the {@linkplain java.lang.invoke.MethodHandles#lookup() caller's class} has + * all possible bits set, except {@code UNCONDITIONAL}. The lookup can be used to + * access all members of the caller's class, all public types in the caller's module, + * and all public types in packages exported by other modules to the caller's module. * A lookup object on a new lookup class * {@linkplain java.lang.invoke.MethodHandles.Lookup#in created from a previous lookup object} * may have some mode bits set to zero. @@ -701,6 +749,9 @@ public class MethodHandles { * @return the lookup modes, which limit the kinds of access performed by this lookup object * @see #in * @see #dropLookupMode + * + * @revised 9 + * @spec JPMS */ public int lookupModes() { return allowedModes & ALL_MODES; @@ -712,9 +763,9 @@ public class MethodHandles { * which in turn is called by a method not in this package. */ Lookup(Class lookupClass) { - this(lookupClass, ALL_MODES); + this(lookupClass, FULL_POWER_MODES); // make sure we haven't accidentally picked up a privileged class: - checkUnprivilegedlookupClass(lookupClass, ALL_MODES); + checkUnprivilegedlookupClass(lookupClass); } private Lookup(Class lookupClass, int allowedModes) { @@ -730,19 +781,20 @@ public class MethodHandles { * However, the resulting {@code Lookup} object is guaranteed * to have no more access capabilities than the original. * In particular, access capabilities can be lost as follows:

      - *
    • If the lookup class for this {@code Lookup} is not in a named module, - * and the new lookup class is in a named module {@code M}, then no members in - * {@code M}'s non-exported packages will be accessible. - *
    • If the lookup for this {@code Lookup} is in a named module, and the - * new lookup class is in a different module {@code M}, then no members, not even - * public members in {@code M}'s exported packages, will be accessible. - *
    • If the new lookup class differs from the old one, - * protected members will not be accessible by virtue of inheritance. - * (Protected members may continue to be accessible because of package sharing.) + *
    • If the old lookup class is in a {@link Module#isNamed() named} module, and + * the new lookup class is in a different module {@code M}, then no members, not + * even public members in {@code M}'s exported packages, will be accessible. + * The exception to this is when this lookup is {@link #publicLookup() + * publicLookup}, in which case {@code PUBLIC} access is not lost. + *
    • If the old lookup class is in an unnamed module, and the new lookup class + * is a different module then {@link #MODULE MODULE} access is lost. + *
    • If the new lookup class differs from the old one then {@code UNCONDITIONAL} is lost. *
    • If the new lookup class is in a different package * than the old one, protected and default (package) members will not be accessible. *
    • If the new lookup class is not within the same package member - * as the old one, private members will not be accessible. + * as the old one, private members will not be accessible, and protected members + * will not be accessible by virtue of inheritance. + * (Protected members may continue to be accessible because of package sharing.) *
    • If the new lookup class is not accessible to the old lookup class, * then no members, not even public members, will be accessible. * (In all other cases, public members will continue to be accessible.) @@ -757,32 +809,34 @@ public class MethodHandles { * @return a lookup object which reports the desired lookup class, or the same object * if there is no change * @throws NullPointerException if the argument is null + * + * @revised 9 + * @spec JPMS */ public Lookup in(Class requestedLookupClass) { Objects.requireNonNull(requestedLookupClass); if (allowedModes == TRUSTED) // IMPL_LOOKUP can make any lookup at all - return new Lookup(requestedLookupClass, ALL_MODES); + return new Lookup(requestedLookupClass, FULL_POWER_MODES); if (requestedLookupClass == this.lookupClass) return this; // keep same capabilities - - int newModes = (allowedModes & (ALL_MODES & ~PROTECTED)); + int newModes = (allowedModes & FULL_POWER_MODES); if (!VerifyAccess.isSameModule(this.lookupClass, requestedLookupClass)) { - // Allowed to teleport from an unnamed to a named module but resulting - // Lookup has no access to module private members - if (this.lookupClass.getModule().isNamed()) { + // Need to drop all access when teleporting from a named module to another + // module. The exception is publicLookup where PUBLIC is not lost. + if (this.lookupClass.getModule().isNamed() + && (this.allowedModes & UNCONDITIONAL) == 0) newModes = 0; - } else { - newModes &= ~MODULE; - } + else + newModes &= ~(MODULE|PACKAGE|PRIVATE|PROTECTED); } if ((newModes & PACKAGE) != 0 && !VerifyAccess.isSamePackage(this.lookupClass, requestedLookupClass)) { - newModes &= ~(PACKAGE|PRIVATE); + newModes &= ~(PACKAGE|PRIVATE|PROTECTED); } // Allow nestmate lookups to be created without special privilege: if ((newModes & PRIVATE) != 0 && !VerifyAccess.isSamePackageMember(this.lookupClass, requestedLookupClass)) { - newModes &= ~PRIVATE; + newModes &= ~(PRIVATE|PROTECTED); } if ((newModes & PUBLIC) != 0 && !VerifyAccess.isClassAccessible(requestedLookupClass, this.lookupClass, allowedModes)) { @@ -791,7 +845,7 @@ public class MethodHandles { newModes = 0; } - checkUnprivilegedlookupClass(requestedLookupClass, newModes); + checkUnprivilegedlookupClass(requestedLookupClass); return new Lookup(requestedLookupClass, newModes); } @@ -801,59 +855,152 @@ public class MethodHandles { * finds members, but with a lookup mode that has lost the given lookup mode. * The lookup mode to drop is one of {@link #PUBLIC PUBLIC}, {@link #MODULE * MODULE}, {@link #PACKAGE PACKAGE}, {@link #PROTECTED PROTECTED} or {@link #PRIVATE PRIVATE}. - * {@link #PROTECTED PROTECTED} is always dropped and so the resulting lookup - * mode will never have this access capability. When dropping {@code PACKAGE} - * then the resulting lookup will not have {@code PACKAGE} or {@code PRIVATE} - * access. When dropping {@code MODULE} then the resulting lookup will not - * have {@code MODULE}, {@code PACKAGE}, or {@code PRIVATE} access. If {@code - * PUBLIC} is dropped then the resulting lookup has no access. + * {@link #PROTECTED PROTECTED} and {@link #UNCONDITIONAL UNCONDITIONAL} are always + * dropped and so the resulting lookup mode will never have these access capabilities. + * When dropping {@code PACKAGE} then the resulting lookup will not have {@code PACKAGE} + * or {@code PRIVATE} access. When dropping {@code MODULE} then the resulting lookup will + * not have {@code MODULE}, {@code PACKAGE}, or {@code PRIVATE} access. If {@code PUBLIC} + * is dropped then the resulting lookup has no access. * @param modeToDrop the lookup mode to drop * @return a lookup object which lacks the indicated mode, or the same object if there is no change * @throws IllegalArgumentException if {@code modeToDrop} is not one of {@code PUBLIC}, - * {@code MODULE}, {@code PACKAGE}, {@code PROTECTED} or {@code PRIVATE} - * @since 9 + * {@code MODULE}, {@code PACKAGE}, {@code PROTECTED}, {@code PRIVATE} or {@code UNCONDITIONAL} * @see MethodHandles#privateLookupIn + * @since 9 */ public Lookup dropLookupMode(int modeToDrop) { int oldModes = lookupModes(); - int newModes = oldModes & ~(modeToDrop | PROTECTED); + int newModes = oldModes & ~(modeToDrop | PROTECTED | UNCONDITIONAL); switch (modeToDrop) { case PUBLIC: newModes &= ~(ALL_MODES); break; case MODULE: newModes &= ~(PACKAGE | PRIVATE); break; case PACKAGE: newModes &= ~(PRIVATE); break; case PROTECTED: - case PRIVATE: break; + case PRIVATE: + case UNCONDITIONAL: break; default: throw new IllegalArgumentException(modeToDrop + " is not a valid mode to drop"); } if (newModes == oldModes) return this; // return self if no change return new Lookup(lookupClass(), newModes); } + /** + * Defines a class to the same class loader and in the same runtime package and + * {@linkplain java.security.ProtectionDomain protection domain} as this lookup's + * {@linkplain #lookupClass() lookup class}. + * + *

      The {@linkplain #lookupModes() lookup modes} for this lookup must include + * {@link #PACKAGE PACKAGE} access as default (package) members will be + * accessible to the class. The {@code PACKAGE} lookup mode serves to authenticate + * that the lookup object was created by a caller in the runtime package (or derived + * from a lookup originally created by suitably privileged code to a target class in + * the runtime package).

      + * + *

      The {@code bytes} parameter is the class bytes of a valid class file (as defined + * by the The Java Virtual Machine Specification) with a class name in the + * same package as the lookup class.

      + * + *

      This method does not run the class initializer. The class initializer may + * run at a later time, as detailed in section 12.4 of the The Java Language + * Specification.

      + * + *

      If there is a security manager, its {@code checkPermission} method is first called + * to check {@code RuntimePermission("defineClass")}.

      + * + * @param bytes the class bytes + * @return the {@code Class} object for the class + * @throws IllegalArgumentException the bytes are for a class in a different package + * to the lookup class + * @throws IllegalAccessException if this lookup does not have {@code PACKAGE} access + * @throws LinkageError if the class is malformed ({@code ClassFormatError}), cannot be + * verified ({@code VerifyError}), is already defined, or another linkage error occurs + * @throws SecurityException if denied by the security manager + * @throws NullPointerException if {@code bytes} is {@code null} + * @since 9 + * @spec JPMS + * @see Lookup#privateLookupIn + * @see Lookup#dropLookupMode + * @see ClassLoader#defineClass(String,byte[],int,int,ProtectionDomain) + */ + public Class defineClass(byte[] bytes) throws IllegalAccessException { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkPermission(new RuntimePermission("defineClass")); + if ((lookupModes() & PACKAGE) == 0) + throw new IllegalAccessException("Lookup does not have PACKAGE access"); + assert (lookupModes() & (MODULE|PUBLIC)) != 0; + + // parse class bytes to get class name (in internal form) + bytes = bytes.clone(); + String name; + try { + ClassReader reader = new ClassReader(bytes); + name = reader.getClassName(); + } catch (RuntimeException e) { + // ASM exceptions are poorly specified + ClassFormatError cfe = new ClassFormatError(); + cfe.initCause(e); + throw cfe; + } + + // get package and class name in binary form + String cn, pn; + int index = name.lastIndexOf('/'); + if (index == -1) { + cn = name; + pn = ""; + } else { + cn = name.replace('/', '.'); + pn = cn.substring(0, index); + } + if (!pn.equals(lookupClass.getPackageName())) { + throw new IllegalArgumentException("Class not in same package as lookup class"); + } + + // invoke the class loader's defineClass method + ClassLoader loader = lookupClass.getClassLoader(); + ProtectionDomain pd = (loader != null) ? lookupClassProtectionDomain() : null; + String source = "__Lookup_defineClass__"; + Class clazz = SharedSecrets.getJavaLangAccess().defineClass(loader, cn, bytes, pd, source); + assert clazz.getClassLoader() == lookupClass.getClassLoader() + && clazz.getPackageName().equals(lookupClass.getPackageName()) + && protectionDomain(clazz) == lookupClassProtectionDomain(); + return clazz; + } + + private ProtectionDomain lookupClassProtectionDomain() { + ProtectionDomain pd = cachedProtectionDomain; + if (pd == null) { + cachedProtectionDomain = pd = protectionDomain(lookupClass); + } + return pd; + } + + private ProtectionDomain protectionDomain(Class clazz) { + PrivilegedAction pa = clazz::getProtectionDomain; + return AccessController.doPrivileged(pa); + } + + // cached protection domain + private volatile ProtectionDomain cachedProtectionDomain; + + // Make sure outer class is initialized first. static { IMPL_NAMES.getClass(); } /** Package-private version of lookup which is trusted. */ static final Lookup IMPL_LOOKUP = new Lookup(Object.class, TRUSTED); - private static void checkUnprivilegedlookupClass(Class lookupClass, int allowedModes) { + /** Version of lookup which is trusted minimally. + * It can only be used to create method handles to publicly accessible + * members in packages that are exported unconditionally. + */ + static final Lookup PUBLIC_LOOKUP = new Lookup(Object.class, (PUBLIC|UNCONDITIONAL)); + + private static void checkUnprivilegedlookupClass(Class lookupClass) { String name = lookupClass.getName(); if (name.startsWith("java.lang.invoke.")) throw newIllegalArgumentException("illegal lookupClass: "+lookupClass); - - // For caller-sensitive MethodHandles.lookup() disallow lookup from - // restricted packages. This a fragile and blunt approach. - // TODO replace with a more formal and less fragile mechanism - // 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.equals("java.lang.Thread") && - !name.startsWith("java.util.concurrent.")) || - (name.startsWith("sun.") && - !name.startsWith("sun.invoke."))) { - throw newIllegalArgumentException("illegal lookupClass: " + lookupClass); - } - } } /** @@ -866,6 +1013,7 @@ public class MethodHandles { *
        *
      • If no access is allowed, the suffix is "/noaccess". *
      • If only public access to types in exported packages is allowed, the suffix is "/public". + *
      • If only public access and unconditional access are allowed, the suffix is "/publicLookup". *
      • If only public and module access are allowed, the suffix is "/module". *
      • If only public, module and package access are allowed, the suffix is "/package". *
      • If only public, module, package, and private access are allowed, the suffix is "/private". @@ -884,6 +1032,9 @@ public class MethodHandles { * because it requires a direct subclass relationship between * caller and callee.) * @see #in + * + * @revised 9 + * @spec JPMS */ @Override public String toString() { @@ -893,13 +1044,15 @@ public class MethodHandles { return cname + "/noaccess"; case PUBLIC: return cname + "/public"; + case PUBLIC|UNCONDITIONAL: + return cname + "/publicLookup"; case PUBLIC|MODULE: return cname + "/module"; case PUBLIC|MODULE|PACKAGE: return cname + "/package"; - case ALL_MODES & ~PROTECTED: + case FULL_POWER_MODES & ~PROTECTED: return cname + "/private"; - case ALL_MODES: + case FULL_POWER_MODES: return cname; case TRUSTED: return "/trusted"; // internal only; not exported @@ -1292,9 +1445,10 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method } /** - * Produces a VarHandle giving access to non-static fields of type - * {@code T} declared by a receiver class of type {@code R}, supporting - * shape {@code (R : T)}. + * Produces a VarHandle giving access to a non-static field {@code name} + * of type {@code type} declared in a class of type {@code recv}. + * The VarHandle's variable type is {@code type} and it has one + * coordinate type, {@code recv}. *

        * Access checking is performed immediately on behalf of the lookup * class. @@ -1317,7 +1471,7 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method *

        * If the field is declared {@code volatile} then the returned VarHandle * will override access to the field (effectively ignore the - * {@code volatile} declaration) in accordance to it's specified + * {@code volatile} declaration) in accordance to its specified * access modes. *

        * If the field type is {@code float} or {@code double} then numeric @@ -1413,9 +1567,10 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method } /** - * Produces a VarHandle giving access to a static field of type - * {@code T} declared by a given declaring class, supporting shape - * {@code ((empty) : T)}. + * Produces a VarHandle giving access to a static field {@code name} of + * type {@code type} declared in a class of type {@code decl}. + * The VarHandle's variable type is {@code type} and it has no + * coordinate types. *

        * Access checking is performed immediately on behalf of the lookup * class. @@ -1441,7 +1596,7 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method *

        * If the field is declared {@code volatile} then the returned VarHandle * will override access to the field (effectively ignore the - * {@code volatile} declaration) in accordance to it's specified + * {@code volatile} declaration) in accordance to its specified * access modes. *

        * If the field type is {@code float} or {@code double} then numeric @@ -1505,7 +1660,7 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method * (If the trailing array argument is the only argument, * the given receiver value will be bound to it.) *

        - * This is equivalent to the following code: + * This is almost equivalent to the following code, with some differences noted below: *

        {@code
         import static java.lang.invoke.MethodHandles.*;
         import static java.lang.invoke.MethodType.*;
        @@ -1518,7 +1673,10 @@ return mh1;
                  * where {@code defc} is either {@code receiver.getClass()} or a super
                  * type of that class, in which the requested method is accessible
                  * to the lookup class.
        -         * (Note that {@code bindTo} does not preserve variable arity.)
        +         * (Unlike {@code bind}, {@code bindTo} does not preserve variable arity.
        +         * Also, {@code bindTo} may throw a {@code ClassCastException} in instances where {@code bind} would
        +         * throw an {@code IllegalAccessException}, as in the case where the member is {@code protected} and
        +         * the receiver is restricted by {@code findVirtual} to the lookup class.)
                  * @param receiver the object from which the method is accessed
                  * @param name the name of the method
                  * @param type the type of the method, with the receiver argument omitted
        @@ -1536,7 +1694,13 @@ return mh1;
                 public MethodHandle bind(Object receiver, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
                     Class refc = receiver.getClass(); // may get NPE
                     MemberName method = resolveOrFail(REF_invokeSpecial, refc, name, type);
        -            MethodHandle mh = getDirectMethodNoRestrict(REF_invokeSpecial, refc, method, findBoundCallerClass(method));
        +            MethodHandle mh = getDirectMethodNoRestrictInvokeSpecial(refc, method, findBoundCallerClass(method));
        +            if (!mh.type().leadingReferenceParameter().isAssignableFrom(receiver.getClass())) {
        +                throw new IllegalAccessException("The restricted defining class " +
        +                                                 mh.type().leadingReferenceParameter().getName() +
        +                                                 " is not assignable from receiver class " +
        +                                                 receiver.getClass().getName());
        +            }
                     return mh.bindArgumentL(0, receiver).setVarargs(method);
                 }
         
        @@ -1580,6 +1744,7 @@ return mh1;
                     if (refKind == REF_invokeSpecial)
                         refKind = REF_invokeVirtual;
                     assert(method.isMethod());
        +            @SuppressWarnings("deprecation")
                     Lookup lookup = m.isAccessible() ? IMPL_LOOKUP : this;
                     return lookup.getDirectMethodNoSecurityManager(refKind, method.getDeclaringClass(), method, findBoundCallerClass(method));
                 }
        @@ -1662,6 +1827,7 @@ return mh1;
                 public MethodHandle unreflectConstructor(Constructor c) throws IllegalAccessException {
                     MemberName ctor = new MemberName(c);
                     assert(ctor.isConstructor());
        +            @SuppressWarnings("deprecation")
                     Lookup lookup = c.isAccessible() ? IMPL_LOOKUP : this;
                     return lookup.getDirectConstructorNoSecurityManager(ctor.getDeclaringClass(), ctor);
                 }
        @@ -1692,6 +1858,7 @@ return mh1;
                     assert(isSetter
                             ? MethodHandleNatives.refKindIsSetter(field.getReferenceKind())
                             : MethodHandleNatives.refKindIsGetter(field.getReferenceKind()));
        +            @SuppressWarnings("deprecation")
                     Lookup lookup = f.isAccessible() ? IMPL_LOOKUP : this;
                     return lookup.getDirectFieldNoSecurityManager(field.getReferenceKind(), f.getDeclaringClass(), field);
                 }
        @@ -1719,11 +1886,12 @@ return mh1;
                 }
         
                 /**
        -         * Produces a VarHandle that accesses fields of type {@code T} declared
        -         * by a class of type {@code R}, as described by the given reflected
        -         * field.
        -         * If the field is non-static the VarHandle supports a shape of
        -         * {@code (R : T)}, otherwise supports a shape of {@code ((empty) : T)}.
        +         * Produces a VarHandle giving access to a reflected field {@code f}
        +         * of type {@code T} declared in a class of type {@code R}.
        +         * The VarHandle's variable type is {@code T}.
        +         * If the field is non-static the VarHandle has one coordinate type,
        +         * {@code R}.  Otherwise, the field is static, and the VarHandle has no
        +         * coordinate types.
                  * 

        * Access checking is performed immediately on behalf of the lookup * class, regardless of the value of the field's {@code accessible} @@ -1751,7 +1919,7 @@ return mh1; *

        * If the field is declared {@code volatile} then the returned VarHandle * will override access to the field (effectively ignore the - * {@code volatile} declaration) in accordance to it's specified + * {@code volatile} declaration) in accordance to its specified * access modes. *

        * If the field type is {@code float} or {@code double} then numeric @@ -1907,7 +2075,7 @@ return mh1; /** * Returns {@code true} if this lookup has {@code PRIVATE} access. - * @return {@code true} if this lookup has {@code PRIVATE} acesss. + * @return {@code true} if this lookup has {@code PRIVATE} access. * @since 9 */ public boolean hasPrivateAccess() { @@ -2033,9 +2201,9 @@ return mh1; (defc == refc || Modifier.isPublic(refc.getModifiers()))); if (!classOK && (allowedModes & PACKAGE) != 0) { - classOK = (VerifyAccess.isClassAccessible(defc, lookupClass(), ALL_MODES) && + classOK = (VerifyAccess.isClassAccessible(defc, lookupClass(), FULL_POWER_MODES) && (defc == refc || - VerifyAccess.isClassAccessible(refc, lookupClass(), ALL_MODES))); + VerifyAccess.isClassAccessible(refc, lookupClass(), FULL_POWER_MODES))); } if (!classOK) return "class is not public"; @@ -2082,7 +2250,7 @@ return mh1; throw method.makeAccessException("caller class must be a subclass below the method", caller); } MethodType rawType = mh.type(); - if (rawType.parameterType(0) == caller) return mh; + if (caller.isAssignableFrom(rawType.parameterType(0))) return mh; // no need to restrict; already narrow MethodType narrowType = rawType.changeParameterType(0, caller); assert(!mh.isVarargsCollector()); // viewAsType will lose varargs-ness assert(mh.viewAsTypeChecks(narrowType, true)); @@ -2095,11 +2263,11 @@ return mh1; final boolean checkSecurity = true; return getDirectMethodCommon(refKind, refc, method, checkSecurity, doRestrict, callerClass); } - /** Check access and get the requested method, eliding receiver narrowing rules. */ - private MethodHandle getDirectMethodNoRestrict(byte refKind, Class refc, MemberName method, Class callerClass) throws IllegalAccessException { + /** Check access and get the requested method, for invokespecial with no restriction on the application of narrowing rules. */ + private MethodHandle getDirectMethodNoRestrictInvokeSpecial(Class refc, MemberName method, Class callerClass) throws IllegalAccessException { final boolean doRestrict = false; final boolean checkSecurity = true; - return getDirectMethodCommon(refKind, refc, method, checkSecurity, doRestrict, callerClass); + return getDirectMethodCommon(REF_invokeSpecial, refc, method, checkSecurity, doRestrict, callerClass); } /** Check access and get the requested method, eliding security manager checks. */ private MethodHandle getDirectMethodNoSecurityManager(byte refKind, Class refc, MemberName method, Class callerClass) throws IllegalAccessException { @@ -2151,10 +2319,8 @@ return mh1; DirectMethodHandle dmh = DirectMethodHandle.make(refKind, refc, method); MethodHandle mh = dmh; // Optionally narrow the receiver argument to refc using restrictReceiver. - if (doRestrict && - (refKind == REF_invokeSpecial || - (MethodHandleNatives.refKindHasReceiver(refKind) && - restrictProtectedReceiver(method)))) { + if ((doRestrict && refKind == REF_invokeSpecial) || + (MethodHandleNatives.refKindHasReceiver(refKind) && restrictProtectedReceiver(method))) { mh = restrictReceiver(method, dmh, lookupClass()); } mh = maybeBindCaller(method, mh, callerClass); @@ -2347,53 +2513,6 @@ return mh1; static ConcurrentHashMap LOOKASIDE_TABLE = new ConcurrentHashMap<>(); } - /** - * Helper class used to lazily create PUBLIC_LOOKUP with a lookup class - * in an unnamed module. - * - * @see Lookup#publicLookup - */ - private static class LookupHelper { - private static final String UNNAMED = "Unnamed"; - private static final String OBJECT = "java/lang/Object"; - - private static Class createClass() { - try { - ClassWriter cw = new ClassWriter(0); - cw.visit(Opcodes.V1_8, - Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, - UNNAMED, - null, - OBJECT, - null); - cw.visitSource(UNNAMED, null); - cw.visitEnd(); - byte[] bytes = cw.toByteArray(); - ClassLoader loader = new ClassLoader(null) { - @Override - protected Class findClass(String cn) throws ClassNotFoundException { - if (cn.equals(UNNAMED)) - return super.defineClass(UNNAMED, bytes, 0, bytes.length); - throw new ClassNotFoundException(cn); - } - }; - return loader.loadClass(UNNAMED); - } catch (Exception e) { - throw new InternalError(e); - } - } - - private static final Class PUBLIC_LOOKUP_CLASS = createClass(); - - /** - * Lookup that is trusted minimally. It can only be used to create - * method handles to publicly accessible members in exported packages. - * - * @see MethodHandles#publicLookup - */ - static final Lookup PUBLIC_LOOKUP = new Lookup(PUBLIC_LOOKUP_CLASS, Lookup.PUBLIC); - } - /** * Produces a method handle constructing arrays of a desired type. * The return type of the method handle will be the array type. @@ -2461,9 +2580,11 @@ return mh1; } /** - * - * Produces a VarHandle giving access to elements of an array type - * {@code T[]}, supporting shape {@code (T[], int : T)}. + * Produces a VarHandle giving access to elements of an array of type + * {@code arrayClass}. The VarHandle's variable type is the component type + * of {@code arrayClass} and the list of coordinate types is + * {@code (arrayClass, int)}, where the {@code int} coordinate type + * corresponds to an argument that is an index into an array. *

        * Certain access modes of the returned VarHandle are unsupported under * the following conditions: @@ -2518,13 +2639,14 @@ return mh1; /** * Produces a VarHandle giving access to elements of a {@code byte[]} array * viewed as if it were a different primitive array type, such as - * {@code int[]} or {@code long[]}. The shape of the resulting VarHandle is - * {@code (byte[], int : T)}, where the {@code int} coordinate type - * corresponds to an argument that is an index in a {@code byte[]} array, - * and {@code T} is the component type of the given view array class. The - * returned VarHandle accesses bytes at an index in a {@code byte[]} array, - * composing bytes to or from a value of {@code T} according to the given - * endianness. + * {@code int[]} or {@code long[]}. + * The VarHandle's variable type is the component type of + * {@code viewArrayClass} and the list of coordinate types is + * {@code (byte[], int)}, where the {@code int} coordinate type + * corresponds to an argument that is an index into a {@code byte[]} array. + * The returned VarHandle accesses bytes at an index in a {@code byte[]} + * array, composing bytes to or from a value of the component type of + * {@code viewArrayClass} according to the given endianness. *

        * The supported component types (variables types) are {@code short}, * {@code char}, {@code int}, {@code long}, {@code float} and @@ -2602,13 +2724,14 @@ return mh1; * Produces a VarHandle giving access to elements of a {@code ByteBuffer} * viewed as if it were an array of elements of a different primitive * component type to that of {@code byte}, such as {@code int[]} or - * {@code long[]}. The shape of the resulting VarHandle is - * {@code (ByteBuffer, int : T)}, where the {@code int} coordinate type - * corresponds to an argument that is an index in a {@code ByteBuffer}, and - * {@code T} is the component type of the given view array class. The - * returned VarHandle accesses bytes at an index in a {@code ByteBuffer}, - * composing bytes to or from a value of {@code T} according to the given - * endianness. + * {@code long[]}. + * The VarHandle's variable type is the component type of + * {@code viewArrayClass} and the list of coordinate types is + * {@code (ByteBuffer, int)}, where the {@code int} coordinate type + * corresponds to an argument that is an index into a {@code byte[]} array. + * The returned VarHandle accesses bytes at an index in a + * {@code ByteBuffer}, composing bytes to or from a value of the component + * type of {@code viewArrayClass} according to the given endianness. *

        * The supported component types (variables types) are {@code short}, * {@code char}, {@code int}, {@code long}, {@code float} and @@ -4386,7 +4509,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); * The init functions can observe initial pre-loop state, in the form {@code (a...)}. * Most clause functions will not need all of this information, but they will be formally connected to it * as if by {@link #dropArguments}. - * + * * More specifically, we shall use the notation {@code (V*)} to express an arbitrary prefix of a full * sequence {@code (V...)} (and likewise for {@code (v*)}, {@code (A*)}, {@code (a*)}). * In that notation, the general form of an init function parameter list @@ -4399,7 +4522,7 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); * met by the inputs to the loop combinator. *

        * Effectively identical sequences: - * + * * A parameter list {@code A} is defined to be effectively identical to another parameter list {@code B} * if {@code A} and {@code B} are identical, or if {@code A} is shorter and is identical with a proper prefix of {@code B}. * When speaking of an unordered set of parameter lists, we say they the set is "effectively identical" 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 53e88de34f2..860ef23f019 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 @@ -88,6 +88,7 @@ import sun.invoke.util.VerifyType; * (But the classes need not be initialized, as is the case with a {@code CONSTANT_Class}.) * This loading may occur at any time before the {@code MethodType} object is first derived. * @author John Rose, JSR 292 EG + * @since 1.7 */ public final class MethodType implements java.io.Serializable { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java b/jdk/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java index 6e5d350495d..2d32abde706 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java @@ -81,6 +81,7 @@ assertEquals("Wilma, dear?", (String) worker2.invokeExact()); * For target values which will be frequently updated, consider using * a {@linkplain VolatileCallSite volatile call site} instead. * @author John Rose, JSR 292 EG + * @since 1.7 */ public class MutableCallSite extends CallSite { /** diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java b/jdk/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java index d9f94f39e77..0566e6b483e 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java @@ -54,6 +54,7 @@ import java.util.Objects; * lambda actually captured by that class. * * @see LambdaMetafactory + * @since 1.8 */ public final class SerializedLambda implements Serializable { private static final long serialVersionUID = 8025925345765570181L; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/SwitchPoint.java b/jdk/src/java.base/share/classes/java/lang/invoke/SwitchPoint.java index 5d9b3bfe843..83b4d49cd42 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/SwitchPoint.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/SwitchPoint.java @@ -108,6 +108,7 @@ package java.lang.invoke; * } * }

        * @author Remi Forax, JSR 292 EG + * @since 1.7 */ public class SwitchPoint { private static final MethodHandle diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index 57e3a3f4a3c..9e2533f071e 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -41,7 +41,7 @@ import static java.lang.invoke.MethodHandleStatics.UNSAFE; import static java.lang.invoke.MethodHandleStatics.newInternalError; /** - * A VarHandle is a dynamically typed reference to a variable, or to a + * A VarHandle is a dynamically strongly typed reference to a variable, or to a * parametrically-defined family of variables, including static fields, * non-static fields, array elements, or components of an off-heap data * structure. Access to such variables is supported under various @@ -53,63 +53,62 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * *

        A VarHandle has: *

          - *
        • a {@link #varType variable type}, referred to as {@code T}, which is the - * type of variable(s) referenced by this VarHandle; - *
        • a list of {@link #coordinateTypes coordinate types}, referred to as - * {@code CT}, where the types (primitive and reference) are represented by - * {@link Class} objects). A list of arguments corresponding to instances of - * the coordinate types uniquely locates a variable referenced by this - * VarHandle; and - *
        • a shape, that combines the variable type and coordinate types, - * and is declared with the notation {@code (CT : T)}. An empty list of - * coordinate types is declared as {@code (empty)}. + *
        • a {@link #varType variable type} T, the type of every variable referenced + * by this VarHandle; and + *
        • a list of {@link #coordinateTypes coordinate types} + * {@code CT1, CT2, ..., CTn}, the types of coordinate expressions that + * jointly locate a variable referenced by this VarHandle. *
        + * Variable and coordinate types may be primitive or reference, and are + * represented by {@code Class} objects. The list of coordinate types may be + * empty. * *

        Factory methods that produce or {@link java.lang.invoke.MethodHandles.Lookup - * lookup} VarHandle instances document the supported variable type, coordinate - * types, and shape. + * lookup} VarHandle instances document the supported variable type and the list + * of coordinate types. * - * For example, a VarHandle referencing a non-static field will declare a shape - * of {@code (R : T)}, where {@code R} is the receiver type and - * {@code T} is the field type, and where the VarHandle and an instance of the - * receiver type can be utilized to access the field variable. - * A VarHandle referencing array elements will declare a shape of - * {@code (T[], int : T)}, where {@code T[]} is the array type and {@code T} - * its component type, and where the VarHandle, an instance of the array type, - * and an {@code int} index can be utilized to access an array element variable. + *

        Each access mode is associated with one access mode method, a + * signature polymorphic method named + * for the access mode. When an access mode method is invoked on a VarHandle + * instance, the initial arguments to the invocation are coordinate expressions + * that indicate in precisely which object the variable is to be accessed. + * Trailing arguments to the invocation represent values of importance to the + * access mode. For example, the various compare-and-set or compare-and-exchange + * access modes require two trailing arguments for the variable's expected value + * and new value. * - *

        Each access mode is associated with a - * signature polymorphic method of the - * same name, where the VarHandle shape and access mode uniquely determine the - * canonical {@link #accessModeType(AccessMode) access mode type}, - * which in turn determines the matching constraints on a valid symbolic - * type descriptor at the call site of an access mode's method - * invocation. + *

        The arity and types of arguments to the invocation of an access mode + * method are not checked statically. Instead, each access mode method + * specifies an {@link #accessModeType(AccessMode) access mode type}, + * represented as an instance of {@link MethodType}, that serves as a kind of + * method signature against which the arguments are checked dynamically. An + * access mode type gives formal parameter types in terms of the coordinate + * types of a VarHandle instance and the types for values of importance to the + * access mode. An access mode type also gives a return type, often in terms of + * the variable type of a VarHandle instance. When an access mode method is + * invoked on a VarHandle instance, the symbolic type descriptor at the + * call site, the run time types of arguments to the invocation, and the run + * time type of the return value, must match the types + * given in the access mode type. A runtime exception will be thrown if the + * match fails. * - * As such, VarHandles are dynamically and strongly typed. Their arity, - * argument types, and return type of an access mode method invocation are not - * statically checked. If they, and associated values, do not match the arity - * and types of the access mode's type, an exception will be thrown. - * - * The parameter types of an access mode method type will consist of those that - * are the VarHandles's coordinate types (in order), followed by access mode - * parameter types specific to the access mode. - * - *

        An access mode's method documents the form of its method signature, which - * is derived from the access mode parameter types. The form is declared with - * the notation {@code (CT, P1 p1, P2 p2, ..., PN pn)R}, where {@code CT} is the - * coordinate types (as documented by a VarHandle factory method), {@code P1}, - * {@code P2} and {@code PN} are the first, second and the n'th access mode - * parameters named {@code p1}, {@code p2} and {@code pn} respectively, and - * {@code R} is the return type. - * - * For example, for the generic shape of {@code (CT : T)} the - * {@link #compareAndSet} access mode method documents that its method - * signature is of the form {@code (CT, T expectedValue, T newValue)boolean}, - * where the parameter types named {@code extendedValue} and {@code newValue} - * are the access mode parameter types. If the VarHandle accesses array - * elements with a shape of say {@code (T[], int : T)} then the access mode - * method type is {@code (T[], int, T, T)boolean}. + * For example, the access mode method {@link #compareAndSet} specifies that if + * its receiver is a VarHandle instance with coordinate types + * {@code CT1, ..., CTn} and variable type {@code T}, then its access mode type + * is {@code (CT1 c1, ..., CTn cn, T expectedValue, T newValue)boolean}. + * Suppose that a VarHandle instance can access array elements, and that its + * coordinate types are {@code String[]} and {@code int} while its variable type + * is {@code String}. The access mode type for {@code compareAndSet} on this + * VarHandle instance would be + * {@code (String[] c1, int c2, String expectedValue, String newValue)boolean}. + * Such a VarHandle instance may produced by the + * {@link MethodHandles#arrayElementVarHandle(Class) array factory method} and + * access array elements as follows: + *

         {@code
        + * String[] sa = ...
        + * VarHandle avh = MethodHandles.arrayElementVarHandle(String[].class);
        + * boolean r = avh.compareAndSet(sa, 10, "expected", "new");
        + * }
        * *

        Access modes are grouped into the following categories: *

          @@ -172,10 +171,10 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * lookup} VarHandle instances document the set of access modes that are * supported, which may also include documenting restrictions based on the * variable type and whether a variable is read-only. If an access mode is not - * supported then the corresponding signature-polymorphic method will on - * invocation throw an {@code UnsupportedOperationException}. Factory methods - * should document any additional undeclared exceptions that may be thrown by - * access mode methods. + * supported then the corresponding access mode method will on invocation throw + * an {@code UnsupportedOperationException}. Factory methods should document + * any additional undeclared exceptions that may be thrown by access mode + * methods. * The {@link #get get} access mode is supported for all * VarHandle instances and the corresponding method never throws * {@code UnsupportedOperationException}. @@ -215,7 +214,7 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * precise phrasing of the specification of access mode methods and memory fence * methods may accompany future updates of the Java Language Specification. * - *

          Compilation of an access mode's method

          + *

          Compiling invocation of access mode methods

          * A Java method call expression naming an access mode method can invoke a * VarHandle from Java source code. From the viewpoint of source code, these * methods can take any arguments and their polymorphic result (if expressed) @@ -247,7 +246,7 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * except the null reference. * * - *

          Invocation of an access mode's method

          + *

          Performing invocation of access mode methods

          * The first time an {@code invokevirtual} instruction is executed it is linked * by symbolically resolving the names in the instruction and verifying that * the method call is statically legal. This also holds for calls to access mode @@ -264,38 +263,31 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * invoking is not present on the individual VarHandle being invoked. * *

          - * Invocation of an access mode's signature-polymorphic method behaves as if an - * invocation of {@link MethodHandle#invoke}, where the receiving method handle - * is bound to a VarHandle instance and the access mode. More specifically, the - * following: + * Invocation of an access mode method behaves as if an invocation of + * {@link MethodHandle#invoke}, where the receiving method handle accepts the + * VarHandle instance as the leading argument. More specifically, the + * following, where {@code {access-mode}} corresponds to the access mode method + * name: *

           {@code
            * VarHandle vh = ..
            * R r = (R) vh.{access-mode}(p1, p2, ..., pN);
            * }
          - * behaves as if (modulo the access mode methods do not declare throwing of - * {@code Throwable}): + * behaves as if: *
           {@code
            * VarHandle vh = ..
          + * VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}");
            * MethodHandle mh = MethodHandles.varHandleExactInvoker(
          - *                       VarHandle.AccessMode.{access-mode},
          - *                       vh.accessModeType(VarHandle.AccessMode.{access-mode}));
          + *                       am,
          + *                       vh.accessModeType(am));
            *
          - * mh = mh.bindTo(vh);
          - * R r = (R) mh.invoke(p1, p2, ..., pN)
          + * R r = (R) mh.invoke(vh, p1, p2, ..., pN)
            * }
          - * or, more concisely, behaves as if: - *
           {@code
          - * VarHandle vh = ..
          - * MethodHandle mh = vh.toMethodHandle(VarHandle.AccessMode.{access-mode});
          - *
          - * R r = (R) mh.invoke(p1, p2, ..., pN)
          - * }
          - * In terms of equivalent {@code invokevirtual} bytecode behaviour an access - * mode method invocation is equivalent to: + * (modulo access mode methods do not declare throwing of {@code Throwable}). + * This is equivalent to: *
           {@code
            * MethodHandle mh = MethodHandles.lookup().findVirtual(
            *                       VarHandle.class,
          - *                       VarHandle.AccessMode.{access-mode}.methodName(),
          + *                       "{access-mode}",
            *                       MethodType.methodType(R, p1, p2, ..., pN));
            *
            * R r = (R) mh.invokeExact(vh, p1, p2, ..., pN)
          @@ -306,6 +298,17 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
            * widen primitive values, as if by {@link MethodHandle#asType asType} (see also
            * {@link MethodHandles#varHandleInvoker}).
            *
          + * More concisely, such behaviour is equivalent to:
          + * 
           {@code
          + * VarHandle vh = ..
          + * VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}");
          + * MethodHandle mh = vh.toMethodHandle(am);
          + *
          + * R r = (R) mh.invoke(p1, p2, ..., pN)
          + * }
          + * Where, in this case, the method handle is bound to the VarHandle instance. + * + * *

          Invocation checking

          * In typical programs, VarHandle access mode type matching will usually * succeed. But if a match fails, the JVM will throw a @@ -439,7 +442,7 @@ public abstract class VarHandle { * if the variable was declared non-{@code volatile}. Commonly referred to * as plain read access. * - *

          The method signature is of the form {@code (CT)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. * *

          The symbolic type descriptor at the call site of {@code get} * must match the access mode type that is the result of calling @@ -449,15 +452,15 @@ public abstract class VarHandle { * throws {@code UnsupportedOperationException}. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT)} + * {@code (CT1 ct1, ..., CTn)} * , statically represented using varargs. * @return the signature-polymorphic result that is the value of the * variable * , statically represented using {@code Object}. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -469,21 +472,21 @@ public abstract class VarHandle { * semantics of setting as if the variable was declared non-{@code volatile} * and non-{@code final}. Commonly referred to as plain write access. * - *

          The method signature is of the form {@code (CT, T newValue)void} + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void} * *

          The symbolic type descriptor at the call site of {@code set} * must match the access mode type that is the result of calling * {@code accessModeType(VarHandle.AccessMode.SET)} on this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T newValue)} * , statically represented using varargs. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -497,7 +500,7 @@ public abstract class VarHandle { * Returns the value of a variable, with memory semantics of reading as if * the variable was declared {@code volatile}. * - *

          The method signature is of the form {@code (CT)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. * *

          The symbolic type descriptor at the call site of {@code getVolatile} * must match the access mode type that is the result of calling @@ -505,17 +508,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT)} + * {@code (CT1 ct1, ..., CTn ctn)} * , statically represented using varargs. * @return the signature-polymorphic result that is the value of the * variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -526,7 +529,7 @@ public abstract class VarHandle { * Sets the value of a variable to the {@code newValue}, with memory * semantics of setting as if the variable was declared {@code volatile}. * - *

          The method signature is of the form {@code (CT, T newValue)void}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}. * *

          The symbolic type descriptor at the call site of {@code setVolatile} * must match the access mode type that is the result of calling @@ -538,14 +541,14 @@ public abstract class VarHandle { * memory ordering effects compatible with {@code memory_order_seq_cst}. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T newValue)} * , statically represented using varargs. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -557,7 +560,7 @@ public abstract class VarHandle { * Returns the value of a variable, accessed in program order, but with no * assurance of memory ordering effects with respect to other threads. * - *

          The method signature is of the form {@code (CT)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. * *

          The symbolic type descriptor at the call site of {@code getOpaque} * must match the access mode type that is the result of calling @@ -565,17 +568,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT)} + * {@code (CT1 ct1, ..., CTn ctn)} * , statically represented using varargs. * @return the signature-polymorphic result that is the value of the * variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -587,7 +590,7 @@ public abstract class VarHandle { * but with no assurance of memory ordering effects with respect to other * threads. * - *

          The method signature is of the form {@code (CT, T newValue)void}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}. * *

          The symbolic type descriptor at the call site of {@code setOpaque} * must match the access mode type that is the result of calling @@ -595,14 +598,14 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T newValue)} * , statically represented using varargs. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -616,7 +619,7 @@ public abstract class VarHandle { * Returns the value of a variable, and ensures that subsequent loads and * stores are not reordered before this access. * - *

          The method signature is of the form {@code (CT)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn)T}. * *

          The symbolic type descriptor at the call site of {@code getAcquire} * must match the access mode type that is the result of calling @@ -629,17 +632,17 @@ public abstract class VarHandle { * ordering. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT)} + * {@code (CT1 ct1, ..., CTn ctn)} * , statically represented using varargs. * @return the signature-polymorphic result that is the value of the * variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -650,7 +653,7 @@ public abstract class VarHandle { * Sets the value of a variable to the {@code newValue}, and ensures that * prior loads and stores are not reordered after this access. * - *

          The method signature is of the form {@code (CT, T newValue)void}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)void}. * *

          The symbolic type descriptor at the call site of {@code setRelease} * must match the access mode type that is the result of calling @@ -663,14 +666,14 @@ public abstract class VarHandle { * ordering. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T newValue)} * , statically represented using varargs. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. */ public final native @MethodHandle.PolymorphicSignature @@ -687,7 +690,7 @@ public abstract class VarHandle { * {@code expectedValue}, as accessed with the memory semantics of * {@link #getVolatile}. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. * *

          The symbolic type descriptor at the call site of {@code * compareAndSet} must match the access mode type that is the result of @@ -695,16 +698,16 @@ public abstract class VarHandle { * this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return {@code true} if successful, otherwise {@code false} if the * witness value was not the same as the {@code expectedValue}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -720,7 +723,7 @@ public abstract class VarHandle { * {@code expectedValue}, as accessed with the memory semantics of * {@link #getVolatile}. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}. * *

          The symbolic type descriptor at the call site of {@code * compareAndExchange} @@ -729,7 +732,7 @@ public abstract class VarHandle { * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return the signature-polymorphic result that is the witness value, which * will be the same as the {@code expectedValue} if successful @@ -755,7 +758,7 @@ public abstract class VarHandle { * {@code expectedValue}, as accessed with the memory semantics of * {@link #getAcquire}. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}. * *

          The symbolic type descriptor at the call site of {@code * compareAndExchangeAcquire} @@ -764,17 +767,17 @@ public abstract class VarHandle { * this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return the signature-polymorphic result that is the witness value, which * will be the same as the {@code expectedValue} if successful * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #set(Object...) * @see #getAcquire(Object...) */ @@ -790,7 +793,7 @@ public abstract class VarHandle { * {@code expectedValue}, as accessed with the memory semantics of * {@link #get}. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T}. * *

          The symbolic type descriptor at the call site of {@code * compareAndExchangeRelease} @@ -799,17 +802,17 @@ public abstract class VarHandle { * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return the signature-polymorphic result that is the witness value, which * will be the same as the {@code expectedValue} if successful * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setRelease(Object...) * @see #get(Object...) */ @@ -830,7 +833,7 @@ public abstract class VarHandle { *

          This operation may fail spuriously (typically, due to memory * contention) even if the witness value does match the expected value. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. * *

          The symbolic type descriptor at the call site of {@code * weakCompareAndSetPlain} must match the access mode type that is the result of @@ -838,17 +841,17 @@ public abstract class VarHandle { * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return {@code true} if successful, otherwise {@code false} if the * witness value was not the same as the {@code expectedValue} or if this * operation spuriously failed. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #set(Object...) * @see #get(Object...) */ @@ -867,7 +870,7 @@ public abstract class VarHandle { *

          This operation may fail spuriously (typically, due to memory * contention) even if the witness value does match the expected value. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. * *

          The symbolic type descriptor at the call site of {@code * weakCompareAndSet} must match the access mode type that is the @@ -875,17 +878,17 @@ public abstract class VarHandle { * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return {@code true} if successful, otherwise {@code false} if the * witness value was not the same as the {@code expectedValue} or if this * operation spuriously failed. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -904,7 +907,7 @@ public abstract class VarHandle { *

          This operation may fail spuriously (typically, due to memory * contention) even if the witness value does match the expected value. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. * *

          The symbolic type descriptor at the call site of {@code * weakCompareAndSetAcquire} @@ -913,17 +916,17 @@ public abstract class VarHandle { * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return {@code true} if successful, otherwise {@code false} if the * witness value was not the same as the {@code expectedValue} or if this * operation spuriously failed. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #set(Object...) * @see #getAcquire(Object...) */ @@ -942,7 +945,7 @@ public abstract class VarHandle { *

          This operation may fail spuriously (typically, due to memory * contention) even if the witness value does match the expected value. * - *

          The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean}. * *

          The symbolic type descriptor at the call site of {@code * weakCompareAndSetRelease} @@ -951,17 +954,17 @@ public abstract class VarHandle { * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T expectedValue, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)} * , statically represented using varargs. * @return {@code true} if successful, otherwise {@code false} if the * witness value was not the same as the {@code expectedValue} or if this * operation spuriously failed. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setRelease(Object...) * @see #get(Object...) */ @@ -976,7 +979,7 @@ public abstract class VarHandle { * previous value, as accessed with the memory semantics of * {@link #getVolatile}. * - *

          The method signature is of the form {@code (CT, T newValue)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)T}. * *

          The symbolic type descriptor at the call site of {@code getAndSet} * must match the access mode type that is the result of calling @@ -984,17 +987,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T newValue)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1009,7 +1012,7 @@ public abstract class VarHandle { * previous value, as accessed with the memory semantics of * {@link #getAcquire}. * - *

          The method signature is of the form {@code (CT, T newValue)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)T}. * *

          The symbolic type descriptor at the call site of {@code getAndSetAcquire} * must match the access mode type that is the result of calling @@ -1017,17 +1020,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T newValue)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1042,7 +1045,7 @@ public abstract class VarHandle { * previous value, as accessed with the memory semantics of * {@link #get}. * - *

          The method signature is of the form {@code (CT, T newValue)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T newValue)T}. * *

          The symbolic type descriptor at the call site of {@code getAndSetRelease} * must match the access mode type that is the result of calling @@ -1050,17 +1053,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T newValue)} + * {@code (CT1 ct1, ..., CTn ctn, T newValue)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1078,7 +1081,7 @@ public abstract class VarHandle { * previous value, as accessed with the memory semantics of * {@link #getVolatile}. * - *

          The method signature is of the form {@code (CT, T value)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T value)T}. * *

          The symbolic type descriptor at the call site of {@code getAndAdd} * must match the access mode type that is the result of calling @@ -1086,17 +1089,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T value)} + * {@code (CT1 ct1, ..., CTn ctn, T value)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1111,7 +1114,7 @@ public abstract class VarHandle { * previous value, as accessed with the memory semantics of * {@link #getAcquire}. * - *

          The method signature is of the form {@code (CT, T value)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T value)T}. * *

          The symbolic type descriptor at the call site of {@code getAndAddAcquire} * must match the access mode type that is the result of calling @@ -1119,17 +1122,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T value)} + * {@code (CT1 ct1, ..., CTn ctn, T value)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1144,7 +1147,7 @@ public abstract class VarHandle { * previous value, as accessed with the memory semantics of * {@link #get}. * - *

          The method signature is of the form {@code (CT, T value)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T value)T}. * *

          The symbolic type descriptor at the call site of {@code getAndAddRelease} * must match the access mode type that is the result of calling @@ -1152,17 +1155,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T value)} + * {@code (CT1 ct1, ..., CTn ctn, T value)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1185,7 +1188,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical OR is performed instead of a bitwise OR. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseOr} * must match the access mode type that is the result of calling @@ -1193,17 +1196,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1222,7 +1225,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical OR is performed instead of a bitwise OR. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseOrAcquire} * must match the access mode type that is the result of calling @@ -1230,17 +1233,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #set(Object...) * @see #getAcquire(Object...) */ @@ -1259,7 +1262,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical OR is performed instead of a bitwise OR. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseOrRelease} * must match the access mode type that is the result of calling @@ -1267,17 +1270,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setRelease(Object...) * @see #get(Object...) */ @@ -1296,7 +1299,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical AND is performed instead of a bitwise AND. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseAnd} * must match the access mode type that is the result of calling @@ -1304,17 +1307,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1333,7 +1336,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical AND is performed instead of a bitwise AND. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseAndAcquire} * must match the access mode type that is the result of calling @@ -1341,17 +1344,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #set(Object...) * @see #getAcquire(Object...) */ @@ -1370,7 +1373,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical AND is performed instead of a bitwise AND. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseAndRelease} * must match the access mode type that is the result of calling @@ -1378,17 +1381,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setRelease(Object...) * @see #get(Object...) */ @@ -1407,7 +1410,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical XOR is performed instead of a bitwise XOR. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseXor} * must match the access mode type that is the result of calling @@ -1415,17 +1418,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setVolatile(Object...) * @see #getVolatile(Object...) */ @@ -1444,7 +1447,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical XOR is performed instead of a bitwise XOR. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseXorAcquire} * must match the access mode type that is the result of calling @@ -1452,17 +1455,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #set(Object...) * @see #getAcquire(Object...) */ @@ -1481,7 +1484,7 @@ public abstract class VarHandle { *

          If the variable type is the non-integral {@code boolean} type then a * logical XOR is performed instead of a bitwise XOR. * - *

          The method signature is of the form {@code (CT, T mask)T}. + *

          The method signature is of the form {@code (CT1 ct1, ..., CTn ctn, T mask)T}. * *

          The symbolic type descriptor at the call site of {@code getAndBitwiseXorRelease} * must match the access mode type that is the result of calling @@ -1489,17 +1492,17 @@ public abstract class VarHandle { * VarHandle. * * @param args the signature-polymorphic parameter list of the form - * {@code (CT, T mask)} + * {@code (CT1 ct1, ..., CTn ctn, T mask)} * , statically represented using varargs. * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported * for this VarHandle. - * @throws WrongMethodTypeException if the access mode type is not - * compatible with the caller's symbolic type descriptor. - * @throws ClassCastException if the access mode type is compatible with the - * caller's symbolic type descriptor, but a reference cast fails. + * @throws WrongMethodTypeException if the access mode type does not + * match the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type matches the caller's + * symbolic type descriptor, but a reference cast fails. * @see #setRelease(Object...) * @see #get(Object...) */ @@ -1790,7 +1793,7 @@ public abstract class VarHandle { /** * Returns the {@code VarHandle} signature-polymorphic method name - * associated with this {@code AccessMode} value + * associated with this {@code AccessMode} value. * * @return the signature-polymorphic method name * @see #valueFromMethodName @@ -1861,14 +1864,13 @@ public abstract class VarHandle { } /** - * Obtains the canonical access mode type for this VarHandle and a given - * access mode. + * Obtains the access mode type for this VarHandle and a given access mode. * *

          The access mode type's parameter types will consist of a prefix that * is the coordinate types of this VarHandle followed by further - * types as defined by the access mode's method. + * types as defined by the access mode method. * The access mode type's return type is defined by the return type of the - * access mode's method. + * access mode method. * * @param accessMode the access mode, corresponding to the * signature-polymorphic method of the same name @@ -1891,7 +1893,7 @@ public abstract class VarHandle { * *

          The return of a {@code false} value for a given access mode indicates * that an {@code UnsupportedOperationException} is thrown on invocation - * of the corresponding access mode's signature-polymorphic method. + * of the corresponding access mode method. * * @param accessMode the access mode, corresponding to the * signature-polymorphic method of the same name @@ -1908,7 +1910,7 @@ public abstract class VarHandle { * * @apiNote This method, for a VarHandle {@code vh} and access mode * {@code {access-mode}}, returns a method handle that is equivalent to - * method handle {@code bhm} in the following code (though it may be more + * method handle {@code bmh} in the following code (though it may be more * efficient): *

          {@code
                * MethodHandle mh = MethodHandles.varHandleExactInvoker(
          diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java b/jdk/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java
          index de88f36bbb3..1046e72edf6 100644
          --- a/jdk/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java
          +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VolatileCallSite.java
          @@ -40,6 +40,7 @@ package java.lang.invoke;
            * with {@code MutableCallSite}.
            * @see MutableCallSite
            * @author John Rose, JSR 292 EG
          + * @since 1.7
            */
           public class VolatileCallSite extends CallSite {
               /**
          diff --git a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
          index 9753569374d..ef7e44a114d 100644
          --- a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java
          +++ b/jdk/src/java.base/share/classes/java/lang/module/Configuration.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
          @@ -42,126 +42,48 @@ import java.util.stream.Collectors;
           import java.util.stream.Stream;
           
           /**
          - * The configuration that is the result of resolution or resolution with
          - * service binding.
          + * A configuration that is the result of 
          + * resolution or resolution with 
          + * service binding.
            *
          - * 

          Resolution

          + *

          A configuration encapsulates the readability graph that is the + * output of resolution. A readability graph is a directed graph where the nodes + * are of type {@link ResolvedModule} and the edges represent the readability + * amongst the modules. {@code Configuration} defines the {@link #modules() + * modules()} method to get the set of resolved modules in the graph. {@code + * ResolvedModule} defines the {@link ResolvedModule#reads() reads()} method to + * get the set of modules that a resolved module reads. The modules that are + * read may be in the same configuration or may be in {@link #parents() parent} + * configurations.

          * - *

          Resolution is the process of computing the transitive closure of a set - * of root modules over a set of observable modules by resolving the - * dependences expressed by {@code requires} clauses. + *

          Configuration defines the {@link #resolve(ModuleFinder,List,ModuleFinder,Collection) + * resolve} method to resolve a collection of root modules, and the {@link + * #resolveAndBind(ModuleFinder,List,ModuleFinder,Collection) resolveAndBind} + * method to do resolution with service binding. There are instance and + * static variants of both methods. The instance methods create a configuration + * with the receiver as the parent configuration. The static methods are for + * more advanced cases where there can be more than one parent configuration.

          * - * The dependence graph is augmented with edges that take account of - * implicitly declared dependences ({@code requires transitive}) to create a - * readability graph. A {@code Configuration} encapsulates the - * resulting graph of {@link ResolvedModule resolved modules}. - * - *

          Suppose we have the following observable modules:

          - *
           {@code
          - *     module m1 { requires m2; }
          - *     module m2 { requires transitive m3; }
          - *     module m3 { }
          - *     module m4 { }
          - * } 
          - * - *

          If the module {@code m1} is resolved then the resulting configuration - * contains three modules ({@code m1}, {@code m2}, {@code m3}). The edges in - * its readability graph are:

          - *
           {@code
          - *     m1 --> m2  (meaning m1 reads m2)
          - *     m1 --> m3
          - *     m2 --> m3
          - * } 
          - * - *

          Resolution is an additive process. When computing the transitive closure - * then the dependence relation may include dependences on modules in parent - * configurations. The result is a relative configuration that is - * relative to one or more parent configurations and where the readability graph - * may have edges from modules in the configuration to modules in parent - * configurations. - * - *

          - * - *

          Suppose we have the following observable modules:

          - *
           {@code
          - *     module m1 { requires m2; requires java.xml; }
          - *     module m2 { }
          - * } 
          - * - *

          If module {@code m1} is resolved with the configuration for the {@link - * java.lang.reflect.Layer#boot() boot} layer as the parent then the resulting - * configuration contains two modules ({@code m1}, {@code m2}). The edges in - * its readability graph are: - *

           {@code
          - *     m1 --> m2
          - *     m1 --> java.xml
          - * } 
          - * where module {@code java.xml} is in the parent configuration. For - * simplicity, this example omits the implicitly declared dependence on the - * {@code java.base} module. - * - * - *

          {@link ModuleDescriptor#isAutomatic() Automatic} modules receive special - * treatment during resolution. Each automatic module is resolved so that it - * reads all other modules in the configuration and all parent configurations. - * Each automatic module is also resolved as if it {@code requires transitive} - * all other automatic modules in the configuration (and all automatic modules - * in parent configurations).

          - - *

          Service binding

          - * - *

          Service binding is the process of augmenting a graph of resolved modules - * from the set of observable modules induced by the service-use dependence - * ({@code uses} and {@code provides} clauses). Any module that was not - * previously in the graph requires resolution to compute its transitive - * closure. Service binding is an iterative process in that adding a module - * that satisfies some service-use dependence may introduce new service-use - * dependences.

          - * - *

          Suppose we have the following observable modules:

          - *
           {@code
          - *     module m1 { exports p; uses p.S; }
          - *     module m2 { requires m1; provides p.S with p2.S2; }
          - *     module m3 { requires m1; requires m4; provides p.S with p3.S3; }
          - *     module m4 { }
          - * } 
          - * - *

          If the module {@code m1} is resolved then the resulting graph of modules - * has one module ({@code m1}). If the graph is augmented with modules induced - * by the service-use dependence relation then the configuration will contain - * four modules ({@code m1}, {@code m2}, {@code m3}, {@code m4}). The edges in - * its readability graph are:

          - *
           {@code
          - *     m2 --> m1
          - *     m3 --> m1
          - *     m3 --> m4
          - * } 
          - *

          The edges in the conceptual service-use graph are:

          - *
           {@code
          - *     m1 --> m2  (meaning m1 uses a service that is provided by m2)
          - *     m1 --> m3
          - * } 
          - * - *

          If this configuration is instantiated as a {@code Layer}, and if code in - * module {@code m1} uses {@link java.util.ServiceLoader ServiceLoader} to - * iterate over implementations of {@code p.S.class}, then it will iterate over - * an instance of {@code p2.S2} and {@code p3.S3}.

          + *

          Each {@link java.lang.ModuleLayer layer} of modules in the Java virtual + * machine is created from a configuration. The configuration for the {@link + * java.lang.ModuleLayer#boot() boot} layer is obtained by invoking {@code + * ModuleLayer.boot().configuration()}. The configuration for the boot layer + * will often be the parent when creating new configurations.

          * *

          Example

          * - *

          The following example uses the {@code resolveRequires} method to resolve - * a module named myapp with the configuration for the boot layer as - * the parent configuration. It prints the name of each resolved module and - * the names of the modules that each module reads.

          + *

          The following example uses the {@link + * #resolve(ModuleFinder,ModuleFinder,Collection) resolve} method to resolve a + * module named myapp with the configuration for the boot layer as the + * parent configuration. It prints the name of each resolved module and the + * names of the modules that each module reads.

          * *
          {@code
            *    ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
            *
          - *    Configuration parent = Layer.boot().configuration();
          + *    Configuration parent = ModuleLayer.boot().configuration();
            *
          - *    Configuration cf = parent.resolveRequires(finder,
          - *                                              ModuleFinder.of(),
          - *                                              Set.of("myapp"));
          + *    Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("myapp"));
            *    cf.modules().forEach(m -> {
            *        System.out.format("%s -> %s%n",
            *            m.name(),
          @@ -172,7 +94,8 @@ import java.util.stream.Stream;
            * }
          * * @since 9 - * @see java.lang.reflect.Layer + * @spec JPMS + * @see java.lang.ModuleLayer */ public final class Configuration { @@ -186,11 +109,17 @@ public final class Configuration { private final Set modules; private final Map nameToModule; + // constraint on target platform + private final String targetPlatform; + + String targetPlatform() { return targetPlatform; } + private Configuration() { this.parents = Collections.emptyList(); this.graph = Collections.emptyMap(); this.modules = Collections.emptySet(); this.nameToModule = Collections.emptyMap(); + this.targetPlatform = null; } private Configuration(List parents, @@ -214,27 +143,28 @@ public final class Configuration { this.graph = g; this.modules = Set.of(moduleArray); this.nameToModule = Map.ofEntries(nameEntries); - } + this.targetPlatform = resolver.targetPlatform(); + } /** * Resolves a collection of root modules, with this configuration as its * parent, to create a new configuration. This method works exactly as * specified by the static {@link - * #resolveRequires(ModuleFinder,List,ModuleFinder,Collection) resolveRequires} + * #resolve(ModuleFinder,List,ModuleFinder,Collection) resolve} * method when invoked with this configuration as the parent. In other words, * if this configuration is {@code cf} then this method is equivalent to * invoking: *
           {@code
          -     *     Configuration.resolveRequires(before, List.of(cf), after, roots);
          +     *     Configuration.resolve(before, List.of(cf), after, roots);
                * }
          * * @param before * The before module finder to find modules * @param after - * The after module finder to locate modules when a - * module cannot be located by the {@code before} module finder - * and the module is not in this configuration + * The after module finder to locate modules when not + * located by the {@code before} module finder or in parent + * configurations * @param roots * The possibly-empty collection of module names of the modules * to resolve @@ -242,16 +172,20 @@ public final class Configuration { * @return The configuration that is the result of resolving the given * root modules * + * @throws FindException + * If resolution fails for any of the observability-related reasons + * specified by the static {@code resolve} method * @throws ResolutionException - * If resolution or the post-resolution checks fail + * If any of the post-resolution consistency checks specified by + * the static {@code resolve} method fail * @throws SecurityException * If locating a module is denied by the security manager */ - public Configuration resolveRequires(ModuleFinder before, - ModuleFinder after, - Collection roots) + public Configuration resolve(ModuleFinder before, + ModuleFinder after, + Collection roots) { - return resolveRequires(before, List.of(this), after, roots); + return resolve(before, List.of(this), after, roots); } @@ -259,12 +193,12 @@ public final class Configuration { * Resolves a collection of root modules, with service binding, and with * this configuration as its parent, to create a new configuration. * This method works exactly as specified by the static {@link - * #resolveRequiresAndUses(ModuleFinder,List,ModuleFinder,Collection) - * resolveRequiresAndUses} method when invoked with this configuration + * #resolveAndBind(ModuleFinder,List,ModuleFinder,Collection) + * resolveAndBind} method when invoked with this configuration * as the parent. In other words, if this configuration is {@code cf} then * this method is equivalent to invoking: *
           {@code
          -     *     Configuration.resolveRequiresAndUses(before, List.of(cf), after, roots);
          +     *     Configuration.resolveAndBind(before, List.of(cf), after, roots);
                * }
          * * @@ -272,25 +206,29 @@ public final class Configuration { * The before module finder to find modules * @param after * The after module finder to locate modules when not - * located by the {@code before} module finder and this - * configuration + * located by the {@code before} module finder or in parent + * configurations * @param roots * The possibly-empty collection of module names of the modules * to resolve * - * @return The configuration that is the result of resolving the given - * root modules + * @return The configuration that is the result of resolving, with service + * binding, the given root modules * + * @throws FindException + * If resolution fails for any of the observability-related reasons + * specified by the static {@code resolve} method * @throws ResolutionException - * If resolution or the post-resolution checks fail + * If any of the post-resolution consistency checks specified by + * the static {@code resolve} method fail * @throws SecurityException * If locating a module is denied by the security manager */ - public Configuration resolveRequiresAndUses(ModuleFinder before, - ModuleFinder after, - Collection roots) + public Configuration resolveAndBind(ModuleFinder before, + ModuleFinder after, + Collection roots) { - return resolveRequiresAndUses(before, List.of(this), after, roots); + return resolveAndBind(before, List.of(this), after, roots); } @@ -301,14 +239,14 @@ public final class Configuration { * * This method is used to create the configuration for the boot layer. */ - static Configuration resolveRequiresAndUses(ModuleFinder finder, - Collection roots, - boolean check, - PrintStream traceOutput) + static Configuration resolveAndBind(ModuleFinder finder, + Collection roots, + boolean check, + PrintStream traceOutput) { List parents = List.of(empty()); Resolver resolver = new Resolver(finder, parents, ModuleFinder.of(), traceOutput); - resolver.resolveRequires(roots).resolveUses(); + resolver.resolve(roots).bind(); return new Configuration(parents, resolver, check); } @@ -328,13 +266,14 @@ public final class Configuration { * *

          When all modules have been resolved then the resulting dependency * graph is checked to ensure that it does not contain cycles. A - * readability graph is constructed and in conjunction with the module + * readability graph is constructed, and in conjunction with the module * exports and service use, checked for consistency.

          * - *

          Resolution and the (post-resolution) consistency checks may fail for - * following reasons:

          + *

          Resolution may fail with {@code FindException} for the following + * observability-related reasons:

          * *
            + * *
          • A root module, or a direct or transitive dependency, is not * found.

          • * @@ -343,9 +282,20 @@ public final class Configuration { * descriptor ({@code module-info.class}) or two versions of the same * module are found in the same directory.

            * + *
          + * + *

          Post-resolution consistency checks may fail with {@code + * ResolutionException} for the following reasons:

          + * + *
            + * *
          • A cycle is detected, say where module {@code m1} requires * module {@code m2} and {@code m2} requires {@code m1}.

          • * + *
          • A module reads two or more modules with the same name. This + * includes the case where a module reads another with the same name as + * itself.

          • + * *
          • Two or more modules in the configuration export the same * package to a module that reads both. This includes the case where a * module {@code M} containing package {@code p} reads another module @@ -356,21 +306,13 @@ public final class Configuration { * module {@code M} nor exported to {@code M} by any module that * {@code M} reads.

          • * - *
          • A module {@code M} declares that it - * "{@code provides ... with q.T}" but package {@code q} is not in - * module {@code M}.

          • - * - *
          • Two or more modules in the configuration are specific to - * different {@link ModuleDescriptor#osName() operating systems}, - * {@link ModuleDescriptor#osArch() architectures}, or {@link - * ModuleDescriptor#osVersion() versions}.

          • - * - *
          • Other implementation specific checks, for example referential - * integrity checks to ensure that different versions of tighly coupled - * modules cannot be combined in the same configuration.

          • - * *
          * + * @implNote In the implementation then observability of modules may depend + * on referential integrity or other checks that ensure different builds of + * tightly coupled modules or modules for specific operating systems or + * architectures are not combined in the same configuration. + * * @param before * The before module finder to find modules * @param parents @@ -386,17 +328,22 @@ public final class Configuration { * @return The configuration that is the result of resolving the given * root modules * + * @throws FindException + * If resolution fails for an observability-related reason * @throws ResolutionException - * If resolution or the post-resolution checks fail + * If a post-resolution consistency checks fails * @throws IllegalArgumentException - * If the list of parents is empty + * If the list of parents is empty, or the list has two or more + * parents with modules for different target operating systems, + * architectures, or versions + * * @throws SecurityException * If locating a module is denied by the security manager */ - public static Configuration resolveRequires(ModuleFinder before, - List parents, - ModuleFinder after, - Collection roots) + public static Configuration resolve(ModuleFinder before, + List parents, + ModuleFinder after, + Collection roots) { Objects.requireNonNull(before); Objects.requireNonNull(after); @@ -407,7 +354,7 @@ public final class Configuration { throw new IllegalArgumentException("'parents' is empty"); Resolver resolver = new Resolver(before, parentList, after, null); - resolver.resolveRequires(roots); + resolver.resolve(roots); return new Configuration(parentList, resolver, true); } @@ -417,24 +364,24 @@ public final class Configuration { * configuration. * *

          This method works exactly as specified by {@link - * #resolveRequires(ModuleFinder,List,ModuleFinder,Collection) - * resolveRequires} except that the graph of resolved modules is augmented + * #resolve(ModuleFinder,List,ModuleFinder,Collection) + * resolve} except that the graph of resolved modules is augmented * with modules induced by the service-use dependence relation.

          * *

          More specifically, the root modules are resolved as if by calling - * {@code resolveRequires}. The resolved modules, and all modules in the + * {@code resolve}. The resolved modules, and all modules in the * parent configurations, with {@link ModuleDescriptor#uses() service * dependences} are then examined. All modules found by the given module * finders that {@link ModuleDescriptor#provides() provide} an * implementation of one or more of the service types are added to the * module graph and then resolved as if by calling the {@code - * resolveRequires} method. Adding modules to the module graph may - * introduce new service-use dependences and so the process works - * iteratively until no more modules are added.

          + * resolve} method. Adding modules to the module graph may introduce new + * service-use dependences and so the process works iteratively until no + * more modules are added.

          * - *

          As service binding involves resolution then it may fail with {@link - * ResolutionException} for exactly the same reasons specified in - * {@code resolveRequires}.

          + *

          As service binding involves resolution then it may fail with {@code + * FindException} or {@code ResolutionException} for exactly the same + * reasons specified in {@code resolve}.

          * * @param before * The before module finder to find modules @@ -448,20 +395,26 @@ public final class Configuration { * The possibly-empty collection of module names of the modules * to resolve * - * @return The configuration that is the result of resolving the given - * root modules + * @return The configuration that is the result of resolving, with service + * binding, the given root modules * + * @throws FindException + * If resolution fails for any of the observability-related reasons + * specified by the static {@code resolve} method * @throws ResolutionException - * If resolution or the post-resolution checks fail + * If any of the post-resolution consistency checks specified by + * the static {@code resolve} method fail * @throws IllegalArgumentException - * If the list of parents is empty + * If the list of parents is empty, or the list has two or more + * parents with modules for different target operating systems, + * architectures, or versions * @throws SecurityException * If locating a module is denied by the security manager */ - public static Configuration resolveRequiresAndUses(ModuleFinder before, - List parents, - ModuleFinder after, - Collection roots) + public static Configuration resolveAndBind(ModuleFinder before, + List parents, + ModuleFinder after, + Collection roots) { Objects.requireNonNull(before); Objects.requireNonNull(after); @@ -472,7 +425,7 @@ public final class Configuration { throw new IllegalArgumentException("'parents' is empty"); Resolver resolver = new Resolver(before, parentList, after, null); - resolver.resolveRequires(roots).resolveUses(); + resolver.resolve(roots).bind(); return new Configuration(parentList, resolver, true); } diff --git a/jdk/src/java.base/share/classes/java/lang/module/FindException.java b/jdk/src/java.base/share/classes/java/lang/module/FindException.java index d76f2935e7e..411959eb418 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/FindException.java +++ b/jdk/src/java.base/share/classes/java/lang/module/FindException.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 @@ -26,10 +26,14 @@ package java.lang.module; /** - * Thrown by module finders when finding a module fails. + * Thrown by a {@link ModuleFinder ModuleFinder} when an error occurs finding + * a module. Also thrown by {@link + * Configuration#resolve(ModuleFinder,java.util.List,ModuleFinder,java.util.Collection) + * Configuration.resolve} when resolution fails for observability-related + * reasons. * - * @see ModuleFinder * @since 9 + * @spec JPMS */ public class FindException extends RuntimeException { diff --git a/jdk/src/java.base/share/classes/java/lang/module/InvalidModuleDescriptorException.java b/jdk/src/java.base/share/classes/java/lang/module/InvalidModuleDescriptorException.java index 981f23a5189..3e306886fb2 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/InvalidModuleDescriptorException.java +++ b/jdk/src/java.base/share/classes/java/lang/module/InvalidModuleDescriptorException.java @@ -31,6 +31,7 @@ package java.lang.module; * * @see ModuleDescriptor#read * @since 9 + * @spec JPMS */ public class InvalidModuleDescriptorException extends RuntimeException { private static final long serialVersionUID = 4863390386809347380L; diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java index b10d986ade9..20d198b46ee 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java @@ -1,5 +1,5 @@ /* - * 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 @@ -32,6 +32,7 @@ import java.io.UncheckedIOException; import java.nio.ByteBuffer; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; @@ -56,29 +57,84 @@ import jdk.internal.module.ModuleInfo; /** * A module descriptor. * - *

          A {@code ModuleDescriptor} is typically created from the binary form - * of a module declaration. Alternatively, the {@link ModuleDescriptor.Builder} - * class can be used to create a {@code ModuleDescriptor} from its components. - * The {@link #module module}, {@link #openModule openModule}, and {@link - * #automaticModule automaticModule} methods create builders for building - * different kinds of modules.

          + *

          A module descriptor describes a named module and defines methods to + * obtain each of its components. The module descriptor for a named module + * in the Java virtual machine is obtained by invoking the {@link + * java.lang.Module Module}'s {@link java.lang.Module#getDescriptor + * getDescriptor} method. Module descriptors can also be created using the + * {@link ModuleDescriptor.Builder} class or by reading the binary form of a + * module declaration ({@code module-info.class}) using the {@link + * #read(InputStream,Supplier) read} methods defined here.

          + * + *

          A module descriptor describes a normal, open, or automatic + * module. Normal modules and open modules describe their {@link + * #requires() dependences}, {@link #exports() exported-packages}, the services + * that they {@link #uses() use} or {@link #provides() provide}, and other + * components. Normal modules may {@link #opens() open} specific + * packages. The module descriptor for an open modules does not declare any + * open packages (its {@code opens} method returns an empty set) but when + * instantiated in the Java virtual machine then it is treated as if all + * packages are open. The module descriptor for an automatic module does not + * declare any dependences (except for the mandatory dependency on {@code + * java.base}), and does not declare any exported or open packages. Automatic + * module receive special treatment during resolution so that they read all + * other modules in the configuration. When an automatic module is instantiated + * in the Java virtual machine then it reads every unnamed module and is + * treated as if all packages are exported and open.

          * *

          {@code ModuleDescriptor} objects are immutable and safe for use by * multiple concurrent threads.

          * + * @see java.lang.Module * @since 9 - * @see java.lang.reflect.Module + * @spec JPMS */ public class ModuleDescriptor implements Comparable { + /** + * A modifier on a module. + * + * @see ModuleDescriptor#modifiers() + * @since 9 + * @spec JPMS + */ + public static enum Modifier { + /** + * An open module. An open module does not declare any open packages + * but the resulting module is treated as if all packages are open. + */ + OPEN, + + /** + * An automatic module. An automatic module is treated as if it exports + * and opens all packages. + * + * @apiNote This modifier does not correspond to a module flag in the + * binary form of a module declaration ({@code module-info.class}). + */ + AUTOMATIC, + + /** + * The module was not explicitly or implicitly declared. + */ + SYNTHETIC, + + /** + * The module was implicitly declared. + */ + MANDATED; + } + + /** *

          A dependence upon a module

          * * @see ModuleDescriptor#requires() * @since 9 + * @spec JPMS */ public final static class Requires @@ -88,7 +144,9 @@ public class ModuleDescriptor /** * A modifier on a module dependence. * + * @see Requires#modifiers() * @since 9 + * @spec JPMS */ public static enum Modifier { @@ -122,8 +180,10 @@ public class ModuleDescriptor private final Set mods; private final String name; private final Version compiledVersion; + private final String rawCompiledVersion; - private Requires(Set ms, String mn, Version v) { + private Requires(Set ms, String mn, Version v, String vs) { + assert v == null || vs == null; if (ms.isEmpty()) { ms = Collections.emptySet(); } else { @@ -132,12 +192,14 @@ public class ModuleDescriptor this.mods = ms; this.name = mn; this.compiledVersion = v; + this.rawCompiledVersion = vs; } private Requires(Set ms, String mn, Version v, boolean unused) { this.mods = ms; this.name = mn; this.compiledVersion = v; + this.rawCompiledVersion = null; } /** @@ -161,24 +223,52 @@ public class ModuleDescriptor /** * Returns the version of the module if recorded at compile-time. * - * @return The version of the module if recorded at compile-time + * @return The version of the module if recorded at compile-time, + * or an empty {@code Optional} if no version was recorded or + * the version string recorded is {@linkplain Version#parse(String) + * unparseable} */ public Optional compiledVersion() { return Optional.ofNullable(compiledVersion); } + /** + * Returns the string with the possibly-unparseable version of the module + * if recorded at compile-time. + * + * @return The string containing the version of the module if recorded + * at compile-time, or an empty {@code Optional} if no version + * was recorded + * + * @see #compiledVersion() + */ + public Optional rawCompiledVersion() { + if (compiledVersion != null) { + return Optional.of(compiledVersion.toString()); + } else { + return Optional.ofNullable(rawCompiledVersion); + } + } + /** * Compares this module dependence to another. * *

          Two {@code Requires} objects are compared by comparing their - * module name lexicographically. Where the module names are equal then - * the sets of modifiers are compared based on a value computed from the - * ordinal of each modifier. Where the module names are equal and the - * set of modifiers are equal then the version of the modules recorded - * at compile-time are compared. When comparing the versions recorded - * at compile-time then a dependence that has a recorded version is - * considered to succeed a dependence that does not have a recorded - * version.

          + * module names lexicographically. Where the module names are equal + * then the sets of modifiers are compared in the same way that + * module modifiers are compared (see {@link ModuleDescriptor#compareTo + * ModuleDescriptor.compareTo}). Where the module names are equal and + * the set of modifiers are equal then the version of the modules + * recorded at compile-time are compared. When comparing the versions + * recorded at compile-time then a dependence that has a recorded + * version is considered to succeed a dependence that does not have a + * recorded version. If both recorded versions are {@linkplain + * Version#parse(String) unparseable} then the {@linkplain + * #rawCompiledVersion() raw version strings} are compared + * lexicographically.

          + * + * @param that + * The module dependence to compare * * @return A negative integer, zero, or a positive integer if this module * dependence is less than, equal to, or greater than the given @@ -186,39 +276,26 @@ public class ModuleDescriptor */ @Override public int compareTo(Requires that) { + if (this == that) return 0; + int c = this.name().compareTo(that.name()); - if (c != 0) - return c; + if (c != 0) return c; // modifiers - c = Long.compare(this.modsValue(), that.modsValue()); - if (c != 0) - return c; + long v1 = modsValue(this.modifiers()); + long v2 = modsValue(that.modifiers()); + c = Long.compare(v1, v2); + if (c != 0) return c; // compiledVersion - if (this.compiledVersion != null) { - if (that.compiledVersion != null) - c = this.compiledVersion.compareTo(that.compiledVersion); - else - c = 1; - } else { - if (that.compiledVersion != null) - c = -1; - } + c = compare(this.compiledVersion, that.compiledVersion); + if (c != 0) return c; - return c; - } + // rawCompiledVersion + c = compare(this.rawCompiledVersion, that.rawCompiledVersion); + if (c != 0) return c; - /** - * Return a value for the modifiers to allow sets of modifiers to be - * compared. - */ - private long modsValue() { - long value = 0; - for (Modifier m : mods) { - value += 1 << m.ordinal(); - } - return value; + return 0; } /** @@ -245,7 +322,8 @@ public class ModuleDescriptor return false; Requires that = (Requires)ob; return name.equals(that.name) && mods.equals(that.mods) - && Objects.equals(compiledVersion, that.compiledVersion); + && Objects.equals(compiledVersion, that.compiledVersion) + && Objects.equals(rawCompiledVersion, that.rawCompiledVersion); } /** @@ -262,13 +340,15 @@ public class ModuleDescriptor int hash = name.hashCode() * 43 + mods.hashCode(); if (compiledVersion != null) hash = hash * 43 + compiledVersion.hashCode(); + if (rawCompiledVersion != null) + hash = hash * 43 + rawCompiledVersion.hashCode(); return hash; } /** - * Returns a string describing module dependence. + * Returns a string describing this module dependence. * - * @return A string describing module dependence + * @return A string describing this module dependence */ @Override public String toString() { @@ -285,18 +365,23 @@ public class ModuleDescriptor /** - *

          A module export, may be qualified or unqualified.

          + *

          A package exported by a module, may be qualified or unqualified.

          * * @see ModuleDescriptor#exports() * @since 9 + * @spec JPMS */ - public final static class Exports { + public final static class Exports + implements Comparable + { /** - * A modifier on a module export. + * A modifier on an exported package. * + * @see Exports#modifiers() * @since 9 + * @spec JPMS */ public static enum Modifier { @@ -380,6 +465,52 @@ public class ModuleDescriptor return targets; } + /** + * Compares this module export to another. + * + *

          Two {@code Exports} objects are compared by comparing the package + * names lexicographically. Where the packages names are equal then the + * sets of modifiers are compared in the same way that module modifiers + * are compared (see {@link ModuleDescriptor#compareTo + * ModuleDescriptor.compareTo}). Where the package names are equal and + * the set of modifiers are equal then the set of target modules are + * compared. This is done by sorting the names of the target modules + * in ascending order, and according to their natural ordering, and then + * comparing the corresponding elements lexicographically. Where the + * sets differ in size, and the larger set contains all elements of the + * smaller set, then the larger set is considered to succeed the smaller + * set.

          + * + * @param that + * The module export to compare + * + * @return A negative integer, zero, or a positive integer if this module + * export is less than, equal to, or greater than the given + * export dependence + */ + @Override + public int compareTo(Exports that) { + if (this == that) return 0; + + int c = source.compareTo(that.source); + if (c != 0) + return c; + + // modifiers + long v1 = modsValue(this.modifiers()); + long v2 = modsValue(that.modifiers()); + c = Long.compare(v1, v2); + if (c != 0) + return c; + + // targets + c = compare(targets, that.targets); + if (c != 0) + return c; + + return 0; + } + /** * Computes a hash code for this module export. * @@ -425,9 +556,9 @@ public class ModuleDescriptor } /** - * Returns a string describing module export. + * Returns a string describing the exported package. * - * @return A string describing module export + * @return A string describing the exported package */ @Override public String toString() { @@ -441,8 +572,7 @@ public class ModuleDescriptor /** - *

          Represents a module opens directive, may be qualified or - * unqualified.

          + *

          A package opened by a module, may be qualified or unqualified.

          * *

          The opens directive in a module declaration declares a * package to be open to allow all types in the package, and all their @@ -452,26 +582,30 @@ public class ModuleDescriptor * * @see ModuleDescriptor#opens() * @since 9 + * @spec JPMS */ - public final static class Opens { - + public final static class Opens + implements Comparable + { /** - * A modifier on a module opens directive. + * A modifier on an open package. * + * @see Opens#modifiers() * @since 9 + * @spec JPMS */ public static enum Modifier { /** - * The opens was not explicitly or implicitly declared in the - * source of the module declaration. + * The open package was not explicitly or implicitly declared in + * the source of the module declaration. */ SYNTHETIC, /** - * The opens was implicitly declared in the source of the module - * declaration. + * The open package was implicitly declared in the source of the + * module declaration. */ MANDATED; @@ -543,6 +677,52 @@ public class ModuleDescriptor return targets; } + /** + * Compares this module opens to another. + * + *

          Two {@code Opens} objects are compared by comparing the package + * names lexicographically. Where the packages names are equal then the + * sets of modifiers are compared in the same way that module modifiers + * are compared (see {@link ModuleDescriptor#compareTo + * ModuleDescriptor.compareTo}). Where the package names are equal and + * the set of modifiers are equal then the set of target modules are + * compared. This is done by sorting the names of the target modules + * in ascending order, and according to their natural ordering, and then + * comparing the corresponding elements lexicographically. Where the + * sets differ in size, and the larger set contains all elements of the + * smaller set, then the larger set is considered to succeed the smaller + * set.

          + * + * @param that + * The module opens to compare + * + * @return A negative integer, zero, or a positive integer if this module + * opens is less than, equal to, or greater than the given + * module opens + */ + @Override + public int compareTo(Opens that) { + if (this == that) return 0; + + int c = source.compareTo(that.source); + if (c != 0) + return c; + + // modifiers + long v1 = modsValue(this.modifiers()); + long v2 = modsValue(that.modifiers()); + c = Long.compare(v1, v2); + if (c != 0) + return c; + + // targets + c = compare(targets, that.targets); + if (c != 0) + return c; + + return 0; + } + /** * Computes a hash code for this module opens. * @@ -588,9 +768,9 @@ public class ModuleDescriptor } /** - * Returns a string describing module opens. + * Returns a string describing the open package. * - * @return A string describing module opens + * @return A string describing the open package */ @Override public String toString() { @@ -608,10 +788,12 @@ public class ModuleDescriptor * * @see ModuleDescriptor#provides() * @since 9 + * @spec JPMS */ - public final static class Provides { - + public final static class Provides + implements Comparable + { private final String service; private final List providers; @@ -628,7 +810,7 @@ public class ModuleDescriptor /** * Returns the fully qualified class name of the service type. * - * @return The fully qualified class name of the service type. + * @return The fully qualified class name of the service type */ public String service() { return service; } @@ -641,6 +823,46 @@ public class ModuleDescriptor */ public List providers() { return providers; } + /** + * Compares this provides to another. + * + *

          Two {@code Provides} objects are compared by comparing the fully + * qualified class name of the service type lexicographically. Where the + * class names are equal then the list of the provider class names are + * compared by comparing the corresponding elements of both lists + * lexicographically and in sequence. Where the lists differ in size, + * {@code N} is the size of the shorter list, and the first {@code N} + * corresponding elements are equal, then the longer list is considered + * to succeed the shorter list.

          + * + * @param that + * The {@code Provides} to compare + * + * @return A negative integer, zero, or a positive integer if this provides + * is less than, equal to, or greater than the given provides + */ + public int compareTo(Provides that) { + if (this == that) return 0; + + int c = service.compareTo(that.service); + if (c != 0) return c; + + // compare provider class names in sequence + int size1 = this.providers.size(); + int size2 = that.providers.size(); + for (int index=0; index size2) ? 1 : -1; + } + } + /** * Computes a hash code for this provides. * @@ -699,7 +921,7 @@ public class ModuleDescriptor * *

          A version string has three components: The version number itself, an * optional pre-release version, and an optional build version. Each - * component is sequence of tokens; each token is either a non-negative + * component is a sequence of tokens; each token is either a non-negative * integer or a string. Tokens are separated by the punctuation characters * {@code '.'}, {@code '-'}, or {@code '+'}, or by transitions from a * sequence of digits to a sequence of characters that are neither digits @@ -740,6 +962,7 @@ public class ModuleDescriptor * * @see ModuleDescriptor#version() * @since 9 + * @spec JPMS */ public final static class Version @@ -1009,53 +1232,40 @@ public class ModuleDescriptor } - + private final String name; private final Version version; - private final boolean open; - - // Indicates if synthesised for a JAR file found on the module path - private final boolean automatic; - - // Not generated from a module-info.java - private final boolean synthetic; - + private final String rawVersionString; + private final Set modifiers; + private final boolean open; // true if modifiers contains OPEN + private final boolean automatic; // true if modifiers contains AUTOMATIC private final Set requires; private final Set exports; private final Set opens; private final Set uses; private final Set provides; - - // Added post-compilation by tools private final Set packages; private final String mainClass; - private final String osName; - private final String osArch; - private final String osVersion; - private ModuleDescriptor(String name, Version version, - boolean open, - boolean automatic, - boolean synthetic, + String rawVersionString, + Set modifiers, Set requires, Set exports, Set opens, Set uses, Set provides, Set packages, - String mainClass, - String osName, - String osArch, - String osVersion) + String mainClass) { + assert version == null || rawVersionString == null; this.name = name; this.version = version; - this.open = open; - this.automatic = automatic; - this.synthetic = synthetic; - + this.rawVersionString = rawVersionString; + this.modifiers = emptyOrUnmodifiableSet(modifiers); + this.open = modifiers.contains(Modifier.OPEN); + this.automatic = modifiers.contains(Modifier.AUTOMATIC); assert (requires.stream().map(Requires::name).distinct().count() == requires.size()); this.requires = emptyOrUnmodifiableSet(requires); @@ -1066,35 +1276,6 @@ public class ModuleDescriptor this.packages = emptyOrUnmodifiableSet(packages); this.mainClass = mainClass; - this.osName = osName; - this.osArch = osArch; - this.osVersion = osVersion; - } - - /** - * Clones the given module descriptor with an augmented set of packages - */ - ModuleDescriptor(ModuleDescriptor md, Set pkgs) { - this.name = md.name; - this.version = md.version; - this.open = md.open; - this.automatic = md.automatic; - this.synthetic = md.synthetic; - - this.requires = md.requires; - this.exports = md.exports; - this.opens = md.opens; - this.uses = md.uses; - this.provides = md.provides; - - Set packages = new HashSet<>(md.packages); - packages.addAll(pkgs); - this.packages = emptyOrUnmodifiableSet(packages); - - this.mainClass = md.mainClass; - this.osName = md.osName; - this.osArch = md.osArch; - this.osVersion = md.osVersion; } /** @@ -1103,9 +1284,7 @@ public class ModuleDescriptor */ ModuleDescriptor(String name, Version version, - boolean open, - boolean automatic, - boolean synthetic, + Set modifiers, Set requires, Set exports, Set opens, @@ -1113,16 +1292,14 @@ public class ModuleDescriptor Set provides, Set packages, String mainClass, - String osName, - String osArch, - String osVersion, int hashCode, boolean unused) { this.name = name; this.version = version; - this.open = open; - this.automatic = automatic; - this.synthetic = synthetic; + this.rawVersionString = null; + this.modifiers = modifiers; + this.open = modifiers.contains(Modifier.OPEN); + this.automatic = modifiers.contains(Modifier.AUTOMATIC); this.requires = requires; this.exports = exports; this.opens = opens; @@ -1130,14 +1307,11 @@ public class ModuleDescriptor this.provides = provides; this.packages = packages; this.mainClass = mainClass; - this.osName = osName; - this.osArch = osArch; - this.osVersion = osVersion; this.hash = hashCode; } /** - *

          The module name.

          + *

          Returns the module name.

          * * @return The module name */ @@ -1145,12 +1319,20 @@ public class ModuleDescriptor return name; } + /** + *

          Returns the set of module modifiers.

          + * + * @return A possibly-empty unmodifiable set of modifiers + */ + public Set modifiers() { + return modifiers; + } + /** *

          Returns {@code true} if this is an open module.

          * - *

          An open module does not declare any open packages (the {@link #opens() - * opens} method returns an empty set) but the resulting module is treated - * as if all packages are open.

          + *

          This method is equivalent to testing if the set of {@link #modifiers + * modifiers} contains the {@link Modifier#OPEN OPEN} modifier.

          * * @return {@code true} if this is an open module */ @@ -1161,12 +1343,8 @@ public class ModuleDescriptor /** *

          Returns {@code true} if this is an automatic module.

          * - *

          An automatic module is defined implicitly rather than explicitly - * and therefore does not have a module declaration. JAR files located on - * the application module path, or by the {@link ModuleFinder} returned by - * {@link ModuleFinder#of(java.nio.file.Path[]) ModuleFinder.of}, are - * treated as automatic modules if they do have not have a module - * declaration.

          + *

          This method is equivalent to testing if the set of {@link #modifiers + * modifiers} contains the {@link Modifier#OPEN AUTOMATIC} modifier.

          * * @return {@code true} if this is an automatic module */ @@ -1175,20 +1353,13 @@ public class ModuleDescriptor } /** - *

          Returns {@code true} if this module descriptor was not generated - * from an explicit module declaration ({@code module-info.java}) - * or an implicit module declaration (an {@link #isAutomatic() automatic} - * module).

          + *

          Returns the set of {@code Requires} objects representing the module + * dependences.

          * - * @return {@code true} if this module descriptor was not generated by - * an explicit or implicit module declaration - */ - public boolean isSynthetic() { - return synthetic; - } - - /** - *

          The dependences of this module.

          + *

          The set includes a dependency on "{@code java.base}" when this + * module is not named "{@code java.base}". If this module is an automatic + * module then it does not have a dependency on any module other than + * "{@code java.base}".

          * * @return A possibly-empty unmodifiable set of {@link Requires} objects */ @@ -1197,7 +1368,11 @@ public class ModuleDescriptor } /** - *

          The module exports.

          + *

          Returns the set of {@code Exports} objects representing the exported + * packages.

          + * + *

          If this module is an automatic module then the set of exports + * is empty.

          * * @return A possibly-empty unmodifiable set of exported packages */ @@ -1206,16 +1381,11 @@ public class ModuleDescriptor } /** - *

          The module opens directives.

          + *

          Returns the set of {@code Opens} objects representing the open + * packages.

          * - *

          Each {@code Opens} object in the set represents a package (and - * the set of target module names when qualified) where all types in the - * package, and all their members, not just public types and their public - * members, can be reflected on when using APIs that bypass or suppress - * default Java language access control checks.

          - * - *

          This method returns an empty set when invoked on {@link #isOpen() - * open} module.

          + *

          If this module is an open module or an automatic module then the + * set of open packages is empty.

          * * @return A possibly-empty unmodifiable set of open packages */ @@ -1224,7 +1394,10 @@ public class ModuleDescriptor } /** - *

          The service dependences of this module.

          + *

          Returns the set of service dependences.

          + * + *

          If this module is an automatic module then the set of service + * dependences is empty.

          * * @return A possibly-empty unmodifiable set of the fully qualified class * names of the service types used @@ -1234,7 +1407,8 @@ public class ModuleDescriptor } /** - *

          The services that this module provides.

          + *

          Returns the set of {@code Provides} objects representing the + * services that the module provides.

          * * @return The possibly-empty unmodifiable set of the services that this * module provides @@ -1244,20 +1418,39 @@ public class ModuleDescriptor } /** - * Returns this module's version. + *

          Returns the module version.

          * - * @return This module's version + * @return This module's version, or an empty {@code Optional} if the + * module does not have a version or the version is + * {@linkplain Version#parse(String) unparseable} */ public Optional version() { return Optional.ofNullable(version); } /** - * Returns a string containing this module's name and, if present, its - * version. + *

          Returns the string with the possibly-unparseable version of the + * module

          * - * @return A string containing this module's name and, if present, its - * version. + * @return The string containing the version of the module or an empty + * {@code Optional} if the module does not have a version + * + * @see #version() + */ + public Optional rawVersion() { + if (version != null) { + return Optional.of(version.toString()); + } else { + return Optional.ofNullable(rawVersionString); + } + } + + /** + *

          Returns a string containing the module name and, if present, its + * version.

          + * + * @return A string containing the module name and, if present, its + * version */ public String toNameAndVersion() { if (version != null) { @@ -1268,51 +1461,22 @@ public class ModuleDescriptor } /** - * Returns the module's main class. + *

          Returns the module main class.

          * - * @return The fully qualified class name of this module's main class + * @return The fully qualified class name of the module's main class */ public Optional mainClass() { return Optional.ofNullable(mainClass); } /** - * Returns the operating system name if this module is operating system - * specific. + * Returns the set of packages in the module. * - * @return The operating system name or an empty {@code Optional} - * if this module is not operating system specific - */ - public Optional osName() { - return Optional.ofNullable(osName); - } - - /** - * Returns the operating system architecture if this module is operating - * system architecture specific. + *

          The set of packages includes all exported and open packages, as well + * as the packages of any service providers, and the package for the main + * class.

          * - * @return The operating system architecture or an empty {@code Optional} - * if this module is not operating system architecture specific - */ - public Optional osArch() { - return Optional.ofNullable(osArch); - } - - /** - * Returns the operating system version if this module is operating - * system version specific. - * - * @return The operating system version or an empty {@code Optional} - * if this module is not operating system version specific - */ - public Optional osVersion() { - return Optional.ofNullable(osVersion); - } - - /** - * Returns the names of all packages in this module. - * - * @return A possibly-empty unmodifiable set of all packages in the module + * @return A possibly-empty unmodifiable set of the packages in the module */ public Set packages() { return packages; @@ -1320,77 +1484,81 @@ public class ModuleDescriptor /** - * A builder used for building {@link ModuleDescriptor} objects. + * A builder for building {@link ModuleDescriptor} objects. * - *

          {@code ModuleDescriptor} defines the {@link #module module}, {@link - * #openModule openModule}, and {@link #automaticModule automaticModule} - * methods to create builders for building different kinds of modules.

          + *

          {@code ModuleDescriptor} defines the {@link #newModule newModule}, + * {@link #newOpenModule newOpenModule}, and {@link #newAutomaticModule + * newAutomaticModule} methods to create builders for building + * normal, open, and automatic modules.

          + * + *

          The set of packages in the module are accumulated by the {@code + * Builder} as the {@link ModuleDescriptor.Builder#exports(String) exports}, + * {@link ModuleDescriptor.Builder#opens(String) opens}, + * {@link ModuleDescriptor.Builder#packages(Set) packages}, + * {@link ModuleDescriptor.Builder#provides(String,List) provides}, and + * {@link ModuleDescriptor.Builder#mainClass(String) mainClass} methods are + * invoked.

          + * + *

          The module names, package names, and class names that are parameters + * specified to the builder methods are the module names, package names, + * and qualified names of classes (in named packages) as defined in the + * The Java™ Language Specification.

          * *

          Example usage:

          - *
          {@code    ModuleDescriptor descriptor = ModuleDescriptor.module("m1")
          -     *         .exports("p")
          -     *         .requires("m2")
          +     * 
          {@code    ModuleDescriptor descriptor = ModuleDescriptor.newModule("stats.core")
          +     *         .requires("java.base")
          +     *         .exports("org.acme.stats.core.clustering")
          +     *         .exports("org.acme.stats.core.regression")
          +     *         .packages(Set.of("org.acme.stats.core.internal"))
                *         .build();
                * }
          * * @apiNote A {@code Builder} checks the components and invariants as - * components are added to the builder. The rational for this is to detect + * components are added to the builder. The rationale for this is to detect * errors as early as possible and not defer all validation to the - * {@link #build build} method. A {@code Builder} cannot be used to create - * a {@link ModuleDescriptor#isSynthetic() synthetic} module. + * {@link #build build} method. * * @since 9 + * @spec JPMS */ public static final class Builder { final String name; - final boolean strict; // true if module names are checked + final boolean strict; + final Set modifiers; final boolean open; - final boolean synthetic; - boolean automatic; + final boolean automatic; + final Set packages = new HashSet<>(); final Map requires = new HashMap<>(); final Map exports = new HashMap<>(); final Map opens = new HashMap<>(); - final Set concealedPackages = new HashSet<>(); final Set uses = new HashSet<>(); final Map provides = new HashMap<>(); Version version; - String osName; - String osArch; - String osVersion; + String rawVersionString; String mainClass; /** * Initializes a new builder with the given module name. * - * @param strict - * Indicates whether module names are checked or not + * If {@code strict} is {@code true} then module, package, and class + * names are checked to ensure they are legal names. In addition, the + * {@link #build buid} method will add "{@code requires java.base}" if + * the dependency is not declared. */ - Builder(String name, boolean strict, boolean open, boolean synthetic) { + Builder(String name, boolean strict, Set modifiers) { this.name = (strict) ? requireModuleName(name) : name; this.strict = strict; - this.open = open; - this.synthetic = synthetic; - } - - /* package */ Builder automatic(boolean automatic) { - this.automatic = automatic; - return this; + this.modifiers = modifiers; + this.open = modifiers.contains(Modifier.OPEN); + this.automatic = modifiers.contains(Modifier.AUTOMATIC); + assert !open || !automatic; } /** - * Returns the set of packages that are exported (unconditionally or - * unconditionally). + * Returns a snapshot of the packages in the module. */ - /* package */ Set exportedPackages() { - return exports.keySet(); - } - - /** - * Returns the set of packages that are opened (unconditionally or - * unconditionally). - */ - /* package */Set openPackages() { - return opens.keySet(); + /* package */ Set packages() { + return Collections.unmodifiableSet(packages); } /** @@ -1406,8 +1574,12 @@ public class ModuleDescriptor * initialized to build * @throws IllegalStateException * If the dependence on the module has already been declared + * or this builder is for an automatic module */ public Builder requires(Requires req) { + if (automatic) + throw new IllegalStateException("Automatic modules cannot declare" + + " dependences"); String mn = req.name(); if (name.equals(mn)) throw new IllegalArgumentException("Dependence on self"); @@ -1433,11 +1605,12 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the module name is {@code null}, is not a legal Java - * identifier, or is equal to the module name that this builder + * If the module name is {@code null}, is not a legal module + * name, or is equal to the module name that this builder * was initialized to build * @throws IllegalStateException * If the dependence on the module has already been declared + * or this builder is for an automatic module */ public Builder requires(Set ms, String mn, @@ -1445,7 +1618,21 @@ public class ModuleDescriptor Objects.requireNonNull(compiledVersion); if (strict) mn = requireModuleName(mn); - return requires(new Requires(ms, mn, compiledVersion)); + return requires(new Requires(ms, mn, compiledVersion, null)); + } + + /* package */Builder requires(Set ms, + String mn, + String rawCompiledVersion) { + Requires r; + try { + Version v = Version.parse(rawCompiledVersion); + r = new Requires(ms, mn, v, null); + } catch (IllegalArgumentException e) { + if (strict) throw e; + r = new Requires(ms, mn, null, rawCompiledVersion); + } + return requires(r); } /** @@ -1460,16 +1647,17 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the module name is {@code null}, is not a legal Java - * identifier, or is equal to the module name that this builder + * If the module name is {@code null}, is not a legal module + * name, or is equal to the module name that this builder * was initialized to build * @throws IllegalStateException * If the dependence on the module has already been declared + * or this builder is for an automatic module */ public Builder requires(Set ms, String mn) { if (strict) mn = requireModuleName(mn); - return requires(new Requires(ms, mn, null)); + return requires(new Requires(ms, mn, null, null)); } /** @@ -1481,18 +1669,19 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the module name is {@code null}, is not a legal Java - * identifier, or is equal to the module name that this builder + * If the module name is {@code null}, is not a legal module + * name, or is equal to the module name that this builder * was initialized to build * @throws IllegalStateException * If the dependence on the module has already been declared + * or this builder is for an automatic module */ public Builder requires(String mn) { return requires(EnumSet.noneOf(Requires.Modifier.class), mn); } /** - * Adds an export. + * Adds an exported package. * * @param e * The export @@ -1500,29 +1689,27 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method or the package is already - * declared as exported + * If the {@link Exports#source package} is already declared as + * exported or this builder is for an automatic module */ public Builder exports(Exports e) { - // can't be exported and concealed - String source = e.source(); - if (concealedPackages.contains(source)) { - throw new IllegalStateException("Package " + source - + " already declared"); + if (automatic) { + throw new IllegalStateException("Automatic modules cannot declare" + + " exported packages"); } + String source = e.source(); if (exports.containsKey(source)) { throw new IllegalStateException("Exported package " + source + " already declared"); } - exports.put(source, e); + packages.add(source); return this; } /** - * Adds an export, with the given (and possibly empty) set of modifiers, - * to export a package to a set of target modules. + * Adds an exported package with the given (and possibly empty) set of + * modifiers. The package is exported to a set of target modules. * * @param ms * The set of modifiers @@ -1534,33 +1721,34 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the package name or any of the target modules is {@code - * null} or is not a legal Java identifier, or the set of - * targets is empty + * If the package name is {@code null} or is not a legal + * package name, the set of target modules is empty, or the set + * of target modules contains a name that is not a legal module + * name * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method or the package is already - * declared as exported + * If the package is already declared as exported + * or this builder is for an automatic module */ public Builder exports(Set ms, String pn, Set targets) { - Exports e = new Exports(ms, requirePackageName(pn), targets); + Exports e = new Exports(ms, pn, targets); // check targets targets = e.targets(); if (targets.isEmpty()) throw new IllegalArgumentException("Empty target set"); - if (strict) + if (strict) { + requirePackageName(e.source()); targets.stream().forEach(Checks::requireModuleName); - + } return exports(e); } /** - * Adds an unqualified export with the given (and possibly empty) set - * of modifiers. + * Adds an exported package with the given (and possibly empty) set of + * modifiers. The package is exported to all modules. * * @param ms * The set of modifiers @@ -1570,160 +1758,22 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the package name is {@code null} or is not a legal Java - * identifier + * If the package name is {@code null} or is not a legal + * package name * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method or the package is already - * declared as exported + * If the package is already declared as exported + * or this builder is for an automatic module */ public Builder exports(Set ms, String pn) { - Exports e = new Exports(ms, requirePackageName(pn), Collections.emptySet()); + if (strict) { + requirePackageName(pn); + } + Exports e = new Exports(ms, pn, Collections.emptySet()); return exports(e); } /** - * Adds an export to export a package to a set of target modules. - * - * @param pn - * The package name - * @param targets - * The set of target modules names - * - * @return This builder - * - * @throws IllegalArgumentException - * If the package name or any of the target modules is {@code - * null} or is not a legal Java identifier, or the set of - * targets is empty - * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method or the package is already - * declared as exported - */ - public Builder exports(String pn, Set targets) { - return exports(Collections.emptySet(), pn, targets); - } - - /** - * Adds an unqualified export. - * - * @param pn - * The package name - * - * @return This builder - * - * @throws IllegalArgumentException - * If the package name is {@code null} or is not a legal Java - * identifier - * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method or the package is already - * declared as exported - */ - public Builder exports(String pn) { - return exports(Collections.emptySet(), pn); - } - - /** - * Adds an opens directive. - * - * @param obj - * The {@code Opens} object - * - * @return This builder - * - * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method, the package is already - * declared as open, or this is a builder for an open module - */ - public Builder opens(Opens obj) { - if (open) { - throw new IllegalStateException("open modules cannot declare" - + " open packages"); - } - - // can't be open and concealed - String source = obj.source(); - if (concealedPackages.contains(source)) { - throw new IllegalStateException("Package " + source - + " already declared"); - } - if (opens.containsKey(source)) { - throw new IllegalStateException("Open package " + source - + " already declared"); - } - - opens.put(source, obj); - return this; - } - - - /** - * Adds an opens directive, with the given (and possibly empty) - * set of modifiers, to open a package to a set of target modules. - * - * @param ms - * The set of modifiers - * @param pn - * The package name - * @param targets - * The set of target modules names - * - * @return This builder - * - * @throws IllegalArgumentException - * If the package name or any of the target modules is {@code - * null} or is not a legal Java identifier, or the set of - * targets is empty - * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method, the package is already - * declared as open, or this is a builder for an open module - */ - public Builder opens(Set ms, - String pn, - Set targets) - { - Opens e = new Opens(ms, requirePackageName(pn), targets); - - // check targets - targets = e.targets(); - if (targets.isEmpty()) - throw new IllegalArgumentException("Empty target set"); - if (strict) - targets.stream().forEach(Checks::requireModuleName); - - return opens(e); - } - - /** - * Adds an opens directive to open a package with the given (and - * possibly empty) set of modifiers. - * - * @param ms - * The set of modifiers - * @param pn - * The package name - * - * @return This builder - * - * @throws IllegalArgumentException - * If the package name is {@code null} or is not a legal Java - * identifier - * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method, the package is already - * declared as open, or this is a builder for an open module - */ - public Builder opens(Set ms, String pn) { - Opens e = new Opens(ms, requirePackageName(pn), Collections.emptySet()); - return opens(e); - } - - /** - * Adds an opens directive to open a package to a set of target + * Adds an exported package. The package is exported to a set of target * modules. * * @param pn @@ -1734,20 +1784,20 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the package name or any of the target modules is {@code - * null} or is not a legal Java identifier, or the set of - * targets is empty + * If the package name is {@code null} or is not a legal + * package name, the set of target modules is empty, or the set + * of target modules contains a name that is not a legal module + * name * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method, the package is already - * declared as open, or this is a builder for an open module + * If the package is already declared as exported + * or this builder is for an automatic module */ - public Builder opens(String pn, Set targets) { - return opens(Collections.emptySet(), pn, targets); + public Builder exports(String pn, Set targets) { + return exports(Collections.emptySet(), pn, targets); } /** - * Adds an opens directive to open a package. + * Adds an exported package. The package is exported to all modules. * * @param pn * The package name @@ -1755,12 +1805,146 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the package name is {@code null} or is not a legal Java - * identifier + * If the package name is {@code null} or is not a legal + * package name * @throws IllegalStateException - * If the package is already declared as a package with the - * {@link #contains contains} method, the package is already - * declared as open, or this is a builder for an open module + * If the package is already declared as exported + * or this builder is for an automatic module + */ + public Builder exports(String pn) { + return exports(Collections.emptySet(), pn); + } + + /** + * Adds an open package. + * + * @param obj + * The {@code Opens} object + * + * @return This builder + * + * @throws IllegalStateException + * If the package is already declared as open, or this is a + * builder for an open module or automatic module + */ + public Builder opens(Opens obj) { + if (open || automatic) { + throw new IllegalStateException("Open or automatic modules cannot" + + " declare open packages"); + } + String source = obj.source(); + if (opens.containsKey(source)) { + throw new IllegalStateException("Open package " + source + + " already declared"); + } + opens.put(source, obj); + packages.add(source); + return this; + } + + + /** + * Adds an open package with the given (and possibly empty) set of + * modifiers. The package is open to a set of target modules. + * + * @param ms + * The set of modifiers + * @param pn + * The package name + * @param targets + * The set of target modules names + * + * @return This builder + * + * @throws IllegalArgumentException + * If the package name is {@code null} or is not a legal + * package name, the set of target modules is empty, or the set + * of target modules contains a name that is not a legal module + * name + * @throws IllegalStateException + * If the package is already declared as open, or this is a + * builder for an open module or automatic module + */ + public Builder opens(Set ms, + String pn, + Set targets) + { + Opens opens = new Opens(ms, pn, targets); + + // check targets + targets = opens.targets(); + if (targets.isEmpty()) + throw new IllegalArgumentException("Empty target set"); + if (strict) { + requirePackageName(opens.source()); + targets.stream().forEach(Checks::requireModuleName); + } + return opens(opens); + } + + /** + * Adds an open package with the given (and possibly empty) set of + * modifiers. The package is open to all modules. + * + * @param ms + * The set of modifiers + * @param pn + * The package name + * + * @return This builder + * + * @throws IllegalArgumentException + * If the package name is {@code null} or is not a legal + * package name + * @throws IllegalStateException + * If the package is already declared as open, or this is a + * builder for an open module or automatic module + */ + public Builder opens(Set ms, String pn) { + if (strict) { + requirePackageName(pn); + } + Opens e = new Opens(ms, pn, Collections.emptySet()); + return opens(e); + } + + /** + * Adds an open package. The package is open to a set of target modules. + * + * @param pn + * The package name + * @param targets + * The set of target modules names + * + * @return This builder + * + * @throws IllegalArgumentException + * If the package name is {@code null} or is not a legal + * package name, the set of target modules is empty, or the set + * of target modules contains a name that is not a legal module + * name + * @throws IllegalStateException + * If the package is already declared as open, or this is a + * builder for an open module or automatic module + */ + public Builder opens(String pn, Set targets) { + return opens(Collections.emptySet(), pn, targets); + } + + /** + * Adds an open package. The package is open to all modules. + * + * @param pn + * The package name + * + * @return This builder + * + * @throws IllegalArgumentException + * If the package name is {@code null} or is not a legal + * package name + * @throws IllegalStateException + * If the package is already declared as open, or this is a + * builder for an open module or automatic module */ public Builder opens(String pn) { return opens(Collections.emptySet(), pn); @@ -1775,12 +1959,16 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If the service type is {@code null} or is not a legal Java - * identifier + * If the service type is {@code null} or not a qualified name of + * a class in a named package * @throws IllegalStateException * If a dependency on the service type has already been declared + * or this is a builder for an automatic module */ public Builder uses(String service) { + if (automatic) + throw new IllegalStateException("Automatic modules can not declare" + + " service dependences"); if (uses.contains(requireServiceTypeName(service))) throw new IllegalStateException("Dependence upon service " + service + " already declared"); @@ -1789,7 +1977,9 @@ public class ModuleDescriptor } /** - * Provides a service with one or more implementations. + * Provides a service with one or more implementations. The package for + * each {@link Provides#providers provider} (or provider factory) is + * added to the module if not already added. * * @param p * The provides @@ -1801,16 +1991,18 @@ public class ModuleDescriptor * declared */ public Builder provides(Provides p) { - String st = p.service(); - if (provides.containsKey(st)) + String service = p.service(); + if (provides.containsKey(service)) throw new IllegalStateException("Providers of service " - + st + " already declared"); - provides.put(st, p); + + service + " already declared"); + provides.put(service, p); + p.providers().forEach(name -> packages.add(packageName(name))); return this; } /** - * Provides implementations of a service. + * Provides implementations of a service. The package for each provider + * (or provider factory) is added to the module if not already added. * * @param service * The service type @@ -1821,103 +2013,59 @@ public class ModuleDescriptor * * @throws IllegalArgumentException * If the service type or any of the provider class names is - * {@code null} or is not a legal Java identifier, or the list - * of provider class names is empty + * {@code null} or not a qualified name of a class in a named + * package, or the list of provider class names is empty * @throws IllegalStateException * If the providers for the service type have already been * declared */ public Builder provides(String service, List providers) { - if (provides.containsKey(service)) - throw new IllegalStateException("Providers of service " - + service + " already declared by " + name); - - Provides p = new Provides(requireServiceTypeName(service), providers); + Provides p = new Provides(service, providers); // check providers after the set has been copied. List providerNames = p.providers(); if (providerNames.isEmpty()) throw new IllegalArgumentException("Empty providers set"); - providerNames.forEach(Checks::requireServiceProviderName); - provides.put(service, p); - return this; + if (strict) { + requireServiceTypeName(p.service()); + providerNames.forEach(Checks::requireServiceProviderName); + } else { + // Disallow service/providers in unnamed package + String pn = packageName(service); + if (pn.isEmpty()) { + throw new IllegalArgumentException(service + + ": unnamed package"); + } + for (String name : providerNames) { + pn = packageName(name); + if (pn.isEmpty()) { + throw new IllegalArgumentException(name + + ": unnamed package"); + } + } + } + return provides(p); } /** - * Provides an implementation of a service. - * - * @param service - * The service type - * @param provider - * The provider or provider factory class name - * - * @return This builder - * - * @throws IllegalArgumentException - * If the service type or the provider class name is {@code - * null} or is not a legal Java identifier - * @throws IllegalStateException - * If the providers for the service type have already been - * declared - */ - public Builder provides(String service, String provider) { - if (provider == null) - throw new IllegalArgumentException("'provider' is null"); - return provides(service, List.of(provider)); - } - - /** - * Adds a (possible empty) set of packages to the module + * Adds packages to the module. All packages in the set of package names + * that are not in the module are added to module. * * @param pns - * The set of package names + * The (possibly empty) set of package names * * @return This builder * * @throws IllegalArgumentException * If any of the package names is {@code null} or is not a - * legal Java identifier - * @throws IllegalStateException - * If any of packages are already declared as packages in - * the module. This includes packages that are already - * declared as exported or open packages. + * legal package name */ - public Builder contains(Set pns) { - pns.forEach(this::contains); - return this; - } - - /** - * Adds a package to the module. - * - * @param pn - * The package name - * - * @return This builder - * - * @throws IllegalArgumentException - * If the package name is {@code null}, or is not a legal Java - * identifier - * @throws IllegalStateException - * If the package is already declared as a package in the - * module. This includes the package already declared as an - * exported or open package. - */ - public Builder contains(String pn) { - Checks.requirePackageName(pn); - if (concealedPackages.contains(pn)) { - throw new IllegalStateException("Package " + pn - + " already declared"); + public Builder packages(Set pns) { + if (strict) { + pns = new HashSet<>(pns); + pns.forEach(Checks::requirePackageName); } - if (exports.containsKey(pn)) { - throw new IllegalStateException("Exported package " - + pn + " already declared"); - } - if (opens.containsKey(pn)) { - throw new IllegalStateException("Open package " - + pn + " already declared"); - } - concealedPackages.add(pn); + this.packages.addAll(pns); return this; } @@ -1931,28 +2079,41 @@ public class ModuleDescriptor */ public Builder version(Version v) { version = requireNonNull(v); + rawVersionString = null; return this; } /** * Sets the module version. * - * @param v + * @param vs * The version string to parse * * @return This builder * * @throws IllegalArgumentException - * If {@code v} is null or cannot be parsed as a version string + * If {@code vs} is {@code null} or cannot be parsed as a + * version string * * @see Version#parse(String) */ - public Builder version(String v) { - return version(Version.parse(v)); + public Builder version(String vs) { + try { + version = Version.parse(vs); + rawVersionString = null; + } catch (IllegalArgumentException e) { + if (strict) throw e; + version = null; + rawVersionString = vs; + } + return this; } /** - * Sets the module main class. + * Sets the module main class. The package for the main class is added + * to the module if not already added. In other words, this method is + * equivalent to first invoking this builder's {@link #packages(Set) + * packages} method to add the package name of the main class. * * @param mc * The module main class @@ -1960,100 +2121,67 @@ public class ModuleDescriptor * @return This builder * * @throws IllegalArgumentException - * If {@code mainClass} is null or is not a legal Java identifier + * If {@code mainClass} is {@code null} or not a qualified + * name of a class in a named package */ public Builder mainClass(String mc) { - mainClass = requireBinaryName("main class name", mc); - return this; - } - - /** - * Sets the operating system name. - * - * @param name - * The operating system name - * - * @return This builder - * - * @throws IllegalArgumentException - * If {@code name} is null or the empty String - */ - public Builder osName(String name) { - if (name == null || name.isEmpty()) - throw new IllegalArgumentException("OS name is null or empty"); - osName = name; - return this; - } - - /** - * Sets the operating system architecture. - * - * @param arch - * The operating system architecture - * - * @return This builder - * - * @throws IllegalArgumentException - * If {@code name} is null or the empty String - */ - public Builder osArch(String arch) { - if (arch == null || arch.isEmpty()) - throw new IllegalArgumentException("OS arch is null or empty"); - osArch = arch; - return this; - } - - /** - * Sets the operating system version. - * - * @param version - * The operating system version - * - * @return This builder - * - * @throws IllegalArgumentException - * If {@code name} is null or the empty String - */ - public Builder osVersion(String version) { - if (version == null || version.isEmpty()) - throw new IllegalArgumentException("OS version is null or empty"); - osVersion = version; + String pn; + if (strict) { + mc = requireQualifiedClassName("main class name", mc); + pn = packageName(mc); + assert !pn.isEmpty(); + } else { + // Disallow main class in unnamed package + pn = packageName(mc); + if (pn.isEmpty()) { + throw new IllegalArgumentException(mc + ": unnamed package"); + } + } + packages.add(pn); + mainClass = mc; return this; } /** * Builds and returns a {@code ModuleDescriptor} from its components. * + *

          The module will require "{@code java.base}" even if the dependence + * has not been declared (the exception is when building a module named + * "{@code java.base}" as it cannot require itself). The dependence on + * "{@code java.base}" will have the {@link + * java.lang.module.ModuleDescriptor.Requires.Modifier#MANDATED MANDATED} + * modifier if the dependence was not declared.

          + * * @return The module descriptor */ public ModuleDescriptor build() { Set requires = new HashSet<>(this.requires.values()); - - Set packages = new HashSet<>(); - packages.addAll(exports.keySet()); - packages.addAll(opens.keySet()); - packages.addAll(concealedPackages); - Set exports = new HashSet<>(this.exports.values()); Set opens = new HashSet<>(this.opens.values()); + // add dependency on java.base + if (strict + && !name.equals("java.base") + && !this.requires.containsKey("java.base")) { + requires.add(new Requires(Set.of(Requires.Modifier.MANDATED), + "java.base", + null, + null)); + } + Set provides = new HashSet<>(this.provides.values()); return new ModuleDescriptor(name, version, - open, - automatic, - synthetic, + rawVersionString, + modifiers, requires, exports, opens, uses, provides, packages, - mainClass, - osName, - osArch, - osVersion); + mainClass); } } @@ -2062,16 +2190,22 @@ public class ModuleDescriptor * Compares this module descriptor to another. * *

          Two {@code ModuleDescriptor} objects are compared by comparing their - * module name lexicographically. Where the module names are equal then - * the versions, if present, are compared.

          - * - * @apiNote For now, the natural ordering is not consistent with equals. - * If two module descriptors have equal module names, equal versions if - * present, but their corresponding components are not equal, then they - * will be considered equal by this method. + * module names lexicographically. Where the module names are equal then the + * module versions are compared. When comparing the module versions then a + * module descriptor with a version is considered to succeed a module + * descriptor that does not have a version. If both versions are {@linkplain + * Version#parse(String) unparseable} then the {@linkplain #rawVersion() + * raw version strings} are compared lexicographically. Where the module names + * are equal and the versions are equal (or not present in both), then the + * set of modifiers are compared. Sets of modifiers are compared by comparing + * a binary value computed for each set. If a modifier is present + * in the set then the bit at the position of its ordinal is {@code 1} + * in the binary value, otherwise {@code 0}. If the two set of modifiers + * are also equal then the other components of the module descriptors are + * compared in a manner that is consistent with {@code equals}.

          * * @param that - * The object to which this module descriptor is to be compared + * The module descriptor to compare * * @return A negative integer, zero, or a positive integer if this module * descriptor is less than, equal to, or greater than the given @@ -2079,16 +2213,44 @@ public class ModuleDescriptor */ @Override public int compareTo(ModuleDescriptor that) { + if (this == that) return 0; + int c = this.name().compareTo(that.name()); if (c != 0) return c; - if (version == null) { - if (that.version == null) - return 0; - return -1; - } - if (that.version == null) - return +1; - return version.compareTo(that.version); + + c = compare(this.version, that.version); + if (c != 0) return c; + + c = compare(this.rawVersionString, that.rawVersionString); + if (c != 0) return c; + + long v1 = modsValue(this.modifiers()); + long v2 = modsValue(that.modifiers()); + c = Long.compare(v1, v2); + if (c != 0) return c; + + c = compare(this.requires, that.requires); + if (c != 0) return c; + + c = compare(this.packages, that.packages); + if (c != 0) return c; + + c = compare(this.exports, that.exports); + if (c != 0) return c; + + c = compare(this.opens, that.opens); + if (c != 0) return c; + + c = compare(this.uses, that.uses); + if (c != 0) return c; + + c = compare(this.provides, that.provides); + if (c != 0) return c; + + c = compare(this.mainClass, that.mainClass); + if (c != 0) return c; + + return 0; } /** @@ -2115,24 +2277,18 @@ public class ModuleDescriptor return false; ModuleDescriptor that = (ModuleDescriptor)ob; return (name.equals(that.name) - && open == that.open - && automatic == that.automatic - && synthetic == that.synthetic + && modifiers.equals(that.modifiers) && requires.equals(that.requires) + && Objects.equals(packages, that.packages) && exports.equals(that.exports) && opens.equals(that.opens) && uses.equals(that.uses) && provides.equals(that.provides) && Objects.equals(version, that.version) - && Objects.equals(mainClass, that.mainClass) - && Objects.equals(osName, that.osName) - && Objects.equals(osArch, that.osArch) - && Objects.equals(osVersion, that.osVersion) - && Objects.equals(packages, that.packages)); + && Objects.equals(rawVersionString, that.rawVersionString) + && Objects.equals(mainClass, that.mainClass)); } - private transient int hash; // cached hash code - /** * Computes a hash code for this module descriptor. * @@ -2147,31 +2303,28 @@ public class ModuleDescriptor int hc = hash; if (hc == 0) { hc = name.hashCode(); - hc = hc * 43 + Boolean.hashCode(open); - hc = hc * 43 + Boolean.hashCode(automatic); - hc = hc * 43 + Boolean.hashCode(synthetic); + hc = hc * 43 + Objects.hashCode(modifiers); hc = hc * 43 + requires.hashCode(); + hc = hc * 43 + Objects.hashCode(packages); hc = hc * 43 + exports.hashCode(); hc = hc * 43 + opens.hashCode(); hc = hc * 43 + uses.hashCode(); hc = hc * 43 + provides.hashCode(); hc = hc * 43 + Objects.hashCode(version); + hc = hc * 43 + Objects.hashCode(rawVersionString); hc = hc * 43 + Objects.hashCode(mainClass); - hc = hc * 43 + Objects.hashCode(osName); - hc = hc * 43 + Objects.hashCode(osArch); - hc = hc * 43 + Objects.hashCode(osVersion); - hc = hc * 43 + Objects.hashCode(packages); if (hc == 0) hc = -1; hash = hc; } return hc; } + private transient int hash; // cached hash code /** - * Returns a string describing this descriptor. + *

          Returns a string describing the module.

          * - * @return A string describing this descriptor + * @return A string describing the module */ @Override public String toString() { @@ -2201,31 +2354,50 @@ public class ModuleDescriptor * * @param name * The module name + * @param ms + * The set of module modifiers * * @return A new builder * * @throws IllegalArgumentException - * If the module name is {@code null} or is not a legal Java - * identifier + * If the module name is {@code null} or is not a legal module + * name, or the set of modifiers contains {@link + * Modifier#AUTOMATIC AUTOMATIC} with other modifiers */ - public static Builder module(String name) { - return new Builder(name, true, false, false); + public static Builder newModule(String name, Set ms) { + Set mods = new HashSet<>(ms); + if (mods.contains(Modifier.AUTOMATIC) && mods.size() > 1) + throw new IllegalArgumentException("AUTOMATIC cannot be used with" + + " other modifiers"); + + return new Builder(name, true, mods); + } + + /** + * Instantiates a builder to build a module descriptor for a normal + * module. This method is equivalent to invoking {@link #newModule(String,Set) + * newModule} with an empty set of {@link ModuleDescriptor.Modifier modifiers}. + * + * @param name + * The module name + * + * @return A new builder + * + * @throws IllegalArgumentException + * If the module name is {@code null} or is not a legal module + * name + */ + public static Builder newModule(String name) { + return new Builder(name, true, Set.of()); } /** * Instantiates a builder to build a module descriptor for an open module. - * An open module does not declare any open packages but the resulting - * module is treated as if all packages are open. + * This method is equivalent to invoking {@link #newModule(String,Set) + * newModule} with the {@link ModuleDescriptor.Modifier#OPEN OPEN} modifier. * - *

          As an example, the following creates a module descriptor for an open - * name "{@code m}" containing two packages, one of which is exported.

          - *
          {@code
          -     *     ModuleDescriptor descriptor = ModuleDescriptor.openModule("m")
          -     *         .requires("java.base")
          -     *         .exports("p")
          -     *         .contains("q")
          -     *         .build();
          -     * }
          + *

          The builder for an open module cannot be used to declare any open + * packages.

          * * @param name * The module name @@ -2233,19 +2405,22 @@ public class ModuleDescriptor * @return A new builder that builds an open module * * @throws IllegalArgumentException - * If the module name is {@code null} or is not a legal Java - * identifier + * If the module name is {@code null} or is not a legal module + * name */ - public static Builder openModule(String name) { - return new Builder(name, true, true, false); + public static Builder newOpenModule(String name) { + return new Builder(name, true, Set.of(Modifier.OPEN)); } /** * Instantiates a builder to build a module descriptor for an automatic - * module. Automatic modules receive special treatment during resolution - * (see {@link Configuration}) so that they read all other modules. When - * Instantiated in the Java virtual machine as a {@link java.lang.reflect.Module} - * then the Module reads every unnamed module in the Java virtual machine. + * module. This method is equivalent to invoking {@link #newModule(String,Set) + * newModule} with the {@link ModuleDescriptor.Modifier#AUTOMATIC AUTOMATIC} + * modifier. + * + *

          The builder for an automatic module cannot be used to declare module + * or service dependences. It also cannot be used to declare any exported + * or open packages.

          * * @param name * The module name @@ -2253,13 +2428,13 @@ public class ModuleDescriptor * @return A new builder that builds an automatic module * * @throws IllegalArgumentException - * If the module name is {@code null} or is not a legal Java - * identifier + * If the module name is {@code null} or is not a legal module + * name * * @see ModuleFinder#of(Path[]) */ - public static Builder automaticModule(String name) { - return new Builder(name, true, false, false).automatic(true); + public static Builder newAutomaticModule(String name) { + return new Builder(name, true, Set.of(Modifier.AUTOMATIC)); } @@ -2269,8 +2444,12 @@ public class ModuleDescriptor * *

          If the descriptor encoded in the input stream does not indicate a * set of packages in the module then the {@code packageFinder} will be - * invoked. If the {@code packageFinder} throws an {@link UncheckedIOException} - * then {@link IOException} cause will be re-thrown.

          + * invoked. The set of packages that the {@code packageFinder} returns + * must include all the packages that the module exports, opens, as well + * as the packages of the service implementations that the module provides, + * and the package of the main class (if the module has a main class). If + * the {@code packageFinder} throws an {@link UncheckedIOException} then + * {@link IOException} cause will be re-thrown.

          * *

          If there are bytes following the module descriptor then it is * implementation specific as to whether those bytes are read, ignored, @@ -2292,7 +2471,9 @@ public class ModuleDescriptor * @return The module descriptor * * @throws InvalidModuleDescriptorException - * If an invalid module descriptor is detected + * If an invalid module descriptor is detected or the set of + * packages returned by the {@code packageFinder} does not include + * all of the packages obtained from the module descriptor * @throws IOException * If an I/O error occurs reading from the input stream or {@code * UncheckedIOException} is thrown by the package finder @@ -2305,8 +2486,12 @@ public class ModuleDescriptor } /** - * Reads the binary form of a module declaration from an input stream - * as a module descriptor. + * Reads the binary form of a module declaration from an input stream as a + * module descriptor. This method works exactly as specified by the 2-arg + * {@link #read(InputStream,Supplier) read} method with the exception that + * a packager finder is not used to find additional packages when the + * module descriptor read from the stream does not indicate the set of + * packages. * * @param in * The input stream @@ -2327,7 +2512,13 @@ public class ModuleDescriptor * as a module descriptor. * *

          If the descriptor encoded in the byte buffer does not indicate a - * set of packages then the {@code packageFinder} will be invoked.

          + * set of packages in the module then the {@code packageFinder} will be + * invoked. The set of packages that the {@code packageFinder} returns + * must include all the packages that the module exports, opens, as well + * as the packages of the service implementations that the module provides, + * and the package of the main class (if the module has a main class). If + * the {@code packageFinder} throws an {@link UncheckedIOException} then + * {@link IOException} cause will be re-thrown.

          * *

          The module descriptor is read from the buffer stating at index * {@code p}, where {@code p} is the buffer's {@link ByteBuffer#position() @@ -2353,7 +2544,9 @@ public class ModuleDescriptor * @return The module descriptor * * @throws InvalidModuleDescriptorException - * If an invalid module descriptor is detected + * If an invalid module descriptor is detected or the set of + * packages returned by the {@code packageFinder} does not include + * all of the packages obtained from the module descriptor */ public static ModuleDescriptor read(ByteBuffer bb, Supplier> packageFinder) @@ -2362,8 +2555,11 @@ public class ModuleDescriptor } /** - * Reads the binary form of a module declaration from a byte buffer - * as a module descriptor. + * Reads the binary form of a module declaration from a byte buffer as a + * module descriptor. This method works exactly as specified by the 2-arg + * {@link #read(ByteBuffer,Supplier) read} method with the exception that a + * packager finder is not used to find additional packages when the module + * descriptor encoded in the buffer does not indicate the set of packages. * * @param bb * The byte buffer @@ -2398,6 +2594,11 @@ public class ModuleDescriptor } } + private static String packageName(String cn) { + int index = cn.lastIndexOf('.'); + return (index == -1) ? "" : cn.substring(0, index); + } + /** * Returns a string containing the given set of modifiers and label. */ @@ -2407,6 +2608,36 @@ public class ModuleDescriptor .collect(Collectors.joining(" ")); } + private static > + int compare(T obj1, T obj2) { + if (obj1 != null) { + return (obj2 != null) ? obj1.compareTo(obj2) : 1; + } else { + return (obj2 == null) ? 0 : -1; + } + } + + /** + * Compares two sets of {@code Comparable} objects. + */ + @SuppressWarnings("unchecked") + private static > + int compare(Set s1, Set s2) { + T[] a1 = (T[]) s1.toArray(); + T[] a2 = (T[]) s2.toArray(); + Arrays.sort(a1); + Arrays.sort(a2); + return Arrays.compare(a1, a2); + } + + private static > long modsValue(Set set) { + long value = 0; + for (Enum e : set) { + value += 1 << e.ordinal(); + } + return value; + } + static { /** * Setup the shared secret to allow code in other packages access @@ -2417,19 +2648,21 @@ public class ModuleDescriptor @Override public Builder newModuleBuilder(String mn, boolean strict, - boolean open, - boolean synthetic) { - return new Builder(mn, strict, open, synthetic); + Set modifiers) { + return new Builder(mn, strict, modifiers); } @Override - public Set exportedPackages(ModuleDescriptor.Builder builder) { - return builder.exportedPackages(); + public Set packages(ModuleDescriptor.Builder builder) { + return builder.packages(); } @Override - public Set openPackages(ModuleDescriptor.Builder builder) { - return builder.openPackages(); + public void requires(ModuleDescriptor.Builder builder, + Set ms, + String mn, + String rawCompiledVersion) { + builder.requires(ms, mn, rawCompiledVersion); } @Override @@ -2466,23 +2699,10 @@ public class ModuleDescriptor return new Provides(service, providers, true); } - @Override - public Version newVersion(String v) { - return new Version(v); - } - - @Override - public ModuleDescriptor newModuleDescriptor(ModuleDescriptor md, - Set pkgs) { - return new ModuleDescriptor(md, pkgs); - } - @Override public ModuleDescriptor newModuleDescriptor(String name, Version version, - boolean open, - boolean automatic, - boolean synthetic, + Set modifiers, Set requires, Set exports, Set opens, @@ -2490,15 +2710,10 @@ public class ModuleDescriptor Set provides, Set packages, String mainClass, - String osName, - String osArch, - String osVersion, int hashCode) { return new ModuleDescriptor(name, version, - open, - automatic, - synthetic, + modifiers, requires, exports, opens, @@ -2506,20 +2721,17 @@ public class ModuleDescriptor provides, packages, mainClass, - osName, - osArch, - osVersion, hashCode, false); } @Override - public Configuration resolveRequiresAndUses(ModuleFinder finder, - Collection roots, - boolean check, - PrintStream traceOutput) + public Configuration resolveAndBind(ModuleFinder finder, + Collection roots, + boolean check, + PrintStream traceOutput) { - return Configuration.resolveRequiresAndUses(finder, roots, check, traceOutput); + return Configuration.resolveAndBind(finder, roots, check, traceOutput); } }); } diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java index 5d01f698806..e0e6d883550 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.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 @@ -25,8 +25,6 @@ package java.lang.module; -import java.io.File; -import java.io.FilePermission; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -42,14 +40,15 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; +import jdk.internal.module.ModuleBootstrap; +import jdk.internal.module.ModulePatcher; import jdk.internal.module.ModulePath; import jdk.internal.module.SystemModuleFinder; -import sun.security.action.GetPropertyAction; /** * A finder of modules. A {@code ModuleFinder} is used to find modules during - * resolution or - * service binding. + * resolution or + * service binding. * *

          A {@code ModuleFinder} can only find one module with a given name. A * {@code ModuleFinder} that finds modules in a sequence of directories, for @@ -85,6 +84,7 @@ import sun.security.action.GetPropertyAction; *

          A {@code ModuleFinder} is not required to be thread safe.

          * * @since 9 + * @spec JPMS */ public interface ModuleFinder { @@ -124,8 +124,8 @@ public interface ModuleFinder { * to find that module.

          * * @apiNote This is important to have for methods such as {@link - * Configuration#resolveRequiresAndUses resolveRequiresAndUses} that need - * to scan the module path to find modules that provide a specific service. + * Configuration#resolveAndBind resolveAndBind} that need to scan the + * module path to find modules that provide a specific service. * * @return The set of all module references that this finder locates * @@ -144,9 +144,9 @@ public interface ModuleFinder { * *

          If there is a security manager set then its {@link * SecurityManager#checkPermission(Permission) checkPermission} method is - * invoked to check that the caller has been granted {@link FilePermission} - * to recursively read the directory that is the value of the system - * property {@code java.home}.

          + * invoked to check that the caller has been granted + * {@link RuntimePermission RuntimePermission("accessSystemModules")} + * to access the system modules.

          * * @return A {@code ModuleFinder} that locates the system modules * @@ -154,31 +154,55 @@ public interface ModuleFinder { * If denied by the security manager */ static ModuleFinder ofSystem() { - String home; - SecurityManager sm = System.getSecurityManager(); if (sm != null) { - PrivilegedAction pa = new GetPropertyAction("java.home"); - home = AccessController.doPrivileged(pa); - Permission p = new FilePermission(home + File.separator + "-", "read"); - sm.checkPermission(p); + sm.checkPermission(new RuntimePermission("accessSystemModules")); + PrivilegedAction pa = ModuleFinder::privilegedOfSystem; + return AccessController.doPrivileged(pa); } else { - home = System.getProperty("java.home"); + return privilegedOfSystem(); } + } + /** + * Returns a module finder that locates the system modules. This method + * assumes it has permissions to access the runtime image. + */ + private static ModuleFinder privilegedOfSystem() { + String home = System.getProperty("java.home"); Path modules = Paths.get(home, "lib", "modules"); if (Files.isRegularFile(modules)) { return SystemModuleFinder.getInstance(); } else { - Path mlib = Paths.get(home, "modules"); - if (Files.isDirectory(mlib)) { - return of(mlib); + Path dir = Paths.get(home, "modules"); + if (Files.isDirectory(dir)) { + return privilegedOf(ModuleBootstrap.patcher(), dir); } else { throw new InternalError("Unable to detect the run-time image"); } } } + /** + * Returns a module finder that locates the system modules in an exploded + * image. The image may be patched. + */ + private static ModuleFinder privilegedOf(ModulePatcher patcher, Path dir) { + ModuleFinder finder = ModulePath.of(patcher, dir); + return new ModuleFinder() { + @Override + public Optional find(String name) { + PrivilegedAction> pa = () -> finder.find(name); + return AccessController.doPrivileged(pa); + } + @Override + public Set findAll() { + PrivilegedAction> pa = finder::findAll; + return AccessController.doPrivileged(pa); + } + }; + } + /** * Returns a module finder that locates modules on the file system by * searching a sequence of directories and/or packaged modules. @@ -198,25 +222,20 @@ public interface ModuleFinder { * *

          If an element is a path to a directory of modules then each entry in * the directory is a packaged module or the top-level directory of an - * exploded module. The module finder's {@link #find(String) find} or - * {@link #findAll() findAll} methods throw {@link FindException} if a - * directory containing more than one module with the same name is - * encountered.

          - * - *

          If an element in the array is a path to a directory, and that - * directory contains a file named {@code module-info.class}, then the + * exploded module. It is an error if a directory contains more than one + * module with the same name. If an element is a path to a directory, and + * that directory contains a file named {@code module-info.class}, then the * directory is treated as an exploded module rather than a directory of * modules.

          * - *

          The module finder returned by this method supports modules that are - * packaged as JAR files. A JAR file with a {@code module-info.class} in - * the top-level directory of the JAR file (or overridden by a versioned - * entry in a {@link java.util.jar.JarFile#isMultiRelease() multi-release} - * JAR file) is a modular JAR and is an explicit module. - * A JAR file that does not have a {@code module-info.class} in the - * top-level directory is an {@link ModuleDescriptor#isAutomatic automatic} - * module. The {@link ModuleDescriptor} for an automatic module is created as - * follows: + *

          The module finder returned by this method + * supports modules packaged as JAR files. A JAR file with a {@code + * module-info.class} in its top-level directory, or in a versioned entry + * in a {@linkplain java.util.jar.JarFile#isMultiRelease() multi-release} + * JAR file, is a modular JAR file and thus defines an explicit + * module. A JAR file that does not have a {@code module-info.class} in its + * top-level directory defines an automatic module, as follows: + *

          * *
            * @@ -235,63 +254,67 @@ public interface ModuleFinder { * ModuleDescriptor.Version} and ignored if it cannot be parsed as * a {@code Version}.

            * - *
          • For the module name, then any trailing digits and dots - * are removed, all non-alphanumeric characters ({@code [^A-Za-z0-9]}) - * are replaced with a dot ({@code "."}), all repeating dots are - * replaced with one dot, and all leading and trailing dots are - * removed.

          • + *
          • All non-alphanumeric characters ({@code [^A-Za-z0-9]}) + * in the module name are replaced with a dot ({@code "."}), all + * repeating dots are replaced with one dot, and all leading and + * trailing dots are removed.

          • * *
          • As an example, a JAR file named {@code foo-bar.jar} will * derive a module name {@code foo.bar} and no version. A JAR file - * named {@code foo-1.2.3-SNAPSHOT.jar} will derive a module name - * {@code foo} and {@code 1.2.3-SNAPSHOT} as the version.

          • + * named {@code foo-bar-1.2.3-SNAPSHOT.jar} will derive a module + * name {@code foo.bar} and {@code 1.2.3-SNAPSHOT} as the version. + *

            * *
          * - *
        • It {@link ModuleDescriptor#requires() requires} {@code - * java.base}.

        • - * - *
        • The set of packages in the module is derived from the names - * of non-directory entries in the JAR file. A candidate package name - * is derived from an entry using the characters up to, but not - * including, the last forward slash. All remaining forward slashes are - * replaced with dot ({@code "."}). If the resulting string is a valid - * Java identifier then it is assumed to be a package name. For example, - * if the JAR file contains an entry "{@code p/q/Foo.class}" then the - * package name derived is "{@code p.q}". All packages are {@link - * ModuleDescriptor#exports() exported}.

        • + *
        • The set of packages in the module is derived from the + * non-directory entries in the JAR file that have names ending in + * "{@code .class}". A candidate package name is derived from the name + * using the characters up to, but not including, the last forward slash. + * All remaining forward slashes are replaced with dot ({@code "."}). If + * the resulting string is a legal package name then it is assumed to be + * a package name. For example, if the JAR file contains the entry + * "{@code p/q/Foo.class}" then the package name derived is + * "{@code p.q}".

        • * *
        • The contents of entries starting with {@code * META-INF/services/} are assumed to be service configuration files * (see {@link java.util.ServiceLoader}). If the name of a file - * (that follows {@code META-INF/services/}) is a legal Java identifier - * then it is assumed to be the fully-qualified binary name of a - * service type. The entries in the file are assumed to be the - * fully-qualified binary names of provider classes.

        • + * (that follows {@code META-INF/services/}) is a legal class name + * then it is assumed to be the fully-qualified class name of a service + * type. The entries in the file are assumed to be the fully-qualified + * class names of provider classes.

          * *
        • If the JAR file has a {@code Main-Class} attribute in its - * main manifest then its value is the {@link - * ModuleDescriptor#mainClass() main class}.

        • + * main manifest, its value is a legal class name, and its package is + * in the set of packages derived for the module, then the value is the + * module {@linkplain ModuleDescriptor#mainClass() main class}.

          * *
        * *

        If a {@code ModuleDescriptor} cannot be created (by means of the * {@link ModuleDescriptor.Builder ModuleDescriptor.Builder} API) for an - * automatic module then {@code FindException} is thrown. This can arise, - * for example, when a legal Java identifier name cannot be derived from - * the file name of the JAR file or where the JAR file contains a {@code - * .class} in the top-level directory of the JAR file.

        + * automatic module then {@code FindException} is thrown. This can arise + * when a legal module name cannot be derived from the file name of the JAR + * file, where the JAR file contains a {@code .class} in the top-level + * directory of the JAR file, where an entry in a service configuration + * file is not a legal class name or its package name is not in the set of + * packages derived for the module.

        * *

        In addition to JAR files, an implementation may also support modules - * that are packaged in other implementation specific module formats. When - * a file is encountered that is not recognized as a packaged module then - * {@code FindException} is thrown. An implementation may choose to ignore - * some files, {@link java.nio.file.Files#isHidden hidden} files for - * example. Paths to files that do not exist are always ignored.

        + * that are packaged in other implementation specific module formats. If + * an element in the array specified to this method is a path to a directory + * of modules then entries in the directory that not recognized as modules + * are ignored. If an element in the array is a path to a packaged module + * that is not recognized then a {@code FindException} is thrown when the + * file is encountered. Paths to files that do not exist are always ignored. + *

        * *

        As with automatic modules, the contents of a packaged or exploded * module may need to be scanned in order to determine the packages - * in the module. If a {@code .class} file (other than {@code + * in the module. Whether {@linkplain java.nio.file.Files#isHidden(Path) + * hidden files} are ignored or not is implementation specific and therefore + * not specified. If a {@code .class} file (other than {@code * module-info.class}) is found in the top-level directory then it is * assumed to be a class in the unnamed package and so {@code FindException} * is thrown.

        @@ -325,7 +348,7 @@ public interface ModuleFinder { }; } - return new ModulePath(entries); + return ModulePath.of(entries); } /** diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleReader.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleReader.java index d79d210edd0..e97f32f7185 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReader.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReader.java @@ -45,10 +45,14 @@ import java.util.stream.Stream; * module. A module reader is also intended to be used by {@code ClassLoader} * implementations that load classes and resources from modules.

        * - *

        A resource in a module is identified by a name that is a + *

        A resource in a module is identified by an abstract name that is a * '{@code /}'-separated path string. For example, module {@code java.base} may * have a resource "{@code java/lang/Object.class}" that, by convention, is the - * class file for {@code java.lang.Object}.

        + * class file for {@code java.lang.Object}. A module reader may treat + * directories in the module content as resources (whether it does or not is + * module reader specific). Where the module content contains a directory + * that can be located as a resource then its name ends with a slash ('/'). The + * directory can also be located with a name that drops the trailing slash.

        * *

        A {@code ModuleReader} is {@linkplain ModuleReference#open open} upon * creation and is closed by invoking the {@link #close close} method. Failure @@ -61,8 +65,18 @@ import java.util.stream.Stream; * open}, {@link #read read}, and {@link #list list} methods may throw {@code * SecurityException} if access is denied by the security manager.

        * + * @implSpec Implementations of {@code ModuleReader} should take great care + * when translating an abstract resource name to the location of a resource in + * a packaged module or on the file system. Implementations are advised to + * treat resource names with elements such as '{@code .}, '{@code ..}', + * elements containing file separators, or empty elements as "not found". More + * generally, if the resource name is not in the stream of elements that the + * {@code list} method returns then the resource should be treated as "not + * found" to avoid inconsistencies. + * * @see ModuleReference * @since 9 + * @spec JPMS */ public interface ModuleReader extends Closeable { @@ -70,6 +84,9 @@ public interface ModuleReader extends Closeable { /** * Finds a resource, returning a URI to the resource in the module. * + *

        If the module reader can determine that the name locates a directory + * then the resulting URI will end with a slash ('/').

        + * * @param name * The name of the resource to open for reading * @@ -130,7 +147,7 @@ public interface ModuleReader extends Closeable { * * @apiNote This method is intended for high-performance class loading. It * is not capable (or intended) to read arbitrary large resources that - * could potentially be 2GB or larger. The rational for using this method + * could potentially be 2GB or larger. The rationale for using this method * in conjunction with the {@code release} method is to allow module reader * implementations manage buffers in an efficient manner. * @@ -148,6 +165,9 @@ public interface ModuleReader extends Closeable { * If an I/O error occurs or the module reader is closed * @throws SecurityException * If denied by the security manager + * @throws OutOfMemoryError + * If the resource is larger than {@code Integer.MAX_VALUE}, + * the maximum capacity of a byte buffer * * @see ClassLoader#defineClass(String, ByteBuffer, java.security.ProtectionDomain) */ @@ -182,7 +202,9 @@ public interface ModuleReader extends Closeable { /** * Lists the contents of the module, returning a stream of elements that - * are the names of all resources in the module. + * are the names of all resources in the module. Whether the stream of + * elements includes names corresponding to directories in the module is + * module reader specific. * *

        In lazy implementations then an {@code IOException} may be thrown * when using the stream to list the module contents. If this occurs then diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java index 09a5acec219..54291e78dcc 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java @@ -44,6 +44,7 @@ import java.util.Optional; * @see ModuleFinder * @see ModuleReader * @since 9 + * @spec JPMS */ public abstract class ModuleReference { @@ -76,7 +77,7 @@ public abstract class ModuleReference { /** * Returns the location of this module's content, if known. * - *

        This URI, when present, is used as the {@linkplain + *

        This URI, when present, can be used as the {@linkplain * java.security.CodeSource#getLocation location} value of a {@link * java.security.CodeSource CodeSource} so that a module's classes can be * granted specific permissions when loaded by a {@link diff --git a/jdk/src/java.base/share/classes/java/lang/module/ResolutionException.java b/jdk/src/java.base/share/classes/java/lang/module/ResolutionException.java index fb14cfe8200..69cc71f3466 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ResolutionException.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ResolutionException.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 @@ -26,10 +26,12 @@ package java.lang.module; /** - * Thrown when resolving a set of modules or binding fails. + * Thrown when resolving a set of modules, or resolving a set of modules with + * service binding, fails. * * @see Configuration * @since 9 + * @spec JPMS */ public class ResolutionException extends RuntimeException { private static final long serialVersionUID = -1031186845316729450L; diff --git a/jdk/src/java.base/share/classes/java/lang/module/ResolvedModule.java b/jdk/src/java.base/share/classes/java/lang/module/ResolvedModule.java index 05ef3c4dc1c..a3858ef6c13 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ResolvedModule.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ResolvedModule.java @@ -37,6 +37,7 @@ import java.util.Set; * module's content. * * @since 9 + * @spec JPMS * @see Configuration#modules() */ public final class ResolvedModule { diff --git a/jdk/src/java.base/share/classes/java/lang/module/Resolver.java b/jdk/src/java.base/share/classes/java/lang/module/Resolver.java index d2aafdc5d87..a723e638abe 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/Resolver.java +++ b/jdk/src/java.base/share/classes/java/lang/module/Resolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -28,7 +28,7 @@ package java.lang.module; import java.io.PrintStream; import java.lang.module.ModuleDescriptor.Provides; import java.lang.module.ModuleDescriptor.Requires.Modifier; -import java.lang.reflect.Layer; +import java.net.URI; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -39,18 +39,17 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.StringJoiner; import java.util.stream.Collectors; import jdk.internal.module.ModuleHashes; import jdk.internal.module.ModuleReferenceImpl; +import jdk.internal.module.ModuleTarget; /** - * The resolver used by {@link Configuration#resolveRequires} and - * {@link Configuration#resolveRequiresAndUses}. + * The resolver used by {@link Configuration#resolve} and {@link + * Configuration#resolveAndBind}. * * @implNote The resolver is used at VM startup and so deliberately avoids * using lambda and stream usages in code paths used during startup. @@ -66,7 +65,18 @@ final class Resolver { // maps module name to module reference private final Map nameToReference = new HashMap<>(); + // true if all automatic modules have been found + private boolean haveAllAutomaticModules; + // constraint on target platform + private String targetPlatform; + + String targetPlatform() { return targetPlatform; } + + /** + * @throws IllegalArgumentException if there are more than one parent and + * the constraints on the target platform conflict + */ Resolver(ModuleFinder beforeFinder, List parents, ModuleFinder afterFinder, @@ -75,15 +85,30 @@ final class Resolver { this.parents = parents; this.afterFinder = afterFinder; this.traceOutput = traceOutput; - } + // record constraint on target platform, checking for conflicts + for (Configuration parent : parents) { + String value = parent.targetPlatform(); + if (value != null) { + if (targetPlatform == null) { + targetPlatform = value; + } else { + if (!value.equals(targetPlatform)) { + String msg = "Parents have conflicting constraints on target" + + " platform: " + targetPlatform + ", " + value; + throw new IllegalArgumentException(msg); + } + } + } + } + } /** * Resolves the given named modules. * * @throws ResolutionException */ - Resolver resolveRequires(Collection roots) { + Resolver resolve(Collection roots) { // create the visit stack to get us started Deque q = new ArrayDeque<>(); @@ -100,17 +125,15 @@ final class Resolver { mref = findWithAfterFinder(root); if (mref == null) { - fail("Module %s not found", root); + findFail("Module %s not found", root); } } if (isTracing()) { - trace("Root module %s located", root); - mref.location().ifPresent(uri -> trace(" (%s)", uri)); + trace("root %s", nameAndInfo(mref)); } - assert mref.descriptor().name().equals(root); - nameToReference.put(root, mref); + addFoundModule(mref); q.push(mref.descriptor()); } @@ -132,6 +155,19 @@ final class Resolver { ModuleDescriptor descriptor = q.poll(); assert nameToReference.containsKey(descriptor.name()); + // if the module is an automatic module then all automatic + // modules need to be resolved + if (descriptor.isAutomatic() && !haveAllAutomaticModules) { + addFoundAutomaticModules().forEach(mref -> { + ModuleDescriptor other = mref.descriptor(); + q.offer(other); + if (isTracing()) { + trace("%s requires %s", descriptor.name(), nameAndInfo(mref)); + } + }); + haveAllAutomaticModules = true; + } + // process dependences for (ModuleDescriptor.Requires requires : descriptor.requires()) { @@ -152,21 +188,18 @@ final class Resolver { mref = findWithAfterFinder(dn); if (mref == null) { - fail("Module %s not found, required by %s", - dn, descriptor.name()); + findFail("Module %s not found, required by %s", + dn, descriptor.name()); } } - if (!nameToReference.containsKey(dn)) { - nameToReference.put(dn, mref); - q.offer(mref.descriptor()); - resolved.add(mref.descriptor()); + if (isTracing() && !dn.equals("java.base")) { + trace("%s requires %s", descriptor.name(), nameAndInfo(mref)); + } - if (isTracing()) { - trace("Module %s located, required by %s", - dn, descriptor.name()); - mref.location().ifPresent(uri -> trace(" (%s)", uri)); - } + if (!nameToReference.containsKey(dn)) { + addFoundModule(mref); + q.offer(mref.descriptor()); } } @@ -181,7 +214,7 @@ final class Resolver { * Augments the set of resolved modules with modules induced by the * service-use relation. */ - Resolver resolveUses() { + Resolver bind() { // Scan the finders for all available service provider modules. As // java.base uses services then then module finders will be scanned @@ -211,7 +244,7 @@ final class Resolver { // the initial set of modules that may use services Set initialConsumers; - if (Layer.boot() == null) { + if (ModuleLayer.boot() == null) { initialConsumers = new HashSet<>(); } else { initialConsumers = parents.stream() @@ -230,6 +263,13 @@ final class Resolver { do { for (ModuleDescriptor descriptor : candidateConsumers) { if (!descriptor.uses().isEmpty()) { + + // the modules that provide at least one service + Set modulesToBind = null; + if (isTracing()) { + modulesToBind = new HashSet<>(); + } + for (String service : descriptor.uses()) { Set mrefs = availableProviders.get(service); if (mrefs != null) { @@ -237,16 +277,14 @@ final class Resolver { ModuleDescriptor provider = mref.descriptor(); if (!provider.equals(descriptor)) { - trace("Module %s provides %s, used by %s", - provider.name(), service, descriptor.name()); + if (isTracing() && modulesToBind.add(provider)) { + trace("%s binds %s", descriptor.name(), + nameAndInfo(mref)); + } String pn = provider.name(); if (!nameToReference.containsKey(pn)) { - if (isTracing()) { - mref.location() - .ifPresent(uri -> trace(" (%s)", uri)); - } - nameToReference.put(pn, mref); + addFoundModule(mref); q.push(provider); } } @@ -262,6 +300,56 @@ final class Resolver { return this; } + /** + * Add all automatic modules that have not already been found to the + * nameToReference map. + */ + private Set addFoundAutomaticModules() { + Set result = new HashSet<>(); + findAll().forEach(mref -> { + String mn = mref.descriptor().name(); + if (mref.descriptor().isAutomatic() && !nameToReference.containsKey(mn)) { + addFoundModule(mref); + result.add(mref); + } + }); + return result; + } + + /** + * Add the module to the nameToReference map. Also check any constraints on + * the target platform with the constraints of other modules. + */ + private void addFoundModule(ModuleReference mref) { + String mn = mref.descriptor().name(); + + if (mref instanceof ModuleReferenceImpl) { + ModuleTarget target = ((ModuleReferenceImpl)mref).moduleTarget(); + if (target != null) + checkTargetPlatform(mn, target); + } + + nameToReference.put(mn, mref); + } + + /** + * Check that the module's constraints on the target platform does + * conflict with the constraint of other modules resolved so far. + */ + private void checkTargetPlatform(String mn, ModuleTarget target) { + String value = target.targetPlatform(); + if (value != null) { + if (targetPlatform == null) { + targetPlatform = value; + } else { + if (!value.equals(targetPlatform)) { + findFail("Module %s has constraints on target platform (%s)" + + " that conflict with other modules: %s", mn, + value, targetPlatform); + } + } + } + } /** * Execute post-resolution checks and returns the module graph of resolved @@ -273,15 +361,8 @@ final class Resolver { Map> finish(Configuration cf, boolean check) { - if (isTracing()) { - trace("Result:"); - Set names = nameToReference.keySet(); - names.stream().sorted().forEach(name -> trace(" %s", name)); - } - if (check) { detectCycles(); - checkPlatformConstraints(); checkHashes(); } @@ -319,8 +400,7 @@ final class Resolver { if (!visited.contains(descriptor)) { boolean added = visitPath.add(descriptor); if (!added) { - throw new ResolutionException("Cycle detected: " + - cycleAsString(descriptor)); + resolveFail("Cycle detected: %s", cycleAsString(descriptor)); } for (ModuleDescriptor.Requires requires : descriptor.requires()) { String dn = requires.name(); @@ -353,86 +433,6 @@ final class Resolver { } - /** - * If there are platform specific modules then check that the OS name, - * architecture and version match. - * - * @apiNote This method does not currently check if the OS matches - * platform specific modules in parent configurations. - */ - private void checkPlatformConstraints() { - - // first module encountered that is platform specific - String savedModuleName = null; - String savedOsName = null; - String savedOsArch = null; - String savedOsVersion = null; - - for (ModuleReference mref : nameToReference.values()) { - ModuleDescriptor descriptor = mref.descriptor(); - - String osName = descriptor.osName().orElse(null); - String osArch = descriptor.osArch().orElse(null); - String osVersion = descriptor.osVersion().orElse(null); - - if (osName != null || osArch != null || osVersion != null) { - - if (savedModuleName == null) { - - savedModuleName = descriptor.name(); - savedOsName = osName; - savedOsArch = osArch; - savedOsVersion = osVersion; - - } else { - - boolean matches = platformMatches(osName, savedOsName) - && platformMatches(osArch, savedOsArch) - && platformMatches(osVersion, savedOsVersion); - - if (!matches) { - String s1 = platformAsString(savedOsName, - savedOsArch, - savedOsVersion); - - String s2 = platformAsString(osName, osArch, osVersion); - fail("Mismatching constraints on target platform: " - + savedModuleName + ": " + s1 - + ", " + descriptor.name() + ": " + s2); - } - - } - - } - } - - } - - /** - * Returns true if the s1 and s2 are equal or one of them is null. - */ - private boolean platformMatches(String s1, String s2) { - if (s1 == null || s2 == null) - return true; - else - return Objects.equals(s1, s2); - } - - /** - * Return a string that encodes the OS name/arch/version. - */ - private String platformAsString(String osName, - String osArch, - String osVersion) { - - return new StringJoiner("-") - .add(Objects.toString(osName, "*")) - .add(Objects.toString(osArch, "*")) - .add(Objects.toString(osVersion, "*")) - .toString(); - - } - /** * Checks the hashes in the module descriptor to ensure that they match * any recorded hashes. @@ -460,20 +460,19 @@ final class Resolver { continue; if (!(mref2 instanceof ModuleReferenceImpl)) { - fail("Unable to compute the hash of module %s", dn); + findFail("Unable to compute the hash of module %s", dn); } - // skip checking the hash if the module has been patched ModuleReferenceImpl other = (ModuleReferenceImpl)mref2; - if (other != null && !other.isPatched()) { + if (other != null) { byte[] recordedHash = hashes.hashFor(dn); byte[] actualHash = other.computeHash(algorithm); if (actualHash == null) - fail("Unable to compute the hash of module %s", dn); + findFail("Unable to compute the hash of module %s", dn); if (!Arrays.equals(recordedHash, actualHash)) { - fail("Hash of %s (%s) differs to expected hash (%s)" + - " recorded in %s", dn, toHexString(actualHash), - toHexString(recordedHash), descriptor.name()); + findFail("Hash of %s (%s) differs to expected hash (%s)" + + " recorded in %s", dn, toHexString(actualHash), + toHexString(recordedHash), descriptor.name()); } } } @@ -514,7 +513,7 @@ final class Resolver { // need "requires transitive" from the modules in parent configurations // as there may be selected modules that have a dependency on modules in // the parent configuration. - if (Layer.boot() == null) { + if (ModuleLayer.boot() == null) { g2 = new HashMap<>(capacity); } else { g2 = parents.stream() @@ -669,16 +668,30 @@ final class Resolver { /** - * Checks the readability graph to ensure that no two modules export the - * same package to a module. This includes the case where module M has - * a local package P and M reads another module that exports P to M. - * Also checks the uses/provides of module M to ensure that it reads a - * module that exports the package of the service type to M. + * Checks the readability graph to ensure that + *

          + *
        1. A module does not read two or more modules with the same name. + * This includes the case where a module reads another another with the + * same name as itself.

        2. + *
        3. Two or more modules in the configuration don't export the same + * package to a module that reads both. This includes the case where a + * module {@code M} containing package {@code p} reads another module + * that exports {@code p} to {@code M}.

        4. + *
        5. A module {@code M} doesn't declare that it "{@code uses p.S}" + * or "{@code provides p.S with ...}" but package {@code p} is neither + * in module {@code M} nor exported to {@code M} by any module that + * {@code M} reads.

        6. + *
        */ private void checkExportSuppliers(Map> graph) { for (Map.Entry> e : graph.entrySet()) { ModuleDescriptor descriptor1 = e.getKey().descriptor(); + String name1 = descriptor1.name(); + + // the names of the modules that are read (including self) + Set names = new HashSet<>(); + names.add(name1); // the map of packages that are local or exported to descriptor1 Map packageToExporter = new HashMap<>(); @@ -694,37 +707,49 @@ final class Resolver { for (ResolvedModule endpoint : reads) { ModuleDescriptor descriptor2 = endpoint.descriptor(); - for (ModuleDescriptor.Exports export : descriptor2.exports()) { - - if (export.isQualified()) { - if (!export.targets().contains(descriptor1.name())) - continue; + String name2 = descriptor2.name(); + if (descriptor2 != descriptor1 && !names.add(name2)) { + if (name2.equals(name1)) { + resolveFail("Module %s reads another module named %s", + name1, name1); + } else{ + resolveFail("Module %s reads more than one module named %s", + name1, name2); } + } - // source is exported to descriptor2 - String source = export.source(); - ModuleDescriptor other - = packageToExporter.putIfAbsent(source, descriptor2); + if (descriptor2.isAutomatic()) { + // automatic modules read self and export all packages + if (descriptor2 != descriptor1) { + for (String source : descriptor2.packages()) { + ModuleDescriptor supplier + = packageToExporter.putIfAbsent(source, descriptor2); - if (other != null && other != descriptor2) { - // package might be local to descriptor1 - if (other == descriptor1) { - fail("Module %s contains package %s" - + ", module %s exports package %s to %s", - descriptor1.name(), - source, - descriptor2.name(), - source, - descriptor1.name()); - } else { - fail("Modules %s and %s export package %s to module %s", - descriptor2.name(), - other.name(), - source, - descriptor1.name()); + // descriptor2 and 'supplier' export source to descriptor1 + if (supplier != null) { + failTwoSuppliers(descriptor1, source, descriptor2, supplier); + } } } + } else { + for (ModuleDescriptor.Exports export : descriptor2.exports()) { + if (export.isQualified()) { + if (!export.targets().contains(descriptor1.name())) + continue; + } + + // source is exported by descriptor2 + String source = export.source(); + ModuleDescriptor supplier + = packageToExporter.putIfAbsent(source, descriptor2); + + // descriptor2 and 'supplier' export source to descriptor1 + if (supplier != null) { + failTwoSuppliers(descriptor1, source, descriptor2, supplier); + } + } + } } @@ -735,8 +760,8 @@ final class Resolver { for (String service : descriptor1.uses()) { String pn = packageName(service); if (!packageToExporter.containsKey(pn)) { - fail("Module %s does not read a module that exports %s", - descriptor1.name(), pn); + resolveFail("Module %s does not read a module that exports %s", + descriptor1.name(), pn); } } @@ -744,15 +769,8 @@ final class Resolver { for (ModuleDescriptor.Provides provides : descriptor1.provides()) { String pn = packageName(provides.service()); if (!packageToExporter.containsKey(pn)) { - fail("Module %s does not read a module that exports %s", - descriptor1.name(), pn); - } - - for (String provider : provides.providers()) { - if (!packages.contains(packageName(provider))) { - fail("Provider %s not in module %s", - provider, descriptor1.name()); - } + resolveFail("Module %s does not read a module that exports %s", + descriptor1.name(), pn); } } @@ -762,6 +780,42 @@ final class Resolver { } + /** + * Fail because a module in the configuration exports the same package to + * a module that reads both. This includes the case where a module M + * containing a package p reads another module that exports p to at least + * module M. + */ + private void failTwoSuppliers(ModuleDescriptor descriptor, + String source, + ModuleDescriptor supplier1, + ModuleDescriptor supplier2) { + + if (supplier2 == descriptor) { + ModuleDescriptor tmp = supplier1; + supplier1 = supplier2; + supplier2 = tmp; + } + + if (supplier1 == descriptor) { + resolveFail("Module %s contains package %s" + + ", module %s exports package %s to %s", + descriptor.name(), + source, + supplier2.name(), + source, + descriptor.name()); + } else { + resolveFail("Modules %s and %s export package %s to module %s", + supplier1.name(), + supplier2.name(), + source, + descriptor.name()); + } + + } + + /** * Find a module of the given name in the parent configurations */ @@ -779,24 +833,16 @@ final class Resolver { * Invokes the beforeFinder to find method to find the given module. */ private ModuleReference findWithBeforeFinder(String mn) { - try { - return beforeFinder.find(mn).orElse(null); - } catch (FindException e) { - // unwrap - throw new ResolutionException(e.getMessage(), e.getCause()); - } + + return beforeFinder.find(mn).orElse(null); + } /** * Invokes the afterFinder to find method to find the given module. */ private ModuleReference findWithAfterFinder(String mn) { - try { - return afterFinder.find(mn).orElse(null); - } catch (FindException e) { - // unwrap - throw new ResolutionException(e.getMessage(), e.getCause()); - } + return afterFinder.find(mn).orElse(null); } /** @@ -804,34 +850,27 @@ final class Resolver { * and after ModuleFinders. */ private Set findAll() { - try { + Set beforeModules = beforeFinder.findAll(); + Set afterModules = afterFinder.findAll(); - Set beforeModules = beforeFinder.findAll(); - Set afterModules = afterFinder.findAll(); + if (afterModules.isEmpty()) + return beforeModules; - if (afterModules.isEmpty()) - return beforeModules; + if (beforeModules.isEmpty() + && parents.size() == 1 + && parents.get(0) == Configuration.empty()) + return afterModules; - if (beforeModules.isEmpty() - && parents.size() == 1 - && parents.get(0) == Configuration.empty()) - return afterModules; - - Set result = new HashSet<>(beforeModules); - for (ModuleReference mref : afterModules) { - String name = mref.descriptor().name(); - if (!beforeFinder.find(name).isPresent() - && findInParent(name) == null) { - result.add(mref); - } + Set result = new HashSet<>(beforeModules); + for (ModuleReference mref : afterModules) { + String name = mref.descriptor().name(); + if (!beforeFinder.find(name).isPresent() + && findInParent(name) == null) { + result.add(mref); } - - return result; - - } catch (FindException e) { - // unwrap - throw new ResolutionException(e.getMessage(), e.getCause()); } + + return result; } /** @@ -842,10 +881,18 @@ final class Resolver { return (index == -1) ? "" : cn.substring(0, index); } + /** + * Throw FindException with the given format string and arguments + */ + private static void findFail(String fmt, Object ... args) { + String msg = String.format(fmt, args); + throw new FindException(msg); + } + /** * Throw ResolutionException with the given format string and arguments */ - private static void fail(String fmt, Object ... args) { + private static void resolveFail(String fmt, Object ... args) { String msg = String.format(fmt, args); throw new ResolutionException(msg); } @@ -860,9 +907,17 @@ final class Resolver { private void trace(String fmt, Object ... args) { if (traceOutput != null) { - traceOutput.format("[Resolver] " + fmt, args); + traceOutput.format(fmt, args); traceOutput.println(); } } + private String nameAndInfo(ModuleReference mref) { + ModuleDescriptor descriptor = mref.descriptor(); + StringBuilder sb = new StringBuilder(descriptor.name()); + mref.location().ifPresent(uri -> sb.append(" " + uri)); + if (descriptor.isAutomatic()) + sb.append(" automatic"); + return sb.toString(); + } } diff --git a/jdk/src/java.base/share/classes/java/lang/module/package-info.java b/jdk/src/java.base/share/classes/java/lang/module/package-info.java index f641638cb2c..b531f13748c 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/package-info.java +++ b/jdk/src/java.base/share/classes/java/lang/module/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -27,6 +27,112 @@ * Classes to support module descriptors and creating configurations of modules * by means of resolution and service binding. * + *

        Resolution

        + * + *

        Resolution is the process of computing the transitive closure of a set + * of root modules over a set of observable modules by resolving the + * dependences expressed by {@link + * java.lang.module.ModuleDescriptor.Requires requires} clauses. + * The dependence graph is augmented with edges that take account of + * implicitly declared dependences ({@code requires transitive}) to create a + * readability graph. The result of resolution is a {@link + * java.lang.module.Configuration Configuration} that encapsulates the + * readability graph.

        + * + *

        As an example, suppose we have the following observable modules:

        + *
         {@code
        + *     module m1 { requires m2; }
        + *     module m2 { requires transitive m3; }
        + *     module m3 { }
        + *     module m4 { }
        + * } 
        + * + *

        If the module {@code m1} is resolved then the resulting configuration + * contains three modules ({@code m1}, {@code m2}, {@code m3}). The edges in + * its readability graph are:

        + *
         {@code
        + *     m1 --> m2  (meaning m1 reads m2)
        + *     m1 --> m3
        + *     m2 --> m3
        + * } 
        + * + *

        Resolution is an additive process. When computing the transitive closure + * then the dependence relation may include dependences on modules in {@link + * java.lang.module.Configuration#parents() parent} configurations. The result + * is a relative configuration that is relative to one or more parent + * configurations and where the readability graph may have edges from modules + * in the configuration to modules in parent configurations.

        + * + *

        As an example, suppose we have the following observable modules:

        + *
         {@code
        + *     module m1 { requires m2; requires java.xml; }
        + *     module m2 { }
        + * } 
        + * + *

        If module {@code m1} is resolved with the configuration for the {@link + * java.lang.ModuleLayer#boot() boot} layer as the parent then the resulting + * configuration contains two modules ({@code m1}, {@code m2}). The edges in + * its readability graph are: + *

         {@code
        + *     m1 --> m2
        + *     m1 --> java.xml
        + * } 
        + * where module {@code java.xml} is in the parent configuration. For + * simplicity, this example omits the implicitly declared dependence on the + * {@code java.base} module. + * + *

        Requires clauses that are "{@code requires static}" express an optional + * dependence (except at compile-time). If a module declares that it + * "{@code requires static M}" then resolution does not search the observable + * modules for "{@code M}". However, if "{@code M}" is resolved (because resolution + * resolves a module that requires "{@code M}" without the {@link + * java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC static} modifier) + * then the readability graph will contain read edges for each module that + * "{@code requires static M}".

        + * + *

        {@link java.lang.module.ModuleDescriptor#isAutomatic() Automatic} modules + * receive special treatment during resolution. Each automatic module is resolved + * as if it "{@code requires transitive}" all observable automatic modules and + * all automatic modules in the parent configurations. Each automatic module is + * resolved so that it reads all other modules in the resulting configuration and + * all modules in parent configurations.

        + * + *

        Service binding

        + * + *

        Service binding is the process of augmenting a graph of resolved modules + * from the set of observable modules induced by the service-use dependence + * ({@code uses} and {@code provides} clauses). Any module that was not + * previously in the graph requires resolution to compute its transitive + * closure. Service binding is an iterative process in that adding a module + * that satisfies some service-use dependence may introduce new service-use + * dependences.

        + * + *

        Suppose we have the following observable modules:

        + *
         {@code
        + *     module m1 { exports p; uses p.S; }
        + *     module m2 { requires m1; provides p.S with p2.S2; }
        + *     module m3 { requires m1; requires m4; provides p.S with p3.S3; }
        + *     module m4 { }
        + * } 
        + * + *

        If the module {@code m1} is resolved then the resulting graph of modules + * has one module ({@code m1}). If the graph is augmented with modules induced + * by the service-use dependence relation then the configuration will contain + * four modules ({@code m1}, {@code m2}, {@code m3}, {@code m4}). The edges in + * its readability graph are:

        + *
         {@code
        + *     m2 --> m1
        + *     m3 --> m1
        + *     m3 --> m4
        + * } 
        + *

        The edges in the conceptual service-use graph are:

        + *
         {@code
        + *     m1 --> m2  (meaning m1 uses a service that is provided by m2)
        + *     m1 --> m3
        + * } 
        + * + *

        General Exceptions

        + * *

        Unless otherwise noted, passing a {@code null} argument to a constructor * or method of any class or interface in this package will cause a {@link * java.lang.NullPointerException NullPointerException} to be thrown. Additionally, @@ -34,6 +140,7 @@ * will cause a {@code NullPointerException}, unless otherwise specified.

        * * @since 9 + * @spec JPMS */ package java.lang.module; diff --git a/jdk/src/java.base/share/classes/java/lang/ref/Cleaner.java b/jdk/src/java.base/share/classes/java/lang/ref/Cleaner.java index 63bd43c53c1..04e2101e2cc 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/Cleaner.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/Cleaner.java @@ -119,7 +119,7 @@ import java.util.function.Function; * Using a static nested class, as above, will avoid accidentally retaining the * object reference. *

        - * + * * Cleaning actions should be prepared to be invoked concurrently with * other cleaning actions. * Typically the cleaning actions should be very quick to execute diff --git a/jdk/src/java.base/share/classes/java/lang/ref/FinalReference.java b/jdk/src/java.base/share/classes/java/lang/ref/FinalReference.java index d7637943726..bb97d6947a5 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/FinalReference.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/FinalReference.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 @@ -33,4 +33,9 @@ class FinalReference extends Reference { public FinalReference(T referent, ReferenceQueue q) { super(referent, q); } + + @Override + public boolean enqueue() { + throw new InternalError("should never reach here"); + } } diff --git a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java index cd4bd8065bc..5125e7cb553 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java @@ -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 @@ -140,15 +140,26 @@ public abstract class Reference { } } - /* Atomically get and clear (set to null) the VM's pending list. + /* + * system property to disable clearing before enqueuing. + */ + private static final class ClearBeforeEnqueue { + static final boolean DISABLE = + Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue"); + } + + /* + * Atomically get and clear (set to null) the VM's pending list. */ private static native Reference getAndClearReferencePendingList(); - /* Test whether the VM's pending list contains any entries. + /* + * Test whether the VM's pending list contains any entries. */ private static native boolean hasReferencePendingList(); - /* Wait until the VM's pending list may be non-null. + /* + * Wait until the VM's pending list may be non-null. */ private static native void waitForReferencePendingList(); @@ -261,7 +272,6 @@ public abstract class Reference { this.referent = null; } - /* -- Queue operations -- */ /** @@ -278,8 +288,8 @@ public abstract class Reference { } /** - * Adds this reference object to the queue with which it is registered, - * if any. + * Clears this reference object and adds it to the queue with which + * it is registered, if any. * *

        This method is invoked only by Java code; when the garbage collector * enqueues references it does so directly, without invoking this method. @@ -289,10 +299,11 @@ public abstract class Reference { * it was not registered with a queue when it was created */ public boolean enqueue() { + if (!ClearBeforeEnqueue.DISABLE) + this.referent = null; return this.queue.enqueue(this); } - /* -- Constructors -- */ Reference(T referent) { @@ -419,5 +430,4 @@ public abstract class Reference { // HotSpot needs to retain the ref and not GC it before a call to this // method } - } diff --git a/jdk/src/java.base/share/classes/java/lang/ref/package-info.java b/jdk/src/java.base/share/classes/java/lang/ref/package-info.java index 58600cba1b8..3f37878650c 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/package-info.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/package-info.java @@ -93,7 +93,7 @@ * structure, this check will add little overhead to the hashtable * access methods. * - * + * *

        Reachability

        * * Going from strongest to weakest, the different levels of diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java index f585b476504..35c689d56cc 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.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 @@ -29,37 +29,46 @@ import java.lang.annotation.Annotation; import java.security.AccessController; import jdk.internal.misc.VM; +import jdk.internal.module.IllegalAccessLogger; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; import jdk.internal.reflect.ReflectionFactory; import sun.security.action.GetPropertyAction; /** - * The AccessibleObject class is the base class for Field, Method and - * Constructor objects. It provides the ability to flag a reflected - * object as suppressing default Java language access control checks - * when it is used. The access checks -- module boundaries, - * public, default (package) access, protected, and private members -- - * are performed when Fields, Methods or Constructors are used to set - * or get fields, to invoke methods or to create and initialize new - * instances of classes, respectively. Unlike access control specified - * in the The Java™ Language Specification and - * The Java Virtual Machine Specification, access checks - * with reflected objects assume {@link Module#canRead readability}. + * The {@code AccessibleObject} class is the base class for {@code Field}, + * {@code Method}, and {@code Constructor} objects (known as reflected + * objects). It provides the ability to flag a reflected object as + * suppressing checks for Java language access control when it is used. This + * permits sophisticated applications with sufficient privilege, such as Java + * Object Serialization or other persistence mechanisms, to manipulate objects + * in a manner that would normally be prohibited. * - *

        Setting the {@code accessible} flag in a reflected object - * permits sophisticated applications with sufficient privilege, such - * as Java Object Serialization or other persistence mechanisms, to - * manipulate objects in a manner that would normally be prohibited. + *

        Java language access control prevents use of private members outside + * their class; package access members outside their package; protected members + * outside their package or subclasses; and public members outside their + * module unless they are declared in an {@link Module#isExported(String,Module) + * exported} package and the user {@link Module#canRead reads} their module. By + * default, Java language access control is enforced (with one variation) when + * {@code Field}s, {@code Method}s, or {@code Constructor}s are used to get or + * set fields, to invoke methods, or to create and initialize new instances of + * classes, respectively. Every reflected object checks that the code using it + * is in an appropriate class, package, or module.

        * - *

        By default, a reflected object is not accessible. + *

        The one variation from Java language access control is that the checks + * by reflected objects assume readability. That is, the module containing + * the use of a reflected object is assumed to read the module in which + * the underlying field, method, or constructor is declared.

        * - * @see Field - * @see Method - * @see Constructor - * @see ReflectPermission + *

        Whether the checks for Java language access control can be suppressed + * (and thus, whether access can be enabled) depends on whether the reflected + * object corresponds to a member in an exported or open package + * (see {@link #setAccessible(boolean)}).

        * + * @jls 6.6 Access Control * @since 1.2 + * @revised 9 + * @spec JPMS */ public class AccessibleObject implements AnnotatedElement { @@ -78,15 +87,11 @@ public class AccessibleObject implements AnnotatedElement { /** * Convenience method to set the {@code accessible} flag for an - * array of objects with a single security check (for efficiency). + * array of reflected objects with a single security check (for efficiency). * - *

        This method cannot be used to enable access to an object that is a - * {@link Member member} of a class in a different module to the caller and - * where the class is in a package that is not exported to the caller's - * module. Additionally, if the member is non-public or its declaring - * class is non-public, then this method can only be used to enable access - * if the package is {@link Module#isOpen(String,Module) open} to at least - * the caller's module. + *

        This method may be used to enable access to all reflected objects in + * the array when access to each reflected object can be enabled as + * specified by {@link #setAccessible(boolean) setAccessible(boolean)}.

        * *

        If there is a security manager, its * {@code checkPermission} method is first called with a @@ -99,10 +104,15 @@ public class AccessibleObject implements AnnotatedElement { * @param array the array of AccessibleObjects * @param flag the new value for the {@code accessible} flag * in each object - * @throws InaccessibleObjectException if access cannot be enabled - * @throws SecurityException if the request is denied. + * @throws InaccessibleObjectException if access cannot be enabled for all + * objects in the array + * @throws SecurityException if the request is denied by the security manager + * or an element in the array is a constructor for {@code + * java.lang.Class} * @see SecurityManager#checkPermission * @see ReflectPermission + * @revised 9 + * @spec JPMS */ @CallerSensitive public static void setAccessible(AccessibleObject[] array, boolean flag) { @@ -120,41 +130,143 @@ public class AccessibleObject implements AnnotatedElement { } /** - * Set the {@code accessible} flag for this object to + * Set the {@code accessible} flag for this reflected object to * the indicated boolean value. A value of {@code true} indicates that - * the reflected object should suppress Java language access - * checking when it is used. A value of {@code false} indicates - * that the reflected object should enforce Java language access checks - * while assuming readability (as noted in the class description). + * the reflected object should suppress checks for Java language access + * control when it is used. A value of {@code false} indicates that + * the reflected object should enforce checks for Java language access + * control when it is used, with the variation noted in the class description. * - *

        This method cannot be used to enable access to an object that is a - * {@link Member member} of a class in a different module to the caller and - * where the class is in a package that is not exported to the caller's - * module. Additionally, if the member is non-public or its declaring - * class is non-public, then this method can only be used to enable access - * if the package is {@link Module#isOpen(String,Module) open} to at least - * the caller's module. + *

        This method may be used by a caller in class {@code C} to enable + * access to a {@link Member member} of {@link Member#getDeclaringClass() + * declaring class} {@code D} if any of the following hold:

        * - *

        If there is a security manager, its + *

          + *
        • {@code C} and {@code D} are in the same module.
        • + * + *
        • The member is {@code public} and {@code D} is {@code public} in + * a package that the module containing {@code D} {@link + * Module#isExported(String,Module) exports} to at least the module + * containing {@code C}.
        • + * + *
        • The member is {@code protected} {@code static}, {@code D} is + * {@code public} in a package that the module containing {@code D} + * exports to at least the module containing {@code C}, and {@code C} + * is a subclass of {@code D}.
        • + * + *
        • {@code D} is in a package that the module containing {@code D} + * {@link Module#isOpen(String,Module) opens} to at least the module + * containing {@code C}. + * All packages in unnamed and open modules are open to all modules and + * so this method always succeeds when {@code D} is in an unnamed or + * open module.
        • + *
        + * + *

        This method cannot be used to enable access to private members, + * members with default (package) access, protected instance members, or + * protected constructors when the declaring class is in a different module + * to the caller and the package containing the declaring class is not open + * to the caller's module.

        + * + *

        If there is a security manager, its * {@code checkPermission} method is first called with a * {@code ReflectPermission("suppressAccessChecks")} permission. * * @param flag the new value for the {@code accessible} flag * @throws InaccessibleObjectException if access cannot be enabled - * @throws SecurityException if the request is denied - * @see SecurityManager#checkPermission - * @see ReflectPermission + * @throws SecurityException if the request is denied by the security manager + * @see #trySetAccessible * @see java.lang.invoke.MethodHandles#privateLookupIn + * @revised 9 + * @spec JPMS */ public void setAccessible(boolean flag) { AccessibleObject.checkPermission(); setAccessible0(flag); } - void setAccessible0(boolean flag) { + /** + * Sets the accessible flag and returns the new value + */ + boolean setAccessible0(boolean flag) { this.override = flag; + return flag; } + /** + * Set the {@code accessible} flag for this reflected object to {@code true} + * if possible. This method sets the {@code accessible} flag, as if by + * invoking {@link #setAccessible(boolean) setAccessible(true)}, and returns + * the possibly-updated value for the {@code accessible} flag. If access + * cannot be enabled, i.e. the checks or Java language access control cannot + * be suppressed, this method returns {@code false} (as opposed to {@code + * setAccessible(true)} throwing {@code InaccessibleObjectException} when + * it fails). + * + *

        This method is a no-op if the {@code accessible} flag for + * this reflected object is {@code true}. + * + *

        For example, a caller can invoke {@code trySetAccessible} + * on a {@code Method} object for a private instance method + * {@code p.T::privateMethod} to suppress the checks for Java language access + * control when the {@code Method} is invoked. + * If {@code p.T} class is in a different module to the caller and + * package {@code p} is open to at least the caller's module, + * the code below successfully sets the {@code accessible} flag + * to {@code true}. + * + *

        +     * {@code
        +     *     p.T obj = ....;  // instance of p.T
        +     *     :
        +     *     Method m = p.T.class.getDeclaredMethod("privateMethod");
        +     *     if (m.trySetAccessible()) {
        +     *         m.invoke(obj);
        +     *     } else {
        +     *         // package p is not opened to the caller to access private member of T
        +     *         ...
        +     *     }
        +     * }
        + * + *

        If there is a security manager, its {@code checkPermission} method + * is first called with a {@code ReflectPermission("suppressAccessChecks")} + * permission.

        + * + * @return {@code true} if the {@code accessible} flag is set to {@code true}; + * {@code false} if access cannot be enabled. + * @throws SecurityException if the request is denied by the security manager + * + * @since 9 + * @spec JPMS + * @see java.lang.invoke.MethodHandles#privateLookupIn + */ + @CallerSensitive + public final boolean trySetAccessible() { + AccessibleObject.checkPermission(); + + if (override == true) return true; + + // if it's not a Constructor, Method, Field then no access check + if (!Member.class.isInstance(this)) { + return setAccessible0(true); + } + + // does not allow to suppress access check for Class's constructor + Class declaringClass = ((Member) this).getDeclaringClass(); + if (declaringClass == Class.class && this instanceof Constructor) { + return false; + } + + if (checkCanSetAccessible(Reflection.getCallerClass(), + declaringClass, + false)) { + return setAccessible0(true); + } else { + return false; + } + } + + /** * If the given AccessibleObject is a {@code Constructor}, {@code Method} * or {@code Field} then checks that its declaring class is in a package @@ -164,106 +276,206 @@ public class AccessibleObject implements AnnotatedElement { // do nothing, needs to be overridden by Constructor, Method, Field } + void checkCanSetAccessible(Class caller, Class declaringClass) { + checkCanSetAccessible(caller, declaringClass, true); + } + + private boolean checkCanSetAccessible(Class caller, + Class declaringClass, + boolean throwExceptionIfDenied) { Module callerModule = caller.getModule(); Module declaringModule = declaringClass.getModule(); - if (callerModule == declaringModule) return; - if (callerModule == Object.class.getModule()) return; - if (!declaringModule.isNamed()) return; + if (callerModule == declaringModule) return true; + if (callerModule == Object.class.getModule()) return true; + if (!declaringModule.isNamed()) return true; - // package is open to caller - String pn = packageName(declaringClass); - if (declaringModule.isOpen(pn, callerModule)) { - printStackTraceIfOpenedReflectively(declaringModule, pn, callerModule); - return; - } - - // package is exported to caller and class/member is public - boolean isExported = declaringModule.isExported(pn, callerModule); - boolean isClassPublic = Modifier.isPublic(declaringClass.getModifiers()); + String pn = declaringClass.getPackageName(); int modifiers; if (this instanceof Executable) { modifiers = ((Executable) this).getModifiers(); } else { modifiers = ((Field) this).getModifiers(); } - boolean isMemberPublic = Modifier.isPublic(modifiers); - if (isExported && isClassPublic && isMemberPublic) { - printStackTraceIfExportedReflectively(declaringModule, pn, callerModule); - return; + + // class is public and package is exported to caller + boolean isClassPublic = Modifier.isPublic(declaringClass.getModifiers()); + if (isClassPublic && declaringModule.isExported(pn, callerModule)) { + // member is public + if (Modifier.isPublic(modifiers)) { + logIfExportedByBackdoor(caller, declaringClass); + return true; + } + + // member is protected-static + if (Modifier.isProtected(modifiers) + && Modifier.isStatic(modifiers) + && isSubclassOf(caller, declaringClass)) { + logIfExportedByBackdoor(caller, declaringClass); + return true; + } } - // not accessible - String msg = "Unable to make "; - if (this instanceof Field) - msg += "field "; - msg += this + " accessible: " + declaringModule + " does not \""; - if (isClassPublic && isMemberPublic) - msg += "exports"; - else - msg += "opens"; - msg += " " + pn + "\" to " + callerModule; - InaccessibleObjectException e = new InaccessibleObjectException(msg); - if (Reflection.printStackTraceWhenAccessFails()) { - e.printStackTrace(System.err); + // package is open to caller + if (declaringModule.isOpen(pn, callerModule)) { + logIfOpenedByBackdoor(caller, declaringClass); + return true; } - throw e; - } - private void printStackTraceIfOpenedReflectively(Module module, - String pn, - Module other) { - printStackTraceIfExposedReflectively(module, pn, other, true); - } - - private void printStackTraceIfExportedReflectively(Module module, - String pn, - Module other) { - printStackTraceIfExposedReflectively(module, pn, other, false); - } - - private void printStackTraceIfExposedReflectively(Module module, - String pn, - Module other, - boolean open) - { - if (Reflection.printStackTraceWhenAccessSucceeds() - && !module.isStaticallyExportedOrOpen(pn, other, open)) - { - String msg = other + " allowed to invoke setAccessible on "; + if (throwExceptionIfDenied) { + // not accessible + String msg = "Unable to make "; if (this instanceof Field) msg += "field "; - msg += this; - new Exception(msg) { - private static final long serialVersionUID = 42L; - public String toString() { - return "WARNING: " + getMessage(); - } - }.printStackTrace(System.err); + msg += this + " accessible: " + declaringModule + " does not \""; + if (isClassPublic && Modifier.isPublic(modifiers)) + msg += "exports"; + else + msg += "opens"; + msg += " " + pn + "\" to " + callerModule; + InaccessibleObjectException e = new InaccessibleObjectException(msg); + if (printStackTraceWhenAccessFails()) { + e.printStackTrace(System.err); + } + throw e; + } + return false; + } + + private boolean isSubclassOf(Class queryClass, Class ofClass) { + while (queryClass != null) { + if (queryClass == ofClass) { + return true; + } + queryClass = queryClass.getSuperclass(); + } + return false; + } + + private void logIfOpenedByBackdoor(Class caller, Class declaringClass) { + Module callerModule = caller.getModule(); + Module targetModule = declaringClass.getModule(); + // callerModule is null during early startup + if (callerModule != null && !callerModule.isNamed() && targetModule.isNamed()) { + IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger(); + if (logger != null) { + logger.logIfOpenedByBackdoor(caller, declaringClass, this::toShortString); + } + } + } + + private void logIfExportedByBackdoor(Class caller, Class declaringClass) { + Module callerModule = caller.getModule(); + Module targetModule = declaringClass.getModule(); + // callerModule is null during early startup + if (callerModule != null && !callerModule.isNamed() && targetModule.isNamed()) { + IllegalAccessLogger logger = IllegalAccessLogger.illegalAccessLogger(); + if (logger != null) { + logger.logIfExportedByBackdoor(caller, declaringClass, this::toShortString); + } } } /** - * Returns the package name of the given class. + * Returns a short descriptive string to describe this object in log messages. */ - private static String packageName(Class c) { - while (c.isArray()) { - c = c.getComponentType(); - } - String pn = c.getPackageName(); - return (pn != null) ? pn : ""; + String toShortString() { + return toString(); } /** - * Get the value of the {@code accessible} flag for this object. + * Get the value of the {@code accessible} flag for this reflected object. * * @return the value of the object's {@code accessible} flag + * + * @deprecated + * This method is deprecated because its name hints that it checks + * if the reflected object is accessible when it actually indicates + * if the checks for Java language access control are suppressed. + * This method may return {@code false} on a reflected object that is + * accessible to the caller. To test if this reflected object is accessible, + * it should use {@link #canAccess(Object)}. + * + * @revised 9 + * @spec JPMS */ + @Deprecated(since="9") public boolean isAccessible() { return override; } + /** + * Test if the caller can access this reflected object. If this reflected + * object corresponds to an instance method or field then this method tests + * if the caller can access the given {@code obj} with the reflected object. + * For instance methods or fields then the {@code obj} argument must be an + * instance of the {@link Member#getDeclaringClass() declaring class}. For + * static members and constructors then {@code obj} must be {@code null}. + * + *

        This method returns {@code true} if the {@code accessible} flag + * is set to {@code true}, i.e. the checks for Java language access control + * are suppressed, or if the caller can access the member as + * specified in The Java™ Language Specification, + * with the variation noted in the class description.

        + * + * @param obj an instance object of the declaring class of this reflected + * object if it is an instance method or field + * + * @return {@code true} if the caller can access this reflected object. + * + * @throws IllegalArgumentException + *
          + *
        • if this reflected object is a static member or constructor and + * the given {@code obj} is non-{@code null}, or
        • + *
        • if this reflected object is an instance method or field + * and the given {@code obj} is {@code null} or of type + * that is not a subclass of the {@link Member#getDeclaringClass() + * declaring class} of the member.
        • + *
        + * + * @since 9 + * @spec JPMS + * @jls 6.6 Access Control + * @see #trySetAccessible + * @see #setAccessible(boolean) + */ + @CallerSensitive + public final boolean canAccess(Object obj) { + if (!Member.class.isInstance(this)) { + return override; + } + + Class declaringClass = ((Member) this).getDeclaringClass(); + int modifiers = ((Member) this).getModifiers(); + if (!Modifier.isStatic(modifiers) && + (this instanceof Method || this instanceof Field)) { + if (obj == null) { + throw new IllegalArgumentException("null object for " + this); + } + // if this object is an instance member, the given object + // must be a subclass of the declaring class of this reflected object + if (!declaringClass.isAssignableFrom(obj.getClass())) { + throw new IllegalArgumentException("object is not an instance of " + + declaringClass.getName()); + } + } else if (obj != null) { + throw new IllegalArgumentException("non-null object for " + this); + } + + // access check is suppressed + if (override) return true; + + Class caller = Reflection.getCallerClass(); + Class targetClass; + if (this instanceof Constructor) { + targetClass = declaringClass; + } else { + targetClass = Modifier.isStatic(modifiers) ? null : obj.getClass(); + } + return verifyAccess(caller, declaringClass, targetClass, modifiers); + } + /** * Constructor: only used by the Java Virtual Machine. */ @@ -302,7 +514,7 @@ public class AccessibleObject implements AnnotatedElement { return AnnotatedElement.super.isAnnotationPresent(annotationClass); } - /** + /** * @throws NullPointerException {@inheritDoc} * @since 1.8 */ @@ -372,9 +584,22 @@ public class AccessibleObject implements AnnotatedElement { final void checkAccess(Class caller, Class memberClass, Class targetClass, int modifiers) throws IllegalAccessException + { + if (!verifyAccess(caller, memberClass, targetClass, modifiers)) { + IllegalAccessException e = Reflection.newIllegalAccessException( + caller, memberClass, targetClass, modifiers); + if (printStackTraceWhenAccessFails()) { + e.printStackTrace(System.err); + } + throw e; + } + } + + final boolean verifyAccess(Class caller, Class memberClass, + Class targetClass, int modifiers) { if (caller == memberClass) { // quick check - return; // ACCESS IS OK + return true; // ACCESS IS OK } Object cache = securityCheckCache; // read volatile if (targetClass != null // instance member or constructor @@ -385,26 +610,31 @@ public class AccessibleObject implements AnnotatedElement { Class[] cache2 = (Class[]) cache; if (cache2[1] == targetClass && cache2[0] == caller) { - return; // ACCESS IS OK + return true; // ACCESS IS OK } // (Test cache[1] first since range check for [1] // subsumes range check for [0].) } } else if (cache == caller) { // Non-protected case (or targetClass == memberClass or static member). - return; // ACCESS IS OK + return true; // ACCESS IS OK } // If no return, fall through to the slow path. - slowCheckMemberAccess(caller, memberClass, targetClass, modifiers); + return slowVerifyAccess(caller, memberClass, targetClass, modifiers); } // Keep all this slow stuff out of line: - void slowCheckMemberAccess(Class caller, Class memberClass, - Class targetClass, int modifiers) - throws IllegalAccessException + private boolean slowVerifyAccess(Class caller, Class memberClass, + Class targetClass, int modifiers) { - Reflection.ensureMemberAccess(caller, memberClass, targetClass, modifiers); + if (!Reflection.verifyMemberAccess(caller, memberClass, targetClass, modifiers)) { + // access denied + return false; + } + + // access okay + logIfExportedByBackdoor(caller, memberClass); // Success: Update the cache. Object cache = (targetClass != null @@ -418,5 +648,27 @@ public class AccessibleObject implements AnnotatedElement { // guarantees that the initializing stores for the cache // elements will occur before the volatile write. securityCheckCache = cache; // write volatile + return true; + } + + // true to print a stack trace when access fails + private static volatile boolean printStackWhenAccessFails; + + // true if printStack* values are initialized + private static volatile boolean printStackPropertiesSet; + + /** + * Returns true if a stack trace should be printed when access fails. + */ + private static boolean printStackTraceWhenAccessFails() { + if (!printStackPropertiesSet && VM.initLevel() >= 1) { + String s = GetPropertyAction.privilegedGetProperty( + "sun.reflect.debugModuleAccessChecks"); + if (s != null) { + printStackWhenAccessFails = !s.equalsIgnoreCase("false"); + } + printStackPropertiesSet = true; + } + return printStackWhenAccessFails; } } diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java index 2f26c0b1bdc..fd15669931b 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.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 @@ -105,28 +105,32 @@ import sun.reflect.annotation.AnnotationType; *

        The table below summarizes which kind of annotation presence * different methods in this interface examine. * - * + *
        * + * * * - * + * + * * - * * - * * - * * - * * - * * + * *
        Overview of kind of presence detected by different AnnotatedElement methods
        Kind of Presence
        MethodDirectly PresentIndirectly PresentPresentAssociated
        {@code T}{@link #getAnnotation(Class) getAnnotation(Class<T>)} + *
        {@code T}{@link #getAnnotation(Class) getAnnotation(Class<T>)} * X
        {@code Annotation[]}{@link #getAnnotations getAnnotations()} + *
        {@code Annotation[]}{@link #getAnnotations getAnnotations()} * X
        {@code T[]}{@link #getAnnotationsByType(Class) getAnnotationsByType(Class<T>)} + *
        {@code T[]}{@link #getAnnotationsByType(Class) getAnnotationsByType(Class<T>)} * X
        {@code T}{@link #getDeclaredAnnotation(Class) getDeclaredAnnotation(Class<T>)} + *
        {@code T}{@link #getDeclaredAnnotation(Class) getDeclaredAnnotation(Class<T>)} * X
        {@code Annotation[]}{@link #getDeclaredAnnotations getDeclaredAnnotations()} + *
        {@code Annotation[]}{@link #getDeclaredAnnotations getDeclaredAnnotations()} * X
        {@code T[]}{@link #getDeclaredAnnotationsByType(Class) getDeclaredAnnotationsByType(Class<T>)} + *
        {@code T[]}{@link #getDeclaredAnnotationsByType(Class) getDeclaredAnnotationsByType(Class<T>)} * XX
        * *

        For an invocation of {@code get[Declared]AnnotationsByType( Class < diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java index f64e84f7f37..ecc3fd1f462 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java @@ -38,6 +38,7 @@ import sun.reflect.generics.factory.GenericsFactory; import sun.reflect.generics.scope.ConstructorScope; import java.lang.annotation.Annotation; import java.lang.annotation.AnnotationFormatError; +import java.util.StringJoiner; /** * {@code Constructor} provides information about, and access to, a single @@ -168,6 +169,12 @@ public final class Constructor extends Executable { * is true.

        * * @param flag {@inheritDoc} + * + * @throws InaccessibleObjectException {@inheritDoc} + * @throws SecurityException if the request is denied by the security manager + * or this is a constructor for {@code java.lang.Class} + * + * @spec JPMS */ @Override @CallerSensitive @@ -353,6 +360,20 @@ public final class Constructor extends Executable { sb.append(getDeclaringClass().getTypeName()); } + @Override + String toShortString() { + StringBuilder sb = new StringBuilder("constructor "); + sb.append(getDeclaringClass().getTypeName()); + sb.append('('); + StringJoiner sj = new StringJoiner(","); + for (Class parameterType : getParameterTypes()) { + sj.add(parameterType.getTypeName()); + } + sb.append(sj); + sb.append(')'); + return sb.toString(); + } + /** * Returns a string describing this {@code Constructor}, * including type parameters. The string is formatted as the diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Field.java b/jdk/src/java.base/share/classes/java/lang/reflect/Field.java index 05b71785ffa..1f1192f6a5b 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/Field.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Field.java @@ -158,6 +158,10 @@ class Field extends AccessibleObject implements Member { return res; } + /** + * @throws InaccessibleObjectException {@inheritDoc} + * @throws SecurityException {@inheritDoc} + */ @Override @CallerSensitive public void setAccessible(boolean flag) { @@ -320,6 +324,11 @@ class Field extends AccessibleObject implements Member { + getName()); } + @Override + String toShortString() { + return "field " + getDeclaringClass().getTypeName() + "." + getName(); + } + /** * Returns a string describing this {@code Field}, including * its generic type. The format is the access modifiers for the diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java b/jdk/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java index 34db5150f85..b03d449fecc 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java @@ -30,6 +30,7 @@ package java.lang.reflect; * * @see AccessibleObject#setAccessible(boolean) * @since 9 + * @spec JPMS */ public class InaccessibleObjectException extends RuntimeException { diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Method.java b/jdk/src/java.base/share/classes/java/lang/reflect/Method.java index 027a711d3e1..b915b5524ae 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/Method.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Method.java @@ -42,6 +42,7 @@ import sun.reflect.annotation.AnnotationParser; import java.lang.annotation.Annotation; import java.lang.annotation.AnnotationFormatError; import java.nio.ByteBuffer; +import java.util.StringJoiner; /** * A {@code Method} provides information about, and access to, a single method @@ -179,6 +180,10 @@ public final class Method extends Executable { return res; } + /** + * @throws InaccessibleObjectException {@inheritDoc} + * @throws SecurityException {@inheritDoc} + */ @Override @CallerSensitive public void setAccessible(boolean flag) { @@ -412,6 +417,21 @@ public final class Method extends Executable { sb.append(getName()); } + @Override + String toShortString() { + StringBuilder sb = new StringBuilder("method "); + sb.append(getDeclaringClass().getTypeName()).append('.'); + sb.append(getName()); + sb.append('('); + StringJoiner sj = new StringJoiner(","); + for (Class parameterType : getParameterTypes()) { + sj.add(parameterType.getTypeName()); + } + sb.append(sj); + sb.append(')'); + return sb.toString(); + } + /** * Returns a string describing this {@code Method}, including * type parameters. The string is formatted as the method access diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java index 15d41a4101d..e2a950ed1c1 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.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 @@ -25,6 +25,7 @@ package java.lang.reflect; +import java.lang.module.ModuleDescriptor; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Arrays; @@ -52,6 +53,9 @@ import sun.reflect.misc.ReflectUtil; import sun.security.action.GetPropertyAction; import sun.security.util.SecurityConstants; +import static java.lang.module.ModuleDescriptor.Modifier.SYNTHETIC; + + /** * * {@code Proxy} provides static methods for creating objects that act like instances @@ -153,7 +157,7 @@ import sun.security.util.SecurityConstants; * like they do for instances of {@code java.lang.Object}. * * - *

        Package and Module Membership of Proxy Class

        + *

        Package and Module Membership of Proxy Class

        * * The package and module to which a proxy class belongs are chosen such that * the accessibility of the proxy class is in line with the accessibility of @@ -164,7 +168,8 @@ import sun.security.util.SecurityConstants; * methods is specified as follows: * *
          - *
        1. If all the proxy interfaces are in exported packages: + *
        2. If all the proxy interfaces are in exported or open + * packages: *
            *
          1. if all the proxy interfaces are public, then the proxy class is * public in a package exported by the @@ -178,10 +183,11 @@ import sun.security.util.SecurityConstants; * not possible.
          2. *
          *
        3. - *
        4. If at least one proxy interface is a non-exported package: + *
        5. If at least one proxy interface is in a package that is + * non-exported and non-open: *
            *
          1. if all the proxy interfaces are public, then the proxy class is - * public in a non-exported package of + * public in a non-exported, non-open package of * dynamic module. * The names of the package and the module are unspecified.
          2. * @@ -195,23 +201,24 @@ import sun.security.util.SecurityConstants; *
          * *

          - * Note that if proxy interfaces with a mix of accessibilities -- - * exported public, exported non-public, non-exported public, non-exported non-public -- - * are proxied by the same instance, then the proxy class's accessibility is + * Note that if proxy interfaces with a mix of accessibilities -- for example, + * an exported public interface and a non-exported non-public interface -- are + * proxied by the same instance, then the proxy class's accessibility is * governed by the least accessible proxy interface. *

          * Note that it is possible for arbitrary code to obtain access to a proxy class - * in an exported package with {@link AccessibleObject#setAccessible setAccessible}, - * whereas a proxy class in a non-exported package is never accessible to + * in an open package with {@link AccessibleObject#setAccessible setAccessible}, + * whereas a proxy class in a non-open package is never accessible to * code outside the module of the proxy class. * *

          - * Throughout this specification, 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. + * Throughout this specification, a "non-exported package" refers to a package + * that is not exported to all modules, and a "non-open package" refers to + * a package that is not open to all modules. Specifically, these terms refer to + * a package that either is not exported/open by its containing module or is + * exported/open in a qualified fashion by its containing module. * - *

          Dynamic Modules

          + *

          Dynamic Modules

          *

          * A dynamic module is a named module generated at runtime. A proxy class * defined in a dynamic module is encapsulated and not accessible to any module. @@ -220,11 +227,11 @@ import sun.security.util.SecurityConstants; * {@code Proxy.newProxyInstance} method should be used instead. * *

          - * A dynamic module can read the modules of all of the superinterfaces of a proxy class - * and the modules of the types referenced by all public method signatures + * A dynamic module can read the modules of all of the superinterfaces of a proxy + * class and the modules of the types referenced by all public method signatures * of a proxy class. If a superinterface or a referenced type, say {@code T}, - * is in a non-exported package, the {@linkplain java.lang.reflect.Module module} - * of {@code T} is updated to export the package of {@code T} to the dynamic module. + * is in a non-exported package, the {@linkplain Module module} of {@code T} is + * updated to export the package of {@code T} to the dynamic module. * *

          Methods Duplicated in Multiple Proxy Interfaces

          * @@ -272,6 +279,8 @@ import sun.security.util.SecurityConstants; * @author Peter Jones * @see InvocationHandler * @since 1.3 + * @revised 9 + * @spec JPMS */ public class Proxy implements java.io.Serializable { private static final long serialVersionUID = -2222568056686623797L; @@ -350,14 +359,17 @@ public class Proxy implements java.io.Serializable { * @throws NullPointerException if the {@code interfaces} array * argument or any of its elements are {@code null} * - * @deprecated Proxy classes generated in a named module are encapsulated and not - * accessible to code outside its module. - * {@link Constructor#newInstance(Object...) Constructor.newInstance} will throw - * {@code IllegalAccessException} when it is called on an inaccessible proxy class. + * @deprecated Proxy classes generated in a named module are encapsulated + * and not accessible to code outside its module. + * {@link Constructor#newInstance(Object...) Constructor.newInstance} + * will throw {@code IllegalAccessException} when it is called on + * an inaccessible proxy class. * Use {@link #newProxyInstance(ClassLoader, Class[], InvocationHandler)} * to create a proxy instance instead. * * @see Package and Module Membership of Proxy Class + * @revised 9 + * @spec JPMS */ @Deprecated @CallerSensitive @@ -500,17 +512,19 @@ public class Proxy implements java.io.Serializable { "Unnamed package cannot be added to " + m); } - // add the package to the runtime module if not exists if (m.isNamed()) { - m.addPackage(proxyPkg); + if (!m.getDescriptor().packages().contains(proxyPkg)) { + throw new InternalError(proxyPkg + " not exist in " + m.getName()); + } } /* * Choose a name for the proxy class to generate. */ long num = nextUniqueNumber.getAndIncrement(); - String proxyName = proxyPkg.isEmpty() ? proxyClassNamePrefix + num - : proxyPkg + "." + proxyClassNamePrefix + num; + String proxyName = proxyPkg.isEmpty() + ? proxyClassNamePrefix + num + : proxyPkg + "." + proxyClassNamePrefix + num; ClassLoader loader = getLoader(m); trace(proxyName, m, loader, interfaces); @@ -570,9 +584,13 @@ public class Proxy implements java.io.Serializable { c.getModule().getName(), c.getName(), access, ld); } - static void trace(String cn, Module module, ClassLoader loader, List> interfaces) { + static void trace(String cn, + Module module, + ClassLoader loader, + List> interfaces) { if (isDebug()) { - System.out.format("PROXY: %s/%s defined by %s%n", module.getName(), cn, loader); + System.err.format("PROXY: %s/%s defined by %s%n", + module.getName(), cn, loader); } if (isDebug("debug")) { interfaces.stream() @@ -581,7 +599,7 @@ public class Proxy implements java.io.Serializable { } private static final String DEBUG = - GetPropertyAction.privilegedGetProperty("jdk.proxy.debug", ""); + GetPropertyAction.privilegedGetProperty("jdk.proxy.debug", ""); private static boolean isDebug() { return !DEBUG.isEmpty(); @@ -592,15 +610,16 @@ public class Proxy implements java.io.Serializable { // ProxyBuilder instance members start here.... - private final ClassLoader loader; private final List> interfaces; private final Module module; ProxyBuilder(ClassLoader loader, List> interfaces) { if (!VM.isModuleSystemInited()) { - throw new InternalError("Proxy is not supported until module system is fully initialized"); + throw new InternalError("Proxy is not supported until " + + "module system is fully initialized"); } if (interfaces.size() > 65535) { - throw new IllegalArgumentException("interface limit exceeded: " + interfaces.size()); + throw new IllegalArgumentException("interface limit exceeded: " + + interfaces.size()); } Set> refTypes = referencedTypes(loader, interfaces); @@ -608,7 +627,6 @@ public class Proxy implements java.io.Serializable { // IAE if violates any restrictions specified in newProxyInstance validateProxyInterfaces(loader, interfaces, refTypes); - this.loader = loader; this.interfaces = interfaces; this.module = mapToModule(loader, interfaces, refTypes); assert getLoader(module) == loader; @@ -648,8 +666,8 @@ public class Proxy implements java.io.Serializable { * Validate the given proxy interfaces and the given referenced types * are visible to the defining loader. * - * @throws IllegalArgumentException if it violates the restrictions specified - * in {@link Proxy#newProxyInstance} + * @throws IllegalArgumentException if it violates the restrictions + * specified in {@link Proxy#newProxyInstance} */ private static void validateProxyInterfaces(ClassLoader loader, List> interfaces, @@ -720,9 +738,9 @@ public class Proxy implements java.io.Serializable { * is in the same module of the package-private interface. * * If all proxy interfaces are public and at least one in a non-exported - * package, then the proxy class is in a dynamic module in a non-exported - * package. Reads edge and qualified exports are added for - * dynamic module to access. + * package, then the proxy class is in a dynamic module in a + * non-exported package. Reads edge and qualified exports are added + * for dynamic module to access. */ private static Module mapToModule(ClassLoader loader, List> interfaces, @@ -741,11 +759,12 @@ public class Proxy implements java.io.Serializable { } } - // all proxy interfaces are public and exported, the proxy class is in unnamed module - // Such proxy class is accessible to any unnamed module and named module that - // can read unnamed module + // all proxy interfaces are public and exported, the proxy class + // is in unnamed module. Such proxy class is accessible to + // any unnamed module and named module that can read unnamed module if (packagePrivateTypes.isEmpty() && modulePrivateTypes.isEmpty()) { - return loader != null ? loader.getUnnamedModule() : BootLoader.getUnnamedModule(); + return loader != null ? loader.getUnnamedModule() + : BootLoader.getUnnamedModule(); } if (packagePrivateTypes.size() > 0) { @@ -767,7 +786,8 @@ public class Proxy implements java.io.Serializable { Module target = null; for (Module m : packagePrivateTypes.values()) { if (getLoader(m) != loader) { - // the specified loader is not the same class loader of the non-public interface + // the specified loader is not the same class loader + // of the non-public interface throw new IllegalArgumentException( "non-public interface is not defined by the given loader"); } @@ -788,8 +808,9 @@ public class Proxy implements java.io.Serializable { return target; } - // all proxy interfaces are public and at least one in a non-exported package - // map to dynamic proxy module and add reads edge and qualified exports, if necessary + // All proxy interfaces are public and at least one in a non-exported + // package. So maps to a dynamic proxy module and add reads edge + // and qualified exports, if necessary Module target = getDynamicModule(loader); // set up proxy class access to proxy interfaces and types @@ -845,8 +866,8 @@ public class Proxy implements java.io.Serializable { private static final AtomicInteger counter = new AtomicInteger(); /* - * Define a dynamic module for the generated proxy classes in a non-exported package - * named com.sun.proxy.$MODULE. + * Define a dynamic module for the generated proxy classes in + * a non-exported package named com.sun.proxy.$MODULE. * * Each class loader will have one dynamic module. */ @@ -855,7 +876,11 @@ public class Proxy implements java.io.Serializable { // create a dynamic module and setup module access String mn = "jdk.proxy" + counter.incrementAndGet(); String pn = PROXY_PACKAGE_PREFIX + "." + mn; - Module m = Modules.defineModule(ld, mn, Collections.singleton(pn)); + ModuleDescriptor descriptor = + ModuleDescriptor.newModule(mn, Set.of(SYNTHETIC)) + .packages(Set.of(pn)) + .build(); + Module m = Modules.defineModule(ld, descriptor, null); Modules.addReads(m, Proxy.class.getModule()); // java.base to create proxy instance Modules.addExports(m, pn, Object.class.getModule()); @@ -869,7 +894,7 @@ public class Proxy implements java.io.Serializable { * that dispatches method invocations to the specified invocation * handler. *

          - * {@code IllegalArgumentException} will be thrown + * {@code IllegalArgumentException} will be thrown * if any of the following restrictions is violated: *

            *
          • All of {@code Class} objects in the given {@code interfaces} array @@ -955,6 +980,8 @@ public class Proxy implements java.io.Serializable { * {@code null} * * @see Package and Module Membership of Proxy Class + * @revised 9 + * @spec JPMS */ @CallerSensitive public static Object newProxyInstance(ClassLoader loader, @@ -1039,6 +1066,9 @@ public class Proxy implements java.io.Serializable { * @return {@code true} if the class is a proxy class and * {@code false} otherwise * @throws NullPointerException if {@code cl} is {@code null} + * + * @revised 9 + * @spec JPMS */ public static boolean isProxyClass(Class cl) { return Proxy.class.isAssignableFrom(cl) && ProxyBuilder.isProxyClass(cl); diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/ReflectPermission.java b/jdk/src/java.base/share/classes/java/lang/reflect/ReflectPermission.java index df6178358df..8b34ae3b4f2 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/ReflectPermission.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/ReflectPermission.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 @@ -32,12 +32,16 @@ package java.lang.reflect; * provides a summary description of what the permission allows, * and discusses the risks of granting code the permission. * - * + *
            + * + * * * * * * + * + * * * * @@ -58,6 +62,7 @@ package java.lang.reflect; * help in its attempt to compromise security in the system. * * + * *
            Table shows permission target name, what the permission allows, and associated risks
            Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
            suppressAccessChecks
            * * @see java.security.Permission diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java b/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java index c8cb0257b2a..e771f31cea1 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/package-info.java @@ -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 @@ -25,11 +25,10 @@ /** * Provides classes and interfaces for obtaining reflective information about - * modules, classes and objects. Reflection allows programmatic access to - * information about modules and to the fields, methods and constructors of - * loaded classes, and the use of reflected fields, methods, and constructors - * to operate on their underlying counterparts, within encapsulation and - * security restrictions. + * classes and objects. Reflection allows programmatic access to information + * about the fields, methods and constructors of loaded classes, and the use + * of reflected fields, methods, and constructors to operate on their underlying + * counterparts, within encapsulation and security restrictions. * *

            {@code AccessibleObject} allows suppression of access checks if * the necessary {@code ReflectPermission} is available. @@ -45,5 +44,7 @@ * members declared by a given class. * * @since 1.1 + * @revised 9 + * @spec JPMS */ package java.lang.reflect; diff --git a/jdk/src/java.base/share/classes/java/math/BigDecimal.java b/jdk/src/java.base/share/classes/java/math/BigDecimal.java index 5feb70fec43..f0b40ffed96 100644 --- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java +++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.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 @@ -120,15 +120,19 @@ import java.util.Arrays; * preferred scale for representing a result. The preferred * scale for each operation is listed in the table below. * - * + *
            * + * * + * + * * * * * * + * *
            Preferred Scales for Results of Arithmetic Operations *
            OperationPreferred Scale of Result
            Addmax(addend.scale(), augend.scale())
            Subtractmax(minuend.scale(), subtrahend.scale())
            Multiplymultiplier.scale() + multiplicand.scale()
            Dividedividend.scale() - divisor.scale()
            Square rootradicand.scale()/2
            * * These scales are the ones used by the methods which return exact diff --git a/jdk/src/java.base/share/classes/java/math/RoundingMode.java b/jdk/src/java.base/share/classes/java/math/RoundingMode.java index a4a1c1aa460..79ecce36e7f 100644 --- a/jdk/src/java.base/share/classes/java/math/RoundingMode.java +++ b/jdk/src/java.base/share/classes/java/math/RoundingMode.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 @@ -51,11 +51,12 @@ package java.math; * proper {@code MathContext}. A summary table showing the results * of these rounding operations for all rounding modes appears below. * - * + *
            * + * * - * + * * * * @@ -64,18 +65,21 @@ package java.math; * * * + * + * * - * - * - * - * - * - * - * - * - * - * - *
            Summary of Rounding Operations Under Different Rounding Modes
            Result of rounding input to one digit with the given * rounding mode
            Input Number {@code UP}{@code DOWN}{@code CEILING}{@code HALF_DOWN}{@code HALF_EVEN}{@code UNNECESSARY}
            5.5 6 5 6 5 6 5 6 throw {@code ArithmeticException}
            2.5 3 2 3 2 3 2 2 throw {@code ArithmeticException}
            1.6 2 1 2 1 2 2 2 throw {@code ArithmeticException}
            1.1 2 1 2 1 1 1 1 throw {@code ArithmeticException}
            1.0 1 1 1 1 1 1 1 1
            -1.0 -1 -1 -1 -1 -1 -1 -1 -1
            -1.1 -2 -1 -1 -2 -1 -1 -1 throw {@code ArithmeticException}
            -1.6 -2 -1 -1 -2 -2 -2 -2 throw {@code ArithmeticException}
            -2.5 -3 -2 -2 -3 -3 -2 -2 throw {@code ArithmeticException}
            -5.5 -6 -5 -5 -6 -6 -5 -6 throw {@code ArithmeticException}
            + *

  • 5.5 6 5 6 5 6 5 6 throw {@code ArithmeticException}
    2.5 3 2 3 2 3 2 2 throw {@code ArithmeticException}
    1.6 2 1 2 1 2 2 2 throw {@code ArithmeticException}
    1.1 2 1 2 1 1 1 1 throw {@code ArithmeticException}
    1.0 1 1 1 1 1 1 1 1
    -1.0 -1 -1 -1 -1 -1 -1 -1 -1
    -1.1 -2 -1 -1 -2 -1 -1 -1 throw {@code ArithmeticException}
    -1.6 -2 -1 -1 -2 -2 -2 -2 throw {@code ArithmeticException}
    -2.5 -3 -2 -2 -3 -3 -2 -2 throw {@code ArithmeticException}
    -5.5 -6 -5 -5 -6 -6 -5 -6 throw {@code ArithmeticException}
    * * *

    This {@code enum} is intended to replace the integer-based @@ -100,20 +104,24 @@ public enum RoundingMode { * value. * *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode UP Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code UP} rounding - *
    5.5 6
    2.5 3
    1.6 2
    1.1 2
    1.0 1
    -1.0 -1
    -1.1 -2
    -1.6 -2
    -2.5 -3
    -5.5 -6
    5.5 6
    2.5 3
    1.6 2
    1.1 2
    1.0 1
    -1.0 -1
    -1.1 -2
    -1.6 -2
    -2.5 -3
    -5.5 -6
    */ UP(BigDecimal.ROUND_UP), @@ -124,20 +132,24 @@ public enum RoundingMode { * rounding mode never increases the magnitude of the calculated value. * *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode DOWN Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code DOWN} rounding - *
    5.5 5
    2.5 2
    1.6 1
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -1
    -2.5 -2
    -5.5 -5
    5.5 5
    2.5 2
    1.6 1
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -1
    -2.5 -2
    -5.5 -5
    */ DOWN(BigDecimal.ROUND_DOWN), @@ -149,20 +161,24 @@ public enum RoundingMode { * that this rounding mode never decreases the calculated value. * *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode CEILING Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code CEILING} rounding - *
    5.5 6
    2.5 3
    1.6 2
    1.1 2
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -1
    -2.5 -2
    -5.5 -5
    5.5 6
    2.5 3
    1.6 2
    1.1 2
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -1
    -2.5 -2
    -5.5 -5
    */ CEILING(BigDecimal.ROUND_CEILING), @@ -174,20 +190,24 @@ public enum RoundingMode { * this rounding mode never increases the calculated value. * *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode FLOOR Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code FLOOR} rounding - *
    5.5 5
    2.5 2
    1.6 1
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -2
    -1.6 -2
    -2.5 -3
    -5.5 -6
    5.5 5
    2.5 2
    1.6 1
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -2
    -1.6 -2
    -2.5 -3
    -5.5 -6
    */ FLOOR(BigDecimal.ROUND_FLOOR), @@ -201,20 +221,24 @@ public enum RoundingMode { * mode commonly taught at school. * *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode HALF_UP Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code HALF_UP} rounding - *
    5.5 6
    2.5 3
    1.6 2
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -2
    -2.5 -3
    -5.5 -6
    5.5 6
    2.5 3
    1.6 2
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -2
    -2.5 -3
    -5.5 -6
    */ HALF_UP(BigDecimal.ROUND_HALF_UP), @@ -227,20 +251,24 @@ public enum RoundingMode { * {@code RoundingMode.DOWN}. * *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode HALF_DOWN Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code HALF_DOWN} rounding - *
    5.5 5
    2.5 2
    1.6 2
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -2
    -2.5 -2
    -5.5 -5
    5.5 5
    2.5 2
    1.6 2
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -2
    -2.5 -2
    -5.5 -5
    */ HALF_DOWN(BigDecimal.ROUND_HALF_DOWN), @@ -260,20 +288,24 @@ public enum RoundingMode { * arithmetic in Java. * *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode HALF_EVEN Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code HALF_EVEN} rounding - *
    5.5 6
    2.5 2
    1.6 2
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -2
    -2.5 -2
    -5.5 -6
    5.5 6
    2.5 2
    1.6 2
    1.1 1
    1.0 1
    -1.0 -1
    -1.1 -1
    -1.6 -2
    -2.5 -2
    -5.5 -6
    */ HALF_EVEN(BigDecimal.ROUND_HALF_EVEN), @@ -284,20 +316,24 @@ public enum RoundingMode { * specified on an operation that yields an inexact result, an * {@code ArithmeticException} is thrown. *

    Example: - * + *
    * - * + * + * * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Rounding mode UNNECESSARY Examples
    Input Number
    Input NumberInput rounded to one digit
    with {@code UNNECESSARY} rounding - *
    5.5 throw {@code ArithmeticException}
    2.5 throw {@code ArithmeticException}
    1.6 throw {@code ArithmeticException}
    1.1 throw {@code ArithmeticException}
    1.0 1
    -1.0 -1
    -1.1 throw {@code ArithmeticException}
    -1.6 throw {@code ArithmeticException}
    -2.5 throw {@code ArithmeticException}
    -5.5 throw {@code ArithmeticException}
    5.5 throw {@code ArithmeticException}
    2.5 throw {@code ArithmeticException}
    1.6 throw {@code ArithmeticException}
    1.1 throw {@code ArithmeticException}
    1.0 1
    -1.0 -1
    -1.1 throw {@code ArithmeticException}
    -1.6 throw {@code ArithmeticException}
    -2.5 throw {@code ArithmeticException}
    -5.5 throw {@code ArithmeticException}
    */ UNNECESSARY(BigDecimal.ROUND_UNNECESSARY); diff --git a/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java b/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java index 4945713e228..d4414560fe6 100644 --- a/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java +++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.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 @@ -275,6 +275,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl return (fd == null) ? true : false; } + @SuppressWarnings("deprecation") protected void finalize() { close(); } diff --git a/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java b/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java index 465ec01cc37..e66bbdc61aa 100644 --- a/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java +++ b/jdk/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.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 @@ -646,6 +646,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl /** * Cleans up if the user forgets to close it. */ + @SuppressWarnings("deprecation") protected void finalize() throws IOException { close(); } diff --git a/jdk/src/java.base/share/classes/java/net/HttpURLConnection.java b/jdk/src/java.base/share/classes/java/net/HttpURLConnection.java index 9e428e59584..448034e6225 100644 --- a/jdk/src/java.base/share/classes/java/net/HttpURLConnection.java +++ b/jdk/src/java.base/share/classes/java/net/HttpURLConnection.java @@ -54,7 +54,7 @@ import java.util.Date; * Security permissions *

    * If a security manager is installed, and if a method is called which results in an - * attempt to open a connection, the caller must possess either:- + * attempt to open a connection, the caller must possess either: *

    • a "connect" {@link SocketPermission} to the host/port combination of the * destination URL or
    • *
    • a {@link URLPermission} that permits this request.
    • diff --git a/jdk/src/java.base/share/classes/java/net/Inet4Address.java b/jdk/src/java.base/share/classes/java/net/Inet4Address.java index ab9c0c93811..25c5ab41224 100644 --- a/jdk/src/java.base/share/classes/java/net/Inet4Address.java +++ b/jdk/src/java.base/share/classes/java/net/Inet4Address.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 @@ -36,17 +36,17 @@ import java.io.ObjectStreamException; * and RFC 2365: * Administratively Scoped IP Multicast * - *

      Textual representation of IP addresses

      + *

      Textual representation of IP addresses

      * * Textual representation of IPv4 address used as input to methods * takes one of the following forms: * - *
      - * - * - * - * - *
      {@code d.d.d.d}
      {@code d.d.d}
      {@code d.d}
      {@code d}
      + *
        + *
      • {@code d.d.d.d}
      • + *
      • {@code d.d.d}
      • + *
      • {@code d.d}
      • + *
      • {@code d}
      • + *
      * *

      When four parts are specified, each is interpreted as a byte of * data and assigned, from left to right, to the four bytes of an IPv4 diff --git a/jdk/src/java.base/share/classes/java/net/Inet6Address.java b/jdk/src/java.base/share/classes/java/net/Inet6Address.java index ce4d9b93a62..0df84877cd5 100644 --- a/jdk/src/java.base/share/classes/java/net/Inet6Address.java +++ b/jdk/src/java.base/share/classes/java/net/Inet6Address.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 @@ -38,20 +38,20 @@ import java.util.Arrays; * Defined by * RFC 2373: IP Version 6 Addressing Architecture. * - *

      Textual representation of IP addresses

      + *

      Textual representation of IP addresses

      * * Textual representation of IPv6 address used as input to methods * takes one of the following forms: * *
        - *
      1. The preferred form is x:x:x:x:x:x:x:x, + *

      2. The preferred form is x:x:x:x:x:x:x:x, * where the 'x's are * the hexadecimal values of the eight 16-bit pieces of the * address. This is the full form. For example, * - *

        - * - *
        {@code 1080:0:0:0:8:800:200C:417A}
        + *
          + *
        • {@code 1080:0:0:0:8:800:200C:417A}
        • + *
        * *

        Note that it is not necessary to write the leading zeros in * an individual field. However, there must be at least one numeral @@ -66,9 +66,9 @@ import java.util.Arrays; * The "::" can also be used to compress the leading and/or trailing * zeros in an address. For example, * - *

        - * - *
        {@code 1080::8:800:200C:417A}
        + *
          + *
        • {@code 1080::8:800:200C:417A}
        • + *
        * *
      3. An alternative form that is sometimes more convenient * when dealing with a mixed environment of IPv4 and IPv6 nodes is @@ -77,35 +77,35 @@ import java.util.Arrays; * are the decimal values of the four low-order 8-bit pieces of the * standard IPv4 representation address, for example, * - *

        - * - * - *
        {@code ::FFFF:129.144.52.38}
        {@code ::129.144.52.38}
        + *
          + *
        • {@code ::FFFF:129.144.52.38}
        • + *
        • {@code ::129.144.52.38}
        • + *
        * *

        where "::FFFF:d.d.d.d" and "::d.d.d.d" are, respectively, the * general forms of an IPv4-mapped IPv6 address and an * IPv4-compatible IPv6 address. Note that the IPv4 portion must be * in the "d.d.d.d" form. The following forms are invalid: * - *

        - * - * - * - * - *
        {@code ::FFFF:d.d.d}
        {@code ::FFFF:d.d}
        {@code ::d.d.d}
        {@code ::d.d}
        + *
          + *
        • {@code ::FFFF:d.d.d}
        • + *
        • {@code ::FFFF:d.d}
        • + *
        • {@code ::d.d.d}
        • + *
        • {@code ::d.d}
        • + *
        * *

        The following form: * - *

        - * - *
        {@code ::FFFF:d}
        + *
          + *
        • {@code ::FFFF:d}
        • + *
        * *

        is valid, however it is an unconventional representation of * the IPv4-compatible IPv6 address, * - *

        - * - *
        {@code ::255.255.0.d}
        + *
          + *
        • {@code ::255.255.0.d}
        • + *
        * *

        while "::d" corresponds to the general IPv6 address * "0:0:0:0:0:0:0:d".

      4. @@ -119,9 +119,10 @@ import java.util.Arrays; *

        Special IPv6 address

        * *
        - * - * - *
        IPv4-mapped addressOf the form::ffff:w.x.y.z, this IPv6 address is used to + * + * + * + * *
        Description of IPv4-mapped address
        IPv4-mapped addressOf the form ::ffff:w.x.y.z, this IPv6 address is used to * represent an IPv4 address. It allows the native program to * use the same address data structure and also the same * socket when communicating with both IPv4 and IPv6 nodes. @@ -134,7 +135,7 @@ import java.util.Arrays; * address.
        * - *

        Textual representation of IPv6 scoped addresses

        + *

        Textual representation of IPv6 scoped addresses

        * *

        The textual representation of IPv6 addresses as described above can be * extended to specify IPv6 scoped addresses. This extension to the basic diff --git a/jdk/src/java.base/share/classes/java/net/InetAddress.java b/jdk/src/java.base/share/classes/java/net/InetAddress.java index 84457f30066..22d9ce80303 100644 --- a/jdk/src/java.base/share/classes/java/net/InetAddress.java +++ b/jdk/src/java.base/share/classes/java/net/InetAddress.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 @@ -72,7 +72,9 @@ import sun.net.util.IPAddressUtil; * *

        Address types

        * - *
        + *
        + * + * * * + * *
        Description of unicast and multicast address types
        unicastAn identifier for a single interface. A packet sent to * a unicast address is delivered to the interface identified by @@ -96,6 +98,7 @@ import sun.net.util.IPAddressUtil; * An identifier for a set of interfaces (typically belonging * to different nodes). A packet sent to a multicast address is * delivered to all interfaces identified by that address.
        * *

        IP address scope

        diff --git a/jdk/src/java.base/share/classes/java/net/NetPermission.java b/jdk/src/java.base/share/classes/java/net/NetPermission.java index dad3fb99f32..f156fb7af50 100644 --- a/jdk/src/java.base/share/classes/java/net/NetPermission.java +++ b/jdk/src/java.base/share/classes/java/net/NetPermission.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 @@ -47,12 +47,16 @@ import java.util.StringTokenizer; * and for each provides a description of what the permission allows * and a discussion of the risks of granting code the permission. * - * + *
        + * + * * * * * * + * + * * * * @@ -151,6 +155,7 @@ import java.util.StringTokenizer; * creating a ProtectionDomain/CodeSource for a class even though * that class really didn't come from that location. * + *
        Permission target name, what the permission allows, and associated risks
        Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
        allowHttpTraceThe ability to use the HTTP TRACE method in HttpURLConnection.
        * * @see java.security.BasicPermission diff --git a/jdk/src/java.base/share/classes/java/net/NetworkInterface.java b/jdk/src/java.base/share/classes/java/net/NetworkInterface.java index 960024f939d..66141af44fa 100644 --- a/jdk/src/java.base/share/classes/java/net/NetworkInterface.java +++ b/jdk/src/java.base/share/classes/java/net/NetworkInterface.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 @@ -175,14 +175,16 @@ public final class NetworkInterface { */ public java.util.List getInterfaceAddresses() { java.util.List lst = new java.util.ArrayList<>(1); - SecurityManager sec = System.getSecurityManager(); - for (int j=0; j - * - * - * - *
        {@code mailto:java-net@java.sun.com}
        {@code news:comp.lang.java}
        {@code urn:isbn:096139210x}
        + *
          + *
        • {@code mailto:java-net@java.sun.com}
        • + *
        • {@code news:comp.lang.java}
        • + *
        • {@code urn:isbn:096139210x}
        • + *
        * *

        A hierarchical URI is either an absolute URI whose * scheme-specific part begins with a slash character, or a relative URI, that @@ -132,8 +132,12 @@ import java.lang.NullPointerException; // for javadoc * *

        All told, then, a URI instance has the following nine components: * - *

        + *
        + * + * * + * + * * * * @@ -143,6 +147,7 @@ import java.lang.NullPointerException; // for javadoc * * * + * *
        Describes the components of a URI:scheme,scheme-specific-part,authority,user-info,host,port,path,query,fragment
        ComponentType
        scheme{@code String}
        scheme-specific-part    {@code String}
        authority{@code String}
        path{@code String}
        query{@code String}
        fragment{@code String}
        * * In a given instance any particular component is either undefined or @@ -248,7 +253,9 @@ import java.lang.NullPointerException; // for javadoc * which are taken from that specification, are used below to describe these * constraints: * - *
        + *
        + * + * * * + * *
        Describes categories alpha,digit,alphanum,unreserved,punct,reserved,escaped,and other
        alphaThe US-ASCII alphabetic characters, * {@code 'A'} through {@code 'Z'} @@ -279,9 +286,10 @@ import java.lang.NullPointerException; // for javadoc * java.lang.Character#isSpaceChar(char) Character.isSpaceChar} * method)  (Deviation from RFC 2396, which is * limited to US-ASCII)
        * - *

        The set of all legal URI characters consists of + *

        The set of all legal URI characters consists of * the unreserved, reserved, escaped, and other * characters. * @@ -308,20 +316,20 @@ import java.lang.NullPointerException; // for javadoc * *

          * - *
        • A character is encoded by replacing it + *

        • A character is encoded by replacing it * with the sequence of escaped octets that represent that character in the * UTF-8 character set. The Euro currency symbol ({@code '\u005Cu20AC'}), * for example, is encoded as {@code "%E2%82%AC"}. (Deviation from * RFC 2396, which does not specify any particular character * set.)

        • * - *
        • An illegal character is quoted simply by + *

        • An illegal character is quoted simply by * encoding it. The space character, for example, is quoted by replacing it * with {@code "%20"}. UTF-8 contains US-ASCII, hence for US-ASCII * characters this transformation has exactly the effect required by * RFC 2396.

        • * - *
        • + *

        • * A sequence of escaped octets is decoded by * replacing it with the sequence of characters that it represents in the * UTF-8 character set. UTF-8 contains US-ASCII, hence decoding has the @@ -983,7 +991,7 @@ public final class URI *

          If the given URI is already absolute, or if this URI is opaque, then * the given URI is returned. * - *

          If the given URI's fragment component is + *

          If the given URI's fragment component is * defined, its path component is empty, and its scheme, authority, and * query components are undefined, then a URI with the given fragment but * with all other components equal to those of this URI is returned. This 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 b029b83d7ca..1ac1437ab96 100644 --- a/jdk/src/java.base/share/classes/java/net/URL.java +++ b/jdk/src/java.base/share/classes/java/net/URL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, 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 @@ -41,6 +41,8 @@ import java.util.NoSuchElementException; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; +import jdk.internal.misc.JavaNetURLAccess; +import jdk.internal.misc.SharedSecrets; import sun.security.util.SecurityConstants; import sun.security.action.GetPropertyAction; @@ -1614,6 +1616,17 @@ public final class URL implements java.io.Serializable { private void setSerializedHashCode(int hc) { this.hashCode = hc; } + + static { + SharedSecrets.setJavaNetURLAccess( + new JavaNetURLAccess() { + @Override + public URLStreamHandler getHandler(URL u) { + return u.handler; + } + } + ); + } } final class UrlDeserializedState { 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 2e52fe2b4e9..d6bd9546750 100644 --- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java +++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java @@ -228,6 +228,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { * allow creation of a class loader. * * @since 9 + * @spec JPMS */ public URLClassLoader(String name, URL[] urls, @@ -262,6 +263,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { * creation of a class loader. * * @since 9 + * @spec JPMS */ public URLClassLoader(String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { @@ -558,6 +560,9 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { * @throws IllegalArgumentException if the package name is * already defined by this class loader * @return the newly defined {@code Package} object + * + * @revised 9 + * @spec JPMS */ protected Package definePackage(String name, Manifest man, URL url) { String path = name.replace('.', '/').concat("/"); 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 e2ed0cfcbdd..c9331b704af 100644 --- a/jdk/src/java.base/share/classes/java/net/URLConnection.java +++ b/jdk/src/java.base/share/classes/java/net/URLConnection.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 @@ -54,16 +54,21 @@ import sun.security.action.GetPropertyAction; * read from and to write to the resource referenced by the URL. In * general, creating a connection to a URL is a multistep process: * - *

          + *
          + * + * * * + * + * * * + * *
          Describes the process of creating a connection to a URL: openConnection() and connect() over time.
          {@code openConnection()}{@code connect()}
          Manipulate parameters that affect the connection to the remote * resource.Interact with the resource; query header fields and * contents.
          * ----------------------------> - *
          time
          + *
          time * *
            *
          1. The connection object is created by invoking the diff --git a/jdk/src/java.base/share/classes/java/net/URLPermission.java b/jdk/src/java.base/share/classes/java/net/URLPermission.java index e78c7aee68c..43a8bd43066 100644 --- a/jdk/src/java.base/share/classes/java/net/URLPermission.java +++ b/jdk/src/java.base/share/classes/java/net/URLPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 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 @@ -72,9 +72,12 @@ import java.security.Permission; * separated by '/' characters. path may also be empty. The path is specified * in a similar way to the path in {@link java.io.FilePermission}. There are * three different ways as the following examples show: - * + *
            * + * * + * + * * * * @@ -90,6 +93,7 @@ import java.security.Permission; * example). * * + * *
            URL Examples
            Example urlDescription
            http://www.oracle.com/a/b/c.htmlA url which identifies a specific (single) resource
            *

            * The '*' and '-' may only be specified in the final segment of a path and must be @@ -246,9 +250,12 @@ public final class URLPermission extends Permission { *

          2. otherwise, return false
          3. *
        *

        Some examples of how paths are matched are shown below: - * + *
        * + * * + * + * * * * @@ -256,6 +263,7 @@ public final class URLPermission extends Permission { * * * + * *
        Examples of Path Matching
        this's pathp's pathmatch
        /a/b/a/byes
        /a/b/*/a/b/cyes
        /a/b/*/a/b/c/dno
        /a/b/-/a/b/c/d/eyes
        /a/b/-/a/b/c/*yes
        /a/b/*/a/b/c/-no
        */ public boolean implies(Permission p) { diff --git a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java index 838cc40a09a..0439afbffca 100644 --- a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java +++ b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java @@ -45,7 +45,7 @@ import jdk.internal.misc.Unsafe; * this program or another. Whether or not such changes occur, and when they * occur, is operating-system dependent and therefore unspecified. * - *

        All or part of a mapped byte buffer may become + *

        All or part of a mapped byte buffer may become * inaccessible at any time, for example if the mapped file is truncated. An * attempt to access an inaccessible region of a mapped byte buffer will not * change the buffer's content and will cause an unspecified exception to be @@ -213,7 +213,6 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 9 */ @Override public final MappedByteBuffer position(int newPosition) { @@ -223,7 +222,6 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 9 */ @Override public final MappedByteBuffer limit(int newLimit) { @@ -233,7 +231,6 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 9 */ @Override public final MappedByteBuffer mark() { @@ -243,7 +240,6 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 9 */ @Override public final MappedByteBuffer reset() { @@ -253,7 +249,6 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 9 */ @Override public final MappedByteBuffer clear() { @@ -263,7 +258,6 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 9 */ @Override public final MappedByteBuffer flip() { @@ -273,7 +267,6 @@ public abstract class MappedByteBuffer /** * {@inheritDoc} - * @since 9 */ @Override public final MappedByteBuffer rewind() { diff --git a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template index 1292ca458c6..0a39543a88e 100644 --- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -93,7 +93,7 @@ import java.util.stream.$Streamtype$Stream; * #if[byte] * - * + * *

        Direct vs. non-direct buffers

        * *

        A byte buffer is either direct or non-direct. Given a @@ -128,7 +128,7 @@ import java.util.stream.$Streamtype$Stream; * that explicit buffer management can be done in performance-critical code. * * - * + * *

        Access to binary data

        * *

        This class defines methods for reading and writing values of all other @@ -155,7 +155,7 @@ import java.util.stream.$Streamtype$Stream; * parameters of the absolute get and put methods are in terms of * bytes rather than of the type being read or written. * - * + * * *

        For access to homogeneous binary data, that is, sequences of values of * the same type, this class defines methods that can create views of a @@ -1069,7 +1069,6 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 9 */ @Override public @@ -1083,7 +1082,6 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 9 */ @Override public @@ -1097,7 +1095,6 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 9 */ @Override public @@ -1111,7 +1108,6 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 9 */ @Override public @@ -1125,7 +1121,6 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 9 */ @Override public @@ -1139,7 +1134,6 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 9 */ @Override public @@ -1153,7 +1147,6 @@ public abstract class $Type$Buffer /** * {@inheritDoc} - * @since 9 */ @Override public diff --git a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousChannelGroup.java b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousChannelGroup.java index 92b7e66a174..acd7da8b1d9 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousChannelGroup.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousChannelGroup.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 @@ -60,11 +60,15 @@ import java.util.concurrent.TimeUnit; * default group is not configured then the pooled threads of the default group * are {@link Thread#isDaemon daemon} threads. * - * + *
        + * + * * * * * + * + * * * * * + * *
        System properties
        System propertyDescription
        {@code java.nio.channels.DefaultThreadPool.threadFactory} The value of this property is taken to be the fully-qualified name @@ -86,9 +90,10 @@ import java.util.concurrent.TimeUnit; * unspecified error to be thrown during the construction of the default * group.
        * - *

        Threading

        + *

        Threading

        * *

        The completion handler for an I/O operation initiated on a channel bound * to a group is guaranteed to be invoked by one of the pooled threads in the @@ -103,7 +108,7 @@ import java.util.concurrent.TimeUnit; * handler directly by the initiating thread (see {@link * AsynchronousServerSocketChannel#accept(Object,CompletionHandler) accept}). * - *

        Shutdown and Termination

        + *

        Shutdown and Termination

        * *

        The {@link #shutdown() shutdown} method is used to initiate an orderly * shutdown of a group. An orderly shutdown marks the group as shutdown; diff --git a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousFileChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousFileChannel.java index 4b5548e79e5..9653a433050 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousFileChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousFileChannel.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 @@ -133,8 +133,12 @@ public abstract class AsynchronousFileChannel *

        In addition to {@code READ} and {@code WRITE}, the following options * may be present: * - * + *
        + * + * * + * + * * * * * + * *
        additional options
        Option Description
        {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} When opening an existing file, the file is first truncated to a @@ -186,6 +190,7 @@ public abstract class AsynchronousFileChannel * href="../file/package-summary.html#integrity"> Synchronized I/O file * integrity).
        * *

        An implementation may also support additional options. diff --git a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java index 44a2460426f..137451c7763 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousServerSocketChannel.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 @@ -52,11 +52,15 @@ import java.io.IOException; *

        Socket options are configured using the {@link #setOption(SocketOption,Object) * setOption} method. Channels of this type support the following options: *

        - * + *
        + * + * * * * * + * + * * * * @@ -65,6 +69,7 @@ import java.io.IOException; * * * + * *
        Socket options
        Option NameDescription
        {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} The size of the socket receive buffer {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} Re-use address
        *
        * Additional (implementation specific) options may also be supported. diff --git a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousSocketChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousSocketChannel.java index d5e2abeb63a..6ba16628632 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousSocketChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/AsynchronousSocketChannel.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 @@ -62,11 +62,15 @@ import java.nio.ByteBuffer; *

        Socket options are configured using the {@link #setOption(SocketOption,Object) * setOption} method. Asynchronous socket channels support the following options: *

        - * + *
        + * + * * * * * + * + * * * * @@ -87,6 +91,7 @@ import java.nio.ByteBuffer; * * * + * *
        Socket options
        Option NameDescription
        {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} The size of the socket send buffer {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} Disable the Nagle algorithm
        *
        * Additional (implementation specific) options may also be supported. diff --git a/jdk/src/java.base/share/classes/java/nio/channels/DatagramChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/DatagramChannel.java index 0b3278bf356..ac96bc61596 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/DatagramChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/DatagramChannel.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 @@ -57,11 +57,15 @@ import java.nio.channels.spi.SelectorProvider; * setOption} method. A datagram channel to an Internet Protocol socket supports * the following options: *
        - * + *
        + * + * * * * * + * + * * * * @@ -97,6 +101,7 @@ import java.nio.channels.spi.SelectorProvider; * IP_MULTICAST_LOOP} * * + * *
        Socket options
        Option NameDescription
        {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} The size of the socket send buffer Loopback for Internet Protocol (IP) multicast datagrams
        *
        * Additional (implementation specific) options may also be supported. diff --git a/jdk/src/java.base/share/classes/java/nio/channels/FileChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/FileChannel.java index 066ef8a9fa9..551ef21bb2c 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/FileChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/FileChannel.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 @@ -118,7 +118,7 @@ import java.util.Collections; * versa. Changing the file's content by writing bytes will change the content * seen by the originating object, and vice versa. * - *

        At various points this class specifies that an + *

        At various points this class specifies that an * instance that is "open for reading," "open for writing," or "open for * reading and writing" is required. A channel obtained via the {@link * java.io.FileInputStream#getChannel getChannel} method of a {@link @@ -131,7 +131,7 @@ import java.util.Collections; * was created with mode {@code "r"} and will be open for reading and writing * if the instance was created with mode {@code "rw"}. * - *

        A file channel that is open for writing may be in + *

        A file channel that is open for writing may be in * append mode, for example if it was obtained from a file-output stream * that was created by invoking the {@link * java.io.FileOutputStream#FileOutputStream(java.io.File,boolean) @@ -174,8 +174,12 @@ public abstract class FileChannel *

        In the addition to {@code READ} and {@code WRITE}, the following * options may be present: * - * + *
        + * + * * + * + * * * * * + * *
        additional options
        Option Description
        {@link StandardOpenOption#APPEND APPEND} If this option is present then the file is opened for writing and @@ -237,6 +241,7 @@ public abstract class FileChannel * href="../file/package-summary.html#integrity"> Synchronized I/O file * integrity).
        * *

        An implementation may also support additional options. diff --git a/jdk/src/java.base/share/classes/java/nio/channels/FileLock.java b/jdk/src/java.base/share/classes/java/nio/channels/FileLock.java index 3a5c6a1a4b7..0edd94d5e25 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/FileLock.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/FileLock.java @@ -73,7 +73,7 @@ import java.util.Objects; *

        File-lock objects are safe for use by multiple concurrent threads. * * - *

        Platform dependencies

        + *

        Platform dependencies

        * *

        This file-locking API is intended to map directly to the native locking * facility of the underlying operating system. Thus the locks held on a file diff --git a/jdk/src/java.base/share/classes/java/nio/channels/SelectableChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/SelectableChannel.java index 8cf4dab27a4..cbb77dab86d 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/SelectableChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/SelectableChannel.java @@ -64,7 +64,7 @@ import java.nio.channels.spi.SelectorProvider; * threads.

        * * - * + * *

        Blocking mode

        * * A selectable channel is either in blocking mode or in diff --git a/jdk/src/java.base/share/classes/java/nio/channels/SelectionKey.java b/jdk/src/java.base/share/classes/java/nio/channels/SelectionKey.java index bd7c74de52a..6af664fa96b 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/SelectionKey.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/SelectionKey.java @@ -40,7 +40,7 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; * next selection operation. The validity of a key may be tested by invoking * its {@link #isValid isValid} method. * - * + * * *

        A selection key contains two operation sets represented as * integer values. Each bit of an operation set denotes a category of diff --git a/jdk/src/java.base/share/classes/java/nio/channels/Selector.java b/jdk/src/java.base/share/classes/java/nio/channels/Selector.java index cfed526b47d..cae3ff2c137 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/Selector.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/Selector.java @@ -42,7 +42,7 @@ import java.util.Set; * method of a custom selector provider. A selector remains open until it is * closed via its {@link #close close} method. * - * + * * *

        A selectable channel's registration with a selector is represented by a * {@link SelectionKey} object. A selector maintains three sets of selection @@ -80,7 +80,7 @@ import java.util.Set; * during the next selection operation, at which time the key will removed from * all of the selector's key sets. * - *

        Keys are added to the selected-key set by selection + *

        Keys are added to the selected-key set by selection * operations. A key may be removed directly from the selected-key set by * invoking the set's {@link java.util.Set#remove(java.lang.Object) remove} * method or by invoking the {@link java.util.Iterator#remove() remove} method @@ -90,7 +90,7 @@ import java.util.Set; * operations. Keys may not be added directly to the selected-key set.

        * * - * + * *

        Selection

        * *

        During each selection operation, keys may be added to and removed from a @@ -183,7 +183,7 @@ import java.util.Set; *

        The {@link #close close} method synchronizes on the selector and all * three key sets in the same order as in a selection operation. * - * + * * *

        A selector's key and selected-key sets are not, in general, safe for use * by multiple concurrent threads. If such a thread might modify one of these diff --git a/jdk/src/java.base/share/classes/java/nio/channels/ServerSocketChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/ServerSocketChannel.java index 7c9666bbdd8..ea8951b2d2e 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/ServerSocketChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/ServerSocketChannel.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,11 +46,15 @@ import java.nio.channels.spi.SelectorProvider; *

        Socket options are configured using the {@link #setOption(SocketOption,Object) * setOption} method. Server-socket channels support the following options: *

        - * + *
        + * + * * * * * + * + * * * * @@ -59,6 +63,7 @@ import java.nio.channels.spi.SelectorProvider; * * * + * *
        Socket options
        Option NameDescription
        {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} The size of the socket receive buffer {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} Re-use address
        *
        * Additional (implementation specific) options may also be supported. diff --git a/jdk/src/java.base/share/classes/java/nio/channels/SocketChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/SocketChannel.java index c25cc68edf2..0025d2c22cf 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/SocketChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/SocketChannel.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 @@ -66,11 +66,15 @@ import java.nio.channels.spi.SelectorProvider; *

        Socket options are configured using the {@link #setOption(SocketOption,Object) * setOption} method. Socket channels support the following options: *

        - * + *
        + * + * * * * * + * + * * * * @@ -96,6 +100,7 @@ import java.nio.channels.spi.SelectorProvider; * * * + * *
        Socket options
        Option NameDescription
        {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} The size of the socket send buffer {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} Disable the Nagle algorithm
        *
        * Additional (implementation specific) options may also be supported. diff --git a/jdk/src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template b/jdk/src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template index 74b6f928439..dd69c9bf62b 100644 --- a/jdk/src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template +++ b/jdk/src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template @@ -41,7 +41,7 @@ import java.util.Arrays; * An engine that can transform a sequence of $itypesPhrase$ into a sequence of * $otypesPhrase$. * - * + * * *

        The input $itype$ sequence is provided in a $itype$ buffer or a series * of such buffers. The output $otype$ sequence is written to a $otype$ buffer @@ -76,14 +76,14 @@ import java.util.Arrays; * examine this object and fill the input buffer, flush the output buffer, or * attempt to recover from $a$ $coding$ error, as appropriate, and try again. * - * + * * *

        There are two general types of $coding$ errors. If the input $itype$ * sequence is $notLegal$ then the input is considered malformed. If * the input $itype$ sequence is legal but cannot be mapped to a valid * $outSequence$ then an unmappable character has been encountered. * - * + * * *

        How $a$ $coding$ error is handled depends upon the action requested for * that type of error, which is described by an instance of the {@link diff --git a/jdk/src/java.base/share/classes/java/nio/charset/Charset.java b/jdk/src/java.base/share/classes/java/nio/charset/Charset.java index 81209891bb4..480ede3e6a2 100644 --- a/jdk/src/java.base/share/classes/java/nio/charset/Charset.java +++ b/jdk/src/java.base/share/classes/java/nio/charset/Charset.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 @@ -67,7 +67,7 @@ import sun.security.action.GetPropertyAction; * concurrent threads. * * - * + * *

        Charset names

        * *

        Charsets are named by strings composed of the following characters: @@ -113,14 +113,14 @@ import sun.security.action.GetPropertyAction; * The aliases of a charset are returned by the {@link #aliases() aliases} * method. * - *

        Some charsets have an historical name that is defined for + *

        Some charsets have an historical name that is defined for * compatibility with previous versions of the Java platform. A charset's * historical name is either its canonical name or one of its aliases. The * historical name is returned by the {@code getEncoding()} methods of the * {@link java.io.InputStreamReader#getEncoding InputStreamReader} and {@link * java.io.OutputStreamWriter#getEncoding OutputStreamWriter} classes. * - *

        If a charset listed in the If a charset listed in the IANA Charset * Registry is supported by an implementation of the Java platform then * its canonical name must be the name listed in the registry. Many charsets @@ -142,29 +142,34 @@ import sun.security.action.GetPropertyAction; * * * - *

        Every implementation of the Java platform is required to support the + *

        Every implementation of the Java platform is required to support the * following standard charsets. Consult the release documentation for your * implementation to see if any other charsets are supported. The behavior * of such optional charsets may differ between implementations. * - *

        - * - * + *
        CharsetDescription
        {@code US-ASCII}
        + * + * + * + * + * + * * - * + * * - * + * * - * + * * - * + * * - * + * * + * *
        Description of standard charsets
        CharsetDescription
        {@code US-ASCII}Seven-bit ASCII, a.k.a. {@code ISO646-US}, * a.k.a. the Basic Latin block of the Unicode character set
        ISO-8859-1  
        ISO-8859-1  ISO Latin Alphabet No. 1, a.k.a. {@code ISO-LATIN-1}
        {@code UTF-8}
        {@code UTF-8}Eight-bit UCS Transformation Format
        {@code UTF-16BE}
        {@code UTF-16BE}Sixteen-bit UCS Transformation Format, * big-endian byte order
        {@code UTF-16LE}
        {@code UTF-16LE}Sixteen-bit UCS Transformation Format, * little-endian byte order
        {@code UTF-16}
        {@code UTF-16}Sixteen-bit UCS Transformation Format, * byte order identified by an optional byte-order mark
        * *

        The {@code UTF-8} charset is specified by aliasSet = null; /** diff --git a/jdk/src/java.base/share/classes/java/nio/file/ClosedFileSystemException.java b/jdk/src/java.base/share/classes/java/nio/file/ClosedFileSystemException.java index 82cf096c848..60d4551419f 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/ClosedFileSystemException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/ClosedFileSystemException.java @@ -28,6 +28,8 @@ package java.nio.file; /** * Unchecked exception thrown when an attempt is made to invoke an operation on * a file and the file system is closed. + * + * @since 1.7 */ public class ClosedFileSystemException diff --git a/jdk/src/java.base/share/classes/java/nio/file/ClosedWatchServiceException.java b/jdk/src/java.base/share/classes/java/nio/file/ClosedWatchServiceException.java index 3995b6def60..4990a7aca3f 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/ClosedWatchServiceException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/ClosedWatchServiceException.java @@ -28,6 +28,8 @@ package java.nio.file; /** * Unchecked exception thrown when an attempt is made to invoke an operation on * a watch service that is closed. + * + * @since 1.7 */ public class ClosedWatchServiceException diff --git a/jdk/src/java.base/share/classes/java/nio/file/FileSystem.java b/jdk/src/java.base/share/classes/java/nio/file/FileSystem.java index 1c60862c857..0fd5be4fcf0 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/FileSystem.java +++ b/jdk/src/java.base/share/classes/java/nio/file/FileSystem.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 @@ -315,7 +315,9 @@ public abstract class FileSystem * that resembles regular expressions but with a simpler syntax. For example: * *

        - * + *
        + * + * * * * @@ -348,7 +350,7 @@ public abstract class FileSystem * platform (note that the backslash is escaped; as a string literal in the * Java Language the pattern would be "C:\\\\*") * - * + * *
        Pattern Language
        {@code *.java}Matches a path that represents a file name ending in {@code .java}
        *
        * diff --git a/jdk/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java b/jdk/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java index e305542508f..5877410473e 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/FileSystemAlreadyExistsException.java @@ -28,6 +28,8 @@ package java.nio.file; /** * Runtime exception thrown when an attempt is made to create a file system that * already exists. + * + * @since 1.7 */ public class FileSystemAlreadyExistsException diff --git a/jdk/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java b/jdk/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java index 1c0ee4cb731..e50eafb5d6d 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/FileSystemNotFoundException.java @@ -27,6 +27,8 @@ package java.nio.file; /** * Runtime exception thrown when a file system cannot be found. + * + * @since 1.7 */ public class FileSystemNotFoundException diff --git a/jdk/src/java.base/share/classes/java/nio/file/FileSystems.java b/jdk/src/java.base/share/classes/java/nio/file/FileSystems.java index 08ff1f0d740..2754fa39c0a 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/FileSystems.java +++ b/jdk/src/java.base/share/classes/java/nio/file/FileSystems.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, 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 @@ -36,6 +36,8 @@ import java.util.Map; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; +import jdk.internal.misc.VM; + /** * Factory methods for file systems. This class defines the {@link #getDefault * getDefault} method to get the default file system and factory methods to @@ -120,8 +122,8 @@ public final class FileSystems { // if the property java.nio.file.spi.DefaultFileSystemProvider is // set then its value is the name of the default provider (or a list) - String propValue = System - .getProperty("java.nio.file.spi.DefaultFileSystemProvider"); + String prop = "java.nio.file.spi.DefaultFileSystemProvider"; + String propValue = System.getProperty(prop); if (propValue != null) { for (String cn: propValue.split(",")) { try { @@ -184,7 +186,7 @@ public final class FileSystems { * @return the default file system */ public static FileSystem getDefault() { - if (jdk.internal.misc.VM.isBooted()) { + if (VM.isModuleSystemInited()) { return DefaultFileSystemHolder.defaultFileSystem; } else { return BuiltinFileSystemHolder.builtinFileSystem; diff --git a/jdk/src/java.base/share/classes/java/nio/file/Files.java b/jdk/src/java.base/share/classes/java/nio/file/Files.java index 3a6491440a7..ac662e4e431 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/Files.java +++ b/jdk/src/java.base/share/classes/java/nio/file/Files.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, 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 @@ -233,8 +233,12 @@ public final class Files { *

        In the addition to {@code READ} and {@code WRITE}, the following * options may be present: * - * + *
        + * + * * + * + * * * * * + * *
        Options
        Option Description
        {@link StandardOpenOption#APPEND APPEND} If this option is present then the file is opened for writing and @@ -294,6 +298,7 @@ public final class Files { * href="package-summary.html#integrity"> Synchronized I/O file * integrity).
        * *

        An implementation may also support additional implementation specific @@ -1188,8 +1193,12 @@ public final class Files { * *

        The {@code options} parameter may include any of the following: * - * + *
        + * + * * + * + * * * * * + * *
        Options
        Option Description
        {@link StandardCopyOption#REPLACE_EXISTING REPLACE_EXISTING} If the target file exists, then the target file is replaced if it @@ -1215,6 +1224,7 @@ public final class Files { * new link. In other words, the {@code COPY_ATTRIBUTES} option may be * ignored when copying a symbolic link.
        * *

        An implementation of this interface may support additional @@ -1306,8 +1316,12 @@ public final class Files { * *

        The {@code options} parameter may include any of the following: * - * + *
        + * + * * + * + * * * * + * *
        Options
        Option Description
        {@link StandardCopyOption#REPLACE_EXISTING REPLACE_EXISTING} If the target file exists, then the target file is replaced if it @@ -1326,6 +1340,7 @@ public final class Files { * example, when the target location is on a different {@code FileStore} * and would require that the file be copied, or target location is * associated with a different provider to this object.
        * *

        An implementation of this interface may support additional @@ -1909,7 +1924,9 @@ public final class Files { * attributes} parameter: * *

        - * + *
        + * + * * * * @@ -1927,6 +1944,7 @@ public final class Files { * * * + * *
        Possible values
        {@code "*"} Read all {@link BasicFileAttributes basic-file-attributes}. {@code "posix:permissions,owner,size"} Reads the POSIX file permissions, owner, and file size.
        *
        * diff --git a/jdk/src/java.base/share/classes/java/nio/file/InvalidPathException.java b/jdk/src/java.base/share/classes/java/nio/file/InvalidPathException.java index 0502d7ba809..2dc3597ded8 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/InvalidPathException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/InvalidPathException.java @@ -29,6 +29,8 @@ package java.nio.file; * Unchecked exception thrown when path string cannot be converted into a * {@link Path} because the path string contains invalid characters, or * the path string is invalid for other file system specific reasons. + * + * @since 1.7 */ public class InvalidPathException diff --git a/jdk/src/java.base/share/classes/java/nio/file/LinkPermission.java b/jdk/src/java.base/share/classes/java/nio/file/LinkPermission.java index bf54e168774..8f82d9f2adb 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/LinkPermission.java +++ b/jdk/src/java.base/share/classes/java/nio/file/LinkPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, 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 @@ -33,13 +33,16 @@ import java.security.BasicPermission; *

        The following table provides a summary description of what the permission * allows, and discusses the risks of granting code the permission. * - * + *
        + * + * * * * * * + * + * * * * * + * *
        Table shows permission target name, what the permission allows, and associated risks
        Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
        hard Ability to add an existing file to a directory. This is sometimes @@ -55,6 +58,7 @@ import java.security.BasicPermission; * linking to any file or directory in the file system thus allowing the * attacker to access to all files.
        * * @since 1.7 diff --git a/jdk/src/java.base/share/classes/java/nio/file/Path.java b/jdk/src/java.base/share/classes/java/nio/file/Path.java index e7307e65640..76715a2225e 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/Path.java +++ b/jdk/src/java.base/share/classes/java/nio/file/Path.java @@ -76,7 +76,7 @@ import java.util.NoSuchElementException; * BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8); * * - *

        Interoperability

        + *

        Interoperability

        *

        Paths associated with the default {@link * java.nio.file.spi.FileSystemProvider provider} are generally interoperable * with the {@link java.io.File java.io.File} class. Paths created by other diff --git a/jdk/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java b/jdk/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java index 0220d6e173f..9e628cbdfc7 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/ProviderMismatchException.java @@ -29,6 +29,8 @@ package java.nio.file; * Unchecked exception thrown when an attempt is made to invoke a method on an * object created by one file system provider with a parameter created by a * different file system provider. + * + * @since 1.7 */ public class ProviderMismatchException extends java.lang.IllegalArgumentException diff --git a/jdk/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java b/jdk/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java index 8fa0cefaf3b..41f9819aacb 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/ProviderNotFoundException.java @@ -27,6 +27,8 @@ package java.nio.file; /** * Runtime exception thrown when a provider of the required type cannot be found. + * + * @since 1.7 */ public class ProviderNotFoundException diff --git a/jdk/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java b/jdk/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java index 9b25e5f054b..0b9d42a2bbb 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java +++ b/jdk/src/java.base/share/classes/java/nio/file/ReadOnlyFileSystemException.java @@ -28,6 +28,8 @@ package java.nio.file; /** * Unchecked exception thrown when an attempt is made to update an object * associated with a {@link FileSystem#isReadOnly() read-only} {@code FileSystem}. + * + * @since 1.7 */ public class ReadOnlyFileSystemException diff --git a/jdk/src/java.base/share/classes/java/nio/file/attribute/AclFileAttributeView.java b/jdk/src/java.base/share/classes/java/nio/file/attribute/AclFileAttributeView.java index 429bfde8a1b..4ba76741dd0 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/attribute/AclFileAttributeView.java +++ b/jdk/src/java.base/share/classes/java/nio/file/attribute/AclFileAttributeView.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 @@ -94,11 +94,15 @@ import java.io.IOException; *

        Where dynamic access to file attributes is required, the attributes * supported by this attribute view are as follows: *

        - * + *
        + * + * * * * * + * + * * * * @@ -107,6 +111,7 @@ import java.io.IOException; * * * + * *
        Supported attributes
        Name Type
        "acl" {@link List}<{@link AclEntry}> "owner" {@link UserPrincipal}
        *
        * diff --git a/jdk/src/java.base/share/classes/java/nio/file/attribute/BasicFileAttributeView.java b/jdk/src/java.base/share/classes/java/nio/file/attribute/BasicFileAttributeView.java index bfa3fdc2676..465fb6bc3f3 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/attribute/BasicFileAttributeView.java +++ b/jdk/src/java.base/share/classes/java/nio/file/attribute/BasicFileAttributeView.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 @@ -41,11 +41,15 @@ import java.io.IOException; *

        Where dynamic access to file attributes is required, the attributes * supported by this attribute view have the following names and types: *

        - * + *
        + * + * * * * * + * + * * * * @@ -82,6 +86,7 @@ import java.io.IOException; * * * + * *
        Supported attributes
        Name Type
        "lastModifiedTime" {@link FileTime} "fileKey" {@link Object}
        *
        * diff --git a/jdk/src/java.base/share/classes/java/nio/file/attribute/DosFileAttributeView.java b/jdk/src/java.base/share/classes/java/nio/file/attribute/DosFileAttributeView.java index c12d8a0e5f0..be4f570b46b 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/attribute/DosFileAttributeView.java +++ b/jdk/src/java.base/share/classes/java/nio/file/attribute/DosFileAttributeView.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 @@ -41,11 +41,15 @@ import java.io.IOException; * BasicFileAttributeView}, and in addition, the following attributes are * supported: *
        - * + *
        + * + * * * * * + * + * * * * @@ -62,6 +66,7 @@ import java.io.IOException; * * * + * *
        Supported attributes
        Name Type
        readonly {@link Boolean} archive {@link Boolean}
        *
        * diff --git a/jdk/src/java.base/share/classes/java/nio/file/attribute/PosixFileAttributeView.java b/jdk/src/java.base/share/classes/java/nio/file/attribute/PosixFileAttributeView.java index f8c36523d66..9e171768603 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/attribute/PosixFileAttributeView.java +++ b/jdk/src/java.base/share/classes/java/nio/file/attribute/PosixFileAttributeView.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 @@ -74,11 +74,15 @@ import java.io.IOException; * BasicFileAttributeView} and {@link FileOwnerAttributeView}, and in addition, * the following attributes are supported: *
        - * + *
        + * + * * * * * + * + * * * * @@ -87,6 +91,7 @@ import java.io.IOException; * * * + * *
        Supported attributes
        Name Type
        "permissions" {@link Set}<{@link PosixFilePermission}> "group" {@link GroupPrincipal}
        *
        * diff --git a/jdk/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.java b/jdk/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.java index b92cf525eef..26dc40606de 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.java +++ b/jdk/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.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 @@ -919,8 +919,12 @@ public abstract class FileSystemProvider { * according to all of access modes specified in the {@code modes} parameter * as follows: * - * + *
        + * + * * + * + * * * * * + * *
        Access Modes
        Value Description
        {@link AccessMode#READ READ} Checks that the file exists and that the Java virtual machine has @@ -940,6 +944,7 @@ public abstract class FileSystemProvider { * virtual machine has permission to search the directory in order to * access file or subdirectories.
        * *

        If the {@code modes} parameter is of length zero, then the existence diff --git a/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java b/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java index 7d1134493ce..8694b603c07 100644 --- a/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java +++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java @@ -75,9 +75,9 @@ import java.util.Objects; *

      5. {@code DSA} (1024, 2048)
      6. * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#algorithmparametergenerator-algorithms"> * AlgorithmParameterGenerator section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -150,8 +150,8 @@ public class AlgorithmParameterGenerator { * @param algorithm the name of the algorithm this * parameter generator is associated with. * See the AlgorithmParameterGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#algorithmparametergenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code AlgorithmParameterGenerator} object @@ -195,8 +195,8 @@ public class AlgorithmParameterGenerator { * @param algorithm the name of the algorithm this * parameter generator is associated with. * See the AlgorithmParameterGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#algorithmparametergenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the string name of the Provider. @@ -245,8 +245,8 @@ public class AlgorithmParameterGenerator { * @param algorithm the string name of the algorithm this * parameter generator is associated with. * See the AlgorithmParameterGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#algorithmparametergenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the {@code Provider} object. diff --git a/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java b/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java index e03361233a5..a5ed953e65b 100644 --- a/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.java +++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameters.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 @@ -57,9 +57,9 @@ import java.util.Objects; *
      7. {@code DSA}
      8. * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#algorithmparameters-algorithms"> * AlgorithmParameters section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -137,8 +137,8 @@ public class AlgorithmParameters { * * @param algorithm the name of the algorithm requested. * See the AlgorithmParameters section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#algorithmparameters-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new parameter object @@ -182,8 +182,8 @@ public class AlgorithmParameters { * * @param algorithm the name of the algorithm requested. * See the AlgorithmParameters section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#algorithmparameters-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -232,8 +232,8 @@ public class AlgorithmParameters { * * @param algorithm the name of the algorithm requested. * See the AlgorithmParameters section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#algorithmparameters-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. diff --git a/jdk/src/java.base/share/classes/java/security/DrbgParameters.java b/jdk/src/java.base/share/classes/java/security/DrbgParameters.java index c71e1cffa28..05723baa916 100644 --- a/jdk/src/java.base/share/classes/java/security/DrbgParameters.java +++ b/jdk/src/java.base/share/classes/java/security/DrbgParameters.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 @@ -53,8 +53,8 @@ import java.util.Objects; * for CTR_DRBG. Please note that it is not the algorithm used in * {@link SecureRandom#getInstance}, which we will call a * SecureRandom algorithm below), - *
      9. optionally features, including prediction resistance - * and reseeding supports. + *
      10. optional features, including prediction resistance + * and reseeding supports, *
      11. highest security strength. * *

        @@ -188,7 +188,7 @@ import java.util.Objects; * @implSpec * By convention, a provider should name its primary DRBG implementation * with the + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> * standard {@code SecureRandom} algorithm name "DRBG". * * @implNote @@ -263,14 +263,19 @@ public class DrbgParameters { * Capability effective = ((DrbgParametes.Initiate) s.getParameters()) * .getCapability(); * - * + *
        + * + * * * * * + * + * * * * + * *
        requested and effective capabilities
        Requested ValuePossible Effective Values
        NONENONE, RESEED_ONLY, PR_AND_RESEED
        RESEED_ONLYRESEED_ONLY, PR_AND_RESEED
        PR_AND_RESEEDPR_AND_RESEED
        *

        * A DRBG implementation supporting prediction resistance must also diff --git a/jdk/src/java.base/share/classes/java/security/Key.java b/jdk/src/java.base/share/classes/java/security/Key.java index 09542e394a2..0f8e84e718e 100644 --- a/jdk/src/java.base/share/classes/java/security/Key.java +++ b/jdk/src/java.base/share/classes/java/security/Key.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, 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 @@ -82,7 +82,7 @@ package java.security; *

        A Key should use KeyRep as its serialized representation. * Note that a serialized Key may contain sensitive information * which should not be exposed in untrusted environments. See the - * + * * Security Appendix * of the Serialization Specification for more information. * diff --git a/jdk/src/java.base/share/classes/java/security/KeyFactory.java b/jdk/src/java.base/share/classes/java/security/KeyFactory.java index 4d297157ebc..8171cb1b568 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyFactory.java +++ b/jdk/src/java.base/share/classes/java/security/KeyFactory.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 @@ -75,9 +75,9 @@ import sun.security.jca.GetInstance.Instance; *

      12. {@code RSA}
      13. * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> * KeyFactory section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -163,8 +163,8 @@ public class KeyFactory { * * @param algorithm the name of the requested key algorithm. * See the KeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code KeyFactory} object @@ -197,8 +197,8 @@ public class KeyFactory { * * @param algorithm the name of the requested key algorithm. * See the KeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -239,8 +239,8 @@ public class KeyFactory { * * @param algorithm the name of the requested key algorithm. * See the KeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java b/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java index 10d2f067f83..b2f87720e80 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java +++ b/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.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 @@ -114,9 +114,9 @@ import sun.security.util.Debug; *
      14. {@code RSA} (1024, 2048, 4096)
      15. * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#keypairgenerator-algorithms"> * KeyPairGenerator section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -142,8 +142,8 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi { * * @param algorithm the standard string name of the algorithm. * See the KeyPairGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keypairgenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. */ protected KeyPairGenerator(String algorithm) { @@ -153,8 +153,8 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi { /** * Returns the standard name of the algorithm for this key pair generator. * See the KeyPairGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keypairgenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the standard string name of the algorithm. @@ -205,8 +205,8 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi { * * @param algorithm the standard string name of the algorithm. * See the KeyPairGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keypairgenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code KeyPairGenerator} object @@ -264,8 +264,8 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi { * * @param algorithm the standard string name of the algorithm. * See the KeyPairGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keypairgenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the string name of the provider. @@ -306,8 +306,8 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi { * * @param algorithm the standard string name of the algorithm. * See the KeyPairGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keypairgenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/java/security/KeyRep.java b/jdk/src/java.base/share/classes/java/security/KeyRep.java index f97208f1083..9d53635f7ce 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyRep.java +++ b/jdk/src/java.base/share/classes/java/security/KeyRep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, 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 @@ -42,7 +42,7 @@ import javax.crypto.spec.SecretKeySpec; * * Note that a serialized Key may contain sensitive information * which should not be exposed in untrusted environments. See the - * + * * Security Appendix * of the Serialization Specification for more information. * diff --git a/jdk/src/java.base/share/classes/java/security/KeyStore.java b/jdk/src/java.base/share/classes/java/security/KeyStore.java index f963cae1390..fec312740f4 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyStore.java +++ b/jdk/src/java.base/share/classes/java/security/KeyStore.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 @@ -176,9 +176,9 @@ import sun.security.util.Debug; *
      16. {@code PKCS12}
      17. * * This type is described in the + * "{@docRoot}/../specs/security/standard-names.html#keystore-types"> * KeyStore section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other types are supported. * @@ -291,9 +291,8 @@ public class KeyStore { * @param protectionAlgorithm the encryption algorithm name, for * example, {@code PBEWithHmacSHA256AndAES_256}. * See the Cipher section in the - * Java Cryptography Architecture Standard Algorithm Name - * Documentation + * "{@docRoot}/../specs/security/standard-names.html#cipher-algorithm-names"> + * Java Security Standard Algorithm Names Specification * for information about standard encryption algorithm names. * @param protectionParameters the encryption algorithm parameter * specification, which may be {@code null} @@ -854,8 +853,8 @@ public class KeyStore { * * @param type the type of keystore. * See the KeyStore section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keystore-types"> + * Java Security Standard Algorithm Names Specification * for information about standard keystore types. * * @return a keystore object of the specified type @@ -895,8 +894,8 @@ public class KeyStore { * * @param type the type of keystore. * See the KeyStore section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keystore-types"> + * Java Security Standard Algorithm Names Specification * for information about standard keystore types. * * @param provider the name of the provider. @@ -941,8 +940,8 @@ public class KeyStore { * * @param type the type of keystore. * See the KeyStore section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keystore-types"> + * Java Security Standard Algorithm Names Specification * for information about standard keystore types. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/java/security/MessageDigest.java b/jdk/src/java.base/share/classes/java/security/MessageDigest.java index 692dce5a10f..14eb6d6e7fe 100644 --- a/jdk/src/java.base/share/classes/java/security/MessageDigest.java +++ b/jdk/src/java.base/share/classes/java/security/MessageDigest.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 @@ -89,9 +89,9 @@ import javax.crypto.SecretKey; *
      18. {@code SHA-256}
      19. * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> * MessageDigest section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -123,8 +123,8 @@ public abstract class MessageDigest extends MessageDigestSpi { * * @param algorithm the standard name of the digest algorithm. * See the MessageDigest section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. */ protected MessageDigest(String algorithm) { @@ -154,8 +154,8 @@ public abstract class MessageDigest extends MessageDigestSpi { * * @param algorithm the name of the algorithm requested. * See the MessageDigest section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return a {@code MessageDigest} object that implements the @@ -209,8 +209,8 @@ public abstract class MessageDigest extends MessageDigestSpi { * * @param algorithm the name of the algorithm requested. * See the MessageDigest section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -262,8 +262,8 @@ public abstract class MessageDigest extends MessageDigestSpi { * * @param algorithm the name of the algorithm requested. * See the MessageDigest section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. @@ -497,8 +497,8 @@ public abstract class MessageDigest extends MessageDigestSpi { * implementation details. The name should be a standard * Java Security name (such as "SHA", "MD5", and so on). * See the MessageDigest section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#messagedigest-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the name of the algorithm diff --git a/jdk/src/java.base/share/classes/java/security/Policy.java b/jdk/src/java.base/share/classes/java/security/Policy.java index 73737ddb525..bad4f522367 100644 --- a/jdk/src/java.base/share/classes/java/security/Policy.java +++ b/jdk/src/java.base/share/classes/java/security/Policy.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 @@ -365,8 +365,8 @@ public abstract class Policy { * * @param type the specified Policy type. See the Policy section in the * - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#policy-types"> + * Java Security Standard Algorithm Names Specification * for a list of standard Policy types. * * @param params parameters for the Policy, which may be null. @@ -419,8 +419,8 @@ public abstract class Policy { * * @param type the specified Policy type. See the Policy section in the * - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#policy-types"> + * Java Security Standard Algorithm Names Specification * for a list of standard Policy types. * * @param params parameters for the Policy, which may be null. @@ -485,8 +485,8 @@ public abstract class Policy { * * @param type the specified Policy type. See the Policy section in the * - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#policy-types"> + * Java Security Standard Algorithm Names Specification * for a list of standard Policy types. * * @param params parameters for the Policy, which may be null. diff --git a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java index ecb12785591..1a9ac151a70 100644 --- a/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java +++ b/jdk/src/java.base/share/classes/java/security/ProtectionDomain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 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 @@ -38,6 +38,7 @@ import jdk.internal.misc.JavaSecurityAccess; import jdk.internal.misc.JavaSecurityProtectionDomainAccess; import static jdk.internal.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache; import jdk.internal.misc.SharedSecrets; +import sun.security.action.GetPropertyAction; import sun.security.provider.PolicyFile; import sun.security.util.Debug; import sun.security.util.FilePermCompat; @@ -62,6 +63,14 @@ import sun.security.util.SecurityConstants; public class ProtectionDomain { + /** + * If true, {@link #impliesWithAltFilePerm} will try to be compatible on + * FilePermission checking even if a 3rd-party Policy implementation is set. + */ + private static final boolean filePermCompatInPD = + "true".equals(GetPropertyAction.privilegedGetProperty( + "jdk.security.filePermCompat")); + private static class JavaSecurityAccessImpl implements JavaSecurityAccess { private JavaSecurityAccessImpl() { @@ -321,19 +330,27 @@ public class ProtectionDomain { } /** - * This method has the same logic flow as {@link #implies} except that - * when the {@link FilePermCompat#compat} flag is on it ensures - * FilePermission compatibility after JDK-8164705. {@code implies()} - * is called when compat flag is not on or user has extended - * {@code ProtectionDomain}. + * This method has almost the same logic flow as {@link #implies} but + * it ensures some level of FilePermission compatibility after JDK-8164705. * * This method is called by {@link AccessControlContext#checkPermission} * and not intended to be called by an application. */ boolean impliesWithAltFilePerm(Permission perm) { - // If this is a subclass of ProtectionDomain. Call the old method. - if (!FilePermCompat.compat || getClass() != ProtectionDomain.class) { + // If FilePermCompat.compat is set (default value), FilePermission + // checking compatibility should be considered. + + // If filePermCompatInPD is set, this method checks for alternative + // FilePermission to keep compatibility for any Policy implementation. + // When set to false (default value), implies() is called since + // the PolicyFile implementation already supports compatibility. + + // If this is a subclass of ProtectionDomain, call implies() + // because most likely user has overridden it. + + if (!filePermCompatInPD || !FilePermCompat.compat || + getClass() != ProtectionDomain.class) { return implies(perm); } diff --git a/jdk/src/java.base/share/classes/java/security/Provider.java b/jdk/src/java.base/share/classes/java/security/Provider.java index f53660346a5..cc5313e2a19 100644 --- a/jdk/src/java.base/share/classes/java/security/Provider.java +++ b/jdk/src/java.base/share/classes/java/security/Provider.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 @@ -61,17 +61,21 @@ import java.util.function.Function; * security framework. Services of this type cannot be added, removed, * or modified by applications. * The following attributes are automatically placed in each Provider object: - * + *
        * + * * + * + * * - * + * * * * - + * * * + * *
        Attributes Automatically Placed in a Provider Object
        NameValue
        {@code Provider.id name}{@code String.valueOf(provider.getName())}{@code String.valueOf(provider.getName())}
        {@code Provider.id version}{@code String.valueOf(provider.getVersionStr())}
        {@code Provider.id info}{@code String.valueOf(provider.getInfo())}{@code String.valueOf(provider.getInfo())}
        {@code Provider.id className}{@code provider.getClass().getName()}
        * *

        Each provider has a name and a version string. A provider normally diff --git a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java index 8f84e10324e..4f0bfa4c27f 100644 --- a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java +++ b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java @@ -125,6 +125,7 @@ public class SecureClassLoader extends ClassLoader { * doesn't allow creation of a class loader. * * @since 9 + * @spec JPMS */ protected SecureClassLoader(String name, ClassLoader parent) { super(name, parent); diff --git a/jdk/src/java.base/share/classes/java/security/SecureRandom.java b/jdk/src/java.base/share/classes/java/security/SecureRandom.java index ac4ee6e7c7a..ae1f04f2896 100644 --- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java +++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.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 @@ -40,7 +40,7 @@ import sun.security.util.Debug; * *

        A cryptographically strong random number minimally complies with the * statistical random number generator tests specified in - * + * * FIPS 140-2, Security Requirements for Cryptographic Modules, * section 4.9.1. * Additionally, {@code SecureRandom} must produce non-deterministic output. @@ -64,8 +64,8 @@ import sun.security.util.Debug; *

          * SecureRandom r1 = new SecureRandom();
          * SecureRandom r2 = SecureRandom.getInstance("NativePRNG");
        - * SecureRandom r3 = SecureRandom("DRBG",
        - *         DrbgParameters.Instantiation(128, RESEED_ONLY, null));
        + * SecureRandom r3 = SecureRandom.getInstance("DRBG", + * DrbgParameters.instantiation(128, RESEED_ONLY, null)); *
        * *

        The third statement above returns a {@code SecureRandom} object of the @@ -126,7 +126,7 @@ import sun.security.util.Debug; * @implSpec * A {@code SecureRandom} service provider can advertise that it is thread-safe * by setting the service + * "{@docRoot}/../specs/security/standard-names.html#service-attributes">service * provider attribute "ThreadSafe" to "true" when registering the provider. * Otherwise, this class will instead synchronize access to the following * methods of the {@code SecureRandomSpi} implementation: @@ -203,8 +203,8 @@ public class SecureRandom extends java.util.Random { * the {@link Security#getProviders() Security.getProviders()} method. * *

        See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. */ public SecureRandom() { @@ -244,8 +244,8 @@ public class SecureRandom extends java.util.Random { * the {@link Security#getProviders() Security.getProviders()} method. * *

        See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * * @param seed the seed. @@ -341,8 +341,8 @@ public class SecureRandom extends java.util.Random { * * @param algorithm the name of the RNG algorithm. * See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * * @return the new {@code SecureRandom} object @@ -380,8 +380,8 @@ public class SecureRandom extends java.util.Random { * * @param algorithm the name of the RNG algorithm. * See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * * @param provider the name of the provider. @@ -424,8 +424,8 @@ public class SecureRandom extends java.util.Random { * * @param algorithm the name of the RNG algorithm. * See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * * @param provider the provider. @@ -478,8 +478,8 @@ public class SecureRandom extends java.util.Random { * * @param algorithm the name of the RNG algorithm. * See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * * @param params the {@code SecureRandomParameters} @@ -528,8 +528,8 @@ public class SecureRandom extends java.util.Random { * * @param algorithm the name of the RNG algorithm. * See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * * @param params the {@code SecureRandomParameters} @@ -581,8 +581,8 @@ public class SecureRandom extends java.util.Random { * * @param algorithm the name of the RNG algorithm. * See the {@code SecureRandom} section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#securerandom-number-generation-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard RNG algorithm names. * * @param params the {@code SecureRandomParameters} @@ -651,8 +651,6 @@ public class SecureRandom extends java.util.Random { * {@code SecureRandom}. * * @return the string representation - * - * @since 9 */ @Override public String toString() { diff --git a/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java b/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java index 65a0ce0164d..8443baf68ee 100644 --- a/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java +++ b/jdk/src/java.base/share/classes/java/security/SecureRandomSpi.java @@ -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 @@ -65,7 +65,7 @@ package java.security; * will synchronize access to each of the applicable engine methods * (see {@link SecureRandom} for the list of methods). However, if a * {@code SecureRandomSpi} implementation is thread-safe, the + * "{@docRoot}/../specs/security/standard-names.html#service-attributes"> * service provider attribute "ThreadSafe" should be set to "true" during * its registration, as follows: *

        @@ -211,8 +211,6 @@ public abstract class SecureRandomSpi implements java.io.Serializable {
              * {@code SecureRandom}.
              *
              * @return the string representation
        -     *
        -     * @since 9
              */
             @Override
             public String toString() {
        diff --git a/jdk/src/java.base/share/classes/java/security/Security.java b/jdk/src/java.base/share/classes/java/security/Security.java
        index 49b7e991b40..6c341abc92d 100644
        --- a/jdk/src/java.base/share/classes/java/security/Security.java
        +++ b/jdk/src/java.base/share/classes/java/security/Security.java
        @@ -1,5 +1,5 @@
         /*
        - * Copyright (c) 1996, 2015, 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
        @@ -25,11 +25,12 @@
         
         package java.security;
         
        -import java.lang.reflect.*;
         import java.util.*;
         import java.util.concurrent.ConcurrentHashMap;
         import java.io.*;
         import java.net.URL;
        +
        +import jdk.internal.misc.SharedSecrets;
         import sun.security.util.Debug;
         import sun.security.util.PropertyExpander;
         
        @@ -280,8 +281,8 @@ public final class Security {
             /**
              * Gets a specified property for an algorithm. The algorithm name
              * should be a standard name. See the 
        -     * Java Cryptography Architecture Standard Algorithm Name Documentation
        +     * "{@docRoot}/../specs/security/standard-names.html">
        +     * Java Security Standard Algorithm Names Specification
              * for information about standard algorithm names.
              *
              * One possible use is by specialized algorithm parsers, which may map
        @@ -510,8 +511,8 @@ public final class Security {
              * 
              *
              * 

        See the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html"> + * Java Security Standard Algorithm Names Specification * for information about standard cryptographic service names, standard * algorithm names and standard attribute names. * @@ -581,8 +582,8 @@ public final class Security { * * *

        See the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html"> + * Java Security Standard Algorithm Names Specification * for information about standard cryptographic service names, standard * algorithm names and standard attribute names. * @@ -800,9 +801,6 @@ public final class Security { * "package.definition", we need to signal to the SecurityManager * class that the value has just changed, and that it should * invalidate it's local cache values. - * - * Rather than create a new API entry for this function, - * we use reflection to set a private variable. */ private static void invalidateSMCache(String key) { @@ -810,42 +808,8 @@ public final class Security { final boolean pd = key.equals("package.definition"); if (pa || pd) { - AccessController.doPrivileged(new PrivilegedAction<>() { - public Void run() { - try { - /* Get the class via the bootstrap class loader. */ - Class cl = Class.forName( - "java.lang.SecurityManager", false, null); - Field f = null; - boolean accessible = false; - - if (pa) { - f = cl.getDeclaredField("packageAccessValid"); - accessible = f.isAccessible(); - f.setAccessible(true); - } else { - f = cl.getDeclaredField("packageDefinitionValid"); - accessible = f.isAccessible(); - f.setAccessible(true); - } - f.setBoolean(f, false); - f.setAccessible(accessible); - } - catch (Exception e1) { - /* If we couldn't get the class, it hasn't - * been loaded yet. If there is no such - * field, we shouldn't try to set it. There - * shouldn't be a security execption, as we - * are loaded by boot class loader, and we - * are inside a doPrivileged() here. - * - * NOOP: don't do anything... - */ - } - return null; - } /* run */ - }); /* PrivilegedAction */ - } /* if */ + SharedSecrets.getJavaLangAccess().invalidatePackageAccessCache(); + } } private static void check(String directive) { diff --git a/jdk/src/java.base/share/classes/java/security/SecurityPermission.java b/jdk/src/java.base/share/classes/java/security/SecurityPermission.java index 8234624d26e..e0d25c9689f 100644 --- a/jdk/src/java.base/share/classes/java/security/SecurityPermission.java +++ b/jdk/src/java.base/share/classes/java/security/SecurityPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, 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 @@ -45,12 +45,16 @@ import java.util.StringTokenizer; * target names, and for each provides a description of what the permission * allows and a discussion of the risks of granting code the permission. * - * + *
        + * + * * * * * * + * + * * * * @@ -196,6 +200,7 @@ import java.util.StringTokenizer; * described under the "removeProvider.{provider name}" permission. * * + * *
        target name, what the permission allows, and associated risks
        Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
        authProvider.{provider name}
        * *

        @@ -204,13 +209,17 @@ import java.util.StringTokenizer; * {@link IdentityScope}, {@link Signer}. Use of them is discouraged. See the * applicable classes for more information. * - * + *
        + * + * * * * * * + * * + * * * * @@ -308,6 +317,7 @@ import java.util.StringTokenizer; * data encrypted under that session key. * * + * *
        target name, what the permission allows, and associated risks
        Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
        insertProvider.{provider name}Addition of a new provider, with the specified name
        * * @implNote diff --git a/jdk/src/java.base/share/classes/java/security/Signature.java b/jdk/src/java.base/share/classes/java/security/Signature.java index df5350e99f1..fd5dfad650a 100644 --- a/jdk/src/java.base/share/classes/java/security/Signature.java +++ b/jdk/src/java.base/share/classes/java/security/Signature.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 @@ -106,9 +106,9 @@ import sun.security.jca.GetInstance.Instance; *

      20. {@code SHA256withRSA}
      21. * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#signature-algorithms"> * Signature section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -164,8 +164,8 @@ public abstract class Signature extends SignatureSpi { * * @param algorithm the standard string name of the algorithm. * See the Signature section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#signature-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. */ protected Signature(String algorithm) { @@ -209,8 +209,8 @@ public abstract class Signature extends SignatureSpi { * * @param algorithm the standard name of the algorithm requested. * See the Signature section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#signature-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code Signature} object @@ -332,8 +332,8 @@ public abstract class Signature extends SignatureSpi { * * @param algorithm the name of the algorithm requested. * See the Signature section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#signature-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -385,8 +385,8 @@ public abstract class Signature extends SignatureSpi { * * @param algorithm the name of the algorithm requested. * See the Signature section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#signature-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/java/security/cert/CertPath.java b/jdk/src/java.base/share/classes/java/security/cert/CertPath.java index 88df135f6c0..295c5aa8804 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/CertPath.java +++ b/jdk/src/java.base/share/classes/java/security/cert/CertPath.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 @@ -91,9 +91,9 @@ import java.util.List; *
      22. {@code PkiPath}
      23. * * These encodings are described in the + * "{@docRoot}/../specs/security/standard-names.html#certpath-encodings"> * CertPath Encodings section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other encodings are supported. *

        diff --git a/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java b/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java index 12f608816be..46d5c77580c 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.java +++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathBuilder.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 @@ -72,9 +72,9 @@ import sun.security.jca.GetInstance.Instance; *

      24. {@code PKIX}
      25. * * This algorithm is described in the + * "{@docRoot}/../specs/security/standard-names.html#certpathbuilder-algorithms"> * CertPathBuilder section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -152,8 +152,8 @@ public class CertPathBuilder { * * @param algorithm the name of the requested {@code CertPathBuilder} * algorithm. See the CertPathBuilder section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certpathbuilder-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return a {@code CertPathBuilder} object that implements the @@ -190,8 +190,8 @@ public class CertPathBuilder { * * @param algorithm the name of the requested {@code CertPathBuilder} * algorithm. See the CertPathBuilder section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certpathbuilder-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -233,8 +233,8 @@ public class CertPathBuilder { * * @param algorithm the name of the requested {@code CertPathBuilder} * algorithm. See the CertPathBuilder section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certpathbuilder-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java b/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java index 298923d84a2..57efedd3348 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.java +++ b/jdk/src/java.base/share/classes/java/security/cert/CertPathValidator.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 @@ -74,9 +74,9 @@ import sun.security.jca.GetInstance.Instance; *
      26. {@code PKIX}
      27. * * This algorithm is described in the + * "{@docRoot}/../specs/security/standard-names.html#certpathvalidator-algorithms"> * CertPathValidator section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -152,9 +152,9 @@ public class CertPathValidator { * {@link Security#getProviders() Security.getProviders()}. * * @param algorithm the name of the requested {@code CertPathValidator} - * algorithm. See the CertPathValidator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * algorithm. See the CertPathValidator section in the + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return a {@code CertPathValidator} object that implements the @@ -190,9 +190,9 @@ public class CertPathValidator { * the {@link Security#getProviders() Security.getProviders()} method. * * @param algorithm the name of the requested {@code CertPathValidator} - * algorithm. See the CertPathValidator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * algorithm. See the CertPathValidator section in the + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -235,8 +235,8 @@ public class CertPathValidator { * * @param algorithm the name of the requested {@code CertPathValidator} * algorithm. See the CertPathValidator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certpathvalidator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/java/security/cert/CertStore.java b/jdk/src/java.base/share/classes/java/security/cert/CertStore.java index e62d39f27b0..0d7675c13af 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/CertStore.java +++ b/jdk/src/java.base/share/classes/java/security/cert/CertStore.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 @@ -67,9 +67,9 @@ import sun.security.jca.GetInstance.Instance; *
      28. {@code Collection}
      29. * * This type is described in the + * "{@docRoot}/../specs/security/standard-names.html#certstore-types"> * CertStore section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other types are supported. * @@ -212,8 +212,8 @@ public class CertStore { * * @param type the name of the requested {@code CertStore} type. * See the CertStore section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certstore-types"> + * Java Security Standard Algorithm Names Specification * for information about standard types. * * @param params the initialization parameters (may be {@code null}). @@ -276,8 +276,8 @@ public class CertStore { * * @param type the requested {@code CertStore} type. * See the CertStore section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certstore-types"> + * Java Security Standard Algorithm Names Specification * for information about standard types. * * @param params the initialization parameters (may be {@code null}). @@ -337,8 +337,8 @@ public class CertStore { * * @param type the requested {@code CertStore} type. * See the CertStore section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certstore-types"> + * Java Security Standard Algorithm Names Specification * for information about standard types. * * @param params the initialization parameters (may be {@code null}). diff --git a/jdk/src/java.base/share/classes/java/security/cert/Certificate.java b/jdk/src/java.base/share/classes/java/security/cert/Certificate.java index 6923627ce7b..32662ceea15 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/Certificate.java +++ b/jdk/src/java.base/share/classes/java/security/cert/Certificate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, 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 @@ -74,8 +74,8 @@ public abstract class Certificate implements java.io.Serializable { * * @param type the standard name of the certificate type. * See the CertificateFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certificatefactory-types"> + * Java Security Standard Algorithm Names Specification * for information about standard certificate types. */ protected Certificate(String type) { diff --git a/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java b/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java index e63c3b403d4..ae4e8bd05c4 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java +++ b/jdk/src/java.base/share/classes/java/security/cert/CertificateFactory.java @@ -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 @@ -101,11 +101,11 @@ import sun.security.jca.GetInstance.Instance; *
      30. {@code PkiPath}
      31. * * The type and encodings are described in the + * "{@docRoot}/../specs/security/standard-names.html#certificatefactory-types"> * CertificateFactory section and the + * "{@docRoot}/../specs/security/standard-names.html#certpath-encodings"> * CertPath Encodings section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other types or encodings are supported. * @@ -172,8 +172,8 @@ public class CertificateFactory { * * @param type the name of the requested certificate type. * See the CertificateFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certificatefactory-types"> + * Java Security Standard Algorithm Names Specification * for information about standard certificate types. * * @return a certificate factory object for the specified type @@ -213,8 +213,8 @@ public class CertificateFactory { * * @param type the certificate type. * See the CertificateFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certificatefactory-types"> + * Java Security Standard Algorithm Names Specification * for information about standard certificate types. * * @param provider the name of the provider. @@ -260,8 +260,8 @@ public class CertificateFactory { * * @param type the certificate type. * See the CertificateFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certificatefactory-types"> + * Java Security Standard Algorithm Names Specification * for information about standard certificate types. * @param provider the provider. * @@ -359,8 +359,8 @@ public class CertificateFactory { * Returns an iteration of the {@code CertPath} encodings supported * by this certificate factory, with the default encoding first. See * the CertPath Encodings section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certpath-encodings"> + * Java Security Standard Algorithm Names Specification * for information about standard encoding names and their formats. *

        * Attempts to modify the returned {@code Iterator} via its @@ -399,8 +399,8 @@ public class CertificateFactory { * the data read from the {@code InputStream} inStream. The data * is assumed to be in the specified encoding. See * the CertPath Encodings section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certpath-encodings"> + * Java Security Standard Algorithm Names Specification * for information about standard encoding names and their formats. * * @param inStream an {@code InputStream} containing the data diff --git a/jdk/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.java b/jdk/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.java index 35aee847bb8..0b1bb337b3f 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.java +++ b/jdk/src/java.base/share/classes/java/security/cert/CertificateFactorySpi.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 @@ -183,8 +183,8 @@ public abstract class CertificateFactorySpi { * Returns an iteration of the {@code CertPath} encodings supported * by this certificate factory, with the default encoding first. See * the CertPath Encodings section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#certpath-encodings"> + * Java Security Standard Algorithm Names Specification * for information about standard encoding names. *

        * Attempts to modify the returned {@code Iterator} via its diff --git a/jdk/src/java.base/share/classes/java/security/cert/X509Extension.java b/jdk/src/java.base/share/classes/java/security/cert/X509Extension.java index 03469606eed..9a988f4dc93 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/X509Extension.java +++ b/jdk/src/java.base/share/classes/java/security/cert/X509Extension.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 @@ -152,10 +152,14 @@ public interface X509Extension { * by periods. * *

        For example:
        - * + *
        + * + * * * * + * + * * * * @@ -176,6 +180,7 @@ public interface X509Extension { * * * + * *
        Examples of OIDs and extension names
        OID (Object Identifier)Extension Name
        2.5.29.14SubjectKeyIdentifier
        2.5.29.15AuthorityKeyIdentifier
        2.5.29.36PolicyConstraints
        * * @param oid the Object Identifier value for the extension. diff --git a/jdk/src/java.base/share/classes/java/security/cert/package-info.java b/jdk/src/java.base/share/classes/java/security/cert/package-info.java index 58f5fb77e0a..50b0f2c9672 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/package-info.java +++ b/jdk/src/java.base/share/classes/java/security/cert/package-info.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 @@ -39,10 +39,9 @@ * Certificate Revocation List (CRL) Profile *

      32. RFC 2560: X.509 Internet Public Key Infrastructure Online Certificate * Status Protocol - OCSP - *
      33. - * Java™ - * Cryptography Architecture Standard Algorithm Name - * Documentation
      34. + *
      35. + * Java™ Security Standard Algorithm Names Specification + *
      36. * * *

        Related Documentation

        diff --git a/jdk/src/java.base/share/classes/java/security/package-info.java b/jdk/src/java.base/share/classes/java/security/package-info.java index 2c8205b09b9..edb91899da8 100644 --- a/jdk/src/java.base/share/classes/java/security/package-info.java +++ b/jdk/src/java.base/share/classes/java/security/package-info.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,10 +53,9 @@ *
      37. PKCS #8: Private-Key Information Syntax Standard, Version 1.2, * November 1993
      38. * - *
      39. - * Java™ - * Cryptography Architecture Standard Algorithm Name - * Documentation
      40. + *
      41. + * Java™ Security Standard Algorithm Names Specification + *
      42. * * *

        Related Documentation

        diff --git a/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java b/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java index 5aca225d2b2..99b5a04655a 100644 --- a/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java +++ b/jdk/src/java.base/share/classes/java/security/spec/EncodedKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -67,8 +67,8 @@ public abstract class EncodedKeySpec implements KeySpec { * array are copied to protect against subsequent modification. * @param algorithm the algorithm name of the encoded key * See the KeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. diff --git a/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java b/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java index 198ca604b8c..73d79a41321 100644 --- a/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java +++ b/jdk/src/java.base/share/classes/java/security/spec/PKCS8EncodedKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, 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 @@ -85,8 +85,8 @@ public class PKCS8EncodedKeySpec extends EncodedKeySpec { * the array are copied to protect against subsequent modification. * @param algorithm the algorithm name of the encoded private key * See the KeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. diff --git a/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java b/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java index 2d23570fe3d..7de4a2a1417 100644 --- a/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java +++ b/jdk/src/java.base/share/classes/java/security/spec/X509EncodedKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -75,8 +75,8 @@ public class X509EncodedKeySpec extends EncodedKeySpec { * array are copied to protect against subsequent modification. * @param algorithm the algorithm name of the encoded public key * See the KeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * @throws NullPointerException if {@code encodedKey} * or {@code algorithm} is null. diff --git a/jdk/src/java.base/share/classes/java/text/BreakIterator.java b/jdk/src/java.base/share/classes/java/text/BreakIterator.java index f5e53c4d4f9..0c780258e47 100644 --- a/jdk/src/java.base/share/classes/java/text/BreakIterator.java +++ b/jdk/src/java.base/share/classes/java/text/BreakIterator.java @@ -68,19 +68,19 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * (word, line, sentence, and so on). You must use a different iterator * for each unit boundary analysis you wish to perform. * - *

        + *

        * Line boundary analysis determines where a text string can be * broken when line-wrapping. The mechanism correctly handles * punctuation and hyphenated words. Actual line breaking needs * to also consider the available line width and is handled by * higher-level software. * - *

        + *

        * Sentence boundary analysis allows selection with correct interpretation * of periods within numbers and abbreviations, and trailing punctuation * marks such as quotation marks and parentheses. * - *

        + *

        * Word boundary analysis is used by search and replace functions, as * well as within text editing applications that allow the user to * select words with a double click. Word selection provides correct @@ -88,7 +88,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * words. Characters that are not part of a word, such as symbols * or punctuation marks, have word-breaks on both sides. * - *

        + *

        * Character boundary analysis allows users to interact with characters * as they expect to, for example, when moving the cursor through a text * string. Character boundary analysis provides correct navigation diff --git a/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java b/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java index e8fa564ec26..8f76aaedf04 100644 --- a/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java +++ b/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java @@ -151,7 +151,7 @@ import java.util.Arrays; * }

        *
        * - *

        Synchronization

        + *

        Synchronization

        * *

        * Choice formats are not synchronized. diff --git a/jdk/src/java.base/share/classes/java/text/DateFormat.java b/jdk/src/java.base/share/classes/java/text/DateFormat.java index 3b689b534f3..620dbe87372 100644 --- a/jdk/src/java.base/share/classes/java/text/DateFormat.java +++ b/jdk/src/java.base/share/classes/java/text/DateFormat.java @@ -133,7 +133,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * on the screen. * * - *

        Synchronization

        + *

        Synchronization

        * *

        * Date formats are not synchronized. diff --git a/jdk/src/java.base/share/classes/java/text/DecimalFormat.java b/jdk/src/java.base/share/classes/java/text/DecimalFormat.java index 3e2a44a2d6c..eb5107cdea4 100644 --- a/jdk/src/java.base/share/classes/java/text/DecimalFormat.java +++ b/jdk/src/java.base/share/classes/java/text/DecimalFormat.java @@ -172,60 +172,63 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter; * are not localized. * *

        - * - * - * + *
        Symbol - * Location - * Localized? - * Meaning - *
        + * + * + * + * + * + * * + * * + * * + * * + * * + * * + * * + * * + * * + * * + * * *
        Chart showing symbol, location, localized, and meaning.
        Symbol + * Location + * Localized? + * Meaning + *
        0 * Number * Yes * Digit - *
        # * Number * Yes * Digit, zero shows as absent - *
        . * Number * Yes * Decimal separator or monetary decimal separator - *
        - * Number * Yes * Minus sign - *
        , * Number * Yes * Grouping separator - *
        E * Number * Yes * Separates mantissa and exponent in scientific notation. * Need not be quoted in prefix or suffix. - *
        ; * Subpattern boundary * Yes * Separates positive and negative subpatterns - *
        % * Prefix or suffix * Yes * Multiply by 100 and show as percentage - *
        \u2030 * Prefix or suffix * Yes * Multiply by 1000 and show as per mille value - *
        ¤ (\u00A4) * Prefix or suffix * No @@ -233,7 +236,7 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter; * doubled, replaced by international currency symbol. * If present in a pattern, the monetary decimal separator * is used instead of the decimal separator. - *
        ' * Prefix or suffix * No @@ -241,6 +244,7 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter; * for example, "'#'#" formats 123 to * "#123". To create a single quote * itself, use two in a row: "# o''clock". + *
        *
        * @@ -327,7 +331,7 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter; * and isParseIntegerOnly() are false. * * - *

        Synchronization

        + *

        Synchronization

        * *

        * Decimal formats are generally not synchronized. diff --git a/jdk/src/java.base/share/classes/java/text/Format.java b/jdk/src/java.base/share/classes/java/text/Format.java index f24b4ee0083..ee6fb4d1fb7 100644 --- a/jdk/src/java.base/share/classes/java/text/Format.java +++ b/jdk/src/java.base/share/classes/java/text/Format.java @@ -115,7 +115,7 @@ import java.io.Serializable; * the field. For examples of these constants, see ERA_FIELD and its * friends in {@link DateFormat}. * - *

        Synchronization

        + *

        Synchronization

        * *

        * Formats are generally not synchronized. diff --git a/jdk/src/java.base/share/classes/java/text/MessageFormat.java b/jdk/src/java.base/share/classes/java/text/MessageFormat.java index b1e0eb70e21..1275f3cc33a 100644 --- a/jdk/src/java.base/share/classes/java/text/MessageFormat.java +++ b/jdk/src/java.base/share/classes/java/text/MessageFormat.java @@ -68,7 +68,7 @@ import java.util.Locale; * behavior is defined by the pattern that you provide as well as the * subformats used for inserted arguments. * - *

        Patterns and Their Interpretation

        + *

        Patterns and Their Interpretation

        * * MessageFormat uses patterns of the following form: *
        @@ -146,11 +146,15 @@ import java.util.Locale;
          * shown in the table are illegal. A SubformatPattern must
          * be a valid pattern string for the {@code Format} subclass used.
          *
        - * 
        + * 
        + * + * * * + * * * *
        Shows how FormatType and FormatStyle values map to Format instances
        FormatType * FormatStyle * Subformat Created + *
        (none) * (none) @@ -213,6 +217,7 @@ import java.util.Locale; * choice * SubformatPattern * {@code new} {@link ChoiceFormat#ChoiceFormat(String) ChoiceFormat}{@code (subformatPattern)} + *
        * *

        Usage Information

        @@ -321,7 +326,7 @@ import java.util.Locale; * // result now equals {new String("z")} *
        * - *

        Synchronization

        + *

        Synchronization

        * *

        * Message formats are not synchronized. @@ -766,11 +771,15 @@ public class MessageFormat extends Format { * argument is unavailable if arguments is * null or has fewer than argumentIndex+1 elements. * - * + *
        + * + * * * + * * * *
        Examples of subformat,argument,and formatted text
        Subformat * Argument * Formatted Text + *
        any * unavailable @@ -805,6 +814,7 @@ public class MessageFormat extends Format { * null * any * argument.toString() + *
        *

        * If pos is non-null, and refers to diff --git a/jdk/src/java.base/share/classes/java/text/NumberFormat.java b/jdk/src/java.base/share/classes/java/text/NumberFormat.java index 73dbfea6dab..7e86bbe35d5 100644 --- a/jdk/src/java.base/share/classes/java/text/NumberFormat.java +++ b/jdk/src/java.base/share/classes/java/text/NumberFormat.java @@ -166,7 +166,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * numbers: "(12)" for -12. * * - *

        Synchronization

        + *

        Synchronization

        * *

        * Number formats are generally not synchronized. diff --git a/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java b/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java index 00b2b969670..70987ad99df 100644 --- a/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java +++ b/jdk/src/java.base/share/classes/java/text/SimpleDateFormat.java @@ -92,18 +92,22 @@ import sun.util.locale.provider.LocaleProviderAdapter; * 'A' to 'Z' and from 'a' to * 'z' are reserved): *

        - * - * - *
        Letter - * Date or Time Component - * Presentation - * Examples + * + * + * + * + * + * * * + * * + * * + * * + * * + * * + * * + * * + * * + * * + * * + * * *
        Chart shows pattern letters, date/time component, presentation, and examples.
        Letter + * Date or Time Component + * Presentation + * Examples + *
        G * Era designator * Text * AD - *
        y * Year * Year @@ -113,7 +117,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Week year * Year * 2009; 09 - *
        M * Month in year (context sensitive) * Month @@ -123,7 +127,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Month in year (standalone form) * Month * July; Jul; 07 - *
        w * Week in year * Number @@ -133,7 +137,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Week in month * Number * 2 - *
        D * Day in year * Number @@ -143,7 +147,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Day in month * Number * 10 - *
        F * Day of week in month * Number @@ -153,7 +157,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Day name in week * Text * Tuesday; Tue - *
        u * Day number of week (1 = Monday, ..., 7 = Sunday) * Number @@ -163,7 +167,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Am/pm marker * Text * PM - *
        H * Hour in day (0-23) * Number @@ -173,7 +177,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Hour in day (1-24) * Number * 24 - *
        K * Hour in am/pm (0-11) * Number @@ -183,7 +187,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Hour in am/pm (1-12) * Number * 12 - *
        m * Minute in hour * Number @@ -193,7 +197,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Second in minute * Number * 55 - *
        S * Millisecond * Number @@ -203,7 +207,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Time zone * General time zone * Pacific Standard Time; PST; GMT-08:00 - *
        Z * Time zone * RFC 822 time zone @@ -213,23 +217,24 @@ import sun.util.locale.provider.LocaleProviderAdapter; * Time zone * ISO 8601 time zone * -08; -0800; -08:00 + *
        * * Pattern letters are usually repeated, as their number determines the * exact presentation: *
          - *
        • Text: + *
        • Text: * For formatting, if the number of pattern letters is 4 or more, * the full form is used; otherwise a short or abbreviated form * is used if available. * For parsing, both forms are accepted, independent of the number * of pattern letters.

        • - *
        • Number: + *
        • Number: * For formatting, the number of pattern letters is the minimum * number of digits, and shorter numbers are zero-padded to this amount. * For parsing, the number of pattern letters is ignored unless * it's needed to separate two adjacent fields.

        • - *
        • Year: + *
        • Year: * If the formatter's {@link #getCalendar() Calendar} is the Gregorian * calendar, the following rules are applied.
          *
            @@ -270,7 +275,7 @@ import sun.util.locale.provider.LocaleProviderAdapter; * DateFormat#getCalendar() getCalendar()}.{@link * java.util.Calendar#isWeekDateSupported() * isWeekDateSupported()}.

            - *
          • Month: + *
          • Month: * If the number of pattern letters is 3 or more, the month is * interpreted as text; otherwise, * it is interpreted as a number.
            @@ -291,12 +296,12 @@ import sun.util.locale.provider.LocaleProviderAdapter; *
          • Letter L produces the standalone form of month names.
          • *
          *
        • - *
        • General time zone: + *
        • General time zone: * Time zones are interpreted as text if they have * names. For time zones representing a GMT offset value, the * following syntax is used: *
          - *     GMTOffsetTimeZone:
          + *     GMTOffsetTimeZone:
            *             GMT Sign Hours : Minutes
            *     Sign: one of
            *             + -
          @@ -312,7 +317,7 @@ import sun.util.locale.provider.LocaleProviderAdapter;
            *     from the Basic Latin block of the Unicode standard.
            *     

          For parsing, RFC 822 time zones are also * accepted.

        • - *
        • RFC 822 time zone: + *
        • RFC 822 time zone: * For formatting, the RFC 822 4-digit time zone format is used: * *
          @@ -325,7 +330,7 @@ import sun.util.locale.provider.LocaleProviderAdapter;
            *
            *     

          For parsing, general time zones are also * accepted. - *

        • ISO 8601 Time zone: + *
        • ISO 8601 Time zone: * The number of pattern letters designates the format for both formatting * and parsing as follows: *
          @@ -370,47 +375,52 @@ import sun.util.locale.provider.LocaleProviderAdapter;
            * the U.S. locale. The given date and time are 2001-07-04 12:08:56 local time
            * in the U.S. Pacific Time time zone.
            * 
          - * - * - *
          Date and Time Pattern - * Result + * + * + * + * + * + * * * + * * * + * * * + * * * + * * * + * * * *
          Examples of date and time patterns interpreted in the U.S. locale
          Date and Time Pattern + * Result + *
          "yyyy.MM.dd G 'at' HH:mm:ss z" * 2001.07.04 AD at 12:08:56 PDT - *
          "EEE, MMM d, ''yy" * Wed, Jul 4, '01 *
          "h:mm a" * 12:08 PM - *
          "hh 'o''clock' a, zzzz" * 12 o'clock PM, Pacific Daylight Time *
          "K:mm a, z" * 0:08 PM, PDT - *
          "yyyyy.MMMMM.dd GGG hh:mm aaa" * 02001.July.04 AD 12:08 PM *
          "EEE, d MMM yyyy HH:mm:ss Z" * Wed, 4 Jul 2001 12:08:56 -0700 - *
          "yyMMddHHmmssZ" * 010704120856-0700 *
          "yyyy-MM-dd'T'HH:mm:ss.SSSZ" * 2001-07-04T12:08:56.235-0700 - *
          "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" * 2001-07-04T12:08:56.235-07:00 *
          "YYYY-'W'ww-u" * 2001-W27-3 + *
          * * - *

          Synchronization

          + *

          Synchronization

          * *

          * Date formats are not synchronized. diff --git a/jdk/src/java.base/share/classes/java/time/Duration.java b/jdk/src/java.base/share/classes/java/time/Duration.java index cacd3999a83..875b9e07761 100644 --- a/jdk/src/java.base/share/classes/java/time/Duration.java +++ b/jdk/src/java.base/share/classes/java/time/Duration.java @@ -1370,6 +1370,7 @@ public final class Duration * @return a {@code Duration} based on this duration with the time truncated, not null * @throws DateTimeException if the unit is invalid for truncation * @throws UnsupportedTemporalTypeException if the unit is not supported + * @since 9 */ public Duration truncatedTo(TemporalUnit unit) { Objects.requireNonNull(unit, "unit"); diff --git a/jdk/src/java.base/share/classes/java/time/chrono/Era.java b/jdk/src/java.base/share/classes/java/time/chrono/Era.java index f8945fa0aec..5cf0968597c 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/Era.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/Era.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -310,8 +310,8 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { * The parameters control the style of the returned text and the locale. *

          * If no textual mapping is found then the {@link #getValue() numeric value} is returned. - *

          - * This default implementation is suitable for all implementations. + * + * @apiNote This default implementation is suitable for most implementations. * * @param style the style of the text required, not null * @param locale the locale to use, not null diff --git a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java index d61c2333303..0ec1b591bc2 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.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 @@ -103,17 +103,18 @@ import sun.util.logging.PlatformLogger; * *

          * CLDR and LDML identify variants: - * + *
          + * * - * - * - * - * - * + * + * + * + * + * * * * - * + * * * * @@ -147,36 +148,37 @@ import sun.util.logging.PlatformLogger; *

          * The Hijrah property resource is a set of properties that describe the calendar. * The syntax is defined by {@code java.util.Properties#load(Reader)}. - *

          Variants of Hijrah Calendars
          Chronology IDCalendar TypeLocale extension, see {@link java.util.Locale}Description
          Chronology IDCalendar TypeLocale extension, see {@link java.util.Locale}Description
          Hijrah-umalquraislamic-umalquraca-islamic-umalqura
          + *
          + * * - * - * - * - * + * + * + * + * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * @@ -813,8 +815,9 @@ public final class HijrahChronology extends AbstractChronology implements Serial private Properties readConfigProperties(final String calendarType) throws Exception { String resourceName = RESOURCE_PREFIX + calendarType + RESOURCE_SUFFIX; PrivilegedAction getResourceAction = () -> HijrahChronology.class.getResourceAsStream(resourceName); - FilePermission perm = new FilePermission("<>", "read"); - try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm)) { + FilePermission perm1 = new FilePermission("<>", "read"); + RuntimePermission perm2 = new RuntimePermission("accessSystemModules"); + try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm1, perm2)) { if (is == null) { throw new RuntimeException("Hijrah calendar resource not found: /java/time/chrono/" + resourceName); } diff --git a/jdk/src/java.base/share/classes/java/time/chrono/IsoEra.java b/jdk/src/java.base/share/classes/java/time/chrono/IsoEra.java index bd299691ace..702fabdf920 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/IsoEra.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/IsoEra.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -70,25 +70,26 @@ import java.time.DateTimeException; * A definition has therefore been created with two eras - 'Current era' (CE) for * years on or after 0001-01-01 (ISO), and 'Before current era' (BCE) for years before that. * - *
          Configuration of Hijrah Calendar
          Property Name Property value Description
          Property Name Property value Description
          idChronology Id, for example, "Hijrah-umalqura"The Id of the calendar in common usage
          typeCalendar type, for example, "islamic-umalqura"LDML defines the calendar types
          versionVersion, for example: "1.8.0_1"The version of the Hijrah variant data
          iso-startISO start date, formatted as {@code yyyy-MM-dd}, for example: "1900-04-30"The ISO date of the first day of the minimum Hijrah year.
          yyyy - a numeric 4 digit year, for example "1434"The value is a sequence of 12 month lengths, * for example: "29 30 29 30 29 30 30 30 29 30 29 29"
          + *
          + * * - * - * - * - * + * + * + * + * * * * - * + * * * - * + * * * - * + * * * - * + * * * * diff --git a/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java b/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java index 7ae62944025..e6fadc902ae 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -240,19 +240,10 @@ public final class JapaneseEra } /** - * Gets the textual representation of this era. - *

          - * This returns the textual name used to identify the era, - * suitable for presentation to the user. - * The parameters control the style of the returned text and the locale. - *

          - * If no textual mapping is found then the {@link #getValue() numeric value} - * is returned. + * {@inheritDoc} * - * @param style the style of the text required, not null - * @param locale the locale to use, not null - * @return the text value of the era, not null - * @since 9 + * @param style {@inheritDoc} + * @param locale {@inheritDoc} */ @Override public String getDisplayName(TextStyle style, Locale locale) { diff --git a/jdk/src/java.base/share/classes/java/time/chrono/MinguoEra.java b/jdk/src/java.base/share/classes/java/time/chrono/MinguoEra.java index fd96de196ee..edac0ec02e7 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/MinguoEra.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/MinguoEra.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -71,26 +71,27 @@ import java.time.DateTimeException; * All previous years, zero or earlier in the proleptic count or one and greater * in the year-of-era count, are part of the 'Before Republic of China' era. * - *

          ISO years and eras
          year-of-eraeraproleptic-year
          year-of-eraeraproleptic-year
          2CE2
          1CE1
          1BCE0
          2BCE-1
          + *
          + * * - * - * - * - * - * + * + * + * + * + * * * * - * + * * * - * + * * * - * + * * * - * + * * * * diff --git a/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistEra.java b/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistEra.java index e3e6e86fa45..53cb5d870be 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistEra.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistEra.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -71,26 +71,27 @@ import java.time.DateTimeException; * All previous years, zero or earlier in the proleptic count or one and greater * in the year-of-era count, are part of the 'Before Buddhist' era. * - *
          Minguo years and eras
          year-of-eraeraproleptic-yearISO proleptic-year
          year-of-eraeraproleptic-yearISO proleptic-year
          2ROC21913
          1ROC11912
          1BEFORE_ROC01911
          2BEFORE_ROC-11910
          + *
          + * * - * - * - * - * - * + * + * + * + * + * * * * - * + * * * - * + * * * - * + * * * - * + * * * * diff --git a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java index c705fcafe88..cda0f8abb48 100644 --- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java +++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -150,105 +150,106 @@ import java.util.Set; * implementation of {@code java.text.Format}. * *

          Predefined Formatters

          - *
          Buddhist years and eras
          year-of-eraeraproleptic-yearISO proleptic-year
          year-of-eraeraproleptic-yearISO proleptic-year
          2BE2-542
          1BE1-543
          1BEFORE_BE0-544
          2BEFORE_BE-1-545
          + *
          + * * - * - * - * - * + * + * + * + * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * - * + * * * * * - * + * * * * diff --git a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java index 8fe990a4f05..f734fdd9d02 100644 --- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -1278,6 +1278,7 @@ public final class DateTimeFormatterBuilder { * * @param textStyle the text style to use, not null * @return this, for chaining, not null + * @since 9 */ public DateTimeFormatterBuilder appendGenericZoneText(TextStyle textStyle) { appendInternal(new ZoneTextPrinterParser(textStyle, null, true)); @@ -1303,6 +1304,7 @@ public final class DateTimeFormatterBuilder { * @param textStyle the text style to use, not null * @param preferredZones the set of preferred zone ids, not null * @return this, for chaining, not null + * @since 9 */ public DateTimeFormatterBuilder appendGenericZoneText(TextStyle textStyle, Set preferredZones) { diff --git a/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java b/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java index 26e7e168446..9740a9defc0 100644 --- a/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java +++ b/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -136,15 +136,19 @@ import sun.util.locale.provider.LocaleResources; *

          * For example: * - *

          Predefined Formatters
          FormatterDescriptionExample
          FormatterDescriptionExample
          {@link #ofLocalizedDate ofLocalizedDate(dateStyle)} Formatter with date style from the locale '2011-12-03'
          {@link #ofLocalizedTime ofLocalizedTime(timeStyle)} Formatter with time style from the locale '10:15:30'
          {@link #ofLocalizedDateTime ofLocalizedDateTime(dateTimeStyle)} Formatter with a style for date and time from the locale '3 Jun 2008 11:05:30'
          {@link #ofLocalizedDateTime ofLocalizedDateTime(dateStyle,timeStyle)} * Formatter with date and time styles from the locale '3 Jun 2008 11:05'
          {@link #BASIC_ISO_DATE}Basic ISO date '20111203'
          {@link #ISO_LOCAL_DATE} ISO Local Date '2011-12-03'
          {@link #ISO_OFFSET_DATE} ISO Date with offset '2011-12-03+01:00'
          {@link #ISO_DATE} ISO Date with or without offset '2011-12-03+01:00'; '2011-12-03'
          {@link #ISO_LOCAL_TIME} Time without offset '10:15:30'
          {@link #ISO_OFFSET_TIME} Time with offset '10:15:30+01:00'
          {@link #ISO_TIME} Time with or without offset '10:15:30+01:00'; '10:15:30'
          {@link #ISO_LOCAL_DATE_TIME} ISO Local Date and Time '2011-12-03T10:15:30'
          {@link #ISO_OFFSET_DATE_TIME} Date Time with Offset * 2011-12-03T10:15:30+01:00'
          {@link #ISO_ZONED_DATE_TIME} Zoned Date Time '2011-12-03T10:15:30+01:00[Europe/Paris]'
          {@link #ISO_DATE_TIME} Date and time with ZoneId '2011-12-03T10:15:30+01:00[Europe/Paris]'
          {@link #ISO_ORDINAL_DATE} Year and day of year '2012-337'
          {@link #ISO_WEEK_DATE} Year and Week 2012-W48-6'
          {@link #ISO_INSTANT} Date and Time of an Instant '2011-12-03T10:15:30Z'
          {@link #RFC_1123_DATE_TIME} RFC 1123 / RFC 822 'Tue, 3 Jun 2008 11:05:30 GMT'
          + *
          * + * * + * + * * * * * * * + * *
          Examples of Week based Years
          DateDay-of-weekField values
          2008-12-28SundayWeek 52 of week-based-year 2008
          2008-12-29MondayWeek 1 of week-based-year 2009
          2008-12-31WednesdayWeek 1 of week-based-year 2009
          2009-01-01ThursdayWeek 1 of week-based-year 2009
          2009-01-04SundayWeek 1 of week-based-year 2009
          2009-01-05MondayWeek 2 of week-based-year 2009
          * * @implSpec diff --git a/jdk/src/java.base/share/classes/java/time/temporal/WeekFields.java b/jdk/src/java.base/share/classes/java/time/temporal/WeekFields.java index faee176d3e7..2f13368d28f 100644 --- a/jdk/src/java.base/share/classes/java/time/temporal/WeekFields.java +++ b/jdk/src/java.base/share/classes/java/time/temporal/WeekFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -127,10 +127,13 @@ import sun.util.locale.provider.LocaleResources; * The earliest period is referred to as week 0 if it has less than the minimal number of days * and week 1 if it has at least the minimal number of days. * - * + *
          * + * * * + * + * * * * @@ -139,6 +142,7 @@ import sun.util.locale.provider.LocaleResources; * * * + * *
          Examples of WeekFields
          DateDay-of-weekFirst day: Monday
          Minimal days: 4
          First day: Monday
          Minimal days: 5
          2008-12-31WednesdayWeek 5 of December 2008Week 5 of December 2008
          2009-01-01ThursdayWeek 1 of January 2009Week 0 of January 2009
          2009-01-05MondayWeek 2 of January 2009Week 1 of January 2009
          * *

          Week of Year

          @@ -157,10 +161,13 @@ import sun.util.locale.provider.LocaleResources; * The first and last weeks of a year may contain days from the * previous calendar year or next calendar year respectively. * - * + *
          * + * * * + * + * * * * @@ -169,6 +176,7 @@ import sun.util.locale.provider.LocaleResources; * * * + * *
          Examples of WeekFields for week-based-year
          DateDay-of-weekFirst day: Monday
          Minimal days: 4
          First day: Monday
          Minimal days: 5
          2008-12-31WednesdayWeek 1 of 2009Week 53 of 2008
          2009-01-01ThursdayWeek 1 of 2009Week 53 of 2008
          2009-01-05MondayWeek 2 of 2009Week 1 of 2009
          * * @implSpec diff --git a/jdk/src/java.base/share/classes/java/util/AbstractCollection.java b/jdk/src/java.base/share/classes/java/util/AbstractCollection.java index 6f344f8befe..9845c0f031b 100644 --- a/jdk/src/java.base/share/classes/java/util/AbstractCollection.java +++ b/jdk/src/java.base/share/classes/java/util/AbstractCollection.java @@ -49,7 +49,7 @@ package java.util; * the collection being implemented admits a more efficient implementation.

          * * This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/AbstractList.java b/jdk/src/java.base/share/classes/java/util/AbstractList.java index c8c160de6a4..6d819368a24 100644 --- a/jdk/src/java.base/share/classes/java/util/AbstractList.java +++ b/jdk/src/java.base/share/classes/java/util/AbstractList.java @@ -62,7 +62,7 @@ import java.util.function.Consumer; * collection being implemented admits a more efficient implementation. * *

          This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/AbstractMap.java b/jdk/src/java.base/share/classes/java/util/AbstractMap.java index 0b76ddd76b1..ed39bcacbca 100644 --- a/jdk/src/java.base/share/classes/java/util/AbstractMap.java +++ b/jdk/src/java.base/share/classes/java/util/AbstractMap.java @@ -52,7 +52,7 @@ import java.util.Map.Entry; * map being implemented admits a more efficient implementation. * *

          This class is a member of the - * + * * Java Collections Framework. * * @param the type of keys maintained by this map diff --git a/jdk/src/java.base/share/classes/java/util/AbstractQueue.java b/jdk/src/java.base/share/classes/java/util/AbstractQueue.java index 6c1442b09f6..789151642d6 100644 --- a/jdk/src/java.base/share/classes/java/util/AbstractQueue.java +++ b/jdk/src/java.base/share/classes/java/util/AbstractQueue.java @@ -54,7 +54,7 @@ package java.util; * instead subclassing {@link AbstractCollection}. * *

          This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/AbstractSequentialList.java b/jdk/src/java.base/share/classes/java/util/AbstractSequentialList.java index bd6736ba63c..0e7cb01938a 100644 --- a/jdk/src/java.base/share/classes/java/util/AbstractSequentialList.java +++ b/jdk/src/java.base/share/classes/java/util/AbstractSequentialList.java @@ -54,7 +54,7 @@ package java.util; * specification.

          * * This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/AbstractSet.java b/jdk/src/java.base/share/classes/java/util/AbstractSet.java index 35e2ba4ec99..534ef775db1 100644 --- a/jdk/src/java.base/share/classes/java/util/AbstractSet.java +++ b/jdk/src/java.base/share/classes/java/util/AbstractSet.java @@ -42,7 +42,7 @@ package java.util; * for {@code equals} and {@code hashCode}.

          * * This class is a member of the - * + * * Java Collections Framework. * * @param the type of elements maintained by this set diff --git a/jdk/src/java.base/share/classes/java/util/ArrayDeque.java b/jdk/src/java.base/share/classes/java/util/ArrayDeque.java index de78bdc9e9a..53cdeffa846 100644 --- a/jdk/src/java.base/share/classes/java/util/ArrayDeque.java +++ b/jdk/src/java.base/share/classes/java/util/ArrayDeque.java @@ -79,7 +79,7 @@ import java.util.function.UnaryOperator; * Iterator} interfaces. * *

          This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch and Doug Lea diff --git a/jdk/src/java.base/share/classes/java/util/ArrayList.java b/jdk/src/java.base/share/classes/java/util/ArrayList.java index dbaa725dacb..f63ef493dc0 100644 --- a/jdk/src/java.base/share/classes/java/util/ArrayList.java +++ b/jdk/src/java.base/share/classes/java/util/ArrayList.java @@ -91,7 +91,7 @@ import java.util.function.UnaryOperator; * should be used only to detect bugs. * *

          This class is a member of the - * + * * Java Collections Framework. * * @param the type of elements in this list diff --git a/jdk/src/java.base/share/classes/java/util/Arrays.java b/jdk/src/java.base/share/classes/java/util/Arrays.java index 6d7e858fbed..e1571cc613f 100644 --- a/jdk/src/java.base/share/classes/java/util/Arrays.java +++ b/jdk/src/java.base/share/classes/java/util/Arrays.java @@ -62,7 +62,7 @@ import java.util.stream.StreamSupport; * a MergeSort, but it does have to be stable.) * *

          This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch @@ -8899,4 +8899,4 @@ public class Arrays { return aLength != bLength ? length : -1; } -} \ No newline at end of file +} diff --git a/jdk/src/java.base/share/classes/java/util/Base64.java b/jdk/src/java.base/share/classes/java/util/Base64.java index 99f5dc0d993..43e3d0690cd 100644 --- a/jdk/src/java.base/share/classes/java/util/Base64.java +++ b/jdk/src/java.base/share/classes/java/util/Base64.java @@ -41,21 +41,21 @@ import java.nio.charset.StandardCharsets; * RFC 2045. * *

            - *
          • Basic + *
          • Basic *

            Uses "The Base64 Alphabet" as specified in Table 1 of * RFC 4648 and RFC 2045 for encoding and decoding operation. * The encoder does not add any line feed (line separator) * character. The decoder rejects data that contains characters * outside the base64 alphabet.

          • * - *
          • URL and Filename safe + *
          • URL and Filename safe *

            Uses the "URL and Filename safe Base64 Alphabet" as specified * in Table 2 of RFC 4648 for encoding and decoding. The * encoder does not add any line feed (line separator) character. * The decoder rejects data that contains characters outside the * base64 alphabet.

          • * - *
          • MIME + *
          • MIME *

            Uses the "The Base64 Alphabet" as specified in Table 1 of * RFC 2045 for encoding and decoding operation. The encoded output * must be represented in lines of no more than 76 characters each diff --git a/jdk/src/java.base/share/classes/java/util/Calendar.java b/jdk/src/java.base/share/classes/java/util/Calendar.java index 7665d84f3ce..83435a90e9e 100644 --- a/jdk/src/java.base/share/classes/java/util/Calendar.java +++ b/jdk/src/java.base/share/classes/java/util/Calendar.java @@ -67,7 +67,7 @@ import sun.util.spi.CalendarProvider; * DAY_OF_MONTH, HOUR, and so on, and for * manipulating the calendar fields, such as getting the date of the next * week. An instant in time can be represented by a millisecond value that is - * an offset from the Epoch, January 1, 1970 + * an offset from the Epoch, January 1, 1970 * 00:00:00.000 GMT (Gregorian). * *

            The class also provides additional fields and methods for @@ -124,7 +124,7 @@ import sun.util.spi.CalendarProvider; * calculating its time or calendar field values if any out-of-range field * value has been set. * - *

            First Week

            + *

            First Week

            * * Calendar defines a locale-specific seven day week using two * parameters: the first day of the week and the minimal days in first week @@ -154,13 +154,13 @@ import sun.util.spi.CalendarProvider; * calendar field values to determine the date and time in the * following way. * - *

            If there is any conflict in calendar field values, + *

            If there is any conflict in calendar field values, * Calendar gives priorities to calendar fields that have been set * more recently. The following are the default combinations of the * calendar fields. The most recent combination, as determined by the * most recently set single field, will be used. * - *

            For the date fields: + *

            For the date fields: *

            *
              * YEAR + MONTH + DAY_OF_MONTH
            @@ -170,7 +170,7 @@ import sun.util.spi.CalendarProvider;
              * YEAR + DAY_OF_WEEK + WEEK_OF_YEAR
              * 
            * - * For the time of day fields: + * For the time of day fields: *
            *
              * HOUR_OF_DAY
            diff --git a/jdk/src/java.base/share/classes/java/util/Collection.java b/jdk/src/java.base/share/classes/java/util/Collection.java
            index f92b9f6153f..bc18f3725a1 100644
            --- a/jdk/src/java.base/share/classes/java/util/Collection.java
            +++ b/jdk/src/java.base/share/classes/java/util/Collection.java
            @@ -64,7 +64,7 @@ import java.util.stream.StreamSupport;
              * but is not required to, throw the exception if the collection to be added
              * is empty.
              *
            - * 

            + *

            * Some collection implementations have restrictions on the elements that * they may contain. For example, some implementations prohibit null elements, * and some have restrictions on the types of their elements. Attempting to @@ -112,7 +112,7 @@ import java.util.stream.StreamSupport; * however most current implementations do not do so. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @implSpec 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 22b4557ae2f..8aa9c53c455 100644 --- a/jdk/src/java.base/share/classes/java/util/Collections.java +++ b/jdk/src/java.base/share/classes/java/util/Collections.java @@ -65,7 +65,7 @@ import java.util.stream.StreamSupport; * already sorted may or may not throw {@code UnsupportedOperationException}. * *

            This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/Comparator.java b/jdk/src/java.base/share/classes/java/util/Comparator.java index ade582dbd3b..1e95e6279bb 100644 --- a/jdk/src/java.base/share/classes/java/util/Comparator.java +++ b/jdk/src/java.base/share/classes/java/util/Comparator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -94,7 +94,7 @@ import java.util.Comparators; * an equivalence relation. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @param the type of objects that may be compared by this comparator @@ -112,12 +112,6 @@ public interface Comparator { * zero, or a positive integer as the first argument is less than, equal * to, or greater than the second.

            * - * In the foregoing description, the notation - * {@code sgn(}expression{@code )} designates the mathematical - * signum function, which is defined to return one of {@code -1}, - * {@code 0}, or {@code 1} according to whether the value of - * expression is negative, zero or positive.

            - * * The implementor must ensure that {@code sgn(compare(x, y)) == * -sgn(compare(y, x))} for all {@code x} and {@code y}. (This * implies that {@code compare(x, y)} must throw an exception if and only @@ -135,7 +129,13 @@ public interface Comparator { * {@code (compare(x, y)==0) == (x.equals(y))}. Generally speaking, * any comparator that violates this condition should clearly indicate * this fact. The recommended language is "Note: this comparator - * imposes orderings that are inconsistent with equals." + * imposes orderings that are inconsistent with equals."

            + * + * In the foregoing description, the notation + * {@code sgn(}expression{@code )} designates the mathematical + * signum function, which is defined to return one of {@code -1}, + * {@code 0}, or {@code 1} according to whether the value of + * expression is negative, zero, or positive, respectively. * * @param o1 the first object to be compared. * @param o2 the second object to be compared. 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 312a74b6033..8b6a6349082 100644 --- a/jdk/src/java.base/share/classes/java/util/Date.java +++ b/jdk/src/java.base/share/classes/java/util/Date.java @@ -728,7 +728,6 @@ public class Date * @see java.util.Calendar * @deprecated As of JDK version 1.1, * replaced by {@code Calendar.get(Calendar.DAY_OF_MONTH)}. - * @deprecated */ @Deprecated public int getDate() { diff --git a/jdk/src/java.base/share/classes/java/util/Deque.java b/jdk/src/java.base/share/classes/java/util/Deque.java index 2714373fe63..48eaa3eb28b 100644 --- a/jdk/src/java.base/share/classes/java/util/Deque.java +++ b/jdk/src/java.base/share/classes/java/util/Deque.java @@ -56,19 +56,19 @@ package java.util; *

            The twelve methods described above are summarized in the * following table: * - * + *
            * * * - * - * + * + * * * * - * - * - * - * + * + * + * + * * * * @@ -99,11 +99,11 @@ package java.util; * inherited from the {@code Queue} interface are precisely equivalent to * {@code Deque} methods as indicated in the following table: * - *
            Summary of Deque methods
            First Element (Head) Last Element (Tail) First Element (Head) Last Element (Tail)
            Throws exceptionSpecial valueThrows exceptionSpecial valueThrows exceptionSpecial valueThrows exceptionSpecial value
            Insert
            + *
            * * - * - * + * + * * * * @@ -137,11 +137,11 @@ package java.util; * beginning of the deque. Stack methods are precisely equivalent to * {@code Deque} methods as indicated in the table below: * - *
            Comparison of Queue and Deque methods
            {@code Queue} Method Equivalent {@code Deque} Method {@code Queue} Method Equivalent {@code Deque} Method
            {@link java.util.Queue#add add(e)}
            + *
            * * - * - * + * + * * * * @@ -181,9 +181,9 @@ package java.util; * methods, but instead inherit the identity-based versions from class * {@code Object}. * - *

            This interface is a member of the Java Collections - * Framework. + *

            This interface is a member of the + * + * Java Collections Framework. * * @author Doug Lea * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/EnumMap.java b/jdk/src/java.base/share/classes/java/util/EnumMap.java index e6d63cf4ae8..3eff9a6fd3a 100644 --- a/jdk/src/java.base/share/classes/java/util/EnumMap.java +++ b/jdk/src/java.base/share/classes/java/util/EnumMap.java @@ -68,7 +68,7 @@ import jdk.internal.misc.SharedSecrets; * {@link HashMap} counterparts. * *

            This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/EnumSet.java b/jdk/src/java.base/share/classes/java/util/EnumSet.java index 0ca61870976..0adeab410b0 100644 --- a/jdk/src/java.base/share/classes/java/util/EnumSet.java +++ b/jdk/src/java.base/share/classes/java/util/EnumSet.java @@ -69,7 +69,7 @@ import jdk.internal.misc.SharedSecrets; * constant time if their argument is also an enum set. * *

            This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/Formatter.java b/jdk/src/java.base/share/classes/java/util/Formatter.java index 1871896bca9..39c23af20ff 100644 --- a/jdk/src/java.base/share/classes/java/util/Formatter.java +++ b/jdk/src/java.base/share/classes/java/util/Formatter.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 @@ -137,7 +137,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * // -> s == "Duke's Birthday: May 23, 1995" * * - *

            Organization

            + *

            Organization

            * *

            This specification is divided into two sections. The first section, Summary, covers the basic formatting concepts. This @@ -147,13 +147,13 @@ import jdk.internal.math.FormattedFloatingDecimal; * details. It is intended for users who want more precise specification of * formatting behavior. * - *

            Summary

            + *

            Summary

            * *

            This section is intended to provide a brief overview of formatting * concepts. For precise behavioral details, refer to the Details section. * - *

            Format String Syntax

            + *

            Format String Syntax

            * *

            Every method which produces formatted output requires a format * string and an argument list. The format string is a {@link @@ -290,87 +290,90 @@ import jdk.internal.math.FormattedFloatingDecimal; *

              *    out.toUpperCase(Locale.getDefault(Locale.Category.FORMAT)) 
            * - *
            Comparison of Stack and Deque methods
            Stack Method Equivalent {@code Deque} Method Stack Method Equivalent {@code Deque} Method
            {@link #push push(e)}
            - * - *
            Conversion - * Argument Category - * Description - * - *
            {@code 'b'}, {@code 'B'} - * general + * + * + * + * + * + * *
            genConv
            Conversion + * Argument Category + * Description + *
            {@code 'b'}, {@code 'B'} + * general * If the argument arg is {@code null}, then the result is * "{@code false}". If arg is a {@code boolean} or {@link * Boolean}, then the result is the string returned by {@link * String#valueOf(boolean) String.valueOf(arg)}. Otherwise, the result is * "true". * - *
            {@code 'h'}, {@code 'H'} - * general + *
            {@code 'h'}, {@code 'H'} + * general * The result is obtained by invoking * {@code Integer.toHexString(arg.hashCode())}. * - *
            {@code 's'}, {@code 'S'} - * general + *
            {@code 's'}, {@code 'S'} + * general * If arg implements {@link Formattable}, then * {@link Formattable#formatTo arg.formatTo} is invoked. Otherwise, the * result is obtained by invoking {@code arg.toString()}. * - *
            {@code 'c'}, {@code 'C'} - * character + *
            {@code 'c'}, {@code 'C'} + * character * The result is a Unicode character * - *
            {@code 'd'} - * integral + *
            {@code 'd'} + * integral * The result is formatted as a decimal integer * - *
            {@code 'o'} - * integral + *
            {@code 'o'} + * integral * The result is formatted as an octal integer * - *
            {@code 'x'}, {@code 'X'} - * integral + *
            {@code 'x'}, {@code 'X'} + * integral * The result is formatted as a hexadecimal integer * - *
            {@code 'e'}, {@code 'E'} - * floating point + *
            {@code 'e'}, {@code 'E'} + * floating point * The result is formatted as a decimal number in computerized * scientific notation * - *
            {@code 'f'} - * floating point + *
            {@code 'f'} + * floating point * The result is formatted as a decimal number * - *
            {@code 'g'}, {@code 'G'} - * floating point + *
            {@code 'g'}, {@code 'G'} + * floating point * The result is formatted using computerized scientific notation or * decimal format, depending on the precision and the value after rounding. * - *
            {@code 'a'}, {@code 'A'} - * floating point + *
            {@code 'a'}, {@code 'A'} + * floating point * The result is formatted as a hexadecimal floating-point number with * a significand and an exponent. This conversion is not supported * for the {@code BigDecimal} type despite the latter's being in the * floating point argument category. * - *
            {@code 't'}, {@code 'T'} - * date/time + *
            {@code 't'}, {@code 'T'} + * date/time * Prefix for date and time conversion characters. See Date/Time Conversions. * - *
            {@code '%'} - * percent + *
            {@code '%'} + * percent * The result is a literal {@code '%'} ('\u0025') * - *
            {@code 'n'} - * line separator + *
            {@code 'n'} + * line separator * The result is the platform-specific line separator * + *
            * *

            Any characters not explicitly defined as conversions are illegal and are * reserved for future extensions. * - *

            Date/Time Conversions

            + *

            Date/Time Conversions

            * *

            The following date and time conversion suffix characters are defined for * the {@code 't'} and {@code 'T'} conversions. The types are similar to but @@ -381,46 +384,47 @@ import jdk.internal.math.FormattedFloatingDecimal; * *

            The following conversion characters are used for formatting times: * - * - * - *
            {@code 'H'} + * + * + * + * *
            time
            {@code 'H'} * Hour of the day for the 24-hour clock, formatted as two digits with * a leading zero as necessary i.e. {@code 00 - 23}. * - *
            {@code 'I'} + *
            {@code 'I'} * Hour for the 12-hour clock, formatted as two digits with a leading * zero as necessary, i.e. {@code 01 - 12}. * - *
            {@code 'k'} + *
            {@code 'k'} * Hour of the day for the 24-hour clock, i.e. {@code 0 - 23}. * - *
            {@code 'l'} + *
            {@code 'l'} * Hour for the 12-hour clock, i.e. {@code 1 - 12}. * - *
            {@code 'M'} + *
            {@code 'M'} * Minute within the hour formatted as two digits with a leading zero * as necessary, i.e. {@code 00 - 59}. * - *
            {@code 'S'} + *
            {@code 'S'} * Seconds within the minute, formatted as two digits with a leading * zero as necessary, i.e. {@code 00 - 60} ("{@code 60}" is a special * value required to support leap seconds). * - *
            {@code 'L'} + *
            {@code 'L'} * Millisecond within the second formatted as three digits with * leading zeros as necessary, i.e. {@code 000 - 999}. * - *
            {@code 'N'} + *
            {@code 'N'} * Nanosecond within the second, formatted as nine digits with leading * zeros as necessary, i.e. {@code 000000000 - 999999999}. * - *
            {@code 'p'} + *
            {@code 'p'} * Locale-specific {@linkplain * java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker * in lower case, e.g."{@code am}" or "{@code pm}". Use of the conversion * prefix {@code 'T'} forces this output to upper case. * - *
            {@code 'z'} + *
            {@code 'z'} * RFC 822 * style numeric time zone offset from GMT, e.g. {@code -0800}. This * value will be adjusted as necessary for Daylight Saving Time. For @@ -428,7 +432,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * the {@linkplain TimeZone#getDefault() default time zone} for this * instance of the Java virtual machine. * - *
            {@code 'Z'} + *
            {@code 'Z'} * A string representing the abbreviation for the time zone. This * value will be adjusted as necessary for Daylight Saving Time. For * {@code long}, {@link Long}, and {@link Date} the time zone used is @@ -436,101 +440,108 @@ import jdk.internal.math.FormattedFloatingDecimal; * instance of the Java virtual machine. The Formatter's locale will * supersede the locale of the argument (if any). * - *
            {@code 's'} + *
            {@code 's'} * Seconds since the beginning of the epoch starting at 1 January 1970 * {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000} to * {@code Long.MAX_VALUE/1000}. * - *
            {@code 'Q'} + *
            {@code 'Q'} * Milliseconds since the beginning of the epoch starting at 1 January * 1970 {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE} to * {@code Long.MAX_VALUE}. * + *
            * *

            The following conversion characters are used for formatting dates: * - * + *
            + * + * * - * *
            date
            {@code 'B'} + *
            {@code 'B'} * Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths * full month name}, e.g. {@code "January"}, {@code "February"}. * - *
            {@code 'b'} + *
            {@code 'b'} * Locale-specific {@linkplain * java.text.DateFormatSymbols#getShortMonths abbreviated month name}, * e.g. {@code "Jan"}, {@code "Feb"}. * - *
            {@code 'h'} + *
            {@code 'h'} * Same as {@code 'b'}. * - *
            {@code 'A'} + *
            {@code 'A'} * Locale-specific full name of the {@linkplain * java.text.DateFormatSymbols#getWeekdays day of the week}, * e.g. {@code "Sunday"}, {@code "Monday"} * - *
            {@code 'a'} + *
            {@code 'a'} * Locale-specific short name of the {@linkplain * java.text.DateFormatSymbols#getShortWeekdays day of the week}, * e.g. {@code "Sun"}, {@code "Mon"} * - *
            {@code 'C'} + *
            {@code 'C'} * Four-digit year divided by {@code 100}, formatted as two digits * with leading zero as necessary, i.e. {@code 00 - 99} * - *
            {@code 'Y'} + *
            {@code 'Y'} * Year, formatted as at least four digits with leading zeros as * necessary, e.g. {@code 0092} equals {@code 92} CE for the Gregorian * calendar. * - *
            {@code 'y'} + *
            {@code 'y'} * Last two digits of the year, formatted with leading zeros as * necessary, i.e. {@code 00 - 99}. * - *
            {@code 'j'} + *
            {@code 'j'} * Day of year, formatted as three digits with leading zeros as * necessary, e.g. {@code 001 - 366} for the Gregorian calendar. * - *
            {@code 'm'} + *
            {@code 'm'} * Month, formatted as two digits with leading zeros as necessary, * i.e. {@code 01 - 13}. * - *
            {@code 'd'} + *
            {@code 'd'} * Day of month, formatted as two digits with leading zeros as * necessary, i.e. {@code 01 - 31} * - *
            {@code 'e'} + *
            {@code 'e'} * Day of month, formatted as two digits, i.e. {@code 1 - 31}. * + *
            * *

            The following conversion characters are used for formatting common * date/time compositions. * - * + *
            + * + * * - * *
            composites
            {@code 'R'} + *
            {@code 'R'} * Time formatted for the 24-hour clock as {@code "%tH:%tM"} * - *
            {@code 'T'} + *
            {@code 'T'} * Time formatted for the 24-hour clock as {@code "%tH:%tM:%tS"}. * - *
            {@code 'r'} + *
            {@code 'r'} * Time formatted for the 12-hour clock as {@code "%tI:%tM:%tS %Tp"}. * The location of the morning or afternoon marker ({@code '%Tp'}) may be * locale-dependent. * - *
            {@code 'D'} + *
            {@code 'D'} * Date formatted as {@code "%tm/%td/%ty"}. * - *
            {@code 'F'} + *
            {@code 'F'} * ISO 8601 * complete date formatted as {@code "%tY-%tm-%td"}. * - *
            {@code 'c'} + *
            {@code 'c'} * Date and time formatted as {@code "%ta %tb %td %tT %tZ %tY"}, * e.g. {@code "Sun Jul 20 16:17:00 EDT 1969"}. * + *
            * *

            Any characters not explicitly defined as date/time conversion suffixes @@ -541,64 +552,67 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            The following table summarizes the supported flags. y means the * flag is supported for the indicated argument types. * - * - * - *
            Flag General - * Character Integral - * Floating Point - * Date/Time - * Description - * - *
            '-' y - * y - * y - * y - * y + * + * + * + * + * + * *
            genConv
            Flag General + * Character Integral + * Floating Point + * Date/Time + * Description + *
            '-' y + * y + * y + * y + * y * The result will be left-justified. * - *
            '#' y1 - * - - * y3 - * y - * - + *
            '#' y1 + * - + * y3 + * y + * - * The result should use a conversion-dependent alternate form * - *
            '+' - - * - - * y4 - * y - * - + *
            '+' - + * - + * y4 + * y + * - * The result will always include a sign * - *
            '  ' - - * - - * y4 - * y - * - + *
            '  ' - + * - + * y4 + * y + * - * The result will include a leading space for positive values * - *
            '0' - - * - - * y - * y - * - + *
            '0' - + * - + * y + * y + * - * The result will be zero-padded * - *
            ',' - - * - - * y2 - * y5 - * - + *
            ',' - + * - + * y2 + * y5 + * - * The result will include locale-specific {@linkplain * java.text.DecimalFormatSymbols#getGroupingSeparator grouping separators} * - *
            '(' - - * - - * y4 - * y5 - * - + *
            '(' - + * - + * y4 + * y5 + * - * The result will enclose negative numbers in parentheses * + *
            * *

            1 Depends on the definition of {@link Formattable}. @@ -659,7 +673,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * * *


            - *

            Details

            + *

            Details

            * *

            This section is intended to provide behavioral details for formatting, * including conditions and exceptions, supported data types, localization, and @@ -701,14 +715,16 @@ import jdk.internal.math.FormattedFloatingDecimal; *

              *    out.toUpperCase(Locale.getDefault(Locale.Category.FORMAT)) 
            * - *

            General

            + *

            General

            * *

            The following general conversions may be applied to any argument type: * - * + *
            + * + * * - * *
            dgConv
            {@code 'b'} - * '\u0062' + *
            {@code 'b'} + * '\u0062' * Produces either "{@code true}" or "{@code false}" as returned by * {@link Boolean#toString(boolean)}. * @@ -721,12 +737,12 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'B'} - * '\u0042' + *
            {@code 'B'} + * '\u0042' * The upper-case variant of {@code 'b'}. * - *
            {@code 'h'} - * '\u0068' + *
            {@code 'h'} + * '\u0068' * Produces a string representing the hash code value of the object. * *

            The result is obtained by invoking @@ -735,12 +751,12 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'H'} - * '\u0048' + *
            {@code 'H'} + * '\u0048' * The upper-case variant of {@code 'h'}. * - *
            {@code 's'} - * '\u0073' + *
            {@code 's'} + * '\u0073' * Produces a string. * *

            If the argument implements {@link Formattable}, then @@ -752,32 +768,36 @@ import jdk.internal.math.FormattedFloatingDecimal; * Formattable} , then a {@link FormatFlagsConversionMismatchException} * will be thrown. * - *

            {@code 'S'} - * '\u0053' + *
            {@code 'S'} + * '\u0053' * The upper-case variant of {@code 's'}. * + *
            * - *

            The following flags apply to general conversions: + *

            The following flags apply to general conversions: * - * + *
            + * + * * - * *
            dFlags
            {@code '-'} - * '\u002d' + *
            {@code '-'} + * '\u002d' * Left justifies the output. Spaces ('\u0020') will be * added at the end of the converted value as required to fill the minimum * width of the field. If the width is not provided, then a {@link * MissingFormatWidthException} will be thrown. If this flag is not given * then the output will be right-justified. * - *
            {@code '#'} - * '\u0023' + *
            {@code '#'} + * '\u0023' * Requires the output use an alternate form. The definition of the * form is specified by the conversion. * + *
            * - *

            The width is the minimum number of characters to + *

            The width is the minimum number of characters to * be written to the * output. If the length of the converted value is less than the width then * the output will be padded by '  ' ('\u0020') @@ -792,7 +812,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * the precision. If the precision is not specified then there is no explicit * limit on the number of characters. * - *

            Character

            + *

            Character

            * * This conversion may be applied to {@code char} and {@link Character}. It * may also be applied to the types {@code byte}, {@link Byte}, @@ -801,10 +821,12 @@ import jdk.internal.math.FormattedFloatingDecimal; * {@code false} then an {@link IllegalFormatCodePointException} will be * thrown. * - * + *
            + * + * * - * *
            charConv
            {@code 'c'} - * '\u0063' + *
            {@code 'c'} + * '\u0063' * Formats the argument as a Unicode character as described in Unicode Character * Representation. This may be more than one 16-bit {@code char} in @@ -813,10 +835,11 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '#'} flag is given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'C'} - * '\u0043' + *
            {@code 'C'} + * '\u0043' * The upper-case variant of {@code 'c'}. * + *
            * *

            The {@code '-'} flag defined for General @@ -828,7 +851,7 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            The precision is not applicable. If the precision is specified then an * {@link IllegalFormatPrecisionException} will be thrown. * - *

            Numeric

            + *

            Numeric

            * *

            Numeric conversions are divided into the following categories: * @@ -846,7 +869,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * *

            Numeric types will be formatted according to the following algorithm: * - *

            Number Localization Algorithm + *

            Number Localization Algorithm * *

            After digits are obtained for the integer part, fractional part, and * exponent (as appropriate for the data type), the following transformation @@ -865,7 +888,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * substituted. * *

          • If the {@code ','} ('\u002c') - * flag is given, then the locale-specific {@linkplain + * flag is given, then the locale-specific {@linkplain * java.text.DecimalFormatSymbols#getGroupingSeparator grouping separator} is * inserted by scanning the integer part of the string from least significant * to most significant digits and inserting a separator at intervals defined by @@ -896,16 +919,18 @@ import jdk.internal.math.FormattedFloatingDecimal; * then the output will be "(Infinity)" if the {@code '('} flag is given * otherwise the output will be "-Infinity". These values are not localized. * - *

            Byte, Short, Integer, and Long + *

            Byte, Short, Integer, and Long * *

            The following conversions may be applied to {@code byte}, {@link Byte}, * {@code short}, {@link Short}, {@code int} and {@link Integer}, * {@code long}, and {@link Long}. * - * + *
            + * + * * - * *
            IntConv
            {@code 'd'} - * '\u0064' + *
            {@code 'd'} + * '\u0064' * Formats the argument as a decimal integer. The localization algorithm is applied. * @@ -915,8 +940,8 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '#'} flag is given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'o'} - * '\u006f' + *
            {@code 'o'} + * '\u006f' * Formats the argument as an integer in base eight. No localization * is applied. * @@ -937,8 +962,8 @@ import jdk.internal.math.FormattedFloatingDecimal; * are given then a {@link FormatFlagsConversionMismatchException} will be * thrown. * - *
            {@code 'x'} - * '\u0078' + *
            {@code 'x'} + * '\u0078' * Formats the argument as an integer in base sixteen. No * localization is applied. * @@ -960,14 +985,15 @@ import jdk.internal.math.FormattedFloatingDecimal; * {@code ','} flags are given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *
            {@code 'X'} - * '\u0058' + *
            {@code 'X'} + * '\u0058' * The upper-case variant of {@code 'x'}. The entire string * representing the number will be converted to {@linkplain * String#toUpperCase upper case} including the {@code 'x'} (if any) and * all hexadecimal digits {@code 'a'} - {@code 'f'} * ('\u0061' - '\u0066'). * + *
            * *

            If the conversion is {@code 'o'}, {@code 'x'}, or {@code 'X'} and @@ -979,13 +1005,15 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '-'} flag is not given, then the space padding will occur * before the sign. * - *

            The following flags apply to numeric integral + *

            The following flags apply to numeric integral * conversions: * - * + *
            + * + * * - * *
            intFlags
            {@code '+'} - * '\u002b' + *
            {@code '+'} + * '\u002b' * Requires the output to include a positive sign for all positive * numbers. If this flag is not given then only negative values will * include a sign. @@ -993,16 +1021,16 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If both the {@code '+'} and '  ' flags are given * then an {@link IllegalFormatFlagsException} will be thrown. * - *

            '  ' - * '\u0020' + *
            '  ' + * '\u0020' * Requires the output to include a single extra space * ('\u0020') for non-negative values. * *

            If both the {@code '+'} and '  ' flags are given * then an {@link IllegalFormatFlagsException} will be thrown. * - *

            {@code '0'} - * '\u0030' + *
            {@code '0'} + * '\u0030' * Requires the output to be padded with leading {@linkplain * java.text.DecimalFormatSymbols#getZeroDigit zeros} to the minimum field * width following any sign or radix indicator except when converting NaN @@ -1012,22 +1040,23 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If both the {@code '-'} and {@code '0'} flags are given then an * {@link IllegalFormatFlagsException} will be thrown. * - *

            {@code ','} - * '\u002c' + *
            {@code ','} + * '\u002c' * Requires the output to include the locale-specific {@linkplain * java.text.DecimalFormatSymbols#getGroupingSeparator group separators} as * described in the "group" section of the * localization algorithm. * - *
            {@code '('} - * '\u0028' + *
            {@code '('} + * '\u0028' * Requires the output to prepend a {@code '('} * ('\u0028') and append a {@code ')'} * ('\u0029') to negative values. * + *
            * - *

            If no flags are given the default formatting is + *

            If no flags are given the default formatting is * as follows: * *

              @@ -1043,7 +1072,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * *
            * - *

            The width is the minimum number of characters to + *

            The width is the minimum number of characters to * be written to the output. This includes any signs, digits, grouping * separators, radix indicator, and parentheses. If the length of the * converted value is less than the width then the output will be padded by @@ -1055,23 +1084,25 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            The precision is not applicable. If precision is specified then an * {@link IllegalFormatPrecisionException} will be thrown. * - *

            BigInteger + *

            BigInteger * *

            The following conversions may be applied to {@link * java.math.BigInteger}. * - * + *
            + * + * * - * *
            bIntConv
            {@code 'd'} - * '\u0064' + *
            {@code 'd'} + * '\u0064' * Requires the output to be formatted as a decimal integer. The localization algorithm is applied. * *

            If the {@code '#'} flag is given {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'o'} - * '\u006f' + *
            {@code 'o'} + * '\u006f' * Requires the output to be formatted as an integer in base eight. * No localization is applied. * @@ -1093,8 +1124,8 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code ','} flag is given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'x'} - * '\u0078' + *
            {@code 'x'} + * '\u0078' * Requires the output to be formatted as an integer in base * sixteen. No localization is applied. * @@ -1117,14 +1148,15 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code ','} flag is given then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'X'} - * '\u0058' + *
            {@code 'X'} + * '\u0058' * The upper-case variant of {@code 'x'}. The entire string * representing the number will be converted to {@linkplain * String#toUpperCase upper case} including the {@code 'x'} (if any) and * all hexadecimal digits {@code 'a'} - {@code 'f'} * ('\u0061' - '\u0066'). * + *
            * *

            If the conversion is {@code 'o'}, {@code 'x'}, or {@code 'X'} and @@ -1149,17 +1181,19 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            The precision is not applicable. If precision is specified then an * {@link IllegalFormatPrecisionException} will be thrown. * - *

            Float and Double + *

            Float and Double * *

            The following conversions may be applied to {@code float}, {@link * Float}, {@code double} and {@link Double}. * - * + *
            + * + * * - * *
            floatConv
            {@code 'e'} - * '\u0065' + *
            {@code 'e'} + * '\u0065' * Requires the output to be formatted using computerized scientific notation. The computerized scientific notation. The localization algorithm is applied. * *

            The formatting of the magnitude m depends upon its value. @@ -1204,13 +1238,13 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code ','} flag is given, then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'E'} - * '\u0045' + *
            {@code 'E'} + * '\u0045' * The upper-case variant of {@code 'e'}. The exponent symbol * will be {@code 'E'} ('\u0045'). * - *
            {@code 'g'} - * '\u0067' + *
            {@code 'g'} + * '\u0067' * Requires the output to be formatted in general scientific notation * as described below. The localization * algorithm is applied. @@ -1234,13 +1268,13 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '#'} flag is given then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'G'} - * '\u0047' + *
            {@code 'G'} + * '\u0047' * The upper-case variant of {@code 'g'}. * - *
            {@code 'f'} - * '\u0066' - * Requires the output to be formatted using decimal + *
            {@code 'f'} + * '\u0066' + * Requires the output to be formatted using decimal * format. The localization algorithm is * applied. * @@ -1270,8 +1304,8 @@ import jdk.internal.math.FormattedFloatingDecimal; * Float#toString(float)} or {@link Double#toString(double)} as * appropriate. * - *
            {@code 'a'} - * '\u0061' + *
            {@code 'a'} + * '\u0061' * Requires the output to be formatted in hexadecimal exponential * form. No localization is applied. * @@ -1323,14 +1357,15 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '('} or {@code ','} flags are given, then a {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'A'} - * '\u0041' + *
            {@code 'A'} + * '\u0041' * The upper-case variant of {@code 'a'}. The entire string * representing the number will be converted to upper case including the * {@code 'x'} ('\u0078') and {@code 'p'} * ('\u0070' and all hexadecimal digits {@code 'a'} - * {@code 'f'} ('\u0061' - '\u0066'). * + *
            * *

            All flags defined for Byte, Short, Integer, and @@ -1339,7 +1374,7 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '#'} flag is given, then the decimal separator will * always be present. * - *

            If no flags are given the default formatting + *

            If no flags are given the default formatting * is as follows: * *

              @@ -1357,7 +1392,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * *
            * - *

            The width is the minimum number of characters + *

            The width is the minimum number of characters * to be written to the output. This includes any signs, digits, grouping * separators, decimal separators, exponential symbol, radix indicator, * parentheses, and strings representing infinity and NaN as applicable. If @@ -1367,7 +1402,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * {@code '-'} flag is given then the padding will be on the right. If width * is not specified then there is no minimum. * - *

            If the conversion is {@code 'e'}, + *

            If the conversion is {@code 'e'}, * {@code 'E'} or {@code 'f'}, then the precision is the number of digits * after the decimal separator. If the precision is not specified, then it is * assumed to be {@code 6}. @@ -1383,17 +1418,19 @@ import jdk.internal.math.FormattedFloatingDecimal; * precision is not provided, then all of the digits as returned by {@link * Double#toHexString(double)} will be output. * - *

            BigDecimal + *

            BigDecimal * *

            The following conversions may be applied {@link java.math.BigDecimal * BigDecimal}. * - * + *
            + * + * * - * *
            floatConv
            {@code 'e'} - * '\u0065' + *
            {@code 'e'} + * '\u0065' * Requires the output to be formatted using computerized scientific notation. The computerized scientific notation. The localization algorithm is applied. * *

            The formatting of the magnitude m depends upon its value. @@ -1432,13 +1469,13 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code ','} flag is given, then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'E'} - * '\u0045' + *
            {@code 'E'} + * '\u0045' * The upper-case variant of {@code 'e'}. The exponent symbol * will be {@code 'E'} ('\u0045'). * - *
            {@code 'g'} - * '\u0067' + *
            {@code 'g'} + * '\u0067' * Requires the output to be formatted in general scientific notation * as described below. The localization * algorithm is applied. @@ -1462,13 +1499,13 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            If the {@code '#'} flag is given then an {@link * FormatFlagsConversionMismatchException} will be thrown. * - *

            {@code 'G'} - * '\u0047' + *
            {@code 'G'} + * '\u0047' * The upper-case variant of {@code 'g'}. * - *
            {@code 'f'} - * '\u0066' - * Requires the output to be formatted using decimal + *
            {@code 'f'} + * '\u0066' + * Requires the output to be formatted using decimal * format. The localization algorithm is * applied. * @@ -1492,6 +1529,7 @@ import jdk.internal.math.FormattedFloatingDecimal; * For a canonical representation of the value, use {@link * BigDecimal#toString()}. * + *
            * *

            All flags defined for Byte, Short, Integer, and @@ -1507,20 +1545,23 @@ import jdk.internal.math.FormattedFloatingDecimal; * href="#floatDPrec">precision is the same as defined for Float and * Double. * - *

            Date/Time

            + *

            Date/Time

            * *

            This conversion may be applied to {@code long}, {@link Long}, {@link * Calendar}, {@link Date} and {@link TemporalAccessor TemporalAccessor} * - * + *
            + * + * * - * *
            DTConv
            {@code 't'} - * '\u0074' + *
            {@code 't'} + * '\u0074' * Prefix for date and time conversion characters. - *
            {@code 'T'} - * '\u0054' + *
            {@code 'T'} + * '\u0054' * The upper-case variant of {@code 't'}. * + *
            * *

            The following date and time conversion character suffixes are defined @@ -1532,55 +1573,57 @@ import jdk.internal.math.FormattedFloatingDecimal; * *

            The following conversion characters are used for formatting times: * - * + *
            + * + * * - * *
            time
            {@code 'H'} - * '\u0048' + *
            {@code 'H'} + * '\u0048' * Hour of the day for the 24-hour clock, formatted as two digits with * a leading zero as necessary i.e. {@code 00 - 23}. {@code 00} * corresponds to midnight. * - *
            {@code 'I'} - * '\u0049' + *
            {@code 'I'} + * '\u0049' * Hour for the 12-hour clock, formatted as two digits with a leading * zero as necessary, i.e. {@code 01 - 12}. {@code 01} corresponds to * one o'clock (either morning or afternoon). * - *
            {@code 'k'} - * '\u006b' + *
            {@code 'k'} + * '\u006b' * Hour of the day for the 24-hour clock, i.e. {@code 0 - 23}. * {@code 0} corresponds to midnight. * - *
            {@code 'l'} - * '\u006c' + *
            {@code 'l'} + * '\u006c' * Hour for the 12-hour clock, i.e. {@code 1 - 12}. {@code 1} * corresponds to one o'clock (either morning or afternoon). * - *
            {@code 'M'} - * '\u004d' + *
            {@code 'M'} + * '\u004d' * Minute within the hour formatted as two digits with a leading zero * as necessary, i.e. {@code 00 - 59}. * - *
            {@code 'S'} - * '\u0053' + *
            {@code 'S'} + * '\u0053' * Seconds within the minute, formatted as two digits with a leading * zero as necessary, i.e. {@code 00 - 60} ("{@code 60}" is a special * value required to support leap seconds). * - *
            {@code 'L'} - * '\u004c' + *
            {@code 'L'} + * '\u004c' * Millisecond within the second formatted as three digits with * leading zeros as necessary, i.e. {@code 000 - 999}. * - *
            {@code 'N'} - * '\u004e' + *
            {@code 'N'} + * '\u004e' * Nanosecond within the second, formatted as nine digits with leading * zeros as necessary, i.e. {@code 000000000 - 999999999}. The precision * of this value is limited by the resolution of the underlying operating * system or hardware. * - *
            {@code 'p'} - * '\u0070' + *
            {@code 'p'} + * '\u0070' * Locale-specific {@linkplain * java.text.DateFormatSymbols#getAmPmStrings morning or afternoon} marker * in lower case, e.g."{@code am}" or "{@code pm}". Use of the @@ -1589,8 +1632,8 @@ import jdk.internal.math.FormattedFloatingDecimal; * GNU {@code date} and POSIX {@code strftime(3c)} which produce * upper-case output.) * - *
            {@code 'z'} - * '\u007a' + *
            {@code 'z'} + * '\u007a' * RFC 822 * style numeric time zone offset from GMT, e.g. {@code -0800}. This * value will be adjusted as necessary for Daylight Saving Time. For @@ -1598,8 +1641,8 @@ import jdk.internal.math.FormattedFloatingDecimal; * the {@linkplain TimeZone#getDefault() default time zone} for this * instance of the Java virtual machine. * - *
            {@code 'Z'} - * '\u005a' + *
            {@code 'Z'} + * '\u005a' * A string representing the abbreviation for the time zone. This * value will be adjusted as necessary for Daylight Saving Time. For * {@code long}, {@link Long}, and {@link Date} the time zone used is @@ -1607,126 +1650,133 @@ import jdk.internal.math.FormattedFloatingDecimal; * instance of the Java virtual machine. The Formatter's locale will * supersede the locale of the argument (if any). * - *
            {@code 's'} - * '\u0073' + *
            {@code 's'} + * '\u0073' * Seconds since the beginning of the epoch starting at 1 January 1970 * {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE/1000} to * {@code Long.MAX_VALUE/1000}. * - *
            {@code 'Q'} - * '\u004f' + *
            {@code 'Q'} + * '\u004f' * Milliseconds since the beginning of the epoch starting at 1 January * 1970 {@code 00:00:00} UTC, i.e. {@code Long.MIN_VALUE} to * {@code Long.MAX_VALUE}. The precision of this value is limited by * the resolution of the underlying operating system or hardware. * + *
            * *

            The following conversion characters are used for formatting dates: * - * + *
            + * + * * - * *
            date
            {@code 'B'} - * '\u0042' + *
            {@code 'B'} + * '\u0042' * Locale-specific {@linkplain java.text.DateFormatSymbols#getMonths * full month name}, e.g. {@code "January"}, {@code "February"}. * - *
            {@code 'b'} - * '\u0062' + *
            {@code 'b'} + * '\u0062' * Locale-specific {@linkplain * java.text.DateFormatSymbols#getShortMonths abbreviated month name}, * e.g. {@code "Jan"}, {@code "Feb"}. * - *
            {@code 'h'} - * '\u0068' + *
            {@code 'h'} + * '\u0068' * Same as {@code 'b'}. * - *
            {@code 'A'} - * '\u0041' + *
            {@code 'A'} + * '\u0041' * Locale-specific full name of the {@linkplain * java.text.DateFormatSymbols#getWeekdays day of the week}, * e.g. {@code "Sunday"}, {@code "Monday"} * - *
            {@code 'a'} - * '\u0061' + *
            {@code 'a'} + * '\u0061' * Locale-specific short name of the {@linkplain * java.text.DateFormatSymbols#getShortWeekdays day of the week}, * e.g. {@code "Sun"}, {@code "Mon"} * - *
            {@code 'C'} - * '\u0043' + *
            {@code 'C'} + * '\u0043' * Four-digit year divided by {@code 100}, formatted as two digits * with leading zero as necessary, i.e. {@code 00 - 99} * - *
            {@code 'Y'} - * '\u0059' Year, formatted to at least + *
            {@code 'Y'} + * '\u0059' Year, formatted to at least * four digits with leading zeros as necessary, e.g. {@code 0092} equals * {@code 92} CE for the Gregorian calendar. * - *
            {@code 'y'} - * '\u0079' + *
            {@code 'y'} + * '\u0079' * Last two digits of the year, formatted with leading zeros as * necessary, i.e. {@code 00 - 99}. * - *
            {@code 'j'} - * '\u006a' + *
            {@code 'j'} + * '\u006a' * Day of year, formatted as three digits with leading zeros as * necessary, e.g. {@code 001 - 366} for the Gregorian calendar. * {@code 001} corresponds to the first day of the year. * - *
            {@code 'm'} - * '\u006d' + *
            {@code 'm'} + * '\u006d' * Month, formatted as two digits with leading zeros as necessary, * i.e. {@code 01 - 13}, where "{@code 01}" is the first month of the * year and ("{@code 13}" is a special value required to support lunar * calendars). * - *
            {@code 'd'} - * '\u0064' + *
            {@code 'd'} + * '\u0064' * Day of month, formatted as two digits with leading zeros as * necessary, i.e. {@code 01 - 31}, where "{@code 01}" is the first day * of the month. * - *
            {@code 'e'} - * '\u0065' + *
            {@code 'e'} + * '\u0065' * Day of month, formatted as two digits, i.e. {@code 1 - 31} where * "{@code 1}" is the first day of the month. * + *
            * *

            The following conversion characters are used for formatting common * date/time compositions. * - * + *
            + * + * * - * *
            composites
            {@code 'R'} - * '\u0052' + *
            {@code 'R'} + * '\u0052' * Time formatted for the 24-hour clock as {@code "%tH:%tM"} * - *
            {@code 'T'} - * '\u0054' + *
            {@code 'T'} + * '\u0054' * Time formatted for the 24-hour clock as {@code "%tH:%tM:%tS"}. * - *
            {@code 'r'} - * '\u0072' + *
            {@code 'r'} + * '\u0072' * Time formatted for the 12-hour clock as {@code "%tI:%tM:%tS * %Tp"}. The location of the morning or afternoon marker * ({@code '%Tp'}) may be locale-dependent. * - *
            {@code 'D'} - * '\u0044' + *
            {@code 'D'} + * '\u0044' * Date formatted as {@code "%tm/%td/%ty"}. * - *
            {@code 'F'} - * '\u0046' + *
            {@code 'F'} + * '\u0046' * ISO 8601 * complete date formatted as {@code "%tY-%tm-%td"}. * - *
            {@code 'c'} - * '\u0063' + *
            {@code 'c'} + * '\u0063' * Date and time formatted as {@code "%ta %tb %td %tT %tZ %tY"}, * e.g. {@code "Sun Jul 20 16:17:00 EDT 1969"}. * + *
            * *

            The {@code '-'} flag defined for General @@ -1744,13 +1794,15 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            The precision is not applicable. If the precision is specified then an * {@link IllegalFormatPrecisionException} will be thrown. * - *

            Percent

            + *

            Percent

            * *

            The conversion does not correspond to any argument. * - * + *
            + * + * * - * *
            DTConv
            {@code '%'} + *
            {@code '%'} * The result is a literal {@code '%'} ('\u0025') * *

            The width is the minimum number of characters to @@ -1767,25 +1819,29 @@ import jdk.internal.math.FormattedFloatingDecimal; *

            The precision is not applicable. If the precision is specified an * {@link IllegalFormatPrecisionException} will be thrown. * + *

            * - *

            Line Separator

            + *

            Line Separator

            * *

            The conversion does not correspond to any argument. * - * + *
            + * + * * - * *
            DTConv
            {@code 'n'} + *
            {@code 'n'} * the platform-specific line separator as returned by {@link * System#lineSeparator()}. * + *
            * *

            Flags, width, and precision are not applicable. If any are provided an * {@link IllegalFormatFlagsException}, {@link IllegalFormatWidthException}, * and {@link IllegalFormatPrecisionException}, respectively will be thrown. * - *

            Argument Index

            + *

            Argument Index

            * *

            Format specifiers can reference arguments in three ways: * diff --git a/jdk/src/java.base/share/classes/java/util/GregorianCalendar.java b/jdk/src/java.base/share/classes/java/util/GregorianCalendar.java index 6ce8e8e9b7a..8d2835fe5ac 100644 --- a/jdk/src/java.base/share/classes/java/util/GregorianCalendar.java +++ b/jdk/src/java.base/share/classes/java/util/GregorianCalendar.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 @@ -91,7 +91,7 @@ import sun.util.calendar.ZoneInfo; * adjustment may be made if desired for dates that are prior to the Gregorian * changeover and which fall between January 1 and March 24. * - *

            Week Of Year and Week Year

            + *

            Week Of Year and Week Year

            * *

            Values calculated for the {@link Calendar#WEEK_OF_YEAR * WEEK_OF_YEAR} field range from 1 to 53. The first week of a @@ -108,7 +108,7 @@ import sun.util.calendar.ZoneInfo; *

            The {@code getFirstDayOfWeek()} and {@code * getMinimalDaysInFirstWeek()} values are initialized using * locale-dependent resources when constructing a {@code - * GregorianCalendar}. The week + * GregorianCalendar}. The week * determination is compatible with the ISO 8601 standard when {@code * getFirstDayOfWeek()} is {@code MONDAY} and {@code * getMinimalDaysInFirstWeek()} is 4, which values are used in locales @@ -117,7 +117,7 @@ import sun.util.calendar.ZoneInfo; * {@link Calendar#setMinimalDaysInFirstWeek(int) * setMinimalDaysInFirstWeek()}. * - *

            A week year is in sync with a + *

            A week year is in sync with a * {@code WEEK_OF_YEAR} cycle. All weeks between the first and last * weeks (inclusive) have the same week year value. * Therefore, the first and last days of a week year may have @@ -159,88 +159,89 @@ import sun.util.calendar.ZoneInfo; * undefined. GregorianCalendar uses the following * default value for each calendar field if its value is undefined. * - * + *
            + * + * + * + * + * + * + * * * - * - * - * - * - * - * * * - * - * * * - * - * * * - * - * * * - * - * * * - * - * * * - * - * * * - * - * * * - * - * * * diff --git a/jdk/src/java.base/share/classes/java/util/HashMap.java b/jdk/src/java.base/share/classes/java/util/HashMap.java index 5cc36296aa8..4f0e8e6c7d6 100644 --- a/jdk/src/java.base/share/classes/java/util/HashMap.java +++ b/jdk/src/java.base/share/classes/java/util/HashMap.java @@ -117,7 +117,7 @@ import java.util.function.Function; * should be used only to detect bugs. * *

            This class is a member of the - * + * * Java Collections Framework. * * @param the type of keys maintained by this map diff --git a/jdk/src/java.base/share/classes/java/util/HashSet.java b/jdk/src/java.base/share/classes/java/util/HashSet.java index 172cb37ad06..360de8119d6 100644 --- a/jdk/src/java.base/share/classes/java/util/HashSet.java +++ b/jdk/src/java.base/share/classes/java/util/HashSet.java @@ -72,7 +72,7 @@ import java.io.InvalidObjectException; * should be used only to detect bugs. * *

            This class is a member of the - * + * * Java Collections Framework. * * @param the type of elements maintained by this set diff --git a/jdk/src/java.base/share/classes/java/util/Hashtable.java b/jdk/src/java.base/share/classes/java/util/Hashtable.java index b541ca12a06..f97303be2b3 100644 --- a/jdk/src/java.base/share/classes/java/util/Hashtable.java +++ b/jdk/src/java.base/share/classes/java/util/Hashtable.java @@ -106,7 +106,7 @@ import java.util.function.BiFunction; * *

            As of the Java 2 platform v1.2, this class was retrofitted to * implement the {@link Map} interface, making it a member of the - * + * * * Java Collections Framework. Unlike the new collection * implementations, {@code Hashtable} is synchronized. If a diff --git a/jdk/src/java.base/share/classes/java/util/IdentityHashMap.java b/jdk/src/java.base/share/classes/java/util/IdentityHashMap.java index bd1e217e7ff..f749774e78e 100644 --- a/jdk/src/java.base/share/classes/java/util/IdentityHashMap.java +++ b/jdk/src/java.base/share/classes/java/util/IdentityHashMap.java @@ -122,7 +122,7 @@ import java.util.function.Consumer; * {@link HashMap} (which uses chaining rather than linear-probing). * *

            This class is a member of the - * + * * Java Collections Framework. * * @see System#identityHashCode(Object) diff --git a/jdk/src/java.base/share/classes/java/util/Iterator.java b/jdk/src/java.base/share/classes/java/util/Iterator.java index 7dcb155c63d..5f7b1de8b85 100644 --- a/jdk/src/java.base/share/classes/java/util/Iterator.java +++ b/jdk/src/java.base/share/classes/java/util/Iterator.java @@ -40,7 +40,7 @@ import java.util.function.Consumer; * * *

            This interface is a member of the - * + * * Java Collections Framework. * * @apiNote @@ -109,7 +109,8 @@ public interface Iterator { * Exceptions thrown by the action are relayed to the caller. *

            * The behavior of an iterator is unspecified if the action modifies the - * collection in any way (even by calling the {@link #remove remove} method), + * collection in any way (even by calling the {@link #remove remove} method + * or other mutator methods of {@code Iterator} subtypes), * unless an overriding class has specified a concurrent modification policy. *

            * Subsequent behavior of an iterator is unspecified if the action throws an diff --git a/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java b/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java index bd21f5bf6d4..252a5437353 100644 --- a/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java +++ b/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java @@ -140,7 +140,7 @@ import java.io.IOException; * fail-fast, and additionally report {@link Spliterator#ORDERED}. * *

            This class is a member of the - * + * * Java Collections Framework. * * @implNote diff --git a/jdk/src/java.base/share/classes/java/util/LinkedHashSet.java b/jdk/src/java.base/share/classes/java/util/LinkedHashSet.java index c0e1f2eb8e4..0d0f927166e 100644 --- a/jdk/src/java.base/share/classes/java/util/LinkedHashSet.java +++ b/jdk/src/java.base/share/classes/java/util/LinkedHashSet.java @@ -100,7 +100,7 @@ package java.util; * should be used only to detect bugs. * *

            This class is a member of the - * + * * Java Collections Framework. * * @param the type of elements maintained by this set diff --git a/jdk/src/java.base/share/classes/java/util/LinkedList.java b/jdk/src/java.base/share/classes/java/util/LinkedList.java index 2d21ff145c3..fce19cad553 100644 --- a/jdk/src/java.base/share/classes/java/util/LinkedList.java +++ b/jdk/src/java.base/share/classes/java/util/LinkedList.java @@ -70,7 +70,7 @@ import java.util.function.Consumer; * should be used only to detect bugs. * *

            This class is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch 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 dda514b313f..8dec9acd6c5 100644 --- a/jdk/src/java.base/share/classes/java/util/List.java +++ b/jdk/src/java.base/share/classes/java/util/List.java @@ -87,7 +87,7 @@ import java.util.function.UnaryOperator; * Such exceptions are marked as "optional" in the specification for this * interface. * - *

            Immutable List Static Factory Methods

            + *

            Immutable List Static Factory Methods

            *

            The {@link List#of(Object...) List.of()} static factory methods * provide a convenient way to create immutable lists. The {@code List} * instances created by these methods have the following characteristics: @@ -114,7 +114,7 @@ import java.util.function.UnaryOperator; * * *

            This interface is a member of the - * + * * Java Collections Framework. * * @param the type of elements in this list diff --git a/jdk/src/java.base/share/classes/java/util/ListIterator.java b/jdk/src/java.base/share/classes/java/util/ListIterator.java index 6ad98fe3fa3..2ec555754ea 100644 --- a/jdk/src/java.base/share/classes/java/util/ListIterator.java +++ b/jdk/src/java.base/share/classes/java/util/ListIterator.java @@ -46,7 +46,7 @@ package java.util; * {@link #previous()}. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @author Josh Bloch diff --git a/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java b/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java index 4c4498e1b6b..de43f09e5c5 100644 --- a/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java +++ b/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java @@ -56,7 +56,7 @@ import sun.util.ResourceBundleEnumeration; * that key. * *

            - * The following example shows two members of a resource + * The following example shows two members of a resource * bundle family with the base name "MyResources". * "MyResources" is the default member of the bundle family, and * "MyResources_fr" is the French member. diff --git a/jdk/src/java.base/share/classes/java/util/Locale.java b/jdk/src/java.base/share/classes/java/util/Locale.java index d4fae4bb544..45d13fa3db9 100644 --- a/jdk/src/java.base/share/classes/java/util/Locale.java +++ b/jdk/src/java.base/share/classes/java/util/Locale.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 @@ -83,7 +83,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * described below. * *

            - *
            language
            + *
            language
            * *
            ISO 639 alpha-2 or alpha-3 language code, or registered * language subtags up to 8 alpha letters (for future enhancements). @@ -101,7 +101,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * *
            Example: "en" (English), "ja" (Japanese), "kok" (Konkani)
            * - *
            script
            + *
            script
            * *
            ISO 15924 alpha-4 script code. You can find a full list of * valid script codes in the IANA Language Subtag Registry (search @@ -115,7 +115,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * *
            Example: "Latn" (Latin), "Cyrl" (Cyrillic)
            * - *
            country (region)
            + *
            country (region)
            * *
            ISO 3166 alpha-2 country code or UN M.49 numeric-3 area code. * You can find a full list of valid country and region codes in the @@ -129,7 +129,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; *
            Example: "US" (United States), "FR" (France), "029" * (Caribbean)
            * - *
            variant
            + *
            variant
            * *
            Any arbitrary value used to indicate a variation of a * Locale. Where there are two or more variant values @@ -160,7 +160,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * *
            Example: "polyton" (Polytonic Greek), "POSIX"
            * - *
            extensions
            + *
            extensions
            * *
            A map from single character keys to string values, indicating * extensions apart from language identification. The extensions in @@ -188,7 +188,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * requirement (is well-formed), but does not validate the value * itself. See {@link Builder} for details. * - *

            Unicode locale/language extension

            + *

            Unicode locale/language extension

            * *

            UTS#35, "Unicode Locale Data Markup Language" defines optional * attributes and keywords to override or refine the default behavior @@ -269,7 +269,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * * * - *

            Locale Matching

            + *

            Locale Matching

            * *

            If an application or a system is internationalized and provides localized * resources for multiple locales, it sometimes needs to find one or more @@ -408,7 +408,7 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * Clients desiring a string representation of the complete locale can * then always rely on toLanguageTag for this purpose. * - *

            Special cases
            + *
            Special cases
            * *

            For compatibility reasons, two * non-conforming locales are treated as special cases. These are @@ -1587,44 +1587,50 @@ public final class Locale implements Cloneable, Serializable { * *

            Grandfathered tags with canonical replacements are as follows: * - *

            GregorianCalendar default field values
            + * Field + * + Default Value + *
            Field
            - *
            Default Value
            - *
            - * ERA
            + *
            + * ERA * - * AD
            + *
            + * AD *
            - * YEAR
            + *
            + * YEAR * - * 1970
            + *
            + * 1970 *
            - * MONTH
            + *
            + * MONTH * - * JANUARY
            + *
            + * JANUARY *
            - * DAY_OF_MONTH
            + *
            + * DAY_OF_MONTH * - * 1
            + *
            + * 1 *
            - * DAY_OF_WEEK
            + *
            + * DAY_OF_WEEK * - * the first day of week
            + *
            + * the first day of week *
            - * WEEK_OF_MONTH
            + *
            + * WEEK_OF_MONTH * - * 0
            + *
            + * 0 *
            - * DAY_OF_WEEK_IN_MONTH
            + *
            + * DAY_OF_WEEK_IN_MONTH * - * 1
            + *
            + * 1 *
            - * AM_PM
            + *
            + * AM_PM * - * AM
            + *
            + * AM *
            - * HOUR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND
            + *
            + * HOUR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND * - * 0
            + *
            + * 0 *
            - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + *
            grandfathered tag modern replacement
            art-lojban jbo
            i-ami ami
            i-bnn bnn
            i-hak hak
            i-klingon tlh
            i-lux lb
            i-navajo nv
            i-pwn pwn
            i-tao tao
            i-tay tay
            i-tsu tsu
            no-bok nb
            no-nyn nn
            sgn-BE-FR sfb
            sgn-BE-NL vgt
            sgn-CH-DE sgg
            zh-guoyu cmn
            zh-hakka hak
            zh-min-nan nan
            zh-xiang hsn
            + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * * *
            Grandfathered tags with canonical replacements
            grandfathered tagmodern replacement
            art-lojbanjbo
            i-amiami
            i-bnnbnn
            i-hakhak
            i-klingontlh
            i-luxlb
            i-navajonv
            i-pwnpwn
            i-taotao
            i-taytay
            i-tsutsu
            no-boknb
            no-nynnn
            sgn-BE-FRsfb
            sgn-BE-NLvgt
            sgn-CH-DEsgg
            zh-guoyucmn
            zh-hakkahak
            zh-min-nannan
            zh-xianghsn
            * *

            Grandfathered tags with no modern replacement will be * converted as follows: * - * - * - * - * - * - * - * - * - * + *
            grandfathered tag converts to
            cel-gaulish xtg-x-cel-gaulish
            en-GB-oed en-GB-x-oed
            i-default en-x-i-default
            i-enochian und-x-i-enochian
            i-mingo see-x-i-mingo
            zh-min nan-x-zh-min
            + * + * + * + * + * + * + * + * + * + * + * * *
            Grandfathered tags with no modern replacement
            grandfathered tagconverts to
            cel-gaulishxtg-x-cel-gaulish
            en-GB-oeden-GB-x-oed
            i-defaulten-x-i-default
            i-enochianund-x-i-enochian
            i-mingosee-x-i-mingo
            zh-minnan-x-zh-min
            * @@ -2767,71 +2773,76 @@ public final class Locale implements Cloneable, Serializable { * * The filtering method will behave as follows: * - * + *
            + * + * * * * * * + * + * * - * - * - * * * - * - * - * + * * * - * - * - * * * - * - * - * + * * * - * - * - * + * * + * *
            Filtering method behavior
            Filtering ModeLanguage Priority List: {@code "de-DE"}Language Priority List: {@code "de-*-DE"}
            + * * {@link FilteringMode#AUTOSELECT_FILTERING AUTOSELECT_FILTERING} * + * * Performs basic filtering and returns {@code "de-DE"} and * {@code "de-DE-1996"}. * + * * Performs extended filtering and returns {@code "de-DE"}, * {@code "de-Deva-DE"}, {@code "de-DE-1996"}, {@code "de-Latn-DE"}, and * {@code "de-Latn-DE-1996"}. *
            + * * {@link FilteringMode#EXTENDED_FILTERING EXTENDED_FILTERING} * + * * Performs extended filtering and returns {@code "de-DE"}, * {@code "de-Deva-DE"}, {@code "de-DE-1996"}, {@code "de-Latn-DE"}, and * {@code "de-Latn-DE-1996"}. * Same as above.Same as above.
            + * * {@link FilteringMode#IGNORE_EXTENDED_RANGES IGNORE_EXTENDED_RANGES} * + * * Performs basic filtering and returns {@code "de-DE"} and * {@code "de-DE-1996"}. * + * * Performs basic filtering and returns {@code null} because * nothing matches. *
            + * * {@link FilteringMode#MAP_EXTENDED_RANGES MAP_EXTENDED_RANGES} * Same as above. + * Same as above. * Performs basic filtering and returns {@code "de-DE"} and * {@code "de-DE-1996"} because {@code "de-*-DE"} is mapped to * {@code "de-DE"}. *
            + * * {@link FilteringMode#REJECT_EXTENDED_RANGES REJECT_EXTENDED_RANGES} * Same as above. + * Same as above. * Throws {@link IllegalArgumentException} because {@code "de-*-DE"} is * not a valid basic language range. *
            * * @see #filter(List, Collection, FilteringMode) 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 153b86b8084..e3bee23b7ea 100644 --- a/jdk/src/java.base/share/classes/java/util/Map.java +++ b/jdk/src/java.base/share/classes/java/util/Map.java @@ -110,7 +110,7 @@ import java.io.Serializable; * Implementations may optionally handle the self-referential scenario, however * most current implementations do not do so. * - *

            Immutable Map Static Factory Methods

            + *

            Immutable Map Static Factory Methods

            *

            The {@link Map#of() Map.of()} and * {@link Map#ofEntries(Map.Entry...) Map.ofEntries()} * static factory methods provide a convenient way to create immutable maps. @@ -140,7 +140,7 @@ import java.io.Serializable; * * *

            This interface is a member of the - * + * * Java Collections Framework. * * @param the type of keys maintained by this map diff --git a/jdk/src/java.base/share/classes/java/util/NavigableMap.java b/jdk/src/java.base/share/classes/java/util/NavigableMap.java index 6045ee2b48f..8a2af7a7a2a 100644 --- a/jdk/src/java.base/share/classes/java/util/NavigableMap.java +++ b/jdk/src/java.base/share/classes/java/util/NavigableMap.java @@ -85,7 +85,7 @@ package java.util; * {@link #keySet()} can be overridden to return {@link NavigableSet}. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @author Doug Lea diff --git a/jdk/src/java.base/share/classes/java/util/NavigableSet.java b/jdk/src/java.base/share/classes/java/util/NavigableSet.java index 40843905271..4f1f0d510a9 100644 --- a/jdk/src/java.base/share/classes/java/util/NavigableSet.java +++ b/jdk/src/java.base/share/classes/java/util/NavigableSet.java @@ -79,7 +79,7 @@ package java.util; * {@code NavigableSet}. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @author Doug Lea diff --git a/jdk/src/java.base/share/classes/java/util/Objects.java b/jdk/src/java.base/share/classes/java/util/Objects.java index dad583b9206..c6bf3c96133 100644 --- a/jdk/src/java.base/share/classes/java/util/Objects.java +++ b/jdk/src/java.base/share/classes/java/util/Objects.java @@ -343,7 +343,8 @@ public final class Objects { */ public static T requireNonNull(T obj, Supplier messageSupplier) { if (obj == null) - throw new NullPointerException(messageSupplier.get()); + throw new NullPointerException(messageSupplier == null ? + null : messageSupplier.get()); return obj; } diff --git a/jdk/src/java.base/share/classes/java/util/Observable.java b/jdk/src/java.base/share/classes/java/util/Observable.java index b19830bb64e..d71bf5d5d4c 100644 --- a/jdk/src/java.base/share/classes/java/util/Observable.java +++ b/jdk/src/java.base/share/classes/java/util/Observable.java @@ -69,6 +69,8 @@ package java.util; * {@link java.beans} package. For reliable and ordered * messaging among threads, consider using one of the concurrent data * structures in the {@link java.util.concurrent} package. + * For reactive streams style programming, see the + * {@link java.util.concurrent.Flow} API. */ @Deprecated(since="9") public class Observable { diff --git a/jdk/src/java.base/share/classes/java/util/Optional.java b/jdk/src/java.base/share/classes/java/util/Optional.java index 94f3c17511a..5803d818deb 100644 --- a/jdk/src/java.base/share/classes/java/util/Optional.java +++ b/jdk/src/java.base/share/classes/java/util/Optional.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -36,9 +36,9 @@ import java.util.stream.Stream; * {@code get()} returns the value. * *

            Additional methods that depend on the presence or absence of a contained - * value are provided, such as {@link #orElse(java.lang.Object) orElse()} + * value are provided, such as {@link #orElse(Object) orElse()} * (returns a default value if no value is present) and - * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (performs an + * {@link #ifPresent(Consumer) ifPresent()} (performs an * action if a value is present). * *

            This is a value-based @@ -46,6 +46,13 @@ import java.util.stream.Stream; * ({@code ==}), identity hash code, or synchronization) on instances of * {@code Optional} may have unpredictable results and should be avoided. * + * @apiNote + * {@code Optional} is primarily intended for use as a method return type where + * there is a clear need to represent "no result," and where using {@code null} + * is likely to cause errors. A variable whose type is {@code Optional} should + * never itself be {@code null}; it should always point to an {@code Optional} + * instance. + * * @param the type of value * @since 1.8 */ @@ -129,6 +136,12 @@ public final class Optional { * If a value is present, returns the value, otherwise throws * {@code NoSuchElementException}. * + * @apiNote + * The methods {@link #orElse(Object) orElse} and + * {@link #orElseGet(Supplier) orElseGet} + * are generally preferable to this method, as they return a substitute + * value if the value is absent, instead of throwing an exception. + * * @return the non-{@code null} value described by this {@code Optional} * @throws NoSuchElementException if no value is present * @see Optional#isPresent() diff --git a/jdk/src/java.base/share/classes/java/util/OptionalDouble.java b/jdk/src/java.base/share/classes/java/util/OptionalDouble.java index 5a637d87b03..5472b34b5ff 100644 --- a/jdk/src/java.base/share/classes/java/util/OptionalDouble.java +++ b/jdk/src/java.base/share/classes/java/util/OptionalDouble.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 @@ -37,7 +37,7 @@ import java.util.stream.DoubleStream; *

            Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(double) orElse()} * (returns a default value if no value is present) and - * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (performs + * {@link #ifPresent(DoubleConsumer) ifPresent()} (performs * an action if a value is present). * *

            This is a value-based @@ -45,6 +45,12 @@ import java.util.stream.DoubleStream; * ({@code ==}), identity hash code, or synchronization) on instances of * {@code OptionalDouble} may have unpredictable results and should be avoided. * + * @apiNote + * {@code OptionalDouble} is primarily intended for use as a method return type where + * there is a clear need to represent "no result." A variable whose type is + * {@code OptionalDouble} should never itself be {@code null}; it should always point + * to an {@code OptionalDouble} instance. + * * @since 1.8 */ public final class OptionalDouble { @@ -110,6 +116,12 @@ public final class OptionalDouble { * If a value is present, returns the value, otherwise throws * {@code NoSuchElementException}. * + * @apiNote + * The methods {@link #orElse(double) orElse} and + * {@link #orElseGet(DoubleSupplier) orElseGet} + * are generally preferable to this method, as they return a substitute + * value if the value is absent, instead of throwing an exception. + * * @return the value described by this {@code OptionalDouble} * @throws NoSuchElementException if no value is present * @see OptionalDouble#isPresent() diff --git a/jdk/src/java.base/share/classes/java/util/OptionalInt.java b/jdk/src/java.base/share/classes/java/util/OptionalInt.java index cc56f47e4ba..12e588e56e9 100644 --- a/jdk/src/java.base/share/classes/java/util/OptionalInt.java +++ b/jdk/src/java.base/share/classes/java/util/OptionalInt.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 @@ -37,7 +37,7 @@ import java.util.stream.IntStream; *

            Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(int) orElse()} * (returns a default value if no value is present) and - * {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (performs an + * {@link #ifPresent(IntConsumer) ifPresent()} (performs an * action if a value is present). * *

            This is a value-based @@ -45,6 +45,12 @@ import java.util.stream.IntStream; * ({@code ==}), identity hash code, or synchronization) on instances of * {@code OptionalInt} may have unpredictable results and should be avoided. * + * @apiNote + * {@code OptionalInt} is primarily intended for use as a method return type where + * there is a clear need to represent "no result." A variable whose type is + * {@code OptionalInt} should never itself be {@code null}; it should always point + * to an {@code OptionalInt} instance. + * * @since 1.8 */ public final class OptionalInt { @@ -110,6 +116,12 @@ public final class OptionalInt { * If a value is present, returns the value, otherwise throws * {@code NoSuchElementException}. * + * @apiNote + * The methods {@link #orElse(int) orElse} and + * {@link #orElseGet(IntSupplier) orElseGet} + * are generally preferable to this method, as they return a substitute + * value if the value is absent, instead of throwing an exception. + * * @return the value described by this {@code OptionalInt} * @throws NoSuchElementException if no value is present * @see OptionalInt#isPresent() diff --git a/jdk/src/java.base/share/classes/java/util/OptionalLong.java b/jdk/src/java.base/share/classes/java/util/OptionalLong.java index b2c34339fd8..57dc8e59688 100644 --- a/jdk/src/java.base/share/classes/java/util/OptionalLong.java +++ b/jdk/src/java.base/share/classes/java/util/OptionalLong.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 @@ -37,7 +37,7 @@ import java.util.stream.LongStream; *

            Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(long) orElse()} * (returns a default value if no value is present) and - * {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (performs an + * {@link #ifPresent(LongConsumer) ifPresent()} (performs an * action if a value is present). * *

            This is a value-based @@ -45,6 +45,12 @@ import java.util.stream.LongStream; * ({@code ==}), identity hash code, or synchronization) on instances of * {@code OptionalLong} may have unpredictable results and should be avoided. * + * @apiNote + * {@code OptionalLong} is primarily intended for use as a method return type where + * there is a clear need to represent "no result." A variable whose type is + * {@code OptionalLong} should never itself be {@code null}; it should always point + * to an {@code OptionalLong} instance. + * * @since 1.8 */ public final class OptionalLong { @@ -110,6 +116,12 @@ public final class OptionalLong { * If a value is present, returns the value, otherwise throws * {@code NoSuchElementException}. * + * @apiNote + * The methods {@link #orElse(long) orElse} and + * {@link #orElseGet(LongSupplier) orElseGet} + * are generally preferable to this method, as they return a substitute + * value if the value is absent, instead of throwing an exception. + * * @return the value described by this {@code OptionalLong} * @throws NoSuchElementException if no value is present * @see OptionalLong#isPresent() diff --git a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java index 829eb01efea..28111ae16bf 100644 --- a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java +++ b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java @@ -73,7 +73,7 @@ import java.util.function.Consumer; * ({@code peek}, {@code element}, and {@code size}). * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/Properties.java b/jdk/src/java.base/share/classes/java/util/Properties.java index 85e294d3340..0b117686cea 100644 --- a/jdk/src/java.base/share/classes/java/util/Properties.java +++ b/jdk/src/java.base/share/classes/java/util/Properties.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 @@ -290,7 +290,7 @@ class Properties extends Hashtable { * specifies that the key is {@code "cheeses"} and the associated * element is the empty string {@code ""}. *

            - * + * * Characters in keys and elements can be represented in escape * sequences similar to those used for character and string literals * (see sections 3.3 and 3.10.6 of @@ -471,7 +471,7 @@ class Properties extends Hashtable { if (inStream != null) { //The line below is equivalent to calling a //ISO8859-1 decoder. - c = (char) (0xff & inByteBuf[inOff++]); + c = (char)(inByteBuf[inOff++] & 0xFF); } else { c = inCharBuf[inOff++]; } @@ -494,8 +494,25 @@ class Properties extends Hashtable { if (isNewLine) { isNewLine = false; if (c == '#' || c == '!') { + // Comment, quickly consume the rest of the line, + // resume on line-break and backslash. + if (inStream != null) { + while (inOff < inLimit) { + byte b = inByteBuf[inOff++]; + if (b == '\n' || b == '\r' || b == '\\') { + c = (char)(b & 0xFF); + break; + } + } + } else { + while (inOff < inLimit) { + c = inCharBuf[inOff++]; + if (c == '\n' || c == '\r' || c == '\\') { + break; + } + } + } isCommentLine = true; - continue; } } diff --git a/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java b/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java index 0866f22eefd..a7231fbef99 100644 --- a/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java +++ b/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java @@ -67,7 +67,7 @@ import sun.util.ResourceBundleEnumeration; * for a complete description of the search and instantiation strategy. * *

            - * The following example shows a member of a resource + * The following example shows a member of a resource * bundle family with the base name "MyResources". * The text defines the bundle "MyResources_de", * the German member of the bundle family. diff --git a/jdk/src/java.base/share/classes/java/util/Queue.java b/jdk/src/java.base/share/classes/java/util/Queue.java index e94b22c7fb2..f8383b67b41 100644 --- a/jdk/src/java.base/share/classes/java/util/Queue.java +++ b/jdk/src/java.base/share/classes/java/util/Queue.java @@ -47,12 +47,12 @@ package java.util; * implementations; in most implementations, insert operations cannot * fail. * - * + *
            * * * - * - * + * + * * * * @@ -125,7 +125,7 @@ package java.util; * ordering properties. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/RandomAccess.java b/jdk/src/java.base/share/classes/java/util/RandomAccess.java index a4d489313de..09793e633f6 100644 --- a/jdk/src/java.base/share/classes/java/util/RandomAccess.java +++ b/jdk/src/java.base/share/classes/java/util/RandomAccess.java @@ -59,7 +59,7 @@ package java.util; * * *

            This interface is a member of the - * + * * Java Collections Framework. * * @since 1.4 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 600b1810a2e..e7fecee180c 100644 --- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java +++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java @@ -50,7 +50,6 @@ import java.lang.ref.WeakReference; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; -import java.lang.reflect.Module; import java.net.JarURLConnection; import java.net.URL; import java.net.URLConnection; @@ -205,7 +204,7 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION; * known concrete subclasses {@code ListResourceBundle} and * {@code PropertyResourceBundle} are thread-safe. * - *

            Resource Bundles in Named Modules

            + *

            Resource Bundles in Named Modules

            * * When resource bundles are deployed in named modules, the following * module-specific requirements and restrictions are applied. @@ -240,7 +239,7 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION; * * * - *

            ResourceBundleProvider Service Providers

            + *

            ResourceBundleProvider Service Providers

            * * The {@code getBundle} factory methods load service providers of * {@link ResourceBundleProvider}, if available, using {@link ServiceLoader}. @@ -267,7 +266,7 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION; * {@link #getBundle(String, Locale, ClassLoader, Control) getBundle} * factory method for details. * - *

            For the {@code getBundle} factory + *

            For the {@code getBundle} factory * methods that take no {@link Control} instance, their default behavior of resource bundle loading * can be modified with custom {@link @@ -350,6 +349,8 @@ import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION; * @see MissingResourceException * @see ResourceBundleProvider * @since 1.1 + * @revised 9 + * @spec JPMS */ public abstract class ResourceBundle { @@ -870,6 +871,8 @@ public abstract class ResourceBundle { * @throws UnsupportedOperationException * if this method is called in a named module * @since 1.6 + * @revised 9 + * @spec JPMS */ @CallerSensitive public static final ResourceBundle getBundle(String baseName, @@ -938,6 +941,7 @@ public abstract class ResourceBundle { * specified module * @return a resource bundle for the given base name and the default locale * @since 9 + * @spec JPMS * @see ResourceBundleProvider */ @CallerSensitive @@ -991,6 +995,7 @@ public abstract class ResourceBundle { * be found in the specified {@code module} * @return a resource bundle for the given base name and locale in the module * @since 9 + * @spec JPMS */ @CallerSensitive public static ResourceBundle getBundle(String baseName, Locale targetLocale, Module module) { @@ -1036,6 +1041,8 @@ public abstract class ResourceBundle { * @throws UnsupportedOperationException * if this method is called in a named module * @since 1.6 + * @revised 9 + * @spec JPMS */ @CallerSensitive public static final ResourceBundle getBundle(String baseName, Locale targetLocale, @@ -1056,7 +1063,7 @@ public abstract class ResourceBundle { * description of modifying the default * behavior. * - *

            The following describes the default + *

            The following describes the default * behavior. * *

            @@ -1073,7 +1080,7 @@ public abstract class ResourceBundle { *

            getBundle uses the base name, the specified locale, and * the default locale (obtained from {@link java.util.Locale#getDefault() * Locale.getDefault}) to generate a sequence of candidate bundle names. If the specified + * id="candidates">candidate bundle names. If the specified * locale's language, script, country, and variant are all empty strings, * then the base name is the only candidate bundle name. Otherwise, a list * of candidate locales is generated from the attribute values of the @@ -1163,7 +1170,7 @@ public abstract class ResourceBundle { *

            If still no result bundle is found, the base name alone is looked up. If * this still fails, a MissingResourceException is thrown. * - *

            Once a result resource bundle has been found, + *

            Once a result resource bundle has been found, * its parent chain is instantiated. If the result bundle already * has a parent (perhaps because it was returned from a cache) the chain is * complete. @@ -1193,7 +1200,7 @@ public abstract class ResourceBundle { * path name (using "/") instead of a fully qualified class name (using * "."). * - *

            + *

            * Example: *

            * The following class and property files are provided: @@ -1215,12 +1222,15 @@ public abstract class ResourceBundle { *

            Calling getBundle with the locale arguments below will * instantiate resource bundles as follows: * - *

            Summary of Queue methods
            Throws exceptionReturns special valueThrows exceptionReturns special value
            Insert
            + *
            + * + * * * * * * + * *
            getBundle() locale to resource bundle mapping
            Locale("fr", "CH")MyResources_fr_CH.class, parent MyResources_fr.properties, parent MyResources.class
            Locale("fr", "FR")MyResources_fr.properties, parent MyResources.class
            Locale("de", "DE")MyResources_en.properties, parent MyResources.class
            Locale("en", "US")MyResources_en.properties, parent MyResources.class
            Locale("es", "ES")MyResources_es_ES.class, parent MyResources.class
            * *

            The file MyResources_fr_CH.properties is never used because it is @@ -1243,6 +1253,8 @@ public abstract class ResourceBundle { * @exception MissingResourceException * if no resource bundle for the specified base name can be found * @since 1.2 + * @revised 9 + * @spec JPMS */ @CallerSensitive public static ResourceBundle getBundle(String baseName, Locale locale, @@ -1302,9 +1314,9 @@ public abstract class ResourceBundle { * sequence of locale-format combinations to be used to call * control.newBundle. * - * - * + *
            + * + * * * * + * + * * * @@ -1465,6 +1479,8 @@ public abstract class ResourceBundle { * @throws UnsupportedOperationException * if this method is called in a named module * @since 1.6 + * @revised 9 + * @spec JPMS */ @CallerSensitive public static ResourceBundle getBundle(String baseName, Locale targetLocale, @@ -1824,7 +1840,7 @@ public abstract class ResourceBundle { cacheKey.setFormat(format); break; } - } catch (Exception e) { + } catch (LinkageError|Exception e) { cacheKey.setCause(e); } } @@ -2194,6 +2210,8 @@ public abstract class ResourceBundle { * by the caller's module. * * @since 1.6 + * @revised 9 + * @spec JPMS * @see ResourceBundle.Control#getTimeToLive(String,Locale) */ @CallerSensitive @@ -2468,13 +2486,15 @@ public abstract class ResourceBundle { * } * * - * @apiNote {@code ResourceBundle.Control} is not supported + * @apiNote {@code ResourceBundle.Control} is not supported * in named modules. If the {@code ResourceBundle.getBundle} method with * a {@code ResourceBundle.Control} is called in a named module, the method * will throw an {@link UnsupportedOperationException}. Any service providers * of {@link ResourceBundleControlProvider} are ignored in named modules. * * @since 1.6 + * @revised 9 + * @spec JPMS * @see java.util.spi.ResourceBundleProvider */ public static class Control { @@ -3103,6 +3123,8 @@ public abstract class ResourceBundle { * if an error occurred when reading resources using * any I/O operations * @see java.util.spi.ResourceBundleProvider#getBundle(String, Locale) + * @revised 9 + * @spec JPMS */ public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) diff --git a/jdk/src/java.base/share/classes/java/util/Scanner.java b/jdk/src/java.base/share/classes/java/util/Scanner.java index df075844364..381bcf3e6cc 100644 --- a/jdk/src/java.base/share/classes/java/util/Scanner.java +++ b/jdk/src/java.base/share/classes/java/util/Scanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, 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 @@ -95,7 +95,7 @@ import java.util.stream.StreamSupport; * s.close(); * } * - *

            The default whitespace delimiter used + *

            The default whitespace delimiter used * by a scanner is as recognized by {@link Character#isWhitespace(char) * Character.isWhitespace()}. The {@link #reset reset()} * method will reset the value of the scanner's delimiter to the default @@ -152,11 +152,11 @@ import java.util.stream.StreamSupport; * {@link #reset} method will reset the value of the scanner's radix to * {@code 10} regardless of whether it was previously changed. * - *

            Localized numbers

            + *

            Localized numbers

            * *

            An instance of this class is capable of scanning numbers in the standard * formats as well as in the formats of the scanner's locale. A scanner's - * initial locale is the value returned by the {@link + * initial locale is the value returned by the {@link * java.util.Locale#getDefault(Locale.Category) * Locale.getDefault(Locale.Category.FORMAT)} method; it may be changed via the {@link * #useLocale useLocale()} method. The {@link #reset} method will reset the value of the @@ -213,7 +213,7 @@ import java.util.stream.StreamSupport; * getInfinity()} * * - *

            Number syntax

            + *

            Number syntax

            * *

            The strings that can be parsed as numbers by an instance of this class * are specified in terms of the following regular-expression grammar, where @@ -244,7 +244,7 @@ import java.util.stream.StreamSupport; *

            {@code ( ( }Digit{@code + ) * | }GroupedNumeral{@code )} * - *
            Integer: + *
            Integer: *
            {@code ( [-+]? ( }Numeral{@code * ) )} *
            {@code | }LocalPositivePrefix Numeral @@ -263,7 +263,7 @@ import java.util.stream.StreamSupport; *
            Exponent: *
            {@code ( [eE] [+-]? }Digit{@code + )} * - *
            Decimal: + *
            Decimal: *
            {@code ( [-+]? }DecimalNumeral * Exponent{@code ? )} *
            {@code | }LocalPositivePrefix @@ -294,7 +294,7 @@ import java.util.stream.StreamSupport; * NonNumber * LocalNegativeSuffix * - *
            Float: + *
            Float: *
            Decimal * {@code | }HexFloat * {@code | }SignedNonNumber @@ -2846,6 +2846,7 @@ public final class Scanner implements Iterator, Closeable { class FindSpliterator extends Spliterators.AbstractSpliterator { final Pattern pattern; int expectedCount = -1; + private boolean advance = false; // true if we need to auto-advance FindSpliterator(Pattern pattern) { super(Long.MAX_VALUE, @@ -2861,12 +2862,15 @@ public final class Scanner implements Iterator, Closeable { throw new ConcurrentModificationException(); } } else { + // init + matchValid = false; + matcher.usePattern(pattern); expectedCount = modCount; } while (true) { // assert expectedCount == modCount - if (findPatternInBuffer(pattern, 0)) { // doesn't increment modCount + if (nextInBuffer()) { // doesn't increment modCount cons.accept(matcher.toMatchResult()); if (expectedCount != modCount) { throw new ConcurrentModificationException(); @@ -2879,6 +2883,29 @@ public final class Scanner implements Iterator, Closeable { return false; // reached end of input } } + + // reimplementation of findPatternInBuffer with auto-advance on zero-length matches + private boolean nextInBuffer() { + if (advance) { + if (position + 1 > buf.limit()) { + if (!sourceClosed) + needInput = true; + return false; + } + position++; + advance = false; + } + matcher.region(position, buf.limit()); + if (matcher.find() && (!matcher.hitEnd() || sourceClosed)) { + // Did not hit end, or hit real end + position = matcher.end(); + advance = matcher.start() == position; + return true; + } + if (!sourceClosed) + needInput = true; + return false; + } } /** Small LRU cache of Patterns. */ diff --git a/jdk/src/java.base/share/classes/java/util/ServiceLoader.java b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java index 0b437d44e2e..8d4cd8de611 100644 --- a/jdk/src/java.base/share/classes/java/util/ServiceLoader.java +++ b/jdk/src/java.base/share/classes/java/util/ServiceLoader.java @@ -31,10 +31,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Layer; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.Module; import java.net.URL; import java.net.URLConnection; import java.security.AccessControlContext; @@ -48,8 +46,8 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; import jdk.internal.loader.BootLoader; +import jdk.internal.loader.ClassLoaders; import jdk.internal.misc.JavaLangAccess; -import jdk.internal.misc.JavaLangReflectModuleAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.VM; import jdk.internal.module.ServicesCatalog; @@ -119,7 +117,7 @@ import jdk.internal.reflect.Reflection; * and deployed as an explicit module must have an appropriate uses * clause in its module descriptor to declare that the module uses * implementations of the service. A corresponding requirement is that a - * provider deployed as a named module must have an appropriate + * provider deployed as an explicit module must have an appropriate * provides clause in its module descriptor to declare that the module * provides an implementation of the service. The uses and * provides allow consumers of a service to be linked to modules @@ -127,13 +125,13 @@ import jdk.internal.reflect.Reflection; * *

            A service provider that is packaged as a JAR file for the class path is * identified by placing a provider-configuration file in the resource - * directory META-INF/services. The file's name is the fully-qualified + * directory {@code META-INF/services}. The file's name is the fully-qualified * binary name of the service's * type. The file contains a list of fully-qualified binary names of concrete * provider classes, one per line. Space and tab characters surrounding each * name, as well as blank lines, are ignored. The comment character is - * '#' ('\u0023', - * NUMBER SIGN); on + * {@code '#'} ('\u0023', + * NUMBER SIGN); on * each line all characters following the first comment character are ignored. * The file must be encoded in UTF-8. * If a particular concrete provider class is named in more than one @@ -159,7 +157,7 @@ import jdk.internal.reflect.Reflection; *

            Locating providers

            * *

            The {@code load} methods locate providers using a class loader or module - * {@link Layer layer}. When locating providers using a class loader then + * {@link ModuleLayer layer}. When locating providers using a class loader then * providers in both named and unnamed modules may be located. When locating * providers using a module layer then only providers in named modules in * the layer (or parent layers) are located. @@ -167,11 +165,11 @@ import jdk.internal.reflect.Reflection; *

            When locating providers using a class loader then any providers in named * modules defined to the class loader, or any class loader that is reachable * via parent delegation, are located. Additionally, providers in module layers - * other than the {@link Layer#boot() boot} layer, where the module layer + * other than the {@link ModuleLayer#boot() boot} layer, where the module layer * contains modules defined to the class loader, or any class loader reachable * via parent delegation, are also located. For example, suppose there is a * module layer where each module is defined to its own class loader (see {@link - * Layer#defineModulesWithManyLoaders defineModulesWithManyLoaders}). If the + * ModuleLayer#defineModulesWithManyLoaders defineModulesWithManyLoaders}). If the * {@code load} method is invoked to locate providers using any of these class * loaders for this layer then it will locate all of the providers in that * layer, irrespective of their defining class loader. @@ -197,14 +195,17 @@ import jdk.internal.reflect.Reflection; * will locate providers in modules defined to the class loader, then its * parent class loader, its parent parent, and so on to the bootstrap class * loader. If a {@code ClassLoader}, or any class loader in the parent - * delegation chain, defines modules in a custom module {@link Layer} then + * delegation chain, defines modules in a custom module {@link ModuleLayer} then * all providers in that layer are located, irrespective of their class * loader. The ordering of modules defined to the same class loader, or the * ordering of modules in a layer, is not defined. * *

          • If a named module declares more than one provider then the providers - * are located in the order that they appear in the {@code provides} table of - * the {@code Module} class file attribute ({@code module-info.class}).
          • + * are located in the iteration order of the {@link + * java.lang.module.ModuleDescriptor.Provides#providers() providers} list. + * Providers added dynamically by instrumentation agents ({@link + * java.lang.instrument.Instrumentation#redefineModule redefineModule}) + * are always located after providers declared by the module. * *
          • When locating providers in unnamed modules then the ordering is * based on the order that the class loader's {@link @@ -212,11 +213,11 @@ import jdk.internal.reflect.Reflection; * method finds the service configuration files.
          • * * - *

            Service loaders created to locate providers in a module {@link Layer} - * will first locate providers in the layer, before locating providers in - * parent layers. Traversal of parent layers is depth-first with each layer - * visited at most once. For example, suppose L0 is the boot layer, L1 and - * L2 are custom layers with L0 as their parent. Now suppose that L3 is + *

            Service loaders created to locate providers in a {@linkplain ModuleLayer + * module layer} will first locate providers in the layer, before locating + * providers in parent layers. Traversal of parent layers is depth-first with + * each layer visited at most once. For example, suppose L0 is the boot layer, + * L1 and L2 are custom layers with L0 as their parent. Now suppose that L3 is * created with L1 and L2 as the parents (in that order). Using a service * loader to locate providers with L3 as the content will locate providers * in the following order: L3, L1, L0, L2. The ordering of modules in a layer @@ -256,7 +257,7 @@ import jdk.internal.reflect.Reflection; * method in this class will cause a {@link NullPointerException} to be thrown. * *

            Example

            - *

            Suppose we have a service type com.example.CodecSet which is + *

            Suppose we have a service type {@code com.example.CodecSet} which is * intended to represent sets of encoder/decoder pairs for some protocol. In * this case it is an abstract class with two abstract methods: * @@ -264,11 +265,11 @@ import jdk.internal.reflect.Reflection; * public abstract Encoder getEncoder(String encodingName); * public abstract Decoder getDecoder(String encodingName); * - * Each method returns an appropriate object or null if the provider + * Each method returns an appropriate object or {@code null} if the provider * does not support the given encoding. Typical providers support more than * one encoding. * - *

            The CodecSet class creates and saves a single service instance + *

            The {@code CodecSet} class creates and saves a single service instance * at initialization: * *

            {@code
            @@ -335,6 +336,8 @@ import jdk.internal.reflect.Reflection;
              *
              * @author Mark Reinhold
              * @since 1.6
            + * @revised 9
            + * @spec JPMS
              */
             
             public final class ServiceLoader
            @@ -346,12 +349,12 @@ public final class ServiceLoader
                 // The class of the service type
                 private final String serviceName;
             
            -    // The module Layer used to locate providers; null when locating
            +    // The module layer used to locate providers; null when locating
                 // providers using a class loader
            -    private final Layer layer;
            +    private final ModuleLayer layer;
             
                 // The class loader used to locate, load, and instantiate providers;
            -    // null when locating provider using a module Layer
            +    // null when locating provider using a module layer
                 private final ClassLoader loader;
             
                 // The access control context taken when the ServiceLoader is created
            @@ -370,10 +373,8 @@ public final class ServiceLoader
                 private int reloadCount;
             
                 private static JavaLangAccess LANG_ACCESS;
            -    private static JavaLangReflectModuleAccess JLRM_ACCESS;
                 static {
                     LANG_ACCESS = SharedSecrets.getJavaLangAccess();
            -        JLRM_ACCESS = SharedSecrets.getJavaLangReflectModuleAccess();
                 }
             
                 /**
            @@ -386,6 +387,7 @@ public final class ServiceLoader
                  *
                  * @param   The service type
                  * @since 9
            +     * @spec JPMS
                  */
                 public static interface Provider extends Supplier {
                     /**
            @@ -418,13 +420,13 @@ public final class ServiceLoader
             
                 /**
                  * Initializes a new instance of this class for locating service providers
            -     * in a module Layer.
            +     * in a module layer.
                  *
                  * @throws ServiceConfigurationError
                  *         If {@code svc} is not accessible to {@code caller} or the caller
                  *         module does not use the service type.
                  */
            -    private ServiceLoader(Class caller, Layer layer, Class svc) {
            +    private ServiceLoader(Class caller, ModuleLayer layer, Class svc) {
                     Objects.requireNonNull(caller);
                     Objects.requireNonNull(layer);
                     Objects.requireNonNull(svc);
            @@ -505,12 +507,15 @@ public final class ServiceLoader
             
                 /**
                  * Checks that the given service type is accessible to types in the given
            -     * module, and check that the module declare that it uses the service type. ??
            +     * module, and check that the module declares that it uses the service type.
                  */
                 private static void checkCaller(Class caller, Class svc) {
            -        Module callerModule = caller.getModule();
            +        if (caller == null) {
            +            fail(svc, "no caller to check if it declares `uses`");
            +        }
             
                     // Check access to the service type
            +        Module callerModule = caller.getModule();
                     int mods = svc.getModifiers();
                     if (!Reflection.verifyMemberAccess(caller, svc, null, mods)) {
                         fail(svc, "service type not accessible to " + callerModule);
            @@ -819,13 +824,13 @@ public final class ServiceLoader
             
                 /**
                  * Implements lazy service provider lookup of service providers that
            -     * are provided by modules in a module Layer (or parent layers)
            +     * are provided by modules in a module layer (or parent layers)
                  */
                 private final class LayerLookupIterator
                     implements Iterator>
                 {
            -        Deque stack = new ArrayDeque<>();
            -        Set visited = new HashSet<>();
            +        Deque stack = new ArrayDeque<>();
            +        Set visited = new HashSet<>();
                     Iterator iterator;
                     ServiceProvider next;  // next provider to load
             
            @@ -834,8 +839,8 @@ public final class ServiceLoader
                         stack.push(layer);
                     }
             
            -        private Iterator providers(Layer layer) {
            -            ServicesCatalog catalog = JLRM_ACCESS.getServicesCatalog(layer);
            +        private Iterator providers(ModuleLayer layer) {
            +            ServicesCatalog catalog = LANG_ACCESS.getServicesCatalog(layer);
                         return catalog.findServices(serviceName).iterator();
                     }
             
            @@ -857,10 +862,10 @@ public final class ServiceLoader
                             if (stack.isEmpty())
                                 return false;
             
            -                Layer layer = stack.pop();
            -                List parents = layer.parents();
            +                ModuleLayer layer = stack.pop();
            +                List parents = layer.parents();
                             for (int i = parents.size() - 1; i >= 0; i--) {
            -                    Layer parent = parents.get(i);
            +                    ModuleLayer parent = parents.get(i);
                                 if (!visited.contains(parent)) {
                                     visited.add(parent);
                                     stack.push(parent);
            @@ -908,8 +913,8 @@ public final class ServiceLoader
                      * Returns iterator to iterate over the implementations of {@code
                      * service} in the given layer.
                      */
            -        private List providers(Layer layer) {
            -            ServicesCatalog catalog = JLRM_ACCESS.getServicesCatalog(layer);
            +        private List providers(ModuleLayer layer) {
            +            ServicesCatalog catalog = LANG_ACCESS.getServicesCatalog(layer);
                         return catalog.findServices(serviceName);
                     }
             
            @@ -927,26 +932,28 @@ public final class ServiceLoader
                         } else {
                             catalog = ServicesCatalog.getServicesCatalogOrNull(loader);
                         }
            -            Stream stream1;
            +            List providers;
                         if (catalog == null) {
            -                stream1 = Stream.empty();
            +                providers = List.of();
                         } else {
            -                stream1 = catalog.findServices(serviceName).stream();
            +                providers = catalog.findServices(serviceName);
                         }
             
                         // modules in custom layers that define modules to the class loader
            -            Stream stream2;
                         if (loader == null) {
            -                stream2 = Stream.empty();
            +                return providers.iterator();
                         } else {
            -                Layer bootLayer = Layer.boot();
            -                stream2 = JLRM_ACCESS.layers(loader)
            -                        .filter(l -> (l != bootLayer))
            -                        .map(l -> providers(l))
            -                        .flatMap(List::stream);
            +                List allProviders = new ArrayList<>(providers);
            +                ModuleLayer bootLayer = ModuleLayer.boot();
            +                Iterator iterator = LANG_ACCESS.layers(loader).iterator();
            +                while (iterator.hasNext()) {
            +                    ModuleLayer layer = iterator.next();
            +                    if (layer != bootLayer) {
            +                        allProviders.addAll(providers(layer));
            +                    }
            +                }
            +                return allProviders.iterator();
                         }
            -
            -            return Stream.concat(stream1, stream2).iterator();
                     }
             
                     @Override
            @@ -998,6 +1005,7 @@ public final class ServiceLoader
                 {
                     static final String PREFIX = "META-INF/services/";
             
            +        Set providerNames = new HashSet<>();  // to avoid duplicates
                     Enumeration configs;
                     Iterator pending;
                     Class nextClass;
            @@ -1007,7 +1015,7 @@ public final class ServiceLoader
             
                     /**
                      * Parse a single line from the given configuration file, adding the
            -         * name on the line to the names list.
            +         * name on the line to set of names if not already seen.
                      */
                     private int parseLine(URL u, BufferedReader r, int lc, Set names)
                         throws IOException
            @@ -1032,7 +1040,9 @@ public final class ServiceLoader
                                 if (!Character.isJavaIdentifierPart(cp) && (cp != '.'))
                                     fail(service, u, lc, "Illegal provider-class name: " + ln);
                             }
            -                names.add(ln);
            +                if (providerNames.add(ln)) {
            +                    names.add(ln);
            +                }
                         }
                         return lc + 1;
                     }
            @@ -1063,15 +1073,24 @@ public final class ServiceLoader
                             return true;
                         }
             
            -            Class clazz = null;
            +            Class clazz;
                         do {
                             if (configs == null) {
                                 try {
                                     String fullName = PREFIX + service.getName();
            -                        if (loader == null)
            +                        if (loader == null) {
                                         configs = ClassLoader.getSystemResources(fullName);
            -                        else
            +                        } else if (loader == ClassLoaders.platformClassLoader()) {
            +                            // The platform classloader doesn't have a class path,
            +                            // but the boot loader might.
            +                            if (BootLoader.hasClassPath()) {
            +                                configs = BootLoader.findResources(fullName);
            +                            } else {
            +                                configs = Collections.emptyEnumeration();
            +                            }
            +                        } else {
                                         configs = loader.getResources(fullName);
            +                        }
                                 } catch (IOException x) {
                                     fail(service, "Error locating configuration files", x);
                                 }
            @@ -1214,6 +1233,9 @@ public final class ServiceLoader
                  *
                  * @return  An iterator that lazily loads providers for this loader's
                  *          service
            +     *
            +     * @revised 9
            +     * @spec JPMS
                  */
                 public Iterator iterator() {
             
            @@ -1279,8 +1301,10 @@ public final class ServiceLoader
                  * provider to be loaded. 

            * *

            If this loader's provider caches are cleared by invoking the {@link - * #reload() reload} method then existing streams for this service - * loader should be discarded.

            + * #reload() reload} method then existing streams for this service loader + * should be discarded. The returned stream's source {@code Spliterator} is + * fail-fast and will throw {@link ConcurrentModificationException} + * if the provider cache has been cleared.

            * *

            The following examples demonstrate usage. The first example * creates a stream of providers, the second example is the same except @@ -1300,6 +1324,7 @@ public final class ServiceLoader * @return A stream that lazily loads providers for this loader's service * * @since 9 + * @spec JPMS */ public Stream> stream() { // use cached providers as the source when all providers loaded @@ -1377,7 +1402,7 @@ public final class ServiceLoader * * @param loader * The class loader to be used to load provider-configuration files - * and provider classes, or null if the system class + * and provider classes, or {@code null} if the system class * loader (or, failing that, the bootstrap class loader) is to be * used * @@ -1414,6 +1439,9 @@ public final class ServiceLoader * if the service type is not accessible to the caller or the * caller is in an explicit module and its module descriptor does * not declare that it uses {@code service} + * + * @revised 9 + * @spec JPMS */ @CallerSensitive public static ServiceLoader load(Class service, @@ -1457,6 +1485,9 @@ public final class ServiceLoader * if the service type is not accessible to the caller or the * caller is in an explicit module and its module descriptor does * not declare that it uses {@code service} + * + * @revised 9 + * @spec JPMS */ @CallerSensitive public static ServiceLoader load(Class service) { @@ -1490,6 +1521,9 @@ public final class ServiceLoader * if the service type is not accessible to the caller or the * caller is in an explicit module and its module descriptor does * not declare that it uses {@code service} + * + * @revised 9 + * @spec JPMS */ @CallerSensitive public static ServiceLoader loadInstalled(Class service) { @@ -1499,7 +1533,7 @@ public final class ServiceLoader /** * Creates a new service loader for the given service type that loads - * service providers from modules in the given {@code Layer} and its + * service providers from modules in the given {@code ModuleLayer} and its * ancestors. * * @apiNote Unlike the other load methods defined here, the service type @@ -1509,7 +1543,7 @@ public final class ServiceLoader * @param the class of the service type * * @param layer - * The module Layer + * The module layer * * @param service * The interface or abstract class representing the service @@ -1522,9 +1556,10 @@ public final class ServiceLoader * not declare that it uses {@code service} * * @since 9 + * @spec JPMS */ @CallerSensitive - public static ServiceLoader load(Layer layer, Class service) { + public static ServiceLoader load(ModuleLayer layer, Class service) { return new ServiceLoader<>(Reflection.getCallerClass(), layer, service); } @@ -1551,6 +1586,7 @@ public final class ServiceLoader * or error is thrown when locating or instantiating the provider. * * @since 9 + * @spec JPMS */ public Optional findFirst() { Iterator iterator = iterator(); 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 2dd9060f7df..32966e993e3 100644 --- a/jdk/src/java.base/share/classes/java/util/Set.java +++ b/jdk/src/java.base/share/classes/java/util/Set.java @@ -63,7 +63,7 @@ package java.util; * Such exceptions are marked as "optional" in the specification for this * interface. * - *

            Immutable Set Static Factory Methods

            + *

            Immutable Set Static Factory Methods

            *

            The {@link Set#of(Object...) Set.of()} static factory methods * provide a convenient way to create immutable sets. The {@code Set} * instances created by these methods have the following characteristics: @@ -91,7 +91,7 @@ package java.util; * * *

            This interface is a member of the - * + * * Java Collections Framework. * * @param the type of elements maintained by this set diff --git a/jdk/src/java.base/share/classes/java/util/SortedMap.java b/jdk/src/java.base/share/classes/java/util/SortedMap.java index 7f98152253c..3a57088859b 100644 --- a/jdk/src/java.base/share/classes/java/util/SortedMap.java +++ b/jdk/src/java.base/share/classes/java/util/SortedMap.java @@ -93,7 +93,7 @@ package java.util; * SortedMap<String, V> sub = m.subMap(low+"\0", high);

            * *

            This interface is a member of the - * + * * Java Collections Framework. * * @param the type of keys maintained by this map diff --git a/jdk/src/java.base/share/classes/java/util/SortedSet.java b/jdk/src/java.base/share/classes/java/util/SortedSet.java index 5eb7f76117d..e95a9775b61 100644 --- a/jdk/src/java.base/share/classes/java/util/SortedSet.java +++ b/jdk/src/java.base/share/classes/java/util/SortedSet.java @@ -89,7 +89,7 @@ package java.util; * SortedSet<String> sub = s.subSet(low+"\0", high); * *

            This interface is a member of the - * + * * Java Collections Framework. * * @param the type of elements maintained by this set diff --git a/jdk/src/java.base/share/classes/java/util/Spliterator.java b/jdk/src/java.base/share/classes/java/util/Spliterator.java index 96db12f0d60..485187952fe 100644 --- a/jdk/src/java.base/share/classes/java/util/Spliterator.java +++ b/jdk/src/java.base/share/classes/java/util/Spliterator.java @@ -62,7 +62,7 @@ import java.util.function.LongConsumer; * New characteristics may be defined in the future, so implementors should not * assign meanings to unlisted values. * - *

            A Spliterator that does not report {@code IMMUTABLE} or + *

            A Spliterator that does not report {@code IMMUTABLE} or * {@code CONCURRENT} is expected to have a documented policy concerning: * when the spliterator binds to the element source; and detection of * structural interference of the element source detected after binding. A diff --git a/jdk/src/java.base/share/classes/java/util/SplittableRandom.java b/jdk/src/java.base/share/classes/java/util/SplittableRandom.java index 1a6653d56c7..f852e1dcaea 100644 --- a/jdk/src/java.base/share/classes/java/util/SplittableRandom.java +++ b/jdk/src/java.base/share/classes/java/util/SplittableRandom.java @@ -779,8 +779,7 @@ public final class SplittableRandom { * @return a stream of pseudorandom {@code double} values, * each with the given origin (inclusive) and bound (exclusive) * @throws IllegalArgumentException if {@code streamSize} is - * less than zero - * @throws IllegalArgumentException if {@code randomNumberOrigin} + * less than zero, or {@code randomNumberOrigin} * is greater than or equal to {@code randomNumberBound} */ public DoubleStream doubles(long streamSize, double randomNumberOrigin, diff --git a/jdk/src/java.base/share/classes/java/util/TimeZone.java b/jdk/src/java.base/share/classes/java/util/TimeZone.java index 1180d38c491..b428cd668a7 100644 --- a/jdk/src/java.base/share/classes/java/util/TimeZone.java +++ b/jdk/src/java.base/share/classes/java/util/TimeZone.java @@ -74,7 +74,7 @@ import sun.util.locale.provider.TimeZoneNameUtility; * produce a TimeZone. The syntax of a custom time zone ID is: * *

            - * CustomID:
            + * CustomID:
              *         GMT Sign Hours : Minutes
              *         GMT Sign Hours Minutes
              *         GMT Sign Hours
            @@ -102,7 +102,7 @@ import sun.util.locale.provider.TimeZoneNameUtility;
              * When creating a TimeZone, the specified custom time
              * zone ID is normalized in the following syntax:
              * 
            - * NormalizedCustomID:
            + * NormalizedCustomID:
              *         GMT Sign TwoDigitHours : Minutes
              * Sign: one of
              *         + -
            diff --git a/jdk/src/java.base/share/classes/java/util/Timer.java b/jdk/src/java.base/share/classes/java/util/Timer.java
            index 770d9f9df8b..7c47d0c7135 100644
            --- a/jdk/src/java.base/share/classes/java/util/Timer.java
            +++ b/jdk/src/java.base/share/classes/java/util/Timer.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
            @@ -108,6 +108,7 @@ public class Timer {
                  * finalizer forgetting to call it.
                  */
                 private final Object threadReaper = new Object() {
            +        @SuppressWarnings("deprecation")
                     protected void finalize() throws Throwable {
                         synchronized(queue) {
                             thread.newTasksMayBeScheduled = false;
            diff --git a/jdk/src/java.base/share/classes/java/util/TreeMap.java b/jdk/src/java.base/share/classes/java/util/TreeMap.java
            index 2da0a5e8b28..5051282a9c9 100644
            --- a/jdk/src/java.base/share/classes/java/util/TreeMap.java
            +++ b/jdk/src/java.base/share/classes/java/util/TreeMap.java
            @@ -92,7 +92,7 @@ import java.util.function.Consumer;
              * associated map using {@code put}.)
              *
              * 

            This class is a member of the - * + * * Java Collections Framework. * * @param the type of keys maintained by this map diff --git a/jdk/src/java.base/share/classes/java/util/TreeSet.java b/jdk/src/java.base/share/classes/java/util/TreeSet.java index b80021e738e..8b110ef3b10 100644 --- a/jdk/src/java.base/share/classes/java/util/TreeSet.java +++ b/jdk/src/java.base/share/classes/java/util/TreeSet.java @@ -74,7 +74,7 @@ package java.util; * should be used only to detect bugs. * *

            This class is a member of the - * + * * Java Collections Framework. * * @param the type of elements maintained by this set diff --git a/jdk/src/java.base/share/classes/java/util/Vector.java b/jdk/src/java.base/share/classes/java/util/Vector.java index fb6c938c226..fac073b1116 100644 --- a/jdk/src/java.base/share/classes/java/util/Vector.java +++ b/jdk/src/java.base/share/classes/java/util/Vector.java @@ -70,7 +70,7 @@ import java.util.function.UnaryOperator; * *

            As of the Java 2 platform v1.2, this class was retrofitted to * implement the {@link List} interface, making it a member of the - * + * * Java Collections Framework. Unlike the new collection * implementations, {@code Vector} is synchronized. If a thread-safe * implementation is not needed, it is recommended to use {@link diff --git a/jdk/src/java.base/share/classes/java/util/WeakHashMap.java b/jdk/src/java.base/share/classes/java/util/WeakHashMap.java index 1aa8ec4396d..183b4c39729 100644 --- a/jdk/src/java.base/share/classes/java/util/WeakHashMap.java +++ b/jdk/src/java.base/share/classes/java/util/WeakHashMap.java @@ -120,7 +120,7 @@ import java.util.function.Consumer; * should be used only to detect bugs. * *

            This class is a member of the - * + * * Java Collections Framework. * * @param the type of keys maintained by this map diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java index 6af7c7a98bc..557ce73a7a3 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java @@ -76,7 +76,7 @@ import java.util.function.Predicate; * methods of the {@link Collection} and {@link Iterator} interfaces. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 @@ -1226,6 +1226,7 @@ public class ArrayBlockingQueue extends AbstractQueue } else { nextIndex = NONE; nextItem = null; + if (lastRet == REMOVED) detach(); } } finally { lock.unlock(); diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java index 27b05bf711b..f93af80ad48 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java @@ -53,17 +53,17 @@ import java.util.NoSuchElementException; * and the fourth blocks for only a given maximum time limit before giving * up. These methods are summarized in the following table: * - *

            locale-format combinations for newBundle
            Locale
            @@ -1313,6 +1325,8 @@ public abstract class ResourceBundle { * style="vertical-align: top; text-align: left; font-weight: bold; width: 50%;">format
            *
            Locale("de", "DE")
            *
            + *
            * * - * + * * * * - * - * - * - * + * + * + * + * * * * @@ -87,14 +87,14 @@ import java.util.NoSuchElementException; * * * - * + * * * * - * - * - * - * + * + * + * + * * * * @@ -128,14 +128,14 @@ import java.util.NoSuchElementException; * {@code BlockingQueue} interface are precisely equivalent to * {@code BlockingDeque} methods as indicated in the following table: * - *
            Summary of BlockingDeque methods
            First Element (Head) First Element (Head)
            Throws exceptionSpecial valueBlocksTimes outThrows exceptionSpecial valueBlocksTimes out
            Insertnot applicable
            Last Element (Tail) Last Element (Tail)
            Throws exceptionSpecial valueBlocksTimes outThrows exceptionSpecial valueBlocksTimes out
            Insert
            + *
            * * - * - * + * + * * * - * + * * * * @@ -154,7 +154,7 @@ import java.util.NoSuchElementException; * * * - * + * * * * @@ -173,7 +173,7 @@ import java.util.NoSuchElementException; * * * - * + * * * * @@ -193,7 +193,7 @@ import java.util.NoSuchElementException; * the {@code BlockingDeque} in another thread. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @since 1.6 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java index 03ca56d8791..65a523e6b40 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/BlockingQueue.java @@ -53,14 +53,14 @@ import java.util.Queue; * and the fourth blocks for only a given maximum time limit before giving * up. These methods are summarized in the following table: * - *

            Comparison of BlockingQueue and BlockingDeque methods
            {@code BlockingQueue} Method Equivalent {@code BlockingDeque} Method {@code BlockingQueue} Method Equivalent {@code BlockingDeque} Method
            Insert Insert
            {@link #add(Object) add(e)}{@link #offerLast(Object, long, TimeUnit) offerLast(e, time, unit)}
            Remove Remove
            {@link #remove() remove()}{@link #pollFirst(long, TimeUnit) pollFirst(time, unit)}
            Examine Examine
            {@link #element() element()}
            + *
            * * * - * - * - * - * + * + * + * + * * * * @@ -170,7 +170,7 @@ import java.util.Queue; * the {@code BlockingQueue} in another thread. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java index 1d80077b58c..77c42efd6fd 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -254,7 +254,7 @@ import jdk.internal.misc.Unsafe; *

            All arguments to all task methods must be non-null. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java index 58e16ae83b8..8546bfb3f46 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java @@ -85,7 +85,7 @@ import java.util.function.Predicate; * the {@code ConcurrentLinkedDeque} in another thread. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.7 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java index 6ce61b8f4ab..ac70f00bac6 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java @@ -99,7 +99,7 @@ import java.util.function.Predicate; * the {@code ConcurrentLinkedQueue} in another thread. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentMap.java index d301de9eee6..0a5cda1d81f 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentMap.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentMap.java @@ -61,7 +61,7 @@ import java.util.function.Function; * the {@code ConcurrentMap} in another thread. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentNavigableMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentNavigableMap.java index 0d763b6e9ea..5040e2ec4af 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentNavigableMap.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentNavigableMap.java @@ -43,7 +43,7 @@ import java.util.NavigableSet; * and recursively so for its navigable sub-maps. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @author Doug Lea diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java index 2ae29aa42f3..8be87529539 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java @@ -106,7 +106,7 @@ import java.util.function.Predicate; * elements. * *

            This class is a member of the - * + * * Java Collections Framework. * * @author Doug Lea diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java index 86be622c78b..d61fb2170cc 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java @@ -87,7 +87,7 @@ import java.util.Spliterator; * distinguished from the absence of elements. * *

            This class is a member of the - * + * * Java Collections Framework. * * @author Doug Lea diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java index 63bd252868d..592f9a51cd2 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -82,7 +82,7 @@ import java.util.function.UnaryOperator; * the {@code CopyOnWriteArrayList} in another thread. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java index 6e4ad018d2f..c8e984fab96 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArraySet.java @@ -87,7 +87,7 @@ import java.util.function.Predicate; * }} * *

            This class is a member of the - * + * * Java Collections Framework. * * @see CopyOnWriteArrayList diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/DelayQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/DelayQueue.java index 50997f7abda..73d66b9e64c 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/DelayQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/DelayQueue.java @@ -67,7 +67,7 @@ import java.util.concurrent.locks.ReentrantLock; * particular order. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java b/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java index a31e3a1ebac..00fdf25772c 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Executors.java @@ -713,6 +713,7 @@ public class Executors { FinalizableDelegatedExecutorService(ExecutorService executor) { super(executor); } + @SuppressWarnings("deprecation") protected void finalize() { super.shutdown(); } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java index 9b53a8a54f9..65e994350ce 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java @@ -271,11 +271,11 @@ public final class Flow { /** * Adds the given number {@code n} of items to the current * unfulfilled demand for this subscription. If {@code n} is - * negative, the Subscriber will receive an {@code onError} - * signal with an {@link IllegalArgumentException} argument. - * Otherwise, the Subscriber will receive up to {@code n} - * additional {@code onNext} invocations (or fewer if - * terminated). + * less than or equal to zero, the Subscriber will receive an + * {@code onError} signal with an {@link + * IllegalArgumentException} argument. Otherwise, the + * Subscriber will receive up to {@code n} additional {@code + * onNext} invocations (or fewer if terminated). * * @param n the increment of demand; a value of {@code * Long.MAX_VALUE} may be considered as effectively unbounded diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 330f4fb78a3..cd14b0057ec 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -109,12 +109,12 @@ import java.util.concurrent.locks.LockSupport; * async event-style tasks that are not usually joined, in which case * there is little difference among choice of methods. * - *

            Summary of BlockingQueue methods
            Throws exceptionSpecial valueBlocksTimes outThrows exceptionSpecial valueBlocksTimes out
            Insert
            + *
            * * * - * - * + * + * * * * diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java index 1db30b3b440..ec7b7eee5ce 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java @@ -68,7 +68,7 @@ import java.util.function.Predicate; * methods of the {@link Collection} and {@link Iterator} interfaces. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.6 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java index 7a1a2138073..368f6014dfa 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java @@ -71,7 +71,7 @@ import java.util.function.Predicate; * methods of the {@link Collection} and {@link Iterator} interfaces. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java index 3a919c1efad..c7ad85b9fc1 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java @@ -81,7 +81,7 @@ import java.util.function.Predicate; * the {@code LinkedTransferQueue} in another thread. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.7 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java index cdb1548eb61..8b0b3fec285 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -101,7 +101,7 @@ import java.util.function.Consumer; * }} * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java index 28e98a361ef..fafc11b8c15 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java @@ -588,6 +588,7 @@ public class SubmissionPublisher implements Flow.Publisher, if (!closed) { BufferedSubscription b; synchronized (this) { + // no need to re-check closed here b = clients; clients = null; closed = true; @@ -619,9 +620,11 @@ public class SubmissionPublisher implements Flow.Publisher, BufferedSubscription b; synchronized (this) { b = clients; - clients = null; - closed = true; - closedException = error; + if (!closed) { // don't clobber racing close + clients = null; + closedException = error; + closed = true; + } } while (b != null) { BufferedSubscription next = b.next; @@ -1362,9 +1365,9 @@ public class SubmissionPublisher implements Flow.Publisher, } } } - else if (n < 0L) + else onError(new IllegalArgumentException( - "negative subscription request")); + "non-positive subscription request")); } public final boolean isReleasable() { // for ManagedBlocker diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java index 165198f97f8..0a4049b6628 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java @@ -80,7 +80,7 @@ import java.util.concurrent.locks.ReentrantLock; * methods of the {@link Collection} and {@link Iterator} interfaces. * *

            This class is a member of the - * + * * Java Collections Framework. * * @since 1.5 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 cfc676aa39a..02820050420 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 @@ -49,6 +49,7 @@ import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.StreamSupport; import jdk.internal.misc.Unsafe; +import jdk.internal.misc.VM; /** * A random number generator isolated to the current thread. Like the @@ -699,8 +700,7 @@ public class ThreadLocalRandom extends Random { * @return a stream of pseudorandom {@code double} values, * each with the given origin (inclusive) and bound (exclusive) * @throws IllegalArgumentException if {@code streamSize} is - * less than zero - * @throws IllegalArgumentException if {@code randomNumberOrigin} + * less than zero, or {@code randomNumberOrigin} * is greater than or equal to {@code randomNumberBound} * @since 1.8 */ @@ -1094,11 +1094,8 @@ public class ThreadLocalRandom extends Random { // at end of to survive static initialization circularity static { - if (java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public Boolean run() { - return Boolean.getBoolean("java.util.secureRandomSeed"); - }})) { + String sec = VM.getSavedProperty("java.util.secureRandomSeed"); + if (Boolean.parseBoolean(sec)) { byte[] seedBytes = java.security.SecureRandom.getSeed(8); long s = (long)seedBytes[0] & 0xffL; for (int i = 1; i < 8; ++i) diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java index 0016bfffe87..ceb9bf2022f 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java @@ -1490,7 +1490,17 @@ public class ThreadPoolExecutor extends AbstractExecutorService { /** * Invokes {@code shutdown} when this executor is no longer * referenced and it has no threads. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() { shutdown(); } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/TransferQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/TransferQueue.java index 43d8f0c1395..0621bce2b76 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/TransferQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/TransferQueue.java @@ -58,7 +58,7 @@ package java.util.concurrent; * and {@code transfer} are effectively synonymous. * *

            This interface is a member of the - * + * * Java Collections Framework. * * @since 1.7 diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java index d228f73d39c..ab43971e84d 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java @@ -53,16 +53,14 @@ import jdk.internal.vm.annotation.ReservedStackAccess; * *

            *
            Non-fair mode (default) - *
            - * When constructed as non-fair (the default), the order of entry + *
            When constructed as non-fair (the default), the order of entry * to the read and write lock is unspecified, subject to reentrancy * constraints. A nonfair lock that is continuously contended may * indefinitely postpone one or more reader or writer threads, but * will normally have higher throughput than a fair lock. * *
            Fair mode - *
            - * When constructed as fair, threads contend for entry using an + *
            When constructed as fair, threads contend for entry using an * approximately arrival-order policy. When the currently held lock * is released, either the longest-waiting single writer thread will * be assigned the write lock, or if there is a group of reader threads diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java index ba072d7aa5d..4076cf59887 100644 --- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java +++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java @@ -48,7 +48,7 @@ import sun.security.util.SignatureFileVerifier; * processing multi-release jar files. The {@code Manifest} can be used * to specify meta-information about the jar file and its entries. * - *

            A multi-release jar file is a jar file that + *

            A multi-release jar file is a jar file that * contains a manifest with a main attribute named "Multi-Release", * a set of "base" entries, some of which are public classes with public * or protected methods that comprise the public interface of the jar file, diff --git a/jdk/src/java.base/share/classes/java/util/jar/Pack200.java b/jdk/src/java.base/share/classes/java/util/jar/Pack200.java index 01df2638039..c8862a8da7a 100644 --- a/jdk/src/java.base/share/classes/java/util/jar/Pack200.java +++ b/jdk/src/java.base/share/classes/java/util/jar/Pack200.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, 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 @@ -452,13 +452,13 @@ public abstract class Pack200 { String CODE_ATTRIBUTE_PFX = "pack.code.attribute."; /** - * The unpacker's progress as a percentage, as periodically - * updated by the unpacker. + * The packer's progress as a percentage, as periodically + * updated by the packer. * Values of 0 - 100 are normal, and -1 indicates a stall. * Progress can be monitored by polling the value of this * property. *

            - * At a minimum, the unpacker must set progress to 0 + * At a minimum, the packer must set progress to 0 * at the beginning of a packing operation, and to 100 * at the end. */ @@ -623,7 +623,7 @@ public abstract class Pack200 { * property. *

            * At a minimum, the unpacker must set progress to 0 - * at the beginning of a packing operation, and to 100 + * at the beginning of an unpacking operation, and to 100 * at the end. */ String PROGRESS = "unpack.progress"; @@ -631,7 +631,7 @@ public abstract class Pack200 { /** * Get the set of this engine's properties. This set is * a "live view", so that changing its - * contents immediately affects the Packer engine, and + * contents immediately affects the Unpacker engine, and * changes from the engine (such as progress indications) * are immediately visible in the map. * diff --git a/jdk/src/java.base/share/classes/java/util/package-info.java b/jdk/src/java.base/share/classes/java/util/package-info.java index ab706e0d179..e6406f14d3d 100644 --- a/jdk/src/java.base/share/classes/java/util/package-info.java +++ b/jdk/src/java.base/share/classes/java/util/package-info.java @@ -29,7 +29,7 @@ * miscellaneous utility classes (a string tokenizer, a random-number * generator, and a bit array). * - *

            Package Specification

            + *

            {@index "Java Collections Framework"}

            *
            Summary of task execution methods
            Call from non-fork/join clients Call from within fork/join computations Call from non-fork/join clients Call from within fork/join computations
            Arrange async execution
            - * - * - * - * + *
            ConstructMatches
            + * + * + * + * + * * + * + * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * - * + * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * - * + * + * * * * - * - * + * + * * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * + * * - * + * * - * + * * * * - * + * * - * - * + * * - * - * + * * * - * + * * - * + * * - * + * * - * + * * * * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * - * + * * * + * *
            Regular expression constructs, and what they match
            ConstructMatches
             
            Characters
            Characters
            x
            xThe character x
            {@code \\}
            {@code \\}The backslash character
            {@code \0}n
            {@code \0}nThe character with octal value {@code 0}n * (0 {@code <=} n {@code <=} 7)
            {@code \0}nn
            {@code \0}nnThe character with octal value {@code 0}nn * (0 {@code <=} n {@code <=} 7)
            {@code \0}mnn
            {@code \0}mnnThe character with octal value {@code 0}mnn * (0 {@code <=} m {@code <=} 3, * 0 {@code <=} n {@code <=} 7)
            {@code \x}hh
            {@code \x}hhThe character with hexadecimal value {@code 0x}hh
            \uhhhh
            \uhhhhThe character with hexadecimal value {@code 0x}hhhh
            \x{h...h}
            \x{h...h}The character with hexadecimal value {@code 0x}h...h * ({@link java.lang.Character#MIN_CODE_POINT Character.MIN_CODE_POINT} *  <= {@code 0x}h...h <=  * {@link java.lang.Character#MAX_CODE_POINT Character.MAX_CODE_POINT})
            \N{name}
            \N{name}The character with Unicode character name 'name'
            {@code \t}
            {@code \t}The tab character ('\u0009')
            {@code \n}
            {@code \n}The newline (line feed) character ('\u000A')
            {@code \r}
            {@code \r}The carriage-return character ('\u000D')
            {@code \f}
            {@code \f}The form-feed character ('\u000C')
            {@code \a}
            {@code \a}The alert (bell) character ('\u0007')
            {@code \e}
            {@code \e}The escape character ('\u001B')
            {@code \c}x
            {@code \c}xThe control character corresponding to x
             
            Character classes
            Character classes
            {@code [abc]}
            {@code [abc]}{@code a}, {@code b}, or {@code c} (simple class)
            {@code [^abc]}
            {@code [^abc]}Any character except {@code a}, {@code b}, or {@code c} (negation)
            {@code [a-zA-Z]}
            {@code [a-zA-Z]}{@code a} through {@code z} * or {@code A} through {@code Z}, inclusive (range)
            {@code [a-d[m-p]]}
            {@code [a-d[m-p]]}{@code a} through {@code d}, * or {@code m} through {@code p}: {@code [a-dm-p]} (union)
            {@code [a-z&&[def]]}
            {@code [a-z&&[def]]}{@code d}, {@code e}, or {@code f} (intersection)
            {@code [a-z&&[^bc]]}
            {@code [a-z&&[^bc]]}{@code a} through {@code z}, * except for {@code b} and {@code c}: {@code [ad-z]} (subtraction)
            {@code [a-z&&[^m-p]]}
            {@code [a-z&&[^m-p]]}{@code a} through {@code z}, * and not {@code m} through {@code p}: {@code [a-lq-z]}(subtraction)
             
            Predefined character classes
            Predefined character classes
            {@code .}
            {@code .}Any character (may or may not match line terminators)
            {@code \d}
            {@code \d}A digit: {@code [0-9]}
            {@code \D}
            {@code \D}A non-digit: {@code [^0-9]}
            {@code \h}
            {@code \h}A horizontal whitespace character: * [ \t\xA0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000]
            {@code \H}
            {@code \H}A non-horizontal whitespace character: {@code [^\h]}
            {@code \s}
            {@code \s}A whitespace character: {@code [ \t\n\x0B\f\r]}
            {@code \S}
            {@code \S}A non-whitespace character: {@code [^\s]}
            {@code \v}
            {@code \v}A vertical whitespace character: [\n\x0B\f\r\x85\u2028\u2029] *
            {@code \V}
            {@code \V}A non-vertical whitespace character: {@code [^\v]}
            {@code \w}
            {@code \w}A word character: {@code [a-zA-Z_0-9]}
            {@code \W}
            {@code \W}A non-word character: {@code [^\w]}
             
            POSIX character classes (US-ASCII only)
            POSIX character classes (US-ASCII only)
            {@code \p{Lower}}
            {@code \p{Lower}}A lower-case alphabetic character: {@code [a-z]}
            {@code \p{Upper}}
            {@code \p{Upper}}An upper-case alphabetic character:{@code [A-Z]}
            {@code \p{ASCII}}
            {@code \p{ASCII}}All ASCII:{@code [\x00-\x7F]}
            {@code \p{Alpha}}
            {@code \p{Alpha}}An alphabetic character:{@code [\p{Lower}\p{Upper}]}
            {@code \p{Digit}}
            {@code \p{Digit}}A decimal digit: {@code [0-9]}
            {@code \p{Alnum}}
            {@code \p{Alnum}}An alphanumeric character:{@code [\p{Alpha}\p{Digit}]}
            {@code \p{Punct}}
            {@code \p{Punct}}Punctuation: One of {@code !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~}
            {@code \p{Graph}}
            {@code \p{Graph}}A visible character: {@code [\p{Alnum}\p{Punct}]}
            {@code \p{Print}}
            {@code \p{Print}}A printable character: {@code [\p{Graph}\x20]}
            {@code \p{Blank}}
            {@code \p{Blank}}A space or a tab: {@code [ \t]}
            {@code \p{Cntrl}}
            {@code \p{Cntrl}}A control character: {@code [\x00-\x1F\x7F]}
            {@code \p{XDigit}}
            {@code \p{XDigit}}A hexadecimal digit: {@code [0-9a-fA-F]}
            {@code \p{Space}}
            {@code \p{Space}}A whitespace character: {@code [ \t\n\x0B\f\r]}
             
            java.lang.Character classes (simple java character type)
            java.lang.Character classes (simple java character type)
            {@code \p{javaLowerCase}}
            {@code \p{javaLowerCase}}Equivalent to java.lang.Character.isLowerCase()
            {@code \p{javaUpperCase}}
            {@code \p{javaUpperCase}}Equivalent to java.lang.Character.isUpperCase()
            {@code \p{javaWhitespace}}
            {@code \p{javaWhitespace}}Equivalent to java.lang.Character.isWhitespace()
            {@code \p{javaMirrored}}
            {@code \p{javaMirrored}}Equivalent to java.lang.Character.isMirrored()
             
            Classes for Unicode scripts, blocks, categories and binary properties
            {@code \p{IsLatin}}
            Classes for Unicode scripts, blocks, categories and binary properties
            {@code \p{IsLatin}}A Latin script character (script)
            {@code \p{InGreek}}
            {@code \p{InGreek}}A character in the Greek block (block)
            {@code \p{Lu}}
            {@code \p{Lu}}An uppercase letter (category)
            {@code \p{IsAlphabetic}}
            {@code \p{IsAlphabetic}}An alphabetic character (binary property)
            {@code \p{Sc}}
            {@code \p{Sc}}A currency symbol
            {@code \P{InGreek}}
            {@code \P{InGreek}}Any character except one in the Greek block (negation)
            {@code [\p{L}&&[^\p{Lu}]]}
            {@code [\p{L}&&[^\p{Lu}]]}Any letter except an uppercase letter (subtraction)
             
            Boundary matchers
            Boundary matchers
            {@code ^}
            {@code ^}The beginning of a line
            {@code $}
            {@code $}The end of a line
            {@code \b}
            {@code \b}A word boundary
            {@code \b{g}}
            {@code \b{g}}A Unicode extended grapheme cluster boundary
            {@code \B}
            {@code \B}A non-word boundary
            {@code \A}
            {@code \A}The beginning of the input
            {@code \G}
            {@code \G}The end of the previous match
            {@code \Z}
            {@code \Z}The end of the input but for the final * terminator, if any
            {@code \z}
            {@code \z}The end of the input
             
            Linebreak matcher
            {@code \R}
            Linebreak matcher
            {@code \R}Any Unicode linebreak sequence, is equivalent to * \u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029] *
             
            Unicode Extended Grapheme matcher
            {@code \X}
            Unicode Extended Grapheme matcher
            {@code \X}Any Unicode extended grapheme cluster
             
            Greedy quantifiers
            Greedy quantifiers
            X{@code ?}
            X{@code ?}X, once or not at all
            X{@code *}
            X{@code *}X, zero or more times
            X{@code +}
            X{@code +}X, one or more times
            X{n}
            X{n}X, exactly n times
            X{n{@code ,}}
            X{n{@code ,}}X, at least n times
            X{n{@code ,}m}
            X{n{@code ,}m}X, at least n but not more than m times
             
            Reluctant quantifiers
            Reluctant quantifiers
            X{@code ??}
            X{@code ??}X, once or not at all
            X{@code *?}
            X{@code *?}X, zero or more times
            X{@code +?}
            X{@code +?}X, one or more times
            X{n}?
            X{n}?X, exactly n times
            X{n,}?
            X{n,}?X, at least n times
            X{n{@code ,}m}?
            X{n{@code ,}m}?X, at least n but not more than m times
             
            Possessive quantifiers
            Possessive quantifiers
            X{@code ?+}
            X{@code ?+}X, once or not at all
            X{@code *+}
            X{@code *+}X, zero or more times
            X{@code ++}
            X{@code ++}X, one or more times
            X{n}+
            X{n}+X, exactly n times
            X{n,}+
            X{n,}+X, at least n times
            X{n{@code ,}m}+
            X{n{@code ,}m}+X, at least n but not more than m times
             
            Logical operators
            Logical operators
            XY
            XYX followed by Y
            X{@code |}Y
            X{@code |}YEither X or Y
            {@code (}X{@code )}
            {@code (}X{@code )}X, as a capturing group
             
            Back references
            Back references
            {@code \}nWhatever the nth + *
            {@code \}nWhatever the nth * capturing group matched
            {@code \}k<name>Whatever the + *
            {@code \}k<name>Whatever the * named-capturing group "name" matched
             
            Quotation
            Quotation
            {@code \}
            {@code \}Nothing, but quotes the following character
            {@code \Q}
            {@code \Q}Nothing, but quotes all characters until {@code \E}
            {@code \E}
            {@code \E}Nothing, but ends quoting started by {@code \Q}
             
            Special constructs (named-capturing and non-capturing)
            Special constructs (named-capturing and non-capturing)
            (?<name>X{@code )}
            (?<name>X{@code )}X, as a named-capturing group
            {@code (?:}X{@code )}
            {@code (?:}X{@code )}X, as a non-capturing group
            (?idmsuxU-idmsuxU) 
            (?idmsuxU-idmsuxU) Nothing, but turns match flags i * d m s * u x U * on - off
            (?idmsux-idmsux:X{@code )}  
            (?idmsux-idmsux:X{@code )}  X, as a non-capturing group with the * given flags i d * m s u * x on - off
            {@code (?=}X{@code )}
            {@code (?=}X{@code )}X, via zero-width positive lookahead
            {@code (?!}X{@code )}
            {@code (?!}X{@code )}X, via zero-width negative lookahead
            {@code (?<=}X{@code )}
            {@code (?<=}X{@code )}X, via zero-width positive lookbehind
            {@code (?X{@code )}
            {@code (?X{@code )}X, via zero-width negative lookbehind
            {@code (?>}X{@code )}
            {@code (?>}X{@code )}X, as an independent, non-capturing group
            * *


            * * - *

            Backslashes, escapes, and quoting

            + *

            Backslashes, escapes, and quoting

            * *

            The backslash character ({@code '\'}) serves to introduce escaped * constructs, as defined in the table above, as well as to quote characters @@ -416,7 +419,7 @@ import java.util.stream.StreamSupport; * {@code (hello)} the string literal {@code "\\(hello\\)"} * must be used. * - *

            Character Classes

            + *

            Character Classes

            * *

            Character classes may appear within other character classes, and * may be composed by the union operator (implicit) and the intersection @@ -429,8 +432,9 @@ import java.util.stream.StreamSupport; *

            The precedence of character-class operators is as follows, from * highest to lowest: * - *

            + *
            + * + * * * * @@ -446,6 +450,7 @@ import java.util.stream.StreamSupport; * * * + * *
            Precedence of character class operators.
            1    Literal escape    {@code \x}
            5    Intersection{@code [a-z&&[aeiou]]}
            * *

            Note that a different set of metacharacters are in effect inside @@ -454,7 +459,7 @@ import java.util.stream.StreamSupport; * character class, while the expression {@code -} becomes a range * forming metacharacter. * - *

            Line terminators

            + *

            Line terminators

            * *

            A line terminator is a one- or two-character sequence that marks * the end of a line of the input character sequence. The following are @@ -489,14 +494,16 @@ import java.util.stream.StreamSupport; * except at the end of input. When in {@link #MULTILINE} mode {@code $} * matches just before a line terminator or the end of the input sequence. * - *

            Groups and capturing

            + *

            Groups and capturing

            * - *

            Group number

            + *

            Group number

            *

            Capturing groups are numbered by counting their opening parentheses from * left to right. In the expression {@code ((A)(B(C)))}, for example, there * are four such groups:

            * - *
            + *
            + * + * * * * @@ -505,6 +512,7 @@ import java.util.stream.StreamSupport; * * * + * *
            Capturing group numberings
            1    {@code ((A)(B(C)))}
            2    {@code (B(C))}
            4    {@code (C)}
            * *

            Group zero always stands for the entire expression. @@ -514,7 +522,7 @@ import java.util.stream.StreamSupport; * subsequence may be used later in the expression, via a back reference, and * may also be retrieved from the matcher once the match operation is complete. * - *

            Group name

            + *

            Group name

            *

            A capturing group can also be assigned a "name", a {@code named-capturing group}, * and then be back-referenced later by the "name". Group names are composed of * the following characters. The first character must be a {@code letter}. @@ -585,7 +593,7 @@ import java.util.stream.StreamSupport; * and outside of a character class. * *

            - * Scripts are specified either with the prefix {@code Is}, as in + * Scripts are specified either with the prefix {@code Is}, as in * {@code IsHiragana}, or by using the {@code script} keyword (or its short * form {@code sc}) as in {@code script=Hiragana} or {@code sc=Hiragana}. *

            @@ -594,7 +602,7 @@ import java.util.stream.StreamSupport; * {@link java.lang.Character.UnicodeScript#forName(String) UnicodeScript.forName}. * *

            - * Blocks are specified with the prefix {@code In}, as in + * Blocks are specified with the prefix {@code In}, as in * {@code InMongolian}, or by using the keyword {@code block} (or its short * form {@code blk}) as in {@code block=Mongolian} or {@code blk=Mongolian}. *

            @@ -603,7 +611,7 @@ import java.util.stream.StreamSupport; * {@link java.lang.Character.UnicodeBlock#forName(String) UnicodeBlock.forName}. *

            * - * Categories may be specified with the optional prefix {@code Is}: + * Categories may be specified with the optional prefix {@code Is}: * Both {@code \p{L}} and {@code \p{IsL}} denote the category of Unicode * letters. Same as scripts and blocks, categories can also be specified * by using the keyword {@code general_category} (or its short form @@ -616,7 +624,7 @@ import java.util.stream.StreamSupport; * defined in the Standard, both normative and informative. *

            * - * Binary properties are specified with the prefix {@code Is}, as in + * Binary properties are specified with the prefix {@code Is}, as in * {@code IsAlphabetic}. The supported binary properties by {@code Pattern} * are *

              @@ -641,12 +649,15 @@ import java.util.stream.StreamSupport; * of Unicode Regular Expression * , when {@link #UNICODE_CHARACTER_CLASS} flag is specified. * - * - * - * - * - * + *
              ClassesMatches
              + * + * + * + * + * + * + * + * * * * @@ -685,9 +696,10 @@ import java.util.stream.StreamSupport; * * * + * *
              predefined and posix character classes in Unicode mode
              ClassesMatches
              {@code \p{Lower}}A lowercase character:{@code \p{IsLowercase}}
              {@code \p{Upper}}A word character: {@code [\p{Alpha}\p{gc=Mn}\p{gc=Me}\p{gc=Mc}\p{Digit}\p{gc=Pc}\p{IsJoin_Control}]}
              {@code \W}A non-word character: {@code [^\w]}
              *

              - * + * * Categories that behave like the java.lang.Character * boolean ismethodname methods (except for the deprecated ones) are * available through the same \p{prop} syntax where @@ -1207,29 +1219,33 @@ public final class Pattern *

              The input {@code "boo:and:foo"}, for example, yields the following * results with these parameters: * - *

              - * - * - * - * - * + *
              Regex    Limit    Result    
              :2
              + * + * + * + * + * + * + * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * + * *
              Split examples showing regex, limit, and result
              Regex    Limit    Result    
              :2{@code { "boo", "and:foo" }}
              :5
              :5{@code { "boo", "and", "foo" }}
              :-2
              :-2{@code { "boo", "and", "foo" }}
              o5
              o5{@code { "b", "", ":and:f", "", "" }}
              o-2
              o-2{@code { "b", "", ":and:f", "", "" }}
              o0
              o0{@code { "b", "", ":and:f" }}
              * * @param input @@ -1294,14 +1310,18 @@ public final class Pattern *

              The input {@code "boo:and:foo"}, for example, yields the following * results with these expressions: * - *

              - * - * - * + *
              Regex    Result
              :
              + * + * + * + * + * + * + * * - * + * * + * *
              Split examples showing regex and result
              Regex    Result
              :{@code { "boo", "and", "foo" }}
              o
              o{@code { "b", "", ":and:f" }}
              * * @@ -3867,8 +3887,10 @@ loop: for(int x=0, offset=0; x * * @since 9 + * @spec JPMS */ public abstract class AbstractResourceBundleProvider implements ResourceBundleProvider { private static final JavaUtilResourceBundleAccess RB_ACCESS = diff --git a/jdk/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java b/jdk/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java index c0a0ad806aa..396ffeae696 100644 --- a/jdk/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java +++ b/jdk/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -33,7 +33,7 @@ import java.util.Map; * An abstract class for service providers that provide localized string * representations (display names) of {@code Calendar} field values. * - *

              Calendar Types + *

              Calendar Types * *

              Calendar types are used to specify calendar systems for which the {@link * #getDisplayName(String, int, int, int, Locale) getDisplayName} and {@link @@ -46,12 +46,16 @@ import java.util.Map; * Calendar}. The following are calendar-common fields and their values to be * supported for each calendar system. * - * + *
              + * + * * * * * * + * + * * * * @@ -73,17 +77,22 @@ import java.util.Map; * * * + * *
              Field values
              FieldValueDescription
              {@link Calendar#MONTH}{@link Calendar#JANUARY} to {@link Calendar#UNDECIMBER}{@link Calendar#AM} to {@link Calendar#PM}0 - AM, 1 - PM
              * *

              The following are calendar-specific fields and their values to be supported. * - * + *
              + * + * * * * * * * + * + * * * * @@ -154,6 +163,7 @@ import java.util.Map; * * * + * *
              Calendar type and field values
              Calendar TypeFieldValueDescription
              {@code "gregory"}{@link Calendar#ERA}1Anno Hijrah (AH)
              * *

              Calendar field value names for {@code "gregory"} must be consistent with diff --git a/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java b/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java index f74830b4d6a..871d9192ec0 100644 --- a/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java +++ b/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java @@ -44,6 +44,8 @@ import java.util.ResourceBundle; * * @author Masayoshi Okutsu * @since 1.8 + * @revised 9 + * @spec JPMS * @see ResourceBundle#getBundle(String, java.util.Locale, ClassLoader, ResourceBundle.Control) * ResourceBundle.getBundle * @see java.util.ServiceLoader#load(Class) diff --git a/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java b/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java index 0074ae32090..251831f1dcb 100644 --- a/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java +++ b/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleProvider.java @@ -57,6 +57,7 @@ import java.util.ResourceBundle; * @see * ResourceBundleProvider Service Providers * @since 9 + * @spec JPMS */ public interface ResourceBundleProvider { /** diff --git a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java index 17c743a9064..02f9ada39c0 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java @@ -720,8 +720,9 @@ public final class Collectors { * the result is 0. * * @param the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property + * @param mapper a function extracting the property to be averaged + * @return a {@code Collector} that produces the arithmetic mean of a + * derived property */ public static Collector averagingInt(ToIntFunction mapper) { @@ -738,8 +739,9 @@ public final class Collectors { * the result is 0. * * @param the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property + * @param mapper a function extracting the property to be averaged + * @return a {@code Collector} that produces the arithmetic mean of a + * derived property */ public static Collector averagingLong(ToLongFunction mapper) { @@ -769,8 +771,9 @@ public final class Collectors { * 253, leading to additional numerical errors. * * @param the type of the input elements - * @param mapper a function extracting the property to be summed - * @return a {@code Collector} that produces the sum of a derived property + * @param mapper a function extracting the property to be averaged + * @return a {@code Collector} that produces the arithmetic mean of a + * derived property */ public static Collector averagingDouble(ToDoubleFunction mapper) { diff --git a/jdk/src/java.base/share/classes/java/util/stream/StreamOpFlag.java b/jdk/src/java.base/share/classes/java/util/stream/StreamOpFlag.java index e4ad988eaf1..a8e06b2f7ce 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/StreamOpFlag.java +++ b/jdk/src/java.base/share/classes/java/util/stream/StreamOpFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -41,7 +41,7 @@ import java.util.Spliterator; * contexts: * *

              - * + *
              * * * diff --git a/jdk/src/java.base/share/classes/java/util/stream/package-info.java b/jdk/src/java.base/share/classes/java/util/stream/package-info.java index f580d8fb372..03904e01df6 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/package-info.java +++ b/jdk/src/java.base/share/classes/java/util/stream/package-info.java @@ -94,7 +94,7 @@ *

              Additional stream sources can be provided by third-party libraries using * these techniques. * - *

              Stream operations and pipelines

              + *

              Stream operations and pipelines

              * *

              Stream operations are divided into intermediate and * terminal operations, and are combined to form stream @@ -159,7 +159,7 @@ * is a necessary, but not sufficient, condition for the processing of an infinite * stream to terminate normally in finite time. * - *

              Parallelism

              + *

              Parallelism

              * *

              Processing elements with an explicit {@code for-}loop is inherently serial. * Streams facilitate parallel execution by reframing the computation as a pipeline of @@ -206,7 +206,7 @@ * as {@link java.util.function.Function}, and are often lambda expressions or * method references. * - *

              Non-interference

              + *

              Non-interference

              * * Streams enable you to execute possibly-parallel aggregate operations over a * variety of data sources, including even non-thread-safe collections such as @@ -252,7 +252,7 @@ * Low-level stream * construction for requirements for building well-behaved streams. * - *

              Stateless behaviors

              + *

              Stateless behaviors

              * * Stream pipeline results may be nondeterministic or incorrect if the behavioral * parameters to the stream operations are stateful. A stateful lambda @@ -280,7 +280,7 @@ * parameters to stream operations entirely; there is usually a way to * restructure the stream pipeline to avoid statefulness. * - *

              Side-effects

              + *

              Side-effects

              * * Side-effects in behavioral parameters to stream operations are, in general, * discouraged, as they can often lead to unwitting violations of the @@ -349,7 +349,7 @@ * .collect(Collectors.toList()); // No side-effects! * } * - *

              Ordering

              + *

              Ordering

              * *

              Streams may or may not have a defined encounter order. Whether * or not a stream has an encounter order depends on the source and the @@ -388,7 +388,7 @@ * However, most stream pipelines, such as the "sum of weight of blocks" example * above, still parallelize efficiently even under ordering constraints. * - *

              Reduction operations

              + *

              Reduction operations

              * * A reduction operation (also called a fold) takes a sequence * of input elements and combines them into a single summary result by repeated @@ -493,7 +493,7 @@ * significant work can be optimized away by combining mapping and reducing * into a single function. * - *

              Mutable reduction

              + *

              Mutable reduction

              * * A mutable reduction operation accumulates input elements into a * mutable result container, such as a {@code Collection} or {@code StringBuilder}, @@ -620,7 +620,7 @@ * but in some cases equivalence may be relaxed to account for differences in * order. * - *

              Reduction, concurrency, and ordering

              + *

              Reduction, concurrency, and ordering

              * * With some complex reduction operations, for example a {@code collect()} that * produces a {@code Map}, such as: @@ -675,7 +675,7 @@ * We would then be constrained to implement either a sequential reduction or * a merge-based parallel reduction. * - *

              Associativity

              + *

              Associativity

              * * An operator or function {@code op} is associative if the following * holds: @@ -693,7 +693,7 @@ *

              Examples of associative operations include numeric addition, min, and * max, and string concatenation. * - *

              Low-level stream construction

              + *

              Low-level stream construction

              * * So far, all the stream examples have used methods like * {@link java.util.Collection#stream()} or {@link java.util.Arrays#stream(Object[])} diff --git a/jdk/src/java.base/share/classes/java/util/zip/Deflater.java b/jdk/src/java.base/share/classes/java/util/zip/Deflater.java index bf70f4dd8a1..6eb5065040e 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/Deflater.java +++ b/jdk/src/java.base/share/classes/java/util/zip/Deflater.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, 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 @@ -551,7 +551,17 @@ class Deflater { /** * Closes the compressor when garbage is collected. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() { end(); } diff --git a/jdk/src/java.base/share/classes/java/util/zip/Inflater.java b/jdk/src/java.base/share/classes/java/util/zip/Inflater.java index 94c05e1d315..2aab545f2a1 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/Inflater.java +++ b/jdk/src/java.base/share/classes/java/util/zip/Inflater.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, 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 @@ -378,7 +378,17 @@ class Inflater { /** * Closes the decompressor when garbage is collected. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() { end(); } diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java index 5191894f4e6..c00b5bf6789 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java @@ -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 @@ -441,7 +441,7 @@ class ZipEntry implements ZipConstants, Cloneable { /** * Sets the size of the compressed entry data. * - * @param csize the compressed size to set to + * @param csize the compressed size to set * * @see #getCompressedSize() */ diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipException.java b/jdk/src/java.base/share/classes/java/util/zip/ZipException.java index 7031292d282..588611f1e0e 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipException.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipException.java @@ -32,7 +32,7 @@ import java.io.IOException; * * @author unascribed * @see java.io.IOException - * @since 1.0 + * @since 1.1 */ public diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java index 4a78e2eb277..83ce2441eeb 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, 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 @@ -274,7 +274,7 @@ class ZipFile implements ZipConstants, Closeable { * * @throws IllegalStateException if the zip file has been closed * - * Since 1.7 + * @since 1.7 */ public String getComment() { synchronized (this) { @@ -420,6 +420,7 @@ class ZipFile implements ZipConstants, Closeable { Integer.MAX_VALUE : (int) avail); } + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { close(); } @@ -641,9 +642,18 @@ class ZipFile implements ZipConstants, Closeable { * This will prevent holding up system resources for an undetermined * length of time. * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. * @throws IOException if an I/O error has occurred * @see java.util.zip.ZipFile#close() */ + @Deprecated(since="9") protected void finalize() throws IOException { close(); } @@ -813,6 +823,7 @@ class ZipFile implements ZipConstants, Closeable { } } + @SuppressWarnings("deprecation") protected void finalize() { close(); } diff --git a/jdk/src/java.base/share/classes/javax/crypto/Cipher.java b/jdk/src/java.base/share/classes/javax/crypto/Cipher.java index 48ca2b01994..cf288f5f1da 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/Cipher.java +++ b/jdk/src/java.base/share/classes/javax/crypto/Cipher.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 @@ -150,9 +150,9 @@ import sun.security.jca.*; *
            • {@code RSA/ECB/OAEPWithSHA-256AndMGF1Padding} (1024, 2048)
            • * * These transformations are described in the - * + * * Cipher section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other transformations are supported. * @@ -489,8 +489,8 @@ public class Cipher { * @param transformation the name of the transformation, e.g., * DES/CBC/PKCS5Padding. * See the Cipher section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#cipher-algorithm-names"> + * Java Security Standard Algorithm Names Specification * for information about standard transformation names. * * @return a cipher that implements the requested transformation @@ -567,8 +567,8 @@ public class Cipher { * @param transformation the name of the transformation, * e.g., DES/CBC/PKCS5Padding. * See the Cipher section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#cipher-algorithm-names"> + * Java Security Standard Algorithm Names Specification * for information about standard transformation names. * * @param provider the name of the provider. @@ -627,8 +627,8 @@ public class Cipher { * @param transformation the name of the transformation, * e.g., DES/CBC/PKCS5Padding. * See the Cipher section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#cipher-algorithm-names"> + * Java Security Standard Algorithm Names Specification * for information about standard transformation names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java index 9c8bc81393a..54ad9611e2d 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, 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 @@ -93,7 +93,7 @@ public class CipherInputStream extends FilterInputStream { // stream status private boolean closed = false; - /** + /* * private convenience function. * * Entry condition: ostart = ofinish diff --git a/jdk/src/java.base/share/classes/javax/crypto/CryptoPermission.java b/jdk/src/java.base/share/classes/javax/crypto/CryptoPermission.java index 749e31926fe..ddc2648b693 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CryptoPermission.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CryptoPermission.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 @@ -196,19 +196,19 @@ class CryptoPermission extends java.security.Permission { * Checks if the specified permission is "implied" by * this object. *

              - * More specifically, this method returns true if:

              + * More specifically, this method returns true if: *

                - *
              • p is an instance of CryptoPermission, and

                + *

              • p is an instance of CryptoPermission, and
              • *
              • p's algorithm name equals or (in the case of wildcards) - * is implied by this permission's algorithm name, and

                + * is implied by this permission's algorithm name, and

              • *
              • p's maximum allowable key size is less or - * equal to this permission's maximum allowable key size, and

                + * equal to this permission's maximum allowable key size, and

              • *
              • p's algorithm parameter spec equals or is - * implied by this permission's algorithm parameter spec, and

                + * implied by this permission's algorithm parameter spec, and

              • *
              • p's exemptionMechanism equals or * is implied by this permission's * exemptionMechanism (a null exemption mechanism - * implies any other exemption mechanism). + * implies any other exemption mechanism).
              • *
              * * @param p the permission to check against. diff --git a/jdk/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java b/jdk/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java index 7f27ea2506a..0093ce65b6d 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.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 @@ -46,10 +46,12 @@ import java.lang.reflect.*; * * The format of a permission entry in the jurisdiction policy file is: * + *
              {@code
                *   permission [, 
                *              [[, ][, 
                *              [, , ]]]];
              + * }
              * * @author Sharon Liu * @@ -526,8 +528,7 @@ final class CryptoPolicyParser { /** * Each grant entry in the policy configuration file is represented by a - * GrantEntry object.

              - * + * GrantEntry object. *

              * For example, the entry *

              @@ -587,8 +588,7 @@ final class CryptoPolicyParser {
               
                   /**
                    * Each crypto permission entry in the policy configuration file is
              -     * represented by a CryptoPermissionEntry object.  

              - * + * represented by a CryptoPermissionEntry object. *

              * For example, the entry *

              diff --git a/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java b/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java
              index cf19807f2dc..35e4fdfca43 100644
              --- a/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java
              +++ b/jdk/src/java.base/share/classes/javax/crypto/ExemptionMechanism.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
              @@ -125,8 +125,8 @@ public class ExemptionMechanism {
                    * mechanism.
                    * See the ExemptionMechanism section in the
                    * 
              -     * Java Cryptography Architecture Standard Algorithm Name Documentation
              +     *   "{@docRoot}/../specs/security/standard-names.html#exemption-mechanisms">
              +     * Java Security Standard Algorithm Names Specification
                    * for information about standard exemption mechanism names.
                    *
                    * @return the new {@code ExemptionMechanism} object
              @@ -164,8 +164,8 @@ public class ExemptionMechanism {
                    * @param algorithm the standard name of the requested exemption mechanism.
                    * See the ExemptionMechanism section in the
                    * 
              -     * Java Cryptography Architecture Standard Algorithm Name Documentation
              +     *   "{@docRoot}/../specs/security/standard-names.html#exemption-mechanisms">
              +     * Java Security Standard Algorithm Names Specification
                    * for information about standard exemption mechanism names.
                    *
                    * @param provider the name of the provider.
              @@ -208,8 +208,8 @@ public class ExemptionMechanism {
                    * @param algorithm the standard name of the requested exemption mechanism.
                    * See the ExemptionMechanism section in the
                    * 
              -     * Java Cryptography Architecture Standard Algorithm Name Documentation
              +     *   "{@docRoot}/../specs/security/standard-names.html#exemption-mechanisms">
              +     * Java Security Standard Algorithm Names Specification
                    * for information about standard exemption mechanism names.
                    *
                    * @param provider the provider.
              diff --git a/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java b/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java
              index 60a1c9d3aa2..16b7903cd8e 100644
              --- a/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java
              +++ b/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java
              @@ -25,7 +25,6 @@
               
               package javax.crypto;
               
              -import java.lang.reflect.Module;
               import java.security.*;
               import java.net.*;
               import java.util.*;
              diff --git a/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java b/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java
              index 47449b3338c..3f77eddccc8 100644
              --- a/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.java
              +++ b/jdk/src/java.base/share/classes/javax/crypto/KeyAgreement.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
              @@ -60,9 +60,9 @@ import sun.security.jca.GetInstance.Instance;
                * 
            • {@code DiffieHellman}
            • * * This algorithm is described in the + * "{@docRoot}/../specs/security/standard-names.html#keyagreement-algorithms"> * KeyAgreement section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -161,8 +161,8 @@ public class KeyAgreement { * @param algorithm the standard name of the requested key agreement * algorithm. * See the KeyAgreement section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyagreement-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code KeyAgreement} object @@ -208,8 +208,8 @@ public class KeyAgreement { * @param algorithm the standard name of the requested key agreement * algorithm. * See the KeyAgreement section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyagreement-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -252,8 +252,8 @@ public class KeyAgreement { * @param algorithm the standard name of the requested key agreement * algorithm. * See the KeyAgreement section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keyagreement-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java b/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java index 4cb8b79be23..135f0ce33df 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.java +++ b/jdk/src/java.base/share/classes/javax/crypto/KeyGenerator.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 @@ -95,9 +95,9 @@ import sun.security.util.Debug; *
            • {@code HmacSHA256}
            • * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#keygenerator-algorithms"> * KeyGenerator section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -216,8 +216,8 @@ public class KeyGenerator { * * @param algorithm the standard name of the requested key algorithm. * See the KeyGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keygenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code KeyGenerator} object @@ -250,8 +250,8 @@ public class KeyGenerator { * * @param algorithm the standard name of the requested key algorithm. * See the KeyGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keygenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -293,8 +293,8 @@ public class KeyGenerator { * * @param algorithm the standard name of the requested key algorithm. * See the KeyGenerator section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#keygenerator-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/javax/crypto/Mac.java b/jdk/src/java.base/share/classes/javax/crypto/Mac.java index 5a1d12de4c6..245f12f6934 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/Mac.java +++ b/jdk/src/java.base/share/classes/javax/crypto/Mac.java @@ -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 @@ -61,9 +61,9 @@ import sun.security.jca.GetInstance.Instance; *
            • {@code HmacSHA256}
            • * * These algorithms are described in the - * + * * Mac section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -162,8 +162,8 @@ public class Mac implements Cloneable { * * @param algorithm the standard name of the requested MAC algorithm. * See the Mac section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#mac-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code Mac} object @@ -206,8 +206,8 @@ public class Mac implements Cloneable { * * @param algorithm the standard name of the requested MAC algorithm. * See the Mac section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#mac-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -247,8 +247,8 @@ public class Mac implements Cloneable { * * @param algorithm the standard name of the requested MAC algorithm. * See the Mac section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#mac-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java b/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java index cadf2302d20..9e4bae382c6 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.java +++ b/jdk/src/java.base/share/classes/javax/crypto/SecretKeyFactory.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 @@ -65,9 +65,9 @@ import sun.security.jca.GetInstance.Instance; *
            • {@code DESede}
            • * * These algorithms are described in the + * "{@docRoot}/../specs/security/standard-names.html#secretkeyfactory-algorithms"> * SecretKeyFactory section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -148,8 +148,8 @@ public class SecretKeyFactory { * @param algorithm the standard name of the requested secret-key * algorithm. * See the SecretKeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#secretkeyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @return the new {@code SecretKeyFactory} object @@ -183,8 +183,8 @@ public class SecretKeyFactory { * @param algorithm the standard name of the requested secret-key * algorithm. * See the SecretKeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#secretkeyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the name of the provider. @@ -227,8 +227,8 @@ public class SecretKeyFactory { * @param algorithm the standard name of the requested secret-key * algorithm. * See the SecretKeyFactory section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#secretkeyfactory-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard algorithm names. * * @param provider the provider. diff --git a/jdk/src/java.base/share/classes/javax/crypto/package-info.java b/jdk/src/java.base/share/classes/javax/crypto/package-info.java index 754b5f643c8..184676fa470 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/package-info.java +++ b/jdk/src/java.base/share/classes/javax/crypto/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, 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 @@ -42,9 +42,9 @@ * having to add or rewrite code. * * * *

              Related Documentation

              diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java index 2f2a0928a15..a649bdd10a0 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLContext.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 @@ -45,9 +45,9 @@ import sun.security.jca.GetInstance; *
            • {@code TLSv1.2}
            • * * These protocols are described in the + * "{@docRoot}/../specs/security/standard-names.html#sslcontext-algorithms"> * SSLContext section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * @@ -147,9 +147,8 @@ public class SSLContext { * * @param protocol the standard name of the requested protocol. * See the SSLContext section in the - * Java Cryptography Architecture Standard Algorithm Name - * Documentation + * "{@docRoot}/../specs/security/standard-names.html#sslcontext-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard protocol names. * * @return the new {@code SSLContext} object @@ -185,9 +184,8 @@ public class SSLContext { * * @param protocol the standard name of the requested protocol. * See the SSLContext section in the - * Java Cryptography Architecture Standard Algorithm Name - * Documentation + * "{@docRoot}/../specs/security/standard-names.html#sslcontext-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard protocol names. * * @param provider the name of the provider. @@ -228,9 +226,8 @@ public class SSLContext { * * @param protocol the standard name of the requested protocol. * See the SSLContext section in the - * Java Cryptography Architecture Standard Algorithm Name - * Documentation + * "{@docRoot}/../specs/security/standard-names.html#sslcontext-algorithms"> + * Java Security Standard Algorithm Names Specification * for information about standard protocol names. * * @param provider an instance of the provider. diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLEngine.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLEngine.java index 9613661afc2..b765128cd85 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLEngine.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLEngine.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 @@ -866,7 +866,7 @@ public abstract class SSLEngine { *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -892,7 +892,7 @@ public abstract class SSLEngine { *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -914,7 +914,7 @@ public abstract class SSLEngine { *

              * Note that the standard list of cipher suite names may be found in the * + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation. Providers * may support cipher suite names not found in this list or might not diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLParameters.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLParameters.java index 5207c3c1f84..0172929926c 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLParameters.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLParameters.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 @@ -110,7 +110,7 @@ public class SSLParameters { * constructor followed by * {@code setCipherSuites(cipherSuites);}. Note that the * standard list of cipher suite names may be found in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation. Providers * may support cipher suite names not found in this list. @@ -130,7 +130,7 @@ public class SSLParameters { * {@code setCipherSuites(cipherSuites); setProtocols(protocols);}. * Note that the standard list of cipher suite names may be found in the * + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation. Providers * may support cipher suite names not found in this list. @@ -153,7 +153,7 @@ public class SSLParameters { *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -170,7 +170,7 @@ public class SSLParameters { * * @param cipherSuites the array of ciphersuites (or null). Note that the * standard list of cipher suite names may be found in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation. Providers * may support cipher suite names not found in this list or might not @@ -675,4 +675,3 @@ public class SSLParameters { applicationProtocols = tempProtocols; } } - diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLPermission.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLPermission.java index b27142128ae..9db1f79a0d2 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLPermission.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLPermission.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 @@ -44,14 +44,17 @@ import java.security.*; * and for each provides a description of what the permission allows * and a discussion of the risks of granting code the permission. * - *

              Type Characteristics
              + *
              + * + * * * * * * + * * + * * * * * * + * *
              permission name, what it allows, and associated risks
              Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
              setHostnameVerifierThe ability to set a callback which can decide whether to @@ -84,6 +87,7 @@ import java.security.*; *
              * * @see java.security.BasicPermission diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java index ead7d20ae58..aa7b266c3a3 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.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 @@ -198,7 +198,7 @@ public abstract class SSLServerSocket extends ServerSocket { *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -224,7 +224,7 @@ public abstract class SSLServerSocket extends ServerSocket { *

              * Note that the standard list of cipher suite names may be found in the * + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation. Providers * may support cipher suite names not found in this list or might not @@ -254,7 +254,7 @@ public abstract class SSLServerSocket extends ServerSocket { *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java index 3629aaef3c7..1cbbf9cfcd8 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.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 @@ -126,7 +126,7 @@ public abstract class SSLServerSocketFactory extends ServerSocketFactory *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -147,7 +147,7 @@ public abstract class SSLServerSocketFactory extends ServerSocketFactory *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocket.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocket.java index 2a00d8f7f26..93e082bde07 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocket.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocket.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 @@ -270,7 +270,7 @@ public abstract class SSLSocket extends Socket *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -296,7 +296,7 @@ public abstract class SSLSocket extends Socket *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -318,7 +318,7 @@ public abstract class SSLSocket extends Socket *

              * Note that the standard list of cipher suite names may be found in the * + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation. Providers * may support cipher suite names not found in this list or might not diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java index d504e1d7a3d..8029b7d6b9a 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.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 @@ -151,7 +151,7 @@ public abstract class SSLSocketFactory extends SocketFactory *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. @@ -170,7 +170,7 @@ public abstract class SSLSocketFactory extends SocketFactory *

              * The returned array includes cipher suites from the list of standard * cipher suite names in the + * "{@docRoot}/../specs/security/standard-names.html#jsse-cipher-suite-names"> * JSSE Cipher Suite Names section of the Java Cryptography * Architecture Standard Algorithm Name Documentation, and may also * include other cipher suites that the provider supports. diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java b/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java index 0f999e8d0aa..cfd144bd917 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.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 @@ -40,12 +40,12 @@ import sun.security.jca.GetInstance; *

              Every implementation of the Java platform is required to support the * following standard {@code TrustManagerFactory} algorithm: *

                - *
              • PKIX
              • + *
              • {@code PKIX}
              • *
              * This algorithm is described in the + * "{@docRoot}/../specs/security/standard-names.html#trustmanagerfactory-algorithms"> * TrustManagerFactory section of the - * Java Cryptography Architecture Standard Algorithm Name Documentation. + * Java Security Standard Algorithm Names Specification. * Consult the release documentation for your implementation to see if any * other algorithms are supported. * diff --git a/jdk/src/java.base/share/classes/javax/net/ssl/package-info.java b/jdk/src/java.base/share/classes/javax/net/ssl/package-info.java index 9fd6868587e..47ea7bf1ff6 100644 --- a/jdk/src/java.base/share/classes/javax/net/ssl/package-info.java +++ b/jdk/src/java.base/share/classes/javax/net/ssl/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, 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 @@ -31,9 +31,9 @@ * the communicating peers. * * * * @since 1.4 diff --git a/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java b/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java index 29d42df6855..1f0b6c95597 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/login/Configuration.java @@ -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 @@ -178,8 +178,8 @@ import sun.security.jca.GetInstance; * constructed by invoking one of the {@code getInstance} factory methods * with a standard type. The default policy type is "JavaLoginConfig". * See the Configuration section in the - * Java Cryptography Architecture Standard Algorithm Name Documentation + * "{@docRoot}/../specs/security/standard-names.html#configuration-types"> + * Java Security Standard Algorithm Names Specification * for a list of standard Configuration types. * * @see javax.security.auth.login.LoginContext @@ -323,9 +323,9 @@ public abstract class Configuration { * * @param type the specified Configuration type. See the Configuration * section in the - * Java Cryptography Architecture Standard Algorithm Name - * Documentation for a list of standard Configuration types. + * "{@docRoot}/../specs/security/standard-names.html#configuration-types"> + * Java Security Standard Algorithm Names Specification + * for a list of standard Configuration types. * * @param params parameters for the Configuration, which may be null. * @@ -381,9 +381,9 @@ public abstract class Configuration { * * @param type the specified Configuration type. See the Configuration * section in the - * Java Cryptography Architecture Standard Algorithm Name - * Documentation for a list of standard Configuration types. + * "{@docRoot}/../specs/security/standard-names.html#configuration-types"> + * Java Security Standard Algorithm Names Specification + * for a list of standard Configuration types. * * @param params parameters for the Configuration, which may be null. * @@ -448,9 +448,9 @@ public abstract class Configuration { * * @param type the specified Configuration type. See the Configuration * section in the - * Java Cryptography Architecture Standard Algorithm Name - * Documentation for a list of standard Configuration types. + * "{@docRoot}/../specs/security/standard-names.html#configuration-types"> + * Java Security Standard Algorithm Names Specification + * for a list of standard Configuration types. * * @param params parameters for the Configuration, which may be null. * diff --git a/jdk/src/java.base/share/classes/javax/security/auth/login/package-info.java b/jdk/src/java.base/share/classes/javax/security/auth/login/package-info.java index 5b43480dc0a..555b4983f38 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/login/package-info.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/login/package-info.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 @@ -28,10 +28,9 @@ *

              Package Specification

              * * * * @since 1.4 diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java index 10506b7029c..ee77794aa1c 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.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 @@ -137,10 +137,15 @@ public class BasicImageReader implements AutoCloseable { int headerSize = ImageHeader.getHeaderSize(); // If no memory map then read header from image file - if (map == null) { + if (headerBuffer == null) { headerBuffer = ByteBuffer.allocateDirect(headerSize); - channel.read(headerBuffer, 0L); - headerBuffer.rewind(); + if (channel.read(headerBuffer, 0L) == headerSize) { + headerBuffer.rewind(); + } else { + throw new IOException("\"" + name + "\" is not an image file"); + } + } else if (headerBuffer.capacity() < headerSize) { + throw new IOException("\"" + name + "\" is not an image file"); } // Interpret the image file header @@ -156,6 +161,9 @@ public class BasicImageReader implements AutoCloseable { memoryMap = map.asReadOnlyBuffer(); // Interpret the image index + if (memoryMap.capacity() < indexSize) { + throw new IOException("The image file \"" + name + "\" is corrupted"); + } redirect = intBuffer(memoryMap, header.getRedirectOffset(), header.getRedirectSize()); offsets = intBuffer(memoryMap, header.getOffsetsOffset(), header.getOffsetsSize()); locations = slice(memoryMap, header.getLocationsOffset(), header.getLocationsSize()); @@ -241,27 +249,20 @@ public class BasicImageReader implements AutoCloseable { return stringsReader; } - public ImageLocation findLocation(String mn, String rn) { - Objects.requireNonNull(mn); - Objects.requireNonNull(rn); - - return findLocation("/" + mn + "/" + rn); - } - - public synchronized ImageLocation findLocation(String name) { + public synchronized ImageLocation findLocation(String module, String name) { + Objects.requireNonNull(module); Objects.requireNonNull(name); // Details of the algorithm used here can be found in // jdk.tools.jlink.internal.PerfectHashBuilder. - byte[] bytes = ImageStringsReader.mutf8FromString(name); int count = header.getTableLength(); - int index = redirect.get(ImageStringsReader.hashCode(bytes) % count); + int index = redirect.get(ImageStringsReader.hashCode(module, name) % count); if (index < 0) { // index is twos complement of location attributes index. index = -index - 1; } else if (index > 0) { // index is hash seed needed to compute location attributes index. - index = ImageStringsReader.hashCode(bytes, index) % count; + index = ImageStringsReader.hashCode(module, name, index) % count; } else { // No entry. return null; @@ -269,13 +270,36 @@ public class BasicImageReader implements AutoCloseable { long[] attributes = getAttributes(offsets.get(index)); - ImageLocation imageLocation = new ImageLocation(attributes, stringsReader); + if (!ImageLocation.verify(module, name, attributes, stringsReader)) { + return null; + } + return new ImageLocation(attributes, stringsReader); + } - if (!imageLocation.verify(name)) { + public synchronized ImageLocation findLocation(String name) { + Objects.requireNonNull(name); + // Details of the algorithm used here can be found in + // jdk.tools.jlink.internal.PerfectHashBuilder. + int count = header.getTableLength(); + int index = redirect.get(ImageStringsReader.hashCode(name) % count); + + if (index < 0) { + // index is twos complement of location attributes index. + index = -index - 1; + } else if (index > 0) { + // index is hash seed needed to compute location attributes index. + index = ImageStringsReader.hashCode(name, index) % count; + } else { + // No entry. return null; } - return imageLocation; + long[] attributes = getAttributes(offsets.get(index)); + + if (!ImageLocation.verify(name, attributes, stringsReader)) { + return null; + } + return new ImageLocation(attributes, stringsReader); } public String[] getEntryNames() { diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java index ad0ae42fc3d..f1b8f5594c3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.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 @@ -59,14 +59,6 @@ public class ImageLocation { return strings; } - private static int attributeLength(int data) { - return (data & 0x7) + 1; - } - - private static int attributeKind(int data) { - return data >>> 3; - } - static long[] decompress(ByteBuffer bytes) { Objects.requireNonNull(bytes); long[] attributes = new long[ATTRIBUTE_COUNT]; @@ -74,7 +66,7 @@ public class ImageLocation { if (bytes != null) { while (bytes.hasRemaining()) { int data = bytes.get() & 0xFF; - int kind = attributeKind(data); + int kind = data >>> 3; if (kind == ATTRIBUTE_END) { break; @@ -85,7 +77,7 @@ public class ImageLocation { "Invalid jimage attribute kind: " + kind); } - int length = attributeLength(data); + int length = (data & 0x7) + 1; long value = 0; for (int j = 0; j < length; j++) { @@ -128,9 +120,82 @@ public class ImageLocation { } public boolean verify(String name) { - Objects.requireNonNull(name); + return verify(name, attributes, strings); + } - return name.equals(getFullName()); + /** + * A simpler verification would be {@code name.equals(getFullName())}, but + * by not creating the full name and enabling early returns we allocate + * fewer objects. Could possibly be made allocation free by extending + * ImageStrings to test if strings at an offset match the name region. + */ + static boolean verify(String name, long[] attributes, ImageStrings strings) { + Objects.requireNonNull(name); + final int length = name.length(); + int index = 0; + int moduleOffset = (int)attributes[ATTRIBUTE_MODULE]; + if (moduleOffset != 0) { + String module = strings.get(moduleOffset); + final int moduleLen = module.length(); + index = moduleLen + 1; + if (length <= index + || name.charAt(0) != '/' + || !name.regionMatches(1, module, 0, moduleLen) + || name.charAt(index++) != '/') { + return false; + } + } + + return verifyName(name, index, length, attributes, strings); + } + + static boolean verify(String module, String name, long[] attributes, + ImageStrings strings) { + Objects.requireNonNull(module); + Objects.requireNonNull(name); + int moduleOffset = (int)attributes[ATTRIBUTE_MODULE]; + if (moduleOffset != 0) { + if (!module.equals(strings.get(moduleOffset))) { + return false; + } + } + + return verifyName(name, 0, name.length(), attributes, strings); + } + + private static boolean verifyName(String name, int index, int length, + long[] attributes, ImageStrings strings) { + + int parentOffset = (int) attributes[ATTRIBUTE_PARENT]; + if (parentOffset != 0) { + String parent = strings.get(parentOffset); + final int parentLen = parent.length(); + if (!name.regionMatches(index, parent, 0, parentLen)) { + return false; + } + index += parentLen; + if (length <= index || name.charAt(index++) != '/') { + return false; + } + } + String base = strings.get((int) attributes[ATTRIBUTE_BASE]); + final int baseLen = base.length(); + if (!name.regionMatches(index, base, 0, baseLen)) { + return false; + } + index += baseLen; + int extOffset = (int) attributes[ATTRIBUTE_EXTENSION]; + if (extOffset != 0) { + String extension = strings.get(extOffset); + int extLen = extension.length(); + if (length <= index + || name.charAt(index++) != '.' + || !name.regionMatches(index, extension, 0, extLen)) { + return false; + } + index += extLen; + } + return length == index; } long getAttribute(int kind) { diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java index 60ab472db3e..6082c21bee3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java @@ -52,7 +52,9 @@ import java.util.function.Consumer; * to the jimage file provided by the shipped JDK by tools running on JDK 8. */ public final class ImageReader implements AutoCloseable { - private SharedImageReader reader; + private final SharedImageReader reader; + + private volatile boolean closed; private ImageReader(SharedImageReader reader) { this.reader = reader; @@ -71,45 +73,49 @@ public final class ImageReader implements AutoCloseable { @Override public void close() throws IOException { - if (reader == null) { + if (closed) { throw new IOException("image file already closed"); } - reader.close(this); - reader = null; + closed = true; + } + + private void ensureOpen() throws IOException { + if (closed) { + throw new IOException("image file closed"); + } + } + + private void requireOpen() { + if (closed) { + throw new IllegalStateException("image file closed"); + } } // directory management interface public Directory getRootDirectory() throws IOException { - if (reader == null) { - throw new IOException("image file closed"); - } + ensureOpen(); return reader.getRootDirectory(); } + public Node findNode(String name) throws IOException { - if (reader == null) { - throw new IOException("image file closed"); - } + ensureOpen(); return reader.findNode(name); } public byte[] getResource(Node node) throws IOException { - if (reader == null) { - throw new IOException("image file closed"); - } + ensureOpen(); return reader.getResource(node); } public byte[] getResource(Resource rs) throws IOException { - if (reader == null) { - throw new IOException("image file closed"); - } + ensureOpen(); return reader.getResource(rs); } public ImageHeader getHeader() { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getHeader(); } @@ -118,42 +124,42 @@ public final class ImageReader implements AutoCloseable { } public String getName() { - Objects.requireNonNull(reader, "image file closed"); - return reader.getName() ; + requireOpen(); + return reader.getName(); } public ByteOrder getByteOrder() { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getByteOrder(); } public Path getImagePath() { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getImagePath(); } public ImageStringsReader getStrings() { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getStrings(); } public ImageLocation findLocation(String mn, String rn) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.findLocation(mn, rn); } public ImageLocation findLocation(String name) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.findLocation(name); } public String[] getEntryNames() { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getEntryNames(); } public String[] getModuleNames() { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); int off = "/modules/".length(); return reader.findNode("/modules") .getChildren() @@ -164,32 +170,32 @@ public final class ImageReader implements AutoCloseable { } public long[] getAttributes(int offset) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getAttributes(offset); } public String getString(int offset) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getString(offset); } public byte[] getResource(String name) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getResource(name); } public byte[] getResource(ImageLocation loc) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getResource(loc); } public ByteBuffer getResourceBuffer(ImageLocation loc) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getResourceBuffer(loc); } public InputStream getResourceStream(ImageLocation loc) { - Objects.requireNonNull(reader, "image file closed"); + requireOpen(); return reader.getResourceStream(loc); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReaderFactory.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReaderFactory.java index 092b309b0b7..24ac9bfc18a 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReaderFactory.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReaderFactory.java @@ -32,6 +32,7 @@ import java.nio.file.Paths; import java.util.concurrent.ConcurrentHashMap; import java.util.Map; import java.util.Objects; +import java.util.function.Function; /** * Factory to get ImageReader @@ -56,21 +57,23 @@ public class ImageReaderFactory { */ public static ImageReader get(Path jimage) throws IOException { Objects.requireNonNull(jimage); - ImageReader reader = readers.get(jimage); - if (reader != null) { - return reader; - } - reader = ImageReader.open(jimage); - // potential race with other threads opening the same URL - ImageReader r = readers.putIfAbsent(jimage, reader); - if (r == null) { - return reader; - } else { - reader.close(); - return r; + try { + return readers.computeIfAbsent(jimage, OPENER); + } catch (UncheckedIOException io) { + throw io.getCause(); } } + private static Function OPENER = new Function() { + public ImageReader apply(Path path) { + try { + return ImageReader.open(path); + } catch (IOException io) { + throw new UncheckedIOException(io); + } + } + }; + /** * Returns the {@code ImageReader} to read the image file in this * run-time image. diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java index e4a11cbdc14..d9900aa231e 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.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 @@ -38,6 +38,8 @@ import java.util.Objects; */ public class ImageStringsReader implements ImageStrings { public static final int HASH_MULTIPLIER = 0x01000193; + public static final int POSITIVE_MASK = 0x7FFFFFFF; + private final BasicImageReader reader; ImageStringsReader(BasicImageReader reader) { @@ -54,40 +56,60 @@ public class ImageStringsReader implements ImageStrings { throw new InternalError("Can not add strings at runtime"); } - private static int hashCode(byte[] bytes, int offset, int count, int seed) { - Objects.requireNonNull(bytes); + public static int hashCode(String s) { + return hashCode(s, HASH_MULTIPLIER); + } - if (offset < 0 || count < 0 || offset > bytes.length - count) { - throw new IndexOutOfBoundsException("offset=" + offset + ", count=" + count); + public static int hashCode(String s, int seed) { + return unmaskedHashCode(s, seed) & POSITIVE_MASK; + } + + public static int hashCode(String module, String name) { + return hashCode(module, name, HASH_MULTIPLIER); + } + + public static int hashCode(String module, String name, int seed) { + seed = unmaskedHashCode("/", seed); + seed = unmaskedHashCode(module, seed); + seed = unmaskedHashCode("/", seed); + seed = unmaskedHashCode(name, seed); + return seed & POSITIVE_MASK; + } + + public static int unmaskedHashCode(String s, int seed) { + int slen = s.length(); + byte[] buffer = null; + + for (int i = 0; i < slen; i++) { + char ch = s.charAt(i); + int uch = ch & 0xFFFF; + + if ((uch & ~0x7F) != 0) { + if (buffer == null) { + buffer = new byte[8]; + } + int mask = ~0x3F; + int n = 0; + + do { + buffer[n++] = (byte)(0x80 | (uch & 0x3F)); + uch >>= 6; + mask >>= 1; + } while ((uch & mask) != 0); + + buffer[n] = (byte)((mask << 1) | uch); + + do { + seed = (seed * HASH_MULTIPLIER) ^ (buffer[n--] & 0xFF); + } while (0 <= n); + } else if (uch == 0) { + seed = (seed * HASH_MULTIPLIER) ^ (0xC0); + seed = (seed * HASH_MULTIPLIER) ^ (0x80); + } else { + seed = (seed * HASH_MULTIPLIER) ^ (uch); + } } - - int limit = offset + count; - - if (limit < 0 || limit > bytes.length) { - throw new IndexOutOfBoundsException("limit=" + limit); - } - - for (int i = offset; i < limit; i++) { - seed = (seed * HASH_MULTIPLIER) ^ (bytes[i] & 0xFF); - } - - return seed & 0x7FFFFFFF; - } - - public static int hashCode(byte[] bytes, int seed) { - return hashCode(bytes, 0, bytes.length, seed); - } - - public static int hashCode(byte[] bytes) { - return hashCode(bytes, 0, bytes.length, HASH_MULTIPLIER); - } - - public static int hashCode(String string, int seed) { - return hashCode(mutf8FromString(string), seed); - } - - public static int hashCode(String string) { - return hashCode(mutf8FromString(string), HASH_MULTIPLIER); + return seed; } static int charsFromMUTF8Length(byte[] bytes, int offset, int count) { @@ -179,7 +201,7 @@ public class ImageStringsReader implements ImageStrings { throw new InternalError("No terminating zero byte for modified UTF-8 byte sequence"); } - static void charsFromByteBuffer(char chars[], ByteBuffer buffer) { + static void charsFromByteBuffer(char[] chars, ByteBuffer buffer) { int j = 0; while(buffer.hasRemaining()) { @@ -228,10 +250,12 @@ public class ImageStringsReader implements ImageStrings { return new String(chars); } - static int mutf8FromCharsLength(char chars[]) { + static int mutf8FromStringLength(String s) { int length = 0; + int slen = s.length(); - for (char ch : chars) { + for (int i = 0; i < slen; i++) { + char ch = s.charAt(i); int uch = ch & 0xFFFF; if ((uch & ~0x7F) != 0) { @@ -255,14 +279,19 @@ public class ImageStringsReader implements ImageStrings { return length; } - static void mutf8FromChars(byte[] bytes, int offset, char chars[]) { + static void mutf8FromString(byte[] bytes, int offset, String s) { int j = offset; - byte[] buffer = new byte[8]; + byte[] buffer = null; + int slen = s.length(); - for (char ch : chars) { + for (int i = 0; i < slen; i++) { + char ch = s.charAt(i); int uch = ch & 0xFFFF; if ((uch & ~0x7F) != 0) { + if (buffer == null) { + buffer = new byte[8]; + } int mask = ~0x3F; int n = 0; @@ -287,10 +316,9 @@ public class ImageStringsReader implements ImageStrings { } public static byte[] mutf8FromString(String string) { - char[] chars = string.toCharArray(); - int length = mutf8FromCharsLength(chars); + int length = mutf8FromStringLength(string); byte[] bytes = new byte[length]; - mutf8FromChars(bytes, 0, chars); + mutf8FromString(bytes, 0, string); return bytes; } diff --git a/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java b/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java index 34e99dfdd9b..0a78e71ed56 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jmod/JmodFile.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 @@ -59,7 +59,7 @@ public class JmodFile implements AutoCloseable { bis.read(magic); if (magic[0] != JMOD_MAGIC_NUMBER[0] || magic[1] != JMOD_MAGIC_NUMBER[1]) { - throw new IOException("Invalid jmod file: " + file.toString()); + throw new IOException("Invalid JMOD file: " + file.toString()); } if (magic[2] > JMOD_MAJOR_VERSION || (magic[2] == JMOD_MAJOR_VERSION && magic[3] > JMOD_MINOR_VERSION)) { @@ -78,7 +78,7 @@ public class JmodFile implements AutoCloseable { HEADER_FILES("include"), LEGAL_NOTICES("legal"), MAN_PAGES("man"), - NATIVE_LIBS("native"), + NATIVE_LIBS("lib"), NATIVE_CMDS("bin"); private final String jmodDir; @@ -130,6 +130,13 @@ public class JmodFile implements AutoCloseable { return name; } + /** + * Returns true if the entry is a directory in the JMOD file. + */ + public boolean isDirectory() { + return zipEntry.isDirectory(); + } + /** * Returns the size of this entry. */ @@ -191,7 +198,7 @@ public class JmodFile implements AutoCloseable { /** * Opens an {@code InputStream} for reading the named entry of the given - * section in this jmod file. + * section in this JMOD file. * * @throws IOException if the named entry is not found, or I/O error * occurs when reading it @@ -217,11 +224,10 @@ public class JmodFile implements AutoCloseable { } /** - * Returns a stream of non-directory entries in this jmod file. + * Returns a stream of entries in this JMOD file. */ public Stream stream() { return zipfile.stream() - .filter(e -> !e.isDirectory()) .map(Entry::new); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java index 49285b31dfb..d544e4c0deb 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, 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 @@ -106,6 +106,7 @@ class JrtFileSystem extends FileSystem { } @Override + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { try { cleanup(); diff --git a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java index 4aed7a67285..12976035291 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.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 @@ -65,14 +65,12 @@ public final class JrtFileSystemProvider extends FileSystemProvider { } /** - * Need FilePermission ${java.home}/-", "read" to create or get jrt:/ + * Need RuntimePermission "accessSystemModules" to create or get jrt:/ */ private void checkPermission() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { - String home = SystemImage.RUNTIME_HOME; - FilePermission perm - = new FilePermission(home + File.separator + "-", "read"); + RuntimePermission perm = new RuntimePermission("accessSystemModules"); sm.checkPermission(perm); } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java b/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java index 7885d8e180d..07b5173e726 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java @@ -27,8 +27,6 @@ package jdk.internal.loader; import java.io.IOException; import java.io.InputStream; import java.lang.module.ModuleReference; -import java.lang.reflect.Layer; -import java.lang.reflect.Module; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -62,8 +60,7 @@ public class BootLoader { private static final String JAVA_HOME = System.getProperty("java.home"); static { - UNNAMED_MODULE - = SharedSecrets.getJavaLangReflectModuleAccess().defineUnnamedModule(null); + UNNAMED_MODULE = SharedSecrets.getJavaLangAccess().defineUnnamedModule(null); setBootLoaderUnnamedModule0(UNNAMED_MODULE); } @@ -95,6 +92,14 @@ public class BootLoader { return CLASS_LOADER_VALUE_MAP; } + /** + * Returns {@code true} if there is a class path associated with the + * BootLoader. + */ + public static boolean hasClassPath() { + return ClassLoaders.bootLoader().hasClassPath(); + } + /** * Register a module with this class loader so that its classes (and * resources) become visible via this class loader. @@ -247,7 +252,7 @@ public class BootLoader { if (mn != null) { // named module from runtime image or exploded module - Optional om = Layer.boot().findModule(mn); + Optional om = ModuleLayer.boot().findModule(mn); if (!om.isPresent()) throw new InternalError(mn + " not in boot layer"); return om.get(); diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java b/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java index ab052ec0b30..5d1c97c6d25 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java @@ -57,8 +57,10 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.stream.Stream; -import jdk.internal.module.ModulePatcher.PatchedModuleReader; import jdk.internal.misc.VM; +import jdk.internal.module.ModulePatcher.PatchedModuleReader; +import jdk.internal.module.SystemModules; +import jdk.internal.module.Resources; /** @@ -135,7 +137,7 @@ public class BuiltinClassLoader // maps package name to loaded module for modules in the boot layer private static final Map packageToModule - = new ConcurrentHashMap<>(1024); + = new ConcurrentHashMap<>(SystemModules.PACKAGES_IN_BOOT_LAYER); // maps a module name to a module reference private final Map nameToModule; @@ -162,12 +164,18 @@ public class BuiltinClassLoader } /** - * Register a module this this class loader. This has the effect of making - * the types in the module visible. + * Returns {@code true} if there is a class path associated with this + * class loader. + */ + boolean hasClassPath() { + return ucp != null; + } + + /** + * Register a module this class loader. This has the effect of making the + * types in the module visible. */ public void loadModule(ModuleReference mref) { - assert !VM.isModuleSystemInited(); - String mn = mref.descriptor().name(); if (nameToModule.putIfAbsent(mn, mref) != null) { throw new InternalError(mn + " already defined to this loader"); @@ -181,6 +189,11 @@ public class BuiltinClassLoader + other.mref().descriptor().name()); } } + + // clear resources cache if VM is already initialized + if (VM.isModuleSystemInited() && resourceCache != null) { + resourceCache = null; + } } /** @@ -247,18 +260,24 @@ public class BuiltinClassLoader */ @Override public URL findResource(String name) { - String pn = ResourceHelper.getPackageName(name); + String pn = Resources.toPackageName(name); LoadedModule module = packageToModule.get(pn); if (module != null) { // resource is in a package of a module defined to this loader - if (module.loader() == this - && (name.endsWith(".class") || isOpen(module.mref(), pn))) { + if (module.loader() == this) { + URL url; try { - return findResource(module.name(), name); // checks URL + url = findResource(module.name(), name); // checks URL } catch (IOException ioe) { return null; } + if (url != null + && (name.endsWith(".class") + || url.toString().endsWith("/") + || isOpen(module.mref(), pn))) { + return url; + } } } else { @@ -292,15 +311,17 @@ public class BuiltinClassLoader public Enumeration findResources(String name) throws IOException { List checked = new ArrayList<>(); // list of checked URLs - String pn = ResourceHelper.getPackageName(name); + String pn = Resources.toPackageName(name); LoadedModule module = packageToModule.get(pn); if (module != null) { // resource is in a package of a module defined to this loader - if (module.loader() == this - && (name.endsWith(".class") || isOpen(module.mref(), pn))) { - URL url = findResource(module.name(), name); // checks URL - if (url != null) { + if (module.loader() == this) { + URL url = findResource(module.name(), name); // checks URL + if (url != null + && (name.endsWith(".class") + || url.toString().endsWith("/") + || isOpen(module.mref(), pn))) { checked.add(url); } } @@ -337,7 +358,10 @@ public class BuiltinClassLoader private List findMiscResource(String name) throws IOException { SoftReference>> ref = this.resourceCache; Map> map = (ref != null) ? ref.get() : null; - if (map != null) { + if (map == null) { + map = new ConcurrentHashMap<>(); + this.resourceCache = new SoftReference<>(map); + } else { List urls = map.get(name); if (urls != null) return urls; @@ -350,34 +374,31 @@ public class BuiltinClassLoader new PrivilegedExceptionAction<>() { @Override public List run() throws IOException { - List result = new ArrayList<>(); + List result = null; for (ModuleReference mref : nameToModule.values()) { URI u = moduleReaderFor(mref).find(name).orElse(null); if (u != null) { try { + if (result == null) + result = new ArrayList<>(); result.add(u.toURL()); } catch (MalformedURLException | IllegalArgumentException e) { } } } - return result; + return (result != null) ? result : Collections.emptyList(); } }); } catch (PrivilegedActionException pae) { throw (IOException) pae.getCause(); } - // only cache resources after all modules have been defined + // only cache resources after VM is fully initialized if (VM.isModuleSystemInited()) { - if (map == null) { - map = new ConcurrentHashMap<>(); - this.resourceCache = new SoftReference<>(map); - } - if (urls.isEmpty()) - urls = Collections.emptyList(); map.putIfAbsent(name, urls); } + return urls; } @@ -424,7 +445,7 @@ public class BuiltinClassLoader * Returns a URL to a resource on the class path. */ private URL findResourceOnClassPath(String name) { - if (ucp != null) { + if (hasClassPath()) { if (System.getSecurityManager() == null) { return ucp.findResource(name, false); } else { @@ -441,7 +462,7 @@ public class BuiltinClassLoader * Returns the URLs of all resources of the given name on the class path. */ private Enumeration findResourcesOnClassPath(String name) { - if (ucp != null) { + if (hasClassPath()) { if (System.getSecurityManager() == null) { return ucp.findResources(name, false); } else { @@ -480,7 +501,7 @@ public class BuiltinClassLoader } else { // search class path - if (ucp != null) { + if (hasClassPath()) { c = findClassOnClassPathOrNull(cn); } @@ -513,7 +534,7 @@ public class BuiltinClassLoader } // search class path - if (ucp != null) { + if (hasClassPath()) { return findClassOnClassPathOrNull(cn); } @@ -568,7 +589,7 @@ public class BuiltinClassLoader } // check class path - if (c == null && ucp != null && VM.isModuleSystemInited()) { + if (c == null && hasClassPath() && VM.isModuleSystemInited()) { c = findClassOnClassPathOrNull(cn); } } @@ -922,13 +943,13 @@ public class BuiltinClassLoader * Returns the ModuleReader for the given module. */ private ModuleReader moduleReaderFor(ModuleReference mref) { - return moduleToReader.computeIfAbsent(mref, m -> createModuleReader(mref)); + return moduleToReader.computeIfAbsent(mref, BuiltinClassLoader::createModuleReader); } /** * Creates a ModuleReader for the given module. */ - private ModuleReader createModuleReader(ModuleReference mref) { + private static ModuleReader createModuleReader(ModuleReference mref) { try { return mref.open(); } catch (IOException e) { @@ -966,7 +987,7 @@ public class BuiltinClassLoader */ private boolean isOpen(ModuleReference mref, String pn) { ModuleDescriptor descriptor = mref.descriptor(); - if (descriptor.isOpen()) + if (descriptor.isOpen() || descriptor.isAutomatic()) return true; for (ModuleDescriptor.Opens opens : descriptor.opens()) { String source = opens.source(); diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java index 64492508dc0..d976aab1cd7 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.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,6 @@ package jdk.internal.loader; import java.io.File; import java.io.IOException; -import java.lang.reflect.Module; import java.net.URL; import java.nio.file.InvalidPathException; import java.nio.file.Paths; @@ -257,7 +256,10 @@ public class ClassLoaders { */ private static URL toFileURL(String s) { try { - return Paths.get(s).toRealPath().toUri().toURL(); + // Use an intermediate File object to construct a URI/URL without + // authority component as URLClassPath can't handle URLs with a UNC + // server name in the authority component. + return Paths.get(s).toRealPath().toFile().toURI().toURL(); } catch (InvalidPathException | IOException ignore) { // malformed path string or class path element does not exist return null; diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java b/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java index 04285cc4cf1..0eb249de0d9 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/Loader.java @@ -33,7 +33,6 @@ import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleReader; import java.lang.module.ModuleReference; import java.lang.module.ResolvedModule; -import java.lang.reflect.Layer; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -60,6 +59,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; import jdk.internal.misc.SharedSecrets; +import jdk.internal.module.Resources; /** @@ -79,8 +79,8 @@ import jdk.internal.misc.SharedSecrets; * loader. This allows automatic modules (for example) to link to types in the * unnamed module of the parent class loader. * - * @see Layer#defineModulesWithOneLoader - * @see Layer#defineModulesWithManyLoaders + * @see ModuleModuleLayer#defineModulesWithOneLoader + * @see ModuleModuleLayer#defineModulesWithManyLoaders */ public final class Loader extends SecureClassLoader { @@ -206,10 +206,10 @@ public final class Loader extends SecureClassLoader { * @param cf the Configuration containing at least modules to be defined to * this class loader * - * @param parentLayers the parent Layers + * @param parentModuleLayers the parent ModuleLayers */ public Loader initRemotePackageMap(Configuration cf, - List parentLayers) + List parentModuleLayers) { for (String name : nameToModule.keySet()) { ResolvedModule resolvedModule = cf.findModule(name).get(); @@ -235,8 +235,8 @@ public final class Loader extends SecureClassLoader { } else { // find the layer for the target module - Layer layer = parentLayers.stream() - .map(parent -> findLayer(parent, other.configuration())) + ModuleLayer layer = parentModuleLayers.stream() + .map(parent -> findModuleLayer(parent, other.configuration())) .flatMap(Optional::stream) .findAny() .orElseThrow(() -> @@ -285,8 +285,8 @@ public final class Loader extends SecureClassLoader { * Find the layer corresponding to the given configuration in the tree * of layers rooted at the given parent. */ - private Optional findLayer(Layer parent, Configuration cf) { - return SharedSecrets.getJavaLangReflectModuleAccess().layers(parent) + private Optional findModuleLayer(ModuleLayer parent, Configuration cf) { + return SharedSecrets.getJavaLangAccess().layers(parent) .filter(l -> l.configuration() == cf) .findAny(); } @@ -356,45 +356,52 @@ public final class Loader extends SecureClassLoader { @Override public URL findResource(String name) { - URL url = null; - String pn = ResourceHelper.getPackageName(name); + String pn = Resources.toPackageName(name); LoadedModule module = localPackageToModule.get(pn); + if (module != null) { - if (name.endsWith(".class") || isOpen(module.mref(), pn)) { - try { - url = findResource(module.name(), name); - } catch (IOException ioe) { - // ignore + try { + URL url = findResource(module.name(), name); + if (url != null + && (name.endsWith(".class") + || url.toString().endsWith("/") + || isOpen(module.mref(), pn))) { + return url; } + } catch (IOException ioe) { + // ignore } + } else { for (ModuleReference mref : nameToModule.values()) { try { - url = findResource(mref.descriptor().name(), name); - if (url != null) - break; + URL url = findResource(mref.descriptor().name(), name); + if (url != null) return url; } catch (IOException ioe) { // ignore } } } - return url; + + return null; } @Override public Enumeration findResources(String name) throws IOException { List urls = new ArrayList<>(); - String pn = ResourceHelper.getPackageName(name); + String pn = Resources.toPackageName(name); LoadedModule module = localPackageToModule.get(pn); if (module != null) { - if (name.endsWith(".class") || isOpen(module.mref(), pn)) { - try { - URL url = findResource(module.name(), name); - if (url != null) - urls.add(url); - } catch (IOException ioe) { - // ignore + try { + URL url = findResource(module.name(), name); + if (url != null + && (name.endsWith(".class") + || url.toString().endsWith("/") + || isOpen(module.mref(), pn))) { + urls.add(url); } + } catch (IOException ioe) { + // ignore } } else { for (ModuleReference mref : nameToModule.values()) { @@ -643,7 +650,7 @@ public final class Loader extends SecureClassLoader { */ private boolean isOpen(ModuleReference mref, String pn) { ModuleDescriptor descriptor = mref.descriptor(); - if (descriptor.isOpen()) + if (descriptor.isOpen() || descriptor.isAutomatic()) return true; for (ModuleDescriptor.Opens opens : descriptor.opens()) { String source = opens.source(); diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java b/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java index 14b088c14a9..a16f2447947 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/LoaderPool.java @@ -27,7 +27,6 @@ package jdk.internal.loader; import java.lang.module.Configuration; import java.lang.module.ResolvedModule; -import java.lang.reflect.Layer; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,7 +35,7 @@ import java.util.stream.Stream; /** * A pool of class loaders. * - * @see Layer#defineModulesWithManyLoaders + * @see ModuleLayer#defineModulesWithManyLoaders */ public final class LoaderPool { @@ -51,7 +50,7 @@ public final class LoaderPool { * created with the given parent class loader as its parent. */ public LoaderPool(Configuration cf, - List parentLayers, + List parentLayers, ClassLoader parentLoader) { Map loaders = new HashMap<>(); 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 d67c342fb0a..d343f8fdcbe 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 @@ -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 @@ -65,6 +65,8 @@ import java.util.jar.Attributes; import java.util.jar.Attributes.Name; import java.util.zip.ZipFile; +import jdk.internal.misc.JavaNetURLAccess; +import jdk.internal.misc.JavaNetURLClassLoaderAccess; import jdk.internal.misc.JavaUtilZipFileAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.util.jar.InvalidJarIndexError; @@ -346,7 +348,7 @@ public class URLClassPath { * path. The URLs are opened and expanded as needed. Returns null * if the specified index is out of range. */ - private synchronized Loader getLoader(int index) { + private synchronized Loader getLoader(int index) { if (closed) { return null; } @@ -404,31 +406,40 @@ public class URLClassPath { private Loader getLoader(final URL url) throws IOException { try { return java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction<>() { - public Loader run() throws IOException { - String protocol = url.getProtocol(); // lower cased in URL - String file = url.getFile(); - if ("jar".equals(protocol) - && 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, acc); - } else if (file != null && file.endsWith("/")) { - if ("file".equals(protocol)) { - return new FileLoader(url); - } else { - return new Loader(url); + new java.security.PrivilegedExceptionAction<>() { + public Loader run() throws IOException { + String protocol = url.getProtocol(); // lower cased in URL + String file = url.getFile(); + if (file != null && file.endsWith("/")) { + if ("file".equals(protocol)) { + return new FileLoader(url); + } else if ("jar".equals(protocol) && + isDefaultJarHandler(url) && + file.endsWith("!/")) { + // extract the nested URL + URL nestedUrl = new URL(file.substring(0, file.length() - 2)); + return new JarLoader(nestedUrl, jarHandler, lmap, acc); + } else { + return new Loader(url); + } + } else { + return new JarLoader(url, jarHandler, lmap, acc); + } } - } else { - return new JarLoader(url, jarHandler, lmap, acc); - } - } - }, acc); + }, acc); } catch (java.security.PrivilegedActionException pae) { throw (IOException)pae.getException(); } } + private static final JavaNetURLAccess JNUA + = SharedSecrets.getJavaNetURLAccess(); + + private static boolean isDefaultJarHandler(URL u) { + URLStreamHandler h = JNUA.getHandler(u); + return h instanceof sun.net.www.protocol.jar.Handler; + } + /* * Pushes the specified URLs onto the list of unopened URLs. */ @@ -493,7 +504,7 @@ public class URLClassPath { } /** - * Inner class used to represent a loader of resources and classes + * Nested class used to represent a loader of resources and classes * from a base URL. */ private static class Loader implements Closeable { @@ -600,7 +611,8 @@ public class URLClassPath { * close this loader and release all resources * method overridden in sub-classes */ - public void close () throws IOException { + @Override + public void close() throws IOException { if (jarfile != null) { jarfile.close(); } @@ -615,7 +627,7 @@ public class URLClassPath { } /* - * Inner class used to represent a Loader of resources from a JAR URL. + * Nested class class used to represent a Loader of resources from a JAR URL. */ static class JarLoader extends Loader { private JarFile jar; @@ -798,7 +810,7 @@ public class URLClassPath { /* - * Returns true iff atleast one resource in the jar file has the same + * Returns true iff at least one resource in the jar file has the same * package name as that of the specified resource name. */ boolean validIndex(final String name) { @@ -826,6 +838,7 @@ public class URLClassPath { /* * Returns the URL for a resource with the specified name */ + @Override URL findResource(final String name, boolean check) { Resource rsc = getResource(name, check); if (rsc != null) { @@ -837,6 +850,7 @@ public class URLClassPath { /* * Returns the JAR Resource for the specified name. */ + @Override Resource getResource(final String name, boolean check) { try { ensureOpen(); @@ -863,7 +877,6 @@ public class URLClassPath { */ Resource getResource(final String name, boolean check, Set visited) { - Resource res; String[] jarFiles; int count = 0; @@ -919,7 +932,6 @@ public class URLClassPath { continue; } - /* Note that the addition of the url to the list of visited * jars incorporates a check for presence in the hashmap */ @@ -975,6 +987,7 @@ public class URLClassPath { /* * Returns the JAR file local class path, or null if none. */ + @Override URL[] getClassPath() throws IOException { if (index != null) { return null; @@ -1002,7 +1015,7 @@ public class URLClassPath { * Parses value of the Class-Path manifest attribute and returns * an array of URLs relative to the specified base URL. */ - private URL[] parseClassPath(URL base, String value) + private static URL[] parseClassPath(URL base, String value) throws MalformedURLException { StringTokenizer st = new StringTokenizer(value); @@ -1018,7 +1031,7 @@ public class URLClassPath { } /* - * Inner class used to represent a loader of classes and resources + * Nested class used to represent a loader of classes and resources * from a file URL that refers to a directory. */ private static class FileLoader extends Loader { @@ -1038,6 +1051,7 @@ public class URLClassPath { /* * Returns the URL for a resource with the specified name */ + @Override URL findResource(final String name, boolean check) { Resource rsc = getResource(name, check); if (rsc != null) { @@ -1046,6 +1060,7 @@ public class URLClassPath { return null; } + @Override Resource getResource(final String name, boolean check) { final URL url; try { diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java index 397ddba5432..5ffd8fd7af4 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java +++ b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java @@ -30,10 +30,10 @@ import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.Map; import java.util.function.Function; +import java.util.Objects; import java.lang.System.LoggerFinder; import java.lang.System.Logger; import java.lang.ref.ReferenceQueue; -import java.lang.reflect.Module; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Collection; @@ -155,6 +155,8 @@ public class DefaultLoggerFinder extends LoggerFinder { @Override public final Logger getLogger(String name, Module module) { + Objects.requireNonNull(name, "name"); + Objects.requireNonNull(module, "module"); checkPermission(); return demandLoggerFor(name, module); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java index 6c65426ca8e..c266caac684 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java +++ b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java @@ -31,7 +31,6 @@ import java.util.function.BiFunction; import java.lang.System.LoggerFinder; import java.lang.System.Logger; import java.lang.ref.WeakReference; -import java.lang.reflect.Module; import java.util.Objects; import jdk.internal.misc.VM; import sun.util.logging.PlatformLogger; @@ -402,10 +401,10 @@ public final class LazyLoggers { * @param module The module on behalf of which the logger is created. * If the module is not loaded from the Boot ClassLoader, * the LoggerFinder is accessed and the logger returned - * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)} + * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.Module)} * is returned to the caller directly. * Otherwise, the logger returned by - * {@link #getLazyLogger(java.lang.String, java.lang.reflect.Module)} + * {@link #getLazyLogger(java.lang.String, java.lang.Module)} * is returned to the caller. * * @return a (possibly lazy) Logger instance. diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java index 6838111c35d..92b60d70777 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.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 @@ -25,18 +25,18 @@ package jdk.internal.misc; -import java.io.IOException; import java.lang.annotation.Annotation; +import java.lang.module.ModuleDescriptor; import java.lang.reflect.Executable; -import java.lang.reflect.Layer; import java.lang.reflect.Method; -import java.lang.reflect.Module; -import java.net.URL; +import java.net.URI; import java.security.AccessControlContext; +import java.security.ProtectionDomain; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; +import jdk.internal.module.ServicesCatalog; import jdk.internal.reflect.ConstantPool; import sun.reflect.annotation.AnnotationType; import sun.nio.ch.Interruptible; @@ -138,28 +138,22 @@ public interface JavaLangAccess { */ void invokeFinalize(Object o) throws Throwable; - /** - * Returns the boot Layer - */ - Layer getBootLayer(); - /** * Returns the ConcurrentHashMap used as a storage for ClassLoaderValue(s) * associated with the given class loader, creating it if it doesn't already exist. */ ConcurrentHashMap createOrGetClassLoaderValueMap(ClassLoader cl); + /** + * Defines a class with the given name to a class loader. + */ + Class defineClass(ClassLoader cl, String name, byte[] b, ProtectionDomain pd, String source); + /** * Returns a class loaded by the bootstrap class loader. */ Class findBootstrapClassOrNull(ClassLoader cl, String name); - /** - * Returns a URL to a resource with the given name in a module that is - * defined to the given class loader. - */ - URL findResource(ClassLoader cl, String moduleName, String name) throws IOException; - /** * Returns the Packages for the given class loader. */ @@ -174,4 +168,84 @@ public interface JavaLangAccess { * Invokes Long.fastUUID */ String fastUUID(long lsb, long msb); + + /** + * Record the non-exported packages of the modules in the given layer + */ + void addNonExportedPackages(ModuleLayer layer); + + /** + * Invalidate package access cache + */ + void invalidatePackageAccessCache(); + + /** + * Defines a new module to the Java virtual machine. The module + * is defined to the given class loader. + * + * The URI is for information purposes only, it can be {@code null}. + */ + Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri); + + /** + * Defines the unnamed module for the given class loader. + */ + Module defineUnnamedModule(ClassLoader loader); + + /** + * Updates the readability so that module m1 reads m2. The new read edge + * does not result in a strong reference to m2 (m2 can be GC'ed). + * + * This method is the same as m1.addReads(m2) but without a permission check. + */ + void addReads(Module m1, Module m2); + + /** + * Updates module m to read all unnamed modules. + */ + void addReadsAllUnnamed(Module m); + + /** + * Updates module m1 to export a package to module m2. The export does + * not result in a strong reference to m2 (m2 can be GC'ed). + */ + void addExports(Module m1, String pkg, Module m2); + + /** + * Updates a module m to export a package to all unnamed modules. + */ + void addExportsToAllUnnamed(Module m, String pkg); + + /** + * Updates module m1 to open a package to module m2. Opening the + * package does not result in a strong reference to m2 (m2 can be GC'ed). + */ + void addOpens(Module m1, String pkg, Module m2); + + /** + * Updates a module m to open a package to all unnamed modules. + */ + void addOpensToAllUnnamed(Module m, String pkg); + + /** + * Updates a module m to use a service. + */ + void addUses(Module m, Class service); + + /** + * Returns the ServicesCatalog for the given Layer. + */ + ServicesCatalog getServicesCatalog(ModuleLayer layer); + + /** + * Returns an ordered stream of layers. The first element is is the + * given layer, the remaining elements are its parents, in DFS order. + */ + Stream layers(ModuleLayer layer); + + /** + * Returns a stream of the layers that have modules defined to the + * given class loader. + */ + Stream layers(ClassLoader loader); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangModuleAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangModuleAccess.java index eed7a2d2aff..9ad1d5cf0ef 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangModuleAccess.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangModuleAccess.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 @@ -59,20 +59,21 @@ public interface JavaLangModuleAccess { */ ModuleDescriptor.Builder newModuleBuilder(String mn, boolean strict, - boolean open, - boolean synthetic); + Set ms); /** - * Returns the set of packages that are exported (unconditionally or - * unconditionally). + * Returns a snapshot of the packages in the module. */ - Set exportedPackages(ModuleDescriptor.Builder builder); + Set packages(ModuleDescriptor.Builder builder); /** - * Returns the set of packages that are opened (unconditionally or - * unconditionally). + * Adds a dependence on a module with the given (possibly un-parsable) + * version string. */ - Set openPackages(ModuleDescriptor.Builder builder); + void requires(ModuleDescriptor.Builder builder, + Set ms, + String mn, + String rawCompiledVersion); /** * Returns a {@code ModuleDescriptor.Requires} of the given modifiers @@ -113,24 +114,12 @@ public interface JavaLangModuleAccess { */ Provides newProvides(String service, List providers); - /** - * Returns a {@code ModuleDescriptor.Version} of the given version. - */ - Version newVersion(String v); - - /** - * Clones the given module descriptor with an augmented set of packages - */ - ModuleDescriptor newModuleDescriptor(ModuleDescriptor md, Set pkgs); - /** * Returns a new {@code ModuleDescriptor} instance. */ ModuleDescriptor newModuleDescriptor(String name, Version version, - boolean open, - boolean automatic, - boolean synthetic, + Set ms, Set requires, Set exports, Set opens, @@ -138,9 +127,6 @@ public interface JavaLangModuleAccess { Set provides, Set packages, String mainClass, - String osName, - String osArch, - String osVersion, int hashCode); /** @@ -148,9 +134,9 @@ public interface JavaLangModuleAccess { * and the empty configuration as the parent. The post resolution * checks are optionally run. */ - Configuration resolveRequiresAndUses(ModuleFinder finder, - Collection roots, - boolean check, - PrintStream traceOutput); + Configuration resolveAndBind(ModuleFinder finder, + Collection roots, + boolean check, + PrintStream traceOutput); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java deleted file mode 100644 index 7bf6a1f3977..00000000000 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangReflectModuleAccess.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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.misc; - -import java.lang.module.ModuleDescriptor; -import java.lang.reflect.Layer; -import java.lang.reflect.Module; -import java.net.URI; -import java.util.stream.Stream; - -import jdk.internal.module.ServicesCatalog; - -/** - * Provides access to non-public methods in java.lang.reflect.Module - */ - -public interface JavaLangReflectModuleAccess { - - /** - * Defines the unnamed module for the given class loader. - */ - Module defineUnnamedModule(ClassLoader loader); - - /** - * Defines a new module to the Java virtual machine. The module - * is defined to the given class loader. - * - * The URI is for information purposes only, it can be {@code null}. - */ - Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri); - - /** - * Updates the readability so that module m1 reads m2. The new read edge - * does not result in a strong reference to m2 (m2 can be GC'ed). - * - * This method is the same as m1.addReads(m2) but without a permission check. - */ - void addReads(Module m1, Module m2); - - /** - * Updates module m to read all unnamed modules. - */ - void addReadsAllUnnamed(Module m); - - /** - * Updates module m1 to export a package to module m2. The export does - * not result in a strong reference to m2 (m2 can be GC'ed). - */ - void addExports(Module m1, String pkg, Module m2); - - /** - * Updates module m1 to open a package to module m2. Opening the - * package does not result in a strong reference to m2 (m2 can be GC'ed). - */ - void addOpens(Module m1, String pkg, Module m2); - - /** - * Updates a module m to export a package to all modules. - */ - void addExportsToAll(Module m, String pkg); - - /** - * Updates a module m to open a package to all modules. - */ - void addOpensToAll(Module m, String pkg); - - /** - * Updates a module m to export a package to all unnamed modules. - */ - void addExportsToAllUnnamed(Module m, String pkg); - - /** - * Updates a module m to open a package to all unnamed modules. - */ - void addOpensToAllUnnamed(Module m, String pkg); - - /** - * Updates a module m to use a service. - */ - void addUses(Module m, Class service); - - /** - * Add a package to the given module. - */ - void addPackage(Module m, String pkg); - - /** - * Returns the ServicesCatalog for the given Layer. - */ - ServicesCatalog getServicesCatalog(Layer layer); - - /** - * Returns an ordered stream of layers. The first element is is the - * given layer, the remaining elements are its parents, in DFS order. - */ - Stream layers(Layer layer); - - /** - * Returns a stream of the layers that have modules defined to the - * given class loader. - */ - Stream layers(ClassLoader loader); - - /** - * Tests if a module exports a package at least {@code other} via its - * module declaration. - * - * @apiNote This is a temporary method for debugging features. - */ - boolean isStaticallyExported(Module module, String pn, Module other); -} \ No newline at end of file diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetURLAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetURLAccess.java new file mode 100644 index 00000000000..37e8fd3216c --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetURLAccess.java @@ -0,0 +1,32 @@ +/* + * 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.misc; + +import java.net.URL; +import java.net.URLStreamHandler; + +public interface JavaNetURLAccess { + URLStreamHandler getHandler(URL u); +} diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java index b137c3d48c4..c0eb99d7dbf 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaUtilResourceBundleAccess.java @@ -25,7 +25,6 @@ package jdk.internal.misc; -import java.lang.reflect.Module; import java.util.Locale; import java.util.ResourceBundle; diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java index 36514cb1065..cd54d422c21 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.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 @@ -50,7 +50,6 @@ public class SharedSecrets { private static JavaUtilJarAccess javaUtilJarAccess; private static JavaLangAccess javaLangAccess; private static JavaLangModuleAccess javaLangModuleAccess; - private static JavaLangReflectModuleAccess javaLangReflectModuleAccess; private static JavaLangInvokeAccess javaLangInvokeAccess; private static JavaLangRefAccess javaLangRefAccess; private static JavaIOAccess javaIOAccess; @@ -58,6 +57,7 @@ public class SharedSecrets { private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; private static JavaNetSocketAccess javaNetSocketAccess; private static JavaNetUriAccess javaNetUriAccess; + private static JavaNetURLAccess javaNetURLAccess; private static JavaNetURLClassLoaderAccess javaNetURLClassLoaderAccess; private static JavaNioAccess javaNioAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; @@ -118,16 +118,6 @@ public class SharedSecrets { return javaLangModuleAccess; } - public static void setJavaLangReflectModuleAccess(JavaLangReflectModuleAccess jlrma) { - javaLangReflectModuleAccess = jlrma; - } - - public static JavaLangReflectModuleAccess getJavaLangReflectModuleAccess() { - if (javaLangReflectModuleAccess == null) - unsafe.ensureClassInitialized(java.lang.reflect.Module.class); - return javaLangReflectModuleAccess; - } - public static void setJavaLangRefAccess(JavaLangRefAccess jlra) { javaLangRefAccess = jlra; } @@ -146,6 +136,16 @@ public class SharedSecrets { return javaNetUriAccess; } + public static void setJavaNetURLAccess(JavaNetURLAccess jnua) { + javaNetURLAccess = jnua; + } + + public static JavaNetURLAccess getJavaNetURLAccess() { + if (javaNetURLAccess == null) + unsafe.ensureClassInitialized(java.net.URL.class); + return javaNetURLAccess; + } + public static void setJavaNetURLClassLoaderAccess(JavaNetURLClassLoaderAccess jnua) { javaNetURLClassLoaderAccess = jnua; } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java index 695795e4338..95961c74584 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java @@ -26,7 +26,10 @@ package jdk.internal.misc; import static java.lang.Thread.State.*; +import java.util.Map; +import java.util.HashMap; import java.util.Properties; +import java.util.Collections; public class VM { @@ -132,25 +135,33 @@ public class VM { * Returns the system property of the specified key saved at * system initialization time. This method should only be used * for the system properties that are not changed during runtime. - * It accesses a private copy of the system properties so - * that user's locking of the system properties object will not - * cause the library to deadlock. * * Note that the saved system properties do not include - * the ones set by sun.misc.Version.init(). - * + * the ones set by java.lang.VersionProps.init(). */ public static String getSavedProperty(String key) { - if (savedProps.isEmpty()) - throw new IllegalStateException("Should be non-empty if initialized"); + if (savedProps == null) + throw new IllegalStateException("Not yet initialized"); - return savedProps.getProperty(key); + return savedProps.get(key); } - // TODO: the Property Management needs to be refactored and - // the appropriate prop keys need to be accessible to the - // calling classes to avoid duplication of keys. - private static final Properties savedProps = new Properties(); + /** + * Gets an unmodifiable view of the system properties saved at system + * initialization time. This method should only be used + * for the system properties that are not changed during runtime. + * + * Note that the saved system properties do not include + * the ones set by java.lang.VersionProps.init(). + */ + public static Map getSavedProperties() { + if (savedProps == null) + throw new IllegalStateException("Not yet initialized"); + + return savedProps; + } + + private static Map savedProps; // Save a private copy of the system properties and remove // the system properties that are not intended for public access. @@ -160,7 +171,12 @@ public class VM { if (initLevel() != 0) throw new IllegalStateException("Wrong init level"); - savedProps.putAll(props); + @SuppressWarnings({"rawtypes", "unchecked"}) + Map sp = + Map.ofEntries(props.entrySet().toArray(new Map.Entry[0])); + // only main thread is running at this time, so savedProps and + // its content will be correctly published to threads started later + savedProps = sp; // Set the maximum amount of direct memory. This value is controlled // by the vm option -XX:MaxDirectMemorySize=. diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/Builder.java b/jdk/src/java.base/share/classes/jdk/internal/module/Builder.java index 2ef9c11d248..2792ccca19f 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/Builder.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/Builder.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 @@ -38,7 +38,7 @@ import jdk.internal.misc.JavaLangModuleAccess; import jdk.internal.misc.SharedSecrets; /** - * This builder is optimized for reconstituting ModuleDescriptor + * This builder is optimized for reconstituting the {@code ModuleDescriptor}s * for system modules. The validation should be done at jlink time. * * 1. skip name validation @@ -136,9 +136,7 @@ final class Builder { } final String name; - boolean open; - boolean automatic; - boolean synthetic; + boolean open, synthetic, mandated; Set requires; Set exports; Set opens; @@ -147,9 +145,6 @@ final class Builder { Set provides; Version version; String mainClass; - String osName; - String osArch; - String osVersion; Builder(String name) { this.name = name; @@ -165,13 +160,13 @@ final class Builder { return this; } - Builder automatic(boolean value) { - this.automatic = value; + Builder synthetic(boolean value) { + this.synthetic = value; return this; } - Builder synthetic(boolean value) { - this.synthetic = value; + Builder mandated(boolean value) { + this.mandated = value; return this; } @@ -228,13 +223,10 @@ final class Builder { * * @throws IllegalArgumentException if {@code v} is null or cannot be * parsed as a version string - * @throws IllegalStateException if the module version is already set * * @see Version#parse(String) */ public Builder version(String v) { - if (version != null) - throw new IllegalStateException("module version already set"); Version ver = cachedVersion; if (ver != null && v.equals(ver.toString())) { version = ver; @@ -246,50 +238,29 @@ final class Builder { /** * Sets the module main class. - * - * @throws IllegalStateException if already set */ public Builder mainClass(String mc) { - if (mainClass != null) - throw new IllegalStateException("main class already set"); mainClass = mc; return this; } /** - * Sets the OS name. - * - * @throws IllegalStateException if already set + * Returns an immutable set of the module modifiers derived from the flags. */ - public Builder osName(String name) { - if (osName != null) - throw new IllegalStateException("OS name already set"); - this.osName = name; - return this; - } - - /** - * Sets the OS arch. - * - * @throws IllegalStateException if already set - */ - public Builder osArch(String arch) { - if (osArch != null) - throw new IllegalStateException("OS arch already set"); - this.osArch = arch; - return this; - } - - /** - * Sets the OS version. - * - * @throws IllegalStateException if already set - */ - public Builder osVersion(String version) { - if (osVersion != null) - throw new IllegalStateException("OS version already set"); - this.osVersion = version; - return this; + private Set modifiers() { + int n = 0; + if (open) n++; + if (synthetic) n++; + if (mandated) n++; + if (n == 0) { + return Collections.emptySet(); + } else { + ModuleDescriptor.Modifier[] mods = new ModuleDescriptor.Modifier[n]; + if (open) mods[--n] = ModuleDescriptor.Modifier.OPEN; + if (synthetic) mods[--n] = ModuleDescriptor.Modifier.SYNTHETIC; + if (mandated) mods[--n] = ModuleDescriptor.Modifier.MANDATED; + return Set.of(mods); + } } /** @@ -297,12 +268,9 @@ final class Builder { */ public ModuleDescriptor build(int hashCode) { assert name != null; - return JLMA.newModuleDescriptor(name, version, - open, - automatic, - synthetic, + modifiers(), requires, exports, opens, @@ -310,9 +278,6 @@ final class Builder { provides, packages, mainClass, - osName, - osArch, - osVersion, hashCode); } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/Checks.java b/jdk/src/java.base/share/classes/jdk/internal/module/Checks.java index 2fdeaab6211..4d772df129a 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/Checks.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/Checks.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 @@ -25,8 +25,10 @@ package jdk.internal.module; +import java.util.Set; + /** - * Utility class for checking module name and binary names. + * Utility class for checking module, package, and class names. */ public final class Checks { @@ -45,21 +47,18 @@ public final class Checks { int next; int off = 0; while ((next = name.indexOf('.', off)) != -1) { - if (isJavaIdentifier(name, off, (next - off)) == -1) { - String id = name.substring(off, next); + String id = name.substring(off, next); + if (!isJavaIdentifier(id)) { throw new IllegalArgumentException(name + ": Invalid module name" + ": '" + id + "' is not a Java identifier"); } off = next+1; } - int last = isJavaIdentifier(name, off, name.length() - off); - if (last == -1) { - String id = name.substring(off); + String last = name.substring(off); + if (!isJavaIdentifier(last)) { throw new IllegalArgumentException(name + ": Invalid module name" - + ": '" + id + "' is not a Java identifier"); + + ": '" + last + "' is not a Java identifier"); } - //if (!Character.isJavaIdentifierStart(last)) - // throw new IllegalArgumentException(name + ": Module name ends in digit"); return name; } @@ -70,16 +69,13 @@ public final class Checks { int next; int off = 0; while ((next = name.indexOf('.', off)) != -1) { - if (isJavaIdentifier(name, off, (next - off)) == -1) + String id = name.substring(off, next); + if (!isJavaIdentifier(id)) return false; off = next+1; } - int last = isJavaIdentifier(name, off, name.length() - off); - if (last == -1) - return false; - //if (!Character.isJavaIdentifierStart(last)) - // return false; - return true; + String last = name.substring(off); + return isJavaIdentifier(last); } /** @@ -89,136 +85,179 @@ public final class Checks { * package name */ public static String requirePackageName(String name) { - return requireBinaryName("package name", name); + return requireTypeName("package name", name); } /** - * Checks a name to ensure that it's a legal type name. + * Returns {@code true} if the given name is a legal package name. + */ + public static boolean isPackageName(String name) { + return isTypeName(name); + } + + /** + * Checks a name to ensure that it's a legal qualified class name * * @throws IllegalArgumentException if name is null or not a legal - * type name + * qualified class name */ public static String requireServiceTypeName(String name) { - return requireBinaryName("service type name", name); + return requireQualifiedClassName("service type name", name); } /** - * Checks a name to ensure that it's a legal type name. + * Checks a name to ensure that it's a legal qualified class name. * * @throws IllegalArgumentException if name is null or not a legal - * type name + * qualified class name */ public static String requireServiceProviderName(String name) { - return requireBinaryName("service provider name", name); + return requireQualifiedClassName("service provider name", name); } /** - * Returns {@code true} if the given name is a legal binary name. + * Checks a name to ensure that it's a legal qualified class name in + * a named package. + * + * @throws IllegalArgumentException if name is null or not a legal + * qualified class name in a named package */ - public static boolean isJavaIdentifier(String name) { - return isBinaryName(name); + public static String requireQualifiedClassName(String what, String name) { + requireTypeName(what, name); + if (name.indexOf('.') == -1) + throw new IllegalArgumentException(name + ": is not a qualified name of" + + " a Java class in a named package"); + return name; } /** - * Returns {@code true} if the given name is a legal binary name. + * Returns {@code true} if the given name is a legal class name. */ - public static boolean isBinaryName(String name) { + public static boolean isClassName(String name) { + return isTypeName(name); + } + + /** + * Returns {@code true} if the given name is a legal type name. + */ + private static boolean isTypeName(String name) { int next; int off = 0; while ((next = name.indexOf('.', off)) != -1) { - if (isJavaIdentifier(name, off, (next - off)) == -1) + String id = name.substring(off, next); + if (!isJavaIdentifier(id)) return false; off = next+1; } - int count = name.length() - off; - return (isJavaIdentifier(name, off, count) != -1); + String last = name.substring(off); + return isJavaIdentifier(last); } /** - * Checks if the given name is a legal binary name. + * Checks if the given name is a legal type name. * * @throws IllegalArgumentException if name is null or not a legal - * binary name + * type name */ - public static String requireBinaryName(String what, String name) { + private static String requireTypeName(String what, String name) { if (name == null) throw new IllegalArgumentException("Null " + what); int next; int off = 0; while ((next = name.indexOf('.', off)) != -1) { - if (isJavaIdentifier(name, off, (next - off)) == -1) { - String id = name.substring(off, next); + String id = name.substring(off, next); + if (!isJavaIdentifier(id)) { throw new IllegalArgumentException(name + ": Invalid " + what + ": '" + id + "' is not a Java identifier"); } off = next + 1; } - if (isJavaIdentifier(name, off, name.length() - off) == -1) { - String id = name.substring(off, name.length()); + String last = name.substring(off); + if (!isJavaIdentifier(last)) { throw new IllegalArgumentException(name + ": Invalid " + what - + ": '" + id + "' is not a Java identifier"); + + ": '" + last + "' is not a Java identifier"); } return name; } /** - * Returns {@code true} if the last character of the given name is legal - * as the last character of a module name. - * - * @throws IllegalArgumentException if name is empty + * Returns true if the given char sequence is a legal Java identifier, + * otherwise false. */ - public static boolean hasLegalModuleNameLastCharacter(String name) { - if (name.isEmpty()) - throw new IllegalArgumentException("name is empty"); - int len = name.length(); - if (isASCIIString(name)) { - char c = name.charAt(len-1); - return Character.isJavaIdentifierStart(c); - } else { - int i = 0; - int cp = -1; - while (i < len) { - cp = name.codePointAt(i); - i += Character.charCount(cp); - } - return Character.isJavaIdentifierStart(cp); - } - } + private static boolean isJavaIdentifier(CharSequence cs) { + if (cs.length() == 0 || RESERVED.contains(cs)) + return false; - /** - * Returns true if the given string only contains ASCII characters. - */ - private static boolean isASCIIString(String s) { - int i = 0; - while (i < s.length()) { - int c = s.charAt(i); - if (c > 0x7F) - return false; - i++; - } - return true; - } - - /** - * Checks if a char sequence is a legal Java identifier, returning the code - * point of the last character if legal or {@code -1} if not legal. - */ - private static int isJavaIdentifier(CharSequence cs, int offset, int count) { - if (count == 0) - return -1; - int first = Character.codePointAt(cs, offset); + int first = Character.codePointAt(cs, 0); if (!Character.isJavaIdentifierStart(first)) - return -1; + return false; - int cp = first; int i = Character.charCount(first); - while (i < count) { - cp = Character.codePointAt(cs, offset+i); + while (i < cs.length()) { + int cp = Character.codePointAt(cs, i); if (!Character.isJavaIdentifierPart(cp)) - return -1; + return false; i += Character.charCount(cp); } - return cp; + return true; } + + // keywords, boolean and null literals, not allowed in identifiers + private static final Set RESERVED = Set.of( + "abstract", + "assert", + "boolean", + "break", + "byte", + "case", + "catch", + "char", + "class", + "const", + "continue", + "default", + "do", + "double", + "else", + "enum", + "extends", + "final", + "finally", + "float", + "for", + "goto", + "if", + "implements", + "import", + "instanceof", + "int", + "interface", + "long", + "native", + "new", + "package", + "private", + "protected", + "public", + "return", + "short", + "static", + "strictfp", + "super", + "switch", + "synchronized", + "this", + "throw", + "throws", + "transient", + "try", + "void", + "volatile", + "while", + "true", + "false", + "null", + "_" + ); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java b/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java index 69c7ee670dd..dd3520f044c 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.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 @@ -26,6 +26,7 @@ package jdk.internal.module; import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleDescriptor.Builder; import java.lang.module.ModuleDescriptor.Requires; import java.lang.module.ModuleDescriptor.Exports; import java.lang.module.ModuleDescriptor.Opens; @@ -98,14 +99,17 @@ public final class ClassFileAttributes { // module_flags int module_flags = cr.readUnsignedShort(off); - boolean open = ((module_flags & ACC_OPEN) != 0); - boolean synthetic = ((module_flags & ACC_SYNTHETIC) != 0); off += 2; - ModuleDescriptor.Builder builder = JLMA.newModuleBuilder(mn, - false, - open, - synthetic); + Set modifiers = new HashSet<>(); + if ((module_flags & ACC_OPEN) != 0) + modifiers.add(ModuleDescriptor.Modifier.OPEN); + if ((module_flags & ACC_SYNTHETIC) != 0) + modifiers.add(ModuleDescriptor.Modifier.SYNTHETIC); + if ((module_flags & ACC_MANDATED) != 0) + modifiers.add(ModuleDescriptor.Modifier.MANDATED); + + Builder builder = JLMA.newModuleBuilder(mn, false, modifiers); // module_version String module_version = cr.readUTF8(off, buf); @@ -142,19 +146,13 @@ public final class ClassFileAttributes { mods.add(Requires.Modifier.MANDATED); } - // requires_version - Version compiledVersion = null; String requires_version = cr.readUTF8(off, buf); off += 2; - if (requires_version != null) { - compiledVersion = Version.parse(requires_version); - } - - if (compiledVersion == null) { + if (requires_version == null) { builder.requires(mods, dn); } else { - builder.requires(mods, dn, compiledVersion); + JLMA.requires(builder, mods, dn, requires_version); } } @@ -283,19 +281,22 @@ public final class ClassFileAttributes { attr.putShort(module_name_index); // module_flags + Set modifiers = descriptor.modifiers(); int module_flags = 0; - if (descriptor.isOpen()) + if (modifiers.contains(ModuleDescriptor.Modifier.OPEN)) module_flags |= ACC_OPEN; - if (descriptor.isSynthetic()) + if (modifiers.contains(ModuleDescriptor.Modifier.SYNTHETIC)) module_flags |= ACC_SYNTHETIC; + if (modifiers.contains(ModuleDescriptor.Modifier.MANDATED)) + module_flags |= ACC_MANDATED; attr.putShort(module_flags); // module_version - Version v = descriptor.version().orElse(null); - if (v == null) { + String vs = descriptor.rawVersion().orElse(null); + if (vs == null) { attr.putShort(0); } else { - int module_version_index = cw.newUTF8(v.toString()); + int module_version_index = cw.newUTF8(vs); attr.putShort(module_version_index); } @@ -319,11 +320,11 @@ public final class ClassFileAttributes { attr.putShort(requires_flags); int requires_version_index; - v = r.compiledVersion().orElse(null); - if (v == null) { + vs = r.rawCompiledVersion().orElse(null); + if (vs == null) { requires_version_index = 0; } else { - requires_version_index = cw.newUTF8(v.toString()); + requires_version_index = cw.newUTF8(vs); } attr.putShort(requires_version_index); } @@ -548,30 +549,26 @@ public final class ClassFileAttributes { * u2 attribute_name_index; * u4 attribute_length; * - * // index to CONSTANT_utf8_info structure with the OS name - * u2 os_name_index; - * // index to CONSTANT_utf8_info structure with the OS arch - * u2 os_arch_index - * // index to CONSTANT_utf8_info structure with the OS version - * u2 os_version_index; + * // index to CONSTANT_utf8_info structure with the target platform + * u2 target_platform_index; * } * * } */ public static class ModuleTargetAttribute extends Attribute { - private final String osName; - private final String osArch; - private final String osVersion; + private final String targetPlatform; - public ModuleTargetAttribute(String osName, String osArch, String osVersion) { + public ModuleTargetAttribute(String targetPlatform) { super(MODULE_TARGET); - this.osName = osName; - this.osArch = osArch; - this.osVersion = osVersion; + this.targetPlatform = targetPlatform; } public ModuleTargetAttribute() { - this(null, null, null); + this(null); + } + + public String targetPlatform() { + return targetPlatform; } @Override @@ -583,26 +580,14 @@ public final class ClassFileAttributes { Label[] labels) { - String osName = null; - String osArch = null; - String osVersion = null; + String targetPlatform = null; - int name_index = cr.readUnsignedShort(off); - if (name_index != 0) - osName = cr.readUTF8(off, buf); + int target_platform_index = cr.readUnsignedShort(off); + if (target_platform_index != 0) + targetPlatform = cr.readUTF8(off, buf); off += 2; - int arch_index = cr.readUnsignedShort(off); - if (arch_index != 0) - osArch = cr.readUTF8(off, buf); - off += 2; - - int version_index = cr.readUnsignedShort(off); - if (version_index != 0) - osVersion = cr.readUTF8(off, buf); - off += 2; - - return new ModuleTargetAttribute(osName, osArch, osVersion); + return new ModuleTargetAttribute(targetPlatform); } @Override @@ -614,20 +599,10 @@ public final class ClassFileAttributes { { ByteVector attr = new ByteVector(); - int name_index = 0; - if (osName != null && osName.length() > 0) - name_index = cw.newUTF8(osName); - attr.putShort(name_index); - - int arch_index = 0; - if (osArch != null && osArch.length() > 0) - arch_index = cw.newUTF8(osArch); - attr.putShort(arch_index); - - int version_index = 0; - if (osVersion != null && osVersion.length() > 0) - version_index = cw.newUTF8(osVersion); - attr.putShort(version_index); + int target_platform_index = 0; + if (targetPlatform != null && targetPlatform.length() > 0) + target_platform_index = cw.newUTF8(targetPlatform); + attr.putShort(target_platform_index); return attr; } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileConstants.java b/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileConstants.java index 48fe536c7aa..66e241ee555 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileConstants.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileConstants.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 @@ -46,8 +46,8 @@ public class ClassFileConstants { // access, requires, exports, and opens flags public static final int ACC_MODULE = 0x8000; public static final int ACC_OPEN = 0x0020; - public static final int ACC_TRANSITIVE = 0x0010; - public static final int ACC_STATIC_PHASE = 0x0020; + public static final int ACC_TRANSITIVE = 0x0020; + public static final int ACC_STATIC_PHASE = 0x0040; public static final int ACC_SYNTHETIC = 0x1000; public static final int ACC_MANDATED = 0x8000; diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java b/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java new file mode 100644 index 00000000000..3914ce923fc --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/module/IllegalAccessLogger.java @@ -0,0 +1,344 @@ +/* + * 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.invoke.MethodHandles; +import java.net.URL; +import java.security.AccessController; +import java.security.CodeSource; +import java.security.PrivilegedAction; +import java.security.ProtectionDomain; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.WeakHashMap; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import jdk.internal.loader.BootLoader; +import sun.security.action.GetPropertyAction; + +/** + * Supports logging of access to members of API packages that are exported or + * opened via backdoor mechanisms to code in unnamed modules. + */ + +public final class IllegalAccessLogger { + + /** + * Holder class to lazily create the StackWalker object and determine + * if the stack trace should be printed + */ + static class Holder { + static final StackWalker STACK_WALKER; + static final boolean PRINT_STACK_TRACE; + + static { + PrivilegedAction pa = () -> + StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); + STACK_WALKER = AccessController.doPrivileged(pa); + + String name = "sun.reflect.debugModuleAccessChecks"; + String value = GetPropertyAction.privilegedGetProperty(name, null); + PRINT_STACK_TRACE = "access" .equals(value); + } + } + + // the maximum number of frames to capture + private static final int MAX_STACK_FRAMES = 32; + + // lock to avoid interference when printing stack traces + private static final Object OUTPUT_LOCK = new Object(); + + // caller -> usages + private final Map, Set> callerToUsages = new WeakHashMap<>(); + + // module -> (package name -> CLI option) + private final Map> exported; + private final Map> opened; + + // the print stream to send the warnings + private final PrintStream warningStream; + + private IllegalAccessLogger(Map> exported, + Map> opened, + PrintStream warningStream) { + this.exported = deepCopy(exported); + this.opened = deepCopy(opened); + this.warningStream = warningStream; + } + + /** + * Returns that a Builder that is seeded with the packages known to this logger. + */ + public Builder toBuilder() { + return new Builder(exported, opened); + } + + /** + * Logs access to the member of a target class by a caller class if the class + * is in a package that is exported via a backdoor mechanism. + * + * The {@code whatSupplier} supplies the message that describes the member. + */ + public void logIfExportedByBackdoor(Class caller, + Class target, + Supplier whatSupplier) { + Map packages = exported.get(target.getModule()); + if (packages != null) { + String how = packages.get(target.getPackageName()); + if (how != null) { + log(caller, whatSupplier.get(), how); + } + } + } + + /** + * Logs access to the member of a target class by a caller class if the class + * is in a package that is opened via a backdoor mechanism. + * + * The {@code what} parameter supplies the message that describes the member. + */ + public void logIfOpenedByBackdoor(Class caller, + Class target, + Supplier whatSupplier) { + Map packages = opened.get(target.getModule()); + if (packages != null) { + String how = packages.get(target.getPackageName()); + if (how != null) { + log(caller, whatSupplier.get(), how); + } + } + } + + /** + * Logs access by a caller class. The {@code what} parameter describes + * the member is accessed, the {@code how} parameter is the means by which + * access is allocated (CLI option for example). + */ + private void log(Class caller, String what, String how) { + log(caller, what, () -> { + PrivilegedAction pa = caller::getProtectionDomain; + CodeSource cs = AccessController.doPrivileged(pa).getCodeSource(); + URL url = (cs != null) ? cs.getLocation() : null; + String source = caller.getName(); + if (url != null) + source += " (" + url + ")"; + return "WARNING: Illegal access by " + source + " to " + what + + " (permitted by " + how + ")"; + }); + } + + + /** + * Logs access to caller class if the class is in a package that is opened via + * a backdoor mechanism. + */ + public void logIfOpenedByBackdoor(MethodHandles.Lookup caller, Class target) { + Map packages = opened.get(target.getModule()); + if (packages != null) { + String how = packages.get(target.getPackageName()); + if (how != null) { + log(caller.lookupClass(), target.getName(), () -> + "WARNING: Illegal access using Lookup on " + caller.lookupClass() + + " to " + target + " (permitted by " + how + ")"); + } + } + } + + /** + * Log access by a caller. The {@code what} parameter describes the class or + * member that is being accessed. The {@code msgSupplier} supplies the log + * message. + * + * To reduce output, this method only logs the access if it hasn't been seen + * previously. "Seen previously" is implemented as a map of caller class -> Usage, + * where a Usage is the "what" and a hash of the stack trace. The map has weak + * keys so it can be expunged when the caller is GC'ed/unloaded. + */ + private void log(Class caller, String what, Supplier msgSupplier) { + // stack trace without the top-most frames in java.base + List stack = Holder.STACK_WALKER.walk(s -> + s.dropWhile(this::isJavaBase) + .limit(MAX_STACK_FRAMES) + .collect(Collectors.toList()) + ); + + // check if the access has already been recorded + Usage u = new Usage(what, hash(stack)); + boolean firstUsage; + synchronized (this) { + firstUsage = callerToUsages.computeIfAbsent(caller, k -> new HashSet<>()).add(u); + } + + // log message if first usage + if (firstUsage) { + String msg = msgSupplier.get(); + if (Holder.PRINT_STACK_TRACE) { + synchronized (OUTPUT_LOCK) { + warningStream.println(msg); + stack.forEach(f -> warningStream.println("\tat " + f)); + } + } else { + warningStream.println(msg); + } + } + } + + private static class Usage { + private final String what; + private final int stack; + Usage(String what, int stack) { + this.what = what; + this.stack = stack; + } + @Override + public int hashCode() { + return what.hashCode() ^ stack; + } + @Override + public boolean equals(Object ob) { + if (ob instanceof Usage) { + Usage that = (Usage)ob; + return what.equals(that.what) && stack == (that.stack); + } else { + return false; + } + } + } + + /** + * Returns true if the stack frame is for a class in java.base. + */ + private boolean isJavaBase(StackWalker.StackFrame frame) { + Module caller = frame.getDeclaringClass().getModule(); + return "java.base".equals(caller.getName()); + } + + /** + * Computes a hash code for the give stack frames. The hash code is based + * on the class, method name, and BCI. + */ + private int hash(List stack) { + int hash = 0; + for (StackWalker.StackFrame frame : stack) { + hash = (31 * hash) + Objects.hash(frame.getDeclaringClass(), + frame.getMethodName(), + frame.getByteCodeIndex()); + } + return hash; + } + + // system-wide IllegalAccessLogger + private static volatile IllegalAccessLogger logger; + + /** + * Sets the system-wide IllegalAccessLogger + */ + public static void setIllegalAccessLogger(IllegalAccessLogger l) { + if (l.exported.isEmpty() && l.opened.isEmpty()) { + logger = null; + } else { + logger = l; + } + } + + /** + * Returns the system-wide IllegalAccessLogger or {@code null} if there is + * no logger. + */ + public static IllegalAccessLogger illegalAccessLogger() { + return logger; + } + + /** + * A builder for IllegalAccessLogger objects. + */ + public static class Builder { + private final Module UNNAMED = BootLoader.getUnnamedModule(); + private Map> exported; + private Map> opened; + private PrintStream warningStream = System.err; + + public Builder() { } + + public Builder(Map> exported, + Map> opened) { + this.exported = deepCopy(exported); + this.opened = deepCopy(opened); + } + + public Builder logAccessToExportedPackage(Module m, String pn, String how) { + if (!m.isExported(pn, UNNAMED)) { + if (exported == null) + exported = new HashMap<>(); + exported.computeIfAbsent(m, k -> new HashMap<>()).putIfAbsent(pn, how); + } + return this; + } + + public Builder logAccessToOpenPackage(Module m, String pn, String how) { + // opens implies exported at run-time. + logAccessToExportedPackage(m, pn, how); + + if (!m.isOpen(pn, UNNAMED)) { + if (opened == null) + opened = new HashMap<>(); + opened.computeIfAbsent(m, k -> new HashMap<>()).putIfAbsent(pn, how); + } + return this; + } + + public Builder warningStream(PrintStream warningStream) { + this.warningStream = Objects.requireNonNull(warningStream); + return this; + } + + /** + * Builds the logger. + */ + public IllegalAccessLogger build() { + return new IllegalAccessLogger(exported, opened, warningStream); + } + } + + + static Map> deepCopy(Map> map) { + if (map == null || map.isEmpty()) { + return new HashMap<>(); + } else { + Map> newMap = new HashMap<>(); + for (Map.Entry> e : map.entrySet()) { + newMap.put(e.getKey(), new HashMap<>(e.getValue())); + } + return newMap; + } + } +} diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java index 71406460c41..d083ead7801 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.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 @@ -32,8 +32,6 @@ import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReference; import java.lang.module.ResolvedModule; -import java.lang.reflect.Layer; -import java.lang.reflect.Module; import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; @@ -60,7 +58,7 @@ import jdk.internal.perf.PerfCounter; * resolving a set of module names specified via the launcher (or equivalent) * -m and --add-modules options. The modules are located on a module path that * is constructed from the upgrade module path, system modules, and application - * module path. The Configuration is instantiated as the boot Layer with each + * module path. The Configuration is instantiated as the boot layer with each * module in the the configuration defined to one of the built-in class loaders. */ @@ -86,8 +84,9 @@ public final class ModuleBootstrap { // The ModulePatcher for the initial configuration private static final ModulePatcher patcher = initModulePatcher(); - // ModuleFinder for the initial configuration - private static ModuleFinder initialFinder; + // ModuleFinders for the initial configuration + private static ModuleFinder unlimitedFinder; + private static ModuleFinder limitedFinder; /** * Returns the ModulePatcher for the initial configuration. @@ -97,19 +96,28 @@ public final class ModuleBootstrap { } /** - * Returns the ModuleFinder for the initial configuration + * Returns the ModuleFinder for the initial configuration before observability + * is limited by the --limit-modules command line option. */ - public static ModuleFinder finder() { - assert initialFinder != null; - return initialFinder; + public static ModuleFinder unlimitedFinder() { + assert unlimitedFinder != null; + return unlimitedFinder; } /** - * Initialize the module system, returning the boot Layer. + * Returns the ModuleFinder for the initial configuration. + */ + public static ModuleFinder limitedFinder() { + assert limitedFinder != null; + return limitedFinder; + } + + /** + * Initialize the module system, returning the boot layer. * * @see java.lang.System#initPhase2() */ - public static Layer boot() { + public static ModuleLayer boot() { long t0 = System.nanoTime(); @@ -136,6 +144,11 @@ public final class ModuleBootstrap { PerfCounters.defineBaseTime.addElapsedTimeFrom(t1); + // special mode to boot with only java.base, ignores other options + String propValue = getAndRemoveProperty("jdk.module.minimumBoot"); + if (propValue != null) { + return createMinimalBootLayer(); + } long t2 = System.nanoTime(); @@ -182,7 +195,8 @@ public final class ModuleBootstrap { } // --limit-modules - String propValue = getAndRemoveProperty("jdk.module.limitmods"); + unlimitedFinder = finder; + propValue = getAndRemoveProperty("jdk.module.limitmods"); if (propValue != null) { Set mods = new HashSet<>(); for (String mod: propValue.split(",")) { @@ -190,6 +204,7 @@ public final class ModuleBootstrap { } finder = limitFinder(finder, mods, roots); } + limitedFinder = finder; // If there is no initial module specified then assume that the initial // module is the unnamed module of the application class loader. This @@ -236,7 +251,6 @@ public final class ModuleBootstrap { ModuleFinder f = finder; // observable modules systemModules.findAll() .stream() - .filter(mref -> !ModuleResolution.doNotResolveByDefault(mref)) .map(ModuleReference::descriptor) .map(ModuleDescriptor::name) .filter(mn -> f.find(mn).isPresent()) // observable @@ -270,15 +284,16 @@ public final class ModuleBootstrap { } PrintStream traceOutput = null; - if (Boolean.getBoolean("jdk.launcher.traceResolver")) + propValue = getAndRemoveProperty("jdk.module.showModuleResolution"); + if (propValue != null && Boolean.parseBoolean(propValue)) traceOutput = System.out; // run the resolver to create the configuration Configuration cf = SharedSecrets.getJavaLangModuleAccess() - .resolveRequiresAndUses(finder, - roots, - needPostResolutionChecks, - traceOutput); + .resolveAndBind(finder, + roots, + needPostResolutionChecks, + traceOutput); // time to create configuration PerfCounters.resolveTime.addElapsedTimeFrom(t3); @@ -318,25 +333,25 @@ public final class ModuleBootstrap { // if needed check that there are no split packages in the set of // resolved modules for the boot layer if (SystemModules.hasSplitPackages() || needPostResolutionChecks) { - Map packageToModule = new HashMap<>(); - for (ResolvedModule resolvedModule : cf.modules()) { - ModuleDescriptor descriptor = - resolvedModule.reference().descriptor(); - String name = descriptor.name(); - for (String p : descriptor.packages()) { - String other = packageToModule.putIfAbsent(p, name); - if (other != null) { - fail("Package " + p + " in both module " - + name + " and module " + other); - } + Map packageToModule = new HashMap<>(); + for (ResolvedModule resolvedModule : cf.modules()) { + ModuleDescriptor descriptor = resolvedModule.reference().descriptor(); + String name = descriptor.name(); + for (String p : descriptor.packages()) { + String other = packageToModule.putIfAbsent(p, name); + if (other != null) { + String msg = "Package " + p + " in both module " + + name + " and module " + other; + throw new LayerInstantiationException(msg); } } } + } long t4 = System.nanoTime(); // define modules to VM/runtime - Layer bootLayer = Layer.empty().defineModules(cf, clf); + ModuleLayer bootLayer = ModuleLayer.empty().defineModules(cf, clf); PerfCounters.layerCreateTime.addElapsedTimeFrom(t4); @@ -358,19 +373,30 @@ public final class ModuleBootstrap { PerfCounters.loadModulesTime.addElapsedTimeFrom(t5); - // --add-reads, -add-exports/-add-opens + // --add-reads, --add-exports/--add-opens addExtraReads(bootLayer); addExtraExportsAndOpens(bootLayer); // total time to initialize PerfCounters.bootstrapTime.addElapsedTimeFrom(t0); - // remember the ModuleFinder - initialFinder = finder; - return bootLayer; } + /** + * Create a "minimal" boot module layer that only contains java.base. + */ + private static ModuleLayer createMinimalBootLayer() { + Configuration cf = SharedSecrets.getJavaLangModuleAccess() + .resolveAndBind(ModuleFinder.ofSystem(), + Set.of(JAVA_BASE), + false, + null); + + Function clf = ModuleLoaderMap.mappingFunction(cf); + return ModuleLayer.empty().defineModules(cf, clf); + } + /** * Returns a ModuleFinder that limits observability to the given root * modules, their transitive dependences, plus a set of other modules. @@ -380,10 +406,9 @@ public final class ModuleBootstrap { Set otherMods) { // resolve all root modules - Configuration cf = Configuration.empty() - .resolveRequires(finder, - ModuleFinder.of(), - roots); + Configuration cf = Configuration.empty().resolve(finder, + ModuleFinder.of(), + roots); // module name -> reference Map map = new HashMap<>(); @@ -416,7 +441,7 @@ public final class ModuleBootstrap { /** * Creates a finder from the module path that is the value of the given - * system property. + * system property and optionally patched by --patch-module */ private static ModuleFinder createModulePathFinder(String prop) { String s = System.getProperty(prop); @@ -429,7 +454,7 @@ public final class ModuleBootstrap { for (String dir: dirs) { paths[i++] = Paths.get(dir); } - return ModuleFinder.of(paths); + return ModulePath.of(patcher, paths); } } @@ -475,7 +500,7 @@ public final class ModuleBootstrap { * Process the --add-reads options to add any additional read edges that * are specified on the command-line. */ - private static void addExtraReads(Layer bootLayer) { + private static void addExtraReads(ModuleLayer bootLayer) { // decode the command line options Map> map = decode("jdk.module.addreads."); @@ -513,8 +538,7 @@ public final class ModuleBootstrap { * Process the --add-exports and --add-opens options to export/open * additional packages specified on the command-line. */ - private static void addExtraExportsAndOpens(Layer bootLayer) { - + private static void addExtraExportsAndOpens(ModuleLayer bootLayer) { // --add-exports String prefix = "jdk.module.addexports."; Map> extraExports = decode(prefix); @@ -528,9 +552,27 @@ public final class ModuleBootstrap { if (!extraOpens.isEmpty()) { addExtraExportsOrOpens(bootLayer, extraOpens, true); } + + // --permit-illegal-access + if (getAndRemoveProperty("jdk.module.permitIllegalAccess") != null) { + warn("--permit-illegal-access will be removed in the next major release"); + IllegalAccessLogger.Builder builder = new IllegalAccessLogger.Builder(); + Module unnamed = BootLoader.getUnnamedModule(); + bootLayer.modules().stream().forEach(m -> { + m.getDescriptor() + .packages() + .stream() + .filter(pn -> !m.isOpen(pn, unnamed)) // skip if opened by --add-opens + .forEach(pn -> { + builder.logAccessToOpenPackage(m, pn, "--permit-illegal-access"); + Modules.addOpensToAllUnnamed(m, pn); + }); + }); + IllegalAccessLogger.setIllegalAccessLogger(builder.build()); + } } - private static void addExtraExportsOrOpens(Layer bootLayer, + private static void addExtraExportsOrOpens(ModuleLayer bootLayer, Map> map, boolean opens) { @@ -541,12 +583,12 @@ public final class ModuleBootstrap { String key = e.getKey(); String[] s = key.split("/"); if (s.length != 2) - fail(unableToParse(option, "/", key)); + fail(unableToParse(option, "/", key)); String mn = s[0]; String pn = s[1]; if (mn.isEmpty() || pn.isEmpty()) - fail(unableToParse(option, "/", key)); + fail(unableToParse(option, "/", key)); // The exporting module is in the boot layer Module m; @@ -631,7 +673,7 @@ public final class ModuleBootstrap { // value is (,)* or ()* if (!allowDuplicates && map.containsKey(key)) - fail(key + " specified more than once in " + option(prefix)); + fail(key + " specified more than once to " + option(prefix)); List values = map.computeIfAbsent(key, k -> new ArrayList<>()); int ntargets = 0; for (String s : rhs.split(regex)) { @@ -675,10 +717,6 @@ public final class ModuleBootstrap { ModuleReference mref = rm.reference(); String mn = mref.descriptor().name(); - // emit warning if module name ends with a non-Java letter - if (!Checks.hasLegalModuleNameLastCharacter(mn)) - warn("Module name \"" + mn + "\" may soon be illegal"); - // emit warning if the WARN_INCUBATING module resolution bit set if (ModuleResolution.hasIncubatingWarning(mref)) { if (incubating == null) { @@ -704,7 +742,7 @@ public final class ModuleBootstrap { } static void warnUnknownModule(String option, String mn) { - warn("Unknown module: " + mn + " specified in " + option); + warn("Unknown module: " + mn + " specified to " + option); } static String unableToParse(String option, String text, String value) { 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 index d808fe1db48..804f5eb4527 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java @@ -138,7 +138,7 @@ public class ModuleHashesBuilder { } /* - * Utilty class + * Utility class */ static class Graph { private final Set nodes; diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java index 3aac651577c..f6f1bb07e16 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.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 @@ -37,7 +37,6 @@ import java.lang.module.ModuleDescriptor.Builder; import java.lang.module.ModuleDescriptor.Requires; import java.lang.module.ModuleDescriptor.Exports; import java.lang.module.ModuleDescriptor.Opens; -import java.lang.module.ModuleDescriptor.Version; import java.nio.ByteBuffer; import java.nio.BufferUnderflowException; import java.util.ArrayList; @@ -51,7 +50,6 @@ import java.util.function.Supplier; import jdk.internal.misc.JavaLangModuleAccess; import jdk.internal.misc.SharedSecrets; -import jdk.internal.module.ModuleResolution; import static jdk.internal.module.ClassFileConstants.*; @@ -91,18 +89,24 @@ public final class ModuleInfo { */ public static final class Attributes { private final ModuleDescriptor descriptor; + private final ModuleTarget target; private final ModuleHashes recordedHashes; private final ModuleResolution moduleResolution; Attributes(ModuleDescriptor descriptor, + ModuleTarget target, ModuleHashes recordedHashes, ModuleResolution moduleResolution) { this.descriptor = descriptor; + this.target = target; this.recordedHashes = recordedHashes; this.moduleResolution = moduleResolution; } public ModuleDescriptor descriptor() { return descriptor; } + public ModuleTarget target() { + return target; + } public ModuleHashes recordedHashes() { return recordedHashes; } @@ -221,10 +225,10 @@ public final class ModuleInfo { Set attributes = new HashSet<>(); Builder builder = null; - Set packages = null; + Set allPackages = null; String mainClass = null; - String[] osValues = null; - ModuleHashes hashes = null; + ModuleTarget moduleTarget = null; + ModuleHashes moduelHashes = null; ModuleResolution moduleResolution = null; for (int i = 0; i < attributes_count ; i++) { @@ -245,7 +249,7 @@ public final class ModuleInfo { break; case MODULE_PACKAGES : - packages = readModulePackagesAttribute(in, cpool); + allPackages = readModulePackagesAttribute(in, cpool); break; case MODULE_MAIN_CLASS : @@ -253,12 +257,12 @@ public final class ModuleInfo { break; case MODULE_TARGET : - osValues = readModuleTargetAttribute(in, cpool); + moduleTarget = readModuleTargetAttribute(in, cpool); break; case MODULE_HASHES : if (parseHashes) { - hashes = readModuleHashesAttribute(in, cpool); + moduelHashes = readModuleHashesAttribute(in, cpool); } else { in.skipBytes(length); } @@ -284,55 +288,46 @@ public final class ModuleInfo { throw invalidModuleDescriptor(MODULE + " attribute not found"); } + // ModuleMainClass attribute + if (mainClass != null) { + builder.mainClass(mainClass); + } + // If the ModulePackages attribute is not present then the packageFinder // is used to find the set of packages boolean usedPackageFinder = false; - if (packages == null && packageFinder != null) { + if (allPackages == null && packageFinder != null) { try { - packages = new HashSet<>(packageFinder.get()); + allPackages = packageFinder.get(); } catch (UncheckedIOException x) { throw x.getCause(); } usedPackageFinder = true; } - if (packages != null) { - Set exportedPackages = JLMA.exportedPackages(builder); - Set openPackages = JLMA.openPackages(builder); - if (packages.containsAll(exportedPackages) - && packages.containsAll(openPackages)) { - packages.removeAll(exportedPackages); - packages.removeAll(openPackages); - } else { - // the set of packages is not complete - Set exportedAndOpenPackages = new HashSet<>(); - exportedAndOpenPackages.addAll(exportedPackages); - exportedAndOpenPackages.addAll(openPackages); - for (String pn : exportedAndOpenPackages) { - if (!packages.contains(pn)) { - String tail; - if (usedPackageFinder) { - tail = " not found by package finder"; - } else { - tail = " missing from ModulePackages attribute"; - } - throw invalidModuleDescriptor("Package " + pn + tail); - } + if (allPackages != null) { + Set knownPackages = JLMA.packages(builder); + if (!allPackages.containsAll(knownPackages)) { + Set missingPackages = new HashSet<>(knownPackages); + missingPackages.removeAll(allPackages); + assert !missingPackages.isEmpty(); + String missingPackage = missingPackages.iterator().next(); + String tail; + if (usedPackageFinder) { + tail = " not found in module"; + } else { + tail = " missing from ModulePackages class file attribute"; } - assert false; // should not get here - } - builder.contains(packages); - } + throw invalidModuleDescriptor("Package " + missingPackage + tail); - if (mainClass != null) - builder.mainClass(mainClass); - if (osValues != null) { - if (osValues[0] != null) builder.osName(osValues[0]); - if (osValues[1] != null) builder.osArch(osValues[1]); - if (osValues[2] != null) builder.osVersion(osValues[2]); + } + builder.packages(allPackages); } ModuleDescriptor descriptor = builder.build(); - return new Attributes(descriptor, hashes, moduleResolution); + return new Attributes(descriptor, + moduleTarget, + moduelHashes, + moduleResolution); } /** @@ -347,10 +342,17 @@ public final class ModuleInfo { String mn = cpool.getModuleName(module_name_index); int module_flags = in.readUnsignedShort(); - boolean open = ((module_flags & ACC_OPEN) != 0); - boolean synthetic = ((module_flags & ACC_SYNTHETIC) != 0); - Builder builder = JLMA.newModuleBuilder(mn, false, open, synthetic); + Set modifiers = new HashSet<>(); + boolean open = ((module_flags & ACC_OPEN) != 0); + if (open) + modifiers.add(ModuleDescriptor.Modifier.OPEN); + if ((module_flags & ACC_SYNTHETIC) != 0) + modifiers.add(ModuleDescriptor.Modifier.SYNTHETIC); + if ((module_flags & ACC_MANDATED) != 0) + modifiers.add(ModuleDescriptor.Modifier.MANDATED); + + Builder builder = JLMA.newModuleBuilder(mn, false, modifiers); int module_version_index = in.readUnsignedShort(); if (module_version_index != 0) { @@ -381,16 +383,11 @@ public final class ModuleInfo { } int requires_version_index = in.readUnsignedShort(); - Version compiledVersion = null; - if (requires_version_index != 0) { - String vs = cpool.getUtf8(requires_version_index); - compiledVersion = Version.parse(vs); - } - - if (compiledVersion == null) { + if (requires_version_index == 0) { builder.requires(mods, dn); } else { - builder.requires(mods, dn, compiledVersion); + String vs = cpool.getUtf8(requires_version_index); + JLMA.requires(builder, mods, dn, vs); } if (dn.equals("java.base")) @@ -429,7 +426,11 @@ public final class ModuleInfo { Set targets = new HashSet<>(exports_to_count); for (int j=0; j targets = new HashSet<>(open_to_count); for (int j=0; j notAllowed = predefinedNotAllowed; @@ -640,6 +635,7 @@ public final class ModuleInfo { notAllowed = Set.of( "ConstantValue", "Code", + "Deprecated", "StackMapTable", "Exceptions", "EnclosingMethod", diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java index 0d05ad296e9..270d0a2605f 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java @@ -56,16 +56,14 @@ public final class ModuleInfoExtender { // the packages in the ModulePackages attribute private Set packages; - // the value of the module_version in Module attribute + // the value for the module version in the Module attribute private Version version; // the value of the ModuleMainClass attribute private String mainClass; - // the values for the ModuleTarget attribute - private String osName; - private String osArch; - private String osVersion; + // the value for the ModuleTarget attribute + private String targetPlatform; // the hashes for the ModuleHashes attribute private ModuleHashes hashes; @@ -78,7 +76,11 @@ public final class ModuleInfoExtender { } /** - * Sets the set of packages for the ModulePackages attribute + * Sets the packages for the ModulePackages attribute + * + * @apiNote This method does not check that the package names are legal + * package names or that the set of packages is a super set of the + * packages in the module. */ public ModuleInfoExtender packages(Set packages) { this.packages = Collections.unmodifiableSet(packages); @@ -86,7 +88,7 @@ public final class ModuleInfoExtender { } /** - * Sets the value of the module_version in Module attribute. + * Sets the value for the module version in the Module attribute */ public ModuleInfoExtender version(Version version) { this.version = version; @@ -95,6 +97,9 @@ public final class ModuleInfoExtender { /** * Sets the value of the ModuleMainClass attribute. + * + * @apiNote This method does not check that the main class is a legal + * class name in a named package. */ public ModuleInfoExtender mainClass(String mainClass) { this.mainClass = mainClass; @@ -102,14 +107,10 @@ public final class ModuleInfoExtender { } /** - * Sets the values for the ModuleTarget attribute. + * Sets the value for the ModuleTarget attribute. */ - public ModuleInfoExtender targetPlatform(String osName, - String osArch, - String osVersion) { - this.osName = osName; - this.osArch = osArch; - this.osVersion = osVersion; + public ModuleInfoExtender targetPlatform(String targetPlatform) { + this.targetPlatform = targetPlatform; return this; } @@ -133,7 +134,7 @@ public final class ModuleInfoExtender { /** * A ClassVisitor that supports adding class file attributes. If an - * attribute already exists then the first occurence of the attribute + * attribute already exists then the first occurrence of the attribute * is replaced. */ private static class AttributeAddingClassVisitor extends ClassVisitor { @@ -196,8 +197,8 @@ public final class ModuleInfoExtender { cv.addAttribute(new ModulePackagesAttribute(packages)); if (mainClass != null) cv.addAttribute(new ModuleMainClassAttribute(mainClass)); - if (osName != null || osArch != null || osVersion != null) - cv.addAttribute(new ModuleTargetAttribute(osName, osArch, osVersion)); + if (targetPlatform != null) + cv.addAttribute(new ModuleTargetAttribute(targetPlatform)); if (hashes != null) cv.addAttribute(new ModuleHashesAttribute(hashes)); if (moduleResolution != null) diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java index 5a17442106c..dded95fe93d 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.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 @@ -48,7 +48,7 @@ public final class ModuleInfoWriter { * Writes the given module descriptor to a module-info.class file, * returning it in a byte array. */ - private static byte[] toModuleInfo(ModuleDescriptor md) { + private static byte[] toModuleInfo(ModuleDescriptor md, ModuleTarget target) { ClassWriter cw = new ClassWriter(0); cw.visit(Opcodes.V1_9, ACC_MODULE, "module-info", null, null, null); cw.visitAttribute(new ModuleAttribute(md)); @@ -66,18 +66,28 @@ public final class ModuleInfoWriter { // write ModuleMainClass if the module has a main class md.mainClass().ifPresent(mc -> cw.visitAttribute(new ModuleMainClassAttribute(mc))); - // write ModuleTarget attribute if have any of OS name/arch/version - String osName = md.osName().orElse(null); - String osArch = md.osArch().orElse(null); - String osVersion = md.osVersion().orElse(null); - if (osName != null || osArch != null || osVersion != null) { - cw.visitAttribute(new ModuleTargetAttribute(osName, osArch, osVersion)); + // write ModuleTarget if there is a target platform + if (target != null) { + cw.visitAttribute(new ModuleTargetAttribute(target.targetPlatform())); } cw.visitEnd(); return cw.toByteArray(); } + /** + * Writes a module descriptor to the given output stream as a + * module-info.class. + */ + public static void write(ModuleDescriptor descriptor, + ModuleTarget target, + OutputStream out) + throws IOException + { + byte[] bytes = toModuleInfo(descriptor, target); + out.write(bytes); + } + /** * Writes a module descriptor to the given output stream as a * module-info.class. @@ -85,8 +95,7 @@ public final class ModuleInfoWriter { public static void write(ModuleDescriptor descriptor, OutputStream out) throws IOException { - byte[] bytes = toModuleInfo(descriptor); - out.write(bytes); + write(descriptor, null, out); } /** @@ -94,8 +103,7 @@ public final class ModuleInfoWriter { * in module-info.class format. */ public static ByteBuffer toByteBuffer(ModuleDescriptor descriptor) { - byte[] bytes = toModuleInfo(descriptor); + byte[] bytes = toModuleInfo(descriptor, null); return ByteBuffer.wrap(bytes); } - } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java index 9c3308f97a0..b0f465d4776 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.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 @@ -37,39 +37,66 @@ import jdk.internal.loader.ClassLoaders; /** - * The module to class loader map. The list of boot modules and platform modules - * are generated at build time. + * Supports the mapping of modules to class loaders. The set of modules mapped + * to the boot and platform class loaders is generated at build time from + * this source file. */ -final class ModuleLoaderMap { - /* - * The list of boot modules and platform modules are generated at build time. +public final class ModuleLoaderMap { + + /** + * Maps the system modules to the built-in class loaders. */ - private static final String[] BOOT_MODULES - = new String[] { "@@BOOT_MODULE_NAMES@@" }; - private static final String[] PLATFORM_MODULES - = new String[] { "@@PLATFORM_MODULE_NAMES@@" }; + public static final class Mapper implements Function { + private final Map map; + + Mapper(Map map) { + this.map = map; // defensive copy not needed + } + + @Override + public ClassLoader apply(String name) { + return map.get(name); + } + } + + /** + * Returns the names of the modules defined to the boot loader. + */ + public static Set bootModules() { + // The list of boot modules generated at build time. + String[] BOOT_MODULES = new String[] { "@@BOOT_MODULE_NAMES@@" }; + Set bootModules = new HashSet<>(BOOT_MODULES.length); + for (String mn : BOOT_MODULES) { + bootModules.add(mn); + } + return bootModules; + } + + /** + * Returns the names of the modules defined to the platform loader. + */ + public static Set platformModules() { + // The list of platform modules generated at build time. + String[] PLATFORM_MODULES = new String[] { "@@PLATFORM_MODULE_NAMES@@" }; + Set platformModules = new HashSet<>(PLATFORM_MODULES.length); + for (String mn : PLATFORM_MODULES) { + platformModules.add(mn); + } + return platformModules; + } /** * Returns the function to map modules in the given configuration to the * built-in class loaders. */ static Function mappingFunction(Configuration cf) { - - Set bootModules = new HashSet<>(BOOT_MODULES.length); - for (String mn : BOOT_MODULES) { - bootModules.add(mn); - } - - Set platformModules = new HashSet<>(PLATFORM_MODULES.length); - for (String mn : PLATFORM_MODULES) { - platformModules.add(mn); - } + Set bootModules = bootModules(); + Set platformModules = platformModules(); ClassLoader platformClassLoader = ClassLoaders.platformClassLoader(); ClassLoader appClassLoader = ClassLoaders.appClassLoader(); Map map = new HashMap<>(); - for (ResolvedModule resolvedModule : cf.modules()) { String mn = resolvedModule.name(); if (!bootModules.contains(mn)) { @@ -80,12 +107,6 @@ final class ModuleLoaderMap { } } } - - return new Function () { - @Override - public ClassLoader apply(String mn) { - return map.get(mn); - } - }; + return new Mapper(map); } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java index 5bd7ef5ed04..c0458e0f34e 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.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 @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleDescriptor.Builder; import java.lang.module.ModuleReader; import java.lang.module.ModuleReference; import java.net.MalformedURLException; @@ -108,18 +109,23 @@ public final class ModulePatcher { if (paths == null) return mref; - // scan the JAR file or directory tree to get the set of packages + // Scan the JAR file or directory tree to get the set of packages. + // For automatic modules then packages that do not contain class files + // must be ignored. Set packages = new HashSet<>(); + boolean isAutomatic = descriptor.isAutomatic(); try { for (Path file : paths) { if (Files.isRegularFile(file)) { // JAR file - do not open as a multi-release JAR as this // is not supported by the boot class loader - try (JarFile jf = new JarFile(file.toFile())) { + try (JarFile jf = new JarFile(file.toString())) { jf.stream() + .filter(e -> !e.isDirectory() + && (!isAutomatic || e.getName().endsWith(".class"))) .map(e -> toPackageName(file, e)) - .filter(Checks::isJavaIdentifier) + .filter(Checks::isPackageName) .forEach(packages::add); } @@ -129,8 +135,11 @@ public final class ModulePatcher { Path top = file; Files.find(top, Integer.MAX_VALUE, ((path, attrs) -> attrs.isRegularFile())) + .filter(path -> (!isAutomatic + || path.toString().endsWith(".class")) + && !isHidden(path)) .map(path -> toPackageName(top, path)) - .filter(Checks::isJavaIdentifier) + .filter(Checks::isPackageName) .forEach(packages::add); } @@ -141,20 +150,41 @@ public final class ModulePatcher { } // if there are new packages then we need a new ModuleDescriptor - Set original = descriptor.packages(); - packages.addAll(original); - if (packages.size() > original.size()) { - descriptor = JLMA.newModuleDescriptor(descriptor, packages); + packages.removeAll(descriptor.packages()); + if (!packages.isEmpty()) { + Builder builder = JLMA.newModuleBuilder(descriptor.name(), + /*strict*/ false, + descriptor.modifiers()); + if (!descriptor.isAutomatic()) { + descriptor.requires().forEach(builder::requires); + descriptor.exports().forEach(builder::exports); + descriptor.opens().forEach(builder::opens); + descriptor.uses().forEach(builder::uses); + } + descriptor.provides().forEach(builder::provides); + + descriptor.version().ifPresent(builder::version); + descriptor.mainClass().ifPresent(builder::mainClass); + + // original + new packages + builder.packages(descriptor.packages()); + builder.packages(packages); + + descriptor = builder.build(); } // return a module reference to the patched module URI location = mref.location().orElse(null); + ModuleTarget target = null; ModuleHashes recordedHashes = null; + ModuleHashes.HashSupplier hasher = null; ModuleResolution mres = null; if (mref instanceof ModuleReferenceImpl) { ModuleReferenceImpl impl = (ModuleReferenceImpl)mref; + target = impl.moduleTarget(); recordedHashes = impl.recordedHashes(); + hasher = impl.hasher(); mres = impl.moduleResolution(); } @@ -162,8 +192,9 @@ public final class ModulePatcher { location, () -> new PatchedModuleReader(paths, mref), this, + target, recordedHashes, - null, + hasher, mres); } @@ -197,7 +228,7 @@ public final class ModulePatcher { private volatile ModuleReader delegate; /** - * Creates the ModuleReader to reads resources a patched module. + * Creates the ModuleReader to reads resources in a patched module. */ PatchedModuleReader(List patches, ModuleReference mref) { List finders = new ArrayList<>(); @@ -262,13 +293,16 @@ public final class ModulePatcher { } /** - * Finds a resources in the patch locations. Returns null if not found. + * Finds a resources in the patch locations. Returns null if not found + * or the name is "module-info.class" as that cannot be overridden. */ private Resource findResourceInPatch(String name) throws IOException { - for (ResourceFinder finder : finders) { - Resource r = finder.find(name); - if (r != null) - return r; + if (!name.equals("module-info.class")) { + for (ResourceFinder finder : finders) { + Resource r = finder.find(name); + if (r != null) + return r; + } } return null; } @@ -397,7 +431,7 @@ public final class ModulePatcher { private final URL csURL; JarResourceFinder(Path path) throws IOException { - this.jf = new JarFile(path.toFile()); + this.jf = new JarFile(path.toString()); this.csURL = path.toUri().toURL(); } @@ -449,9 +483,7 @@ public final class ModulePatcher { @Override public Stream list() throws IOException { - return jf.stream() - .filter(e -> !e.isDirectory()) - .map(JarEntry::getName); + return jf.stream().map(JarEntry::getName); } } @@ -471,19 +503,8 @@ public final class ModulePatcher { @Override public Resource find(String name) throws IOException { - Path file = Paths.get(name.replace('/', File.separatorChar)); - if (file.getRoot() == null) { - file = dir.resolve(file); - } else { - // drop the root component so that the resource is - // located relative to the module directory - int n = file.getNameCount(); - if (n == 0) - return null; - file = dir.resolve(file.subpath(0, n)); - } - - if (Files.isRegularFile(file)) { + Path file = Resources.toFilePath(dir, name); + if (file != null) { return newResource(name, dir, file); } else { return null; @@ -530,17 +551,15 @@ public final class ModulePatcher { @Override public Stream list() throws IOException { - return Files.find(dir, Integer.MAX_VALUE, - (path, attrs) -> attrs.isRegularFile()) - .map(f -> dir.relativize(f) - .toString() - .replace(File.separatorChar, '/')); + return Files.walk(dir, Integer.MAX_VALUE) + .map(f -> Resources.toResourceName(dir, f)) + .filter(s -> s.length() > 0); } } /** - * Derives a package name from a file path to a .class file. + * Derives a package name from the file path of an entry in an exploded patch */ private static String toPackageName(Path top, Path file) { Path entry = top.relativize(file); @@ -552,6 +571,17 @@ public final class ModulePatcher { } } + /** + * Returns true if the given file exists and is a hidden file + */ + private boolean isHidden(Path file) { + try { + return Files.isHidden(file); + } catch (IOException ioe) { + return false; + } + } + /** * Derives a package name from the name of an entry in a JAR file. */ diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java index fb7871d3c31..750ac801fe3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.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 @@ -35,7 +35,6 @@ import java.io.UncheckedIOException; import java.lang.module.FindException; import java.lang.module.InvalidModuleDescriptorException; import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleDescriptor.Requires; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReference; import java.net.URI; @@ -60,6 +59,7 @@ import java.util.jar.Manifest; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.zip.ZipException; import java.util.zip.ZipFile; import jdk.internal.jmod.JmodFile; @@ -70,12 +70,11 @@ import jdk.internal.util.jar.VersionedStream; /** * A {@code ModuleFinder} that locates modules on the file system by searching - * a sequence of directories or packaged modules. - * - * The {@code ModuleFinder} can be created to work in either the run-time - * or link-time phases. In both cases it locates modular JAR and exploded - * modules. When created for link-time then it additionally locates - * modules in JMOD files. + * a sequence of directories or packaged modules. The ModuleFinder can be + * created to work in either the run-time or link-time phases. In both cases it + * locates modular JAR and exploded modules. When created for link-time then it + * additionally locates modules in JMOD files. The ModuleFinder can also + * optionally patch any modules that it locates with a ModulePatcher. */ public class ModulePath implements ModuleFinder { @@ -87,6 +86,9 @@ public class ModulePath implements ModuleFinder { // true for the link phase (supports modules packaged in JMOD format) private final boolean isLinkPhase; + // for patching modules, can be null + private final ModulePatcher patcher; + // the entries on this module path private final Path[] entries; private int next; @@ -94,19 +96,51 @@ public class ModulePath implements ModuleFinder { // map of module name to module reference map for modules already located private final Map cachedModules = new HashMap<>(); - public ModulePath(Runtime.Version version, boolean isLinkPhase, Path... entries) { + + private ModulePath(Runtime.Version version, + boolean isLinkPhase, + ModulePatcher patcher, + Path... entries) { this.releaseVersion = version; this.isLinkPhase = isLinkPhase; + this.patcher = patcher; this.entries = entries.clone(); for (Path entry : this.entries) { Objects.requireNonNull(entry); } } - public ModulePath(Path... entries) { - this(JarFile.runtimeVersion(), false, entries); + /** + * Returns a ModuleFinder that that locates modules on the file system by + * searching a sequence of directories and/or packaged modules. The modules + * may be patched by the given ModulePatcher. + */ + public static ModuleFinder of(ModulePatcher patcher, Path... entries) { + return new ModulePath(JarFile.runtimeVersion(), false, patcher, entries); } + /** + * Returns a ModuleFinder that that locates modules on the file system by + * searching a sequence of directories and/or packaged modules. + */ + public static ModuleFinder of(Path... entries) { + return of((ModulePatcher)null, entries); + } + + /** + * Returns a ModuleFinder that that locates modules on the file system by + * searching a sequence of directories and/or packaged modules. + * + * @param version The release version to use for multi-release JAR files + * @param isLinkPhase {@code true} if the link phase to locate JMOD files + */ + public static ModuleFinder of(Runtime.Version version, + boolean isLinkPhase, + Path... entries) { + return new ModulePath(version, isLinkPhase, null, entries); + } + + @Override public Optional find(String name) { Objects.requireNonNull(name); @@ -195,8 +229,7 @@ public class ModulePath implements ModuleFinder { if (attrs.isDirectory()) { Path mi = entry.resolve(MODULE_INFO); if (!Files.exists(mi)) { - // does not exist or unable to determine so assume a - // directory of modules + // assume a directory of modules return scanDirectory(entry); } } @@ -206,11 +239,17 @@ public class ModulePath implements ModuleFinder { if (mref != null) { String name = mref.descriptor().name(); return Collections.singletonMap(name, mref); - } else { - // skipped - return Collections.emptyMap(); } + // not recognized + String msg; + if (!isLinkPhase && entry.toString().endsWith(".jmod")) { + msg = "JMOD format not supported at execution time"; + } else { + msg = "Module format not recognized"; + } + throw new FindException(msg + ": " + entry); + } catch (IOException ioe) { throw new FindException(ioe); } @@ -266,48 +305,53 @@ public class ModulePath implements ModuleFinder { /** - * Locates a packaged or exploded module, returning a {@code ModuleReference} - * to the module. Returns {@code null} if the entry is skipped because it is - * to a directory that does not contain a module-info.class or it's a hidden - * file. + * Reads a packaged or exploded module, returning a {@code ModuleReference} + * to the module. Returns {@code null} if the entry is not recognized. * * @throws IOException if an I/O error occurs - * @throws FindException if the file is not recognized as a module or an - * error occurs parsing its module descriptor + * @throws FindException if an error occurs parsing its module descriptor */ private ModuleReference readModule(Path entry, BasicFileAttributes attrs) throws IOException { try { + // exploded module if (attrs.isDirectory()) { return readExplodedModule(entry); // may return null } - String fn = entry.getFileName().toString(); + // JAR or JMOD file if (attrs.isRegularFile()) { + String fn = entry.getFileName().toString(); + boolean isDefaultFileSystem = isDefaultFileSystem(entry); + + // JAR file if (fn.endsWith(".jar")) { - return readJar(entry); - } else if (fn.endsWith(".jmod")) { - if (isLinkPhase) - return readJMod(entry); - throw new FindException("JMOD files not supported: " + entry); + if (isDefaultFileSystem) { + return readJar(entry); + } else { + // the JAR file is in a custom file system so + // need to copy it to the local file system + Path tmpdir = Files.createTempDirectory("mlib"); + Path target = Files.copy(entry, tmpdir.resolve(fn)); + return readJar(target); + } + } + + // JMOD file + if (isDefaultFileSystem && isLinkPhase && fn.endsWith(".jmod")) { + return readJMod(entry); } } - // skip hidden files - if (fn.startsWith(".") || Files.isHidden(entry)) { - return null; - } else { - throw new FindException("Unrecognized module: " + entry); - } + return null; } catch (InvalidModuleDescriptorException e) { throw new FindException("Error reading module: " + entry, e); } } - /** * Returns a string with the file name of the module if possible. * If the module location is not a file URI then return the URI @@ -327,7 +371,7 @@ public class ModulePath implements ModuleFinder { } } - // -- jmod files -- + // -- JMOD files -- private Set jmodPackages(JmodFile jf) { return jf.stream() @@ -339,7 +383,7 @@ public class ModulePath implements ModuleFinder { } /** - * Returns a {@code ModuleReference} to a module in jmod file on the + * Returns a {@code ModuleReference} to a module in JMOD file on the * file system. * * @throws IOException @@ -362,7 +406,7 @@ public class ModulePath implements ModuleFinder { /** * Returns the service type corresponding to the name of a services - * configuration file if it is a valid Java identifier. + * configuration file if it is a legal type name. * * For example, if called with "META-INF/services/p.S" then this method * returns a container with the value "p.S". @@ -374,7 +418,7 @@ public class ModulePath implements ModuleFinder { String prefix = cf.substring(0, index); if (prefix.equals(SERVICES_PREFIX)) { String sn = cf.substring(index); - if (Checks.isJavaIdentifier(sn)) + if (Checks.isClassName(sn)) return Optional.of(sn); } } @@ -403,12 +447,11 @@ public class ModulePath implements ModuleFinder { * * 1. The module name (and optionally the version) is derived from the file * name of the JAR file - * 2. All packages are exported and open - * 3. It has no non-exported/non-open packages - * 4. The contents of any META-INF/services configuration files are mapped + * 2. All packages are derived from the .class files in the JAR file + * 3. The contents of any META-INF/services configuration files are mapped * to "provides" declarations - * 5. The Main-Class attribute in the main attributes of the JAR manifest - * is mapped to the module descriptor mainClass + * 4. The Main-Class attribute in the main attributes of the JAR manifest + * is mapped to the module descriptor mainClass if possible */ private ModuleDescriptor deriveModuleDescriptor(JarFile jf) throws IOException @@ -443,9 +486,7 @@ public class ModulePath implements ModuleFinder { mn = cleanModuleName(mn); // Builder throws IAE if module name is empty or invalid - ModuleDescriptor.Builder builder - = ModuleDescriptor.automaticModule(mn) - .requires(Set.of(Requires.Modifier.MANDATED), "java.base"); + ModuleDescriptor.Builder builder = ModuleDescriptor.newAutomaticModule(mn); if (vs != null) builder.version(vs); @@ -453,17 +494,22 @@ public class ModulePath implements ModuleFinder { Map> map = VersionedStream.stream(jf) .filter(e -> !e.isDirectory()) .map(JarEntry::getName) + .filter(e -> (e.endsWith(".class") ^ e.startsWith(SERVICES_PREFIX))) .collect(Collectors.partitioningBy(e -> e.startsWith(SERVICES_PREFIX), Collectors.toSet())); - Set resources = map.get(Boolean.FALSE); + Set classFiles = map.get(Boolean.FALSE); Set configFiles = map.get(Boolean.TRUE); - // all packages are exported and open - resources.stream() + + // the packages containing class files + Set packages = classFiles.stream() .map(this::toPackageName) .flatMap(Optional::stream) .distinct() - .forEach(pn -> builder.exports(pn).opens(pn)); + .collect(Collectors.toSet()); + + // all packages are exported and open + builder.packages(packages); // map names of service configuration files to service names Set serviceNames = configFiles.stream() @@ -481,6 +527,11 @@ public class ModulePath implements ModuleFinder { String cn; while ((cn = nextLine(reader)) != null) { if (cn.length() > 0) { + String pn = packageName(cn); + if (!packages.contains(pn)) { + String msg = "Provider class " + cn + " not in module"; + throw new InvalidModuleDescriptorException(msg); + } providerClasses.add(cn); } } @@ -494,8 +545,15 @@ public class ModulePath implements ModuleFinder { if (man != null) { Attributes attrs = man.getMainAttributes(); String mainClass = attrs.getValue(Attributes.Name.MAIN_CLASS); - if (mainClass != null) - builder.mainClass(mainClass.replace("/", ".")); + if (mainClass != null) { + mainClass = mainClass.replace("/", "."); + if (Checks.isClassName(mainClass)) { + String pn = packageName(mainClass); + if (packages.contains(pn)) { + builder.mainClass(mainClass); + } + } + } } return builder.build(); @@ -506,7 +564,6 @@ public class ModulePath implements ModuleFinder { */ private static class Patterns { static final Pattern DASH_VERSION = Pattern.compile("-(\\d+(\\.|$))"); - static final Pattern TRAILING_VERSION = Pattern.compile("(\\.|\\d)*$"); static final Pattern NON_ALPHANUM = Pattern.compile("[^A-Za-z0-9]"); static final Pattern REPEATING_DOTS = Pattern.compile("(\\.)(\\1)+"); static final Pattern LEADING_DOTS = Pattern.compile("^\\."); @@ -517,9 +574,6 @@ public class ModulePath implements ModuleFinder { * Clean up candidate module name derived from a JAR file name. */ private static String cleanModuleName(String mn) { - // drop trailing version from name - mn = Patterns.TRAILING_VERSION.matcher(mn).replaceAll(""); - // replace non-alphanumeric mn = Patterns.NON_ALPHANUM.matcher(mn).replaceAll("."); @@ -568,11 +622,10 @@ public class ModulePath implements ModuleFinder { // no module-info.class so treat it as automatic module try { ModuleDescriptor md = deriveModuleDescriptor(jf); - attrs = new ModuleInfo.Attributes(md, null, null); - } catch (IllegalArgumentException iae) { - throw new FindException( - "Unable to derive module descriptor for: " - + jf.getName(), iae); + attrs = new ModuleInfo.Attributes(md, null, null, null); + } catch (RuntimeException e) { + throw new FindException("Unable to derive module descriptor for " + + jf.getName(), e); } } else { @@ -580,7 +633,9 @@ public class ModulePath implements ModuleFinder { () -> jarPackages(jf)); } - return ModuleReferences.newJarModule(attrs, file); + return ModuleReferences.newJarModule(attrs, patcher, file); + } catch (ZipException e) { + throw new FindException("Error reading " + file, e); } } @@ -590,7 +645,7 @@ public class ModulePath implements ModuleFinder { private Set explodedPackages(Path dir) { try { return Files.find(dir, Integer.MAX_VALUE, - ((path, attrs) -> attrs.isRegularFile())) + ((path, attrs) -> attrs.isRegularFile() && !isHidden(path))) .map(path -> dir.relativize(path)) .map(this::toPackageName) .flatMap(Optional::stream) @@ -617,31 +672,38 @@ public class ModulePath implements ModuleFinder { // for now return null; } - return ModuleReferences.newExplodedModule(attrs, dir); + return ModuleReferences.newExplodedModule(attrs, patcher, dir); + } + + /** + * Maps a type name to its package name. + */ + private static String packageName(String cn) { + int index = cn.lastIndexOf('.'); + return (index == -1) ? "" : cn.substring(0, index); } /** * Maps the name of an entry in a JAR or ZIP file to a package name. * - * @throws IllegalArgumentException if the name is a class file in - * the top-level directory of the JAR/ZIP file (and it's - * not module-info.class) + * @throws InvalidModuleDescriptorException if the name is a class file in + * the top-level directory of the JAR/ZIP file (and it's not + * module-info.class) */ private Optional toPackageName(String name) { assert !name.endsWith("/"); - int index = name.lastIndexOf("/"); if (index == -1) { if (name.endsWith(".class") && !name.equals(MODULE_INFO)) { - throw new IllegalArgumentException(name - + " found in top-level directory:" - + " (unnamed package not allowed in module)"); + String msg = name + " found in top-level directory" + + " (unnamed package not allowed in module)"; + throw new InvalidModuleDescriptorException(msg); } return Optional.empty(); } String pn = name.substring(0, index).replace('/', '.'); - if (Checks.isJavaIdentifier(pn)) { + if (Checks.isPackageName(pn)) { return Optional.of(pn); } else { // not a valid package name @@ -653,7 +715,7 @@ public class ModulePath implements ModuleFinder { * Maps the relative path of an entry in an exploded module to a package * name. * - * @throws IllegalArgumentException if the name is a class file in + * @throws InvalidModuleDescriptorException if the name is a class file in * the top-level directory (and it's not module-info.class) */ private Optional toPackageName(Path file) { @@ -663,15 +725,15 @@ public class ModulePath implements ModuleFinder { if (parent == null) { String name = file.toString(); if (name.endsWith(".class") && !name.equals(MODULE_INFO)) { - throw new IllegalArgumentException(name - + " found in in top-level directory" - + " (unnamed package not allowed in module)"); + String msg = name + " found in top-level directory" + + " (unnamed package not allowed in module)"; + throw new InvalidModuleDescriptorException(msg); } return Optional.empty(); } String pn = parent.toString().replace(File.separatorChar, '.'); - if (Checks.isJavaIdentifier(pn)) { + if (Checks.isPackageName(pn)) { return Optional.of(pn); } else { // not a valid package name @@ -679,6 +741,27 @@ public class ModulePath implements ModuleFinder { } } + /** + * Returns true if the given file exists and is a hidden file + */ + private boolean isHidden(Path file) { + try { + return Files.isHidden(file); + } catch (IOException ioe) { + return false; + } + } + + + /** + * Return true if a path locates a path in the default file system + */ + private boolean isDefaultFileSystem(Path path) { + return path.getFileSystem().provider() + .getScheme().equalsIgnoreCase("file"); + } + + private static final PerfCounter scanTime = PerfCounter.newPerfCounter("jdk.module.finder.modulepath.scanTime"); private static final PerfCounter moduleCount diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferenceImpl.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferenceImpl.java index 2ab42bdb4a2..002930907ba 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferenceImpl.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferenceImpl.java @@ -46,6 +46,9 @@ public class ModuleReferenceImpl extends ModuleReference { // non-null if the module is patched private final ModulePatcher patcher; + // ModuleTarget if the module is OS/architecture specific + private final ModuleTarget target; + // the hashes of other modules recorded in this module private final ModuleHashes recordedHashes; @@ -65,6 +68,7 @@ public class ModuleReferenceImpl extends ModuleReference { URI location, Supplier readerSupplier, ModulePatcher patcher, + ModuleTarget target, ModuleHashes recordedHashes, ModuleHashes.HashSupplier hasher, ModuleResolution moduleResolution) @@ -72,6 +76,7 @@ public class ModuleReferenceImpl extends ModuleReference { super(descriptor, Objects.requireNonNull(location)); this.readerSupplier = readerSupplier; this.patcher = patcher; + this.target = target; this.recordedHashes = recordedHashes; this.hasher = hasher; this.moduleResolution = moduleResolution; @@ -93,6 +98,13 @@ public class ModuleReferenceImpl extends ModuleReference { return (patcher != null); } + /** + * Returns the ModuleTarget or {@code null} if the no target platform. + */ + public ModuleTarget moduleTarget() { + return target; + } + /** * Returns the hashes recorded in this module or {@code null} if there * are no hashes recorded. @@ -163,7 +175,14 @@ public class ModuleReferenceImpl extends ModuleReference { @Override public String toString() { - return super.toString(); + StringBuilder sb = new StringBuilder(); + sb.append("[module "); + sb.append(descriptor().name()); + sb.append(", location="); + sb.append(location().orElseThrow(() -> new InternalError())); + if (isPatched()) sb.append(" (patched)"); + sb.append("]"); + return sb.toString(); } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java index a2aff8f76be..938c446b6c7 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java @@ -36,7 +36,6 @@ import java.net.URI; import java.nio.ByteBuffer; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -51,7 +50,6 @@ import java.util.stream.Stream; import java.util.zip.ZipFile; import jdk.internal.jmod.JmodFile; -import jdk.internal.misc.JavaLangAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.module.ModuleHashes.HashSupplier; import jdk.internal.util.jar.VersionedStream; @@ -65,59 +63,60 @@ import sun.net.www.ParseUtil; */ class ModuleReferences { - - private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); - private ModuleReferences() { } /** - * Creates a ModuleReference to a module or to patched module when - * creating modules for the boot Layer and --patch-module is specified. + * Creates a ModuleReference to a possibly-patched module */ private static ModuleReference newModule(ModuleInfo.Attributes attrs, URI uri, Supplier supplier, + ModulePatcher patcher, HashSupplier hasher) { - ModuleReference mref = new ModuleReferenceImpl(attrs.descriptor(), uri, supplier, null, + attrs.target(), attrs.recordedHashes(), hasher, attrs.moduleResolution()); - if (JLA.getBootLayer() == null) - mref = ModuleBootstrap.patcher().patchIfNeeded(mref); + if (patcher != null) + mref = patcher.patchIfNeeded(mref); return mref; } /** - * Creates a ModuleReference to a module packaged as a modular JAR. + * Creates a ModuleReference to a possibly-patched module in a modular JAR. */ - static ModuleReference newJarModule(ModuleInfo.Attributes attrs, Path file) { + static ModuleReference newJarModule(ModuleInfo.Attributes attrs, + ModulePatcher patcher, + Path file) { URI uri = file.toUri(); Supplier supplier = () -> new JarModuleReader(file, uri); HashSupplier hasher = (a) -> ModuleHashes.computeHash(file, a); - return newModule(attrs, uri, supplier, hasher); + return newModule(attrs, uri, supplier, patcher, hasher); } /** - * Creates a ModuleReference to a module packaged as a JMOD. + * Creates a ModuleReference to a module in a JMOD file. */ static ModuleReference newJModModule(ModuleInfo.Attributes attrs, Path file) { URI uri = file.toUri(); Supplier supplier = () -> new JModModuleReader(file, uri); HashSupplier hasher = (a) -> ModuleHashes.computeHash(file, a); - return newModule(attrs, uri, supplier, hasher); + return newModule(attrs, uri, supplier, null, hasher); } /** - * Creates a ModuleReference to an exploded module. + * Creates a ModuleReference to a possibly-patched exploded module. */ - static ModuleReference newExplodedModule(ModuleInfo.Attributes attrs, Path dir) { + static ModuleReference newExplodedModule(ModuleInfo.Attributes attrs, + ModulePatcher patcher, + Path dir) { Supplier supplier = () -> new ExplodedModuleReader(dir); - return newModule(attrs, dir.toUri(), supplier, null); + return newModule(attrs, dir.toUri(), supplier, patcher, null); } @@ -228,8 +227,8 @@ class ModuleReferences { static JarFile newJarFile(Path path) { try { - return new JarFile(path.toFile(), - true, // verify + return new JarFile(new File(path.toString()), + true, // verify ZipFile.OPEN_READ, JarFile.runtimeVersion()); } catch (IOException ioe) { @@ -252,6 +251,8 @@ class ModuleReferences { if (je != null) { if (jf.isMultiRelease()) name = SharedSecrets.javaUtilJarAccess().getRealName(jf, je); + if (je.isDirectory() && !name.endsWith("/")) + name += "/"; String encodedPath = ParseUtil.encodePath(name, false); String uris = "jar:" + uri + "!/" + encodedPath; return Optional.of(URI.create(uris)); @@ -274,7 +275,6 @@ class ModuleReferences { Stream implList() throws IOException { // take snapshot to avoid async close List names = VersionedStream.stream(jf) - .filter(e -> !e.isDirectory()) .map(JarEntry::getName) .collect(Collectors.toList()); return names.stream(); @@ -316,6 +316,8 @@ class ModuleReferences { Optional implFind(String name) { JmodFile.Entry je = getEntry(name); if (je != null) { + if (je.isDirectory() && !name.endsWith("/")) + name += "/"; String encodedPath = ParseUtil.encodePath(name, false); String uris = "jmod:" + uri + "!/" + encodedPath; return Optional.of(URI.create(uris)); @@ -369,21 +371,6 @@ class ModuleReferences { } } - /** - * Returns a Path to access to the given resource. - */ - private Path toPath(String name) { - Path path = Paths.get(name.replace('/', File.separatorChar)); - if (path.getRoot() == null) { - return dir.resolve(path); - } else { - // drop the root component so that the resource is - // located relative to the module directory - int n = path.getNameCount(); - return (n > 0) ? dir.resolve(path.subpath(0, n)) : null; - } - } - /** * Throws IOException if the module reader is closed; */ @@ -394,8 +381,8 @@ class ModuleReferences { @Override public Optional find(String name) throws IOException { ensureOpen(); - Path path = toPath(name); - if (path != null && Files.isRegularFile(path)) { + Path path = Resources.toFilePath(dir, name); + if (path != null) { try { return Optional.of(path.toUri()); } catch (IOError e) { @@ -409,8 +396,8 @@ class ModuleReferences { @Override public Optional open(String name) throws IOException { ensureOpen(); - Path path = toPath(name); - if (path != null && Files.isRegularFile(path)) { + Path path = Resources.toFilePath(dir, name); + if (path != null) { return Optional.of(Files.newInputStream(path)); } else { return Optional.empty(); @@ -420,8 +407,8 @@ class ModuleReferences { @Override public Optional read(String name) throws IOException { ensureOpen(); - Path path = toPath(name); - if (path != null && Files.isRegularFile(path)) { + Path path = Resources.toFilePath(dir, name); + if (path != null) { return Optional.of(ByteBuffer.wrap(Files.readAllBytes(path))); } else { return Optional.empty(); @@ -431,12 +418,9 @@ class ModuleReferences { @Override public Stream list() throws IOException { ensureOpen(); - // sym links not followed - return Files.find(dir, Integer.MAX_VALUE, - (path, attrs) -> attrs.isRegularFile()) - .map(f -> dir.relativize(f) - .toString() - .replace(File.separatorChar, '/')); + return Files.walk(dir, Integer.MAX_VALUE) + .map(f -> Resources.toResourceName(dir, f)) + .filter(s -> s.length() > 0); } @Override diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleResolution.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleResolution.java index 76c42368c63..d8b9d9609a1 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleResolution.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleResolution.java @@ -39,6 +39,10 @@ public final class ModuleResolution { this.value = value; } + public int value() { + return value; + } + public static ModuleResolution empty() { return new ModuleResolution(0); } @@ -74,35 +78,30 @@ public final class ModuleResolution { throw new InternalError("cannot add deprecated for removal to " + value); return new ModuleResolution(value | WARN_DEPRECATED_FOR_REMOVAL); } + public ModuleResolution withIncubating() { if ((value & (WARN_DEPRECATED | WARN_DEPRECATED_FOR_REMOVAL)) != 0) throw new InternalError("cannot add incubating to " + value); return new ModuleResolution(value | WARN_INCUBATING); } - public int value() { - return value; - } - public static boolean doNotResolveByDefault(ModuleReference mref) { // get the DO_NOT_RESOLVE_BY_DEFAULT flag, if any - if (!(mref instanceof ModuleReferenceImpl)) - return false; - - ModuleResolution mres = ((ModuleReferenceImpl)mref).moduleResolution(); - if (mres != null) - return mres.doNotResolveByDefault(); + if (mref instanceof ModuleReferenceImpl) { + ModuleResolution mres = ((ModuleReferenceImpl) mref).moduleResolution(); + if (mres != null) + return mres.doNotResolveByDefault(); + } return false; } public static boolean hasIncubatingWarning(ModuleReference mref) { - if (!(mref instanceof ModuleReferenceImpl)) - return false; - - ModuleResolution mres = ((ModuleReferenceImpl)mref).moduleResolution(); - if (mres != null) - return mres.hasIncubatingWarning(); + if (mref instanceof ModuleReferenceImpl) { + ModuleResolution mres = ((ModuleReferenceImpl) mref).moduleResolution(); + if (mres != null) + return mres.hasIncubatingWarning(); + } return false; } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleTarget.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleTarget.java new file mode 100644 index 00000000000..ffd50704f33 --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleTarget.java @@ -0,0 +1,45 @@ +/* + * 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; + +/** + * Represents the module target. + * + * For now, this is a single value for the target platform, e.g. "linux-x64". + */ +public final class ModuleTarget { + + private final String targetPlatform; + + public ModuleTarget(String targetPlatform) { + this.targetPlatform = targetPlatform; + } + + public String targetPlatform() { + return targetPlatform; + } + +} diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java b/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java index 9f68cfbc421..af784dd944e 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java @@ -25,24 +25,31 @@ package jdk.internal.module; +import java.lang.module.Configuration; import java.lang.module.ModuleDescriptor; -import java.lang.reflect.Layer; -import java.lang.reflect.Module; +import java.lang.module.ModuleFinder; +import java.lang.module.ModuleReference; +import java.lang.module.ResolvedModule; import java.net.URI; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; import jdk.internal.loader.BootLoader; +import jdk.internal.loader.BuiltinClassLoader; import jdk.internal.loader.ClassLoaders; -import jdk.internal.misc.JavaLangReflectModuleAccess; +import jdk.internal.misc.JavaLangAccess; import jdk.internal.misc.SharedSecrets; /** - * A helper class to allow JDK classes create dynamic modules and to update - * modules, exports and the readability graph. It is also invoked by the VM - * to add read edges when agents are instrumenting code that need to link - * to supporting classes. + * A helper class for creating and updating modules. This class is intended to + * support command-line options, tests, and the instrumentation API. It is also + * used by the VM to load modules or add read edges when agents are instrumenting + * code that need to link to supporting classes. * * The parameters that are package names in this API are the fully-qualified * names of the packages as defined in section 6.5.3 of The Java™ @@ -52,8 +59,7 @@ import jdk.internal.misc.SharedSecrets; public class Modules { private Modules() { } - private static final JavaLangReflectModuleAccess JLRMA - = SharedSecrets.getJavaLangReflectModuleAccess(); + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); /** * Creates a new Module. The module has the given ModuleDescriptor and @@ -68,48 +74,37 @@ public class Modules { ModuleDescriptor descriptor, URI uri) { - return JLRMA.defineModule(loader, descriptor, uri); + return JLA.defineModule(loader, descriptor, uri); } /** - * Define a new module to the VM. The module has the given set of - * packages and is defined to the given class loader. - * - * The resulting Module is in a larval state in that it does not not read - * any other module and does not have any exports. - */ - public static Module defineModule(ClassLoader loader, - String name, - Set packages) - { - ModuleDescriptor descriptor = ModuleDescriptor.module(name) - .contains(packages) - .build(); - - return JLRMA.defineModule(loader, descriptor, null); - } - - /** - * Adds a read-edge so that module {@code m1} reads module {@code m1}. + * Updates m1 to read m2. * Same as m1.addReads(m2) but without a caller check. */ public static void addReads(Module m1, Module m2) { - JLRMA.addReads(m1, m2); + JLA.addReads(m1, m2); } /** - * Update module {@code m} to read all unnamed modules. + * Update module m to read all unnamed modules. */ public static void addReadsAllUnnamed(Module m) { - JLRMA.addReadsAllUnnamed(m); + JLA.addReadsAllUnnamed(m); } /** * Updates module m1 to export a package to module m2. - * Same as m1.addExports(pn, m2) but without a caller check. + * Same as m1.addExports(pn, m2) but without a caller check */ public static void addExports(Module m1, String pn, Module m2) { - JLRMA.addExports(m1, pn, m2); + JLA.addExports(m1, pn, m2); + } + + /** + * Updates module m to export a package to all unnamed modules. + */ + public static void addExportsToAllUnnamed(Module m, String pn) { + JLA.addExportsToAllUnnamed(m, pn); } /** @@ -117,51 +112,31 @@ public class Modules { * Same as m1.addOpens(pn, m2) but without a caller check. */ public static void addOpens(Module m1, String pn, Module m2) { - JLRMA.addOpens(m1, pn, m2); - } - - /** - * Updates a module m to export a package to all modules. - */ - public static void addExportsToAll(Module m, String pn) { - JLRMA.addExportsToAll(m, pn); - } - - /** - * Updates a module m to open a package to all modules. - */ - public static void addOpensToAll(Module m, String pn) { - JLRMA.addOpensToAll(m, pn); - } - - /** - * Updates module m to export a package to all unnamed modules. - */ - public static void addExportsToAllUnnamed(Module m, String pn) { - JLRMA.addExportsToAllUnnamed(m, pn); + JLA.addOpens(m1, pn, m2); } /** * Updates module m to open a package to all unnamed modules. */ public static void addOpensToAllUnnamed(Module m, String pn) { - JLRMA.addOpensToAllUnnamed(m, pn); + JLA.addOpensToAllUnnamed(m, pn); } /** - * Updates module m to use a service + * Updates module m to use a service. + * Same as m2.addUses(service) but without a caller check. */ public static void addUses(Module m, Class service) { - JLRMA.addUses(m, service); + JLA.addUses(m, service); } /** * Updates module m to provide a service */ public static void addProvides(Module m, Class service, Class impl) { - Layer layer = m.getLayer(); + ModuleLayer layer = m.getLayer(); - if (layer == null || layer == Layer.boot()) { + if (layer == null || layer == ModuleLayer.boot()) { // update ClassLoader catalog PrivilegedAction pa = m::getClassLoader; ClassLoader loader = AccessController.doPrivileged(pa); @@ -176,21 +151,10 @@ public class Modules { if (layer != null) { // update Layer catalog - SharedSecrets.getJavaLangReflectModuleAccess() - .getServicesCatalog(layer) - .addProvider(m, service, impl); + JLA.getServicesCatalog(layer).addProvider(m, service, impl); } } - /** - * Adds a package to a module's content. - * - * This method is a no-op if the module already contains the package. - */ - public static void addPackage(Module m, String pn) { - JLRMA.addPackage(m, pn); - } - /** * Called by the VM when code in the given Module has been transformed by * an agent and so may have been instrumented to call into supporting @@ -200,4 +164,90 @@ public class Modules { addReads(m, BootLoader.getUnnamedModule()); addReads(m, ClassLoaders.appClassLoader().getUnnamedModule()); } + + /** + * Called by the VM to load a system module, typically "java.instrument" or + * "jdk.management.agent". If the module is not loaded then it is resolved + * and loaded (along with any dependences that weren't previously loaded) + * into a child layer. + */ + public static synchronized Module loadModule(String name) { + ModuleLayer top = topLayer; + if (top == null) + top = ModuleLayer.boot(); + + Module module = top.findModule(name).orElse(null); + if (module != null) { + // module already loaded + return module; + } + + // resolve the module with the top-most layer as the parent + ModuleFinder empty = ModuleFinder.of(); + ModuleFinder finder = ModuleBootstrap.unlimitedFinder(); + Set roots = Set.of(name); + Configuration cf = top.configuration().resolveAndBind(empty, finder, roots); + + // create the child layer + Function clf = ModuleLoaderMap.mappingFunction(cf); + ModuleLayer newLayer = top.defineModules(cf, clf); + + // add qualified exports/opens to give access to modules in child layer + Map map = newLayer.modules().stream() + .collect(Collectors.toMap(Module::getName, + Function.identity())); + ModuleLayer layer = top; + while (layer != null) { + for (Module m : layer.modules()) { + // qualified exports + m.getDescriptor().exports().stream() + .filter(ModuleDescriptor.Exports::isQualified) + .forEach(e -> e.targets().forEach(target -> { + Module other = map.get(target); + if (other != null) { + addExports(m, e.source(), other); + }})); + + // qualified opens + m.getDescriptor().opens().stream() + .filter(ModuleDescriptor.Opens::isQualified) + .forEach(o -> o.targets().forEach(target -> { + Module other = map.get(target); + if (other != null) { + addOpens(m, o.source(), other); + }})); + } + + List parents = layer.parents(); + assert parents.size() <= 1; + layer = parents.isEmpty() ? null : parents.get(0); + } + + // update security manager before making types visible + JLA.addNonExportedPackages(newLayer); + + // update the built-in class loaders to make the types visible + for (ResolvedModule resolvedModule : cf.modules()) { + ModuleReference mref = resolvedModule.reference(); + String mn = mref.descriptor().name(); + ClassLoader cl = clf.apply(mn); + if (cl == null) { + BootLoader.loadModule(mref); + } else { + ((BuiltinClassLoader) cl).loadModule(mref); + } + } + + // new top layer + topLayer = newLayer; + + // return module + return newLayer.findModule(name) + .orElseThrow(() -> new InternalError("module not loaded")); + + } + + // the top-most system layer + private static ModuleLayer topLayer; + } diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/Resources.java b/jdk/src/java.base/share/classes/jdk/internal/module/Resources.java new file mode 100644 index 00000000000..53865742dbe --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/module/Resources.java @@ -0,0 +1,167 @@ +/* + * 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. 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.File; +import java.io.IOException; +import java.nio.file.FileSystem; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; + +/** + * A helper class to support working with resources in modules. Also provides + * support for translating resource names to file paths. + */ +public final class Resources { + private Resources() { } + + /** + * Return true if a resource can be encapsulated. Resource with names + * ending in ".class" or "/" cannot be encapsulated. Resource names + * that map to a legal package name can be encapsulated. + */ + public static boolean canEncapsulate(String name) { + int len = name.length(); + if (len > 6 && name.endsWith(".class")) { + return false; + } else { + return Checks.isPackageName(toPackageName(name)); + } + } + + /** + * Derive a package name for a resource. The package name + * returned by this method may not be a legal package name. This method + * returns null if the the resource name ends with a "/" (a directory) + * or the resource name does not contain a "/". + */ + public static String toPackageName(String name) { + int index = name.lastIndexOf('/'); + if (index == -1 || index == name.length()-1) { + return ""; + } else { + return name.substring(0, index).replace("/", "."); + } + } + + /** + * Returns a resource name corresponding to the relative file path + * between {@code dir} and {@code file}. If the file is a directory + * then the name will end with a "/", except the top-level directory + * where the empty string is returned. + */ + public static String toResourceName(Path dir, Path file) { + String s = dir.relativize(file) + .toString() + .replace(File.separatorChar, '/'); + if (s.length() > 0 && Files.isDirectory(file)) + s += "/"; + return s; + } + + /** + * Returns a file path to a resource in a file tree. If the resource + * name has a trailing "/" then the file path will locate a directory. + * Returns {@code null} if the resource does not map to a file in the + * tree file. + */ + public static Path toFilePath(Path dir, String name) throws IOException { + boolean expectDirectory = name.endsWith("/"); + if (expectDirectory) { + name = name.substring(0, name.length() - 1); // drop trailing "/" + } + Path path = toSafeFilePath(dir.getFileSystem(), name); + if (path != null) { + Path file = dir.resolve(path); + try { + BasicFileAttributes attrs; + attrs = Files.readAttributes(file, BasicFileAttributes.class); + if (attrs.isDirectory() + || (!attrs.isDirectory() && !expectDirectory)) + return file; + } catch (NoSuchFileException ignore) { } + } + return null; + } + + /** + * Map a resource name to a "safe" file path. Returns {@code null} if + * the resource name cannot be converted into a "safe" file path. + * + * Resource names with empty elements, or elements that are "." or ".." + * are rejected, as are resource names that translates to a file path + * with a root component. + */ + private static Path toSafeFilePath(FileSystem fs, String name) { + // scan elements of resource name + int next; + int off = 0; + while ((next = name.indexOf('/', off)) != -1) { + int len = next - off; + if (!mayTranslate(name, off, len)) { + return null; + } + off = next + 1; + } + int rem = name.length() - off; + if (!mayTranslate(name, off, rem)) { + return null; + } + + // convert to file path + Path path; + if (File.separatorChar == '/') { + path = fs.getPath(name); + } else { + // not allowed to embed file separators + if (name.contains(File.separator)) + return null; + path = fs.getPath(name.replace('/', File.separatorChar)); + } + + // file path not allowed to have root component + return (path.getRoot() == null) ? path : null; + } + + /** + * Returns {@code true} if the element in a resource name is a candidate + * to translate to the element of a file path. + */ + private static boolean mayTranslate(String name, int off, int len) { + if (len <= 2) { + if (len == 0) + return false; + boolean starsWithDot = (name.charAt(off) == '.'); + if (len == 1 && starsWithDot) + return false; + if (len == 2 && starsWithDot && (name.charAt(off+1) == '.')) + return false; + } + return true; + } + +} diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java b/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java index d4425aadbb8..f0d7126adc8 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ServicesCatalog.java @@ -25,7 +25,6 @@ package jdk.internal.module; -import java.lang.reflect.Module; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor.Provides; import java.util.ArrayList; diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModuleFinder.java b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModuleFinder.java index 5ec0a62ca69..92c4c96cadb 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModuleFinder.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModuleFinder.java @@ -80,8 +80,6 @@ public class SystemModuleFinder implements ModuleFinder { = PerfCounter.newPerfCounter("jdk.module.finder.jimage.packages"); private static final PerfCounter exportsCount = PerfCounter.newPerfCounter("jdk.module.finder.jimage.exports"); - // ImageReader used to access all modules in the image - private static final ImageReader imageReader; // singleton finder to find modules in the run-time images private static final SystemModuleFinder INSTANCE; @@ -96,13 +94,28 @@ public class SystemModuleFinder implements ModuleFinder { */ static { long t0 = System.nanoTime(); - imageReader = ImageReaderFactory.getImageReader(); INSTANCE = new SystemModuleFinder(); initTime.addElapsedTimeFrom(t0); } + /** + * Holder class for the ImageReader + */ + private static class SystemImage { + static final ImageReader READER; + static { + long t0 = System.nanoTime(); + READER = ImageReaderFactory.getImageReader(); + initTime.addElapsedTimeFrom(t0); + } + + static ImageReader reader() { + return READER; + } + } + private static boolean isFastPathSupported() { return SystemModules.MODULE_NAMES.length > 0; } @@ -114,7 +127,7 @@ public class SystemModuleFinder implements ModuleFinder { // this happens when java.base is patched with java.base // from an exploded image - return imageReader.getModuleNames(); + return SystemImage.reader().getModuleNames(); } // the set of modules in the run-time image @@ -137,26 +150,31 @@ public class SystemModuleFinder implements ModuleFinder { System.getProperty("jdk.system.module.finder.disabledFastPath") != null; ModuleDescriptor[] descriptors; + ModuleTarget[] targets; ModuleHashes[] recordedHashes; ModuleResolution[] moduleResolutions; // fast loading of ModuleDescriptor of system modules if (isFastPathSupported() && !disabled) { descriptors = SystemModules.descriptors(); + targets = SystemModules.targets(); recordedHashes = SystemModules.hashes(); moduleResolutions = SystemModules.moduleResolutions(); } else { // if fast loading of ModuleDescriptors is disabled // fallback to read module-info.class descriptors = new ModuleDescriptor[n]; + targets = new ModuleTarget[n]; recordedHashes = new ModuleHashes[n]; moduleResolutions = new ModuleResolution[n]; + ImageReader imageReader = SystemImage.reader(); for (int i = 0; i < names.length; i++) { String mn = names[i]; ImageLocation loc = imageReader.findLocation(mn, "module-info.class"); ModuleInfo.Attributes attrs = ModuleInfo.read(imageReader.getResourceBuffer(loc), null); descriptors[i] = attrs.descriptor(); + targets[i] = attrs.target(); recordedHashes[i] = attrs.recordedHashes(); moduleResolutions[i] = attrs.moduleResolution(); } @@ -192,6 +210,7 @@ public class SystemModuleFinder implements ModuleFinder { // create the ModuleReference ModuleReference mref = toModuleReference(md, + targets[i], recordedHashes[i], hashSupplier(names[i]), moduleResolutions[i]); @@ -219,6 +238,7 @@ public class SystemModuleFinder implements ModuleFinder { } private ModuleReference toModuleReference(ModuleDescriptor md, + ModuleTarget target, ModuleHashes recordedHashes, HashSupplier hasher, ModuleResolution mres) { @@ -232,9 +252,14 @@ public class SystemModuleFinder implements ModuleFinder { } }; - ModuleReference mref = - new ModuleReferenceImpl(md, uri, readerSupplier, null, - recordedHashes, hasher, mres); + ModuleReference mref = new ModuleReferenceImpl(md, + uri, + readerSupplier, + null, + target, + recordedHashes, + hasher, + mres); // may need a reference to a patched module if --patch-module specified mref = ModuleBootstrap.patcher().patchIfNeeded(mref); @@ -291,6 +316,7 @@ public class SystemModuleFinder implements ModuleFinder { Objects.requireNonNull(name); if (closed) throw new IOException("ModuleReader is closed"); + ImageReader imageReader = SystemImage.reader(); if (imageReader != null) { return imageReader.findLocation(module, name); } else { @@ -330,7 +356,7 @@ public class SystemModuleFinder implements ModuleFinder { public Optional read(String name) throws IOException { ImageLocation location = findImageLocation(name); if (location != null) { - return Optional.of(imageReader.getResourceBuffer(location)); + return Optional.of(SystemImage.reader().getResourceBuffer(location)); } else { return Optional.empty(); } @@ -372,7 +398,7 @@ public class SystemModuleFinder implements ModuleFinder { stack = new ArrayDeque<>(); // push the root node to the stack to get started - ImageReader.Node dir = imageReader.findNode(moduleRoot); + ImageReader.Node dir = SystemImage.reader().findNode(moduleRoot); if (dir == null || !dir.isDirectory()) throw new IOException(moduleRoot + " not a directory"); stack.push(dir); @@ -390,7 +416,7 @@ public class SystemModuleFinder implements ModuleFinder { String name = node.getName(); if (node.isDirectory()) { // build node - ImageReader.Node dir = imageReader.findNode(name); + ImageReader.Node dir = SystemImage.reader().findNode(name); assert dir.isDirectory(); stack.push(dir); } else { diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java index 596bb697238..06e21ba2967 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.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 @@ -27,7 +27,7 @@ package jdk.internal.module; import java.lang.module.ModuleDescriptor; -/* +/** * SystemModules class will be generated at link time to create * ModuleDescriptor for the system modules directly to improve * the module descriptor reconstitution time. @@ -65,7 +65,7 @@ public final class SystemModules { } /** - * Returns a non-empty array of ModuleDescriptors in the run-time image. + * Returns a non-empty array of ModuleDescriptor objects in the run-time image. * * When running an exploded image it returns an empty array. */ @@ -73,6 +73,15 @@ public final class SystemModules { throw new InternalError("expected to be overridden at link time"); } + /** + * Returns a non-empty array of ModuleTarget objects in the run-time image. + * + * When running an exploded image it returns an empty array. + */ + public static ModuleTarget[] targets() { + throw new InternalError("expected to be overridden at link time"); + } + /** * Returns a non-empty array of ModuleHashes recorded in each module * in the run-time image. diff --git a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java index 4d91a001690..a3c58f2990c 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java @@ -2508,7 +2508,7 @@ public class ClassReader { } /** - * Reads a CONSTANT_Pakcage_info item in {@code b}. This method is + * Reads a CONSTANT_Package_info item in {@code b}. This method is * intended for {@link Attribute} sub slasses, and is normally not needed * by class generators or adapters. * diff --git a/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java b/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java index 9a410049188..f2670e55200 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java +++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, 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 @@ -31,9 +31,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import jdk.internal.HotSpotIntrinsicCandidate; -import jdk.internal.misc.SharedSecrets; +import jdk.internal.loader.ClassLoaders; import jdk.internal.misc.VM; -import sun.security.action.GetPropertyAction; /** Common utility routines used by both java.lang and java.lang.reflect */ @@ -104,39 +103,40 @@ public class Reflection { int modifiers) throws IllegalAccessException { - if (currentClass == null || memberClass == null) { - throw new InternalError(); - } - if (!verifyMemberAccess(currentClass, memberClass, targetClass, modifiers)) { - throwIllegalAccessException(currentClass, memberClass, targetClass, modifiers); + throw newIllegalAccessException(currentClass, memberClass, targetClass, modifiers); } } /** - * Verify access to a member, returning {@code false} if no access + * Verify access to a member and return {@code true} if it is granted. + * + * @param currentClass the class performing the access + * @param memberClass the declaring class of the member being accessed + * @param targetClass the class of target object if accessing instance + * field or method; + * or the declaring class if accessing constructor; + * or null if accessing static field or method + * @param modifiers the member's access modifiers + * @return {@code true} if access to member is granted */ public static boolean verifyMemberAccess(Class currentClass, Class memberClass, Class targetClass, int modifiers) { - // Verify that currentClass can access a field, method, or - // constructor of memberClass, where that member's access bits are - // "modifiers". - - boolean gotIsSameClassPackage = false; - boolean isSameClassPackage = false; - if (currentClass == memberClass) { // Always succeeds return true; } - if (!verifyModuleAccess(currentClass, memberClass)) { + if (!verifyModuleAccess(currentClass.getModule(), memberClass)) { return false; } + boolean gotIsSameClassPackage = false; + boolean isSameClassPackage = false; + if (!Modifier.isPublic(getClassAccessFlags(memberClass))) { isSameClassPackage = isSameClassPackage(currentClass, memberClass); gotIsSameClassPackage = true; @@ -196,39 +196,20 @@ public class Reflection { } /** - * Returns {@code true} if memberClass's's module exports memberClass's - * package to currentClass's module. + * Returns {@code true} if memberClass's module exports memberClass's + * package to currentModule. */ - public static boolean verifyModuleAccess(Class currentClass, - Class memberClass) { - return verifyModuleAccess(currentClass.getModule(), memberClass); - } - public static boolean verifyModuleAccess(Module currentModule, Class memberClass) { Module memberModule = memberClass.getModule(); - - // module may be null during startup (initLevel 0) - if (currentModule == memberModule) - return true; // same module (named or unnamed) - - // memberClass may be primitive or array class - Class c = memberClass; - while (c.isArray()) { - c = c.getComponentType(); - } - if (c.isPrimitive()) + if (currentModule == memberModule) { + // same module (named or unnamed) or both null if called + // before module system is initialized, which means we are + // dealing with java.base only. return true; - - String pkg = c.getPackageName(); - boolean allowed = memberModule.isExported(pkg, currentModule); - if (allowed && memberModule.isNamed() && printStackTraceWhenAccessSucceeds()) { - if (!SharedSecrets.getJavaLangReflectModuleAccess() - .isStaticallyExported(memberModule, pkg, currentModule)) { - String msg = currentModule + " allowed access to member of " + memberClass; - new Exception(msg).printStackTrace(System.err); - } + } else { + String pkg = memberClass.getPackageName(); + return memberModule.isExported(pkg, currentModule); } - return allowed; } /** @@ -237,10 +218,6 @@ public class Reflection { private static boolean isSameClassPackage(Class c1, Class c2) { if (c1.getClassLoader() != c2.getClassLoader()) return false; - while (c1.isArray()) - c1 = c1.getComponentType(); - while (c2.isArray()) - c2 = c2.getComponentType(); return Objects.equals(c1.getPackageName(), c2.getPackageName()); } @@ -339,69 +316,21 @@ public class Reflection { */ public static boolean isCallerSensitive(Method m) { final ClassLoader loader = m.getDeclaringClass().getClassLoader(); - if (VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) { + if (VM.isSystemDomainLoader(loader) || + loader == ClassLoaders.platformClassLoader()) { return m.isAnnotationPresent(CallerSensitive.class); } return false; } - private static boolean isExtClassLoader(ClassLoader loader) { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - while (cl != null) { - if (cl.getParent() == null && cl == loader) { - return true; - } - cl = cl.getParent(); - } - return false; - } - - - // true to print a stack trace when access fails - private static volatile boolean printStackWhenAccessFails; - - // true to print a stack trace when access succeeds - private static volatile boolean printStackWhenAccessSucceeds; - - // true if printStack* values are initialized - private static volatile boolean printStackPropertiesSet; - - private static void ensurePrintStackPropertiesSet() { - if (!printStackPropertiesSet && VM.initLevel() >= 1) { - String s = GetPropertyAction.privilegedGetProperty( - "sun.reflect.debugModuleAccessChecks"); - if (s != null) { - printStackWhenAccessFails = !s.equalsIgnoreCase("false"); - printStackWhenAccessSucceeds = s.equalsIgnoreCase("access"); - } - printStackPropertiesSet = true; - } - } - - public static void enableStackTraces() { - printStackWhenAccessFails = true; - printStackWhenAccessSucceeds = true; - printStackPropertiesSet = true; - } - - public static boolean printStackTraceWhenAccessFails() { - ensurePrintStackPropertiesSet(); - return printStackWhenAccessFails; - } - - public static boolean printStackTraceWhenAccessSucceeds() { - ensurePrintStackPropertiesSet(); - return printStackWhenAccessSucceeds; - } - /** - * Throws IllegalAccessException with the an exception message based on + * Returns an IllegalAccessException with an exception message based on * the access that is denied. */ - private static void throwIllegalAccessException(Class currentClass, - Class memberClass, - Object target, - int modifiers) + public static IllegalAccessException newIllegalAccessException(Class currentClass, + Class memberClass, + Class targetClass, + int modifiers) throws IllegalAccessException { String currentSuffix = ""; @@ -413,11 +342,7 @@ public class Reflection { if (m2.isNamed()) memberSuffix = " (in " + m2 + ")"; - Class c = memberClass; - while (c.isArray()) { - c = c.getComponentType(); - } - String memberPackageName = c.getPackageName(); + String memberPackageName = memberClass.getPackageName(); String msg = currentClass + currentSuffix + " cannot access "; if (m2.isExported(memberPackageName, m1)) { @@ -433,20 +358,6 @@ public class Reflection { if (m2.isNamed()) msg += " to " + m1; } - throwIllegalAccessException(msg); - } - - /** - * Throws IllegalAccessException with the given exception message. - */ - public static void throwIllegalAccessException(String msg) - throws IllegalAccessException - { - IllegalAccessException e = new IllegalAccessException(msg); - ensurePrintStackPropertiesSet(); - if (printStackWhenAccessFails) { - e.printStackTrace(System.err); - } - throw e; + return new IllegalAccessException(msg); } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java b/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java index 990de713fc6..f919026b31d 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java +++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.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 @@ -44,6 +44,7 @@ import java.security.PrivilegedAction; import java.util.Objects; import java.util.Properties; +import jdk.internal.misc.VM; import sun.reflect.misc.ReflectUtil; import sun.security.action.GetPropertyAction; @@ -134,6 +135,24 @@ public class ReflectionFactory { return soleInstance; } + /** + * Returns an alternate reflective Method instance for the given method + * intended for reflection to invoke, if present. + * + * A trusted method can define an alternate implementation for a method `foo` + * by defining a method named "reflected$foo" that will be invoked + * reflectively. + */ + private static Method findMethodForReflection(Method method) { + String altName = "reflected$" + method.getName(); + try { + return method.getDeclaringClass() + .getDeclaredMethod(altName, method.getParameterTypes()); + } catch (NoSuchMethodException ex) { + return null; + } + } + //-------------------------------------------------------------------------- // // Routines used by java.lang.reflect @@ -160,6 +179,13 @@ public class ReflectionFactory { public MethodAccessor newMethodAccessor(Method method) { checkInitted(); + if (Reflection.isCallerSensitive(method)) { + Method altMethod = findMethodForReflection(method); + if (altMethod != null) { + method = altMethod; + } + } + if (noInflation && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) { return new MethodAccessorGenerator(). generateMethod(method.getDeclaringClass(), @@ -585,17 +611,10 @@ public class ReflectionFactory { private static void checkInitted() { if (initted) return; - // Tests to ensure the system properties table is fully - // initialized. This is needed because reflection code is - // called very early in the initialization process (before - // command-line arguments have been parsed and therefore - // these user-settable properties installed.) We assume that - // if System.out is non-null then the System class has been - // fully initialized and that the bulk of the startup code - // has been run. - - if (System.out == null) { - // java.lang.System not yet fully initialized + // Defer initialization until module system is initialized so as + // to avoid inflation and spinning bytecode in unnamed modules + // during early startup. + if (!VM.isModuleSystemInited()) { return; } diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index 185f8f2a1d1..e637bc34d7d 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -25,6 +25,9 @@ /** * Defines the foundational APIs of the Java SE Platform. + * + * @moduleGraph + * @since 9 */ module java.base { @@ -123,10 +126,9 @@ module java.base { jdk.jlink; exports jdk.internal.loader to java.instrument, - java.logging, - jdk.jlink; + java.logging; exports jdk.internal.jmod to - jdk.compiler, + jdk.compiler, // reflective dependency jdk.jlink; exports jdk.internal.logger to java.logging; @@ -134,14 +136,11 @@ module java.base { jdk.jartool, jdk.jlink, jdk.scripting.nashorn, - jdk.vm.ci; + jdk.internal.vm.ci; exports jdk.internal.org.objectweb.asm.tree to jdk.jlink; exports jdk.internal.org.objectweb.asm.util to - jdk.jlink, jdk.scripting.nashorn; - exports jdk.internal.org.objectweb.asm.tree.analysis to - jdk.jlink; exports jdk.internal.org.objectweb.asm.commons to jdk.scripting.nashorn; exports jdk.internal.org.objectweb.asm.signature to @@ -155,7 +154,6 @@ module java.base { jdk.jlink; exports jdk.internal.misc to java.desktop, - jdk.incubator.httpclient, java.logging, java.management, java.naming, @@ -163,9 +161,10 @@ module java.base { java.security.jgss, java.sql, java.xml, + jdk.attach, jdk.charsets, - jdk.compiler, - jdk.jartool, + jdk.compiler, // reflective dependency + jdk.incubator.httpclient, jdk.jdeps, jdk.jlink, jdk.jshell, @@ -173,7 +172,7 @@ module java.base { jdk.scripting.nashorn, jdk.scripting.nashorn.shell, jdk.unsupported, - jdk.vm.ci; + jdk.internal.vm.ci; exports jdk.internal.perf to java.desktop, java.management, @@ -191,7 +190,8 @@ module java.base { jdk.unsupported; exports jdk.internal.vm.annotation to jdk.unsupported, - jdk.vm.ci; + jdk.internal.vm.ci, + jdk.incubator.httpclient; exports jdk.internal.util.jar to jdk.jartool, jdk.jdeps, @@ -208,11 +208,10 @@ module java.base { jdk.naming.dns; exports sun.net.util to java.desktop, - jdk.jconsole, - jdk.naming.dns; + jdk.jconsole; exports sun.net.www to - jdk.incubator.httpclient, java.desktop, + jdk.incubator.httpclient, jdk.jartool; exports sun.net.www.protocol.http to java.security.jgss; @@ -237,8 +236,7 @@ module java.base { java.management.rmi, java.rmi, java.sql.rowset, - java.xml, - java.xml.ws; + java.xml; exports sun.security.action to java.desktop, java.security.jgss; diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java index 9c46aad018f..d0e2a98995a 100644 --- a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java +++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, 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 @@ -27,7 +27,6 @@ package sun.invoke.util; import java.lang.reflect.Modifier; import static java.lang.reflect.Modifier.*; -import java.lang.reflect.Module; import java.util.Objects; import jdk.internal.reflect.Reflection; @@ -39,6 +38,7 @@ public class VerifyAccess { private VerifyAccess() { } // cannot instantiate + private static final int UNCONDITIONAL_ALLOWED = java.lang.invoke.MethodHandles.Lookup.UNCONDITIONAL; private static final int MODULE_ALLOWED = java.lang.invoke.MethodHandles.Lookup.MODULE; private static final int PACKAGE_ONLY = 0; private static final int PACKAGE_ALLOWED = java.lang.invoke.MethodHandles.Lookup.PACKAGE; @@ -92,7 +92,7 @@ public class VerifyAccess { int allowedModes) { if (allowedModes == 0) return false; assert((allowedModes & PUBLIC) != 0 && - (allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED|MODULE_ALLOWED)) == 0); + (allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED|MODULE_ALLOWED|UNCONDITIONAL_ALLOWED)) == 0); // The symbolic reference class (refc) must always be fully verified. if (!isClassAccessible(refc, lookupClass, allowedModes)) { return false; @@ -173,7 +173,7 @@ public class VerifyAccess { int allowedModes) { if (allowedModes == 0) return false; assert((allowedModes & PUBLIC) != 0 && - (allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED|MODULE_ALLOWED)) == 0); + (allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED|MODULE_ALLOWED|UNCONDITIONAL_ALLOWED)) == 0); int mods = getClassModifiers(refc); if (isPublic(mods)) { @@ -191,22 +191,17 @@ public class VerifyAccess { (lookupModule == refModule)) return true; - // check readability - if (lookupModule.canRead(refModule)) { + // check readability when UNCONDITIONAL not allowed + if (((allowedModes & UNCONDITIONAL_ALLOWED) != 0) + || lookupModule.canRead(refModule)) { // check that refc is in an exported package - Class c = refc; - while (c.isArray()) { - c = c.getComponentType(); - } - if (c.isPrimitive()) - return true; if ((allowedModes & MODULE_ALLOWED) != 0) { - if (refModule.isExported(c.getPackageName(), lookupModule)) + if (refModule.isExported(refc.getPackageName(), lookupModule)) return true; } else { // exported unconditionally - if (refModule.isExported(c.getPackageName())) + if (refModule.isExported(refc.getPackageName())) return true; } diff --git a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java index ee8f311d2e4..5ac605a2092 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java +++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, 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 @@ -43,31 +43,35 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.io.UnsupportedEncodingException; -import java.lang.module.ModuleFinder; -import java.lang.module.ModuleReference; +import java.lang.module.Configuration; +import java.lang.module.FindException; import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor.Requires; import java.lang.module.ModuleDescriptor.Exports; import java.lang.module.ModuleDescriptor.Opens; import java.lang.module.ModuleDescriptor.Provides; -import java.lang.reflect.Layer; +import java.lang.module.ModuleFinder; +import java.lang.module.ModuleReference; +import java.lang.module.ResolvedModule; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.Module; import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URI; import java.nio.charset.Charset; import java.nio.file.DirectoryStream; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; import java.text.Normalizer; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -85,6 +89,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.internal.misc.VM; +import jdk.internal.module.ModuleBootstrap; import jdk.internal.module.Modules; @@ -100,6 +105,7 @@ public final class LauncherHelper { "javafx.application.Application"; private static final String JAVAFX_FXHELPER_CLASS_NAME_SUFFIX = "sun.launcher.LauncherHelper$FXHelper"; + private static final String LAUNCHER_AGENT_CLASS = "Launcher-Agent-Class"; private static final String MAIN_CLASS = "Main-Class"; private static final String ADD_EXPORTS = "Add-Exports"; private static final String ADD_OPENS = "Add-Opens"; @@ -410,8 +416,12 @@ public final class LauncherHelper { ostream = (printToStderr) ? System.err : System.out; } + static void initOutput(PrintStream ps) { + ostream = ps; + } + static String getMainClassFromJar(String jarname) { - String mainValue = null; + String mainValue; try (JarFile jarFile = new JarFile(jarname)) { Manifest manifest = jarFile.getManifest(); if (manifest == null) { @@ -428,7 +438,23 @@ public final class LauncherHelper { abort(null, "java.launcher.jar.error3", jarname); } - // Add-Exports and Add-Opens to break encapsulation + // Launcher-Agent-Class (only check for this when Main-Class present) + String agentClass = mainAttrs.getValue(LAUNCHER_AGENT_CLASS); + if (agentClass != null) { + ModuleLayer.boot().findModule("java.instrument").ifPresent(m -> { + try { + String cn = "sun.instrument.InstrumentationImpl"; + Class clazz = Class.forName(cn, false, null); + Method loadAgent = clazz.getMethod("loadAgent", String.class); + loadAgent.invoke(null, jarname); + } catch (Throwable e) { + if (e instanceof InvocationTargetException) e = e.getCause(); + abort(e, "java.launcher.jar.error4", jarname); + } + }); + } + + // Add-Exports and Add-Opens String exports = mainAttrs.getValue(ADD_EXPORTS); if (exports != null) { addExportsOrOpens(exports, false); @@ -466,7 +492,8 @@ public final class LauncherHelper { if (s.length == 2) { String mn = s[0]; String pn = s[1]; - Layer.boot().findModule(mn).ifPresent(m -> { + + ModuleLayer.boot().findModule(mn).ifPresent(m -> { if (m.getDescriptor().packages().contains(pn)) { if (open) { Modules.addOpensToAllUnnamed(m, pn); @@ -563,7 +590,7 @@ public final class LauncherHelper { } // main module is in the boot layer - Layer layer = Layer.boot(); + ModuleLayer layer = ModuleLayer.boot(); Optional om = layer.findModule(mainModule); if (!om.isPresent()) { // should not happen @@ -591,8 +618,8 @@ public final class LauncherHelper { c = Class.forName(m, cn); } } catch (LinkageError le) { - abort(null, "java.launcher.module.error3", - mainClass, m.getName(), le.getLocalizedMessage()); + abort(null, "java.launcher.module.error3", mainClass, m.getName(), + le.getClass().getName() + ": " + le.getLocalizedMessage()); } if (c == null) { abort(null, "java.launcher.module.error2", mainClass, mainModule); @@ -638,14 +665,17 @@ public final class LauncherHelper { String ncn = Normalizer.normalize(cn, Normalizer.Form.NFC); mainClass = Class.forName(ncn, false, scl); } catch (NoClassDefFoundError | ClassNotFoundException cnfe1) { - abort(cnfe1, "java.launcher.cls.error1", cn); + abort(cnfe1, "java.launcher.cls.error1", cn, + cnfe1.getClass().getCanonicalName(), cnfe1.getMessage()); } } else { - abort(cnfe, "java.launcher.cls.error1", cn); + abort(cnfe, "java.launcher.cls.error1", cn, + cnfe.getClass().getCanonicalName(), cnfe.getMessage()); } } } catch (LinkageError le) { - abort(le, "java.launcher.cls.error6", cn, le.getLocalizedMessage()); + abort(le, "java.launcher.cls.error6", cn, + le.getClass().getName() + ": " + le.getLocalizedMessage()); } return mainClass; } @@ -850,7 +880,7 @@ public final class LauncherHelper { private static void setFXLaunchParameters(String what, int mode) { // find the module with the FX launcher - Optional om = Layer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME); + Optional om = ModuleLayer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME); if (!om.isPresent()) { abort(null, "java.launcher.cls.error5"); } @@ -911,130 +941,350 @@ public final class LauncherHelper { } } - private static void formatCommaList(PrintStream out, - String prefix, - Collection list) - { - if (list.isEmpty()) - return; - out.format("%s", prefix); - boolean first = true; - for (Object ob : list) { - if (first) { - out.format(" %s", ob); - first = false; - } else { - out.format(", %s", ob); - } - } - out.format("%n"); + /** + * Called by the launcher to list the observable modules. + */ + static void listModules() { + initOutput(System.out); + + ModuleBootstrap.limitedFinder().findAll().stream() + .sorted(new JrtFirstComparator()) + .forEach(LauncherHelper::showModule); } /** - * Called by the launcher to list the observable modules. - * If called without any sub-options then the output is a simple list of - * the modules. If called with sub-options then the sub-options are the - * names of the modules to list (-listmods:java.base,java.desktop for - * example). + * Called by the launcher to show the resolved modules */ - static void listModules(boolean printToStderr, String optionFlag) - throws IOException, ClassNotFoundException - { - initOutput(printToStderr); + static void showResolvedModules() { + initOutput(System.out); - ModuleFinder finder = jdk.internal.module.ModuleBootstrap.finder(); + ModuleLayer bootLayer = ModuleLayer.boot(); + Configuration cf = bootLayer.configuration(); - int colon = optionFlag.indexOf('='); - if (colon == -1) { - finder.findAll().stream() - .sorted(Comparator.comparing(ModuleReference::descriptor)) - .forEach(md -> { - ostream.println(midAndLocation(md.descriptor(), - md.location())); - }); - } else { - String[] names = optionFlag.substring(colon+1).split(","); - for (String name: names) { - ModuleReference mref = finder.find(name).orElse(null); - if (mref == null) { - System.err.format("%s not observable!%n", name); - continue; - } + cf.modules().stream() + .map(ResolvedModule::reference) + .sorted(new JrtFirstComparator()) + .forEach(LauncherHelper::showModule); + } - ModuleDescriptor md = mref.descriptor(); - if (md.isOpen()) - ostream.print("open "); - if (md.isAutomatic()) - ostream.print("automatic "); - ostream.println("module " + midAndLocation(md, mref.location())); + /** + * Called by the launcher to describe a module + */ + static void describeModule(String moduleName) { + initOutput(System.out); - // unqualified exports (sorted by package) - Set exports = new TreeSet<>(Comparator.comparing(Exports::source)); - md.exports().stream().filter(e -> !e.isQualified()).forEach(exports::add); - for (Exports e : exports) { - String modsAndSource = Stream.concat(toStringStream(e.modifiers()), - Stream.of(e.source())) - .collect(Collectors.joining(" ")); - ostream.format(" exports %s%n", modsAndSource); - } + ModuleFinder finder = ModuleBootstrap.limitedFinder(); + ModuleReference mref = finder.find(moduleName).orElse(null); + if (mref == null) { + abort(null, "java.launcher.module.error4", moduleName); + } + ModuleDescriptor md = mref.descriptor(); - for (Requires d : md.requires()) { - ostream.format(" requires %s%n", d); - } - for (String s : md.uses()) { - ostream.format(" uses %s%n", s); - } + // one-line summary + showModule(mref); - for (Provides ps : md.provides()) { - ostream.format(" provides %s with %s%n", ps.service(), - ps.providers().stream().collect(Collectors.joining(", "))); - } + // unqualified exports (sorted by package) + md.exports().stream() + .filter(e -> !e.isQualified()) + .sorted(Comparator.comparing(Exports::source)) + .map(e -> Stream.concat(Stream.of(e.source()), + toStringStream(e.modifiers())) + .collect(Collectors.joining(" "))) + .forEach(sourceAndMods -> ostream.format("exports %s%n", sourceAndMods)); - // qualified exports - for (Exports e : md.exports()) { - if (e.isQualified()) { - String modsAndSource = Stream.concat(toStringStream(e.modifiers()), - Stream.of(e.source())) - .collect(Collectors.joining(" ")); - ostream.format(" exports %s", modsAndSource); - formatCommaList(ostream, " to", e.targets()); - } - } + // dependences + for (Requires r : md.requires()) { + String nameAndMods = Stream.concat(Stream.of(r.name()), + toStringStream(r.modifiers())) + .collect(Collectors.joining(" ")); + ostream.format("requires %s", nameAndMods); + finder.find(r.name()) + .map(ModuleReference::descriptor) + .filter(ModuleDescriptor::isAutomatic) + .ifPresent(any -> ostream.print(" automatic")); + ostream.println(); + } - // open packages - for (Opens obj: md.opens()) { - String modsAndSource = Stream.concat(toStringStream(obj.modifiers()), - Stream.of(obj.source())) - .collect(Collectors.joining(" ")); - ostream.format(" opens %s", modsAndSource); - if (obj.isQualified()) - formatCommaList(ostream, " to", obj.targets()); - else - ostream.println(); - } + // service use and provides + for (String s : md.uses()) { + ostream.format("uses %s%n", s); + } + for (Provides ps : md.provides()) { + String names = ps.providers().stream().collect(Collectors.joining(" ")); + ostream.format("provides %s with %s%n", ps.service(), names); - // non-exported/non-open packages - Set concealed = new TreeSet<>(md.packages()); - md.exports().stream().map(Exports::source).forEach(concealed::remove); - md.opens().stream().map(Opens::source).forEach(concealed::remove); - concealed.forEach(p -> ostream.format(" contains %s%n", p)); + } + + // qualified exports + for (Exports e : md.exports()) { + if (e.isQualified()) { + String who = e.targets().stream().collect(Collectors.joining(" ")); + ostream.format("qualified exports %s to %s%n", e.source(), who); + } + } + + // open packages + for (Opens opens: md.opens()) { + if (opens.isQualified()) + ostream.print("qualified "); + String sourceAndMods = Stream.concat(Stream.of(opens.source()), + toStringStream(opens.modifiers())) + .collect(Collectors.joining(" ")); + ostream.format("opens %s", sourceAndMods); + if (opens.isQualified()) { + String who = opens.targets().stream().collect(Collectors.joining(" ")); + ostream.format(" to %s", who); + } + ostream.println(); + } + + // non-exported/non-open packages + Set concealed = new TreeSet<>(md.packages()); + md.exports().stream().map(Exports::source).forEach(concealed::remove); + md.opens().stream().map(Opens::source).forEach(concealed::remove); + concealed.forEach(p -> ostream.format("contains %s%n", p)); + } + + /** + * Prints a single line with the module name, version and modifiers + */ + private static void showModule(ModuleReference mref) { + ModuleDescriptor md = mref.descriptor(); + ostream.print(md.toNameAndVersion()); + mref.location() + .filter(uri -> !isJrt(uri)) + .ifPresent(uri -> ostream.format(" %s", uri)); + if (md.isOpen()) + ostream.print(" open"); + if (md.isAutomatic()) + ostream.print(" automatic"); + ostream.println(); + } + + /** + * A ModuleReference comparator that considers modules in the run-time + * image to be less than modules than not in the run-time image. + */ + private static class JrtFirstComparator implements Comparator { + private final Comparator real; + + JrtFirstComparator() { + this.real = Comparator.comparing(ModuleReference::descriptor); + } + + @Override + public int compare(ModuleReference a, ModuleReference b) { + if (isJrt(a)) { + return isJrt(b) ? real.compare(a, b) : -1; + } else { + return isJrt(b) ? 1 : real.compare(a, b); } } } - static String toString(Set s) { - return toStringStream(s).collect(Collectors.joining(" ")); - } - - static Stream toStringStream(Set s) { + private static Stream toStringStream(Set s) { return s.stream().map(e -> e.toString().toLowerCase()); } - static String midAndLocation(ModuleDescriptor md, Optional location ) { - URI loc = location.orElse(null); - if (loc == null || loc.getScheme().equalsIgnoreCase("jrt")) - return md.toNameAndVersion(); - else - return md.toNameAndVersion() + " (" + loc + ")"; + private static boolean isJrt(ModuleReference mref) { + return isJrt(mref.location().orElse(null)); + } + + private static boolean isJrt(URI uri) { + return (uri != null && uri.getScheme().equalsIgnoreCase("jrt")); + } + + /** + * Called by the launcher to validate the modules on the upgrade and + * application module paths. + * + * @return {@code true} if no errors are found + */ + private static boolean validateModules() { + initOutput(System.out); + + ModuleValidator validator = new ModuleValidator(); + + // upgrade module path + String value = System.getProperty("jdk.module.upgrade.path"); + if (value != null) { + Stream.of(value.split(File.pathSeparator)) + .map(Paths::get) + .forEach(validator::scan); + } + + // system modules + ModuleFinder.ofSystem().findAll().stream() + .sorted(Comparator.comparing(ModuleReference::descriptor)) + .forEach(validator::process); + + // application module path + value = System.getProperty("jdk.module.path"); + if (value != null) { + Stream.of(value.split(File.pathSeparator)) + .map(Paths::get) + .forEach(validator::scan); + } + + return !validator.foundErrors(); + } + + /** + * A simple validator to check for errors and conflicts between modules. + */ + static class ModuleValidator { + private static final String MODULE_INFO = "module-info.class"; + + private Map nameToModule = new HashMap<>(); + private Map packageToModule = new HashMap<>(); + private boolean errorFound; + + /** + * Returns true if at least one error was found + */ + boolean foundErrors() { + return errorFound; + } + + /** + * Prints the module location and name. + */ + private void printModule(ModuleReference mref) { + mref.location() + .filter(uri -> !isJrt(uri)) + .ifPresent(uri -> ostream.print(uri + " ")); + ModuleDescriptor descriptor = mref.descriptor(); + ostream.print(descriptor.name()); + if (descriptor.isAutomatic()) + ostream.print(" automatic"); + ostream.println(); + } + + /** + * Prints the module location and name, checks if the module is + * shadowed by a previously seen module, and finally checks for + * package conflicts with previously seen modules. + */ + void process(ModuleReference mref) { + printModule(mref); + + String name = mref.descriptor().name(); + ModuleReference previous = nameToModule.putIfAbsent(name, mref); + if (previous != null) { + ostream.print(INDENT + "shadowed by "); + printModule(previous); + } else { + // check for package conflicts when not shadowed + for (String pkg : mref.descriptor().packages()) { + previous = packageToModule.putIfAbsent(pkg, mref); + if (previous != null) { + String mn = previous.descriptor().name(); + ostream.println(INDENT + "contains " + pkg + + " conflicts with module " + mn); + errorFound = true; + } + } + } + } + + /** + * Scan an element on a module path. The element is a directory + * of modules, an exploded module, or a JAR file. + */ + void scan(Path entry) { + BasicFileAttributes attrs; + try { + attrs = Files.readAttributes(entry, BasicFileAttributes.class); + } catch (NoSuchFileException ignore) { + return; + } catch (IOException ioe) { + ostream.println(entry + " " + ioe); + errorFound = true; + return; + } + + String fn = entry.getFileName().toString(); + if (attrs.isRegularFile() && fn.endsWith(".jar")) { + // JAR file, explicit or automatic module + scanModule(entry).ifPresent(this::process); + } else if (attrs.isDirectory()) { + Path mi = entry.resolve(MODULE_INFO); + if (Files.exists(mi)) { + // exploded module + scanModule(entry).ifPresent(this::process); + } else { + // directory of modules + scanDirectory(entry); + } + } + } + + /** + * Scan the JAR files and exploded modules in a directory. + */ + private void scanDirectory(Path dir) { + try (DirectoryStream stream = Files.newDirectoryStream(dir)) { + Map moduleToEntry = new HashMap<>(); + + for (Path entry : stream) { + BasicFileAttributes attrs; + try { + attrs = Files.readAttributes(entry, BasicFileAttributes.class); + } catch (IOException ioe) { + ostream.println(entry + " " + ioe); + errorFound = true; + continue; + } + + ModuleReference mref = null; + + String fn = entry.getFileName().toString(); + if (attrs.isRegularFile() && fn.endsWith(".jar")) { + mref = scanModule(entry).orElse(null); + } else if (attrs.isDirectory()) { + Path mi = entry.resolve(MODULE_INFO); + if (Files.exists(mi)) { + mref = scanModule(entry).orElse(null); + } + } + + if (mref != null) { + String name = mref.descriptor().name(); + Path previous = moduleToEntry.putIfAbsent(name, entry); + if (previous != null) { + // same name as other module in the directory + printModule(mref); + ostream.println(INDENT + "contains same module as " + + previous.getFileName()); + errorFound = true; + } else { + process(mref); + } + } + } + } catch (IOException ioe) { + ostream.println(dir + " " + ioe); + errorFound = true; + } + } + + /** + * Scan a JAR file or exploded module. + */ + private Optional scanModule(Path entry) { + ModuleFinder finder = ModuleFinder.of(entry); + try { + return finder.findAll().stream().findFirst(); + } catch (FindException e) { + ostream.println(entry); + ostream.println(INDENT + e.getMessage()); + Throwable cause = e.getCause(); + if (cause != null) { + ostream.println(INDENT + cause); + } + errorFound = true; + return Optional.empty(); + } + } } } diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties index 23439deb377..7cf14706afb 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,19 +24,23 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = Usage: {0} [options] class [args...]\n\ -\ (to execute a class)\n or {0} [options] -jar jarfile [args...]\n\ +java.launcher.opt.header = Usage: {0} [options] [args...]\n\ +\ (to execute a class)\n or {0} [options] -jar [args...]\n\ \ (to execute a jar file)\n\ -\ or {0} [options] -p -m [/] [args...]\n\ +\ or {0} [options] -m [/] [args...]\n\ +\ {0} [options] --module [/] [args...]\n\ \ (to execute the main class in a module)\n\n\ -where options include:\n\n +\ Arguments following the main class, -jar , -m or --module\n\ +\ / are passed as the arguments to main class.\n\n\ +\ where options include:\n\n java.launcher.opt.datamodel =\ -d{0}\t Deprecated, will be removed in a future release\n java.launcher.opt.vmselect =\ {0}\t to select the "{1}" VM\n java.launcher.opt.hotspot =\ {0}\t is a synonym for the "{1}" VM [deprecated]\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n\ +java.launcher.opt.footer = \ +\ -cp \n\ \ -classpath \n\ \ --class-path \n\ \ A {0} separated list of directories, JAR archives,\n\ @@ -49,30 +53,33 @@ java.launcher.opt.footer =\ -cp [/]\n\ -\ --module [/]\n\ -\ the initial module to resolve, and the name of the main class\n\ -\ to execute if not specified by the module\n\ -\ --add-modules [,...]\n\ +\ --add-modules [,...]\n\ \ root modules to resolve in addition to the initial module.\n\ -\ can also be ALL-DEFAULT, ALL-SYSTEM,\n\ +\ can also be ALL-DEFAULT, ALL-SYSTEM,\n\ \ ALL-MODULE-PATH.\n\ -\ --limit-modules [,...]\n\ -\ limit the universe of observable modules\n\ -\ --list-modules [[,...]]\n\ -\ list the observable modules and exit\n\ -\ --dry-run create VM but do not execute main method.\n\ -\ This --dry-run option may be useful for validating the\n\ +\ --list-modules\n\ +\ list observable modules and exit\n\ +\ --d \n\ +\ --describe-module \n\ +\ describe a module and exit\n\ +\ --dry-run create VM and load main class but do not execute main method.\n\ +\ The --dry-run option may be useful for validating the\n\ \ command-line options such as the module system configuration.\n\ +\ --validate-modules\n\ +\ validate all modules and exit\n\ +\ The --validate-modules option may be useful for finding\n\ +\ conflicts and other errors with modules on the module path.\n\ \ -D=\n\ \ set a system property\n\ -\ -verbose:[class|gc|jni]\n\ +\ -verbose:[class|module|gc|jni]\n\ \ enable verbose output\n\ \ -version print product version to the error stream and exit\n\ \ --version print product version to the output stream and exit\n\ \ -showversion print product version to the error stream and continue\n\ \ --show-version\n\ \ print product version to the output stream and continue\n\ +\ --show-module-resolution\n\ +\ show module resolution output during startup\n\ \ -? -h -help\n\ \ print this help message to the error stream\n\ \ --help print this help message to the output stream\n\ @@ -102,8 +109,11 @@ java.launcher.opt.footer =\ -cp read options from the specified file\n\n\ +\ See the SplashScreen API documentation for more information\n\ +\ @argument files\n\ +\ one or more argument files containing options\n\ +\ -disable-@files\n\ +\ prevent further argument file expansion\n\ \To specify an argument for a long option, you can use --= or\n\ \-- .\n @@ -116,7 +126,6 @@ java.launcher.X.usage=\n\ \ -Xcomp forces compilation of methods on first invocation\n\ \ -Xdebug provided for backward compatibility\n\ \ -Xdiag show additional diagnostic messages\n\ -\ -Xdiag:resolver show resolver diagnostic messages\n\ \ -Xfuture enable strictest checks, anticipating future default\n\ \ -Xint interpreted mode execution only\n\ \ -Xinternalversion\n\ @@ -129,7 +138,7 @@ java.launcher.X.usage=\n\ \ -Xms set initial Java heap size\n\ \ -Xmx set maximum Java heap size\n\ \ -Xnoclassgc disable class garbage collection\n\ -\ -Xprof output cpu profiling data\n\ +\ -Xprof output cpu profiling data (deprecated)\n\ \ -Xrs reduce use of OS signals by Java/VM (see documentation)\n\ \ -Xshare:auto use shared class data if possible (default)\n\ \ -Xshare:off do not attempt to use shared class data\n\ @@ -157,10 +166,16 @@ java.launcher.X.usage=\n\ \ --add-opens /=(,)*\n\ \ updates to open to\n\ \ , regardless of module declaration.\n\ -\ --disable-@files disable further argument file expansion\n\ +\ --permit-illegal-access\n\ +\ permit illegal access to members of types in named modules\n\ +\ by code in unnamed modules. This compatibility option will\n\ +\ be removed in the next release.\n\ +\ --limit-modules [,...]\n\ +\ limit the universe of observable modules\n\ \ --patch-module =({0})*\n\ -\ Override or augment a module with classes and resources\n\ -\ in JAR files or directories.\n\n\ +\ override or augment a module with classes and resources\n\ +\ in JAR files or directories.\n\ +\ --disable-@files disable further argument file expansion\n\n\ These extra options are subject to change without notice.\n # Translators please note do not translate the options themselves @@ -175,7 +190,8 @@ The following options are Mac OS X specific:\n\ \ override default icon displayed in dock\n\n java.launcher.cls.error1=\ - Error: Could not find or load main class {0} + Error: Could not find or load main class {0}\n\ + Caused by: {1}: {2} java.launcher.cls.error2=\ Error: Main method is not {0} in class {1}, please define the main method as:\n\ \ public static void main(String[] args) @@ -196,6 +212,7 @@ java.launcher.jar.error1=\ Error: An unexpected error occurred while trying to open file {0} java.launcher.jar.error2=manifest not found in {0} java.launcher.jar.error3=no main manifest attribute, in {0} +java.launcher.jar.error4=error loading java agent in {0} java.launcher.init.error=initialization error java.launcher.javafx.error1=\ Error: The JavaFX launchApplication method has the wrong signature, it\n\ @@ -207,4 +224,5 @@ java.launcher.module.error2=\ java.launcher.module.error3=\ Error: Unable to load main class {0} from module {1}\n\ \t{2} - +java.launcher.module.error4=\ + {0} not found diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_de.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_de.properties index 2272ae9fa24..b3d9295af56 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_de.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,21 +24,18 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = Verwendung: {0} [Optionen] Klasse [Argumente...]\n (zur Ausf\u00FChrung einer Klasse)\n oder {0} [Optionen] -jar JAR-Datei [Argumente...]\n (zur Ausf\u00FChrung einer JAR-Datei)\n oder {0} [Optionen] -p -m [/] [Argumente...]\n (zur Ausf\u00FChrung der Hauptklasse in einem Modul)\nwobei "Optionen" Folgendes umfasst:\n +java.launcher.opt.header = Verwendung: {0} [Optionen] Klasse [Argumente...]\n (zur Ausf\u00FChrung einer Klasse)\n oder {0} [Optionen] -jar JAR-Datei [Argumente...]\n (zur Ausf\u00FChrung einer JAR-Datei)\n oder {0} [Optionen] -p -m [/] [Argumente...]\n (zur Ausf\u00FChrung der Hauptklasse in einem Modul)\nwobei "Optionen" Folgendes umfasst:\n\n java.launcher.opt.datamodel =\ -d{0}\t Veraltet, wird in einem zuk\u00FCnftigen Release entfernt\n java.launcher.opt.vmselect =\ {0}\t zur Auswahl der "{1}" VM\n java.launcher.opt.hotspot =\ {0}\t ist ein Synonym f\u00FCr die "{1}" VM [verworfen]\n -java.launcher.ergo.message1 =\ Die Standard-VM ist {0} -java.launcher.ergo.message2 =\ weil die Ausf\u00FChrung auf einem Server-Class-Rechner erfolgt.\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =-cp \n -classpath \n --class-path \n Eine durch {0} getrennte Liste mit Verzeichnissen, JAR-Archiven\n und ZIP-Archiven zur Suche nach Klassendateien.\n -p \n --module-path ...\n Eine durch {0} getrennte Liste mit Verzeichnissen, wobei jedes Verzeichnis\n ein Modulverzeichnis ist.\n --upgrade-module-path ...\n Eine durch {0} getrennte Liste mit Verzeichnissen, wobei jedes Verzeichnis\n ein Verzeichnis mit Modulen ist, die upgradef\u00E4hige\n Module im Laufzeitimage ersetzen\n -m [/]\n --module [/]\n Das anf\u00E4ngliche aufzul\u00F6sende Modul und der Name der auszuf\u00FChrenden\n Hauptklasse, wenn nicht durch das Modul angegeben\n --add-modules [,...]\n Zus\u00E4tzlich zum anf\u00E4nglichen Modul aufzul\u00F6sende Root-Module.\n kann auch ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH sein.\n --limit-modules [,...]\n Begrenzt die Gesamtheit der beobachtbaren Module\n --list-modules [[,...]]\n F\u00FChrt die beobachtbaren Module auf und beendet den Vorgang\n --dry-run Erstellt VM, f\u00FChrt jedoch die Hauptmethode nicht aus.\n Diese --dry-run-Option kann zur Validierung der Befehlszeilenoptionen,\n etwa der Modulsystemkonfiguration, n\u00FCtzlich sein.\n -D=\n Legt eine Systemeigenschaft fest\n -verbose:[class|gc|jni]\n Aktiviert Verbose-Ausgabe\n -version Druckt die Produktversion in den Fehlerstream und beendet den Vorgang\n --version Druckt die Produktversion in den Ausgabestream und beendet den Vorgang\n -showversion Druckt die Produktversion in den Fehlerstream und f\u00E4hrt fort\n --show-version\n Druckt die Produktversion in den Ausgabestream und f\u00E4hrt fort\n -? -h -help\n Gibt diese Hilfemeldung in den Fehlerstream aus\n --help Gibt diese Hilfemeldung in den Ausgabestream aus\n -X Gibt Hilfe zu zus\u00E4tzlichen Optionen in den Fehlerstream aus\n --help-extra Gibt Hilfe zu zus\u00E4tzlichen Optionen in den Ausgabestream aus\n -ea[:...|:]\n -enableassertions[:...|:]\n Aktiviert Assertions mit angegebener Granularit\u00E4t\n -da[:...|:]\n -disableassertions[:...|:]\n Deaktiviert Assertions mit angegebener Granularit\u00E4t\n -esa | -enablesystemassertions\n Aktiviert System-Assertions\n -dsa | -disablesystemassertions\n Deaktiviert System-Assertions\n -agentlib:[=]\n L\u00E4dt native Agent Library , Beispiel: -agentlib:jdwp\n siehe auch -agentlib:jdwp=help\n -agentpath:[=]\n L\u00E4dt native Agent Library nach vollst\u00E4ndigem Pfadnamen\n -javaagent:[=]\n L\u00E4dt Java-Programmiersprachen-Agent, siehe java.lang.instrument\n -splash:\n Zeigt Begr\u00FC\u00DFungsbildschirm mit angegebenem Bild an\n HiDPI-skalierte Bilder werden automatisch unterst\u00FCtzt und verwendet,\n sofern verf\u00FCgbar. Der nicht skalierte Bilddateiname, z.B. image.ext,\n muss immer als Argument an die Option -splash \u00FCbergeben \ +werden.\n Das geeignetste skalierte Bild wird automatisch\n ausgew\u00E4hlt.\n Weitere Informationen finden Sie in der Dokumentation zur SplashScreen-API.\n @ Liest Optionen aus der angegebenen Datei\n\nZur Angabe eines Arguments f\u00FCr eine lange Option k\u00F6nnen Sie --= oder\n-- verwenden.\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Eine durch {0} getrennte Liste mit Verzeichnissen, JAR-Archiven\n und ZIP-Archiven zur Suche nach Klassendateien.\n -p \n --module-path ...\n Eine durch {0} getrennte Liste mit Verzeichnissen, wobei jedes Verzeichnis\n ein Modulverzeichnis ist.\n --upgrade-module-path ...\n Eine durch {0} getrennte Liste mit Verzeichnissen, wobei jedes Verzeichnis\n ein Verzeichnis mit Modulen ist, die upgradef\u00E4hige\n Module im Laufzeitimage ersetzen\n -m [/]\n --module [/]\n Das anf\u00E4ngliche aufzul\u00F6sende Modul und der Name der auszuf\u00FChrenden\n Hauptklasse, wenn nicht durch das Modul angegeben\n --add-modules [,...]\n Zus\u00E4tzlich zu dem anf\u00E4nglichen Modul aufzul\u00F6sende Root-Module.\n kann auch ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH sein.\n --limit-modules [,...]\n Begrenzt die gesamten beobachtbaren Module\n --list-modules [[,...]]\n F\u00FChrt die beobachtbaren Module auf und beendet den Vorgang\n --dry-run Erstellt VM, f\u00FChrt jedoch die Hauptmethode nicht aus.\n Diese --dry-run-Option kann zur Validierung der Befehlszeilenoptionen\n n\u00FCtzlich sein, wie der Modulsystemkonfiguration.\n -D=\n Setzt eine Systemeigenschaft\n -verbose:[class|gc|jni]\n Aktiviert Verbose-Ausgabe\n -version Druckt Produktversion und beendet den Vorgang\n -showversion Druckt Produktversion und f\u00E4hrt fort\n -? -help --help\n Gibt diese Hilfemeldung aus\n -X Gibt Hilfe zu Nicht-Standardoptionen aus\n -ea[:...|:]\n -enableassertions[:...|:]\n Aktiviert Assertions mit angegebener Granularit\u00E4t\n -da[:...|:]\n -disableassertions[:...|:]\n Deaktiviert Assertions mit angegebener Granularit\u00E4t\n -esa | -enablesystemassertions\n Aktiviert System-Assertions\n -dsa | -disablesystemassertions\n Deaktiviert System-Assertions\n -agentlib:[=]\n L\u00E4dt native Agent Library , Beispiel: -agentlib:jdwp\n siehe auch -agentlib:jdwp=help\n -agentpath:[=]\n L\u00E4dt native Agent Library nach vollst\u00E4ndigem Pfadnamen\n -javaagent:[=]\n L\u00E4dt Java-Programmiersprachen-Agent, siehe java.lang.instrument\n -splash:\n Zeigt Begr\u00FC\u00DFungsbildschirm mit angegebenem Bild an\n HiDPI-skalierte Bilder werden automatisch unterst\u00FCtzt und verwendet,\n sofern verf\u00FCgbar. Der nicht skalierte Bilddateiname, z.B. image.ext,\n muss immer als Argument an die Option -splash \u00FCbergeben werden.\n Das geeignetste skalierte Bild wird automatisch\n ausgew\u00E4hlt.\n Weitere Informationen finden Sie in der Dokumentation zu SplashScreen-API.\n @ Liest Optionen aus der angegebenen Datei\nZur Angabe eines Arguments f\u00FCr eine lange Option k\u00F6nnen Sie --= oder\n-- verwenden.\n -See Weitere Einzelheiten finden Sie unter http://www.oracle.com/technetwork/java/javase/documentation/index.html. - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch Deaktiviert Hintergrundkompilierung\n -Xbootclasspath/a:\n an Ende von Bootstrap-Klassenpfad anh\u00E4ngen\n -Xcheck:jni F\u00FChrt zus\u00E4tzliche Pr\u00FCfungen f\u00FCr JNI-Funktionen aus\n -Xcomp Erzwingt Kompilierung von Methoden beim ersten Aufruf\n -Xdebug Wird zur Abw\u00E4rtskompatiblit\u00E4t bereitgestellt\n -Xdiag Zeigt zus\u00E4tzliche Diagnosemeldungen\n -Xdiag:resolver Zeigt Resolver-Diagnosemeldungen\n -Xfuture Aktiviert strengste Pr\u00FCfungen, als m\u00F6glicher zuk\u00FCnftiger Standardwert erwartet\n -Xint Nur Ausf\u00FChrung im interpretierten Modus\n -Xinternalversion\n Zeigt detailliertere JVM-Versionsinformationen an als die\n -version-Option\n -Xloggc: Protokolliert GC-Status in einer Datei mit Zeitstempeln\n -Xmixed Ausf\u00FChrung im gemischten Modus (Standard)\n -Xmn Setzt die anf\u00E4ngliche und maximale Gr\u00F6\u00DFe (in Byte) des Heaps\n f\u00FCr die junge Generation (Nursery)\n -Xms Setzt die anf\u00E4ngliche Java-Heap-Gr\u00F6\u00DFe\n -Xmx Setzt die maximale Java-Heap-Gr\u00F6\u00DFe\n -Xnoclassgc Deaktiviert die Klassen-Garbage Collection\n -Xprof Gibt CPU-Profilierungsdaten aus\n -Xrs Reduziert die Verwendung von BS-Signalen durch Java/VM (siehe Dokumentation)\n -Xshare:auto Verwendet freigegebene Klassendaten, wenn m\u00F6glich (Standard)\n -Xshare:off Versucht nicht, freigegebene Klassendaten zu verwenden\n -Xshare:on Erfordert die Verwendung von freigegebenen Klassendaten, verl\u00E4uft sonst nicht erfolgreich.\n -XshowSettings Zeigt alle Einstellungen und f\u00E4hrt fort\n -XshowSettings:all\n Zeigt alle Einstellungen und f\u00E4hrt fort\n -XshowSettings:locale\n Zeigt alle gebietsschemabezogenen Einstellungen und f\u00E4hrt fort\n -XshowSettings:properties\n Zeigt alle Eigenschaftseinstellungen und f\u00E4hrt fort\n -XshowSettings:vm Zeigt alle VM-bezogenen Einstellungen und f\u00E4hrt fort\n -Xss Setzt Stackgr\u00F6\u00DFe des Java-Threads\n -Xverify Setzt den Modus der Bytecodeverifizierung\n --add-reads =(,)*\n Aktualisiert , damit gelesen wird, ungeachtet \n der Moduldeklaration. \n kann ALL-UNNAMED sein, um alle unbenannten\n Module zu lesen.\n --add-exports /=(,)*\n Aktualisiert , um in zu exportieren,\n ungeachtet der Moduldeklaration.\n kann ALL-UNNAMED sein, um in alle \n unbenannten Module zu exportieren.\n --disable-@files Deaktiviert das weitere Einblenden der Argumentdatei\n --patch-module =({0})*\n Setzt ein Modul au\u00DFer Kraft oder erweitert ein Modul mit Klassen und Ressourcen\n in JAR-Dateien oder -Verzeichnissen.\n\nDiese Optionen sind Nicht-Standardoptionen und k\u00F6nnen ohne Ank\u00FCndigung ge\u00E4ndert werden.\n +java.launcher.X.usage=\n -Xbatch Deaktiviert Hintergrundkompilierung\n -Xbootclasspath/a: \n an Ende von Bootstrap-Klassenpfad anh\u00E4ngen\n -Xcheck:jni F\u00FChrt zus\u00E4tzliche Pr\u00FCfungen f\u00FCr JNI-Funktionen aus\n -Xcomp Erzwingt Kompilierung von Methoden beim ersten Aufruf\n -Xdebug Wird zur Abw\u00E4rtskompatiblit\u00E4t bereitgestellt\n -Xdiag Zeigt zus\u00E4tzliche Diagnosemeldungen an\n -Xdiag:resolver Zeigt Resolver-Diagnosemeldungen an\n -Xfuture Aktiviert strengste Pr\u00FCfungen, wird als m\u00F6glicher zuk\u00FCnftiger Standardwert erwartet\n -Xint Nur Ausf\u00FChrung im interpretierten Modus\n -Xinternalversion\n Zeigt detailliertere JVM-Versionsinformationen an als die\n Option -version\n -Xloggc: Protokolliert GC-Status in einer Datei mit Zeitstempeln\n -Xmixed Ausf\u00FChrung im gemischten Modus (Standard)\n -Xmn Legt die anf\u00E4ngliche und maximale Gr\u00F6\u00DFe (in Byte) des Heaps\n f\u00FCr die junge Generation (Nursery) fest\n -Xms Legt die anf\u00E4ngliche Java-Heap-Gr\u00F6\u00DFe fest\n -Xmx Legt die maximale Java-Heap-Gr\u00F6\u00DFe fest\n -Xnoclassgc Deaktiviert die Klassen-Garbage Collection\n -Xprof Gibt CPU-Profilierungsdaten aus\n -Xrs Reduziert die Verwendung von BS-Signalen durch Java/VM (siehe Dokumentation)\n -Xshare:auto Verwendet, wenn m\u00F6glich, freigegebene Klassendaten (Standard)\n -Xshare:off Versucht, keine freigegebene Klassendaten zu verwenden\n -Xshare:on Erfordert die Verwendung von freigegebenen Klassendaten, verl\u00E4uft sonst nicht erfolgreich.\n -XshowSettings Zeigt alle Einstellungen an und f\u00E4hrt fort\n -XshowSettings:all\n Zeigt alle Einstellungen an und f\u00E4hrt fort\n -XshowSettings:locale\n Zeigt alle gebietsschemabezogenen Einstellungen an und f\u00E4hrt fort\n -XshowSettings:properties\n Zeigt alle Eigenschaftseinstellungen an und f\u00E4hrt fort\n -XshowSettings:vm Zeigt alle VM-bezogenen Einstellungen an und f\u00E4hrt fort\n -Xss Legt Stack-Gr\u00F6\u00DFe des Java-Threads fest\n -Xverify Legt den Modus der Bytecodeverifizierung fest\n --add-reads =(,)*\n Aktualisiert , damit ungeachtet der\n der Moduldeklaration gelesen wird. \n kann ALL-UNNAMED sein, um alle unbenannten\n Module zu lesen.\n --add-exports /=(,)*\n Aktualisiert , um ungeachtet der Moduldeklaration\n in zu exportieren.\n kann ALL-UNNAMED sein, um in alle \n unbenannten Module zu exportieren.\n --add-opens /=(,)*\n Aktualisiert , um ungeachtet der Moduldeklaration\n in zu \u00F6ffnen.\n --disable-@files Deaktiviert das weitere Einblenden der Argumentdatei\n --patch-module =({0})*\n \u00DCberschreibt oder erweitert ein Modul in JAR-Dateien\n oder -Verzeichnissen mit Klassen und Ressourcen.\n\nDiese zus\u00E4tzlichen Optionen k\u00F6nnen ohne Vorank\u00FCndigung ge\u00E4ndert werden. # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\nDie folgenden Optionen sind f\u00FCr Mac OS X spezifisch:\n -XstartOnFirstThread\n main()-Methode f\u00FCr den ersten (AppKit) Thread ausf\u00FChren\n -Xdock:name=\n Den im Dock angezeigten Standardanwendungsnamen \u00FCberschreiben\n -Xdock:icon=\n Das im Dock angezeigte Standardsymbol \u00FCberschreiben\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_es.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_es.properties index c8370841ab9..12052a2df6a 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_es.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_es.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,22 +24,19 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = Sintaxis: {0} [opciones] class [argumentos...]\n (para ejecutar una clase)\n o {0} [opciones] -jar jarfile [argumentos...]\n (para ejecutar un archivo jar)\n o {0} [opciones] -p -m [/] [argumentos...]\n (para ejecutar la clase principal en un m\u00F3dulo)\ndonde las opciones incluyen:\n +java.launcher.opt.header = Sintaxis: {0} [opciones] class [argumentos...]\n (para ejecutar una clase)\n o {0} [opciones] -jar jarfile [argumentos...]\n (para ejecutar un archivo jar)\n o {0} [opciones] -p -m [/] [argumentos...]\n (para ejecutar la clase principal en un m\u00F3dulo)\ndonde las opciones incluyen:\n\n java.launcher.opt.datamodel =\ -d{0}\t Anticuada, se eliminar\u00E1 en una versi\u00F3n futura\n java.launcher.opt.vmselect =\ {0}\t para seleccionar la VM "{1}"\n java.launcher.opt.hotspot =\ {0}\t es un sin\u00F3nimo de la VM "{1}" [anticuada]\n -java.launcher.ergo.message1 =\ La VM por defecto es {0} -java.launcher.ergo.message2 =\ porque la ejecuci\u00F3n se est\u00E1 llevando a cabo en una m\u00E1quina de clase de servidor.\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =-cp \n -classpath \n --class-path \n Lista separada por {0} de directorios, archivos JAR\n y archivos ZIP para buscar archivos de clase.\n -p \n --module-path ...\n Lista separada por {0} de directorios, cada directorio\n es un directorio de m\u00F3dulos.\n --upgrade-module-path ...\n Lista separada por {0} de directorios, cada directorio\n es un directorio de m\u00F3dulos que sustituye a los m\u00F3dulos\n actualizables en la imagen de tiempo de ejecuci\u00F3n\n -m [/]\n --module [/]\n m\u00F3dulo inicial que resolver y nombre de la clase principal\n que ejecutar si el m\u00F3dulo no la especifica\n --add-modules [,...]\n m\u00F3dulos ra\u00EDz que resolver, adem\u00E1s del m\u00F3dulo inicial.\n tambi\u00E9n puede ser ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n --limit-modules [,...]\n limitar el universo de los m\u00F3dulos observables\n --list-modules [[,...]]\n mostrar los m\u00F3dulos observables y salir\n --dry-run crear VM pero no ejecutar m\u00E9todo principal.\n Esta opci\u00F3n --dry-run puede ser \u00FAtil para validar las\n opciones de l\u00EDnea de comandos como la configuraci\u00F3n del sistema de m\u00F3dulo.\n -D=\n definir una propiedad del sistema\n -verbose:[class|gc|jni]\n activar la salida detallada\n -version imprimir la versi\u00F3n del producto en el flujo de errores y salir\n ---version imprimir la versi\u00F3n del producto en el flujo de salida y salir\n -showversion imprimir la versi\u00F3n del producto en el flujo de errores y continuar\n --show-version\n imprimir la versi\u00F3n del producto en el flujo de salida y continuar\n -? -h -help\n imprimir este mensaje de ayuda en el flujo de errores\n --help imprimir este mensaje de ayuda en el flujo de salida\n -X imprimir la ayuda de opciones adicionales en el flujo de errores\n --help-extra imprimir la ayuda de opciones adicionales en el fujo de salida\n -ea[:...|:]\n -enableassertions[:...|:]\n activar afirmaciones con la granularidad especificada\n -da[:...|:]\n -disableassertions[:...|:]\n desactivar afirmaciones con la granularidad especificada\n -esa | -enablesystemassertions\n activar afirmaciones del sistema\n -dsa | -disablesystemassertions\n desactivar afirmaciones del sistema\n -agentlib:[=]\n cargar biblioteca de agentes nativos , por ejemplo, -agentlib:jdwp\n ver tambi\u00E9n -agentlib:jdwp=help\n -agentpath:[=]\n cargar biblioteca de agentes nativos por nombre de ruta completo\n -javaagent:[=]\n cargar agente de lenguaje de programaci\u00F3n Java, ver java.lang.instrument\n -splash:\n mostrar pantalla de presentaci\u00F3n con la imagen especificada\n Las im\u00E1genes a escala HiDPI est\u00E1n \ +soportadas y se usan autom\u00E1ticamente\n si est\u00E1n disponibles. El nombre de archivo de la imagen sin escala, por ejemplo, image.ext,\n siempre debe transferirse como el argumento en la opci\u00F3n -splash.\n La imagen a escala m\u00E1s adecuada que se haya proporcionado se escoger\u00E1\n autom\u00E1ticamente.\n Consulte la documentaci\u00F3n de la API de la pantalla de presentaci\u00F3n para obtener m\u00E1s informaci\u00F3n.\n en leer opciones del archivo especificado\nPara especificar un argumento para una opci\u00F3n larga, puede usar --= o\n-- . # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Lista separada por {0} de directorios, archivos JAR\n y archivos ZIP para buscar archivos de clase.\n -p \n --module-path ...\n Lista separada por {0} de directorios, cada directorio\n es un directorio de m\u00F3dulos.\n --upgrade-module-path ...\n Lista separada por {0} de directorios, cada directorio\n es un directorio de m\u00F3dulos que sustituye a los m\u00F3dulos\n actualizables en la imagen de tiempo de ejecuci\u00F3n\n -m [/]\n --module [/]\n m\u00F3dulo inicial que resolver y nombre de la clase principal\n que ejecutar si el m\u00F3dulo no la especifica\n --add-modules [,...]\n m\u00F3dulos ra\u00EDz que resolver, adem\u00E1s del m\u00F3dulo inicial.\n tambi\u00E9n puede ser ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n --limit-modules [,...]\n limitar el universo de los m\u00F3dulos observables\n --list-modules [[,...]]\n mostrar los m\u00F3dulos observables y salir\n --dry-run crear VM pero no ejecutar m\u00E9todo principal.\n Esta opci\u00F3n --dry-run puede ser \u00FAtil para validar las\n opciones de l\u00EDnea de comandos como la configuraci\u00F3n del sistema de m\u00F3dulo.\n -D=\n definir una propiedad del sistema\n -verbose:[class|gc|jni]\n activar la salida detallada\n -version imprimir la versi\u00F3n del producto y salir\n -showversion imprimir la versi\u00F3n del producto y continuar\n -? -help --help\n imprimir este mensaje de ayuda\n -X imprimir la ayuda de opciones no est\u00E1ndar\n -ea[:...|:]\n -enableassertions[:...|:]\n activar afirmaciones con la granularidad especificada\n -da[:...|:]\n -disableassertions[:...|:]\n desactivar afirmaciones con la granularidad especificada\n -esa | -enablesystemassertions\n activar afirmaciones del sistema\n -dsa | -disablesystemassertions\n desactivar afirmaciones del sistema\n -agentlib:[=]\n cargar biblioteca de agentes nativos , por ejemplo, -agentlib:jdwp\n ver tambi\u00E9n -agentlib:jdwp=help\n -agentpath:[=]\n cargar biblioteca de agentes nativos por nombre de ruta completo\n -javaagent:[=]\n cargar agente de lenguaje de programaci\u00F3n Java, ver java.lang.instrument\n -splash:\n mostrar pantalla de bienvenida con la imagen especificada\n Las im\u00E1genes a escala HiDPI est\u00E1n soportadas y se usan autom\u00E1ticamente\n si est\u00E1n disponibles. El nombre de archivo de la imagen sin escala, por ejemplo, image.ext,\n siempre debe transferirse como el argumento en la opci\u00F3n -splash.\n La imagen a escala m\u00E1s adecuada que se haya proporcionado se escoger\u00E1\n autom\u00E1ticamente.\n Consulte la documentaci\u00F3n de \ -la API de la pantalla de bienvenida para obtener m\u00E1s informaci\u00F3n.\n en leer opciones del archivo especificado\nPara especificar un argumento para una opci\u00F3n larga, puede usar --= o\n-- .\n -See http://www.oracle.com/technetwork/java/javase/documentation/index.html para obtener m\u00E1s informaci\u00F3n. - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch desactivar compilaci\u00F3n de fondo\n -Xbootclasspath/a:\n agregar al final de la ruta de la clase de inicializaci\u00F3n de datos\n -Xcheck:jni realizar comprobaciones adicionales para las funciones de JNI\n -Xcomp fuerza la compilaci\u00F3n de m\u00E9todos en la primera llamada\n -Xdebug se proporciona para ofrecer compatibilidad con versiones anteriores\n -Xdiag mostrar mensajes de diagn\u00F3stico adicionales\n -Xdiag:resolver mostrar mensajes de diagn\u00F3stico de resoluci\u00F3n\n -Xfuture activar las comprobaciones m\u00E1s estrictas, anticip\u00E1ndose al futuro valor por defecto\n -Xint solo ejecuci\u00F3n de modo interpretado\n -Xinternalversion\n muestra una informaci\u00F3n de la versi\u00F3n de JVM m\u00E1s detallada que la\n opci\u00F3n -version\n -Xloggc: registrar el estado de GC en un archivo con registros de hora\n -Xmixed ejecuci\u00F3n de modo mixto (por defecto)\n -Xmn define el tama\u00F1o inicial y m\u00E1ximo (en bytes) de la pila\n para la generaci\u00F3n m\u00E1s joven (espacio infantil)\n -Xms define el tama\u00F1o inicial de la pila de Java\n -Xmx define el tama\u00F1o m\u00E1ximo de la pila de Java\n -Xnoclassgc desactivar la recolecci\u00F3n de basura de clases\n -Xprof datos de creaci\u00F3n de perfiles de CPU de salida\n -Xrs reducir el uso de se\u00F1ales de sistema operativo por parte de Java/VM (consulte la documentaci\u00F3n)\n -Xshare:auto usar datos de clase compartidos si es posible (valor por defecto)\n -Xshare:off no intentar usar datos de clase compartidos\n -Xshare:on es obligatorio el uso de datos de clase compartidos, de lo contrario se producir\u00E1 un fallo.\n -XshowSettings mostrar toda la configuraci\u00F3n y continuar\n -XshowSettings:all\n mostrar todos los valores y continuar\n -XshowSettings:locale\n mostrar todos los valores relacionados con la configuraci\u00F3n regional y continuar\n -XshowSettings:properties\n mostrar todos los valores de propiedad y continuar\n -XshowSettings:vm mostrar todos los valores relacionados con vm y continuar\n -Xss definir tama\u00F1o de la pila del thread de Java\n -Xverify define el modo del verificador de c\u00F3digo de bytes\n --add-reads =(,)*\n actualiza para leer , independientemente\n de la declaraci\u00F3n del m\u00F3dulo. \n puede ser ALL-UNNAMED para leer todos los\n m\u00F3dulos sin nombre.\n --add-exports /=(,)*\n actualiza para exportar en ,\n independientemente de la declaraci\u00F3n del m\u00F3dulo.\n puede ser ALL-UNNAMED para exportar a todos los\n m\u00F3dulos sin nombre.\n --disable-@files desactivar la ampliaci\u00F3n de archivos de m\u00E1s argumentos\n --patch-module =({0})*\n Aumentar o anular un m\u00F3dulo con clases y recursos\n en directorios y archivos JAR\n\nEstas opciones no son est\u00E1ndar y est\u00E1n sujetas a cambio sin previo aviso.\n +java.launcher.X.usage=-Xbatch desactivar compilaci\u00F3n de fondo\n -Xbootclasspath/a:\n agregar al final de la ruta de la clase de inicializaci\u00F3n de datos\n -Xcheck:jni realizar comprobaciones adicionales para las funciones de JNI\n -Xcomp fuerza la compilaci\u00F3n de m\u00E9todos en la primera llamada\n -Xdebug se proporciona para ofrecer compatibilidad con versiones anteriores\n -Xdiag mostrar mensajes de diagn\u00F3stico adicionales\n -Xdiag:resolver mostrar mensajes de diagn\u00F3stico de resoluci\u00F3n\n -Xfuture activar las comprobaciones m\u00E1s estrictas, anticip\u00E1ndose al futuro valor por defecto\n -Xint solo ejecuci\u00F3n de modo interpretado\n -Xinternalversion\n muestra una informaci\u00F3n de la versi\u00F3n de JVM m\u00E1s detallada que la\n opci\u00F3n -version\n -Xloggc: registrar el estado de GC en un archivo con registros de hora\n -Xmixed ejecuci\u00F3n de modo mixto (por defecto)\n -Xmn define el tama\u00F1o inicial y m\u00E1ximo (en bytes) de la pila\n para la generaci\u00F3n m\u00E1s joven (espacio infantil)\n -Xms define el tama\u00F1o inicial de la pila de Java\n -Xmx define el tama\u00F1o m\u00E1ximo de la pila de Java\n -Xnoclassgc desactivar la recolecci\u00F3n de basura de clases\n -Xprof datos de creaci\u00F3n de perfiles de CPU de salida\n -Xrs reducir el uso de se\u00F1ales de sistema operativo por parte de Java/VM (consulte la documentaci\u00F3n)\n -Xshare:auto usar datos de clase compartidos si es posible (valor por defecto)\n -Xshare:off no intentar usar datos de clase compartidos\n -Xshare:on es obligatorio el uso de datos de clase compartidos, de lo contrario se producir\u00E1 un fallo.\n -XshowSettings mostrar toda la configuraci\u00F3n y continuar\n -XshowSettings:all\n mostrar todos los valores y continuar\n -XshowSettings:locale\n mostrar todos los valores relacionados con la configuraci\u00F3n regional y continuar\n -XshowSettings:properties\n mostrar todos los valores de propiedad y continuar\n -XshowSettings:vm mostrar todos los valores relacionados con vm y continuar\n -Xss definir tama\u00F1o de la pila del thread de Java\n -Xverify define el modo del verificador de c\u00F3digo de bytes\n --add-reads =(,)*\n actualiza para leer , independientemente\n de la declaraci\u00F3n del m\u00F3dulo. \n puede ser ALL-UNNAMED para leer todos los\n m\u00F3dulos sin nombre.\n --add-exports /=(,)*\n actualiza para exportar en ,\n independientemente de la declaraci\u00F3n del m\u00F3dulo.\n puede ser ALL-UNNAMED para exportar a todos los\n m\u00F3dulos sin nombre.\n --add-opens /=(,)*\n actualiza para abrir en\n , independientemente de la declaraci\u00F3n del m\u00F3dulo.\n --disable-@files desactivar la ampliaci\u00F3n de archivos de m\u00E1s argumentos\n --patch-module =({0})*\n Aumentar o anular un m\u00F3dulo con clases y recursos\n en directorios o archivos JAR\n\nEstas opciones \ +son adicionales y est\u00E1n sujetas a cambio sin previo aviso. # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\nLas siguientes opciones son espec\u00EDficas para Mac OS X:\n -XstartOnFirstThread\n ejecutar el m\u00E9todo main() del primer thread (AppKit)\n -Xdock:name=\n sustituir al nombre por defecto de la aplicaci\u00F3n que se muestra en el Dock\n -Xdock:icon=\n sustituir al icono por defecto que se muestra en el Dock\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_fr.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_fr.properties index 974388514ba..49179530b44 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_fr.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_fr.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,23 +24,19 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = Syntaxe : {0} [options] class [args...]\n (pour l''ex\u00E9cution d''une classe)\n ou {0} [options] -jar jarfile [args...]\n (pour l''ex\u00E9cution d''un fichier JAR)\n ou {0} [options] -p -m [/] [args...]\n (pour l''ex\u00E9cution de la classe principale dans un module)\no\u00F9 options comprend les \u00E9l\u00E9ments suivants :\n +java.launcher.opt.header = Syntaxe : {0} [options] class [args...]\n (pour l''ex\u00E9cution d''une classe)\n ou {0} [options] -jar jarfile [args...]\n (pour l''ex\u00E9cution d''un fichier JAR)\n ou {0} [options] -p -m [/] [args...]\n (pour l''ex\u00E9cution de la classe principale dans un module)\n\no\u00F9 options comprend les \u00E9l\u00E9ments suivants :\n\n java.launcher.opt.datamodel =\ -d{0}\t En phase d''abandon, sera enlev\u00E9 dans une version future\n java.launcher.opt.vmselect =\ {0}\t pour s\u00E9lectionner la machine virtuelle "{1}"\n java.launcher.opt.hotspot =\ {0}\t est un synonyme pour la machine virtuelle "{1}" [en phase d''abandon]\n -java.launcher.ergo.message1 =\ La machine virtuelle par d\u00E9faut est {0} -java.launcher.ergo.message2 =\ car vous ex\u00E9cutez une machine de classe de serveur.\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Liste de r\u00E9pertoires, d''archives JAR\n et d''archives ZIP s\u00E9par\u00E9s par des {0} dans laquelle rechercher les fichiers de classe.\n -p \n --module-path ...\n Liste de r\u00E9pertoires s\u00E9par\u00E9s par des {0}, chaque r\u00E9pertoire\n est un r\u00E9pertoire de modules.\n --upgrade-module-path ...\n Liste de r\u00E9pertoires s\u00E9par\u00E9s par des {0}, chaque r\u00E9pertoire\n est un r\u00E9pertoire de modules qui remplacent des modules\n pouvant \u00EAtre mis \u00E0 niveau dans l''image d''ex\u00E9cution\n -m [/]\n --module [/]\n module initial \u00E0 r\u00E9soudre et nom de la classe principale\n \u00E0 ex\u00E9cuter si elle n''est pas indiqu\u00E9e par le module\n --add-modules [,...]\n modules racine \u00E0 r\u00E9soudre en plus du module initial.\n peut \u00E9galement \u00EAtre ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n --limit-modules [,...]\n limitation de l''univers de modules observables\n --list-modules [[,...]]\n \u00E9num\u00E9ration des modules observables et fin de l''op\u00E9ration\n --dry-run cr\u00E9e une machine virtuelle mais n''ex\u00E9cute pas la m\u00E9thode principale.\n Cette option --dry-run peut s''av\u00E9rer utile pour la validation des\n options de ligne de commandes telles que la configuration syst\u00E8me de module.\n -D=\n d\u00E9finition d''une propri\u00E9t\u00E9 syst\u00E8me\n -verbose:[class|gc|jni]\n activation de la sortie en mode verbose\n -version affichage de la version du produit dans le flux d''erreur et fin de l''op\u00E9ration\n --version affichage de la version du produit dans le flux de sortie et fin de l''op\u00E9ration\n -showversion affichage de la version du produit dans le flux d''erreur et poursuite de l''op\u00E9ration\n --show-version\n affichage de la version du produit dans le flux de sortie et poursuite de l''op\u00E9ration\n -? -h -help\n affichage de ce message d''aide dans le flux d''erreur\n --help affichage de ce message d''aide dans le flux de sortie\n -X affichage de l''aide sur les options suppl\u00E9mentaires dans le flux d''erreur\n --help-extra affichage de l''aide sur les options suppl\u00E9mentaires dans le flux de sortie\n -ea[:...|:]\n -enableassertions[:...|:]\n activation des assertions avec la granularit\u00E9 indiqu\u00E9e\n -da[:...|:]\n -disableassertions[:...|:]\n d\u00E9sactivation des assertions avec la granularit\u00E9 indiqu\u00E9e\n -esa | -enablesystemassertions\n activation des assertions syst\u00E8me\n -dsa | -disablesystemassertions\n d\u00E9sactivation des assertions syst\u00E8me\n -agentlib:[=]\n chargement de la biblioth\u00E8que d''agents natifs , par exemple : -agentlib:jdwp\n voir aussi -agentlib:jdwp=help\n -agentpath:[=]\n chargement de la biblioth\u00E8que d''agents natifs via le chemin d''acc\u00E8s complet\n \ +-javaagent:[=]\n chargement de l''agent de langage de programmation Java, voir java.lang.instrument\n -splash:\n affichage de l''\u00E9cran d''accueil avec l''image indiqu\u00E9e\n Les images redimensionn\u00E9es HiDPI sont automatiquement prises en charge et utilis\u00E9es\n si elles sont disponibles. Le nom de fichier d''une image non redimensionn\u00E9e, par ex. image.ext,\n doit toujours \u00EAtre transmis comme argument \u00E0 l''option -splash.\n L''image redimensionn\u00E9e fournie la plus appropri\u00E9e sera automatiquement\n s\u00E9lectionn\u00E9e.\n Pour plus d''informations, reportez-vous \u00E0 la documentation relative \u00E0 l''API SplashScreen.\n @ lecture des options \u00E0 partir du fichier indiqu\u00E9\n\nPour indiquer un argument pour une option longue, vous pouvez utiliser --= ou\n-- .\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Liste de r\u00E9pertoires, d''archives JAR\n et d''archives ZIP s\u00E9par\u00E9s par des {0} dans laquelle rechercher les fichiers de classe.\n -p \n --module-path ...\n Liste de r\u00E9pertoires s\u00E9par\u00E9s par des {0}, chaque r\u00E9pertoire\n est un r\u00E9pertoire de modules.\n --upgrade-module-path ...\n Liste de r\u00E9pertoires s\u00E9par\u00E9s par des {0}, chaque r\u00E9pertoire\n est un r\u00E9pertoire de modules qui remplace des modules\n pouvant \u00EAtre mis \u00E0 niveau dans l''image d''ex\u00E9cution\n -m [/]\n --module [/]\n module initial \u00E0 r\u00E9soudre et nom de la classe principale\n \u00E0 ex\u00E9cuter si elle n''est pas indiqu\u00E9e par le module\n --add-modules [,...]\n modules racine \u00E0 r\u00E9soudre en plus du module initial.\n peut \u00E9galement \u00EAtre ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n --limit-modules [,...]\n limitation de l''univers de modules observables\n --list-modules [[,...]]\n \u00E9num\u00E9ration des modules observables et fin de l''op\u00E9ration\n --dry-run cr\u00E9e une machine virtuelle mais n''ex\u00E9cute pas la m\u00E9thode principale.\n Cette option --dry-run peut s''av\u00E9rer utile pour la validation des\n options de ligne de commandes telles que la configuration syst\u00E8me de module.\n -D=\n d\u00E9finition d''une propri\u00E9t\u00E9 syst\u00E8me\n -verbose:[class|gc|jni]\n activation de la sortie en mode verbose\n -version affichage de la version du produit et fin de l''op\u00E9ration\n -showversion affichage de la version du produit et poursuite de l''op\u00E9ration\n -? -help --help\n affichage du message d''aide\n -X affichage de l''aide sur les options non standard\n -ea[:...|:]\n -enableassertions[:...|:]\n activation des assertions avec la granularit\u00E9 sp\u00E9cifi\u00E9e\n -da[:...|:]\n -disableassertions[:...|:]\n d\u00E9sactivation des assertions avec la granularit\u00E9 sp\u00E9cifi\u00E9e\n -esa | -enablesystemassertions\n activation des assertions syst\u00E8me\n -dsa | -disablesystemassertions\n d\u00E9sactivation des assertions syst\u00E8me\n -agentlib:[=]\n chargement de la biblioth\u00E8que d''agent natif , par exemple : -agentlib:jdwp\n voir aussi -agentlib:jdwp=help\n -agentpath:[=]\n chargement de la biblioth\u00E8que d''agent natif via le chemin d''acc\u00E8s complet\n -javaagent:[=]\n chargement de l''agent du langage de programmation Java, voir java.lang.instrument\n -splash:\n affichage de l''\u00E9cran d''accueil avec l''image indiqu\u00E9e\n Les images redimensionn\u00E9es HiDPI sont automatiquement prises en charge et utilis\u00E9es\n si elles sont disponibles. Le nom de fichier d''une image non redimensionn\u00E9e, par ex. image.ext,\n doit toujours \ -\u00EAtre transmis comme argument \u00E0 l''option -splash.\n L''image redimensionn\u00E9e fournie la plus appropri\u00E9e sera automatiquement\n s\u00E9lectionn\u00E9e.\n Pour plus d''informations, reportez-vous \u00E0 la documentation relative \u00E0 l''API SplashScreen.\n @ lire les options \u00E0 partir du fichier indiqu\u00E9\nPour indiquer un argument pour une option longue, vous pouvez utiliser --= ou\n-- .\n -See http://www.oracle.com/technetwork/java/javase/documentation/index.html pour plus de d\u00E9tails. - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch d\u00E9sactivation de la compilation en arri\u00E8re-plan\n -Xbootclasspath/a:\n ajout \u00E0 la fin du chemin de classe bootstrap\n -Xcheck:jni ex\u00E9cution de contr\u00F4les suppl\u00E9mentaires pour les fonctions JNI\n -Xcomp force la compilation de m\u00E9thodes au premier appel\n -Xdebug fourni pour la compatibilit\u00E9 amont\n -Xdiag affichage de messages de diagnostic suppl\u00E9mentaires\n -Xdiag:resolver affichage de messages de diagnostic du r\u00E9solveur\n -Xfuture activation des contr\u00F4les les plus stricts en vue d''anticiper la future valeur par d\u00E9faut\n -Xint ex\u00E9cution en mode interpr\u00E9t\u00E9 uniquement\n -Xinternalversion\n affiche des informations de version JVM plus d\u00E9taill\u00E9es que\n l''option -version\n -Xloggc: journalisation du statut de l''op\u00E9ration de ramasse-miette dans un fichier avec horodatage\n -Xmixed ex\u00E9cution en mode mixte (valeur par d\u00E9faut)\n -Xmn d\u00E9finit les tailles initiale et maximale (en octets) de la portion de m\u00E9moire\n pour la jeune g\u00E9n\u00E9ration (nursery)\n -Xms d\u00E9finition de la taille initiale des portions de m\u00E9moire Java\n -Xmx d\u00E9finition de la taille maximale des portions de m\u00E9moire Java\n -Xnoclassgc d\u00E9sactivation de l''op\u00E9ration de ramasse-miette de la classe\n -Xprof sortie des donn\u00E9es de profilage d''UC\n -Xrs r\u00E9duction de l''utilisation des signaux OS par Java/la machine virtuelle (voir documentation)\n -Xshare:auto utilisation des donn\u00E9es de classe partag\u00E9es si possible (valeur par d\u00E9faut)\n -Xshare:off aucune tentative d''utilisation des donn\u00E9es de classe partag\u00E9es\n -Xshare:on utilisation des donn\u00E9es de classe partag\u00E9es obligatoire ou \u00E9chec de l''op\u00E9ration\n -XshowSettings affichage de tous les param\u00E8tres et poursuite de l''op\u00E9ration\n -XshowSettings:all\n affichage de tous les param\u00E8tres et poursuite de l''op\u00E9ration\n -XshowSettings:locale\n affichage de tous les param\u00E8tres d''environnement local et poursuite de l''op\u00E9ration\n -XshowSettings:properties\n affichage de tous les param\u00E8tres de propri\u00E9t\u00E9 et poursuite de l''op\u00E9ration\n -XshowSettings:vm affichage de tous les param\u00E8tres de machine virtuelle et poursuite de l''op\u00E9ration\n -Xss d\u00E9finition de la taille de pile de threads Java\n -Xverify d\u00E9finit le mode du v\u00E9rificateur de code ex\u00E9cutable\n --add-reads =(,)*\n met \u00E0 jour pour lire , sans tenir compte\n de la d\u00E9claration de module. \n peut \u00EAtre ALL-UNNAMED pour lire tous les modules\n sans nom.\n --add-exports /=(,)*\n met \u00E0 jour pour exporter vers ,\n sans tenir compte de la d\u00E9claration de module.\n peut \u00EAtre ALL-UNNAMED pour effectuer un export vers tous\n les modules sans nom.\n --disable-@files d\u00E9sactivation d''autres d\u00E9veloppements de fichier d''argument\n --patch-module =({0})*\n Remplacement ou augmentation d''un module avec des classes et des ressources\n dans des \ -fichiers ou des r\u00E9pertoires JAR.\n\nCes options ne sont pas standard et peuvent \u00EAtre modifi\u00E9es sans pr\u00E9avis.\n +java.launcher.X.usage=\n -Xbatch d\u00E9sactivation de la compilation en arri\u00E8re-plan\n -Xbootclasspath/a:\n ajout \u00E0 la fin du chemin de classe bootstrap\n -Xcheck:jni ex\u00E9cution de contr\u00F4les suppl\u00E9mentaires pour les fonctions JNI\n -Xcomp force la compilation de m\u00E9thodes au premier appel\n -Xdebug fourni pour la compatibilit\u00E9 amont\n -Xdiag affichage de messages de diagnostic suppl\u00E9mentaires\n -Xdiag:resolver affichage de messages de diagnostic du r\u00E9solveur\n -Xfuture activation des contr\u00F4les les plus stricts en vue d''anticiper la future valeur par d\u00E9faut\n -Xint ex\u00E9cution en mode interpr\u00E9t\u00E9 uniquement\n -Xinternalversion\n affiche des informations de version JVM plus d\u00E9taill\u00E9es que\n l''option -version\n -Xloggc: journalisation du statut de l''op\u00E9ration de ramasse-miette dans un fichier avec horodatage\n -Xmixed ex\u00E9cution en mode mixte (valeur par d\u00E9faut)\n -Xmn d\u00E9finit les tailles initiale et maximale (en octets) de la portion de m\u00E9moire\n pour la jeune g\u00E9n\u00E9ration (nursery)\n -Xms d\u00E9finition de la taille initiale des portions de m\u00E9moire Java\n -Xmx d\u00E9finition de la taille maximale des portions de m\u00E9moire Java\n -Xnoclassgc d\u00E9sactivation de l''op\u00E9ration de ramasse-miette de la classe\n -Xprof sortie des donn\u00E9es de profilage d''UC\n -Xrs r\u00E9duction de l''utilisation des signaux OS par Java/la machine virtuelle (voir documentation)\n -Xshare:auto utilisation des donn\u00E9es de classe partag\u00E9es si possible (valeur par d\u00E9faut)\n -Xshare:off aucune tentative d''utilisation des donn\u00E9es de classe partag\u00E9es\n -Xshare:on utilisation des donn\u00E9es de classe partag\u00E9es obligatoire ou \u00E9chec de l''op\u00E9ration\n -XshowSettings affichage de tous les param\u00E8tres et poursuite de l''op\u00E9ration\n -XshowSettings:all\n affichage de tous les param\u00E8tres et poursuite de l''op\u00E9ration\n -XshowSettings:locale\n affichage de tous les param\u00E8tres d''environnement local et poursuite de l''op\u00E9ration\n -XshowSettings:properties\n affichage de tous les param\u00E8tres de propri\u00E9t\u00E9 et poursuite de l''op\u00E9ration\n -XshowSettings:vm affichage de tous les param\u00E8tres de machine virtuelle et poursuite de l''op\u00E9ration\n -Xss d\u00E9finition de la taille de pile de threads Java\n -Xverify d\u00E9finit le mode du v\u00E9rificateur de code ex\u00E9cutable\n --add-reads =(,)*\n met \u00E0 jour pour lire , sans tenir compte\n de la d\u00E9claration de module. \n peut \u00EAtre ALL-UNNAMED pour lire tous les modules\n sans nom.\n --add-exports /=(,)*\n met \u00E0 jour pour exporter vers ,\n sans tenir compte de la d\u00E9claration de module.\n peut \u00EAtre ALL-UNNAMED pour effectuer un export vers tous\n les modules sans nom.\n --add-opens /=(,)*\n met \u00E0 jour pour ouvrir vers\n \ +, sans tenir compte de la d\u00E9claration de module\n --disable-@files d\u00E9sactivation d''autres d\u00E9veloppements de fichier d''argument\n --patch-module =({0})*\n Remplacement ou augmentation d''un module avec des classes et des ressources\n dans des fichiers ou des r\u00E9pertoires JAR.\n\nCes options suppl\u00E9mentaires peuvent \u00EAtre modifi\u00E9es sans pr\u00E9avis.\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\nLes options suivantes sont propres \u00E0 Mac OS X :\n -XstartOnFirstThread\n ex\u00E9cute la m\u00E9thode main() sur le premier thread (AppKit)\n -Xdock:name=\n remplace le nom d'application par d\u00E9faut affich\u00E9 dans l'ancrage\n -Xdock:icon=\n remplace l'ic\u00F4ne par d\u00E9faut affich\u00E9e dans l'ancrage\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_it.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_it.properties index d06e6997728..7be6b1f81fd 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_it.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_it.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,22 +24,18 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = Uso: {0} [opzioni] class [argomenti...]\n (per eseguire una classe)\n oppure {0} [opzioni] -jar jarfile [argomenti...]\n (per eseguire un file jar)\n oppure {0} [opzioni] -p -m [/] [argomenti...]\n (per eseguire la classe principale in un modulo)\ndove opzioni include:\n +java.launcher.opt.header = Uso: {0} [opzioni] class [argomenti...]\n (per eseguire una classe)\n oppure {0} [opzioni] -jar jarfile [argomenti...]\n (per eseguire un file jar)\n oppure {0} [opzioni] -p -m [/] [argomenti...]\n (per eseguire la classe principale in un modulo)\ndove opzioni include:\n\n java.launcher.opt.datamodel =\ -d{0}\t opzione non pi\u00F9 valida; verr\u00E0 rimossa in una release futura\n java.launcher.opt.vmselect =\ {0}\t per selezionare la VM "{1}"\n java.launcher.opt.hotspot =\ {0}\t \u00E8 un sinonimo per la VM "{1}" [non valido]\n -java.launcher.ergo.message1 =\ La VM predefinita \u00E8 {0} -java.launcher.ergo.message2 =\ perch\u00E9 si utilizza un computer di classe server.\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Lista separata da {0} di directory, archivi JAR\n e archivi ZIP utilizzata per la ricerca di file di classe.\n -p \n -module-path ...\n Lista separata da {0} di directory; ciascuna directory\n \u00E8 una directory di moduli.\n -upgrade-module-path ...\n Lista separata da {0} di directory; ciascuna directory\n \u00E8 una directory dei moduli che sostituiscono i moduli\n aggiornabili nell''immagine in fase di esecuzione.\n -m [/]\n --module [/]\n Il modulo iniziale da risolvere e il nome della classe\n principale da eseguire se non specificata dal modulo.\n -add-modules [,...]\n Moduli root da risolvere in aggiunta al modulo iniziale.\n pu\u00F2 essere anche ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n -limit-modules [,...]\n Limita l''universe dei moduli osservabili.\n -list-modules[:[,...]]\n Elenca i moduli osservabili ed esce.\n --dry-run Crea la VM ma non esegue il metodo principale.\n Pu\u00F2 essere utile, ad esempio, per la convalida delle opzioni della\n riga di comando utilizzate per la configurazione del sistema di moduli.\n -D=\n Imposta una propriet\u00E0 di sistema.\n -verbose:[class|gc|jni]\n Abilita l''output descrittivo.\n -version Visualizza la versione del prodotto ed esce.\n --version Visualizza la versione del prodotto nel flusso di output ed esce.\n -showversion Visualizza la versione del prodotto nel flusso di errori e continua.\n --show-version\n Visualizza la versione del prodotto nel flusso di output e continua.\n -? -h -help\n Visualizza questo messaggio della Guida nel flusso di errori.\n --help Visualizza questo messaggio della Guida nel flusso di output.\n -X Visualizza la Guida relativa alle opzioni non standard nel flusso di errori.\n --help-extra Visualizza la Guida relativa alle opzioni non standard nel flusso di output.\n -ea[:...|:]\n -enableassertions[:...|:]\n Abilita le asserzioni con la granularit\u00E0 specificata.\n -da[:...|:]\n -disableassertions[:...|:]\n Disabilita le asserzioni con la granularit\u00E0 specificata.\n -esa | -enablesystemassertions\n Abilita le asserzioni di sistema.\n -dsa | -disablesystemassertions\n Disabilita le asserzioni di sistema.\n -agentlib:[=]\n Carica la libreria agenti nativa , ad esempio -agentlib:jdwp.\n Vedere anche -agentlib:jdwp=help.\n -agentpath:[=]\n Carica la libreria agenti nativa con il percorso completo.\n -javaagent:[=]\n Carica l''agente del linguaggio di programmazione Java. Vedere java.lang.instrument.\n -splash:\n Mostra la schermata iniziale con l''immagine specificata.\n Le immagini ridimensionate HiDPI sono supportate e utilizzate automaticamente\n se disponibili. I nomi file delle immagini non ridimensionate, ad esempio image.ext,\n devono \ +essere sempre passati come argomenti all''opzione -splash.\n Verr\u00E0 scelta automaticamente l''immagine ridimensionata pi\u00F9 appropriata\n fornita.\n Per ulteriori informazioni, vedere la documentazione relativa all''API SplashScreen.\n @ Legge le opzioni dal file specificato.\n\nPer specificare un argomento per un''opzione lunga, \u00E8 possibile utilizzare --= o\n-- .\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Lista separata da {0} di directory e di archivi JAR\n e ZIP utilizzata per la ricerca di file di classe.\n -p \n -module-path ...\n Lista separata da {0} di directory; ciascuna directory\n \u00E8 una directory di moduli.\n -upgrade-module-path ...\n Lista separata da {0} di directory; ciascuna directory\n \u00E8 una directory dei moduli che sostituiscono i moduli\n aggiornabili nell''immagine in fase di esecuzione.\n -m [/]\n --module [/]\n Il modulo iniziale da risolvere e il nome della classe\n principale da eseguire se non specificata dal modulo.\n -add-modules [,...]\n Moduli root da risolvere in aggiunta al modulo iniziale.\n pu\u00F2 essere anche ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n -limit-modules [,...]\n Limita l''universe dei moduli osservabili.\n -list-modules[:[,...]]\n Elenca i moduli osservabili ed esce.\n --dry-run Crea la VM ma non esegue il metodo principale.\n Pu\u00F2 essere utile, ad esempio, per la convalida delle opzioni della\n riga di comando utilizzate per la configurazione del sistema di moduli.\n -D=\n Imposta una propriet\u00E0 di sistema.\n -verbose:[class|gc|jni]\n Abilita l''output descrittivo.\n -version Visualizza la versione del prodotto ed esce.\n -showversion Visualizza la versione del prodotto e continua\n -? -help --help\n Visualizza questo messaggio della Guida.\n -X Visualizza la Guida relativa alle opzioni non standard.\n -ea[:...|:]\n -enableassertions[:...|:]\n Abilita le asserzioni con la granularit\u00E0 specificata.\n -da[:...|:]\n -disableassertions[:...|:]\n Disabilita le asserzioni con la granularit\u00E0 specificata.\n -esa | -enablesystemassertions\n Abilita le asserzioni di sistema.\n -dsa | -disablesystemassertions\n Disabilita le asserzioni di sistema.\n -agentlib:[=]\n Carica la libreria agenti nativa , ad esempio -agentlib:jdwp.\n Vedere anche -agentlib:jdwp=help.\n -agentpath:[=]\n Carica la libreria agenti nativa con il percorso completo.\n -javaagent:[=]\n Carica l''agente del linguaggio di programmazione Java. Vedere java.lang.instrument.\n -splash:\n Mostra la schermata iniziale con l''immagine specificata.\n Le immagini ridimensionate HiDPI sono supportate e utilizzate automaticamente\n se disponibili. I nomi file delle immagini non ridimensionate, ad esempio image.ext,\n devono essere sempre passati come argomenti all''opzione -splash.\n Verr\u00E0 scelta automaticamente l''immagine ridimensionata pi\u00F9 appropriata\n fornita.\n Per ulteriori informazioni, vedere la documentazione relativa all''API SplashScreen.\n @ legge le opzioni dal file specificato.\nPer specificare un argomento per un''opzione lunga, \u00E8 possibile \ -utilizzare --= o\n-- . -See Per ulteriori dettagli, vedere http://www.oracle.com/technetwork/java/javase/documentation/index.html. - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch disabilita la compilazione in background\n -Xbootclasspath/a:\n aggiunge alla fine del classpath di bootstrap\n -Xcheck:jni esegue controlli aggiuntivi per le funzioni JNI\n -Xcomp forza la compilazione dei metodi al primo richiamo\n -Xdebug fornito per la compatibilit\u00E0 con le versioni precedenti\n -Xdiag mostra ulteriori messaggi diagnostici\n -Xdiag:resolver mostra i messaggi diagnostici del resolver\n -Xfuture abilita i controlli pi\u00F9 limitativi anticipando le impostazioni predefinite future\n -Xint esecuzione solo in modalit\u00E0 convertita\n -Xinternalversion\n visualizza informazioni pi\u00F9 dettagliate sulla versione JVM rispetto\n all''opzione -version\n -Xloggc: registra lo stato GC in un file con indicatori orari\n -Xmixed esecuzione in modalit\u00E0 mista (impostazione predefinita)\n -Xmn imposta le dimensioni iniziale e massima (in byte) dell''heap\n per la young generation (nursery)\n -Xms imposta la dimensione heap Java iniziale\n -Xmx imposta la dimensione heap Java massima\n -Xnoclassgc disabilta la garbage collection della classe\n -Xprof visualizza i dati di profilo della CPU\n -Xrs riduce l''uso di segnali del sistema operativo da Java/VM (vedere la documentazione)\n -Xshare:auto utilizza i dati di classe condivisi se possibile (impostazione predefinita)\n -Xshare:off non tenta di utilizzare i dati di classe condivisi\n -Xshare:on richiede l''uso dei dati di classe condivisi, altrimenti l''esecuzione non riesce.\n -XshowSettings mostra tutte le impostazioni e continua\n -XshowSettings:all\n mostra tutte le impostazioni e continua\n -XshowSettings:locale\n mostra tutte le impostazioni correlate alle impostazioni nazionali e continua\n -XshowSettings:properties\n mostra tutte le impostazioni delle propriet\u00E0 e continua\n -XshowSettings:vm mostra tutte le impostazioni correlate alla VM e continua\n -Xss imposta la dimensione dello stack di thread Java\n -Xverify imposta la modalit\u00E0 del verificatore bytecode\n --add-reads:=(,)*\n aggiorna per leggere , indipendentemente\n dalla dichiarazione del modulo.\n pu\u00F2 essere ALL-UNNAMED per leggere tutti i\n moduli senza nome.\n -add-exports:/=(,)*\n aggiorna per esportare in ,\n indipendentemente dalla dichiarazione del modulo.\n pu\u00F2 essere ALL-UNNAMED per esportare tutti i\n moduli senza nome.\n --disable-@files disabilita l''ulteriore espansione del file di argomenti\n -patch-module =({0})*\n sostituisce o migliora un modulo con classi e risorse\n in file JAR o directory\n\nQueste opzioni non sono opzioni standard e sono soggette a modifiche senza preavviso.\n +java.launcher.X.usage=\n -Xbatch Disabilita la compilazione in background.\n -Xbootclasspath/a:\n Aggiunge alla fine del classpath di bootstrap.\n -Xcheck:jni Esegue controlli aggiuntivi per le funzioni JNI.\n -Xcomp Forza la compilazione dei metodi al primo richiamo.\n -Xdebug Fornito per la compatibilit\u00E0 con le versioni precedenti.\n -Xdiag Mostra ulteriori messaggi diagnostici.\n -Xdiag:resolver Mostra i messaggi diagnostici del resolver.\n -Xfuture Abilita i controlli pi\u00F9 limitativi anticipando le impostazioni predefinite future.\n -Xint Esecuzione solo in modalit\u00E0 convertita.\n -Xinternalversion\n Visualizza informazioni pi\u00F9 dettagliate sulla versione JVM rispetto\n all''opzione -version.\n -Xloggc: Registra lo stato GC in un file con indicatori orari.\n -Xmixed Esecuzione in modalit\u00E0 mista (impostazione predefinita).\n -Xmn Imposta le dimensioni iniziale e massima (in byte) dell''heap\n per la young generation (nursery).\n -Xms Imposta la dimensione heap Java iniziale.\n -Xmx Imposta la dimensione heap Java massima.\n -Xnoclassgc Disabilta la garbage collection della classe.\n -Xprof Visualizza i dati di profilo della CPU.\n -Xrs Riduce l''uso di segnali del sistema operativo da Java/VM (vedere la documentazione).\n -Xshare:auto Utilizza i dati di classe condivisi se possibile (impostazione predefinita).\n -Xshare:off Non tenta di utilizzare i dati di classe condivisi.\n -Xshare:on Richiede l''uso dei dati di classe condivisi, altrimenti l''esecuzione non riesce.\n -XshowSettings Mostra tutte le impostazioni e continua.\n -XshowSettings:all\n Mostra tutte le impostazioni e continua.\n -XshowSettings:locale\n Mostra tutte le impostazioni correlate alle impostazioni nazionali e continua.\n -XshowSettings:properties\n Mostra tutte le impostazioni delle propriet\u00E0 e continua.\n -XshowSettings:vm Mostra tutte le impostazioni correlate alla VM e continua.\n -Xss Imposta la dimensione dello stack di thread Java.\n -Xverify Imposta la modalit\u00E0 del verificatore bytecode.\n --add-reads:=(,)*\n Aggiorna per leggere , indipendentemente\n dalla dichiarazione del modulo.\n pu\u00F2 essere ALL-UNNAMED per leggere tutti i\n moduli senza nome.\n -add-exports:/=(,)*\n Aggiorna per esportare in ,\n indipendentemente dalla dichiarazione del modulo.\n pu\u00F2 essere ALL-UNNAMED per esportare tutti i\n moduli senza nome.\n --add-opens /=(,)*\n Aggiorna per aprire in\n , indipendentemente dalla dichiarazione del modulo.\n --disable-@files Disabilita l''ulteriore espansione del file di argomenti.\n -patch-module =({0})*\n Sostituisce o migliora un modulo con classi e risorse\n in file JAR o directory.\n\nQueste opzioni non sono opzioni standard e sono soggette a modifiche senza preavviso.\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\nLe opzioni riportate di seguito sono specifiche del sistema operativo Mac OS X:\n -XstartOnFirstThread\n Esegue il metodo main() sul primo thread (AppKit).\n -Xdock:name=\n Sostituisce il nome applicazione predefinito visualizzato nel dock\n -Xdock:icon=\n Sostituisce l'icona predefinita visualizzata nel dock\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ja.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ja.properties index 996a8065a87..57453ce57e4 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ja.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,23 +24,20 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = \u4F7F\u7528\u65B9\u6CD5: {0} [options] class [args...]\n (\u30AF\u30E9\u30B9\u3092\u5B9F\u884C\u3059\u308B\u5834\u5408)\n \u307E\u305F\u306F {0} [options] -jar jarfile [args...]\n (jar\u30D5\u30A1\u30A4\u30EB\u3092\u5B9F\u884C\u3059\u308B\u5834\u5408)\n \u307E\u305F\u306F {0} [options] -p -m [/] [args...]\n (\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30E1\u30A4\u30F3\u30FB\u30AF\u30E9\u30B9\u3092\u5B9F\u884C\u3059\u308B\u5834\u5408)\n\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059:\n +java.launcher.opt.header = \u4F7F\u7528\u65B9\u6CD5: {0} [options] class [args...]\n (\u30AF\u30E9\u30B9\u3092\u5B9F\u884C\u3059\u308B\u5834\u5408)\n \u307E\u305F\u306F {0} [options] -jar jarfile [args...]\n (jar\u30D5\u30A1\u30A4\u30EB\u3092\u5B9F\u884C\u3059\u308B\u5834\u5408)\n \u307E\u305F\u306F {0} [options] -p -m [/] [args...]\n (\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30E1\u30A4\u30F3\u30FB\u30AF\u30E9\u30B9\u3092\u5B9F\u884C\u3059\u308B\u5834\u5408)\n\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059:\n\n java.launcher.opt.datamodel =\ -d{0}\t \u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u4E88\u5B9A\u3067\u3059\n java.launcher.opt.vmselect =\ {0}\t "{1}" VM\u3092\u9078\u629E\u3059\u308B\u5834\u5408\n java.launcher.opt.hotspot =\ {0}\t \u306F"{1}" VM\u306E\u30B7\u30CE\u30CB\u30E0\u3067\u3059 [\u975E\u63A8\u5968]\n -java.launcher.ergo.message1 =\ \u30C7\u30D5\u30A9\u30EB\u30C8VM\u306F{0}\u3067\u3059 -java.launcher.ergo.message2 =\ \u3053\u308C\u306F\u30B5\u30FC\u30D0\u30FC\u30AF\u30E9\u30B9\u306E\u30DE\u30B7\u30F3\u3067\u5B9F\u884C\u3057\u3066\u3044\u308B\u305F\u3081\u3067\u3059\u3002\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp <\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB\u306E\u30AF\u30E9\u30B9\u691C\u7D22\u30D1\u30B9>\n -classpath <\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB\u306E\u30AF\u30E9\u30B9\u691C\u7D22\u30D1\u30B9>\n --class-path <\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB\u306E\u30AF\u30E9\u30B9\u691C\u7D22\u30D1\u30B9>\n \u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3001JAR\u30A2\u30FC\u30AB\u30A4\u30D6\n \u304A\u3088\u3073ZIP\u30A2\u30FC\u30AB\u30A4\u30D6\u306E{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30EA\u30B9\u30C8\u3002\n -p <\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30D1\u30B9>\n --module-path <\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30D1\u30B9>...\n \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30EA\u30B9\u30C8\u3002\u5404\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\n \u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u3059\u3002\n --upgrade-module-path <\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30D1\u30B9>...\n \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30EA\u30B9\u30C8\u3002\u5404\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\n \u30E9\u30F3\u30BF\u30A4\u30E0\u30FB\u30A4\u30E1\u30FC\u30B8\u3067\u30A2\u30C3\u30D7\u30B0\u30EC\u30FC\u30C9\u53EF\u80FD\u306A\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\n \u7F6E\u63DB\u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u3059\n -m [/]\n --module [/]\n \u89E3\u6C7A\u3059\u308B\u521D\u671F\u30E2\u30B8\u30E5\u30FC\u30EB\u304A\u3088\u3073\u30E2\u30B8\u30E5\u30FC\u30EB\u3067\u6307\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u306B\n \u5B9F\u884C\u3059\u308B\u30E1\u30A4\u30F3\u30FB\u30AF\u30E9\u30B9\u306E\u540D\u524D\n --add-modules [,...]\n \u521D\u671F\u30E2\u30B8\u30E5\u30FC\u30EB\u306B\u52A0\u3048\u3066\u89E3\u6C7A\u3059\u308B\u30EB\u30FC\u30C8\u30FB\u30E2\u30B8\u30E5\u30FC\u30EB\u3002\n \u306B\u306F\u3001ALL-DEFAULT\u3001ALL-SYSTEM\u3001\n ALL-MODULE-PATH\u3082\u4F7F\u7528\u3067\u304D\u308B\u3002\n --limit-modules [,...]\n \u53C2\u7167\u53EF\u80FD\u306A\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u9818\u57DF\u3092\u5236\u9650\u3059\u308B\n --list-modules [[,...]]\n \u53C2\u7167\u53EF\u80FD\u306A\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u4E00\u89A7\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3059\u308B\n --dry-run VM\u3092\u4F5C\u6210\u3059\u308B\u304C\u3001\u30E1\u30A4\u30F3\u30FB\u30E1\u30BD\u30C3\u30C9\u306F\u5B9F\u884C\u3057\u306A\u3044\u3002\n \u3053\u306E--dry-run\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30B7\u30B9\u30C6\u30E0\u69CB\u6210\u306A\u3069\u306E\n \u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u691C\u8A3C\u3059\u308B\u5834\u5408\u306B\u4FBF\u5229\u3067\u3059\u3002\n -D=\n \u30B7\u30B9\u30C6\u30E0\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u8A2D\u5B9A\u3059\u308B\n -verbose:[class|gc|jni]\n \u8A73\u7D30\u306A\u51FA\u529B\u3092\u884C\u3046\n -version \u88FD\u54C1\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u30A8\u30E9\u30FC\u30FB\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3059\u308B\n --version \u88FD\u54C1\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u51FA\u529B\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3059\u308B\n \ +-showversion \u88FD\u54C1\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u30A8\u30E9\u30FC\u30FB\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3057\u3066\u7D9A\u884C\u3059\u308B\n --show-version\n \u88FD\u54C1\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u51FA\u529B\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3057\u3066\u7D9A\u884C\u3059\u308B\n -? -h -help\n \u3053\u306E\u30D8\u30EB\u30D7\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u30A8\u30E9\u30FC\u30FB\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3059\u308B\n --help \u3053\u306E\u30D8\u30EB\u30D7\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3059\u308B\n -X \u8FFD\u52A0\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u95A2\u3059\u308B\u30D8\u30EB\u30D7\u3092\u30A8\u30E9\u30FC\u30FB\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3059\u308B\n --help-extra \u8FFD\u52A0\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u95A2\u3059\u308B\u30D8\u30EB\u30D7\u3092\u51FA\u529B\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u51FA\u529B\u3059\u308B\n -ea[:...|:]\n -enableassertions[:...|:]\n \u6307\u5B9A\u3057\u305F\u7C92\u5EA6\u3067\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u6709\u52B9\u306B\u3059\u308B\n -da[:...|:]\n -disableassertions[:...|:]\n \u6307\u5B9A\u3057\u305F\u7C92\u5EA6\u3067\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3059\u308B\n -esa | -enablesystemassertions\n \u30B7\u30B9\u30C6\u30E0\u30FB\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u6709\u52B9\u306B\u3059\u308B\n -dsa | -disablesystemassertions\n \u30B7\u30B9\u30C6\u30E0\u30FB\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3059\u308B\n -agentlib:[=]\n \u30CD\u30A4\u30C6\u30A3\u30D6\u30FB\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30E9\u30A4\u30D6\u30E9\u30EA\u3092\u30ED\u30FC\u30C9\u3059\u308B\u3002\u4F8B: -agentlib:jdwp\n -agentlib:jdwp=help\u3082\u53C2\u7167\n -agentpath:[=]\n \u30D5\u30EB\u30D1\u30B9\u540D\u3067\u30CD\u30A4\u30C6\u30A3\u30D6\u30FB\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30E9\u30A4\u30D6\u30E9\u30EA\u3092\u30ED\u30FC\u30C9\u3059\u308B\n -javaagent:[=]\n Java\u30D7\u30ED\u30B0\u30E9\u30DF\u30F3\u30B0\u8A00\u8A9E\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u3092\u30ED\u30FC\u30C9\u3059\u308B\u3002java.lang.instrument\u3092\u53C2\u7167\n -splash:\n \u6307\u5B9A\u3057\u305F\u30A4\u30E1\u30FC\u30B8\u3067\u30B9\u30D7\u30E9\u30C3\u30B7\u30E5\u753B\u9762\u3092\u8868\u793A\u3059\u308B\n HiDPI\u306B\u30B9\u30B1\u30FC\u30EA\u30F3\u30B0\u3055\u308C\u305F\u30A4\u30E1\u30FC\u30B8\u304C\u81EA\u52D5\u7684\u306B\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3001\n \u4F7F\u7528\u3067\u304D\u308C\u3070\u4F7F\u7528\u3055\u308C\u307E\u3059\u3002\u5FC5\u305A\u3001\u30B9\u30B1\u30FC\u30EA\u30F3\u30B0\n \u3055\u308C\u306A\u3044\u30A4\u30E1\u30FC\u30B8\u306E\u30D5\u30A1\u30A4\u30EB\u540D\u3001\u305F\u3068\u3048\u3070image.ext\u3092\u3001\n \u5F15\u6570\u3068\u3057\u3066-splash\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n \u6307\u5B9A\u3055\u308C\u305F\u6700\u3082\u9069\u5207\u306A\u30B9\u30B1\u30FC\u30EA\u30F3\u30B0\u6E08\u30A4\u30E1\u30FC\u30B8\u304C\u81EA\u52D5\u7684\u306B\n \u9078\u629E\u3055\u308C\u307E\u3059\u3002\n \u8A73\u7D30\u306FSplashScreen API\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n @ \ +\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u8AAD\u307F\u53D6\u308B\n\nlong\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u5F15\u6570\u3092\u6307\u5B9A\u3059\u308B\u306B\u306F\u3001--=\u307E\u305F\u306F-- \u3092\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp <\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB\u306E\u30AF\u30E9\u30B9\u691C\u7D22\u30D1\u30B9>\n -classpath <\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB\u306E\u30AF\u30E9\u30B9\u691C\u7D22\u30D1\u30B9>\n --class-path <\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB\u306E\u30AF\u30E9\u30B9\u691C\u7D22\u30D1\u30B9>\n \u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3001\n JAR\u30A2\u30FC\u30AB\u30A4\u30D6\u304A\u3088\u3073ZIP\u30A2\u30FC\u30AB\u30A4\u30D6\u306E{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30EA\u30B9\u30C8\u3002\n -p <\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30D1\u30B9>\n --module-path <\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30D1\u30B9>...\n \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30EA\u30B9\u30C8\u3002\u5404\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\n \u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u3059\u3002\n --upgrade-module-path <\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30D1\u30B9>...\n \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30EA\u30B9\u30C8\u3002\u5404\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\n \u30E9\u30F3\u30BF\u30A4\u30E0\u30FB\u30A4\u30E1\u30FC\u30B8\u3067\u30A2\u30C3\u30D7\u30B0\u30EC\u30FC\u30C9\u53EF\u80FD\u306A\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\u7F6E\u63DB\u3059\u308B\n \u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u3059\n -m [/]\n --module [/]\n \u89E3\u6C7A\u3059\u308B\u521D\u671F\u30E2\u30B8\u30E5\u30FC\u30EB\u304A\u3088\u3073\u30E2\u30B8\u30E5\u30FC\u30EB\u3067\u6307\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u306B\n \u5B9F\u884C\u3059\u308B\u30E1\u30A4\u30F3\u30FB\u30AF\u30E9\u30B9\u306E\u540D\u524D\n --add-modules [,...]\n \u521D\u671F\u30E2\u30B8\u30E5\u30FC\u30EB\u306B\u52A0\u3048\u3066\u89E3\u6C7A\u3059\u308B\u30EB\u30FC\u30C8\u30FB\u30E2\u30B8\u30E5\u30FC\u30EB\u3002\n \u306FALL-DEFAULT\u3001ALL-SYSTEM\u3001ALL-MODULE-PATH\n \u306B\u3059\u308B\u3053\u3068\u3082\u3067\u304D\u307E\u3059\u3002\n --limit-modules [,...]\n \u53C2\u7167\u53EF\u80FD\u306A\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u9818\u57DF\u3092\u5236\u9650\u3059\u308B\n --list-modules [[,...]]\n \u53C2\u7167\u53EF\u80FD\u306A\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u4E00\u89A7\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3059\u308B\n --dry-run VM\u3092\u4F5C\u6210\u3059\u308B\u304C\u3001\u30E1\u30A4\u30F3\u30FB\u30E1\u30BD\u30C3\u30C9\u306F\u5B9F\u884C\u3057\u306A\u3044\u3002\n \u3053\u306E--dry-run\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001\u30E2\u30B8\u30E5\u30FC\u30EB\u30FB\u30B7\u30B9\u30C6\u30E0\u69CB\u6210\u306A\u3069\u306E\n \u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u691C\u8A3C\u3059\u308B\u5834\u5408\u306B\u4FBF\u5229\u3067\u3059\u3002\n -D=\n \u30B7\u30B9\u30C6\u30E0\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u8A2D\u5B9A\u3059\u308B\n -verbose:[class|gc|jni]\n \u8A73\u7D30\u306A\u51FA\u529B\u3092\u884C\u3046\n -version \u88FD\u54C1\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3059\u308B\n -showversion \u88FD\u54C1\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u51FA\u529B\u3057\u3066\u7D9A\u884C\u3059\u308B\n -? -help --help\n \ -\u3053\u306E\u30D8\u30EB\u30D7\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B\n -X \u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u95A2\u3059\u308B\u30D8\u30EB\u30D7\u3092\u51FA\u529B\u3059\u308B\n -ea[:...|:]\n -enableassertions[:...|:]\n \u6307\u5B9A\u3057\u305F\u7C92\u5EA6\u3067\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u6709\u52B9\u306B\u3059\u308B\n -da[:...|:]\n -disableassertions[:...|:]\n \u6307\u5B9A\u3057\u305F\u7C92\u5EA6\u3067\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3059\u308B\n -esa | -enablesystemassertions\n \u30B7\u30B9\u30C6\u30E0\u30FB\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u6709\u52B9\u306B\u3059\u308B\n -dsa | -disablesystemassertions\n \u30B7\u30B9\u30C6\u30E0\u30FB\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3059\u308B\n -agentlib:[=]\n \u30CD\u30A4\u30C6\u30A3\u30D6\u30FB\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30E9\u30A4\u30D6\u30E9\u30EA\u3092\u30ED\u30FC\u30C9\u3059\u308B\u3002\u4F8B: -agentlib:jdwp\n -agentlib:jdwp=help\u3082\u53C2\u7167\n -agentpath:[=]\n \u30D5\u30EB\u30D1\u30B9\u540D\u3067\u30CD\u30A4\u30C6\u30A3\u30D6\u30FB\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30E9\u30A4\u30D6\u30E9\u30EA\u3092\u30ED\u30FC\u30C9\u3059\u308B\n -javaagent:[=]\n Java\u30D7\u30ED\u30B0\u30E9\u30DF\u30F3\u30B0\u8A00\u8A9E\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u3092\u30ED\u30FC\u30C9\u3059\u308B\u3002java.lang.instrument\u3092\u53C2\u7167\n -splash:\n \u6307\u5B9A\u3057\u305F\u30A4\u30E1\u30FC\u30B8\u3067\u30B9\u30D7\u30E9\u30C3\u30B7\u30E5\u753B\u9762\u3092\u8868\u793A\u3059\u308B\n \u53EF\u80FD\u3067\u3042\u308C\u3070\u3001HiDPI\u30B9\u30B1\u30FC\u30EB\u306E\u30A4\u30E1\u30FC\u30B8\u304C\u81EA\u52D5\u7684\u306B\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u4F7F\u7528\u3055\u308C\u307E\u3059\u3002\n \u30B9\u30B1\u30FC\u30EB\u306A\u3057\u306E\u30A4\u30E1\u30FC\u30B8\u306E\u30D5\u30A1\u30A4\u30EB\u540D(image.ext\u306A\u3069)\u306F\u3001\n \u5E38\u306B-splash\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u3068\u3057\u3066\u6E21\u3055\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n \u6307\u5B9A\u3055\u308C\u305F\u6700\u9069\u306A\u30B9\u30B1\u30FC\u30EB\u306E\u30A4\u30E1\u30FC\u30B8\u304C\u81EA\u52D5\u7684\u306B\n \u9078\u629E\u3055\u308C\u307E\u3059\u3002\n \u8A73\u7D30\u306FSplashScreen API\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n @ \u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u8AAD\u307F\u53D6\u308B\n\u9577\u3044\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u3092\u6307\u5B9A\u3059\u308B\u5834\u5408\u3001--=\u307E\u305F\u306F\n-- \u3092\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002\n -See \u8A73\u7D30\u306F\u3001http://www.oracle.com/technetwork/java/javase/documentation/index.html\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch \u30D0\u30C3\u30AF\u30B0\u30E9\u30A6\u30F3\u30C9\u306E\u30B3\u30F3\u30D1\u30A4\u30EB\u3092\u7121\u52B9\u306B\u3059\u308B\n -Xbootclasspath/a:<{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB>\n \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306E\u6700\u5F8C\u306B\u8FFD\u52A0\u3059\u308B\n -Xcheck:jni JNI\u95A2\u6570\u306B\u5BFE\u3059\u308B\u8FFD\u52A0\u306E\u30C1\u30A7\u30C3\u30AF\u3092\u5B9F\u884C\u3059\u308B\n -Xcomp \u521D\u56DE\u547C\u51FA\u3057\u6642\u306B\u30E1\u30BD\u30C3\u30C9\u306E\u30B3\u30F3\u30D1\u30A4\u30EB\u3092\u5F37\u5236\u3059\u308B\n -Xdebug \u4E0B\u4F4D\u4E92\u63DB\u6027\u306E\u305F\u3081\u306B\u63D0\u4F9B\n -Xdiag \u8FFD\u52A0\u306E\u8A3A\u65AD\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3059\u308B\n -Xdiag:resolver \u30EA\u30BE\u30EB\u30D0\u8A3A\u65AD\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3059\u308B\n -Xfuture \u5C06\u6765\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u898B\u8D8A\u3057\u3066\u3001\u6700\u3082\u53B3\u5BC6\u306A\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u306B\u3059\u308B\n -Xint \u30A4\u30F3\u30BF\u30D7\u30EA\u30BF\u30FB\u30E2\u30FC\u30C9\u306E\u5B9F\u884C\u306E\u307F\n -Xinternalversion\n -version\u30AA\u30D7\u30B7\u30E7\u30F3\u3088\u308A\u8A73\u7D30\u306AJVM\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\n \u8868\u793A\u3059\u308B\n -Xloggc: \u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u304C\u4ED8\u3044\u305F\u30D5\u30A1\u30A4\u30EB\u306BGC\u30B9\u30C6\u30FC\u30BF\u30B9\u306E\u30ED\u30B0\u3092\u8A18\u9332\u3059\u308B\n -Xmixed \u6DF7\u5408\u30E2\u30FC\u30C9\u306E\u5B9F\u884C(\u30C7\u30D5\u30A9\u30EB\u30C8)\n -Xmn \u82E5\u3044\u4E16\u4EE3(\u30CA\u30FC\u30B5\u30EA)\u306E\u30D2\u30FC\u30D7\u306E\u521D\u671F\u304A\u3088\u3073\u6700\u5927\u30B5\u30A4\u30BA(\u30D0\u30A4\u30C8\u5358\u4F4D)\n \u3092\u8A2D\u5B9A\u3059\u308B\n -Xms Java\u306E\u521D\u671F\u30D2\u30FC\u30D7\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n -Xmx Java\u306E\u6700\u5927\u30D2\u30FC\u30D7\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n -Xnoclassgc \u30AF\u30E9\u30B9\u306E\u30AC\u30D9\u30FC\u30B8\u30FB\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3059\u308B\n -Xprof CPU\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u30FB\u30C7\u30FC\u30BF\u3092\u51FA\u529B\u3059\u308B\n -Xrs Java/VM\u306B\u3088\u308BOS\u30B7\u30B0\u30CA\u30EB\u306E\u4F7F\u7528\u3092\u524A\u6E1B\u3059\u308B(\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167)\n -Xshare:auto \u53EF\u80FD\u3067\u3042\u308C\u3070\u5171\u6709\u30AF\u30E9\u30B9\u306E\u30C7\u30FC\u30BF\u3092\u4F7F\u7528\u3059\u308B(\u30C7\u30D5\u30A9\u30EB\u30C8)\n -Xshare:off \u5171\u6709\u30AF\u30E9\u30B9\u306E\u30C7\u30FC\u30BF\u3092\u4F7F\u7528\u3057\u3088\u3046\u3068\u3057\u306A\u3044\n -Xshare:on \u5171\u6709\u30AF\u30E9\u30B9\u30FB\u30C7\u30FC\u30BF\u306E\u4F7F\u7528\u3092\u5FC5\u9808\u306B\u3057\u3001\u3067\u304D\u306A\u3051\u308C\u3070\u5931\u6557\u3059\u308B\u3002\n -XshowSettings \u3059\u3079\u3066\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:all\n \u3059\u3079\u3066\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:locale\n \u3059\u3079\u3066\u306E\u30ED\u30B1\u30FC\u30EB\u95A2\u9023\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:properties\n \ -\u3059\u3079\u3066\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:vm \u3059\u3079\u3066\u306EVM\u95A2\u9023\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -Xss Java\u306E\u30B9\u30EC\u30C3\u30C9\u30FB\u30B9\u30BF\u30C3\u30AF\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n -Xverify \u30D0\u30A4\u30C8\u30B3\u30FC\u30C9\u691C\u8A3C\u6A5F\u80FD\u306E\u30E2\u30FC\u30C9\u3092\u8A2D\u5B9A\u3059\u308B\n --add-reads =(,)*\n \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001\u3092\u66F4\u65B0\u3057\u3066\n \u3092\u8AAD\u307F\u53D6\u308A\u307E\u3059\u3002 \n \u3092ALL-UNNAMED\u306B\u8A2D\u5B9A\u3059\u308B\u3068\u3001\u3059\u3079\u3066\u306E\u540D\u524D\u306E\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\n \u8AAD\u307F\u53D6\u308C\u307E\u3059\u3002\n --add-exports /=(,)*\n \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001\u3092\u66F4\u65B0\u3057\u3066\u3092\u306B\n \u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\n \u3092ALL-UNNAMED\u306B\u8A2D\u5B9A\u3059\u308B\u3068\u3001\u3059\u3079\u3066\u306E\u540D\u524D\u306E\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u306B\n \u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3067\u304D\u307E\u3059\u3002\n --disable-@files \u3055\u3089\u306A\u308B\u5F15\u6570\u30D5\u30A1\u30A4\u30EB\u62E1\u5F35\u3092\u7121\u52B9\u306B\u3059\u308B\n --patch-module =({0})*\n JAR\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30EA\u30BD\u30FC\u30B9\u3067\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u307E\u305F\u306F\n \u62E1\u5F35\u3057\u307E\u3059\u3002\n\n\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002\n +java.launcher.X.usage=\n -Xbatch \u30D0\u30C3\u30AF\u30B0\u30E9\u30A6\u30F3\u30C9\u306E\u30B3\u30F3\u30D1\u30A4\u30EB\u3092\u7121\u52B9\u306B\u3059\u308B\n -Xbootclasspath/a:<{0}\u3067\u533A\u5207\u3089\u308C\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304A\u3088\u3073zip/jar\u30D5\u30A1\u30A4\u30EB>\n \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306E\u6700\u5F8C\u306B\u8FFD\u52A0\u3059\u308B\n -Xcheck:jni JNI\u95A2\u6570\u306B\u5BFE\u3059\u308B\u8FFD\u52A0\u306E\u30C1\u30A7\u30C3\u30AF\u3092\u5B9F\u884C\u3059\u308B\n -Xcomp \u521D\u56DE\u547C\u51FA\u3057\u6642\u306B\u30E1\u30BD\u30C3\u30C9\u306E\u30B3\u30F3\u30D1\u30A4\u30EB\u3092\u5F37\u5236\u3059\u308B\n -Xdebug \u4E0B\u4F4D\u4E92\u63DB\u6027\u306E\u305F\u3081\u306B\u63D0\u4F9B\n -Xdiag \u8FFD\u52A0\u306E\u8A3A\u65AD\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3059\u308B\n -Xdiag:resolver \u30EA\u30BE\u30EB\u30D0\u8A3A\u65AD\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3059\u308B\n -Xfuture \u5C06\u6765\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u898B\u8D8A\u3057\u3066\u3001\u6700\u3082\u53B3\u5BC6\u306A\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u306B\u3059\u308B\n -Xint \u30A4\u30F3\u30BF\u30D7\u30EA\u30BF\u30FB\u30E2\u30FC\u30C9\u306E\u5B9F\u884C\u306E\u307F\n -Xinternalversion\n -version\u30AA\u30D7\u30B7\u30E7\u30F3\u3088\u308A\u8A73\u7D30\u306AJVM\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\n \u8868\u793A\u3059\u308B\n -Xloggc: \u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u304C\u4ED8\u3044\u305F\u30D5\u30A1\u30A4\u30EB\u306BGC\u30B9\u30C6\u30FC\u30BF\u30B9\u306E\u30ED\u30B0\u3092\u8A18\u9332\u3059\u308B\n -Xmixed \u6DF7\u5408\u30E2\u30FC\u30C9\u306E\u5B9F\u884C(\u30C7\u30D5\u30A9\u30EB\u30C8)\n -Xmn \u82E5\u3044\u4E16\u4EE3(\u30CA\u30FC\u30B5\u30EA)\u306E\u30D2\u30FC\u30D7\u306E\u521D\u671F\u304A\u3088\u3073\u6700\u5927\u30B5\u30A4\u30BA(\u30D0\u30A4\u30C8\u5358\u4F4D)\n \u3092\u8A2D\u5B9A\u3059\u308B\n -Xms Java\u306E\u521D\u671F\u30D2\u30FC\u30D7\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n -Xmx Java\u306E\u6700\u5927\u30D2\u30FC\u30D7\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n -Xnoclassgc \u30AF\u30E9\u30B9\u306E\u30AC\u30D9\u30FC\u30B8\u30FB\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3059\u308B\n -Xprof CPU\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u30FB\u30C7\u30FC\u30BF\u3092\u51FA\u529B\u3059\u308B\n -Xrs Java/VM\u306B\u3088\u308BOS\u30B7\u30B0\u30CA\u30EB\u306E\u4F7F\u7528\u3092\u524A\u6E1B\u3059\u308B(\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167)\n -Xshare:auto \u53EF\u80FD\u3067\u3042\u308C\u3070\u5171\u6709\u30AF\u30E9\u30B9\u306E\u30C7\u30FC\u30BF\u3092\u4F7F\u7528\u3059\u308B(\u30C7\u30D5\u30A9\u30EB\u30C8)\n -Xshare:off \u5171\u6709\u30AF\u30E9\u30B9\u306E\u30C7\u30FC\u30BF\u3092\u4F7F\u7528\u3057\u3088\u3046\u3068\u3057\u306A\u3044\n -Xshare:on \u5171\u6709\u30AF\u30E9\u30B9\u30FB\u30C7\u30FC\u30BF\u306E\u4F7F\u7528\u3092\u5FC5\u9808\u306B\u3057\u3001\u3067\u304D\u306A\u3051\u308C\u3070\u5931\u6557\u3059\u308B\u3002\n -XshowSettings \u3059\u3079\u3066\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:all\n \u3059\u3079\u3066\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:locale\n \u3059\u3079\u3066\u306E\u30ED\u30B1\u30FC\u30EB\u95A2\u9023\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:properties\n \ +\u3059\u3079\u3066\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -XshowSettings:vm \u3059\u3079\u3066\u306EVM\u95A2\u9023\u306E\u8A2D\u5B9A\u3092\u8868\u793A\u3057\u3066\u7D9A\u884C\u3059\u308B\n -Xss Java\u306E\u30B9\u30EC\u30C3\u30C9\u30FB\u30B9\u30BF\u30C3\u30AF\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n -Xverify \u30D0\u30A4\u30C8\u30B3\u30FC\u30C9\u691C\u8A3C\u6A5F\u80FD\u306E\u30E2\u30FC\u30C9\u3092\u8A2D\u5B9A\u3059\u308B\n --add-reads =(,)*\n \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001\u3092\u66F4\u65B0\u3057\u3066\n \u3092\u8AAD\u307F\u53D6\u308A\u307E\u3059\u3002 \n \u3092ALL-UNNAMED\u306B\u8A2D\u5B9A\u3059\u308B\u3068\u3001\u3059\u3079\u3066\u306E\u540D\u524D\u306E\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\n \u8AAD\u307F\u53D6\u308C\u307E\u3059\u3002\n --add-exports /=(,)*\n \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001\u3092\u66F4\u65B0\u3057\u3066\u3092\u306B\n \u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\n \u3092ALL-UNNAMED\u306B\u8A2D\u5B9A\u3059\u308B\u3068\u3001\u3059\u3079\u3066\u306E\u540D\u524D\u306E\u306A\u3044\u30E2\u30B8\u30E5\u30FC\u30EB\u306B\n \u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3067\u304D\u307E\u3059\u3002\n --add-opens /=(,)*\n \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001\u3092\u66F4\u65B0\u3057\u3066\n \u3092\u306B\u958B\u304D\u307E\u3059\u3002\n --disable-@files \u3055\u3089\u306A\u308B\u5F15\u6570\u30D5\u30A1\u30A4\u30EB\u62E1\u5F35\u3092\u7121\u52B9\u306B\u3059\u308B\n --patch-module =({0})*\n JAR\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30EA\u30BD\u30FC\u30B9\u3067\u30E2\u30B8\u30E5\u30FC\u30EB\u3092\n \u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u307E\u305F\u306F\u62E1\u5F35\u3057\u307E\u3059\u3002\n\n\u3053\u308C\u3089\u306F\u8FFD\u52A0\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\n\u6B21\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306FMac OS X\u56FA\u6709\u3067\u3059:\n -XstartOnFirstThread\n main()\u30E1\u30BD\u30C3\u30C9\u3092\u6700\u521D(AppKit)\u306E\u30B9\u30EC\u30C3\u30C9\u3067\u5B9F\u884C\u3059\u308B\n -Xdock:name=\n Dock\u306B\u8868\u793A\u3055\u308C\u308B\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u540D\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\n -Xdock:icon=\n Dock\u306B\u8868\u793A\u3055\u308C\u308B\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30A2\u30A4\u30B3\u30F3\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ko.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ko.properties index a734e614e2a..e543dc7b325 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ko.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ko.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,23 +24,19 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = \uC0AC\uC6A9\uBC95: {0} [options] class [args...]\n (\uD074\uB798\uC2A4 \uC2E4\uD589)\n \uB610\uB294 {0} [options] -jar jarfile [args...]\n (jar \uD30C\uC77C \uC2E4\uD589)\n \uB610\uB294 {0} [options] -p -m [/] [args...]\n (\uBAA8\uB4C8\uC758 \uAE30\uBCF8 \uD074\uB798\uC2A4 \uC2E4\uD589)\n\uC5EC\uAE30\uC11C options\uB294 \uB2E4\uC74C\uACFC \uAC19\uC2B5\uB2C8\uB2E4.\n +java.launcher.opt.header = \uC0AC\uC6A9\uBC95: {0} [options] class [args...]\n (\uD074\uB798\uC2A4 \uC2E4\uD589)\n \uB610\uB294 {0} [options] -jar jarfile [args...]\n (jar \uD30C\uC77C \uC2E4\uD589)\n \uB610\uB294 {0} [options] -p -m [/] [args...]\n (\uBAA8\uB4C8\uC758 \uAE30\uBCF8 \uD074\uB798\uC2A4 \uC2E4\uD589)\n\uC5EC\uAE30\uC11C options\uB294 \uB2E4\uC74C\uACFC \uAC19\uC2B5\uB2C8\uB2E4.\n\n java.launcher.opt.datamodel =\ -d{0}\t \uB354 \uC774\uC0C1 \uC0AC\uC6A9\uB418\uC9C0 \uC54A\uC74C. \uC774\uD6C4 \uB9B4\uB9AC\uC2A4\uC5D0\uC11C \uC81C\uAC70\uB429\uB2C8\uB2E4.\n java.launcher.opt.vmselect =\ {0}\t "{1}" VM\uC744 \uC120\uD0DD\uD569\uB2C8\uB2E4.\n java.launcher.opt.hotspot =\ {0}\t "{1}" VM\uC758 \uB3D9\uC758\uC5B4\uC785\uB2C8\uB2E4[\uC0AC\uC6A9\uB418\uC9C0 \uC54A\uC74C].\n -java.launcher.ergo.message1 =\ \uAE30\uBCF8 VM\uC740 {0}\uC785\uB2C8\uB2E4. -java.launcher.ergo.message2 =\ \uC11C\uBC84\uAE09 \uC2DC\uC2A4\uD15C\uC5D0\uC11C \uC2E4\uD589 \uC911\uC774\uAE30 \uB54C\uBB38\uC785\uB2C8\uB2E4.\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp <\uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C\uC758 \uD074\uB798\uC2A4 \uAC80\uC0C9 \uACBD\uB85C>\n -classpath <\uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C\uC758 \uD074\uB798\uC2A4 \uAC80\uC0C9 \uACBD\uB85C>\n --class-path <\uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C\uC758 \uD074\uB798\uC2A4 \uAC80\uC0C9 \uACBD\uB85C>\n \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uAC80\uC0C9\uD560 {0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC,\n JAR \uC544\uCE74\uC774\uBE0C \uBC0F ZIP \uC544\uCE74\uC774\uBE0C \uBAA9\uB85D\uC785\uB2C8\uB2E4.\n -p <\uBAA8\uB4C8 \uACBD\uB85C>\n -module-path <\uBAA8\uB4C8 \uACBD\uB85C>...\n {0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC \uBAA9\uB85D\uC785\uB2C8\uB2E4. \uAC01 \uB514\uB809\uD1A0\uB9AC\uB294\n \uBAA8\uB4C8\uC758 \uB514\uB809\uD1A0\uB9AC\uC785\uB2C8\uB2E4.\n -upgrade-module-path <\uBAA8\uB4C8 \uACBD\uB85C>...\n {0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC \uBAA9\uB85D\uC785\uB2C8\uB2E4. \uAC01 \uB514\uB809\uD1A0\uB9AC\uB294\n \uBAA8\uB4C8\uC758 \uB514\uB809\uD1A0\uB9AC\uB85C, \uB7F0\uD0C0\uC784 \uC774\uBBF8\uC9C0\uC5D0\uC11C \uC5C5\uADF8\uB808\uC774\uB4DC\n \uAC00\uB2A5\uD55C \uBAA8\uB4C8\uC744 \uB300\uCCB4\uD569\uB2C8\uB2E4.\n -m <\uBAA8\uB4C8>[/<\uAE30\uBCF8 \uD074\uB798\uC2A4>]\n --module <\uBAA8\uB4C8 \uC774\uB984>[/<\uAE30\uBCF8 \uD074\uB798\uC2A4>]\n \uBD84\uC11D\uD560 \uCD08\uAE30 \uBAA8\uB4C8 \uBC0F \uBAA8\uB4C8\uC5D0\uC11C \uC9C0\uC815\uB418\uC9C0 \uC54A\uC740 \uACBD\uC6B0 \uC2E4\uD589\uD560\n \uAE30\uBCF8 \uD074\uB798\uC2A4\uC758 \uC774\uB984\uC785\uB2C8\uB2E4.\n --add-modules <\uBAA8\uB4C8 \uC774\uB984>[,<\uBAA8\uB4C8 \uC774\uB984>...]\n \uCD08\uAE30 \uBAA8\uB4C8 \uC678\uC5D0 \uBD84\uC11D\uD560 \uB8E8\uD2B8 \uBAA8\uB4C8\uC785\uB2C8\uB2E4.\n <\uBAA8\uB4C8 \uC774\uB984>\uC740 ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH\uC77C \uC218\uB3C4 \uC788\uC2B5\uB2C8\uB2E4.\n --limit-modules <\uBAA8\uB4C8 \uC774\uB984>[,<\uBAA8\uB4C8 \uC774\uB984>...]\n \uAD00\uCC30 \uAC00\uB2A5\uD55C \uBAA8\uB4C8\uC744 \uB098\uC5F4\uD558\uACE0 \uC885\uB8CC \uBC94\uC704\uB97C \uC81C\uD55C\uD569\uB2C8\uB2E4.\n --list-modules[<\uBAA8\uB4C8 \uC774\uB984>[,<\uBAA8\uB4C8 \uC774\uB984>...]]\n \uAD00\uCC30 \uAC00\uB2A5\uD55C \uBAA8\uB4C8\uC744 \uB098\uC5F4\uD55C \uD6C4 \uC885\uB8CC\uD569\uB2C8\uB2E4.\n --dry-run VM\uC744 \uC0DD\uC131\uD558\uC9C0\uB9CC \uAE30\uBCF8 \uBA54\uC18C\uB4DC\uB97C \uC2E4\uD589\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.\n \uC774 --dry-run \uC635\uC158\uC740 \uBAA8\uB4C8 \uC2DC\uC2A4\uD15C \uAD6C\uC131\uACFC \uAC19\uC740 \uBA85\uB839\uD589\n \uC635\uC158\uC744 \uAC80\uC99D\uD558\uB294 \uB370 \uC720\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n -D<\uC774\uB984>=<\uAC12>\n \uC2DC\uC2A4\uD15C \uC18D\uC131\uC744 \uC124\uC815\uD569\uB2C8\uB2E4.\n -verbose:[class|gc|jni]\n \uC0C1\uC138 \uC815\uBCF4 \uCD9C\uB825\uC744 \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -version \uC81C\uD488 \uBC84\uC804\uC744 \uC624\uB958 \uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD55C \uD6C4 \uC885\uB8CC\uD569\uB2C8\uB2E4.\n --version \uC81C\uD488 \uBC84\uC804\uC744 \uCD9C\uB825 \uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD55C \uD6C4 \uC885\uB8CC\uD569\uB2C8\uB2E4.\n -showversion \uC81C\uD488 \uBC84\uC804\uC744 \uC624\uB958 \uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n --show-version\n \uC81C\uD488 \uBC84\uC804\uC744 \uCD9C\uB825 \uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -? -h -help\n \uC774 \uB3C4\uC6C0\uB9D0 \uBA54\uC2DC\uC9C0\uB97C \uC624\uB958 \ +\uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD569\uB2C8\uB2E4.\n --help \uC774 \uB3C4\uC6C0\uB9D0 \uBA54\uC2DC\uC9C0\uB97C \uCD9C\uB825 \uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD569\uB2C8\uB2E4.\n -X \uCD94\uAC00 \uC635\uC158\uC5D0 \uB300\uD55C \uB3C4\uC6C0\uB9D0\uC744 \uC624\uB958 \uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD569\uB2C8\uB2E4.\n --help-extra \uCD94\uAC00 \uC635\uC158\uC5D0 \uB300\uD55C \uB3C4\uC6C0\uB9D0\uC744 \uCD9C\uB825 \uC2A4\uD2B8\uB9BC\uC5D0 \uC778\uC1C4\uD569\uB2C8\uB2E4.\n -ea[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n -enableassertions[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n \uC138\uBD84\uC131\uC774 \uC9C0\uC815\uB41C \uAC80\uC99D\uC744 \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -da[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n -disableassertions[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n \uC138\uBD84\uC131\uC774 \uC9C0\uC815\uB41C \uAC80\uC99D\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -esa | -enablesystemassertions\n \uC2DC\uC2A4\uD15C \uAC80\uC99D\uC744 \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -dsa | -disablesystemassertions\n \uC2DC\uC2A4\uD15C \uAC80\uC99D\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -agentlib:<\uB77C\uC774\uBE0C\uB7EC\uB9AC \uC774\uB984>[=<\uC635\uC158>]\n \uACE0\uC720 \uC5D0\uC774\uC804\uD2B8 \uB77C\uC774\uBE0C\uB7EC\uB9AC <\uB77C\uC774\uBE0C\uB7EC\uB9AC \uC774\uB984>\uC744 \uB85C\uB4DC\uD569\uB2C8\uB2E4(\uC608: -agentlib:jdwp).\n -agentlib:jdwp=help\uB3C4 \uCC38\uC870\uD558\uC2ED\uC2DC\uC624.\n -agentpath:<\uACBD\uB85C \uC774\uB984>[=<\uC635\uC158>]\n \uC804\uCCB4 \uACBD\uB85C \uC774\uB984\uC744 \uC0AC\uC6A9\uD558\uC5EC \uACE0\uC720 \uC5D0\uC774\uC804\uD2B8 \uB77C\uC774\uBE0C\uB7EC\uB9AC\uB97C \uB85C\uB4DC\uD569\uB2C8\uB2E4.\n -javaagent:[=<\uC635\uC158>]\n Java \uD504\uB85C\uADF8\uB798\uBC0D \uC5B8\uC5B4 \uC5D0\uC774\uC804\uD2B8\uB97C \uB85C\uB4DC\uD569\uB2C8\uB2E4. java.lang.instrument\uB97C \uCC38\uC870\uD558\uC2ED\uC2DC\uC624.\n -splash:<\uC774\uBBF8\uC9C0 \uACBD\uB85C>\n \uC774\uBBF8\uC9C0\uAC00 \uC9C0\uC815\uB41C \uC2A4\uD50C\uB798\uC2DC \uD654\uBA74\uC744 \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n HiDPI\uB85C \uC870\uC815\uB41C \uC774\uBBF8\uC9C0\uAC00 \uC790\uB3D9\uC73C\uB85C \uC9C0\uC6D0\uB418\uACE0 \uAC00\uB2A5\uD55C \uACBD\uC6B0\n \uC0AC\uC6A9\uB429\uB2C8\uB2E4. \uBBF8\uC870\uC815 \uC774\uBBF8\uC9C0 \uD30C\uC77C \uC774\uB984(\uC608: image.ext)\uC740\n \uD56D\uC0C1 -splash \uC635\uC158\uC5D0 \uC778\uC218\uB85C \uC804\uB2EC\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4.\n \uAC00\uC7A5 \uC801\uC808\uD788 \uC870\uC815\uB41C \uC774\uBBF8\uC9C0\uAC00 \uC790\uB3D9\uC73C\uB85C\n \uCC44\uD0DD\uB429\uB2C8\uB2E4.\n \uC790\uC138\uD55C \uB0B4\uC6A9\uC740 SplashScreen API \uC124\uBA85\uC11C\uB97C \uCC38\uC870\uD558\uC2ED\uC2DC\uC624.\n @<\uD30C\uC77C \uACBD\uB85C> \uC9C0\uC815\uB41C \uD30C\uC77C\uC5D0\uC11C \uC635\uC158\uC744 \uC77D\uC2B5\uB2C8\uB2E4.\n\nlong \uC635\uC158\uC5D0 \uB300\uD55C \uC778\uC218\uB97C \uC9C0\uC815\uD558\uB824\uBA74 --<\uC774\uB984>=<\uAC12> \uB610\uB294\n--<\uC774\uB984> <\uAC12>\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp <\uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C\uC758 \uD074\uB798\uC2A4 \uAC80\uC0C9 \uACBD\uB85C>\n -classpath <\uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C\uC758 \uD074\uB798\uC2A4 \uAC80\uC0C9 \uACBD\uB85C>\n --class-path <\uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C\uC758 \uD074\uB798\uC2A4 \uAC80\uC0C9 \uACBD\uB85C>\n \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uAC80\uC0C9\uD560 {0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC,\n JAR \uC544\uCE74\uC774\uBE0C \uBC0F ZIP \uC544\uCE74\uC774\uBE0C \uBAA9\uB85D\uC785\uB2C8\uB2E4.\n -p <\uBAA8\uB4C8 \uACBD\uB85C>\n --module-path <\uBAA8\uB4C8 \uACBD\uB85C>...\n {0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC \uBAA9\uB85D\uC785\uB2C8\uB2E4. \uAC01 \uB514\uB809\uD1A0\uB9AC\uB294\n \uBAA8\uB4C8\uC758 \uB514\uB809\uD1A0\uB9AC\uC785\uB2C8\uB2E4.\n --upgrade-module-path <\uBAA8\uB4C8 \uACBD\uB85C>...\n {0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC \uBAA9\uB85D\uC785\uB2C8\uB2E4. \uAC01 \uB514\uB809\uD1A0\uB9AC\uB294\n \uBAA8\uB4C8\uC758 \uB514\uB809\uD1A0\uB9AC\uB85C, \uB7F0\uD0C0\uC784 \uC774\uBBF8\uC9C0\uC5D0\uC11C \uC5C5\uADF8\uB808\uC774\uB4DC\n \uAC00\uB2A5\uD55C \uBAA8\uB4C8\uC744 \uB300\uCCB4\uD569\uB2C8\uB2E4.\n -m <\uBAA8\uB4C8>[/<\uAE30\uBCF8 \uD074\uB798\uC2A4>]\n --module <\uBAA8\uB4C8 \uC774\uB984>[/<\uAE30\uBCF8 \uD074\uB798\uC2A4>]\n \uBD84\uC11D\uD560 \uCD08\uAE30 \uBAA8\uB4C8 \uBC0F \uBAA8\uB4C8\uC5D0\uC11C \uC9C0\uC815\uB418\uC9C0 \uC54A\uC740 \uACBD\uC6B0 \uC2E4\uD589\uD560\n \uAE30\uBCF8 \uD074\uB798\uC2A4\uC758 \uC774\uB984\uC785\uB2C8\uB2E4.\n --add-modules <\uBAA8\uB4C8 \uC774\uB984>[,<\uBAA8\uB4C8 \uC774\uB984>...]\n \uCD08\uAE30 \uBAA8\uB4C8 \uC678\uC5D0 \uBD84\uC11D\uD560 \uB8E8\uD2B8 \uBAA8\uB4C8\uC785\uB2C8\uB2E4.\n <\uBAA8\uB4C8 \uC774\uB984>\uC740 ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH\uC77C \uC218\uB3C4 \uC788\uC2B5\uB2C8\uB2E4.\n --limit-modules <\uBAA8\uB4C8 \uC774\uB984>[,<\uBAA8\uB4C8 \uC774\uB984>...]\n \uAD00\uCC30 \uAC00\uB2A5\uD55C \uBAA8\uB4C8\uC758 \uBC94\uC704\uB97C \uC81C\uD55C\uD569\uB2C8\uB2E4.\n --list-modules [<\uBAA8\uB4C8 \uC774\uB984>[,<\uBAA8\uB4C8 \uC774\uB984>...]]\n \uAD00\uCC30 \uAC00\uB2A5\uD55C \uBAA8\uB4C8\uC744 \uB098\uC5F4\uD55C \uD6C4 \uC885\uB8CC\uD569\uB2C8\uB2E4.\n --dry-run VM\uC744 \uC0DD\uC131\uD558\uC9C0\uB9CC \uAE30\uBCF8 \uBA54\uC18C\uB4DC\uB97C \uC2E4\uD589\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.\n \uC774 --dry-run \uC635\uC158\uC740 \uBAA8\uB4C8 \uC2DC\uC2A4\uD15C \uAD6C\uC131\uACFC \uAC19\uC740 \uBA85\uB839\uD589\n \uC635\uC158\uC744 \uAC80\uC99D\uD558\uB294 \uB370 \uC720\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n -D<\uC774\uB984>=<\uAC12>\n \uC2DC\uC2A4\uD15C \uC18D\uC131\uC744 \uC124\uC815\uD569\uB2C8\uB2E4.\n -verbose:[class|gc|jni]\n \uC0C1\uC138 \uC815\uBCF4 \uCD9C\uB825\uC744 \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -version \uC81C\uD488 \uBC84\uC804\uC744 \uC778\uC1C4\uD55C \uD6C4 \uC885\uB8CC\uD569\uB2C8\uB2E4.\n -showversion \uC81C\uD488 \uBC84\uC804\uC744 \uC778\uC1C4\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -? -help --help\n \uC774 \uB3C4\uC6C0\uB9D0 \uBA54\uC2DC\uC9C0\uB97C \uC778\uC1C4\uD569\uB2C8\uB2E4.\n -X \uBE44\uD45C\uC900 \uC635\uC158\uC5D0 \uB300\uD55C \uB3C4\uC6C0\uB9D0\uC744 \uC778\uC1C4\uD569\uB2C8\uB2E4.\n -ea[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n -enableassertions[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n \uC138\uBD84\uC131\uC774 \uC9C0\uC815\uB41C \uAC80\uC99D\uC744 \ -\uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -da[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n -disableassertions[:<\uD328\uD0A4\uC9C0 \uC774\uB984>...|:<\uD074\uB798\uC2A4 \uC774\uB984>]\n \uC138\uBD84\uC131\uC774 \uC9C0\uC815\uB41C \uAC80\uC99D\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -esa | -enablesystemassertions\n \uC2DC\uC2A4\uD15C \uAC80\uC99D\uC744 \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -dsa | -disablesystemassertions\n \uC2DC\uC2A4\uD15C \uAC80\uC99D\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -agentlib:<\uB77C\uC774\uBE0C\uB7EC\uB9AC \uC774\uB984>[=<\uC635\uC158>]\n \uACE0\uC720 \uC5D0\uC774\uC804\uD2B8 \uB77C\uC774\uBE0C\uB7EC\uB9AC <\uB77C\uC774\uBE0C\uB7EC\uB9AC \uC774\uB984>\uC744 \uB85C\uB4DC\uD569\uB2C8\uB2E4(\uC608: -agentlib:jdwp).\n -agentlib:jdwp=help\uB3C4 \uCC38\uC870\uD558\uC2ED\uC2DC\uC624.\n -agentpath:<\uACBD\uB85C \uC774\uB984>[=<\uC635\uC158>]\n \uC804\uCCB4 \uACBD\uB85C \uC774\uB984\uC744 \uC0AC\uC6A9\uD558\uC5EC \uACE0\uC720 \uC5D0\uC774\uC804\uD2B8 \uB77C\uC774\uBE0C\uB7EC\uB9AC\uB97C \uB85C\uB4DC\uD569\uB2C8\uB2E4.\n -javaagent:[=<\uC635\uC158>]\n Java \uD504\uB85C\uADF8\uB798\uBC0D \uC5B8\uC5B4 \uC5D0\uC774\uC804\uD2B8\uB97C \uB85C\uB4DC\uD569\uB2C8\uB2E4. java.lang.instrument\uB97C \uCC38\uC870\uD558\uC2ED\uC2DC\uC624.\n -splash:<\uC774\uBBF8\uC9C0 \uACBD\uB85C>\n \uC774\uBBF8\uC9C0\uAC00 \uC9C0\uC815\uB41C \uC2A4\uD50C\uB798\uC2DC \uD654\uBA74\uC744 \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n HiDPI\uB85C \uC870\uC815\uB41C \uC774\uBBF8\uC9C0\uAC00 \uC790\uB3D9\uC73C\uB85C \uC9C0\uC6D0\uB418\uACE0 \uAC00\uB2A5\uD55C \uACBD\uC6B0\n \uC0AC\uC6A9\uB429\uB2C8\uB2E4. \uBBF8\uC870\uC815 \uC774\uBBF8\uC9C0 \uD30C\uC77C \uC774\uB984(\uC608: image.ext)\uC740\n \uD56D\uC0C1 -splash \uC635\uC158\uC5D0 \uC778\uC218\uB85C \uC804\uB2EC\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4.\n \uAC00\uC7A5 \uC801\uC808\uD788 \uC870\uC815\uB41C \uC774\uBBF8\uC9C0\uAC00 \uC790\uB3D9\uC73C\uB85C \uCC44\uD0DD\uB429\uB2C8\uB2E4.\n \uC790\uC138\uD55C \uB0B4\uC6A9\uC740 SplashScreen API \uC124\uBA85\uC11C\uB97C \uCC38\uC870\uD558\uC2ED\uC2DC\uC624.\n @<\uD30C\uC77C \uACBD\uB85C> \uC9C0\uC815\uB41C \uD30C\uC77C\uC5D0\uC11C \uC635\uC158\uC744 \uC77D\uC2B5\uB2C8\uB2E4.\nlong \uC635\uC158\uC5D0 \uB300\uD55C \uC778\uC218\uB97C \uC9C0\uC815\uD558\uB824\uBA74 --<\uC774\uB984>=<\uAC12> \uB610\uB294 --<\uC774\uB984> <\uAC12>\uC744\n\uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n -See \uC790\uC138\uD55C \uB0B4\uC6A9\uC740 http://www.oracle.com/technetwork/java/javase/documentation/index.html\uC744 \uCC38\uC870\uD558\uC2ED\uC2DC\uC624. - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch \uBC31\uADF8\uB77C\uC6B4\uB4DC \uCEF4\uD30C\uC77C\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xbootclasspath/a:<{0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C>\n \uBD80\uD2B8\uC2A4\uD2B8\uB7A9 \uD074\uB798\uC2A4 \uACBD\uB85C \uB05D\uC5D0 \uCD94\uAC00\uD569\uB2C8\uB2E4.\n -Xcheck:jni JNI \uD568\uC218\uC5D0 \uB300\uD55C \uCD94\uAC00 \uAC80\uC0AC\uB97C \uC218\uD589\uD569\uB2C8\uB2E4.\n -Xcomp \uCCAB\uBC88\uC9F8 \uD638\uCD9C\uC5D0\uC11C \uBA54\uC18C\uB4DC \uCEF4\uD30C\uC77C\uC744 \uAC15\uC81C\uD569\uB2C8\uB2E4.\n -Xdebug \uC5ED \uD638\uD658\uC131\uC744 \uC704\uD574 \uC81C\uACF5\uB418\uC5C8\uC2B5\uB2C8\uB2E4.\n -Xdiag \uCD94\uAC00 \uC9C4\uB2E8 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n -Xdiag:resolver \uBD84\uC11D\uAE30 \uC9C4\uB2E8 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n -Xfuture \uBBF8\uB798 \uAE30\uBCF8\uAC12\uC744 \uC608\uCE21\uD558\uC5EC \uAC00\uC7A5 \uC5C4\uACA9\uD55C \uAC80\uC0AC\uB97C \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xint \uD574\uC11D\uB41C \uBAA8\uB4DC\uB9CC \uC2E4\uD589\uD569\uB2C8\uB2E4.\n -Xinternalversion\n -version \uC635\uC158\uBCF4\uB2E4 \uC0C1\uC138\uD55C JVM \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n -Xloggc: \uC2DC\uAC04 \uAE30\uB85D\uACFC \uD568\uAED8 \uD30C\uC77C\uC5D0 GC \uC0C1\uD0DC\uB97C \uAE30\uB85D\uD569\uB2C8\uB2E4.\n -Xmixed \uD63C\uD569 \uBAA8\uB4DC\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4(\uAE30\uBCF8\uAC12).\n -Xmn \uC80A\uC740 \uC138\uB300(Nursery)\uB97C \uC704\uD574 \uD799\uC758 \uCD08\uAE30 \uBC0F \uCD5C\uB300\n \uD06C\uAE30(\uBC14\uC774\uD2B8)\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xms \uCD08\uAE30 Java \uD799 \uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xmx \uCD5C\uB300 Java \uD799 \uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xnoclassgc \uD074\uB798\uC2A4\uC758 \uBD88\uD544\uC694\uD55C \uC815\uBCF4 \uBAA8\uC74C\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xprof CPU \uD504\uB85C\uD30C\uC77C \uC791\uC131 \uB370\uC774\uD130\uB97C \uCD9C\uB825\uD569\uB2C8\uB2E4.\n -Xrs Java/VM\uC5D0 \uC758\uD55C OS \uC2E0\uD638 \uC0AC\uC6A9\uC744 \uC904\uC785\uB2C8\uB2E4(\uC124\uBA85\uC11C \uCC38\uC870).\n -Xshare:auto \uAC00\uB2A5\uD55C \uACBD\uC6B0 \uACF5\uC720 \uD074\uB798\uC2A4 \uB370\uC774\uD130\uB97C \uC0AC\uC6A9\uD569\uB2C8\uB2E4(\uAE30\uBCF8\uAC12).\n -Xshare:off \uACF5\uC720 \uD074\uB798\uC2A4 \uB370\uC774\uD130 \uC0AC\uC6A9\uC744 \uC2DC\uB3C4\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.\n -Xshare:on \uACF5\uC720 \uD074\uB798\uC2A4 \uB370\uC774\uD130\uB97C \uC0AC\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4. \uADF8\uB807\uC9C0 \uC54A\uC744 \uACBD\uC6B0 \uC2E4\uD328\uD569\uB2C8\uB2E4.\n -XshowSettings \uBAA8\uB4E0 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:all\n \uBAA8\uB4E0 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:locale\n \uBAA8\uB4E0 \uB85C\uCF00\uC77C \uAD00\uB828 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:properties\n \uBAA8\uB4E0 \uC18D\uC131 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:vm \uBAA8\uB4E0 VM \uAD00\uB828 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -Xss Java \uC2A4\uB808\uB4DC \uC2A4\uD0DD \ -\uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xverify \uBC14\uC774\uD2B8\uCF54\uB4DC \uAC80\uC99D\uC790\uC758 \uBAA8\uB4DC\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n --add-reads =(,)*\n \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 \uC744 \uC77D\uB3C4\uB85D\n \uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n \uC740 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC740 \uBAA8\uB4E0 \uBAA8\uB4C8\uC744 \uC77D\uC744 \uC218 \uC788\uB294\n ALL-UNNAMED\uC77C \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n --add-exports /=(,)*\n \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 \uB97C \uB85C \uC775\uC2A4\uD3EC\uD2B8\uD558\uB3C4\uB85D\n \uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n \uC740 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC740 \uBAA8\uB4E0 \uBAA8\uB4C8\uB85C \uC775\uC2A4\uD3EC\uD2B8\uD560 \uC218 \uC788\uB294\n ALL-UNNAMED\uC77C \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n --disable-@files \uCD94\uAC00 \uC778\uC218 \uD30C\uC77C \uD655\uC7A5\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n --patch-module =({0})*\n JAR \uD30C\uC77C/\uB514\uB809\uD1A0\uB9AC\uC758 \uD074\uB798\uC2A4\uC640 \uB9AC\uC18C\uC2A4\uB85C\n \uBAA8\uB4C8\uC744 \uBB34\uD6A8\uD654\uD558\uAC70\uB098 \uC778\uC218\uD654\uD569\uB2C8\uB2E4.\n\n\uC774 \uC635\uC158\uC740 \uBE44\uD45C\uC900 \uC635\uC158\uC774\uBBC0\uB85C \uD1B5\uC9C0 \uC5C6\uC774 \uBCC0\uACBD\uB420 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n +java.launcher.X.usage=\n -Xbatch \uBC31\uADF8\uB77C\uC6B4\uB4DC \uCEF4\uD30C\uC77C\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xbootclasspath/a:<{0}(\uC73C)\uB85C \uAD6C\uBD84\uB41C \uB514\uB809\uD1A0\uB9AC \uBC0F zip/jar \uD30C\uC77C>\n \uBD80\uD2B8\uC2A4\uD2B8\uB7A9 \uD074\uB798\uC2A4 \uACBD\uB85C \uB05D\uC5D0 \uCD94\uAC00\uD569\uB2C8\uB2E4.\n -Xcheck:jni JNI \uD568\uC218\uC5D0 \uB300\uD55C \uCD94\uAC00 \uAC80\uC0AC\uB97C \uC218\uD589\uD569\uB2C8\uB2E4.\n -Xcomp \uCCAB\uBC88\uC9F8 \uD638\uCD9C\uC5D0\uC11C \uBA54\uC18C\uB4DC \uCEF4\uD30C\uC77C\uC744 \uAC15\uC81C\uD569\uB2C8\uB2E4.\n -Xdebug \uC5ED \uD638\uD658\uC131\uC744 \uC704\uD574 \uC81C\uACF5\uB418\uC5C8\uC2B5\uB2C8\uB2E4.\n -Xdiag \uCD94\uAC00 \uC9C4\uB2E8 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n -Xdiag:resolver \uBD84\uC11D\uAE30 \uC9C4\uB2E8 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n -Xfuture \uBBF8\uB798 \uAE30\uBCF8\uAC12\uC744 \uC608\uCE21\uD558\uC5EC \uAC00\uC7A5 \uC5C4\uACA9\uD55C \uAC80\uC0AC\uB97C \uC0AC\uC6A9\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xint \uD574\uC11D\uB41C \uBAA8\uB4DC\uB9CC \uC2E4\uD589\uD569\uB2C8\uB2E4.\n -Xinternalversion\n -version \uC635\uC158\uBCF4\uB2E4 \uC0C1\uC138\uD55C JVM \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n -Xloggc: \uC2DC\uAC04 \uAE30\uB85D\uACFC \uD568\uAED8 \uD30C\uC77C\uC5D0 GC \uC0C1\uD0DC\uB97C \uAE30\uB85D\uD569\uB2C8\uB2E4.\n -Xmixed \uD63C\uD569 \uBAA8\uB4DC\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4(\uAE30\uBCF8\uAC12).\n -Xmn \uC80A\uC740 \uC138\uB300(Nursery)\uB97C \uC704\uD574 \uD799\uC758 \uCD08\uAE30 \uBC0F \uCD5C\uB300\n \uD06C\uAE30(\uBC14\uC774\uD2B8)\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xms \uCD08\uAE30 Java \uD799 \uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xmx \uCD5C\uB300 Java \uD799 \uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xnoclassgc \uD074\uB798\uC2A4\uC758 \uBD88\uD544\uC694\uD55C \uC815\uBCF4 \uBAA8\uC74C\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xprof CPU \uD504\uB85C\uD30C\uC77C \uC791\uC131 \uB370\uC774\uD130\uB97C \uCD9C\uB825\uD569\uB2C8\uB2E4.\n -Xrs Java/VM\uC5D0 \uC758\uD55C OS \uC2E0\uD638 \uC0AC\uC6A9\uC744 \uC904\uC785\uB2C8\uB2E4(\uC124\uBA85\uC11C \uCC38\uC870).\n -Xshare:auto \uAC00\uB2A5\uD55C \uACBD\uC6B0 \uACF5\uC720 \uD074\uB798\uC2A4 \uB370\uC774\uD130\uB97C \uC0AC\uC6A9\uD569\uB2C8\uB2E4(\uAE30\uBCF8\uAC12).\n -Xshare:off \uACF5\uC720 \uD074\uB798\uC2A4 \uB370\uC774\uD130 \uC0AC\uC6A9\uC744 \uC2DC\uB3C4\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.\n -Xshare:on \uACF5\uC720 \uD074\uB798\uC2A4 \uB370\uC774\uD130\uB97C \uC0AC\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4. \uADF8\uB807\uC9C0 \uC54A\uC744 \uACBD\uC6B0 \uC2E4\uD328\uD569\uB2C8\uB2E4.\n -XshowSettings \uBAA8\uB4E0 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:all\n \uBAA8\uB4E0 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:locale\n \uBAA8\uB4E0 \uB85C\uCF00\uC77C \uAD00\uB828 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:properties\n \uBAA8\uB4E0 \uC18D\uC131 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -XshowSettings:vm \uBAA8\uB4E0 VM \uAD00\uB828 \uC124\uC815\uC744 \uD45C\uC2DC\uD55C \uD6C4 \uACC4\uC18D\uD569\uB2C8\uB2E4.\n -Xss Java \uC2A4\uB808\uB4DC \uC2A4\uD0DD \ +\uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n -Xverify \uBC14\uC774\uD2B8\uCF54\uB4DC \uAC80\uC99D\uC790\uC758 \uBAA8\uB4DC\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n --add-reads =(,)*\n \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 \uC744 \uC77D\uB3C4\uB85D\n \uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n \uC740 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC740 \uBAA8\uB4E0 \uBAA8\uB4C8\uC744 \uC77D\uC744 \uC218 \uC788\uB294\n ALL-UNNAMED\uC77C \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n --add-exports /=(,)*\n \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 \uB97C \uB85C \uC775\uC2A4\uD3EC\uD2B8\uD558\uB3C4\uB85D\n \uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n \uC740 \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC9C0 \uC54A\uC740 \uBAA8\uB4E0 \uBAA8\uB4C8\uB85C \uC775\uC2A4\uD3EC\uD2B8\uD560 \uC218 \uC788\uB294\n ALL-UNNAMED\uC77C \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n --add-opens /=(,)*\n \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 \uB97C \uB85C \uC5F4\uB3C4\uB85D\n \uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n --disable-@files \uCD94\uAC00 \uC778\uC218 \uD30C\uC77C \uD655\uC7A5\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\uD569\uB2C8\uB2E4.\n --patch-module =({0})*\n JAR \uD30C\uC77C \uB610\uB294 \uB514\uB809\uD1A0\uB9AC\uC758 \uD074\uB798\uC2A4\uC640 \uB9AC\uC18C\uC2A4\uB85C\n \uBAA8\uB4C8\uC744 \uBB34\uD6A8\uD654\uD558\uAC70\uB098 \uC778\uC218\uD654\uD569\uB2C8\uB2E4.\n\n\uC774\uB7EC\uD55C \uCD94\uAC00 \uC635\uC158\uC740 \uD1B5\uC9C0 \uC5C6\uC774 \uBCC0\uACBD\uB420 \uC218 \uC788\uC2B5\uB2C8\uB2E4.\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\n\uB2E4\uC74C\uC740 Mac OS X\uC5D0 \uD2B9\uC815\uB41C \uC635\uC158\uC785\uB2C8\uB2E4.\n -XstartOnFirstThread\n \uCCAB\uBC88\uC9F8 (AppKit) \uC2A4\uB808\uB4DC\uC5D0 main() \uBA54\uC18C\uB4DC\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4.\n -Xdock:name=\n \uACE0\uC815\uC73C\uB85C \uD45C\uC2DC\uB41C \uAE30\uBCF8 \uC560\uD50C\uB9AC\uCF00\uC774\uC158 \uC774\uB984\uC744 \uBB34\uD6A8\uD654\uD569\uB2C8\uB2E4.\n -Xdock:icon=\n \uACE0\uC815\uC73C\uB85C \uD45C\uC2DC\uB41C \uAE30\uBCF8 \uC544\uC774\uCF58\uC744 \uBB34\uD6A8\uD654\uD569\uB2C8\uB2E4.\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_pt_BR.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_pt_BR.properties index 1d8421df7a8..e83e6d594c8 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_pt_BR.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_pt_BR.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,22 +24,18 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = Uso: {0} [options] class [args...]\n (para executar uma classe)\n ou {0} [options] -jar jarfile [args...]\n (para executar um arquivo jar)\n or {0} [options] -p -m [/] [args...]\n (para executar a classe principal em um m\u00F3dulo)\nem que as op\u00E7\u00F5es incluem:\n +java.launcher.opt.header = Uso: {0} [options] class [args...]\n (para executar uma classe)\n ou {0} [options] -jar jarfile [args...]\n (para executar um arquivo jar)\n or {0} [options] -p -m [/] [args...]\n (para executar a classe principal em um m\u00F3dulo)\nem que as op\u00E7\u00F5es incluem:\n\n java.launcher.opt.datamodel =\ -d{0}\t Obsoleto, ser\u00E1 removido em uma futura release\n java.launcher.opt.vmselect =\ {0}\t para selecionar a VM "{1}"\n java.launcher.opt.hotspot =\ {0}\t \u00E9 um sin\u00F4nimo da VM "{1}" [obsoleto]\n -java.launcher.ergo.message1 =\ A VM padr\u00E3o \u00E9 {0} -java.launcher.ergo.message2 =\ porque a execu\u00E7\u00E3o est\u00E1 sendo feita em uma m\u00E1quina de classe de servidor.\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Uma lista separada por {0} de diret\u00F3rios, arquivos compactados JAR\n e arquivos ZIP nos quais procurar arquivos de classe.\n -p \n --module-path ...\n Uma lista separada por {0} de diret\u00F3rios, cada um sendo um\n diret\u00F3rio de m\u00F3dulos.\n --upgrade-module-path ...\n Uma lista separada por {0} de diret\u00F3rios, cada um\n um diret\u00F3rio de m\u00F3dulos que substituem m\u00F3dulos\n atualiz\u00E1veis na imagem de runtime\n -m [/]\n --module [/]\n o m\u00F3dulo inicial a ser resolvido e o nome da classe principal\n a ser executada se n\u00E3o especificado pelo m\u00F3dulo\n --add-modules [,...]\n m\u00F3dulos raiz a serem resolvidos al\u00E9m do m\u00F3dulo inicial.\n pode ser tamb\u00E9m ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n --limit-modules [,...]\n limitar o universo dos m\u00F3dulos observ\u00E1veis\n --list-modules [[,...]]\n listar os m\u00F3dulos observ\u00E1veis e sair\n --dry-run criar VM, mas n\u00E3o executar o m\u00E9todo principal.\n Esta op\u00E7\u00E3o --dry-run pode ser \u00FAtil para validar as\n op\u00E7\u00F5es de linha de comando, como a configura\u00E7\u00E3o do sistema de m\u00F3dulos.\n -D=\n definir uma propriedade do sistema\n -verbose:[class|gc|jni]\n ativar sa\u00EDda detalhada\n -version imprimir vers\u00E3o do produto no fluxo de erros e sair\n --version imprimir vers\u00E3o do produto no fluxo de sa\u00EDda e sair\n -showversion imprimir vers\u00E3o do produto no fluxo de sa\u00EDda e continuar\n --show-version\n imprimir vers\u00E3o do produto no fluxo de sa\u00EDda e continuar\n -? -h -help\n imprimir esta mensagem de ajuda no fluxo de erros\n --help imprimir esta mensagem de ajuda no fluxo de sa\u00EDda\n -X imprimir ajuda sobre op\u00E7\u00F5es extras no fluxo de erros\n --help-extra imprimir ajuda sobre op\u00E7\u00F5es extras no fluxo de sa\u00EDda\n -ea[:...|:]\n -enableassertions[:...|:]\n ativar asser\u00E7\u00F5es com granularidade especificada\n -da[:...|:]\n -disableassertions[:...|:]\n desativar asser\u00E7\u00F5es com granularidade especificada\n -esa | -enablesystemassertions\n ativar asser\u00E7\u00F5es de sistema\n -dsa | -disablesystemassertions\n desativar asser\u00E7\u00F5es de sistema\n -agentlib:[=]\n carregar biblioteca de agente nativo ; por exemplo, -agentlib:jdwp\n ver tamb\u00E9m -agentlib:jdwp=help\n -agentpath:[=]\n carregar biblioteca de agente nativo por nome do caminho completo\n -javaagent:[=]\n carregar agente de linguagem de programa\u00E7\u00E3o Java; ver java.lang.instrument\n -splash:\n mostrar tela de apresenta\u00E7\u00E3o com imagem especificada\n Imagens em escala HiDPI ser\u00E3o automaticamente suportadas e usadas\n se dispon\u00EDveis. O \ +nome do arquivo de imagem sem escala, por exemplo, image.ext,\n sempre dever\u00E1 ser informado como argumento para a op\u00E7\u00E3o -splash.\n A imagem em escala mais apropriada fornecida ser\u00E1 selecionada\n automaticamente.\n Consulte a documenta\u00E7\u00E3o da API SplashScreen para obter mais informa\u00E7\u00F5es.\n @ op\u00E7\u00F5es de leitura do arquivo especificado\n\nPara especificar um argumento para uma op\u00E7\u00E3o longa, voc\u00EA pode usar --= ou\n-- .\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n Uma lista separada por {0} de diret\u00F3rios, arquivos compactados JAR\n e ZIP para pesquisa de arquivos de classe.\n -p \n --module-path ...\n Uma lista separada por {0} de diret\u00F3rios, cada um\n sendo um diret\u00F3rio de m\u00F3dulos.\n --upgrade-module-path ...\n Uma lista separada por {0} de diret\u00F3rios, cada um sendo\n um diret\u00F3rio de m\u00F3dulos que substituem m\u00F3dulos atualiz\u00E1veis\n por upgrade na imagem do runtime\n -m [/]\n --module [/]\n o m\u00F3dulo inicial a ser resolvido e o nome da classe principal\n a ser executada se o m\u00F3dulo n\u00E3o especificar\n --add-modules [,...]\n m\u00F3dulos-raiz a serem resolvidos al\u00E9m do m\u00F3dulo inicial.\n tamb\u00E9m pode ser ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH.\n --limit-modules [,...]\n limitar o universo de m\u00F3dulos observ\u00E1veis\n --list-modules [[,...]]\n listar os m\u00F3dulos observ\u00E1veis e sair\n --dry-run criar VM, mas n\u00E3o executar o m\u00E9todo principal.\n Esta op\u00E7\u00E3o --dry-run pode ser \u00FAtil para validar as\n op\u00E7\u00F5es da linha de comando, como a configura\u00E7\u00E3o do sistema do m\u00F3dulo.\n -D=\n definir uma propriedade do sistema\n -verbose:[class|gc|jni]\n ativar sa\u00EDda detalhada\n -version imprimir vers\u00E3o do produto e sair\n -showversion imprimir vers\u00E3o do produto e continuar\n -? -help --help\n imprimir esta mensagem de ajuda\n -X imprimir a ajuda em op\u00E7\u00F5es n\u00E3o padr\u00E3o\n -ea[:...|:]\n -enableassertions[:...|:]\n ativar asser\u00E7\u00F5es com granularidade especificada\n -da[:...|:]\n -disableassertions[:...|:]\n desativar asser\u00E7\u00F5es com granularidade especificada\n -esa | -enablesystemassertions\n ativar asser\u00E7\u00F5es do sistema\n -dsa | -disablesystemassertions\n desativar asser\u00E7\u00F5es do sistema\n -agentlib:[=]\n carregar biblioteca de agentes nativa ; por exemplo, -agentlib:jdwp\n consulte tamb\u00E9m -agentlib:jdwp=help\n -agentpath:[=]\n carregar biblioteca de agentes nativa por nome de caminho completo\n -javaagent:[=]\n carregar agente de linguagem de programa\u00E7\u00E3o Java; consulte java.lang.instrument\n -splash:\n mostrar tela de abertura com imagem especificada\n Imagens HiDPI dimensionadas s\u00E3o suportadas automaticamente e utilizadas\n se dispon\u00EDveis. O nome do arquivo de imagem n\u00E3o dimensionada, por exemplo, image.ext,\n deve ser informado sempre como argumento para a op\u00E7\u00E3o -splash.\n A imagem dimensionada mais apropriada fornecida ser\u00E1 selecionada\n automaticamente.\n Consulte a documenta\u00E7\u00E3o da API de Tela de Abertura para obter mais \ -informa\u00E7\u00F5es.\n @ op\u00E7\u00F5es de leitura do arquivo especificado\nPara especificar um argumento para uma op\u00E7\u00E3o longa, voc\u00EA pode usar --= ou\n-- .\n -See http://www.oracle.com/technetwork/java/javase/documentation/index.html para obter mais detalhes. - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch desativar compila\u00E7\u00E3o em segundo plano\n -Xbootclasspath/a:\n anexar ao final do caminho de classe bootstrap\n -Xcheck:jni executar verifica\u00E7\u00F5es adicionais de fun\u00E7\u00F5es JNI\n -Xcomp for\u00E7a a compila\u00E7\u00E3o de m\u00E9todos na primeira chamada\n -Xdebug fornecido para fins de compatibilidade reversa\n -Xdiag mostrar mensagens de diagn\u00F3stico adicionais\n -Xdiag:resolver mostrar mensagens de diagn\u00F3stico do resolvedor\n -Xfuture ativar verifica\u00E7\u00F5es mais rigorosas, antecipando padr\u00E3o futuro\n -Xint somente execu\u00E7\u00E3o em modo interpretado\n -Xinternalversion\n exibe informa\u00E7\u00F5es mais detalhadas de vers\u00E3o da JVM do que a\n op\u00E7\u00E3o -version\n -Xloggc: registrar status de GC em um arquivo com time-stamps\n -Xmixed execu\u00E7\u00E3o em modo misto (padr\u00E3o)\n -Xmn define o tamanho inicial e m\u00E1ximo (em bytes) do heap\n para a gera\u00E7\u00E3o jovem (infantil)\n -Xms definir tamanho do heap Java inicial\n -Xmx definir tamanho do heap Java m\u00E1ximo\n -Xnoclassgc desativar coleta de lixo de classe\n -Xprof emitir dados de perfil de cpu\n -Xrs reduzir uso de sinais do SO por Java/VM (consultar documenta\u00E7\u00E3o)\n -Xshare:auto usar dados de classe compartilhados, se poss\u00EDvel (padr\u00E3o)\n -Xshare:off n\u00E3o tentar usar dados de classe compartilhados\n -Xshare:on exigir o uso de dados de classe compartilhados; caso contr\u00E1rio, falhar\u00E1.\n -XshowSettings mostrar todas as defini\u00E7\u00F5es e continuar\n -XshowSettings:all\n mostrar todas as defini\u00E7\u00F5es e continuar\n -XshowSettings:locale\n mostrar todas as defini\u00E7\u00F5es relativas a localidade e continuar\n -XshowSettings:properties\n mostrar todas as defini\u00E7\u00F5es de propriedade e continuar\n -XshowSettings:vm mostrar todas as defini\u00E7\u00F5es relativas a vm e continuar\n -Xss definir tamanho de pilha de thread java\n -Xverify define o modo do verificador de c\u00F3digo de byte\n --add-reads =(,)*\n atualiza para ler , independentemente\n da declara\u00E7\u00E3o do m\u00F3dulo. \n pode ser ALL-UNNAMED para ler todos os m\u00F3dulos\n sem nome.\n --add-exports /=(,)*\n atualiza para exportar para ,\n independentemente da declara\u00E7\u00E3o do m\u00F3dulo.\n pode ser ALL-UNNAMED para exportar para todos\n os m\u00F3dulos sem nome.\n --disable-@files desativar expans\u00E3o de arquivo de argumento adicional\n --patch-module =({0})*\n Substituir ou aumentar um m\u00F3dulo com classes e recursos\n em arquivo JAR ou diret\u00F3rios.\n\nEssas op\u00E7\u00F5es n\u00E3o s\u00E3o padr\u00E3o e est\u00E3o sujeitas a altera\u00E7\u00E3o sem aviso.\n +java.launcher.X.usage=\n -Xbatch desativar compila\u00E7\u00E3o em segundo plano\n -Xbootclasspath/a:\n anexar ao final do caminho de classe de bootstrap\n -Xcheck:jni executar verifica\u00E7\u00F5es adicionais de fun\u00E7\u00F5es JNI\n -Xcomp for\u00E7a a compila\u00E7\u00E3o de m\u00E9todos na primeira chamada\n -Xdebug fornecido para compatibilidade reversa\n -Xdiag mostrar mensagens adicionais de diagn\u00F3stico\n -Xdiag:resolver mostrar mensagens de diagn\u00F3stico do resolvedor\n -Xfuture ativar verifica\u00E7\u00F5es mais estritas, antecipando padr\u00E3o futuro\n -Xint somente execu\u00E7\u00E3o de modo interpretado\n -Xinternalversion\n exibe informa\u00E7\u00F5es mais detalhadas da vers\u00E3o da JVM do que a\n op\u00E7\u00E3o -version\n -Xloggc: registrar status de GC em um arquivo com time-stamps\n -Xmixed execu\u00E7\u00E3o em modo misto (padr\u00E3o)\n -Xmn define o tamanho inicial e m\u00E1ximo (em bytes) do heap\n para a gera\u00E7\u00E3o jovem (infantil)\n -Xms definir tamanho inicial do heap Java\n -Xmx definir tamanho m\u00E1ximo do heap Java\n -Xnoclassgc desativar coleta de lixo de classe\n -Xprof gerar dados de perfil de cpu\n -Xrs reduzir uso de sinais do SO por Java/VM (ver documenta\u00E7\u00E3o)\n -Xshare:auto usar dados de classe compartilhados se poss\u00EDvel (padr\u00E3o)\n -Xshare:off n\u00E3o tentar usar dados de classe compartilhados\n -Xshare:on exigido o uso de dados de classe compartilhados; caso contr\u00E1rio, falhar\u00E1.\n -XshowSettings mostrar todas as defini\u00E7\u00F5es e continuar\n -XshowSettings:all\n mostrar todas as defini\u00E7\u00F5es e continuar\n -XshowSettings:locale\n mostrar todas as defini\u00E7\u00F5es relacionadas a localidade e continuar\n -XshowSettings:properties\n mostrar todas as defini\u00E7\u00F5es de propriedade e continuar\n -XshowSettings:vm mostrar todas as defini\u00E7\u00F5es relacionadas a vm e continuar\n -Xss definir tamanho da pilha de thread java\n -Xverify define o modo do verificador de c\u00F3digo de byte\n --add-reads =(,)*\n atualiza para ler , independentemente\n da declara\u00E7\u00E3o de m\u00F3dulo. \n pode ser ALL-UNNAMED para ler todos os m\u00F3dulos\n sem nome.\n --add-exports /=(,)*\n atualiza para exportar para ,\n independentemente da declara\u00E7\u00E3o de m\u00F3dulo.\n pode ser ALL-UNNAMED para exportar todos os\n m\u00F3dulos sem nome.\n --add-opens /=(,)*\n atualiza para abrir para\n , independentemente da declara\u00E7\u00E3o de m\u00F3dulo.\n --disable-@files desativar expans\u00E3o de arquivo de argumento adicional\n --patch-module =({0})*\n Substitui ou amplia um m\u00F3dulo com classes e recursos\n em arquivos ou diret\u00F3rios JAR.\n\nEssas op\u00E7\u00F5es extras est\u00E3o sujeitas a altera\u00E7\u00E3o sem aviso.\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\nAs op\u00E7\u00F5es a seguir s\u00E3o espec\u00EDficas para o Mac OS X:\n -XstartOnFirstThread\n executa o m\u00E9todo main() no primeiro thread (AppKit)\n -Xdock:name=\n substitui o nome do aplicativo padr\u00E3o exibido no encaixe\n -Xdock:icon=\n substitui o \u00EDcone exibido no encaixe\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_sv.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_sv.properties index c456d6102bf..4a66d707b48 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_sv.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_sv.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,22 +24,18 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = Syntax: {0} [options] class [args...]\n (f\u00F6r att k\u00F6ra en klass)\n eller {0} [options] -jar jarfile [args...]\n (f\u00F6r att k\u00F6ra en jar-fil)\n eller {0} [options] -p -m [/] [args...]\n (f\u00F6r att k\u00F6ra huvudklassen i en modul)\nmed alternativen:\n +java.launcher.opt.header = Syntax: {0} [options] class [args...]\n (f\u00F6r att k\u00F6ra en klass)\n eller {0} [options] -jar jarfile [args...]\n (f\u00F6r att k\u00F6ra en jar-fil)\n eller {0} [options] -p -m [/] [args...]\n (f\u00F6r att k\u00F6ra huvudklassen i en modul)\nmed alternativen:\n\n java.launcher.opt.datamodel =\ -d{0}\t Inaktuellt, tas bort i en framtida utg\u00E5va\n java.launcher.opt.vmselect =\ {0}\t f\u00F6r att v\u00E4lja "{1}" VM\n java.launcher.opt.hotspot =\ {0}\t \u00E4r en synonym f\u00F6r "{1}" VM [inaktuell]\n -java.launcher.ergo.message1 =\ Standard-VM \u00E4r {0} -java.launcher.ergo.message2 =\ eftersom du k\u00F6r en serverklassmaskin.\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n En lista \u00F6ver kataloger, JAR-arkiv och ZIP-arkiv att\n s\u00F6ka efter klassfiler i, avgr\u00E4nsad med {0}.\n -p \n --module-path ...\n En lista \u00F6ver kataloger, d\u00E4r varje katalog \u00E4r en katalog\n med moduler, avgr\u00E4nsad med {0}.\n --upgrade-module-path ...\n En lista \u00F6ver kataloger, d\u00E4r varje katalog \u00E4r en katalog\n med moduler som ers\u00E4tter uppgraderingsbara moduler\n i exekveringsavbilden, avgr\u00E4nsad med {0} \n -m [/]\n --module [/]\n den ursprungliga modulen att l\u00F6sa och namnet p\u00E5 huvudklassen\n att k\u00F6ra, om den inte anges av modulen\n --add-modules [,...]\n rotmoduler att l\u00F6sa f\u00F6rutom den ursprungliga modulen.\n kan \u00E4ven vara ALL-DEFAULT, ALL-SYSTEM och\n ALL-MODULE-PATH.\n --limit-modules [,...]\n begr\u00E4nsa universumet med observerbara moduler\n --list-modules [[,...]]\n lista de observerbara modulerna och avsluta\n --dry-run skapa VM:en men k\u00F6r inte huvudmetoden.\n Det h\u00E4r alternativet kan vara anv\u00E4ndbart f\u00F6r att validera\n kommandoradsalternativen, som modulsystemkonfigurationen.\n -D=\n ange en systemegenskap\n -verbose:[class|gc|jni]\n aktivera utf\u00F6rliga utdata\n -version skriv ut produktversion till felstr\u00F6mmen och avsluta\n --version skriv ut produktversion till utdatastr\u00F6mmen och avsluta\n -showversion skriv ut produktversion till felstr\u00F6mmen och forts\u00E4tt\n --show-version\n skriv ut produktversion till utdatastr\u00F6mmen och forts\u00E4tt\n -? -h -help\n skriv ut det h\u00E4r hj\u00E4lpmeddelandet till felstr\u00F6mmen\n --help skriv ut det h\u00E4r hj\u00E4lpmeddelandet till utdatastr\u00F6mmen\n -X skriv ut hj\u00E4lp f\u00F6r icke-standardalternativ till felstr\u00F6mmen\n --help-extra skriv ut hj\u00E4lp f\u00F6r icke-standardalternativ till utdatastr\u00F6mmen\n -ea[:...|:]\n -enableassertions[:...|:]\n aktivera verifieringar med den angivna detaljgraden\n -da[:...|:]\n -disableassertions[:...|:]\n avaktivera verifieringar med den angivna detaljgraden\n -esa | -enablesystemassertions\n aktivera systemverifieringar\n -dsa | -disablesystemassertions\n avaktivera systemverifieringar\n -agentlib:[=]\n ladda det ursprungliga agentbiblioteket , exempel: -agentlib:jdwp\n se \u00E4ven -agentlib:jdwp=help\n -agentpath:[=]\n ladda det ursprungliga agentbiblioteket med fullst\u00E4ndigt s\u00F6kv\u00E4gsnamn\n -javaagent:[=]\n ladda agenten f\u00F6r programmeringsspr\u00E5ket Java, se java.lang.instrument\n -splash:\n visa v\u00E4lkomstsk\u00E4rmen med den angivna bilden\n HiDPI-skal\u00E4ndrade bilder st\u00F6ds automatiskt och anv\u00E4nds om de \u00E4r\n tillg\u00E4ngliga. Filnamnet p\u00E5 den \ +oskal\u00E4ndrade bilden, t.ex.\n bild.filtill\u00E4gg, ska alltid \u00F6verf\u00F6ras som argument till\n alternativet -splash.\n Den l\u00E4mpligaste skal\u00E4ndrade bilden v\u00E4ljs automatiskt.\n Mer information finns i dokumentationen f\u00F6r API:t SplashScreen.\n @ l\u00E4s alternativ fr\u00E5n den angivna filen\n\nOm du vill ange ett argument f\u00F6r ett l\u00E5ngt alternativ kan du anv\u00E4nda --=\neller -- . # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n En lista \u00F6ver kataloger, JAR-arkiv och ZIP-arkiv att\n s\u00F6ka efter klassfiler i, avgr\u00E4nsad med {0}.\n -p \n --module-path ...\n En lista \u00F6ver kataloger, d\u00E4r varje katalog \u00E4r en katalog\n med moduler, avgr\u00E4nsad med {0}.\n --upgrade-module-path ...\n En lista \u00F6ver kataloger, d\u00E4r varje katalog \u00E4r en katalog\n med moduler som ers\u00E4tter uppgraderingsbara moduler\n i exekveringsavbilden, avgr\u00E4nsad med {0} \n -m [/]\n --module [/]\n den ursprungliga modulen att l\u00F6sa och namnet p\u00E5 huvudklassen\n att k\u00F6ra, om den inte anges av modulen\n --add-modules [,...]\n rotmoduler att l\u00F6sa f\u00F6rutom den ursprungliga modulen.\n kan \u00E4ven vara ALL-DEFAULT, ALL-SYSTEM och\n ALL-MODULE-PATH.\n --limit-modules [,...]\n begr\u00E4nsa universumet med observerbara moduler\n --list-modules [[,...]]\n lista de observerbara modulerna och avsluta\n --dry-run skapa VM:en men k\u00F6r inte huvudmetoden.\n Det h\u00E4r alternativet kan vara anv\u00E4ndbart f\u00F6r att validera\n kommandoradsalternativen, som modulsystemkonfigurationen.\n -D=\n ange en systemegenskap\n -verbose:[class|gc|jni]\n aktivera utf\u00F6rliga utdata\n -version skriv ut produktversion och avsluta\n -showversion skriv ut produktversion och forts\u00E4tt\n -? -help --help\n skriv ut det h\u00E4r hj\u00E4lpmeddelandet\n -X skriv ut hj\u00E4lp f\u00F6r icke-standardalternativ\n -ea[:...|:]\n -enableassertions[:...|:]\n aktivera verifieringar med den angivna detaljgraden\n -da[:...|:]\n -disableassertions[:...|:]\n avaktivera verifieringar med den angivna detaljgraden\n -esa | -enablesystemassertions\n aktivera systemverifieringar\n -dsa | -disablesystemassertions\n avaktivera systemverifieringar\n -agentlib:[=]\n ladda det ursprungliga agentbiblioteket , exempel: -agentlib:jdwp\n se \u00E4ven -agentlib:jdwp=help\n -agentpath:[=]\n ladda det ursprungliga agentbiblioteket med fullst\u00E4ndigt s\u00F6kv\u00E4gsnamn\n -javaagent:[=]\n ladda agenten f\u00F6r programmeringsspr\u00E5ket Java, se java.lang.instrument\n -splash:\n visa v\u00E4lkomstsk\u00E4rmen med den angivna bilden\n HiDPI-skal\u00E4ndrade bilder st\u00F6ds automatiskt och anv\u00E4nds om de \u00E4r\n tillg\u00E4ngliga. Filnamnet p\u00E5 den oskal\u00E4ndrade bilden, t.ex.\n bild.filtill\u00E4gg, ska alltid \u00F6verf\u00F6ras som argument till\n alternativet -splash.\n Den l\u00E4mpligaste skal\u00E4ndrade bilden v\u00E4ljs automatiskt.\n Mer information finns i dokumentationen f\u00F6r API:t SplashScreen.\n @ l\u00E4s alternativ fr\u00E5n den angivna filen\nOm du vill ange ett argument f\u00F6r \ -ett l\u00E5ngt alternativ kan du anv\u00E4nda --=\neller -- .\n -See Se http://www.oracle.com/technetwork/java/javase/documentation/index.html f\u00F6r mer information. - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch avaktivera bakgrundskompilering\n -Xbootclasspath/a:\n l\u00E4gg till sist i klass\u00F6kv\u00E4gen f\u00F6r programladdning\n -Xcheck:jni utf\u00F6r fler kontroller f\u00F6r JNI-funktioner\n -Xcomp tvingar kompilering av metoder vid det f\u00F6rsta anropet\n -Xdebug tillhandah\u00E5lls f\u00F6r bak\u00E5tkompatibilitet\n -Xdiag visa fler diagnostiska meddelanden\n -Xdiag:resolver visa diagnostiska meddelanden f\u00F6r matchning\n -Xfuture aktivera str\u00E4ngaste kontroller, f\u00F6rv\u00E4ntad framtida standard\n -Xint endast exekvering i tolkat l\u00E4ge\n -Xinternalversion\n visar mer detaljerad information om JVM-version \u00E4n\n alternativet -version\n -Xloggc: logga GC-status till en fil med tidsst\u00E4mplar\n -Xmixed exekvering i blandat l\u00E4ge (standard)\n -Xmn anger ursprunglig och maximal storlek (i byte) f\u00F6r h\u00F6gen f\u00F6r\n generationen med nyare objekt (h\u00F6gen f\u00F6r tilldelning av nya objekt)\n -Xms ange ursprunglig storlek f\u00F6r Java-heap-utrymmet\n -Xmx ange st\u00F6rsta storlek f\u00F6r Java-heap-utrymmet\n -Xnoclassgc avaktivera klasskr\u00E4pinsamling\n -Xprof utdata f\u00F6r processorprofilering\n -Xrs minska operativsystemssignalanv\u00E4ndning f\u00F6r Java/VM (se dokumentationen)\n -Xshare:auto anv\u00E4nd delade klassdata om m\u00F6jligt (standard)\n -Xshare:off f\u00F6rs\u00F6k inte anv\u00E4nda delade klassdata\n -Xshare:on kr\u00E4v anv\u00E4ndning av delade klassdata, utf\u00F6r inte i annat fall.\n -XshowSettings visa alla inst\u00E4llningar och forts\u00E4tt\n -XshowSettings:all\n visa alla inst\u00E4llningar och forts\u00E4tt\n -XshowSettings:locale\n visa alla spr\u00E5kkonventionsrelaterade inst\u00E4llningar och forts\u00E4tt\n -XshowSettings:properties\n visa alla egenskapsinst\u00E4llningar och forts\u00E4tt\n -XshowSettings:vm visa alla vm-relaterade inst\u00E4llningar och forts\u00E4tt\n -Xss ange storlek f\u00F6r java-tr\u00E5dsstacken\n -Xverify anger l\u00E4ge f\u00F6r bytekodverifieraren\n --add-reads =(,)*\n uppdaterar att l\u00E4sa , oavsett\n moduldeklarationen. \n kan vara ALL-UNNAMED f\u00F6r att l\u00E4sa alla\n ej namngivna moduler.\n --add-exports /=(,)*\n uppdaterar att exportera till ,\n oavsett moduldeklarationen.\n kan vara ALL-UNNAMED f\u00F6r att exportera till alla\n ej namngivna moduler.\n --disable-@files avaktivera ytterligare argumentfilsut\u00F6kning\n --patch-module =({0})*\n \u00C5sidos\u00E4tt eller ut\u00F6ka en modul med klasser och resurser\n i JAR-filer eller kataloger.\n\nDe h\u00E4r alternativen \u00E4r icke-standardalternativ och kan \u00E4ndras utan f\u00F6reg\u00E5ende meddelande.\n +java.launcher.X.usage=\n -Xbatch avaktivera bakgrundskompilering\n -Xbootclasspath/a:\n l\u00E4gg till sist i klass\u00F6kv\u00E4gen f\u00F6r programladdning\n -Xcheck:jni utf\u00F6r fler kontroller f\u00F6r JNI-funktioner\n -Xcomp tvingar kompilering av metoder vid det f\u00F6rsta anropet\n -Xdebug tillhandah\u00E5lls f\u00F6r bak\u00E5tkompatibilitet\n -Xdiag visa fler diagnostiska meddelanden\n -Xdiag:resolver visa diagnostiska meddelanden f\u00F6r matchning\n -Xfuture aktivera str\u00E4ngaste kontroller, f\u00F6rv\u00E4ntad framtida standard\n -Xint endast exekvering i tolkat l\u00E4ge\n -Xinternalversion\n visar mer detaljerad information om JVM-version \u00E4n\n alternativet -version\n -Xloggc: logga GC-status till en fil med tidsst\u00E4mplar\n -Xmixed exekvering i blandat l\u00E4ge (standard)\n -Xmn anger ursprunglig och maximal storlek (i byte) f\u00F6r h\u00F6gen f\u00F6r\n generationen med nyare objekt (h\u00F6gen f\u00F6r tilldelning av nya objekt)\n -Xms ange ursprunglig storlek f\u00F6r Java-heap-utrymmet\n -Xmx ange st\u00F6rsta storlek f\u00F6r Java-heap-utrymmet\n -Xnoclassgc avaktivera klasskr\u00E4pinsamling\n -Xprof utdata f\u00F6r processorprofilering\n -Xrs minska operativsystemssignalanv\u00E4ndning f\u00F6r Java/VM (se dokumentationen)\n -Xshare:auto anv\u00E4nd delade klassdata om m\u00F6jligt (standard)\n -Xshare:off f\u00F6rs\u00F6k inte anv\u00E4nda delade klassdata\n -Xshare:on kr\u00E4v anv\u00E4ndning av delade klassdata, utf\u00F6r inte i annat fall.\n -XshowSettings visa alla inst\u00E4llningar och forts\u00E4tt\n -XshowSettings:all\n visa alla inst\u00E4llningar och forts\u00E4tt\n -XshowSettings:locale\n visa alla spr\u00E5kkonventionsrelaterade inst\u00E4llningar och forts\u00E4tt\n -XshowSettings:properties\n visa alla egenskapsinst\u00E4llningar och forts\u00E4tt\n -XshowSettings:vm visa alla vm-relaterade inst\u00E4llningar och forts\u00E4tt\n -Xss ange storlek f\u00F6r java-tr\u00E5dsstacken\n -Xverify anger l\u00E4ge f\u00F6r bytekodverifieraren\n --add-reads =(,)*\n uppdaterar f\u00F6r att l\u00E4sa , oavsett\n moduldeklarationen. \n kan vara ALL-UNNAMED f\u00F6r att l\u00E4sa alla\n ej namngivna moduler.\n --add-exports /=(,)*\n uppdaterar f\u00F6r att exportera till ,\n oavsett moduldeklarationen.\n kan vara ALL-UNNAMED f\u00F6r att exportera till alla\n ej namngivna moduler.\n --add-opens /=(,)*\n uppdaterar f\u00F6r att \u00F6ppna till\n , oavsett moduldeklarationen.\n --disable-@files avaktivera ytterligare argumentfilsut\u00F6kning\n --patch-module =({0})*\n \u00C5sidos\u00E4tt eller ut\u00F6ka en modul med klasser och resurser\n i JAR-filer eller kataloger.\n\nDe h\u00E4r extra alternativen kan \u00E4ndras utan f\u00F6reg\u00E5ende meddelande. # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\nF\u00F6ljande alternativ \u00E4r Mac OS X-specifika:\n -XstartOnFirstThread\n k\u00F6r main()-metoden p\u00E5 den f\u00F6rsta (AppKit)-tr\u00E5den\n -Xdock:name=\n \u00E5sidos\u00E4tt det standardapplikationsnamn som visas i dockan\n -Xdock:icon=\n \u00E5sidos\u00E4tt den standardikon som visas i dockan\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_CN.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_CN.properties index b2043dad703..70975375e3a 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_CN.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,23 +24,19 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = \u7528\u6CD5: {0} [options] class [args...]\n (\u6267\u884C\u7C7B)\n \u6216 {0} [options] -jar jarfile [args...]\n (\u6267\u884C jar \u6587\u4EF6)\n \u6216 {0} [options] -p <\u6A21\u5757\u8DEF\u5F84> -m <\u6A21\u5757\u540D\u79F0>[/<\u6A21\u5757\u7C7B>] [args...]\n (\u6267\u884C\u6A21\u5757\u4E2D\u7684\u4E3B\u7C7B)\n\u5176\u4E2D\u9009\u9879\u5305\u62EC:\n +java.launcher.opt.header = \u7528\u6CD5: {0} [options] class [args...]\n (\u6267\u884C\u7C7B)\n \u6216 {0} [options] -jar jarfile [args...]\n (\u6267\u884C jar \u6587\u4EF6)\n \u6216 {0} [options] -p <\u6A21\u5757\u8DEF\u5F84> -m <\u6A21\u5757\u540D\u79F0>[/<\u6A21\u5757\u7C7B>] [args...]\n (\u6267\u884C\u6A21\u5757\u4E2D\u7684\u4E3B\u7C7B)\n\u5176\u4E2D\u9009\u9879\u5305\u62EC:\n\n java.launcher.opt.datamodel =\ -d{0}\t \u5DF2\u8FC7\u65F6, \u5728\u4EE5\u540E\u7684\u53D1\u884C\u7248\u4E2D\u5C06\u88AB\u5220\u9664\n java.launcher.opt.vmselect =\ {0}\t \u9009\u62E9 "{1}" VM\n java.launcher.opt.hotspot =\ {0}\t \u662F "{1}" VM \u7684\u540C\u4E49\u8BCD [\u5DF2\u8FC7\u65F6]\n -java.launcher.ergo.message1 =\ \u9ED8\u8BA4 VM \u662F {0} -java.launcher.ergo.message2 =\ \u56E0\u4E3A\u60A8\u662F\u5728\u670D\u52A1\u5668\u7C7B\u8BA1\u7B97\u673A\u4E0A\u8FD0\u884C\u3002\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp <\u76EE\u5F55\u548C zip/jar \u6587\u4EF6\u7684\u7C7B\u641C\u7D22\u8DEF\u5F84>\n -classpath <\u76EE\u5F55\u548C zip/jar \u6587\u4EF6\u7684\u7C7B\u641C\u7D22\u8DEF\u5F84>\n --class-path <\u76EE\u5F55\u548C zip/jar \u6587\u4EF6\u7684\u7C7B\u641C\u7D22\u8DEF\u5F84>\n \u7528\u4E8E\u641C\u7D22\u7C7B\u6587\u4EF6\u7684\u76EE\u5F55, JAR \u6863\u6848\n \u548C ZIP \u6863\u6848\u7684\u5217\u8868, \u4F7F\u7528 {0} \u5206\u9694\u3002\n -p <\u6A21\u5757\u8DEF\u5F84>\n --module-path <\u6A21\u5757\u8DEF\u5F84>...\n \u7528 {0} \u5206\u9694\u7684\u76EE\u5F55\u5217\u8868, \u6BCF\u4E2A\u76EE\u5F55\n \u90FD\u662F\u4E00\u4E2A\u5305\u542B\u6A21\u5757\u7684\u76EE\u5F55\u3002\n --upgrade-module-path <\u6A21\u5757\u8DEF\u5F84>...\n \u7528 {0} \u5206\u9694\u7684\u76EE\u5F55\u5217\u8868, \u6BCF\u4E2A\u76EE\u5F55\n \u90FD\u662F\u4E00\u4E2A\u5305\u542B\u6A21\u5757\u7684\u76EE\u5F55, \u8FD9\u4E9B\u6A21\u5757\n \u7528\u4E8E\u66FF\u6362\u8FD0\u884C\u65F6\u6620\u50CF\u4E2D\u7684\u53EF\u5347\u7EA7\u6A21\u5757\n -m <\u6A21\u5757>[/<\u4E3B\u7C7B>]\n --module <\u6A21\u5757\u540D\u79F0>[/<\u4E3B\u7C7B>]\n \u8981\u89E3\u6790\u7684\u521D\u59CB\u6A21\u5757, \u4EE5\u53CA\u5728\u672A\u7531\u6A21\u5757\u6307\u5B9A\u65F6\n \u8981\u6267\u884C\u7684\u4E3B\u7C7B\u540D\u79F0\n --add-modules <\u6A21\u5757\u540D\u79F0>[,<\u6A21\u5757\u540D\u79F0>...]\n \u9664\u4E86\u521D\u59CB\u6A21\u5757\u4E4B\u5916\u8981\u89E3\u6790\u7684\u6839\u6A21\u5757\u3002\n <\u6A21\u5757\u540D\u79F0> \u8FD8\u53EF\u4EE5\u4E3A ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH\u3002\n --limit-modules <\u6A21\u5757\u540D\u79F0>[,<\u6A21\u5757\u540D\u79F0>...]\n \u9650\u5236\u53EF\u89C2\u5BDF\u6A21\u5757\u7684\u9886\u57DF\n --list-modules [<\u6A21\u5757\u540D\u79F0>[,<\u6A21\u5757\u540D\u79F0>...]]\n \u5217\u51FA\u53EF\u89C2\u5BDF\u6A21\u5757\u5E76\u9000\u51FA\n --dry-run \u521B\u5EFA VM \u4F46\u4E0D\u6267\u884C main \u65B9\u6CD5\u3002\n \u6B64 --dry-run \u9009\u9879\u5BF9\u4E8E\u9A8C\u8BC1\u8BF8\u5982\n \u6A21\u5757\u7CFB\u7EDF\u914D\u7F6E\u8FD9\u6837\u7684\u547D\u4EE4\u884C\u9009\u9879\u53EF\u80FD\u662F\u975E\u5E38\u6709\u7528\u7684\u3002\n -D<\u540D\u79F0>=<\u503C>\n \u8BBE\u7F6E\u7CFB\u7EDF\u5C5E\u6027\n -verbose:[class|gc|jni]\n \u542F\u7528\u8BE6\u7EC6\u8F93\u51FA\n -version \u5C06\u4EA7\u54C1\u7248\u672C\u8F93\u51FA\u5230\u9519\u8BEF\u6D41\u5E76\u9000\u51FA\n --version \u5C06\u4EA7\u54C1\u7248\u672C\u8F93\u51FA\u5230\u8F93\u51FA\u6D41\u5E76\u9000\u51FA\n -showversion \u5C06\u4EA7\u54C1\u7248\u672C\u8F93\u51FA\u5230\u9519\u8BEF\u6D41\u5E76\u7EE7\u7EED\n --show-version\n \u5C06\u4EA7\u54C1\u7248\u672C\u8F93\u51FA\u5230\u8F93\u51FA\u6D41\u5E76\u7EE7\u7EED\n -? -h -help\n \u5C06\u6B64\u5E2E\u52A9\u6D88\u606F\u8F93\u51FA\u5230\u9519\u8BEF\u6D41\n --help \u5C06\u6B64\u5E2E\u52A9\u6D88\u606F\u8F93\u51FA\u5230\u8F93\u51FA\u6D41\n -X \u5C06\u989D\u5916\u9009\u9879\u7684\u5E2E\u52A9\u8F93\u51FA\u5230\u9519\u8BEF\u6D41\n --help-extra \u5C06\u989D\u5916\u9009\u9879\u7684\u5E2E\u52A9\u8F93\u51FA\u5230\u8F93\u51FA\u6D41\n -ea[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n -enableassertions[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n \u6309\u6307\u5B9A\u7684\u7C92\u5EA6\u542F\u7528\u65AD\u8A00\n -da[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n -disableassertions[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n \u6309\u6307\u5B9A\u7684\u7C92\u5EA6\u7981\u7528\u65AD\u8A00\n -esa | -enablesystemassertions\n \u542F\u7528\u7CFB\u7EDF\u65AD\u8A00\n -dsa | \ +-disablesystemassertions\n \u7981\u7528\u7CFB\u7EDF\u65AD\u8A00\n -agentlib:<\u5E93\u540D>[=<\u9009\u9879>]\n \u52A0\u8F7D\u672C\u673A\u4EE3\u7406\u5E93 <\u5E93\u540D>, \u4F8B\u5982 -agentlib:jdwp\n \u53E6\u8BF7\u53C2\u9605 -agentlib:jdwp=help\n -agentpath:<\u8DEF\u5F84\u540D>[=<\u9009\u9879>]\n \u6309\u5B8C\u6574\u8DEF\u5F84\u540D\u52A0\u8F7D\u672C\u673A\u4EE3\u7406\u5E93\n -javaagent:[=<\u9009\u9879>]\n \u52A0\u8F7D Java \u7F16\u7A0B\u8BED\u8A00\u4EE3\u7406, \u8BF7\u53C2\u9605 java.lang.instrument\n -splash:<\u56FE\u50CF\u8DEF\u5F84>\n \u4F7F\u7528\u6307\u5B9A\u7684\u56FE\u50CF\u663E\u793A\u542F\u52A8\u5C4F\u5E55\n \u81EA\u52A8\u652F\u6301\u548C\u4F7F\u7528 HiDPI \u7F29\u653E\u56FE\u50CF\n (\u5982\u679C\u53EF\u7528)\u3002\u672A\u7F29\u653E\u7684\u56FE\u50CF\u6587\u4EF6\u540D (\u4F8B\u5982, image.ext)\n \u5E94\u59CB\u7EC8\u4F5C\u4E3A\u53C2\u6570\u4F20\u9012\u7ED9 -splash \u9009\u9879\u3002\n \u5C06\u81EA\u52A8\u9009\u53D6\u63D0\u4F9B\u7684\u6700\u9002\u5F53\u7684\u7F29\u653E\n \u56FE\u50CF\u3002\n \u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605 SplashScreen API \u6587\u6863\u3002\n @<\u6587\u4EF6\u8DEF\u5F84> \u4ECE\u6307\u5B9A\u6587\u4EF6\u4E2D\u8BFB\u53D6\u9009\u9879\n\n\u8981\u4E3A\u957F\u9009\u9879\u6307\u5B9A\u53C2\u6570, \u53EF\u4EE5\u4F7F\u7528 --<\u540D\u79F0>=<\u503C> \u6216\n--<\u540D\u79F0> <\u503C>\u3002\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp <\u76EE\u5F55\u548C zip/jar \u6587\u4EF6\u7684\u7C7B\u641C\u7D22\u8DEF\u5F84>\n -classpath <\u76EE\u5F55\u548C zip/jar \u6587\u4EF6\u7684\u7C7B\u641C\u7D22\u8DEF\u5F84>\n --class-path <\u76EE\u5F55\u548C zip/jar \u6587\u4EF6\u7684\u7C7B\u641C\u7D22\u8DEF\u5F84>\n \u7528\u4E8E\u641C\u7D22\u7C7B\u6587\u4EF6\u7684\u76EE\u5F55, JAR \u6863\u6848\n \u548C ZIP \u6863\u6848\u7684\u5217\u8868, \u4F7F\u7528 {0} \u5206\u9694\u3002\n -p <\u6A21\u5757\u8DEF\u5F84>\n --module-path <\u6A21\u5757\u8DEF\u5F84>...\n \u7528 {0} \u5206\u9694\u7684\u76EE\u5F55\u5217\u8868, \u6BCF\u4E2A\u76EE\u5F55\n \u90FD\u662F\u4E00\u4E2A\u5305\u542B\u6A21\u5757\u7684\u76EE\u5F55\u3002\n --upgrade-module-path <\u6A21\u5757\u8DEF\u5F84>...\n \u7528 {0} \u5206\u9694\u7684\u76EE\u5F55\u5217\u8868, \u6BCF\u4E2A\u76EE\u5F55\n \u90FD\u662F\u4E00\u4E2A\u5305\u542B\u6A21\u5757\u7684\u76EE\u5F55, \u8FD9\u4E9B\u6A21\u5757\n \u7528\u4E8E\u66FF\u6362\u8FD0\u884C\u65F6\u6620\u50CF\u4E2D\u7684\u53EF\u5347\u7EA7\u6A21\u5757\n -m <\u6A21\u5757>[/<\u4E3B\u7C7B>]\n --module <\u6A21\u5757\u540D\u79F0>[/<\u4E3B\u7C7B>]\n \u8981\u89E3\u6790\u7684\u521D\u59CB\u6A21\u5757, \u4EE5\u53CA\u5728\u672A\u7531\u6A21\u5757\u6307\u5B9A\u65F6\n \u8981\u6267\u884C\u7684\u4E3B\u7C7B\u540D\u79F0\n --add-modules <\u6A21\u5757\u540D\u79F0>[,<\u6A21\u5757\u540D\u79F0>...]\n \u9664\u4E86\u521D\u59CB\u6A21\u5757\u4E4B\u5916\u8981\u89E3\u6790\u7684\u6839\u6A21\u5757\u3002\n <\u6A21\u5757\u540D\u79F0> \u8FD8\u53EF\u4EE5\u4E3A ALL-DEFAULT, ALL-SYSTEM,\n ALL-MODULE-PATH\u3002\n --limit-modules <\u6A21\u5757\u540D\u79F0>[,<\u6A21\u5757\u540D\u79F0>...]\n \u9650\u5236\u53EF\u89C2\u5BDF\u6A21\u5757\u7684\u9886\u57DF\n --list-modules [<\u6A21\u5757\u540D\u79F0>[,<\u6A21\u5757\u540D\u79F0>...]]\n \u5217\u51FA\u53EF\u89C2\u5BDF\u6A21\u5757\u5E76\u9000\u51FA\n --dry-run \u521B\u5EFA VM \u4F46\u4E0D\u6267\u884C\u4E3B\u65B9\u6CD5\u3002\n \u6B64 --dry-run \u9009\u9879\u5BF9\u4E8E\u9A8C\u8BC1\u8BF8\u5982\n \u6A21\u5757\u7CFB\u7EDF\u914D\u7F6E\u8FD9\u6837\u7684\u547D\u4EE4\u884C\u9009\u9879\u53EF\u80FD\u662F\u975E\u5E38\u6709\u7528\u7684\u3002\n -D<\u540D\u79F0>=<\u503C>\n \u8BBE\u7F6E\u7CFB\u7EDF\u5C5E\u6027\n -verbose:[class|gc|jni]\n \u542F\u7528\u8BE6\u7EC6\u8F93\u51FA\n -version \u8F93\u51FA\u4EA7\u54C1\u7248\u672C\u5E76\u9000\u51FA\n -showversion \u8F93\u51FA\u4EA7\u54C1\u7248\u672C\u5E76\u7EE7\u7EED\n -? -help --help\n \u8F93\u51FA\u6B64\u5E2E\u52A9\u6D88\u606F\n -X \u8F93\u51FA\u975E\u6807\u51C6\u9009\u9879\u7684\u5E2E\u52A9\n -ea[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n -enableassertions[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n \u6309\u6307\u5B9A\u7684\u7C92\u5EA6\u542F\u7528\u65AD\u8A00\n -da[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n -disableassertions[:<\u7A0B\u5E8F\u5305\u540D\u79F0>...|:<\u7C7B\u540D>]\n \u6309\u6307\u5B9A\u7684\u7C92\u5EA6\u7981\u7528\u65AD\u8A00\n -esa | -enablesystemassertions\n \u542F\u7528\u7CFB\u7EDF\u65AD\u8A00\n -dsa | -disablesystemassertions\n \u7981\u7528\u7CFB\u7EDF\u65AD\u8A00\n -agentlib:<\u5E93\u540D>[=<\u9009\u9879>]\n \u52A0\u8F7D\u672C\u673A\u4EE3\u7406\u5E93 <\u5E93\u540D>, \u4F8B\u5982 -agentlib:jdwp\n \u53E6\u8BF7\u53C2\u9605 -agentlib:jdwp=help\n -agentpath:<\u8DEF\u5F84\u540D>[=<\u9009\u9879>]\n \u6309\u5B8C\u6574\u8DEF\u5F84\u540D\u52A0\u8F7D\u672C\u673A\u4EE3\u7406\u5E93\n -javaagent:[=<\u9009\u9879>]\n \u52A0\u8F7D \ -Java \u7F16\u7A0B\u8BED\u8A00\u4EE3\u7406, \u8BF7\u53C2\u9605 java.lang.instrument\n -splash:<\u56FE\u50CF\u8DEF\u5F84>\n \u4F7F\u7528\u6307\u5B9A\u7684\u56FE\u50CF\u663E\u793A\u542F\u52A8\u5C4F\u5E55\n \u81EA\u52A8\u652F\u6301\u548C\u4F7F\u7528 HiDPI \u7F29\u653E\u56FE\u50CF\n (\u5982\u679C\u53EF\u7528)\u3002\u672A\u7F29\u653E\u7684\u56FE\u50CF\u6587\u4EF6\u540D (\u4F8B\u5982, image.ext)\n \u5E94\u59CB\u7EC8\u4F5C\u4E3A\u53C2\u6570\u4F20\u9012\u7ED9 -splash \u9009\u9879\u3002\n \u5C06\u81EA\u52A8\u9009\u53D6\u63D0\u4F9B\u7684\u6700\u9002\u5F53\u7684\u7F29\u653E\n \u56FE\u50CF\u3002\n \u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605 SplashScreen API \u6587\u6863\u3002\n @<\u6587\u4EF6\u8DEF\u5F84> \u4ECE\u6307\u5B9A\u6587\u4EF6\u4E2D\u8BFB\u53D6\u9009\u9879\n\u8981\u4E3A\u957F\u9009\u9879\u6307\u5B9A\u53C2\u6570, \u53EF\u4EE5\u4F7F\u7528 --<\u540D\u79F0>=<\u503C> \u6216\n--<\u540D\u79F0> <\u503C>\u3002\n -See \u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605 http://www.oracle.com/technetwork/java/javase/documentation/index.html\u3002 - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch \u7981\u7528\u540E\u53F0\u7F16\u8BD1\n -Xbootclasspath/a:<\u7528 {0} \u5206\u9694\u7684\u76EE\u5F55\u548C zip/jar \u6587\u4EF6>\n \u9644\u52A0\u5728\u5F15\u5BFC\u7C7B\u8DEF\u5F84\u672B\u5C3E\n -Xcheck:jni \u5BF9 JNI \u51FD\u6570\u6267\u884C\u5176\u4ED6\u68C0\u67E5\n -Xcomp \u5728\u9996\u6B21\u8C03\u7528\u65F6\u5F3A\u5236\u7F16\u8BD1\u65B9\u6CD5\n -Xdebug \u4E3A\u5B9E\u73B0\u5411\u540E\u517C\u5BB9\u800C\u63D0\u4F9B\n -Xdiag \u663E\u793A\u9644\u52A0\u8BCA\u65AD\u6D88\u606F\n -Xdiag:resolver \u663E\u793A\u89E3\u6790\u5668\u8BCA\u65AD\u6D88\u606F\n -Xfuture \u542F\u7528\u6700\u4E25\u683C\u7684\u68C0\u67E5, \u9884\u671F\u5C06\u6765\u7684\u9ED8\u8BA4\u503C\n -Xint \u4EC5\u89E3\u91CA\u6A21\u5F0F\u6267\u884C\n -Xinternalversion\n \u663E\u793A\u6BD4 -version \u9009\u9879\u66F4\u8BE6\u7EC6\u7684 JVM\n \u7248\u672C\u4FE1\u606F\n -Xloggc:<\u6587\u4EF6> \u5C06 GC \u72B6\u6001\u8BB0\u5F55\u5728\u6587\u4EF6\u4E2D (\u5E26\u65F6\u95F4\u6233)\n -Xmixed \u6DF7\u5408\u6A21\u5F0F\u6267\u884C (\u9ED8\u8BA4\u503C)\n -Xmn<\u5927\u5C0F> \u4E3A\u5E74\u8F7B\u4EE3 (\u65B0\u751F\u4EE3) \u8BBE\u7F6E\u521D\u59CB\u548C\u6700\u5927\u5806\u5927\u5C0F\n (\u4EE5\u5B57\u8282\u4E3A\u5355\u4F4D)\n -Xms<\u5927\u5C0F> \u8BBE\u7F6E\u521D\u59CB Java \u5806\u5927\u5C0F\n -Xmx<\u5927\u5C0F> \u8BBE\u7F6E\u6700\u5927 Java \u5806\u5927\u5C0F\n -Xnoclassgc \u7981\u7528\u7C7B\u5783\u573E\u6536\u96C6\n -Xprof \u8F93\u51FA cpu \u914D\u7F6E\u6587\u4EF6\u6570\u636E\n -Xrs \u51CF\u5C11 Java/VM \u5BF9\u64CD\u4F5C\u7CFB\u7EDF\u4FE1\u53F7\u7684\u4F7F\u7528 (\u8BF7\u53C2\u9605\u6587\u6863)\n -Xshare:auto \u5728\u53EF\u80FD\u7684\u60C5\u51B5\u4E0B\u4F7F\u7528\u5171\u4EAB\u7C7B\u6570\u636E (\u9ED8\u8BA4\u503C)\n -Xshare:off \u4E0D\u5C1D\u8BD5\u4F7F\u7528\u5171\u4EAB\u7C7B\u6570\u636E\n -Xshare:on \u8981\u6C42\u4F7F\u7528\u5171\u4EAB\u7C7B\u6570\u636E, \u5426\u5219\u5C06\u5931\u8D25\u3002\n -XshowSettings \u663E\u793A\u6240\u6709\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -XshowSettings:all\n \u663E\u793A\u6240\u6709\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -XshowSettings:locale\n \u663E\u793A\u6240\u6709\u4E0E\u533A\u57DF\u8BBE\u7F6E\u76F8\u5173\u7684\u8BBE\u7F6E\u5E76\u7EE7\u7EEDe\n -XshowSettings:properties\n \u663E\u793A\u6240\u6709\u5C5E\u6027\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -XshowSettings:vm \u663E\u793A\u6240\u6709\u4E0E vm \u76F8\u5173\u7684\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -Xss<\u5927\u5C0F> \u8BBE\u7F6E Java \u7EBF\u7A0B\u5806\u6808\u5927\u5C0F\n -Xverify \u8BBE\u7F6E\u5B57\u8282\u7801\u9A8C\u8BC1\u5668\u7684\u6A21\u5F0F\n --add-reads <\u6A21\u5757>=<\u76EE\u6807\u6A21\u5757>(,<\u76EE\u6807\u6A21\u5757>)*\n \u66F4\u65B0 <\u6A21\u5757> \u4EE5\u8BFB\u53D6 <\u76EE\u6807\u6A21\u5757>,\n \u800C\u65E0\u8BBA\u6A21\u5757\u58F0\u660E\u5982\u4F55\u3002\n <\u76EE\u6807\u6A21\u5757> \u53EF\u4EE5\u662F ALL-UNNAMED \u4EE5\u8BFB\u53D6\u6240\u6709\u672A\u547D\u540D\n \u6A21\u5757\u3002\n --add-exports <\u6A21\u5757>/<\u7A0B\u5E8F\u5305>=<\u76EE\u6807\u6A21\u5757>(,<\u76EE\u6807\u6A21\u5757>)*\n \u66F4\u65B0 <\u6A21\u5757> \u4EE5\u5C06 <\u7A0B\u5E8F\u5305> \u5BFC\u51FA\u5230 <\u76EE\u6807\u6A21\u5757>,\n \u800C\u65E0\u8BBA\u6A21\u5757\u58F0\u660E\u5982\u4F55\u3002\n <\u76EE\u6807\u6A21\u5757> \u53EF\u4EE5\u662F ALL-UNNAMED \u4EE5\u5BFC\u51FA\u6240\u6709\n \u672A\u547D\u540D\u6A21\u5757\u3002\n --disable-@files \u7981\u6B62\u8FDB\u4E00\u6B65\u6269\u5C55\u53C2\u6570\u6587\u4EF6\n --patch-module \ -<\u6A21\u5757>=<\u6587\u4EF6>({0}<\u6587\u4EF6>)*\n \u4F7F\u7528 JAR \u6587\u4EF6\u6216\u76EE\u5F55\u4E2D\u7684\u7C7B\u548C\u8D44\u6E90\n \u8986\u76D6\u6216\u589E\u5F3A\u6A21\u5757\u3002\n\n\u8FD9\u4E9B\u9009\u9879\u662F\u975E\u6807\u51C6\u9009\u9879, \u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002\n +java.launcher.X.usage=\n -Xbatch \u7981\u7528\u540E\u53F0\u7F16\u8BD1\n -Xbootclasspath/a:<\u7528 {0} \u5206\u9694\u7684\u76EE\u5F55\u548C zip/jar \u6587\u4EF6>\n \u9644\u52A0\u5728\u5F15\u5BFC\u7C7B\u8DEF\u5F84\u672B\u5C3E\n -Xcheck:jni \u5BF9 JNI \u51FD\u6570\u6267\u884C\u5176\u4ED6\u68C0\u67E5\n -Xcomp \u5728\u9996\u6B21\u8C03\u7528\u65F6\u5F3A\u5236\u7F16\u8BD1\u65B9\u6CD5\n -Xdebug \u4E3A\u5B9E\u73B0\u5411\u540E\u517C\u5BB9\u800C\u63D0\u4F9B\n -Xdiag \u663E\u793A\u9644\u52A0\u8BCA\u65AD\u6D88\u606F\n -Xdiag:resolver \u663E\u793A\u89E3\u6790\u5668\u8BCA\u65AD\u6D88\u606F\n -Xfuture \u542F\u7528\u6700\u4E25\u683C\u7684\u68C0\u67E5, \u9884\u671F\u5C06\u6765\u7684\u9ED8\u8BA4\u503C\n -Xint \u4EC5\u89E3\u91CA\u6A21\u5F0F\u6267\u884C\n -Xinternalversion\n \u663E\u793A\u6BD4 -version \u9009\u9879\u66F4\u8BE6\u7EC6\u7684 JVM\n \u7248\u672C\u4FE1\u606F\n -Xloggc:<\u6587\u4EF6> \u5C06 GC \u72B6\u6001\u8BB0\u5F55\u5728\u6587\u4EF6\u4E2D (\u5E26\u65F6\u95F4\u6233)\n -Xmixed \u6DF7\u5408\u6A21\u5F0F\u6267\u884C (\u9ED8\u8BA4\u503C)\n -Xmn<\u5927\u5C0F> \u4E3A\u5E74\u8F7B\u4EE3 (\u65B0\u751F\u4EE3) \u8BBE\u7F6E\u521D\u59CB\u548C\u6700\u5927\u5806\u5927\u5C0F\n (\u4EE5\u5B57\u8282\u4E3A\u5355\u4F4D)\n -Xms<\u5927\u5C0F> \u8BBE\u7F6E\u521D\u59CB Java \u5806\u5927\u5C0F\n -Xmx<\u5927\u5C0F> \u8BBE\u7F6E\u6700\u5927 Java \u5806\u5927\u5C0F\n -Xnoclassgc \u7981\u7528\u7C7B\u5783\u573E\u6536\u96C6\n -Xprof \u8F93\u51FA cpu \u5206\u6790\u6570\u636E\n -Xrs \u51CF\u5C11 Java/VM \u5BF9\u64CD\u4F5C\u7CFB\u7EDF\u4FE1\u53F7\u7684\u4F7F\u7528 (\u8BF7\u53C2\u9605\u6587\u6863)\n -Xshare:auto \u5728\u53EF\u80FD\u7684\u60C5\u51B5\u4E0B\u4F7F\u7528\u5171\u4EAB\u7C7B\u6570\u636E (\u9ED8\u8BA4\u503C)\n -Xshare:off \u4E0D\u5C1D\u8BD5\u4F7F\u7528\u5171\u4EAB\u7C7B\u6570\u636E\n -Xshare:on \u8981\u6C42\u4F7F\u7528\u5171\u4EAB\u7C7B\u6570\u636E, \u5426\u5219\u5C06\u5931\u8D25\u3002\n -XshowSettings \u663E\u793A\u6240\u6709\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -XshowSettings:all\n \u663E\u793A\u6240\u6709\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -XshowSettings:locale\n \u663E\u793A\u6240\u6709\u4E0E\u533A\u57DF\u8BBE\u7F6E\u76F8\u5173\u7684\u8BBE\u7F6E\u5E76\u7EE7\u7EEDe\n -XshowSettings:properties\n \u663E\u793A\u6240\u6709\u5C5E\u6027\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -XshowSettings:vm \u663E\u793A\u6240\u6709\u4E0E vm \u76F8\u5173\u7684\u8BBE\u7F6E\u5E76\u7EE7\u7EED\n -Xss<\u5927\u5C0F> \u8BBE\u7F6E Java \u7EBF\u7A0B\u5806\u6808\u5927\u5C0F\n -Xverify \u8BBE\u7F6E\u5B57\u8282\u7801\u9A8C\u8BC1\u5668\u7684\u6A21\u5F0F\n --add-reads <\u6A21\u5757>=<\u76EE\u6807\u6A21\u5757>(,<\u76EE\u6807\u6A21\u5757>)*\n \u66F4\u65B0 <\u6A21\u5757> \u4EE5\u8BFB\u53D6 <\u76EE\u6807\u6A21\u5757>,\n \u800C\u65E0\u8BBA\u6A21\u5757\u58F0\u660E\u5982\u4F55\u3002\n <\u76EE\u6807\u6A21\u5757> \u53EF\u4EE5\u662F ALL-UNNAMED \u4EE5\u8BFB\u53D6\u6240\u6709\u672A\u547D\u540D\n \u6A21\u5757\u3002\n --add-exports <\u6A21\u5757>/<\u7A0B\u5E8F\u5305>=<\u76EE\u6807\u6A21\u5757>(,<\u76EE\u6807\u6A21\u5757>)*\n \u66F4\u65B0 <\u6A21\u5757> \u4EE5\u5C06 <\u7A0B\u5E8F\u5305> \u5BFC\u51FA\u5230 <\u76EE\u6807\u6A21\u5757>,\n \u800C\u65E0\u8BBA\u6A21\u5757\u58F0\u660E\u5982\u4F55\u3002\n <\u76EE\u6807\u6A21\u5757> \u53EF\u4EE5\u662F ALL-UNNAMED \u4EE5\u5BFC\u51FA\u6240\u6709\n \u672A\u547D\u540D\u6A21\u5757\u3002\n --add-opens \ +<\u6A21\u5757>/<\u7A0B\u5E8F\u5305>=<\u76EE\u6807\u6A21\u5757>(,<\u76EE\u6807\u6A21\u5757>)*\n \u66F4\u65B0 <\u6A21\u5757> \u4EE5\u5728 <\u76EE\u6807\u6A21\u5757> \u4E2D\n \u6253\u5F00 <\u7A0B\u5E8F\u5305>, \u800C\u65E0\u8BBA\u6A21\u5757\u58F0\u660E\u5982\u4F55\u3002\n --disable-@files \u7981\u6B62\u8FDB\u4E00\u6B65\u6269\u5C55\u53C2\u6570\u6587\u4EF6\n --patch-module <\u6A21\u5757>=<\u6587\u4EF6>({0}<\u6587\u4EF6>)*\n \u4F7F\u7528 JAR \u6587\u4EF6\u6216\u76EE\u5F55\u4E2D\u7684\u7C7B\u548C\u8D44\u6E90\n \u8986\u76D6\u6216\u589E\u5F3A\u6A21\u5757\u3002\n\n\u8FD9\u4E9B\u989D\u5916\u9009\u9879\u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\n\u4EE5\u4E0B\u9009\u9879\u4E3A Mac OS X \u7279\u5B9A\u7684\u9009\u9879:\n -XstartOnFirstThread\n \u5728\u7B2C\u4E00\u4E2A (AppKit) \u7EBF\u7A0B\u4E0A\u8FD0\u884C main() \u65B9\u6CD5\n -Xdock:name=<\u5E94\u7528\u7A0B\u5E8F\u540D\u79F0>\n \u8986\u76D6\u505C\u9760\u680F\u4E2D\u663E\u793A\u7684\u9ED8\u8BA4\u5E94\u7528\u7A0B\u5E8F\u540D\u79F0\n -Xdock:icon=<\u56FE\u6807\u6587\u4EF6\u7684\u8DEF\u5F84>\n \u8986\u76D6\u505C\u9760\u680F\u4E2D\u663E\u793A\u7684\u9ED8\u8BA4\u56FE\u6807\n\n diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_TW.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_TW.properties index 38815af2ae4..af484c784e2 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_TW.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_TW.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2016, 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 @@ -24,23 +24,19 @@ # # Translators please note do not translate the options themselves -java.launcher.opt.header = \u7528\u6CD5: {0} [options] class [args...]\n (\u7528\u65BC\u57F7\u884C\u985E\u5225)\n \u6216 {0} [options] -jar jarfile [args...]\n (\u7528\u65BC\u57F7\u884C jar \u6A94\u6848)\n \u6216 {0} [options] -p -m [/] [args...]\n (\u7528\u65BC\u57F7\u884C\u6A21\u7D44\u4E2D\u7684\u4E3B\u8981\u985E\u5225)\n\u5176\u4E2D\u7684\u9078\u9805\u5305\u62EC:\n +java.launcher.opt.header = \u7528\u6CD5: {0} [options] class [args...]\n (\u7528\u65BC\u57F7\u884C\u985E\u5225)\n \u6216 {0} [options] -jar jarfile [args...]\n (\u7528\u65BC\u57F7\u884C jar \u6A94\u6848)\n \u6216 {0} [options] -p -m [/] [args...]\n (\u7528\u65BC\u57F7\u884C\u6A21\u7D44\u4E2D\u7684\u4E3B\u8981\u985E\u5225)\n\u5176\u4E2D\u7684\u9078\u9805\u5305\u62EC:\n\n java.launcher.opt.datamodel =\ -d{0}\t \u5DF2\u4E0D\u518D\u4F7F\u7528\uFF0C\u5C07\u65BC\u672A\u4F86\u7248\u672C\u4E2D\u79FB\u9664\n java.launcher.opt.vmselect =\ {0}\t \u9078\u53D6 "{1}" VM\n java.launcher.opt.hotspot =\ {0}\t \u662F "{1}" VM \u7684\u540C\u7FA9\u5B57 [\u5DF2\u4E0D\u518D\u4F7F\u7528]\n -java.launcher.ergo.message1 =\ \u9810\u8A2D\u7684 VM \u70BA {0} -java.launcher.ergo.message2 =\ \u56E0\u70BA\u60A8\u6B63\u5728\u4F3A\u670D\u5668\u985E\u5225\u6A5F\u5668\u4E0A\u57F7\u884C\u3002\n +# Translators please note do not translate the options themselves +java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n \u4EE5 {0} \u5340\u9694\u7684\u76EE\u9304\u3001JAR \u5B58\u6A94\u4EE5\u53CA\n ZIP \u5B58\u6A94\u6E05\u55AE\uFF0C\u5C07\u5728\u5176\u4E2D\u641C\u5C0B\u985E\u5225\u6A94\u6848\u3002\n -p \n --module-path ...\n \u4EE5 {0} \u5340\u9694\u7684\u76EE\u9304\u6E05\u55AE\uFF0C\u6BCF\u500B\u76EE\u9304\n \u90FD\u662F\u4E00\u500B\u6A21\u7D44\u76EE\u9304\u3002\n --upgrade-module-path ...\n \u4EE5 {0} \u5340\u9694\u7684\u76EE\u9304\u6E05\u55AE\uFF0C\u6BCF\u500B\u76EE\u9304\n \u90FD\u662F\u4E00\u500B\u6A21\u7D44\u76EE\u9304\uFF0C \u7576\u4E2D\u7684\u6A21\u7D44\u53EF\u53D6\u4EE3\n \u7A0B\u5F0F\u5BE6\u969B\u57F7\u884C\u5F71\u50CF\u4E2D\u7684\u53EF\u5347\u7D1A\u6A21\u7D44\n -m [/]\n --module [/]\n \u8981\u89E3\u6790\u7684\u8D77\u59CB\u6A21\u7D44\uFF0C\u4EE5\u53CA\u8981\u57F7\u884C\u4E4B\u4E3B\u8981\u985E\u5225\n \u7684\u540D\u7A31 (\u82E5\u6A21\u7D44\u672A\u6307\u5B9A\u7684\u8A71)\n --add-modules [,...]\n \u9664\u4E86\u8D77\u59CB\u6A21\u7D44\u5916\uFF0C\u8981\u89E3\u6790\u7684\u6839\u6A21\u7D44\u3002\n \u4E5F\u53EF\u4EE5\u662F ALL-DEFAULT\u3001ALL-SYSTEM\u3001\n ALL-MODULE-PATH\u3002\n --limit-modules [,...]\n \u9650\u5236\u53EF\u76E3\u6E2C\u6A21\u7D44\u7684\u7BC4\u570D\n --list-modules [[,...]]\n \u5217\u51FA\u53EF\u76E3\u6E2C\u6A21\u7D44\u4E26\u7D50\u675F\n --dry-run \u5EFA\u7ACB VM \u4F46\u4E0D\u57F7\u884C\u4E3B\u8981\u65B9\u6CD5\u3002\n \u6B64 --dry-run \u9078\u9805\u5C0D\u65BC\u9A57\u8B49\u547D\u4EE4\u884C\u9078\u9805\n (\u4F8B\u5982\u6A21\u7D44\u7CFB\u7D71\u7D44\u614B) \u5F88\u6709\u7528\u3002\n -D=\n \u8A2D\u5B9A\u7CFB\u7D71\u5C6C\u6027\n -verbose:[class|gc|jni]\n \u555F\u7528\u8A73\u7D30\u8CC7\u8A0A\u8F38\u51FA\n -version \u5728\u932F\u8AA4\u4E32\u6D41\u5370\u51FA\u7522\u54C1\u7248\u672C\u4E26\u7D50\u675F\n --version \u5728\u8F38\u51FA\u4E32\u6D41\u5370\u51FA\u7522\u54C1\u7248\u672C\u4E26\u7D50\u675F\n -showversion \u5728\u932F\u8AA4\u4E32\u6D41\u5370\u51FA\u7522\u54C1\u7248\u672C\u4E26\u7E7C\u7E8C\n --show-version\n \u5728\u8F38\u51FA\u4E32\u6D41\u5370\u51FA\u7522\u54C1\u7248\u672C\u4E26\u7E7C\u7E8C\n -? -h -help\n \u5728\u932F\u8AA4\u4E32\u6D41\u5370\u51FA\u6B64\u8AAA\u660E\u8A0A\u606F\n --help \u5728\u8F38\u51FA\u4E32\u6D41\u5370\u51FA\u6B64\u8AAA\u660E\u8A0A\u606F\n -X \u5728\u932F\u8AA4\u4E32\u6D41\u5370\u51FA\u984D\u5916\u9078\u9805\u7684\u8AAA\u660E\n --help-extra \u5728\u8F38\u51FA\u4E32\u6D41\u5370\u51FA\u984D\u5916\u9078\u9805\u7684\u8AAA\u660E\n -ea[:...|:]\n -enableassertions[:...|:]\n \u555F\u7528\u6307\u5B9A\u4E4B\u8A73\u7D30\u7A0B\u5EA6\u7684\u5BA3\u544A\n -da[:...|:]\n -disableassertions[:...|:]\n \u505C\u7528\u6307\u5B9A\u4E4B\u8A73\u7D30\u7A0B\u5EA6\u7684\u5BA3\u544A\n -esa | -enablesystemassertions\n \u555F\u7528\u7CFB\u7D71\u5BA3\u544A\n -dsa | -disablesystemassertions\n \u505C\u7528\u7CFB\u7D71\u5BA3\u544A\n -agentlib:[=]\n \u8F09\u5165\u539F\u751F\u4EE3\u7406\u7A0B\u5F0F\u7A0B\u5F0F\u5EAB \uFF0C\u4F8B\u5982 -agentlib:jdwp\n \u53E6\u8ACB\u53C3\u95B1 \ +-agentlib:jdwp=help\n -agentpath:[=]\n \u4F9D\u5B8C\u6574\u8DEF\u5F91\u540D\u7A31\u8F09\u5165\u539F\u751F\u4EE3\u7406\u7A0B\u5F0F\u7A0B\u5F0F\u5EAB\n -javaagent:[=]\n \u8F09\u5165 Java \u7A0B\u5F0F\u8A9E\u8A00\u4EE3\u7406\u7A0B\u5F0F\uFF0C\u8ACB\u53C3\u95B1 java.lang.instrument\n -splash:\n \u986F\u793A\u542B\u6307\u5B9A\u5F71\u50CF\u7684\u8EDF\u9AD4\u8CC7\u8A0A\u756B\u9762\n \u7CFB\u7D71\u6703\u81EA\u52D5\u652F\u63F4\u4E26\u4F7F\u7528 HiDPI \u5DF2\u7E2E\u653E\u5F71\u50CF\n (\u5982\u679C\u53EF\u7528\u7684\u8A71)\u3002\u672A\u7E2E\u653E\u5F71\u50CF\u6A94\u6848\u540D\u7A31 (\u4F8B\u5982 image.ext)\n \u61C9\u4E00\u5F8B\u4EE5\u5F15\u6578\u7684\u5F62\u5F0F\u50B3\u9001\u5230 -splash \u9078\u9805\u3002\n \u7CFB\u7D71\u6703\u81EA\u52D5\u5F9E\u63D0\u4F9B\u7684\u5DF2\u7E2E\u653E\u5F71\u50CF\u4E2D\u9078\u64C7\u6700\u9069\u5408\u7684\n \u5DF2\u7E2E\u653E\u5F71\u50CF\u3002\n \u8ACB\u53C3\u95B1 SplashScreen API \u6587\u4EF6\uFF0C\u4EE5\u77AD\u89E3\u8A73\u7D30\u8CC7\u8A0A\u3002\n @ \u5F9E\u6307\u5B9A\u7684\u6A94\u6848\u8B80\u53D6\u9078\u9805\n\n\u82E5\u8981\u6307\u5B9A\u9577\u9078\u9805\u7684\u5F15\u6578\uFF0C\u53EF\u4EE5\u4F7F\u7528 --= \u6216\n-- \u3002\n # Translators please note do not translate the options themselves -java.launcher.opt.footer =\ -cp \n -classpath \n --class-path \n \u5C07\u5728\u5176\u4E2D\u641C\u5C0B\u985E\u5225\u6A94\u6848\u4E4B\u4EE5 {0} \u5340\u9694\u7684\n \u76EE\u9304\u3001JAR \u5B58\u6A94\u4EE5\u53CA ZIP \u5B58\u6A94\u6E05\u55AE\u3002\n -p \n --module-path ...\n \u4EE5 {0} \u5340\u9694\u7684\u76EE\u9304\u6E05\u55AE\uFF0C\u6BCF\u500B\u76EE\u9304\n \u662F\u4E00\u500B\u6A21\u7D44\u76EE\u9304\u3002\n --upgrade-module-path ...\n \u4EE5 {0} \u5340\u9694\u7684\u76EE\u9304\u6E05\u55AE\uFF0C\u6BCF\u500B\u76EE\u9304\n \u90FD\u662F\u4E00\u500B\u6A21\u7D44\u76EE\u9304\uFF0C\u7576\u4E2D\u7684\u6A21\u7D44\u53EF\u53D6\u4EE3\n \u7A0B\u5F0F\u5BE6\u969B\u57F7\u884C\u5F71\u50CF\u4E2D\u7684\u53EF\u5347\u7D1A\u6A21\u7D44\n -m [/]\n --module [/]\n \u8981\u89E3\u6790\u7684\u8D77\u59CB\u6A21\u7D44\uFF0C\u4EE5\u53CA\u6A21\u7D44\u672A\u6307\u5B9A\u6642\n \u6240\u8981\u57F7\u884C\u4E4B\u4E3B\u8981\u985E\u5225\u7684\u540D\u7A31\n --add-modules [,...]\n \u9664\u4E86\u8D77\u59CB\u6A21\u7D44\u5916\uFF0C\u8981\u89E3\u6790\u7684\u6839\u6A21\u7D44\u3002\n \u4E5F\u53EF\u4EE5\u662F ALL-DEFAULT\u3001ALL-SYSTEM\u3001\n ALL-MODULE-PATH\u3002\n --limit-modules [,...]\n \u9650\u5236\u53EF\u76E3\u6E2C\u6A21\u7D44\u7684\u7BC4\u570D\n --list-modules [[,...]]\n \u5217\u51FA\u53EF\u76E3\u6E2C\u6A21\u7D44\u4E26\u7D50\u675F\n --dry-run \u5EFA\u7ACB VM \u4F46\u4E0D\u57F7\u884C\u4E3B\u8981\u65B9\u6CD5\u3002\n \u6B64 --dry-run \u9078\u9805\u5C0D\u65BC\u9A57\u8B49\u547D\u4EE4\u884C\u9078\u9805\n (\u4F8B\u5982\u6A21\u7D44\u7CFB\u7D71\u7D44\u614B) \u6703\u5F88\u6709\u7528\u3002\n -D=\n \u8A2D\u5B9A\u7CFB\u7D71\u5C6C\u6027\n -verbose:[class|gc|jni]\n \u555F\u7528\u8A73\u7D30\u8CC7\u8A0A\u8F38\u51FA\n -version \u5217\u5370\u7522\u54C1\u7248\u672C\u4E26\u7D50\u675F\n -showversion \u5217\u5370\u7522\u54C1\u7248\u672C\u4E26\u7E7C\u7E8C\n -? -help --help\n \u5217\u5370\u672C\u8AAA\u660E\u8A0A\u606F\n -X \u5217\u5370\u975E\u6A19\u6E96\u9078\u9805\u7684\u8AAA\u660E\n -ea[:...|:]\n -enableassertions[:...|:]\n \u555F\u7528\u6307\u5B9A\u4E4B\u8A73\u7D30\u7A0B\u5EA6\u7684\u5BA3\u544A\n -da[:...|:]\n -disableassertions[:...|:]\n \u505C\u7528\u6307\u5B9A\u4E4B\u8A73\u7D30\u7A0B\u5EA6\u7684\u5BA3\u544A\n -esa | -enablesystemassertions\n \u555F\u7528\u7CFB\u7D71\u5BA3\u544A\n -dsa | -disablesystemassertions\n \u505C\u7528\u7CFB\u7D71\u5BA3\u544A\n -agentlib:[=]\n \u8F09\u5165\u539F\u751F\u4EE3\u7406\u7A0B\u5F0F\u7A0B\u5F0F\u5EAB \uFF0C\u4F8B\u5982 -agentlib:jdwp\n \u53E6\u8ACB\u53C3\u95B1 -agentlib:jdwp=help\n -agentpath:[=]\n \u4F7F\u7528\u5B8C\u6574\u8DEF\u5F91\u540D\u7A31\u8F09\u5165\u539F\u751F\u4EE3\u7406\u7A0B\u5F0F\u7A0B\u5F0F\u5EAB\n -javaagent:[=]\n \u8F09\u5165 Java \u7A0B\u5F0F\u8A9E\u8A00\u4EE3\u7406\u7A0B\u5F0F\uFF0C\u8ACB\u53C3\u95B1 java.lang.instrument\n -splash:\n \u986F\u793A\u542B\u6307\u5B9A\u5F71\u50CF\u7684\u8EDF\u9AD4\u8CC7\u8A0A\u756B\u9762\n \ -\u7CFB\u7D71\u6703\u81EA\u52D5\u652F\u63F4\u4E26\u4F7F\u7528 HiDPI \u5DF2\u7E2E\u653E\u5F71\u50CF\n (\u5982\u679C\u53EF\u7528\u7684\u8A71)\u3002\u672A\u7E2E\u653E\u5F71\u50CF\u6A94\u6848\u540D\u7A31 (\u4F8B\u5982 image.ext)\n \u61C9\u4E00\u5F8B\u4EE5\u5F15\u6578\u7684\u5F62\u5F0F\u50B3\u9001\u5230 -splash \u9078\u9805\u3002\n \u7CFB\u7D71\u6703\u81EA\u52D5\u5F9E\u63D0\u4F9B\u7684\u5DF2\u7E2E\u653E\u5F71\u50CF\u4E2D\u9078\u64C7\u6700\u9069\u5408\u7684\n \u5DF2\u7E2E\u653E\u5F71\u50CF\u3002\n \u8ACB\u53C3\u95B1 SplashScreen API \u6587\u4EF6\uFF0C\u4EE5\u53D6\u5F97\u66F4\u591A\u8CC7\u8A0A\u3002\n @ \u5F9E\u6307\u5B9A\u7684\u6A94\u6848\u8B80\u53D6\u9078\u9805\n\u82E5\u8981\u6307\u5B9A\u9577\u9078\u9805\u7684\u5F15\u6578\uFF0C\u53EF\u4EE5\u4F7F\u7528 --= \u6216\n-- \u3002\n -See \u8ACB\u53C3\u95B1 http://www.oracle.com/technetwork/java/javase/documentation/index.html \u66B8\u89E3\u8A73\u7D30\u8CC7\u8A0A\u3002 - -# Translators please note do not translate the options themselves -java.launcher.X.usage=\ -Xbatch \u505C\u7528\u80CC\u666F\u7DE8\u8B6F\n -Xbootclasspath/a:\n \u52A0\u5728\u555F\u52D5\u5B89\u88DD\u985E\u5225\u8DEF\u5F91\u7684\u7D50\u5C3E\n -Xcheck:jni \u57F7\u884C\u5176\u4ED6\u7684 JNI \u51FD\u6578\u6AA2\u67E5\n -Xcomp \u5F37\u5236\u7DE8\u8B6F\u7B2C\u4E00\u500B\u547C\u53EB\u7684\u65B9\u6CD5\n -Xdebug \u70BA\u56DE\u6EAF\u76F8\u5BB9\u6027\u63D0\u4F9B\n -Xdiag \u986F\u793A\u5176\u4ED6\u8A3A\u65B7\u8A0A\u606F\n -Xdiag:resolver \u986F\u793A\u89E3\u6790\u5668\u8A3A\u65B7\u8A0A\u606F\n -Xfuture \u555F\u7528\u6700\u56B4\u683C\u7684\u6AA2\u67E5\uFF0C\u9810\u5148\u4F5C\u70BA\u5C07\u4F86\u7684\u9810\u8A2D\n -Xint \u50C5\u9650\u89E3\u8B6F\u6A21\u5F0F\u57F7\u884C\n -Xinternalversion\n \u986F\u793A\u6BD4\u4F7F\u7528 -version \u9078\u9805\u6642\u66F4\u70BA\u8A73\u7D30\u7684\n JVM \u7248\u672C\u8CC7\u8A0A\n -Xloggc: \u5C07 GC \u72C0\u614B\u548C\u6642\u6233\u8A18\u9304\u81F3\u6A94\u6848\n -Xmixed \u6DF7\u5408\u6A21\u5F0F\u57F7\u884C (\u9810\u8A2D)\n -Xmn \u91DD\u5C0D\u65B0\u751F\u4EE3 (\u990A\u6210\u5340) \u8A2D\u5B9A\u5806\u96C6\u7684\u8D77\u59CB\u5927\u5C0F\u548C\n \u5927\u5C0F\u4E0A\u9650 (\u4F4D\u5143\u7D44)\n -Xms \u8A2D\u5B9A\u8D77\u59CB Java \u5806\u96C6\u5927\u5C0F\n -Xmx \u8A2D\u5B9A Java \u5806\u96C6\u5927\u5C0F\u4E0A\u9650\n -Xnoclassgc \u505C\u7528\u985E\u5225\u8CC7\u6E90\u56DE\u6536\n -Xprof \u8F38\u51FA cpu \u5206\u6790\u8CC7\u6599\n -Xrs \u6E1B\u5C11 Java/VM \u4F7F\u7528\u4F5C\u696D\u7CFB\u7D71\u4FE1\u865F (\u8ACB\u53C3\u95B1\u6587\u4EF6)\n -Xshare:auto \u76E1\u53EF\u80FD\u4F7F\u7528\u5171\u7528\u985E\u5225\u8CC7\u6599 (\u9810\u8A2D)\n -Xshare:off \u4E0D\u5617\u8A66\u4F7F\u7528\u5171\u7528\u985E\u5225\u8CC7\u6599\n -Xshare:on \u9700\u8981\u4F7F\u7528\u5171\u7528\u985E\u5225\u8CC7\u6599\uFF0C\u5426\u5247\u5931\u6557\u3002\n -XshowSettings \u986F\u793A\u6240\u6709\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:all\n \u986F\u793A\u6240\u6709\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:locale\n \u986F\u793A\u6240\u6709\u5730\u5340\u8A2D\u5B9A\u76F8\u95DC\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:properties\n \u986F\u793A\u6240\u6709\u5C6C\u6027\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:vm \u986F\u793A\u6240\u6709 VM \u76F8\u95DC\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -Xss \u8A2D\u5B9A Java \u57F7\u884C\u7DD2\u5806\u758A\u5927\u5C0F\n -Xverify \u8A2D\u5B9A Bytecode \u9A57\u8B49\u7A0B\u5F0F\u6A21\u5F0F\n --add-reads =(,)*\n \u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\uFF0C\u66F4\u65B0 \u4EE5\n \u8B80\u53D6 \u3002\n \u53EF\u5C07 \u8A2D\u70BA ALL-UNNAMED \u4EE5\u8B80\u53D6\u6240\u6709\u672A\u547D\u540D\u7684\n \u6A21\u7D44\u3002\n --add-exports /=(,)*\n \u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\uFF0C\u66F4\u65B0 \u4EE5\u4FBF\u5C07 \n \u532F\u51FA\u81F3 \u3002\n \u53EF\u5C07 \u8A2D\u70BA ALL-UNNAMED \u4EE5\u532F\u51FA\u81F3\u6240\u6709\n \u672A\u547D\u540D\u7684\u6A21\u7D44\u3002\n --disable-@files \u505C\u7528\u9032\u4E00\u6B65\u7684\u5F15\u6578\u6A94\u6848\u64F4\u5145\n --patch-module =({0})*\n \u8986\u5BEB\u6216\u52A0\u5F37 JAR \u6A94\u6848\u6216\u76EE\u9304\u4E2D\n \ -\u542B\u6709\u985E\u5225\u548C\u8CC7\u6E90\u7684\u6A21\u7D44\u3002\n\n\u4E0A\u8FF0\u9078\u9805\u4E0D\u662F\u6A19\u6E96\u9078\u9805\uFF0C\u82E5\u6709\u8B8A\u66F4\u4E0D\u53E6\u884C\u901A\u77E5\u3002\n +java.launcher.X.usage=\n -Xbatch \u505C\u7528\u80CC\u666F\u7DE8\u8B6F\n -Xbootclasspath/a:\n \u9644\u52A0\u81F3\u555F\u52D5\u5B89\u88DD\u985E\u5225\u8DEF\u5F91\u7684\u7D50\u5C3E\n -Xcheck:jni \u57F7\u884C\u5176\u4ED6\u7684 JNI \u51FD\u6578\u6AA2\u67E5\n -Xcomp \u5F37\u5236\u7DE8\u8B6F\u7B2C\u4E00\u500B\u547C\u53EB\u7684\u65B9\u6CD5\n -Xdebug \u91DD\u5C0D\u56DE\u6EAF\u76F8\u5BB9\u6027\u63D0\u4F9B\n -Xdiag \u986F\u793A\u5176\u4ED6\u8A3A\u65B7\u8A0A\u606F\n -Xdiag:resolver \u986F\u793A\u89E3\u6790\u5668\u8A3A\u65B7\u8A0A\u606F\n -Xfuture \u555F\u7528\u6700\u56B4\u683C\u7684\u6AA2\u67E5\uFF0C\u9810\u5148\u4F5C\u70BA\u5C07\u4F86\u7684\u9810\u8A2D\n -Xint \u50C5\u9650\u89E3\u8B6F\u6A21\u5F0F\u57F7\u884C\n -Xinternalversion\n \u986F\u793A\u6BD4 -version \u9078\u9805\u66F4\u70BA\u8A73\u7D30\u7684\n JVM \u7248\u672C\u8CC7\u8A0A\n -Xloggc: \u5C07 GC \u72C0\u614B\u8A18\u9304\u81F3\u6A94\u6848\u4E14\u9023\u540C\u6642\u6233\n -Xmixed \u6DF7\u5408\u6A21\u5F0F\u57F7\u884C (\u9810\u8A2D)\n -Xmn \u8A2D\u5B9A\u65B0\u751F\u4EE3 (\u990A\u6210\u5340) \u4E4B\u5806\u96C6\u7684\u8D77\u59CB\u5927\u5C0F\u548C\n \u5927\u5C0F\u4E0A\u9650 (\u4F4D\u5143\u7D44)\n -Xms \u8A2D\u5B9A\u8D77\u59CB Java \u5806\u96C6\u5927\u5C0F\n -Xmx \u8A2D\u5B9A Java \u5806\u96C6\u5927\u5C0F\u4E0A\u9650\n -Xnoclassgc \u505C\u7528\u985E\u5225\u8CC7\u6E90\u56DE\u6536\n -Xprof \u8F38\u51FA cpu \u5206\u6790\u8CC7\u6599\n -Xrs \u6E1B\u5C11 Java/VM \u4F7F\u7528\u4F5C\u696D\u7CFB\u7D71\u4FE1\u865F (\u8ACB\u53C3\u95B1\u6587\u4EF6)\n -Xshare:auto \u5728\u53EF\u80FD\u7684\u60C5\u6CC1\u4E0B\u4F7F\u7528\u5171\u7528\u985E\u5225\u8CC7\u6599 (\u9810\u8A2D)\n -Xshare:off \u4E0D\u5617\u8A66\u4F7F\u7528\u5171\u7528\u985E\u5225\u8CC7\u6599\n -Xshare:on \u9700\u8981\u4F7F\u7528\u5171\u7528\u985E\u5225\u8CC7\u6599\uFF0C\u5426\u5247\u6703\u5931\u6557\u3002\n -XshowSettings \u986F\u793A\u6240\u6709\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:all\n \u986F\u793A\u6240\u6709\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:locale\n \u986F\u793A\u6240\u6709\u5730\u5340\u8A2D\u5B9A\u76F8\u95DC\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:properties\n \u986F\u793A\u6240\u6709\u5C6C\u6027\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -XshowSettings:vm \u986F\u793A\u6240\u6709 VM \u76F8\u95DC\u8A2D\u5B9A\u503C\u4E26\u7E7C\u7E8C\n -Xss \u8A2D\u5B9A Java \u57F7\u884C\u7DD2\u5806\u758A\u5927\u5C0F\n -Xverify \u8A2D\u5B9A Bytecode \u9A57\u8B49\u7A0B\u5F0F\u7684\u6A21\u5F0F\n --add-reads =(,)*\n \u66F4\u65B0 \u4EE5\u8B80\u53D6 \uFF0C\u7121\u8AD6\n \u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\u3002 \n \u53EF\u5C07 \u8A2D\u70BA ALL-UNNAMED \u4EE5\u8B80\u53D6\u6240\u6709\u672A\u547D\u540D\u7684\n \u6A21\u7D44\u3002\n --add-exports /=(,)*\n \u66F4\u65B0 \u4EE5\u4FBF\u5C07 \u532F\u51FA\u81F3 \uFF0C\n \u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\u3002\n \u53EF\u5C07 \u8A2D\u70BA ALL-UNNAMED \u4EE5\u532F\u51FA\u81F3\u6240\u6709\n \u672A\u547D\u540D\u7684\u6A21\u7D44\u3002\n --add-opens /=(,)*\n \u66F4\u65B0 \ +\u4EE5\u4FBF\u5C07 \u958B\u555F\u81F3\n \uFF0C\u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\u3002\n --disable-@files \u505C\u7528\u9032\u4E00\u6B65\u7684\u5F15\u6578\u6A94\u6848\u64F4\u5145\n --patch-module =({0})*\n \u8986\u5BEB\u6216\u52A0\u5F37\u542B\u6709 JAR \u6A94\u6848\u6216\u76EE\u9304\u4E2D\n \u985E\u5225\u548C\u8CC7\u6E90\u7684\u6A21\u7D44\u3002\n\n\u4E0A\u8FF0\u7684\u984D\u5916\u9078\u9805\u82E5\u6709\u8B8A\u66F4\u4E0D\u53E6\u884C\u901A\u77E5\u3002\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\n\u4E0B\u5217\u662F Mac OS X \u7279\u5B9A\u9078\u9805:\n -XstartOnFirstThread\n \u5728\u7B2C\u4E00\u500B (AppKit) \u57F7\u884C\u7DD2\u57F7\u884C main() \u65B9\u6CD5\n -Xdock:name=\n \u8986\u5BEB\u7D50\u5408\u8AAA\u660E\u756B\u9762\u4E2D\u986F\u793A\u7684\u9810\u8A2D\u61C9\u7528\u7A0B\u5F0F\u540D\u7A31\n -Xdock:icon=\n \u8986\u5BEB\u7D50\u5408\u8AAA\u660E\u756B\u9762\u4E2D\u986F\u793A\u7684\u9810\u8A2D\u5716\u793A\n\n diff --git a/jdk/src/java.base/share/classes/sun/net/RegisteredDomain.java b/jdk/src/java.base/share/classes/sun/net/RegisteredDomain.java index 7e75b321eb6..3a506da9831 100644 --- a/jdk/src/java.base/share/classes/sun/net/RegisteredDomain.java +++ b/jdk/src/java.base/share/classes/sun/net/RegisteredDomain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -32,6 +32,10 @@ import java.util.Map; import java.util.Set; /* + * WARNING: This class may contain out-of-date information. It should be + * updated or replaced with an appropriate implementation. See + * sun.security.util.RegisteredDomain for more information. + * * The naming tables listed below were gathered from publicly available data such as * the subdomain registration websites listed for each top-level domain by the Internet * Assigned Numbers Authority and the website of the Internet Corporation for Assigned Names @@ -696,6 +700,36 @@ static { top3Map.put("tr", new HashSet(Arrays.asList("gov.nc.tr"))); } + /** + * Returns a {@code sun.security.util.RegisteredDomain} representing the + * registered part of the specified domain. + * + * @param domain the domain name + * @return a {@code sun.security.util.RegisteredDomain} or null + * if the domain is unknown or not registerable + * @throws NullPointerException if domain is null + */ + public static sun.security.util.RegisteredDomain registeredDomain(String domain) { + String name = getRegisteredDomain(domain); + if (name.equals(domain)) { + return null; + } + return new sun.security.util.RegisteredDomain() { + private String rname = name; + @Override + public String name() { + return rname; + } + @Override + public sun.security.util.RegisteredDomain.Type type() { + return sun.security.util.RegisteredDomain.Type.ICANN; + } + @Override + public String publicSuffix() { + return rname.substring(rname.indexOf(".") + 1); + } + }; + } /* * Return the registered part of a qualified domain diff --git a/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java b/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java index b727b672e86..7180884ec69 100644 --- a/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java +++ b/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java @@ -1,5 +1,5 @@ /* - * 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 @@ -516,7 +516,8 @@ public class FtpClient extends sun.net.ftp.FtpClient { * @return true if the command was successful * @throws IOException */ - private boolean issueCommand(String cmd) throws IOException { + private boolean issueCommand(String cmd) throws IOException, + sun.net.ftp.FtpProtocolException { if (!isConnected()) { throw new IllegalStateException("Not connected"); } @@ -527,6 +528,12 @@ public class FtpClient extends sun.net.ftp.FtpClient { // ignore... } } + if (cmd.indexOf('\n') != -1) { + sun.net.ftp.FtpProtocolException ex + = new sun.net.ftp.FtpProtocolException("Illegal FTP command"); + ex.initCause(new IllegalArgumentException("Illegal carriage return")); + throw ex; + } sendServer(cmd + "\r\n"); return readReply(); } @@ -1119,7 +1126,10 @@ public class FtpClient extends sun.net.ftp.FtpClient { */ public void close() throws IOException { if (isConnected()) { - issueCommand("QUIT"); + try { + issueCommand("QUIT"); + } catch (FtpProtocolException e) { + } loggedIn = false; } disconnect(); @@ -1897,7 +1907,8 @@ public class FtpClient extends sun.net.ftp.FtpClient { return null; } - private boolean sendSecurityData(byte[] buf) throws IOException { + private boolean sendSecurityData(byte[] buf) throws IOException, + sun.net.ftp.FtpProtocolException { String s = Base64.getMimeEncoder().encodeToString(buf); return issueCommand("ADAT " + s); } diff --git a/jdk/src/java.base/share/classes/sun/net/smtp/SmtpClient.java b/jdk/src/java.base/share/classes/sun/net/smtp/SmtpClient.java index 93451253f0a..59c60ce70dc 100644 --- a/jdk/src/java.base/share/classes/sun/net/smtp/SmtpClient.java +++ b/jdk/src/java.base/share/classes/sun/net/smtp/SmtpClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2011, 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 @@ -43,6 +43,7 @@ import sun.security.action.GetPropertyAction; public class SmtpClient extends TransferProtocolClient { + private static int DEFAULT_SMTP_PORT = 25; String mailhost; SmtpPrintStream message; @@ -74,6 +75,10 @@ public class SmtpClient extends TransferProtocolClient { } public void to(String s) throws IOException { + if (s.indexOf('\n') != -1) { + throw new IOException("Illegal SMTP command", + new IllegalArgumentException("Illegal carriage return")); + } int st = 0; int limit = s.length(); int pos = 0; @@ -116,16 +121,21 @@ public class SmtpClient extends TransferProtocolClient { } public void from(String s) throws IOException { - if (s.startsWith("<")) + if (s.indexOf('\n') != -1) { + throw new IOException("Illegal SMTP command", + new IllegalArgumentException("Illegal carriage return")); + } + if (s.startsWith("<")) { issueCommand("mail from: " + s + "\r\n", 250); - else + } else { issueCommand("mail from: <" + s + ">\r\n", 250); + } } /** open a SMTP connection to host host. */ private void openServer(String host) throws IOException { mailhost = host; - openServer(mailhost, 25); + openServer(mailhost, DEFAULT_SMTP_PORT); issueCommand("helo "+InetAddress.getLocalHost().getHostName()+"\r\n", 250); } diff --git a/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java b/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java index 29b998a5e70..08ff179457a 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java +++ b/jdk/src/java.base/share/classes/sun/net/www/MeteredStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2004, 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 @@ -203,6 +203,7 @@ public class MeteredStream extends FilterInputStream { return super.markSupported(); } + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { try { close(); diff --git a/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java b/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java index 9237d37a354..57d734e5166 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java +++ b/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java @@ -102,7 +102,20 @@ public class HttpClient extends NetworkClient { // from previous releases. private static boolean retryPostProp = true; + /* Value of the system property jdk.ntlm.cache; + if false, then NTLM connections will not be cached. + The default value is 'true'. */ + private static final boolean cacheNTLMProp; + /* Value of the system property jdk.spnego.cache; + if false, then connections authentified using the Negotiate/Kerberos + scheme will not be cached. + The default value is 'true'. */ + private static final boolean cacheSPNEGOProp; + volatile boolean keepingAlive; /* this is a keep-alive connection */ + volatile boolean disableKeepAlive;/* keep-alive has been disabled for this + connection - this will be used when + recomputing the value of keepingAlive */ int keepAliveConnections = -1; /* number of keep-alives left */ /**Idle timeout value, in milliseconds. Zero means infinity, @@ -152,6 +165,8 @@ public class HttpClient extends NetworkClient { Properties props = GetPropertyAction.privilegedGetProperties(); String keepAlive = props.getProperty("http.keepAlive"); String retryPost = props.getProperty("sun.net.http.retryPost"); + String cacheNTLM = props.getProperty("jdk.ntlm.cache"); + String cacheSPNEGO = props.getProperty("jdk.spnego.cache"); if (keepAlive != null) { keepAliveProp = Boolean.parseBoolean(keepAlive); @@ -161,9 +176,21 @@ public class HttpClient extends NetworkClient { if (retryPost != null) { retryPostProp = Boolean.parseBoolean(retryPost); - } else + } else { retryPostProp = true; + } + if (cacheNTLM != null) { + cacheNTLMProp = Boolean.parseBoolean(cacheNTLM); + } else { + cacheNTLMProp = true; + } + + if (cacheSPNEGO != null) { + cacheSPNEGOProp = Boolean.parseBoolean(cacheSPNEGO); + } else { + cacheSPNEGOProp = true; + } } /** @@ -723,6 +750,7 @@ public class HttpClient extends NetworkClient { nread += r; } String keep=null; + String authenticate=null; ret = b[0] == 'H' && b[1] == 'T' && b[2] == 'T' && b[3] == 'P' && b[4] == '/' && b[5] == '1' && b[6] == '.'; @@ -751,17 +779,44 @@ public class HttpClient extends NetworkClient { */ if (usingProxy) { // not likely a proxy will return this keep = responses.findValue("Proxy-Connection"); + authenticate = responses.findValue("Proxy-Authenticate"); } if (keep == null) { keep = responses.findValue("Connection"); + authenticate = responses.findValue("WWW-Authenticate"); } + + // 'disableKeepAlive' starts with the value false. + // It can transition from false to true, but once true + // it stays true. + // If cacheNTLMProp is false, and disableKeepAlive is false, + // then we need to examine the response headers to figure out + // whether we are doing NTLM authentication. If we do NTLM, + // and cacheNTLMProp is false, than we can't keep this connection + // alive: we will switch disableKeepAlive to true. + boolean canKeepAlive = !disableKeepAlive; + if (canKeepAlive && (cacheNTLMProp == false || cacheSPNEGOProp == false) + && authenticate != null) { + authenticate = authenticate.toLowerCase(Locale.US); + if (cacheNTLMProp == false) { + canKeepAlive &= !authenticate.startsWith("ntlm "); + } + if (cacheSPNEGOProp == false) { + canKeepAlive &= !authenticate.startsWith("negotiate "); + canKeepAlive &= !authenticate.startsWith("kerberos "); + } + } + disableKeepAlive |= !canKeepAlive; + if (keep != null && keep.toLowerCase(Locale.US).equals("keep-alive")) { /* some servers, notably Apache1.1, send something like: * "Keep-Alive: timeout=15, max=1" which we should respect. */ - HeaderParser p = new HeaderParser( + if (disableKeepAlive) { + keepAliveConnections = 1; + } else { + HeaderParser p = new HeaderParser( responses.findValue("Keep-Alive")); - if (p != null) { /* default should be larger in case of proxy */ keepAliveConnections = p.findInt("max", usingProxy?50:5); keepAliveTimeout = p.findInt("timeout", usingProxy?60:5); @@ -771,7 +826,7 @@ public class HttpClient extends NetworkClient { * We're talking 1.1 or later. Keep persistent until * the server says to close. */ - if (keep != null) { + if (keep != null || disableKeepAlive) { /* * The only Connection token we understand is close. * Paranoia: if there is any Connection header then @@ -853,7 +908,7 @@ public class HttpClient extends NetworkClient { keepAliveConnections = 1; keepingAlive = false; } else { - keepingAlive = true; + keepingAlive = !disableKeepAlive; } failedOnce = false; } else { @@ -886,7 +941,7 @@ public class HttpClient extends NetworkClient { (cl >= 0 || code == HttpURLConnection.HTTP_NOT_MODIFIED || code == HttpURLConnection.HTTP_NO_CONTENT)) { - keepingAlive = true; + keepingAlive = !disableKeepAlive; failedOnce = false; } else if (keepingAlive) { /* Previously we were keeping alive, and now we're not. Remove @@ -908,7 +963,11 @@ public class HttpClient extends NetworkClient { pi.setContentType(responses.findValue("content-type")); } - if (isKeepingAlive()) { + // If disableKeepAlive == true, the client will not be returned + // to the cache. But we still need to use a keepalive stream to + // allow the multi-message authentication exchange on the connection + boolean useKeepAliveStream = isKeepingAlive() || disableKeepAlive; + if (useKeepAliveStream) { // Wrap KeepAliveStream if keep alive is enabled. logFinest("KeepAlive stream used: " + url); serverInput = new KeepAliveStream(serverInput, pi, cl, this); diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java index 7d0dae92a8a..c7f369eda23 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java @@ -65,8 +65,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone * repeatedly, via the Authenticator. Default is false, which means that this * behavior is switched off. */ - static boolean serializeAuth; - + static final boolean serializeAuth; static { serializeAuth = java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction( @@ -106,6 +105,16 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone public String getProtocolScheme() { return protocol; } + /** + * Whether we should cache this instance in the AuthCache. + * This method returns {@code true} by default. + * Subclasses may override this method to add + * additional restrictions. + * @return {@code true} by default. + */ + protected boolean useAuthCache() { + return true; + } /** * requests is used to ensure that interaction with the @@ -373,9 +382,11 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone */ void addToCache() { String key = cacheKey(true); - cache.put(key, this); - if (supportsPreemptiveAuthorization()) { - cache.put(cacheKey(false), this); + if (useAuthCache()) { + cache.put(key, this); + if (supportsPreemptiveAuthorization()) { + cache.put(cacheKey(false), this); + } } endAuthRequest(key); } diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java index d7c379f0d47..b4a4584f8ee 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java @@ -34,6 +34,7 @@ import sun.net.www.HeaderParser; import sun.util.logging.PlatformLogger; import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; import static sun.net.www.protocol.http.AuthScheme.KERBEROS; +import sun.security.action.GetPropertyAction; /** * NegotiateAuthentication: @@ -55,7 +56,14 @@ class NegotiateAuthentication extends AuthenticationInfo { // if it's true, a cached Negotiator is put into cache. // the cache can be used only once, so after the first use, it's cleaned. static HashMap supported = null; - static HashMap cache = null; + static ThreadLocal > cache = null; + /* Whether cache is enabled for Negotiate/Kerberos */ + private static final boolean cacheSPNEGO; + static { + String spnegoCacheProp = + GetPropertyAction.privilegedGetProperty("jdk.spnego.cache", "true"); + cacheSPNEGO = Boolean.parseBoolean(spnegoCacheProp); + } // The HTTP Negotiate Helper private Negotiator negotiator = null; @@ -119,8 +127,7 @@ class NegotiateAuthentication extends AuthenticationInfo { */ private static synchronized boolean isSupportedImpl(HttpCallerInfo hci) { if (supported == null) { - supported = new HashMap (); - cache = new HashMap (); + supported = new HashMap<>(); } String hostname = hci.host; hostname = hostname.toLowerCase(); @@ -133,7 +140,15 @@ class NegotiateAuthentication extends AuthenticationInfo { supported.put(hostname, true); // the only place cache.put is called. here we can make sure // the object is valid and the oneToken inside is not null - cache.put(hostname, neg); + if (cache == null) { + cache = new ThreadLocal<>() { + @Override + protected HashMap initialValue() { + return new HashMap<>(); + } + }; + } + cache.get().put(hostname, neg); return true; } else { supported.put(hostname, false); @@ -141,6 +156,16 @@ class NegotiateAuthentication extends AuthenticationInfo { } } + private static synchronized HashMap getCache() { + if (cache == null) return null; + return cache.get(); + } + + @Override + protected boolean useAuthCache() { + return super.useAuthCache() && cacheSPNEGO; + } + /** * Not supported. Must use the setHeaders() method */ @@ -198,12 +223,11 @@ class NegotiateAuthentication extends AuthenticationInfo { */ private byte[] firstToken() throws IOException { negotiator = null; - if (cache != null) { - synchronized(cache) { - negotiator = cache.get(getHost()); - if (negotiator != null) { - cache.remove(getHost()); // so that it is only used once - } + HashMap cachedMap = getCache(); + if (cachedMap != null) { + negotiator = cachedMap.get(getHost()); + if (negotiator != null) { + cachedMap.remove(getHost()); // so that it is only used once } } if (negotiator == null) { diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java index b6ff7b417ac..2b5e5115cf3 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/DelegateHttpsURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2005, 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 @@ -77,6 +77,7 @@ public class DelegateHttpsURLConnection extends AbstractDelegateHttpsURLConnecti * Called by layered delegator's finalize() method to handle closing * the underlying object. */ + @SuppressWarnings("deprecation") protected void dispose() throws Throwable { super.finalize(); } diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java index 1b2a584a79b..792af78675c 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.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 @@ -478,6 +478,7 @@ public class HttpsURLConnectionImpl * sun.net.www.protocol.http.HttpURLConnection's finalize() * would have to be made public. */ + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { delegate.dispose(); } diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java index fb12cf77626..5cb3e999a71 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java @@ -82,6 +82,9 @@ public class JarURLConnection extends java.net.JarURLConnection { jarFileURL = getJarFileURL(); jarFileURLConnection = jarFileURL.openConnection(); + // whether, or not, the embedded URL should use the cache will depend + // on this instance's cache value + jarFileURLConnection.setUseCaches(useCaches); entryName = getEntryName(); } diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java index 88e6f5b7caa..c7446082edd 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.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 @@ -26,13 +26,13 @@ package sun.net.www.protocol.jrt; import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.security.AccessController; import java.security.Permission; +import java.security.PrivilegedAction; import jdk.internal.jimage.ImageLocation; import jdk.internal.jimage.ImageReader; @@ -42,7 +42,6 @@ import jdk.internal.loader.URLClassPath; import jdk.internal.loader.Resource; import sun.net.www.ParseUtil; import sun.net.www.URLConnection; -import sun.security.action.GetPropertyAction; /** * URLConnection implementation that can be used to connect to resources @@ -51,7 +50,11 @@ import sun.security.action.GetPropertyAction; public class JavaRuntimeURLConnection extends URLConnection { // ImageReader to access resources in jimage - private static final ImageReader reader = ImageReaderFactory.getImageReader(); + private static final ImageReader reader; + static { + PrivilegedAction pa = ImageReaderFactory::getImageReader; + reader = AccessController.doPrivileged(pa); + } // the module and resource name in the URL private final String module; @@ -60,9 +63,6 @@ public class JavaRuntimeURLConnection extends URLConnection { // the Resource when connected private volatile Resource resource; - // the permission to access resources in the runtime image, created lazily - private static volatile Permission permission; - JavaRuntimeURLConnection(URL url) throws IOException { super(url); String path = url.getPath(); @@ -158,14 +158,8 @@ public class JavaRuntimeURLConnection extends URLConnection { } @Override - public Permission getPermission() throws IOException { - Permission p = permission; - if (p == null) { - String home = GetPropertyAction.privilegedGetProperty("java.home"); - p = new FilePermission(home + File.separator + "-", "read"); - permission = p; - } - return p; + public Permission getPermission() { + return new RuntimePermission("accessSystemModules"); } /** diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java index 7f63ec88264..c4d508070d4 100644 --- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java +++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.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 @@ -1034,6 +1034,7 @@ class DatagramChannelImpl } } + @SuppressWarnings("deprecation") protected void finalize() throws IOException { // fd is null if constructor threw exception if (fd != null) diff --git a/jdk/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template b/jdk/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template index f2eeaaafdc3..8969ef1a04b 100644 --- a/jdk/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template +++ b/jdk/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template @@ -32,7 +32,6 @@ package sun.nio.cs; import java.nio.charset.Charset; import java.nio.charset.spi.CharsetProvider; import java.util.Iterator; -import java.util.Locale; import java.util.Map; import sun.security.action.GetPropertyAction; @@ -44,13 +43,13 @@ public class StandardCharsets extends CharsetProvider { _INCLUDE_CACHE_MAP_ // Maps canonical names to class names - private Map classMap; + private final Map classMap; // Maps alias names to canonical names - private Map aliasMap; + private final Map aliasMap; // Maps canonical names to cached instances - private Map cache; + private final Map cache; - private String packagePrefix = "sun.nio.cs"; + private static final String packagePrefix = "sun.nio.cs"; public StandardCharsets() { this.aliasMap = new Aliases(); @@ -102,10 +101,16 @@ public class StandardCharsets extends CharsetProvider { if (cln == null) return null; - if (cln.equals("US_ASCII")) { - cs = new US_ASCII(); - cache.put(csn, cs); - return cs; + // As all charset class names added to classMap are string literals we + // can check identity here as an optimization + if (cln == "US_ASCII") { + return cache(csn, new US_ASCII()); + } + if (cln == "ISO_8859_1") { + return cache(csn, new ISO_8859_1()); + } + if (cln == "UTF_8") { + return cache(csn, new UTF_8()); } // Instantiate the charset and cache it @@ -114,9 +119,7 @@ public class StandardCharsets extends CharsetProvider { Object o = Class.forName(packagePrefix + "." + cln, true, this.getClass().getClassLoader()).newInstance(); - cs = (Charset)o; - cache.put(csn, cs); - return cs; + return cache(csn, (Charset)o); } catch (ClassNotFoundException | IllegalAccessException | InstantiationException x) { @@ -124,6 +127,11 @@ public class StandardCharsets extends CharsetProvider { } } + private Charset cache(String csn, Charset cs) { + cache.put(csn, cs); + return cs; + } + public final Charset charsetForName(String charsetName) { synchronized (this) { return lookup(canonicalize(charsetName)); diff --git a/jdk/src/java.base/share/classes/sun/nio/cs/US_ASCII.java b/jdk/src/java.base/share/classes/sun/nio/cs/US_ASCII.java index 39b7df07d85..e85ce61ccd8 100644 --- a/jdk/src/java.base/share/classes/sun/nio/cs/US_ASCII.java +++ b/jdk/src/java.base/share/classes/sun/nio/cs/US_ASCII.java @@ -31,7 +31,6 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; -import java.util.Arrays; public class US_ASCII extends Charset diff --git a/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java b/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java index d3d34da4967..8cb5ca08fcb 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java +++ b/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java @@ -25,7 +25,6 @@ package sun.reflect.misc; -import java.lang.reflect.Module; import java.io.EOFException; import java.security.AllPermission; import java.security.AccessController; diff --git a/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java b/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java index ed69ba3d8b9..6efd90d0670 100644 --- a/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java +++ b/jdk/src/java.base/share/classes/sun/security/pkcs/SignerInfo.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 @@ -37,6 +37,7 @@ import java.security.PublicKey; import java.security.Signature; import java.security.SignatureException; import java.security.Timestamp; +import java.security.cert.CertPathValidatorException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.CertPath; @@ -48,6 +49,7 @@ import java.util.EnumSet; import java.util.Set; import sun.security.timestamp.TimestampToken; +import sun.security.util.ConstraintsParameters; import sun.security.util.Debug; import sun.security.util.DerEncoder; import sun.security.util.DerInputStream; @@ -321,6 +323,8 @@ public class SignerInfo implements DerEncoder { data = content.getContentBytes(); } + ConstraintsParameters cparams = + new ConstraintsParameters(timestamp); String digestAlgname = getDigestAlgorithmId().getName(); byte[] dataSigned; @@ -347,11 +351,11 @@ public class SignerInfo implements DerEncoder { if (messageDigest == null) // fail if there is no message digest return null; - // check that algorithm is not restricted - if (!JAR_DISABLED_CHECK.permits(DIGEST_PRIMITIVE_SET, - digestAlgname, null)) { - throw new SignatureException("Digest check failed. " + - "Disabled algorithm used: " + digestAlgname); + // check that digest algorithm is not restricted + try { + JAR_DISABLED_CHECK.permits(digestAlgname, cparams); + } catch (CertPathValidatorException e) { + throw new SignatureException(e.getMessage(), e); } MessageDigest md = MessageDigest.getInstance(digestAlgname); @@ -385,17 +389,18 @@ public class SignerInfo implements DerEncoder { String algname = AlgorithmId.makeSigAlg( digestAlgname, encryptionAlgname); - // check that algorithm is not restricted - if (!JAR_DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, algname, null)) { - throw new SignatureException("Signature check failed. " + - "Disabled algorithm used: " + algname); + // check that jar signature algorithm is not restricted + try { + JAR_DISABLED_CHECK.permits(algname, cparams); + } catch (CertPathValidatorException e) { + throw new SignatureException(e.getMessage(), e); } X509Certificate cert = getCertificate(block); - PublicKey key = cert.getPublicKey(); if (cert == null) { return null; } + PublicKey key = cert.getPublicKey(); // check if the public key is restricted if (!JAR_DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) { diff --git a/jdk/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java b/jdk/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java index 02ed730b9af..9302580db1c 100644 --- a/jdk/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java +++ b/jdk/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java @@ -167,7 +167,8 @@ public class PKCS10 { // key and signature algorithm we found. // try { - sig = Signature.getInstance(id.getName()); + sigAlg = id.getName(); + sig = Signature.getInstance(sigAlg); sig.initVerify(subjectPublicKeyInfo); sig.update(data); if (!sig.verify(sigData)) @@ -218,6 +219,7 @@ public class PKCS10 { signature.update(certificateRequestInfo, 0, certificateRequestInfo.length); sig = signature.sign(); + sigAlg = signature.getAlgorithm(); /* * Build guts of SIGNED macro @@ -250,6 +252,11 @@ public class PKCS10 { public PublicKey getSubjectPublicKeyInfo() { return subjectPublicKeyInfo; } + /** + * Returns the signature algorithm. + */ + public String getSigAlg() { return sigAlg; } + /** * Returns the additional attributes requested. */ @@ -348,6 +355,7 @@ public class PKCS10 { private X500Name subject; private PublicKey subjectPublicKeyInfo; + private String sigAlg; private PKCS10Attributes attributeSet; private byte[] encoded; // signed } diff --git a/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java b/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java index ef7a1f43ffb..bffa1f5b283 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/KeyProtector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, 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 @@ -147,6 +147,7 @@ final class KeyProtector { * Ensures that the password bytes of this key protector are * set to zero when there are no more references to it. */ + @SuppressWarnings("deprecation") protected void finalize() { if (passwdBytes != null) { Arrays.fill(passwdBytes, (byte)0x00); diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java index 90559598aee..f7bedb99ccb 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java @@ -1,5 +1,5 @@ /* - * 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 @@ -28,6 +28,7 @@ package sun.security.provider.certpath; import java.security.AlgorithmConstraints; import java.security.CryptoPrimitive; import java.security.Timestamp; +import java.security.cert.CertPathValidator; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -53,9 +54,10 @@ import java.security.interfaces.DSAPublicKey; import java.security.spec.DSAPublicKeySpec; import sun.security.util.AnchorCertificates; -import sun.security.util.CertConstraintParameters; +import sun.security.util.ConstraintsParameters; import sun.security.util.Debug; import sun.security.util.DisabledAlgorithmConstraints; +import sun.security.validator.Validator; import sun.security.x509.X509CertImpl; import sun.security.x509.X509CRLImpl; import sun.security.x509.AlgorithmId; @@ -79,6 +81,7 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { private final Date pkixdate; private PublicKey prevPubKey; private final Timestamp jarTimestamp; + private final String variant; private static final Set SIGNATURE_PRIMITIVE_SET = Collections.unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE)); @@ -103,87 +106,56 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { private boolean trustedMatch = false; /** - * Create a new {@code AlgorithmChecker} with the algorithm - * constraints specified in security property - * "jdk.certpath.disabledAlgorithms". + * Create a new {@code AlgorithmChecker} with the given algorithm + * given {@code TrustAnchor} and {@code String} variant. * * @param anchor the trust anchor selected to validate the target * certificate + * @param variant is the Validator variants of the operation. A null value + * passed will set it to Validator.GENERIC. */ - public AlgorithmChecker(TrustAnchor anchor) { - this(anchor, certPathDefaultConstraints, null); - } - - /** - * Create a new {@code AlgorithmChecker} with the - * given {@code TrustAnchor} and {@code AlgorithmConstraints}. - * - * @param anchor the trust anchor selected to validate the target - * certificate - * @param constraints the algorithm constraints (or null) - * - * @throws IllegalArgumentException if the {@code anchor} is null - */ - public AlgorithmChecker(TrustAnchor anchor, - AlgorithmConstraints constraints) { - this(anchor, constraints, null); - } - - /** - * Create a new {@code AlgorithmChecker} with the - * given {@code AlgorithmConstraints}. - *

              - * Note that this constructor will be used to check a certification - * path where the trust anchor is unknown, or a certificate list which may - * contain the trust anchor. This constructor is used by SunJSSE. - * - * @param constraints the algorithm constraints (or null) - */ - public AlgorithmChecker(AlgorithmConstraints constraints) { - this.prevPubKey = null; - this.trustedPubKey = null; - this.constraints = constraints; - this.pkixdate = null; - this.jarTimestamp = null; + public AlgorithmChecker(TrustAnchor anchor, String variant) { + this(anchor, certPathDefaultConstraints, null, null, variant); } /** * Create a new {@code AlgorithmChecker} with the given - * {@code Timestamp}. - *

              - * Note that this constructor will be used to check a certification - * path for signed JAR files that are timestamped. + * {@code AlgorithmConstraints}, {@code Timestamp}, and {@code String} + * variant. * + * Note that this constructor can initialize a variation of situations where + * the AlgorithmConstraints, Timestamp, or Variant maybe known. + * + * @param constraints the algorithm constraints (or null) * @param jarTimestamp Timestamp passed for JAR timestamp constraint * checking. Set to null if not applicable. + * @param variant is the Validator variants of the operation. A null value + * passed will set it to Validator.GENERIC. */ - public AlgorithmChecker(Timestamp jarTimestamp) { - this.prevPubKey = null; - this.trustedPubKey = null; - this.constraints = certPathDefaultConstraints; - if (jarTimestamp == null) { - throw new IllegalArgumentException( - "Timestamp cannot be null"); - } - this.pkixdate = jarTimestamp.getTimestamp(); - this.jarTimestamp = jarTimestamp; + public AlgorithmChecker(AlgorithmConstraints constraints, + Timestamp jarTimestamp, String variant) { + this(null, constraints, null, jarTimestamp, variant); } /** * Create a new {@code AlgorithmChecker} with the - * given {@code TrustAnchor} and {@code AlgorithmConstraints}. + * given {@code TrustAnchor}, {@code AlgorithmConstraints}, + * {@code Timestamp}, and {@code String} variant. * * @param anchor the trust anchor selected to validate the target * certificate * @param constraints the algorithm constraints (or null) - * @param pkixdate Date the constraints are checked against. The value is - * either the PKIXParameter date or null for the current date. - * - * @throws IllegalArgumentException if the {@code anchor} is null + * @param pkixdate The date specified by the PKIXParameters date. If the + * PKIXParameters is null, the current date is used. This + * should be null when jar files are being checked. + * @param jarTimestamp Timestamp passed for JAR timestamp constraint + * checking. Set to null if not applicable. + * @param variant is the Validator variants of the operation. A null value + * passed will set it to Validator.GENERIC. */ public AlgorithmChecker(TrustAnchor anchor, - AlgorithmConstraints constraints, - Date pkixdate) { + AlgorithmConstraints constraints, Date pkixdate, + Timestamp jarTimestamp, String variant) { if (anchor != null) { if (anchor.getTrustedCert() != null) { @@ -203,25 +175,30 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { } } - this.prevPubKey = trustedPubKey; - this.constraints = constraints; - this.pkixdate = pkixdate; - this.jarTimestamp = null; + this.prevPubKey = this.trustedPubKey; + this.constraints = (constraints == null ? certPathDefaultConstraints : + constraints); + // If we are checking jar files, set pkixdate the same as the timestamp + // for certificate checking + this.pkixdate = (jarTimestamp != null ? jarTimestamp.getTimestamp() : + pkixdate); + this.jarTimestamp = jarTimestamp; + this.variant = (variant == null ? Validator.VAR_GENERIC : variant); } /** - * Create a new {@code AlgorithmChecker} with the - * given {@code TrustAnchor} and {@code PKIXParameter} date. + * Create a new {@code AlgorithmChecker} with the given {@code TrustAnchor}, + * {@code PKIXParameter} date, and {@code varient} * * @param anchor the trust anchor selected to validate the target * certificate * @param pkixdate Date the constraints are checked against. The value is - * either the PKIXParameter date or null for the current date. - * - * @throws IllegalArgumentException if the {@code anchor} is null + * either the PKIXParameters date or null for the current date. + * @param variant is the Validator variants of the operation. A null value + * passed will set it to Validator.GENERIC. */ - public AlgorithmChecker(TrustAnchor anchor, Date pkixdate) { - this(anchor, certPathDefaultConstraints, pkixdate); + public AlgorithmChecker(TrustAnchor anchor, Date pkixdate, String variant) { + this(anchor, certPathDefaultConstraints, pkixdate, null, variant); } // Check this 'cert' for restrictions in the AnchorCertificates @@ -237,10 +214,6 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { return AnchorCertificates.contains(cert); } - Timestamp getJarTimestamp() { - return jarTimestamp; - } - @Override public void init(boolean forward) throws CertPathValidatorException { // Note that this class does not support forward mode. @@ -286,6 +259,28 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { null, null, -1, PKIXReason.INVALID_KEY_USAGE); } + X509CertImpl x509Cert; + AlgorithmId algorithmId; + try { + x509Cert = X509CertImpl.toImpl((X509Certificate)cert); + algorithmId = (AlgorithmId)x509Cert.get(X509CertImpl.SIG_ALG); + } catch (CertificateException ce) { + throw new CertPathValidatorException(ce); + } + + AlgorithmParameters currSigAlgParams = algorithmId.getParameters(); + PublicKey currPubKey = cert.getPublicKey(); + String currSigAlg = ((X509Certificate)cert).getSigAlgName(); + + // Check the signature algorithm and parameters against constraints. + if (!constraints.permits(SIGNATURE_PRIMITIVE_SET, currSigAlg, + currSigAlgParams)) { + throw new CertPathValidatorException( + "Algorithm constraints check failed on signature " + + "algorithm: " + currSigAlg, null, null, -1, + BasicReason.ALGORITHM_CONSTRAINED); + } + // Assume all key usage bits are set if key usage is not present Set primitives = KU_PRIMITIVE_SET; @@ -322,101 +317,74 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { } } - PublicKey currPubKey = cert.getPublicKey(); + ConstraintsParameters cp = + new ConstraintsParameters((X509Certificate)cert, + trustedMatch, pkixdate, jarTimestamp, variant); + // Check against local constraints if it is DisabledAlgorithmConstraints if (constraints instanceof DisabledAlgorithmConstraints) { - // Check against DisabledAlgorithmConstraints certpath constraints. - // permits() will throw exception on failure. - ((DisabledAlgorithmConstraints)constraints).permits(primitives, - new CertConstraintParameters((X509Certificate)cert, - trustedMatch, pkixdate, jarTimestamp)); - // If there is no previous key, set one and exit - if (prevPubKey == null) { - prevPubKey = currPubKey; - return; - } - } - - X509CertImpl x509Cert; - AlgorithmId algorithmId; - try { - x509Cert = X509CertImpl.toImpl((X509Certificate)cert); - algorithmId = (AlgorithmId)x509Cert.get(X509CertImpl.SIG_ALG); - } catch (CertificateException ce) { - throw new CertPathValidatorException(ce); - } - - AlgorithmParameters currSigAlgParams = algorithmId.getParameters(); - String currSigAlg = x509Cert.getSigAlgName(); - - // If 'constraints' is not of DisabledAlgorithmConstraints, check all - // everything individually - if (!(constraints instanceof DisabledAlgorithmConstraints)) { - // Check the current signature algorithm - if (!constraints.permits( - SIGNATURE_PRIMITIVE_SET, - currSigAlg, currSigAlgParams)) { - throw new CertPathValidatorException( - "Algorithm constraints check failed on signature " + - "algorithm: " + currSigAlg, null, null, -1, - BasicReason.ALGORITHM_CONSTRAINED); - } + ((DisabledAlgorithmConstraints)constraints).permits(currSigAlg, cp); + // DisabledAlgorithmsConstraints does not check primitives, so key + // additional key check. + } else { + // Perform the default constraints checking anyway. + certPathDefaultConstraints.permits(currSigAlg, cp); + // Call locally set constraints to check key with primitives. if (!constraints.permits(primitives, currPubKey)) { throw new CertPathValidatorException( - "Algorithm constraints check failed on keysize: " + - sun.security.util.KeyUtil.getKeySize(currPubKey), + "Algorithm constraints check failed on key " + + currPubKey.getAlgorithm() + " with size of " + + sun.security.util.KeyUtil.getKeySize(currPubKey) + + "bits", null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); } } + // If there is no previous key, set one and exit + if (prevPubKey == null) { + prevPubKey = currPubKey; + return; + } + // Check with previous cert for signature algorithm and public key - if (prevPubKey != null) { - if (!constraints.permits( - SIGNATURE_PRIMITIVE_SET, - currSigAlg, prevPubKey, currSigAlgParams)) { - throw new CertPathValidatorException( + if (!constraints.permits( + SIGNATURE_PRIMITIVE_SET, + currSigAlg, prevPubKey, currSigAlgParams)) { + throw new CertPathValidatorException( "Algorithm constraints check failed on " + "signature algorithm: " + currSigAlg, null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); + } + + // Inherit key parameters from previous key + if (PKIX.isDSAPublicKeyWithoutParams(currPubKey)) { + // Inherit DSA parameters from previous key + if (!(prevPubKey instanceof DSAPublicKey)) { + throw new CertPathValidatorException("Input key is not " + + "of a appropriate type for inheriting parameters"); } - // Inherit key parameters from previous key - if (PKIX.isDSAPublicKeyWithoutParams(currPubKey)) { - // Inherit DSA parameters from previous key - if (!(prevPubKey instanceof DSAPublicKey)) { - throw new CertPathValidatorException("Input key is not " + - "of a appropriate type for inheriting parameters"); - } - - DSAParams params = ((DSAPublicKey)prevPubKey).getParams(); - if (params == null) { - throw new CertPathValidatorException( + DSAParams params = ((DSAPublicKey)prevPubKey).getParams(); + if (params == null) { + throw new CertPathValidatorException( "Key parameters missing from public key."); - } + } - try { - BigInteger y = ((DSAPublicKey)currPubKey).getY(); - KeyFactory kf = KeyFactory.getInstance("DSA"); - DSAPublicKeySpec ks = new DSAPublicKeySpec(y, - params.getP(), - params.getQ(), - params.getG()); - currPubKey = kf.generatePublic(ks); - } catch (GeneralSecurityException e) { - throw new CertPathValidatorException("Unable to generate " + + try { + BigInteger y = ((DSAPublicKey)currPubKey).getY(); + KeyFactory kf = KeyFactory.getInstance("DSA"); + DSAPublicKeySpec ks = new DSAPublicKeySpec(y, params.getP(), + params.getQ(), params.getG()); + currPubKey = kf.generatePublic(ks); + } catch (GeneralSecurityException e) { + throw new CertPathValidatorException("Unable to generate " + "key with inherited parameters: " + e.getMessage(), e); - } } } // reset the previous public key prevPubKey = currPubKey; - - // check the extended key usage, ignore the check now - // List extendedKeyUsages = x509Cert.getExtendedKeyUsage(); - - // DO NOT remove any unresolved critical extensions } /** @@ -456,8 +424,10 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { * * @param key the public key to verify the CRL signature * @param crl the target CRL + * @param variant is the Validator variants of the operation. A null value + * passed will set it to Validator.GENERIC. */ - static void check(PublicKey key, X509CRL crl) + static void check(PublicKey key, X509CRL crl, String variant) throws CertPathValidatorException { X509CRLImpl x509CRLImpl = null; @@ -468,7 +438,7 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { } AlgorithmId algorithmId = x509CRLImpl.getSigAlgId(); - check(key, algorithmId); + check(key, algorithmId, variant); } /** @@ -476,20 +446,16 @@ public final class AlgorithmChecker extends PKIXCertPathChecker { * * @param key the public key to verify the CRL signature * @param algorithmId signature algorithm Algorithm ID + * @param variant is the Validator variants of the operation. A null value + * passed will set it to Validator.GENERIC. */ - static void check(PublicKey key, AlgorithmId algorithmId) + static void check(PublicKey key, AlgorithmId algorithmId, String variant) throws CertPathValidatorException { String sigAlgName = algorithmId.getName(); AlgorithmParameters sigAlgParams = algorithmId.getParameters(); - if (!certPathDefaultConstraints.permits( - SIGNATURE_PRIMITIVE_SET, sigAlgName, key, sigAlgParams)) { - throw new CertPathValidatorException( - "Algorithm constraints check failed on signature algorithm: " + - sigAlgName + " is disabled", - null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); - } + certPathDefaultConstraints.permits(new ConstraintsParameters( + sigAlgName, sigAlgParams, key, variant)); } - } diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/BasicChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/BasicChecker.java index 49a0368753e..43ff7b7cd9d 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/BasicChecker.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/BasicChecker.java @@ -51,7 +51,7 @@ import sun.security.util.Debug; /** * BasicChecker is a PKIXCertPathChecker that checks the basic information - * on a PKIX certificate, namely the signature, timestamp, and subject/issuer + * on a PKIX certificate, namely the signature, validity, and subject/issuer * name chaining. * * @since 1.4 @@ -125,7 +125,7 @@ class BasicChecker extends PKIXCertPathChecker { } /** - * Performs the signature, timestamp, and subject/issuer name chaining + * Performs the signature, validity, and subject/issuer name chaining * checks on the certificate using its internal state. This method does * not remove any critical extensions from the Collection. * @@ -141,7 +141,7 @@ class BasicChecker extends PKIXCertPathChecker { X509Certificate currCert = (X509Certificate)cert; if (!sigOnly) { - verifyTimestamp(currCert); + verifyValidity(currCert); verifyNameChaining(currCert); } verifySignature(currCert); @@ -177,12 +177,12 @@ class BasicChecker extends PKIXCertPathChecker { } /** - * Internal method to verify the timestamp on a certificate + * Internal method to verify the validity on a certificate */ - private void verifyTimestamp(X509Certificate cert) + private void verifyValidity(X509Certificate cert) throws CertPathValidatorException { - String msg = "timestamp"; + String msg = "validity"; if (debug != null) debug.println("---checking " + msg + ":" + date.toString() + "..."); diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java index 95ef350a9d3..0f16c646a9c 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.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 @@ -33,6 +33,7 @@ import javax.security.auth.x500.X500Principal; import java.util.*; import sun.security.util.Debug; +import sun.security.validator.Validator; import static sun.security.x509.PKIXExtensions.*; import sun.security.x509.*; @@ -65,6 +66,20 @@ public class DistributionPointFetcher { * Return the X509CRLs matching this selector. The selector must be * an X509CRLSelector with certificateChecking set. */ + public static Collection getCRLs(X509CRLSelector selector, + boolean signFlag, PublicKey prevKey, String provider, + List certStores, boolean[] reasonsMask, + Set trustAnchors, Date validity, String variant) + throws CertStoreException + { + return getCRLs(selector, signFlag, prevKey, null, provider, certStores, + reasonsMask, trustAnchors, validity, variant); + } + /** + * Return the X509CRLs matching this selector. The selector must be + * an X509CRLSelector with certificateChecking set. + */ + // Called by com.sun.deploy.security.RevocationChecker public static Collection getCRLs(X509CRLSelector selector, boolean signFlag, PublicKey prevKey, @@ -76,7 +91,7 @@ public class DistributionPointFetcher { throws CertStoreException { return getCRLs(selector, signFlag, prevKey, null, provider, certStores, - reasonsMask, trustAnchors, validity); + reasonsMask, trustAnchors, validity, Validator.VAR_GENERIC); } /** @@ -91,7 +106,8 @@ public class DistributionPointFetcher { List certStores, boolean[] reasonsMask, Set trustAnchors, - Date validity) + Date validity, + String variant) throws CertStoreException { X509Certificate cert = selector.getCertificateChecking(); @@ -120,7 +136,7 @@ public class DistributionPointFetcher { DistributionPoint point = t.next(); Collection crls = getCRLs(selector, certImpl, point, reasonsMask, signFlag, prevKey, prevCert, provider, - certStores, trustAnchors, validity); + certStores, trustAnchors, validity, variant); results.addAll(crls); } if (debug != null) { @@ -145,7 +161,7 @@ public class DistributionPointFetcher { X509CertImpl certImpl, DistributionPoint point, boolean[] reasonsMask, boolean signFlag, PublicKey prevKey, X509Certificate prevCert, String provider, List certStores, - Set trustAnchors, Date validity) + Set trustAnchors, Date validity, String variant) throws CertStoreException { // check for full name @@ -208,7 +224,7 @@ public class DistributionPointFetcher { selector.setIssuerNames(null); if (selector.match(crl) && verifyCRL(certImpl, point, crl, reasonsMask, signFlag, prevKey, prevCert, provider, - trustAnchors, certStores, validity)) { + trustAnchors, certStores, validity, variant)) { crls.add(crl); } } catch (IOException | CRLException e) { @@ -316,7 +332,7 @@ public class DistributionPointFetcher { X509CRL crl, boolean[] reasonsMask, boolean signFlag, PublicKey prevKey, X509Certificate prevCert, String provider, Set trustAnchors, List certStores, - Date validity) throws CRLException, IOException { + Date validity, String variant) throws CRLException, IOException { if (debug != null) { debug.println("DistributionPointFetcher.verifyCRL: " + @@ -663,7 +679,7 @@ public class DistributionPointFetcher { // check the crl signature algorithm try { - AlgorithmChecker.check(prevKey, crl); + AlgorithmChecker.check(prevKey, crl, variant); } catch (CertPathValidatorException cpve) { if (debug != null) { debug.println("CRL signature algorithm check failed: " + cpve); diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java index 8753072e9d0..dce73028cd0 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java @@ -1,5 +1,5 @@ /* - * 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 @@ -45,6 +45,7 @@ import java.util.Map; import sun.security.action.GetIntegerAction; import sun.security.util.Debug; +import sun.security.validator.Validator; import sun.security.x509.AccessDescription; import sun.security.x509.AuthorityInfoAccessExtension; import sun.security.x509.GeneralName; @@ -94,42 +95,6 @@ public final class OCSP { private OCSP() {} - /** - * Obtains the revocation status of a certificate using OCSP using the most - * common defaults. The OCSP responder URI is retrieved from the - * certificate's AIA extension. The OCSP responder certificate is assumed - * to be the issuer's certificate (or issued by the issuer CA). - * - * @param cert the certificate to be checked - * @param issuerCert the issuer certificate - * @return the RevocationStatus - * @throws IOException if there is an exception connecting to or - * communicating with the OCSP responder - * @throws CertPathValidatorException if an exception occurs while - * encoding the OCSP Request or validating the OCSP Response - */ - public static RevocationStatus check(X509Certificate cert, - X509Certificate issuerCert) - throws IOException, CertPathValidatorException { - CertId certId = null; - URI responderURI = null; - try { - X509CertImpl certImpl = X509CertImpl.toImpl(cert); - responderURI = getResponderURI(certImpl); - if (responderURI == null) { - throw new CertPathValidatorException - ("No OCSP Responder URI in certificate"); - } - certId = new CertId(issuerCert, certImpl.getSerialNumberObject()); - } catch (CertificateException | IOException e) { - throw new CertPathValidatorException - ("Exception while encoding OCSPRequest", e); - } - OCSPResponse ocspResponse = check(Collections.singletonList(certId), - responderURI, new OCSPResponse.IssuerInfo(issuerCert), null, null, - Collections.emptyList()); - return (RevocationStatus)ocspResponse.getSingleResponse(certId); - } /** * Obtains the revocation status of a certificate using OCSP. @@ -146,6 +111,8 @@ public final class OCSP { * @throws CertPathValidatorException if an exception occurs while * encoding the OCSP Request or validating the OCSP Response */ + + // Called by com.sun.deploy.security.TrustDecider public static RevocationStatus check(X509Certificate cert, X509Certificate issuerCert, URI responderURI, @@ -154,27 +121,27 @@ public final class OCSP { throws IOException, CertPathValidatorException { return check(cert, issuerCert, responderURI, responderCert, date, - Collections.emptyList()); + Collections.emptyList(), Validator.VAR_GENERIC); } - // Called by com.sun.deploy.security.TrustDecider + public static RevocationStatus check(X509Certificate cert, - X509Certificate issuerCert, - URI responderURI, - X509Certificate responderCert, - Date date, List extensions) + X509Certificate issuerCert, URI responderURI, + X509Certificate responderCert, Date date, List extensions, + String variant) throws IOException, CertPathValidatorException { - return check(cert, responderURI, null, issuerCert, responderCert, date, extensions); + return check(cert, responderURI, null, issuerCert, responderCert, date, + extensions, variant); } public static RevocationStatus check(X509Certificate cert, URI responderURI, TrustAnchor anchor, X509Certificate issuerCert, X509Certificate responderCert, Date date, - List extensions) + List extensions, String variant) throws IOException, CertPathValidatorException { - CertId certId = null; + CertId certId; try { X509CertImpl certImpl = X509CertImpl.toImpl(cert); certId = new CertId(issuerCert, certImpl.getSerialNumberObject()); @@ -184,7 +151,7 @@ public final class OCSP { } OCSPResponse ocspResponse = check(Collections.singletonList(certId), responderURI, new OCSPResponse.IssuerInfo(anchor, issuerCert), - responderCert, date, extensions); + responderCert, date, extensions, variant); return (RevocationStatus) ocspResponse.getSingleResponse(certId); } @@ -206,10 +173,10 @@ public final class OCSP { * @throws CertPathValidatorException if an exception occurs while * encoding the OCSP Request or validating the OCSP Response */ - static OCSPResponse check(List certIds, URI responderURI, + static OCSPResponse check(List certIds, URI responderURI, OCSPResponse.IssuerInfo issuerInfo, X509Certificate responderCert, Date date, - List extensions) + List extensions, String variant) throws IOException, CertPathValidatorException { byte[] nonce = null; @@ -226,7 +193,7 @@ public final class OCSP { // verify the response ocspResponse.verify(certIds, issuerInfo, responderCert, date, - nonce); + nonce, variant); } catch (IOException ioe) { throw new CertPathValidatorException( "Unable to determine revocation status due to network error", diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java index d1770da153a..11f1b0996db 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.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 @@ -41,7 +41,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; import javax.security.auth.x500.X500Principal; @@ -375,7 +374,8 @@ public final class OCSPResponse { } void verify(List certIds, IssuerInfo issuerInfo, - X509Certificate responderCert, Date date, byte[] nonce) + X509Certificate responderCert, Date date, byte[] nonce, + String variant) throws CertPathValidatorException { switch (responseStatus) { @@ -508,7 +508,8 @@ public final class OCSPResponse { // Check algorithm constraints specified in security property // "jdk.certpath.disabledAlgorithms". AlgorithmChecker algChecker = - new AlgorithmChecker(issuerInfo.getAnchor(), date); + new AlgorithmChecker(issuerInfo.getAnchor(), date, + variant); algChecker.init(false); algChecker.check(signerCert, Collections.emptySet()); @@ -568,7 +569,7 @@ public final class OCSPResponse { if (signerCert != null) { // Check algorithm constraints specified in security property // "jdk.certpath.disabledAlgorithms". - AlgorithmChecker.check(signerCert.getPublicKey(), sigAlgId); + AlgorithmChecker.check(signerCert.getPublicKey(), sigAlgId, variant); if (!verifySignature(signerCert)) { throw new CertPathValidatorException( diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIX.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIX.java index f6b0b2ed6f3..8a177c04fc1 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIX.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIX.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -87,6 +87,7 @@ class PKIX { private Set anchors; private List certs; private Timestamp timestamp; + private String variant; ValidatorParams(CertPath cp, PKIXParameters params) throws InvalidAlgorithmParameterException @@ -102,8 +103,9 @@ class PKIX { ValidatorParams(PKIXParameters params) throws InvalidAlgorithmParameterException { - if (params instanceof PKIXTimestampParameters) { - timestamp = ((PKIXTimestampParameters) params).getTimestamp(); + if (params instanceof PKIXExtendedParameters) { + timestamp = ((PKIXExtendedParameters) params).getTimestamp(); + variant = ((PKIXExtendedParameters) params).getVariant(); } this.anchors = params.getTrustAnchors(); @@ -199,6 +201,10 @@ class PKIX { Timestamp timestamp() { return timestamp; } + + String variant() { + return variant; + } } static class BuilderParams extends ValidatorParams { diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java index ac12fab75ab..53ae439baf3 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.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 @@ -172,11 +172,8 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi { List certPathCheckers = new ArrayList<>(); // add standard checkers that we will be using certPathCheckers.add(untrustedChecker); - if (params.timestamp() == null) { - certPathCheckers.add(new AlgorithmChecker(anchor, params.date())); - } else { - certPathCheckers.add(new AlgorithmChecker(params.timestamp())); - } + certPathCheckers.add(new AlgorithmChecker(anchor, null, params.date(), + params.timestamp(), params.variant())); certPathCheckers.add(new KeyChecker(certPathLen, params.targetCertConstraints())); certPathCheckers.add(new ConstraintsChecker(certPathLen)); @@ -194,13 +191,10 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi { certPathCheckers.add(pc); // default value for date is current time BasicChecker bc; - if (params.timestamp() == null) { - bc = new BasicChecker(anchor, params.date(), params.sigProvider(), - false); - } else { - bc = new BasicChecker(anchor, params.timestamp().getTimestamp(), - params.sigProvider(), false); - } + bc = new BasicChecker(anchor, + (params.timestamp() == null ? params.date() : + params.timestamp().getTimestamp()), + params.sigProvider(), false); certPathCheckers.add(bc); boolean revCheckerAdded = false; diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXTimestampParameters.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXExtendedParameters.java similarity index 91% rename from jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXTimestampParameters.java rename to jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXExtendedParameters.java index 34b497188e0..42c2d1f9c4f 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXTimestampParameters.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXExtendedParameters.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 @@ -39,19 +39,23 @@ import java.util.Set; /** * This class is a wrapper for PKIXBuilderParameters so that a Timestamp object - * can be passed alone when PKIXCertPath is checking signed jar files. + * and a string for the variant type, can be passed when doing certpath + * checking. */ -public class PKIXTimestampParameters extends PKIXBuilderParameters { +public class PKIXExtendedParameters extends PKIXBuilderParameters { private final PKIXBuilderParameters p; private Timestamp jarTimestamp; + private final String variant; - public PKIXTimestampParameters(PKIXBuilderParameters params, - Timestamp timestamp) throws InvalidAlgorithmParameterException { + public PKIXExtendedParameters(PKIXBuilderParameters params, + Timestamp timestamp, String variant) + throws InvalidAlgorithmParameterException { super(params.getTrustAnchors(), null); p = params; jarTimestamp = timestamp; + this.variant = variant; } public Timestamp getTimestamp() { @@ -61,6 +65,10 @@ public class PKIXTimestampParameters extends PKIXBuilderParameters { jarTimestamp = t; } + public String getVariant() { + return variant; + } + @Override public void setDate(Date d) { p.setDate(d); diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java index 5fba1666119..9b443a733dd 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -579,7 +579,7 @@ class RevocationChecker extends PKIXRevocationChecker { approvedCRLs.addAll(DistributionPointFetcher.getCRLs( sel, signFlag, prevKey, prevCert, params.sigProvider(), certStores, - reasonsMask, anchors, null)); + reasonsMask, anchors, null, params.variant())); } } catch (CertStoreException e) { if (e instanceof CertStoreTypeException) { @@ -727,7 +727,7 @@ class RevocationChecker extends PKIXRevocationChecker { } } response.verify(Collections.singletonList(certId), issuerInfo, - responderCert, params.date(), nonce); + responderCert, params.date(), nonce, params.variant()); } else { URI responderURI = (this.responderURI != null) @@ -741,7 +741,7 @@ class RevocationChecker extends PKIXRevocationChecker { response = OCSP.check(Collections.singletonList(certId), responderURI, issuerInfo, responderCert, null, - ocspExtensions); + ocspExtensions, params.variant()); } } catch (IOException e) { throw new CertPathValidatorException( @@ -853,7 +853,7 @@ class RevocationChecker extends PKIXRevocationChecker { if (DistributionPointFetcher.verifyCRL( certImpl, point, crl, reasonsMask, signFlag, prevKey, null, params.sigProvider(), anchors, - certStores, params.date())) + certStores, params.date(), params.variant())) { results.add(crl); } diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java index c0cc98a7a36..11d8a067329 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.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 @@ -344,7 +344,7 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi { // add the algorithm checker checkers.add(new AlgorithmChecker(builder.trustAnchor, - buildParams.date())); + buildParams.date(), null)); BasicChecker basicChecker = null; if (nextState.keyParamsNeeded()) { diff --git a/jdk/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java b/jdk/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java index 7b1fcce7eba..45cb91ff6c6 100644 --- a/jdk/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.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 @@ -191,14 +191,22 @@ public final class RSAPrivateCrtKeyImpl if (version != 0) { throw new IOException("Version must be 0"); } - n = getBigInteger(data); - e = getBigInteger(data); - d = getBigInteger(data); - p = getBigInteger(data); - q = getBigInteger(data); - pe = getBigInteger(data); - qe = getBigInteger(data); - coeff = getBigInteger(data); + + /* + * Some implementations do not correctly encode ASN.1 INTEGER values + * in 2's complement format, resulting in a negative integer when + * decoded. Correct the error by converting it to a positive integer. + * + * See CR 6255949 + */ + n = data.getPositiveBigInteger(); + e = data.getPositiveBigInteger(); + d = data.getPositiveBigInteger(); + p = data.getPositiveBigInteger(); + q = data.getPositiveBigInteger(); + pe = data.getPositiveBigInteger(); + qe = data.getPositiveBigInteger(); + coeff = data.getPositiveBigInteger(); if (derValue.data.available() != 0) { throw new IOException("Extra data available"); } @@ -206,23 +214,4 @@ public final class RSAPrivateCrtKeyImpl throw new InvalidKeyException("Invalid RSA private key", e); } } - - /** - * Read a BigInteger from the DerInputStream. - */ - static BigInteger getBigInteger(DerInputStream data) throws IOException { - BigInteger b = data.getBigInteger(); - - /* - * Some implementations do not correctly encode ASN.1 INTEGER values - * in 2's complement format, resulting in a negative integer when - * decoded. Correct the error by converting it to a positive integer. - * - * See CR 6255949 - */ - if (b.signum() < 0) { - b = new BigInteger(1, b.toByteArray()); - } - return b; - } } diff --git a/jdk/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java b/jdk/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java index 52c0d6718d7..5f2afac4df9 100644 --- a/jdk/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.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 @@ -111,8 +111,8 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey { throw new IOException("Not a SEQUENCE"); } DerInputStream data = derValue.data; - n = RSAPrivateCrtKeyImpl.getBigInteger(data); - e = RSAPrivateCrtKeyImpl.getBigInteger(data); + n = data.getPositiveBigInteger(); + e = data.getPositiveBigInteger(); if (derValue.data.available() != 0) { throw new IOException("Extra data available"); } diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java index a09932d94e5..51560f5872d 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, 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 @@ -265,6 +265,7 @@ abstract class BaseSSLSocketImpl extends SSLSocket { * the penalty of prematurly killing SSL sessions. */ @Override + @SuppressWarnings("deprecation") protected final void finalize() throws Throwable { try { close(); diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java b/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java index d4f2848c973..c91b25e72ef 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.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 @@ -43,6 +43,9 @@ import sun.security.action.GetPropertyAction; final class EllipticCurvesExtension extends HelloExtension { + /* Class and subclass dynamic debugging support */ + private static final Debug debug = Debug.getInstance("ssl"); + private static final int ARBITRARY_PRIME = 0xff01; private static final int ARBITRARY_CHAR2 = 0xff02; @@ -159,6 +162,11 @@ final class EllipticCurvesExtension extends HelloExtension { } // ignore unknown curves } } + if (idList.isEmpty() && JsseJce.isEcAvailable()) { + throw new IllegalArgumentException( + "System property jdk.tls.namedGroups(" + property + ") " + + "contains no supported elliptic curves"); + } } else { // default curves int[] ids; if (requireFips) { @@ -183,16 +191,17 @@ final class EllipticCurvesExtension extends HelloExtension { } } - if (idList.isEmpty()) { - throw new IllegalArgumentException( - "System property jdk.tls.namedGroups(" + property + ") " + - "contains no supported elliptic curves"); - } else { - supportedCurveIds = new int[idList.size()]; - int i = 0; - for (Integer id : idList) { - supportedCurveIds[i++] = id; - } + if (debug != null && idList.isEmpty()) { + Debug.log( + "Initialized [jdk.tls.namedGroups|default] list contains " + + "no available elliptic curves. " + + (property != null ? "(" + property + ")" : "[Default]")); + } + + supportedCurveIds = new int[idList.size()]; + int i = 0; + for (Integer id : idList) { + supportedCurveIds[i++] = id; } } diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index 46ae8d5281e..4f0a95ff80b 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.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 @@ -37,6 +37,7 @@ import javax.net.ssl.*; import sun.security.provider.certpath.AlgorithmChecker; import sun.security.action.GetPropertyAction; +import sun.security.validator.Validator; public abstract class SSLContextImpl extends SSLContextSpi { @@ -1436,7 +1437,7 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager constraints = new SSLAlgorithmConstraints(sslSocket, true); } - checkAlgorithmConstraints(chain, constraints); + checkAlgorithmConstraints(chain, constraints, isClient); } } @@ -1478,12 +1479,12 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager constraints = new SSLAlgorithmConstraints(engine, true); } - checkAlgorithmConstraints(chain, constraints); + checkAlgorithmConstraints(chain, constraints, isClient); } } private void checkAlgorithmConstraints(X509Certificate[] chain, - AlgorithmConstraints constraints) throws CertificateException { + AlgorithmConstraints constraints, boolean isClient) throws CertificateException { try { // Does the certificate chain end with a trusted certificate? @@ -1501,7 +1502,9 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager // A forward checker, need to check from trust to target if (checkedLength >= 0) { - AlgorithmChecker checker = new AlgorithmChecker(constraints); + AlgorithmChecker checker = + new AlgorithmChecker(constraints, null, + (isClient ? Validator.VAR_TLS_CLIENT : Validator.VAR_TLS_SERVER)); checker.init(false); for (int i = checkedLength; i >= 0; i--) { Certificate cert = chain[i]; diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java b/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java index 3ef37b798a1..0bb89fbc3ca 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SunJSSE.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 @@ -247,6 +247,7 @@ public abstract class SunJSSE extends java.security.Provider { } @Override + @SuppressWarnings("deprecation") protected final void finalize() throws Throwable { // empty super.finalize(); 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 b6ed37cc5a3..954b90d15dd 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 @@ -39,6 +39,7 @@ import java.security.cert.Certificate; import javax.net.ssl.*; import sun.security.provider.certpath.AlgorithmChecker; +import sun.security.validator.Validator; /** * The new X509 key manager implementation. The main differences to the @@ -661,6 +662,15 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager return CheckResult.OK; } + + public String getValidator() { + if (this == CLIENT) { + return Validator.VAR_TLS_CLIENT; + } else if (this == SERVER) { + return Validator.VAR_TLS_SERVER; + } + return Validator.VAR_GENERIC; + } } // enum for the result of the extension check @@ -774,7 +784,8 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager // check the algorithm constraints if (constraints != null && - !conformsToAlgorithmConstraints(constraints, chain)) { + !conformsToAlgorithmConstraints(constraints, chain, + checkType.getValidator())) { if (useDebug) { debug.println("Ignoring alias " + alias + @@ -811,9 +822,10 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager } private static boolean conformsToAlgorithmConstraints( - AlgorithmConstraints constraints, Certificate[] chain) { + AlgorithmConstraints constraints, Certificate[] chain, + String variant) { - AlgorithmChecker checker = new AlgorithmChecker(constraints); + AlgorithmChecker checker = new AlgorithmChecker(constraints, null, variant); try { checker.init(false); } catch (CertPathValidatorException cpve) { diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java index a8e7328b753..42c84872bad 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.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 @@ -35,6 +35,7 @@ import java.security.cert.*; import javax.net.ssl.*; import sun.security.validator.*; +import sun.security.util.AnchorCertificates; import sun.security.util.HostnameChecker; /** @@ -186,13 +187,11 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager return v; } - private void checkTrusted(X509Certificate[] chain, String authType, Socket socket, boolean isClient) throws CertificateException { Validator v = checkTrustedInit(chain, authType, isClient); - AlgorithmConstraints constraints = null; - List responseList = Collections.emptyList(); + X509Certificate[] trustedChain = null; if ((socket != null) && socket.isConnected() && (socket instanceof SSLSocket)) { @@ -202,48 +201,46 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager throw new CertificateException("No handshake session"); } - // check endpoint identity - String identityAlg = sslSocket.getSSLParameters(). - getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { - checkIdentity(session, chain[0], identityAlg, isClient, - getRequestedServerNames(socket)); - } - // create the algorithm constraints ProtocolVersion protocolVersion = ProtocolVersion.valueOf(session.getProtocol()); - if (protocolVersion.v >= ProtocolVersion.TLS12.v) { - if (session instanceof ExtendedSSLSession) { - ExtendedSSLSession extSession = - (ExtendedSSLSession)session; - String[] localSupportedSignAlgs = - extSession.getLocalSupportedSignatureAlgorithms(); + boolean isExtSession = (session instanceof ExtendedSSLSession); + AlgorithmConstraints constraints = null; + if (protocolVersion.v >= ProtocolVersion.TLS12.v && isExtSession) { + ExtendedSSLSession extSession = (ExtendedSSLSession)session; + String[] localSupportedSignAlgs = + extSession.getLocalSupportedSignatureAlgorithms(); - constraints = new SSLAlgorithmConstraints( - sslSocket, localSupportedSignAlgs, false); - } else { - constraints = - new SSLAlgorithmConstraints(sslSocket, false); - } + constraints = new SSLAlgorithmConstraints( + sslSocket, localSupportedSignAlgs, false); } else { constraints = new SSLAlgorithmConstraints(sslSocket, false); } // Grab any stapled OCSP responses for use in validation - if (session instanceof ExtendedSSLSession) { + List responseList = Collections.emptyList(); + if (!isClient && isExtSession) { responseList = ((ExtendedSSLSession)session).getStatusResponses(); } - } + trustedChain = validate(v, chain, responseList, + constraints, isClient ? null : authType); - X509Certificate[] trustedChain = null; - if (isClient) { - trustedChain = validate(v, chain, Collections.emptyList(), - constraints, null); + // check if EE certificate chains to a public root CA (as + // pre-installed in cacerts) + boolean chainsToPublicCA = + AnchorCertificates.contains(trustedChain[trustedChain.length-1]); + + // check endpoint identity + String identityAlg = sslSocket.getSSLParameters(). + getEndpointIdentificationAlgorithm(); + if (identityAlg != null && identityAlg.length() != 0) { + checkIdentity(session, trustedChain[0], identityAlg, isClient, + getRequestedServerNames(socket), chainsToPublicCA); + } } else { - trustedChain = validate(v, chain, responseList, constraints, - authType); + trustedChain = validate(v, chain, Collections.emptyList(), + null, isClient ? null : authType); } if (debug != null && Debug.isOn("trustmanager")) { System.out.println("Found trusted certificate:"); @@ -255,56 +252,53 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager SSLEngine engine, boolean isClient) throws CertificateException { Validator v = checkTrustedInit(chain, authType, isClient); - AlgorithmConstraints constraints = null; - List responseList = Collections.emptyList(); + X509Certificate[] trustedChain = null; if (engine != null) { SSLSession session = engine.getHandshakeSession(); if (session == null) { throw new CertificateException("No handshake session"); } - // check endpoint identity - String identityAlg = engine.getSSLParameters(). - getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { - checkIdentity(session, chain[0], identityAlg, isClient, - getRequestedServerNames(engine)); - } - // create the algorithm constraints ProtocolVersion protocolVersion = ProtocolVersion.valueOf(session.getProtocol()); - if (protocolVersion.v >= ProtocolVersion.TLS12.v) { - if (session instanceof ExtendedSSLSession) { - ExtendedSSLSession extSession = - (ExtendedSSLSession)session; - String[] localSupportedSignAlgs = - extSession.getLocalSupportedSignatureAlgorithms(); + boolean isExtSession = (session instanceof ExtendedSSLSession); + AlgorithmConstraints constraints = null; + if (protocolVersion.v >= ProtocolVersion.TLS12.v && isExtSession) { + ExtendedSSLSession extSession = (ExtendedSSLSession)session; + String[] localSupportedSignAlgs = + extSession.getLocalSupportedSignatureAlgorithms(); - constraints = new SSLAlgorithmConstraints( - engine, localSupportedSignAlgs, false); - } else { - constraints = - new SSLAlgorithmConstraints(engine, false); - } + constraints = new SSLAlgorithmConstraints( + engine, localSupportedSignAlgs, false); } else { constraints = new SSLAlgorithmConstraints(engine, false); } // Grab any stapled OCSP responses for use in validation - if (session instanceof ExtendedSSLSession) { + List responseList = Collections.emptyList(); + if (!isClient && isExtSession) { responseList = ((ExtendedSSLSession)session).getStatusResponses(); } - } + trustedChain = validate(v, chain, responseList, + constraints, isClient ? null : authType); - X509Certificate[] trustedChain = null; - if (isClient) { - trustedChain = validate(v, chain, Collections.emptyList(), - constraints, null); + // check if EE certificate chains to a public root CA (as + // pre-installed in cacerts) + boolean chainsToPublicCA = + AnchorCertificates.contains(trustedChain[trustedChain.length-1]); + + // check endpoint identity + String identityAlg = engine.getSSLParameters(). + getEndpointIdentificationAlgorithm(); + if (identityAlg != null && identityAlg.length() != 0) { + checkIdentity(session, trustedChain[0], identityAlg, isClient, + getRequestedServerNames(engine), chainsToPublicCA); + } } else { - trustedChain = validate(v, chain, responseList, constraints, - authType); + trustedChain = validate(v, chain, Collections.emptyList(), + null, isClient ? null : authType); } if (debug != null && Debug.isOn("trustmanager")) { System.out.println("Found trusted certificate:"); @@ -437,7 +431,8 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager X509Certificate cert, String algorithm, boolean isClient, - List sniNames) throws CertificateException { + List sniNames, + boolean chainsToPublicCA) throws CertificateException { boolean identifiable = false; String peerHost = session.getPeerHost(); @@ -445,7 +440,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager String hostname = getHostNameInSNI(sniNames); if (hostname != null) { try { - checkIdentity(hostname, cert, algorithm); + checkIdentity(hostname, cert, algorithm, chainsToPublicCA); identifiable = true; } catch (CertificateException ce) { if (hostname.equalsIgnoreCase(peerHost)) { @@ -458,7 +453,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager } if (!identifiable) { - checkIdentity(peerHost, cert, algorithm); + checkIdentity(peerHost, cert, algorithm, chainsToPublicCA); } } @@ -469,6 +464,12 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager */ static void checkIdentity(String hostname, X509Certificate cert, String algorithm) throws CertificateException { + checkIdentity(hostname, cert, algorithm, false); + } + + private static void checkIdentity(String hostname, X509Certificate cert, + String algorithm, boolean chainsToPublicCA) + throws CertificateException { if (algorithm != null && algorithm.length() != 0) { // if IPv6 strip off the "[]" if ((hostname != null) && hostname.startsWith("[") && @@ -478,11 +479,11 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager if (algorithm.equalsIgnoreCase("HTTPS")) { HostnameChecker.getInstance(HostnameChecker.TYPE_TLS).match( - hostname, cert); + hostname, cert, chainsToPublicCA); } else if (algorithm.equalsIgnoreCase("LDAP") || algorithm.equalsIgnoreCase("LDAPS")) { HostnameChecker.getInstance(HostnameChecker.TYPE_LDAP).match( - hostname, cert); + hostname, cert, chainsToPublicCA); } else { throw new CertificateException( "Unknown identification algorithm: " + algorithm); 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 b73773f5711..53ea9706207 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 @@ -27,6 +27,7 @@ package sun.security.tools.keytool; import java.io.*; import java.security.CodeSigner; +import java.security.CryptoPrimitive; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.MessageDigest; @@ -156,6 +157,7 @@ public final class Main { private boolean protectedPath = false; private boolean srcprotectedPath = false; private boolean cacerts = false; + private boolean nowarn = false; private CertificateFactory cf = null; private KeyStore caks = null; // "cacerts" keystore private char[] srcstorePass = null; @@ -166,6 +168,16 @@ public final class Main { private List ids = new ArrayList<>(); // used in GENCRL private List v3ext = new ArrayList<>(); + // Warnings on weak algorithms + private List weakWarnings = new ArrayList<>(); + + private static final DisabledAlgorithmConstraints DISABLED_CHECK = + new DisabledAlgorithmConstraints( + DisabledAlgorithmConstraints.PROPERTY_CERTPATH_DISABLED_ALGS); + + private static final Set SIG_PRIMITIVE_SET = Collections + .unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE)); + enum Command { CERTREQ("Generates.a.certificate.request", ALIAS, SIGALG, FILEOUT, KEYPASS, KEYSTORE, DNAME, @@ -351,7 +363,7 @@ public final class Main { private static final String NONE = "NONE"; private static final String P11KEYSTORE = "PKCS11"; private static final String P12KEYSTORE = "PKCS12"; - private final String keyAlias = "mykey"; + private static final String keyAlias = "mykey"; // for i18n private static final java.util.ResourceBundle rb = @@ -387,6 +399,7 @@ public final class Main { throw e; } } finally { + printWeakWarnings(false); for (char[] pass : passwords) { if (pass != null) { Arrays.fill(pass, ' '); @@ -476,6 +489,8 @@ public final class Main { help = true; } else if (collator.compare(flags, "-conf") == 0) { i++; + } else if (collator.compare(flags, "-nowarn") == 0) { + nowarn = true; } else if (collator.compare(flags, "-keystore") == 0) { ksfname = args[++i]; if (new File(ksfname).getCanonicalPath().equals( @@ -1010,6 +1025,13 @@ public final class Main { cf = CertificateFactory.getInstance("X509"); } + // -trustcacerts can only be specified on -importcert. + // Reset it so that warnings on CA cert will remain for + // -printcert, etc. + if (command != IMPORTCERT) { + trustcacerts = false; + } + if (trustcacerts) { caks = KeyStoreUtil.getCacertsKeyStore(); } @@ -1152,11 +1174,11 @@ public final class Main { } else if (command == LIST) { if (storePass == null && !KeyStoreUtil.isWindowsKeyStore(storetype)) { - printWarning(); + printNoIntegrityWarning(); } if (alias != null) { - doPrintEntry(alias, out); + doPrintEntry(rb.getString("the.certificate"), alias, out); } else { doPrintEntries(out); } @@ -1253,6 +1275,12 @@ public final class Main { throws Exception { + if (keyStore.containsAlias(alias) == false) { + MessageFormat form = new MessageFormat + (rb.getString("Alias.alias.does.not.exist")); + Object[] source = {alias}; + throw new Exception(form.format(source)); + } Certificate signerCert = keyStore.getCertificate(alias); byte[] encoded = signerCert.getEncoded(); X509CertImpl signerCertImpl = new X509CertImpl(encoded); @@ -1306,6 +1334,8 @@ public final class Main { byte[] rawReq = Pem.decode(new String(sb)); PKCS10 req = new PKCS10(rawReq); + checkWeak(rb.getString("the.certificate.request"), req); + info.set(X509CertInfo.KEY, new CertificateX509Key(req.getSubjectPublicKeyInfo())); info.set(X509CertInfo.SUBJECT, dname==null?req.getSubjectName():new X500Name(dname)); @@ -1335,6 +1365,9 @@ public final class Main { } } } + + checkWeak(rb.getString("the.issuer"), keyStore.getCertificateChain(alias)); + checkWeak(rb.getString("the.generated.certificate"), cert); } private void doGenCRL(PrintStream out) @@ -1385,6 +1418,7 @@ public final class Main { } else { out.write(crl.getEncodedInternal()); } + checkWeak(rb.getString("the.generated.crl"), crl, privateKey); } /** @@ -1431,6 +1465,8 @@ public final class Main { // Sign the request and base-64 encode it request.encodeAndSign(subject, signature); request.print(out); + + checkWeak(rb.getString("the.generated.certificate.request"), request); } /** @@ -1454,7 +1490,7 @@ public final class Main { { if (storePass == null && !KeyStoreUtil.isWindowsKeyStore(storetype)) { - printWarning(); + printNoIntegrityWarning(); } if (alias == null) { alias = keyAlias; @@ -1474,6 +1510,7 @@ public final class Main { throw new Exception(form.format(source)); } dumpCert(cert, out); + checkWeak(rb.getString("the.certificate"), cert); } /** @@ -1728,6 +1765,7 @@ public final class Main { if (keyPass == null) { keyPass = promptForKeyPass(alias, null, storePass); } + checkWeak(rb.getString("the.generated.certificate"), chain[0]); keyStore.setKeyEntry(alias, privKey, keyPass, chain); } @@ -1810,7 +1848,7 @@ public final class Main { /** * Prints a single keystore entry. */ - private void doPrintEntry(String alias, PrintStream out) + private void doPrintEntry(String label, String alias, PrintStream out) throws Exception { if (keyStore.containsAlias(alias) == false) { @@ -1881,12 +1919,14 @@ public final class Main { } else { dumpCert(chain[i], out); } + checkWeak(label, chain[i]); } } else { // Print the digest of the user cert only out.println (rb.getString("Certificate.fingerprint.SHA.256.") + getCertFingerPrint("SHA-256", chain[0])); + checkWeak(label, chain); } } } else if (keyStore.entryInstanceOf(alias, @@ -1909,6 +1949,7 @@ public final class Main { out.println(rb.getString("Certificate.fingerprint.SHA.256.") + getCertFingerPrint("SHA-256", cert)); } + checkWeak(label, cert); } else { out.println(rb.getString("Unknown.Entry.Type")); } @@ -1992,7 +2033,7 @@ public final class Main { if (srcstorePass == null && !KeyStoreUtil.isWindowsKeyStore(srcstoretype)) { - // anti refactoring, copied from printWarning(), + // anti refactoring, copied from printNoIntegrityWarning(), // but change 2 lines System.err.println(); System.err.println(rb.getString @@ -2083,6 +2124,10 @@ public final class Main { } try { + Certificate c = srckeystore.getCertificate(alias); + if (c != null) { + checkWeak("<" + newAlias + ">", c); + } keyStore.setEntry(newAlias, entry, pp); // Place the check so that only successful imports are blocked. // For example, we don't block a failed SecretEntry import. @@ -2154,7 +2199,7 @@ public final class Main { for (Enumeration e = keyStore.aliases(); e.hasMoreElements(); ) { String alias = e.nextElement(); - doPrintEntry(alias, out); + doPrintEntry("<" + alias + ">", alias, out); if (verbose || rfc) { out.println(rb.getString("NEWLINE")); out.println(rb.getString @@ -2300,19 +2345,28 @@ public final class Main { for (CRL crl: loadCRLs(src)) { printCRL(crl, out); String issuer = null; + Certificate signer = null; if (caks != null) { issuer = verifyCRL(caks, crl); if (issuer != null) { + signer = caks.getCertificate(issuer); out.printf(rb.getString( - "verified.by.s.in.s"), issuer, "cacerts"); + "verified.by.s.in.s.weak"), + issuer, + "cacerts", + withWeak(signer.getPublicKey())); out.println(); } } if (issuer == null && keyStore != null) { issuer = verifyCRL(keyStore, crl); if (issuer != null) { + signer = keyStore.getCertificate(issuer); out.printf(rb.getString( - "verified.by.s.in.s"), issuer, "keystore"); + "verified.by.s.in.s.weak"), + issuer, + "keystore", + withWeak(signer.getPublicKey())); out.println(); } } @@ -2324,18 +2378,26 @@ public final class Main { out.println(rb.getString ("STARNN")); } + checkWeak(rb.getString("the.crl"), crl, signer == null ? null : signer.getPublicKey()); } } private void printCRL(CRL crl, PrintStream out) throws Exception { + X509CRL xcrl = (X509CRL)crl; if (rfc) { - X509CRL xcrl = (X509CRL)crl; out.println("-----BEGIN X509 CRL-----"); out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(xcrl.getEncoded())); out.println("-----END X509 CRL-----"); } else { - out.println(crl.toString()); + String s; + if (crl instanceof X509CRLImpl) { + X509CRLImpl x509crl = (X509CRLImpl) crl; + s = x509crl.toStringWithAlgName(withWeak("" + x509crl.getSigAlgId())); + } else { + s = crl.toString(); + } + out.println(s); } } @@ -2362,8 +2424,11 @@ public final class Main { PKCS10 req = new PKCS10(Pem.decode(new String(sb))); PublicKey pkey = req.getSubjectPublicKeyInfo(); - out.printf(rb.getString("PKCS.10.Certificate.Request.Version.1.0.Subject.s.Public.Key.s.format.s.key."), - req.getSubjectName(), pkey.getFormat(), pkey.getAlgorithm()); + out.printf(rb.getString("PKCS.10.with.weak"), + req.getSubjectName(), + pkey.getFormat(), + withWeak(pkey), + withWeak(req.getSigAlg())); for (PKCS10Attribute attr: req.getAttributes().getAttributes()) { ObjectIdentifier oid = attr.getAttributeId(); if (oid.equals(PKCS9Attribute.EXTENSION_REQUEST_OID)) { @@ -2386,6 +2451,7 @@ public final class Main { if (debug) { out.println(req); // Just to see more, say, public key length... } + checkWeak(rb.getString("the.certificate.request"), req); } /** @@ -2425,6 +2491,15 @@ public final class Main { if (i < (certs.length-1)) { out.println(); } + checkWeak(oneInMany(rb.getString("the.certificate"), i, certs.length), x509Cert); + } + } + + private static String oneInMany(String label, int i, int num) { + if (num == 1) { + return label; + } else { + return String.format(rb.getString("one.in.many"), label, i+1, num); } } @@ -2458,7 +2533,11 @@ public final class Main { out.println(); out.println(rb.getString("Signature.")); out.println(); - for (Certificate cert: signer.getSignerCertPath().getCertificates()) { + + List certs + = signer.getSignerCertPath().getCertificates(); + int cc = 0; + for (Certificate cert: certs) { X509Certificate x = (X509Certificate)cert; if (rfc) { out.println(rb.getString("Certificate.owner.") + x.getSubjectDN() + "\n"); @@ -2467,12 +2546,15 @@ public final class Main { printX509Cert(x, out); } out.println(); + checkWeak(oneInMany(rb.getString("the.certificate"), cc++, certs.size()), x); } Timestamp ts = signer.getTimestamp(); if (ts != null) { out.println(rb.getString("Timestamp.")); out.println(); - for (Certificate cert: ts.getSignerCertPath().getCertificates()) { + certs = ts.getSignerCertPath().getCertificates(); + cc = 0; + for (Certificate cert: certs) { X509Certificate x = (X509Certificate)cert; if (rfc) { out.println(rb.getString("Certificate.owner.") + x.getSubjectDN() + "\n"); @@ -2481,6 +2563,7 @@ public final class Main { printX509Cert(x, out); } out.println(); + checkWeak(oneInMany(rb.getString("the.tsa.certificate"), cc++, certs.size()), x); } } } @@ -2523,6 +2606,7 @@ public final class Main { printX509Cert((X509Certificate)cert, out); out.println(); } + checkWeak(oneInMany(rb.getString("the.certificate"), i, chain.size()), cert); } catch (Exception e) { if (debug) { e.printStackTrace(); @@ -2698,7 +2782,7 @@ public final class Main { } // Now store the newly established chain in the keystore. The new - // chain replaces the old one. + // chain replaces the old one. The chain can be null if user chooses no. if (newChain != null) { keyStore.setKeyEntry(alias, privKey, (keyPass != null) ? keyPass : storePass, @@ -2735,6 +2819,12 @@ public final class Main { throw new Exception(rb.getString("Input.not.an.X.509.certificate")); } + if (noprompt) { + checkWeak(rb.getString("the.input"), cert); + keyStore.setCertificateEntry(alias, cert); + return true; + } + // if certificate is self-signed, make sure it verifies boolean selfSigned = false; if (KeyStoreUtil.isSelfSigned(cert)) { @@ -2742,11 +2832,6 @@ public final class Main { selfSigned = true; } - if (noprompt) { - keyStore.setCertificateEntry(alias, cert); - return true; - } - // check if cert already exists in keystore String reply = null; String trustalias = keyStore.getCertificateAlias(cert); @@ -2755,6 +2840,8 @@ public final class Main { ("Certificate.already.exists.in.keystore.under.alias.trustalias.")); Object[] source = {trustalias}; System.err.println(form.format(source)); + checkWeak(rb.getString("the.input"), cert); + printWeakWarnings(true); reply = getYesNoReply (rb.getString("Do.you.still.want.to.add.it.no.")); } else if (selfSigned) { @@ -2764,6 +2851,8 @@ public final class Main { ("Certificate.already.exists.in.system.wide.CA.keystore.under.alias.trustalias.")); Object[] source = {trustalias}; System.err.println(form.format(source)); + checkWeak(rb.getString("the.input"), cert); + printWeakWarnings(true); reply = getYesNoReply (rb.getString("Do.you.still.want.to.add.it.to.your.own.keystore.no.")); } @@ -2771,6 +2860,8 @@ public final class Main { // Print the cert and ask user if they really want to add // it to their keystore printX509Cert(cert, System.out); + checkWeak(rb.getString("the.input"), cert); + printWeakWarnings(true); reply = getYesNoReply (rb.getString("Trust.this.certificate.no.")); } @@ -2784,6 +2875,7 @@ public final class Main { } } + // Not found in this keystore and not self-signed // Try to establish trust chain try { Certificate[] chain = establishCertChain(null, cert); @@ -2795,6 +2887,8 @@ public final class Main { // Print the cert and ask user if they really want to add it to // their keystore printX509Cert(cert, System.out); + checkWeak(rb.getString("the.input"), cert); + printWeakWarnings(true); reply = getYesNoReply (rb.getString("Trust.this.certificate.no.")); if ("YES".equals(reply)) { @@ -2933,6 +3027,24 @@ public final class Main { return keyPass; } + private String withWeak(String alg) { + if (DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, alg, null)) { + return alg; + } else { + return String.format(rb.getString("with.weak"), alg); + } + } + + private String withWeak(PublicKey key) { + if (DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) { + return String.format(rb.getString("key.bit"), + KeyUtil.getKeySize(key), key.getAlgorithm()); + } else { + return String.format(rb.getString("key.bit.weak"), + KeyUtil.getKeySize(key), key.getAlgorithm()); + } + } + /** * Prints a certificate in a human readable format. */ @@ -2941,8 +3053,13 @@ public final class Main { { MessageFormat form = new MessageFormat - (rb.getString(".PATTERN.printX509Cert")); + (rb.getString(".PATTERN.printX509Cert.with.weak")); PublicKey pkey = cert.getPublicKey(); + String sigName = cert.getSigAlgName(); + // No need to warn about sigalg of a trust anchor + if (!isTrustedCert(cert)) { + sigName = withWeak(sigName); + } Object[] source = {cert.getSubjectDN().toString(), cert.getIssuerDN().toString(), cert.getSerialNumber().toString(16), @@ -2950,10 +3067,9 @@ public final class Main { cert.getNotAfter().toString(), getCertFingerPrint("SHA-1", cert), getCertFingerPrint("SHA-256", cert), - cert.getSigAlgName(), - pkey.getAlgorithm(), - KeyUtil.getKeySize(pkey), - cert.getVersion(), + sigName, + withWeak(pkey), + cert.getVersion() }; out.println(form.format(source)); @@ -3003,12 +3119,12 @@ public final class Main { * @param ks the keystore to search with, not null * @return cert itself if it's already inside ks, * or a certificate inside ks who signs cert, - * or null otherwise. + * or null otherwise. A label is added. */ - private static Certificate getTrustedSigner(Certificate cert, KeyStore ks) - throws Exception { + private static Pair + getSigner(Certificate cert, KeyStore ks) throws Exception { if (ks.getCertificateAlias(cert) != null) { - return cert; + return new Pair<>("", cert); } for (Enumeration aliases = ks.aliases(); aliases.hasMoreElements(); ) { @@ -3017,7 +3133,7 @@ public final class Main { if (trustedCert != null) { try { cert.verify(trustedCert.getPublicKey()); - return trustedCert; + return new Pair<>(name, trustedCert); } catch (Exception e) { // Not verified, skip to the next one } @@ -3281,7 +3397,7 @@ public final class Main { /** * Prints warning about missing integrity check. */ - private void printWarning() { + private void printNoIntegrityWarning() { System.err.println(); System.err.println(rb.getString (".WARNING.WARNING.WARNING.")); @@ -3306,6 +3422,9 @@ public final class Main { Certificate[] replyCerts) throws Exception { + + checkWeak(rb.getString("reply"), replyCerts); + // order the certs in the reply (bottom-up). // we know that all certs in the reply are of type X.509, because // we parsed them using an X.509 certificate factory @@ -3358,9 +3477,11 @@ public final class Main { // do we trust the cert at the top? Certificate topCert = replyCerts[replyCerts.length-1]; - Certificate root = getTrustedSigner(topCert, keyStore); + boolean fromKeyStore = true; + Pair root = getSigner(topCert, keyStore); if (root == null && trustcacerts && caks != null) { - root = getTrustedSigner(topCert, caks); + root = getSigner(topCert, caks); + fromKeyStore = false; } if (root == null) { System.err.println(); @@ -3369,33 +3490,42 @@ public final class Main { printX509Cert((X509Certificate)topCert, System.out); System.err.println(); System.err.print(rb.getString(".is.not.trusted.")); + printWeakWarnings(true); String reply = getYesNoReply (rb.getString("Install.reply.anyway.no.")); if ("NO".equals(reply)) { return null; } } else { - if (root != topCert) { + if (root.snd != topCert) { // append the root CA cert to the chain Certificate[] tmpCerts = new Certificate[replyCerts.length+1]; System.arraycopy(replyCerts, 0, tmpCerts, 0, replyCerts.length); - tmpCerts[tmpCerts.length-1] = root; + tmpCerts[tmpCerts.length-1] = root.snd; replyCerts = tmpCerts; + checkWeak(String.format(rb.getString(fromKeyStore ? + "alias.in.keystore" : + "alias.in.cacerts"), + root.fst), + root.snd); } } - return replyCerts; } /** * Establishes a certificate chain (using trusted certificates in the - * keystore), starting with the user certificate + * keystore and cacerts), starting with the reply (certToVerify) * and ending at a self-signed certificate found in the keystore. * - * @param userCert the user certificate of the alias - * @param certToVerify the single certificate provided in the reply + * @param userCert optional existing certificate, mostly likely be the + * original self-signed cert created by -genkeypair. + * It must have the same public key as certToVerify + * but cannot be the same cert. + * @param certToVerify the starting certificate to build the chain + * @returns the established chain, might be null if user decides not */ private Certificate[] establishCertChain(Certificate userCert, Certificate certToVerify) @@ -3423,30 +3553,37 @@ public final class Main { // Use the subject distinguished name as the key into the hash table. // All certificates associated with the same subject distinguished // name are stored in the same hash table entry as a vector. - Hashtable> certs = null; + Hashtable>> certs = null; if (keyStore.size() > 0) { - certs = new Hashtable>(11); + certs = new Hashtable<>(11); keystorecerts2Hashtable(keyStore, certs); } if (trustcacerts) { if (caks!=null && caks.size()>0) { if (certs == null) { - certs = new Hashtable>(11); + certs = new Hashtable<>(11); } keystorecerts2Hashtable(caks, certs); } } // start building chain - Vector chain = new Vector<>(2); - if (buildChain((X509Certificate)certToVerify, chain, certs)) { - Certificate[] newChain = new Certificate[chain.size()]; + Vector> chain = new Vector<>(2); + if (buildChain( + new Pair<>(rb.getString("the.input"), + (X509Certificate) certToVerify), + chain, certs)) { + for (Pair p : chain) { + checkWeak(p.fst, p.snd); + } + Certificate[] newChain = + new Certificate[chain.size()]; // buildChain() returns chain with self-signed root-cert first and // user-cert last, so we need to invert the chain before we store // it int j=0; for (int i=chain.size()-1; i>=0; i--) { - newChain[j] = chain.elementAt(i); + newChain[j] = chain.elementAt(i).snd; j++; } return newChain; @@ -3457,7 +3594,17 @@ public final class Main { } /** - * Recursively tries to establish chain from pool of trusted certs. + * Recursively tries to establish chain from pool of certs starting from + * certToVerify until a self-signed cert is found, and fill the certs found + * into chain. Each cert in the chain signs the next one. + * + * This method is able to recover from an error, say, if certToVerify + * is signed by certA but certA has no issuer in certs and itself is not + * self-signed, the method can try another certB that also signs + * certToVerify and look for signer of certB, etc, etc. + * + * Each cert in chain comes with a label showing its origin. The label is + * used in the warning message when the cert is considered a risk. * * @param certToVerify the cert that needs to be verified. * @param chain the chain that's being built. @@ -3465,19 +3612,20 @@ public final class Main { * * @return true if successful, false otherwise. */ - private boolean buildChain(X509Certificate certToVerify, - Vector chain, - Hashtable> certs) { - Principal issuer = certToVerify.getIssuerDN(); - if (KeyStoreUtil.isSelfSigned(certToVerify)) { + private boolean buildChain(Pair certToVerify, + Vector> chain, + Hashtable>> certs) { + if (KeyStoreUtil.isSelfSigned(certToVerify.snd)) { // reached self-signed root cert; // no verification needed because it's trusted. chain.addElement(certToVerify); return true; } + Principal issuer = certToVerify.snd.getIssuerDN(); + // Get the issuer's certificate(s) - Vector vec = certs.get(issuer); + Vector> vec = certs.get(issuer); if (vec == null) { return false; } @@ -3485,13 +3633,12 @@ public final class Main { // Try out each certificate in the vector, until we find one // whose public key verifies the signature of the certificate // in question. - for (Enumeration issuerCerts = vec.elements(); - issuerCerts.hasMoreElements(); ) { - X509Certificate issuerCert - = (X509Certificate)issuerCerts.nextElement(); - PublicKey issuerPubKey = issuerCert.getPublicKey(); + for (Enumeration> issuerCerts = vec.elements(); + issuerCerts.hasMoreElements(); ) { + Pair issuerCert = issuerCerts.nextElement(); + PublicKey issuerPubKey = issuerCert.snd.getPublicKey(); try { - certToVerify.verify(issuerPubKey); + certToVerify.snd.verify(issuerPubKey); } catch (Exception e) { continue; } @@ -3541,10 +3688,11 @@ public final class Main { /** * Stores the (leaf) certificates of a keystore in a hashtable. * All certs belonging to the same CA are stored in a vector that - * in turn is stored in the hashtable, keyed by the CA's subject DN + * in turn is stored in the hashtable, keyed by the CA's subject DN. + * Each cert comes with a string label that shows its origin and alias. */ private void keystorecerts2Hashtable(KeyStore ks, - Hashtable> hash) + Hashtable>> hash) throws Exception { for (Enumeration aliases = ks.aliases(); @@ -3553,13 +3701,20 @@ public final class Main { Certificate cert = ks.getCertificate(alias); if (cert != null) { Principal subjectDN = ((X509Certificate)cert).getSubjectDN(); - Vector vec = hash.get(subjectDN); + Pair pair = new Pair<>( + String.format( + rb.getString(ks == caks ? + "alias.in.cacerts" : + "alias.in.keystore"), + alias), + (X509Certificate)cert); + Vector> vec = hash.get(subjectDN); if (vec == null) { - vec = new Vector(); - vec.addElement(cert); + vec = new Vector<>(); + vec.addElement(pair); } else { - if (!vec.contains(cert)) { - vec.addElement(cert); + if (!vec.contains(pair)) { + vec.addElement(pair); } } hash.put(subjectDN, vec); @@ -4157,6 +4312,81 @@ public final class Main { return result; } + private boolean isTrustedCert(Certificate cert) throws KeyStoreException { + if (caks != null && caks.getCertificateAlias(cert) != null) { + return true; + } else { + String inKS = keyStore.getCertificateAlias(cert); + return inKS != null && keyStore.isCertificateEntry(inKS); + } + } + + private void checkWeak(String label, String sigAlg, Key key) { + + if (sigAlg != null && !DISABLED_CHECK.permits( + SIG_PRIMITIVE_SET, sigAlg, null)) { + weakWarnings.add(String.format( + rb.getString("whose.sigalg.risk"), label, sigAlg)); + } + if (key != null && !DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) { + weakWarnings.add(String.format( + rb.getString("whose.key.risk"), + label, + String.format(rb.getString("key.bit"), + KeyUtil.getKeySize(key), key.getAlgorithm()))); + } + } + + private void checkWeak(String label, Certificate[] certs) + throws KeyStoreException { + for (int i = 0; i < certs.length; i++) { + Certificate cert = certs[i]; + if (cert instanceof X509Certificate) { + X509Certificate xc = (X509Certificate)cert; + String fullLabel = label; + if (certs.length > 1) { + fullLabel = oneInMany(label, i, certs.length); + } + checkWeak(fullLabel, xc); + } + } + } + + private void checkWeak(String label, Certificate cert) + throws KeyStoreException { + if (cert instanceof X509Certificate) { + X509Certificate xc = (X509Certificate)cert; + // No need to check the sigalg of a trust anchor + String sigAlg = isTrustedCert(cert) ? null : xc.getSigAlgName(); + checkWeak(label, sigAlg, xc.getPublicKey()); + } + } + + private void checkWeak(String label, PKCS10 p10) { + checkWeak(label, p10.getSigAlg(), p10.getSubjectPublicKeyInfo()); + } + + private void checkWeak(String label, CRL crl, Key key) { + if (crl instanceof X509CRLImpl) { + X509CRLImpl impl = (X509CRLImpl)crl; + checkWeak(label, impl.getSigAlgName(), key); + } + } + + private void printWeakWarnings(boolean newLine) { + if (!weakWarnings.isEmpty() && !nowarn) { + System.err.println("\nWarning:"); + for (String warning : weakWarnings) { + System.err.println(warning); + } + if (newLine) { + // When calling before a yes/no prompt, add a new line + System.err.println(); + } + } + weakWarnings.clear(); + } + /** * Prints the usage of this tool. */ diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java index 8ede53992d8..522449c366b 100644 --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java @@ -360,8 +360,6 @@ public class Resources extends java.util.ListResourceBundle { {"Enter.alias.name.", "Enter alias name: "}, {".RETURN.if.same.as.for.otherAlias.", "\t(RETURN if same as for <{0}>)"}, - {".PATTERN.printX509Cert", - "Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t SHA1: {5}\n\t SHA256: {6}\nSignature algorithm name: {7}\nSubject Public Key Algorithm: {8} ({9,number,#})\nVersion: {10}"}, {"What.is.your.first.and.last.name.", "What is your first and last name?"}, {"What.is.the.name.of.your.organizational.unit.", @@ -428,16 +426,12 @@ public class Resources extends java.util.ListResourceBundle { {"Please.provide.keysize.for.secret.key.generation", "Please provide -keysize for secret key generation"}, - {"verified.by.s.in.s", "Verified by %s in %s"}, {"warning.not.verified.make.sure.keystore.is.correct", "WARNING: not verified. Make sure -keystore is correct."}, {"Extensions.", "Extensions: "}, {".Empty.value.", "(Empty value)"}, {"Extension.Request.", "Extension Request:"}, - {"PKCS.10.Certificate.Request.Version.1.0.Subject.s.Public.Key.s.format.s.key.", - "PKCS #10 Certificate Request (Version 1.0)\n" + - "Subject: %s\nPublic Key: %s format %s key\n"}, {"Unknown.keyUsage.type.", "Unknown keyUsage type: "}, {"Unknown.extendedkeyUsage.type.", "Unknown extendedkeyUsage type: "}, {"Unknown.AccessDescription.type.", "Unknown AccessDescription type: "}, @@ -446,7 +440,34 @@ public class Resources extends java.util.ListResourceBundle { "This extension cannot be marked as critical. "}, {"Odd.number.of.hex.digits.found.", "Odd number of hex digits found: "}, {"Unknown.extension.type.", "Unknown extension type: "}, - {"command.{0}.is.ambiguous.", "command {0} is ambiguous:"} + {"command.{0}.is.ambiguous.", "command {0} is ambiguous:"}, + + // 8171319: keytool should print out warnings when reading or + // generating cert/cert req using weak algorithms + {"the.certificate.request", "The certificate request"}, + {"the.issuer", "The issuer"}, + {"the.generated.certificate", "The generated certificate"}, + {"the.generated.crl", "The generated CRL"}, + {"the.generated.certificate.request", "The generated certificate request"}, + {"the.certificate", "The certificate"}, + {"the.crl", "The CRL"}, + {"the.tsa.certificate", "The TSA certificate"}, + {"the.input", "The input"}, + {"reply", "Reply"}, + {"one.in.many", "%s #%d of %d"}, + {"alias.in.cacerts", "Issuer <%s> in cacerts"}, + {"alias.in.keystore", "Issuer <%s>"}, + {"with.weak", "%s (weak)"}, + {"key.bit", "%d-bit %s key"}, + {"key.bit.weak", "%d-bit %s key (weak)"}, + {".PATTERN.printX509Cert.with.weak", + "Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t SHA1: {5}\n\t SHA256: {6}\nSignature algorithm name: {7}\nSubject Public Key Algorithm: {8}\nVersion: {9}"}, + {"PKCS.10.with.weak", + "PKCS #10 Certificate Request (Version 1.0)\n" + + "Subject: %s\nFormat: %s\nPublic Key: %s\nSignature algorithm: %s\n"}, + {"verified.by.s.in.s.weak", "Verified by %s in %s with a %s"}, + {"whose.sigalg.risk", "%s uses the %s signature algorithm which is considered a security risk."}, + {"whose.key.risk", "%s uses a %s which is considered a security risk."}, }; diff --git a/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java b/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java deleted file mode 100644 index 23880f7c6aa..00000000000 --- a/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java +++ /dev/null @@ -1,76 +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.security.Timestamp; -import java.security.cert.X509Certificate; -import java.util.Date; - -/** - * This class is a wrapper for keeping state and passing objects between PKIX, - * AlgorithmChecker, and DisabledAlgorithmConstraints. - */ -public class CertConstraintParameters { - // A certificate being passed to check against constraints. - private final X509Certificate cert; - // This is true if the trust anchor in the certificate chain matches a cert - // in AnchorCertificates - private final boolean trustedMatch; - // PKIXParameter date - private final Date pkixDate; - // Timestamp of the signed JAR file - private final Timestamp jarTimestamp; - - public CertConstraintParameters(X509Certificate c, boolean match, - Date pkixdate, Timestamp jarTime) { - cert = c; - trustedMatch = match; - pkixDate = pkixdate; - jarTimestamp = jarTime; - } - - public CertConstraintParameters(X509Certificate c) { - this(c, false, null, null); - } - - // Returns if the trust anchor has a match if anchor checking is enabled. - public boolean isTrustedMatch() { - return trustedMatch; - } - - public X509Certificate getCertificate() { - return cert; - } - - public Date getPKIXParamDate() { - return pkixDate; - } - - public Timestamp getJARTimestamp() { - return jarTimestamp; - } - -} diff --git a/jdk/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java b/jdk/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java new file mode 100644 index 00000000000..83e6d32ff8a --- /dev/null +++ b/jdk/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java @@ -0,0 +1,135 @@ +/* + * 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. 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 sun.security.validator.Validator; + +import java.security.AlgorithmParameters; +import java.security.Key; +import java.security.Timestamp; +import java.security.cert.X509Certificate; +import java.util.Date; + +/** + * This class contains parameters for checking against constraints that extend + * past the publicly available parameters in java.security.AlgorithmConstraints. + + * This is currently on passed between between PKIX, AlgorithmChecker, + * and DisabledAlgorithmConstraints. + */ +public class ConstraintsParameters { + /* + * The below 3 values are used the same as the permit() methods + * published in java.security.AlgorithmConstraints. + */ + // Algorithm string to be checked against constraints + private final String algorithm; + // AlgorithmParameters to the algorithm being checked + private final AlgorithmParameters algParams; + // Public Key being checked against constraints + private final Key publicKey; + + /* + * New values that are checked against constraints that the current public + * API does not support. + */ + // A certificate being passed to check against constraints. + private final X509Certificate cert; + // This is true if the trust anchor in the certificate chain matches a cert + // in AnchorCertificates + private final boolean trustedMatch; + // PKIXParameter date + private final Date pkixDate; + // Timestamp of the signed JAR file + private final Timestamp jarTimestamp; + private final String variant; + + public ConstraintsParameters(X509Certificate c, boolean match, + Date pkixdate, Timestamp jarTime, String variant) { + cert = c; + trustedMatch = match; + pkixDate = pkixdate; + jarTimestamp = jarTime; + this.variant = (variant == null ? Validator.VAR_GENERIC : variant); + algorithm = null; + algParams = null; + publicKey = null; + } + + public ConstraintsParameters(String algorithm, AlgorithmParameters params, + Key key, String variant) { + this.algorithm = algorithm; + algParams = params; + this.publicKey = key; + cert = null; + trustedMatch = false; + pkixDate = null; + jarTimestamp = null; + this.variant = (variant == null ? Validator.VAR_GENERIC : variant); + } + + + public ConstraintsParameters(X509Certificate c) { + this(c, false, null, null, + Validator.VAR_GENERIC); + } + + public ConstraintsParameters(Timestamp jarTime) { + this(null, false, null, jarTime, Validator.VAR_GENERIC); + } + + public String getAlgorithm() { + return algorithm; + } + + public AlgorithmParameters getAlgParams() { + return algParams; + } + + public Key getPublicKey() { + return publicKey; + } + // Returns if the trust anchor has a match if anchor checking is enabled. + public boolean isTrustedMatch() { + return trustedMatch; + } + + public X509Certificate getCertificate() { + return cert; + } + + public Date getPKIXParamDate() { + return pkixDate; + } + + public Timestamp getJARTimestamp() { + return jarTimestamp; + } + + public String getVariant() { + return variant; + } +} 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 1e5600214bc..54eade39044 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, 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 @@ -44,16 +44,26 @@ import sun.util.calendar.CalendarSystem; */ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { - DerInputBuffer(byte[] buf) { super(buf); } + boolean allowBER = true; - DerInputBuffer(byte[] buf, int offset, int len) { + // used by sun/security/util/DerInputBuffer/DerInputBufferEqualsHashCode.java + DerInputBuffer(byte[] buf) { + this(buf, true); + } + + DerInputBuffer(byte[] buf, boolean allowBER) { + super(buf); + this.allowBER = allowBER; + } + + DerInputBuffer(byte[] buf, int offset, int len, boolean allowBER) { super(buf, offset, len); + this.allowBER = allowBER; } DerInputBuffer dup() { try { DerInputBuffer retval = (DerInputBuffer)clone(); - retval.mark(Integer.MAX_VALUE); return retval; } catch (CloneNotSupportedException e) { @@ -147,8 +157,8 @@ 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)) { + // BER allows leading 0s but DER does not + if (!allowBER && (len >= 2 && (bytes[0] == 0) && (bytes[1] >= 0))) { throw new IOException("Invalid encoding: redundant leading 0s"); } 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 94c9085a7bc..d8498c79625 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, 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 @@ -80,6 +80,25 @@ public class DerInputStream { init(data, 0, data.length, true); } + /** + * Create a DER input stream from part of a data buffer with + * additional arg to control whether DER checks are enforced. + * 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 allowBER whether to allow constructed indefinite-length + * encoding as well as tolerate leading 0s + */ + public DerInputStream(byte[] data, int offset, int len, + boolean allowBER) throws IOException { + init(data, offset, len, allowBER); + } + /** * Create a DER input stream from part of a data buffer. * The buffer is not copied, it is shared. Accordingly, the @@ -95,47 +114,27 @@ public class DerInputStream { 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, - boolean allowIndefiniteLength) throws IOException { + private void init(byte[] data, int offset, int len, boolean allowBER) 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])) { - if (!allowIndefiniteLength) { + if (!allowBER) { 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)); + buffer = new DerInputBuffer(derIn.convert(inData), allowBER); } - } else - buffer = new DerInputBuffer(data, offset, len); + } else { + buffer = new DerInputBuffer(data, offset, len, allowBER); + } buffer.mark(Integer.MAX_VALUE); } @@ -156,7 +155,7 @@ public class DerInputStream { */ public DerInputStream subStream(int len, boolean do_skip) throws IOException { - DerInputBuffer newbuf = buffer.dup(); + DerInputBuffer newbuf = buffer.dup(); newbuf.truncate(len); if (do_skip) { @@ -399,7 +398,8 @@ public class DerInputStream { dis.readFully(indefData, offset, readLen); dis.close(); DerIndefLenConverter derIn = new DerIndefLenConverter(); - buffer = new DerInputBuffer(derIn.convert(indefData)); + buffer = new DerInputBuffer(derIn.convert(indefData), buffer.allowBER); + if (tag != buffer.read()) throw new IOException("Indefinite length encoding" + " not supported"); @@ -427,7 +427,7 @@ public class DerInputStream { DerValue value; do { - value = new DerValue(newstr.buffer); + value = new DerValue(newstr.buffer, buffer.allowBER); vec.addElement(value); } while (newstr.available() > 0); 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 b47064abce9..4f48cdce7be 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, 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 @@ -225,6 +225,16 @@ public class DerValue { data = init(stringTag, value); } + // Creates a DerValue from a tag and some DER-encoded data w/ additional + // arg to control whether DER checks are enforced. + DerValue(byte tag, byte[] data, boolean allowBER) { + this.tag = tag; + buffer = new DerInputBuffer(data.clone(), allowBER); + length = data.length; + this.data = new DerInputStream(buffer); + this.data.mark(Integer.MAX_VALUE); + } + /** * Creates a DerValue from a tag and some DER-encoded data. * @@ -232,20 +242,16 @@ public class DerValue { * @param data the DER-encoded data */ public DerValue(byte tag, byte[] data) { - this.tag = tag; - buffer = new DerInputBuffer(data.clone()); - length = data.length; - this.data = new DerInputStream(buffer); - this.data.mark(Integer.MAX_VALUE); + this(tag, data, true); } /* * package private */ DerValue(DerInputBuffer in) throws IOException { + // XXX must also parse BER-encoded constructed // values such as sequences, sets... - tag = (byte)in.read(); byte lenByte = (byte)in.read(); length = DerInputStream.getLength(lenByte, in); @@ -260,7 +266,7 @@ public class DerValue { dis.readFully(indefData, offset, readLen); dis.close(); DerIndefLenConverter derIn = new DerIndefLenConverter(); - inbuf = new DerInputBuffer(derIn.convert(indefData)); + inbuf = new DerInputBuffer(derIn.convert(indefData), in.allowBER); if (tag != inbuf.read()) throw new IOException ("Indefinite length encoding not supported"); @@ -282,6 +288,12 @@ public class DerValue { } } + // Get an ASN.1/DER encoded datum from a buffer w/ additional + // arg to control whether DER checks are enforced. + DerValue(byte[] buf, boolean allowBER) throws IOException { + data = init(true, new ByteArrayInputStream(buf), allowBER); + } + /** * Get an ASN.1/DER encoded datum from a buffer. The * entire buffer must hold exactly one datum, including @@ -290,7 +302,14 @@ public class DerValue { * @param buf buffer holding a single DER-encoded datum. */ public DerValue(byte[] buf) throws IOException { - data = init(true, new ByteArrayInputStream(buf)); + this(buf, true); + } + + // Get an ASN.1/DER encoded datum from part of a buffer w/ additional + // arg to control whether DER checks are enforced. + DerValue(byte[] buf, int offset, int len, boolean allowBER) + throws IOException { + data = init(true, new ByteArrayInputStream(buf, offset, len), allowBER); } /** @@ -303,7 +322,13 @@ public class DerValue { * @param len how many bytes are in the encoded datum */ public DerValue(byte[] buf, int offset, int len) throws IOException { - data = init(true, new ByteArrayInputStream(buf, offset, len)); + this(buf, offset, len, true); + } + + // Get an ASN1/DER encoded datum from an input stream w/ additional + // arg to control whether DER checks are enforced. + DerValue(InputStream in, boolean allowBER) throws IOException { + data = init(false, in, allowBER); } /** @@ -316,10 +341,11 @@ public class DerValue { * which may be followed by additional data */ public DerValue(InputStream in) throws IOException { - data = init(false, in); + this(in, true); } - private DerInputStream init(byte stringTag, String value) throws IOException { + private DerInputStream init(byte stringTag, String value) + throws IOException { String enc = null; tag = stringTag; @@ -347,7 +373,7 @@ public class DerValue { byte[] buf = value.getBytes(enc); length = buf.length; - buffer = new DerInputBuffer(buf); + buffer = new DerInputBuffer(buf, true); DerInputStream result = new DerInputStream(buffer); result.mark(Integer.MAX_VALUE); return result; @@ -356,8 +382,8 @@ public class DerValue { /* * helper routine */ - private DerInputStream init(boolean fullyBuffered, InputStream in) - throws IOException { + private DerInputStream init(boolean fullyBuffered, InputStream in, + boolean allowBER) throws IOException { tag = (byte)in.read(); byte lenByte = (byte)in.read(); @@ -384,7 +410,7 @@ public class DerValue { byte[] bytes = IOUtils.readFully(in, length, true); - buffer = new DerInputBuffer(bytes); + buffer = new DerInputBuffer(bytes, allowBER); return new DerInputStream(buffer); } @@ -479,7 +505,8 @@ public class DerValue { if (buffer.read(bytes) != length) throw new IOException("short read on DerValue buffer"); if (isConstructed()) { - DerInputStream in = new DerInputStream(bytes); + DerInputStream in = new DerInputStream(bytes, 0, bytes.length, + buffer.allowBER); bytes = null; while (in.available() != 0) { bytes = append(bytes, in.getOctetString()); diff --git a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java index 73914fe30ae..9051b392970 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java +++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, 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 @@ -25,6 +25,10 @@ package sun.security.util; +import sun.security.validator.Validator; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; import java.security.CryptoPrimitive; import java.security.AlgorithmParameters; import java.security.Key; @@ -32,10 +36,12 @@ import java.security.cert.CertPathValidatorException; import java.security.cert.CertPathValidatorException.BasicReason; import java.security.cert.X509Certificate; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -100,12 +106,6 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { @Override public final boolean permits(Set primitives, String algorithm, AlgorithmParameters parameters) { - - if (primitives == null || primitives.isEmpty()) { - throw new IllegalArgumentException( - "No cryptographic primitive specified"); - } - return checkAlgorithm(disabledAlgorithms, algorithm, decomposer); } @@ -133,6 +133,18 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { return checkConstraints(primitives, algorithm, key, parameters); } + public final void permits(ConstraintsParameters cp) + throws CertPathValidatorException { + permits(cp.getAlgorithm(), cp); + } + + public final void permits(String algorithm, Key key, + AlgorithmParameters params, String variant) + throws CertPathValidatorException { + permits(algorithm, new ConstraintsParameters(algorithm, params, key, + (variant == null) ? Validator.VAR_GENERIC : variant)); + } + /* * Check if a x509Certificate object is permitted. Check if all * algorithms are allowed, certificate constraints, and the @@ -140,18 +152,10 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { * * Uses new style permit() which throws exceptions. */ - public final void permits(Set primitives, - CertConstraintParameters cp) throws CertPathValidatorException { - checkConstraints(primitives, cp); - } - /* - * Check if Certificate object is within the constraints. - * Uses new style permit() which throws exceptions. - */ - public final void permits(Set primitives, - X509Certificate cert) throws CertPathValidatorException { - checkConstraints(primitives, new CertConstraintParameters(cert)); + public final void permits(String algorithm, ConstraintsParameters cp) + throws CertPathValidatorException { + algorithmConstraints.permits(algorithm, cp); } // Check if a string is contained inside the property @@ -174,7 +178,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { throw new IllegalArgumentException("The key cannot be null"); } - // check the signature algorithm + // check the signature algorithm with parameters if (algorithm != null && algorithm.length() != 0) { if (!permits(primitives, algorithm, parameters)) { return false; @@ -190,36 +194,6 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { return algorithmConstraints.permits(key); } - /* - * Check algorithm constraints with Certificate - * Uses new style permit() which throws exceptions. - */ - private void checkConstraints(Set primitives, - CertConstraintParameters cp) throws CertPathValidatorException { - - X509Certificate cert = cp.getCertificate(); - String algorithm = cert.getSigAlgName(); - - // Check signature algorithm is not disabled - if (!permits(primitives, algorithm, null)) { - throw new CertPathValidatorException( - "Algorithm constraints check failed on disabled "+ - "signature algorithm: " + algorithm, - null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); - } - - // Check key algorithm is not disabled - if (!permits(primitives, cert.getPublicKey().getAlgorithm(), null)) { - throw new CertPathValidatorException( - "Algorithm constraints check failed on disabled "+ - "public key algorithm: " + algorithm, - null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); - } - - // Check the certificate and key constraints - algorithmConstraints.permits(cp); - - } /** * Key and Certificate Constraints @@ -234,13 +208,13 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { * 'true' means the operation is allowed. * 'false' means it failed the constraints and is disallowed. * - * When passing CertConstraintParameters through permit(), an exception + * When passing ConstraintsParameters through permit(), an exception * will be thrown on a failure to better identify why the operation was * disallowed. */ private static class Constraints { - private Map> constraintsMap = new HashMap<>(); + private Map> constraintsMap = new HashMap<>(); private static class Holder { private static final Pattern DENY_AFTER_PATTERN = Pattern.compile( @@ -260,23 +234,22 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { // Check if constraint is a complete disabling of an // algorithm or has conditions. - String algorithm; - String policy; int space = constraintEntry.indexOf(' '); - if (space > 0) { - algorithm = AlgorithmDecomposer.hashName( - constraintEntry.substring(0, space). - toUpperCase(Locale.ENGLISH)); - policy = constraintEntry.substring(space + 1); - } else { - algorithm = constraintEntry.toUpperCase(Locale.ENGLISH); - if (!constraintsMap.containsKey(algorithm)) { - constraintsMap.putIfAbsent(algorithm, - new HashSet<>()); - } + String algorithm = AlgorithmDecomposer.hashName( + ((space > 0 ? constraintEntry.substring(0, space) : + constraintEntry). + toUpperCase(Locale.ENGLISH))); + List constraintList = + constraintsMap.getOrDefault(algorithm, + new ArrayList<>(1)); + constraintsMap.putIfAbsent(algorithm, constraintList); + if (space <= 0) { + constraintList.add(new DisabledConstraint(algorithm)); continue; } + String policy = constraintEntry.substring(space + 1); + // Convert constraint conditions into Constraint classes Constraint c, lastConstraint = null; // Allow only one jdkCA entry per constraint entry @@ -315,7 +288,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { c = new jdkCAConstraint(algorithm); jdkCALimit = true; - } else if(entry.startsWith("denyAfter") && + } else if (entry.startsWith("denyAfter") && (matcher = Holder.DENY_AFTER_PATTERN.matcher(entry)) .matches()) { if (debug != null) { @@ -332,6 +305,12 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { c = new DenyAfterConstraint(algorithm, year, month, day); denyAfterLimit = true; + } else if (entry.startsWith("usage")) { + String s[] = (entry.substring(5)).trim().split(" "); + c = new UsageConstraint(algorithm, s); + if (debug != null) { + debug.println("Constraints usage length is " + s.length); + } } else { throw new IllegalArgumentException("Error in security" + " property. Constraint unknown: " + entry); @@ -340,11 +319,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { // Link multiple conditions for a single constraint // into a linked list. if (lastConstraint == null) { - if (!constraintsMap.containsKey(algorithm)) { - constraintsMap.putIfAbsent(algorithm, - new HashSet<>()); - } - constraintsMap.get(algorithm).add(c); + constraintList.add(c); } else { lastConstraint.nextConstraint = c; } @@ -354,17 +329,17 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { } // Get applicable constraints based off the signature algorithm - private Set getConstraints(String algorithm) { + private List getConstraints(String algorithm) { return constraintsMap.get(algorithm); } // Check if KeySizeConstraints permit the specified key public boolean permits(Key key) { - Set set = getConstraints(key.getAlgorithm()); - if (set == null) { + List list = getConstraints(key.getAlgorithm()); + if (list == null) { return true; } - for (Constraint constraint : set) { + for (Constraint constraint : list) { if (!constraint.permits(key)) { if (debug != null) { debug.println("keySizeConstraint: failed key " + @@ -377,31 +352,35 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { } // Check if constraints permit this cert. - public void permits(CertConstraintParameters cp) + public void permits(String algorithm, ConstraintsParameters cp) throws CertPathValidatorException { X509Certificate cert = cp.getCertificate(); if (debug != null) { - debug.println("Constraints.permits(): " + cert.getSigAlgName()); + debug.println("Constraints.permits(): " + algorithm + + " Variant: " + cp.getVariant()); } // Get all signature algorithms to check for constraints - Set algorithms = - AlgorithmDecomposer.decomposeOneHash(cert.getSigAlgName()); - if (algorithms == null || algorithms.isEmpty()) { - return; + Set algorithms = new HashSet<>(); + if (algorithm != null) { + algorithms.addAll(AlgorithmDecomposer.decomposeOneHash(algorithm)); } - // Attempt to add the public key algorithm to the set - algorithms.add(cert.getPublicKey().getAlgorithm()); - + // Attempt to add the public key algorithm if cert provided + if (cert != null) { + algorithms.add(cert.getPublicKey().getAlgorithm()); + } + if (cp.getPublicKey() != null) { + algorithms.add(cp.getPublicKey().getAlgorithm()); + } // Check all applicable constraints - for (String algorithm : algorithms) { - Set set = getConstraints(algorithm); - if (set == null) { + for (String alg : algorithms) { + List list = getConstraints(alg); + if (list == null) { continue; } - for (Constraint constraint : set) { + for (Constraint constraint : list) { constraint.permits(cp); } } @@ -467,17 +446,17 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { /** * Check if an algorithm constraint is permitted with a given - * CertConstraintParameters. + * ConstraintsParameters. * * If the check inside of {@code permits()} fails, it must call - * {@code next()} with the same {@code CertConstraintParameters} + * {@code next()} with the same {@code ConstraintsParameters} * parameter passed if multiple constraints need to be checked. * * @param cp CertConstraintParameter containing certificate info * @throws CertPathValidatorException if constraint disallows. * */ - public abstract void permits(CertConstraintParameters cp) + public abstract void permits(ConstraintsParameters cp) throws CertPathValidatorException; /** @@ -491,12 +470,12 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { * were disallowed, the last constraint will throw * {@code CertPathValidatorException}. * - * @param cp CertConstraintParameters + * @param cp ConstraintsParameters * @return 'true' if constraint allows the operation, 'false' if * we are at the end of the constraint list or, * {@code nextConstraint} is null. */ - boolean next(CertConstraintParameters cp) + boolean next(ConstraintsParameters cp) throws CertPathValidatorException { if (nextConstraint != null) { nextConstraint.permits(cp); @@ -525,6 +504,14 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { } return false; } + + String extendedMsg(ConstraintsParameters cp) { + return (cp.getCertificate() == null ? "." : + " used with certificate: " + + cp.getCertificate().getSubjectX500Principal() + + (cp.getVariant() != Validator.VAR_GENERIC ? + ". Usage was " + cp.getVariant() : ".")); + } } /* @@ -537,11 +524,11 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { } /* - * Check if CertConstraintParameters has a trusted match, if it does + * Check if ConstraintsParameters has a trusted match, if it does * call next() for any following constraints. If it does not, exit * as this constraint(s) does not restrict the operation. */ - public void permits(CertConstraintParameters cp) + public void permits(ConstraintsParameters cp) throws CertPathValidatorException { if (debug != null) { debug.println("jdkCAConstraints.permits(): " + algorithm); @@ -554,8 +541,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { } throw new CertPathValidatorException( "Algorithm constraints check failed on certificate " + - "anchor limits. " + algorithm + " used with " + - cp.getCertificate().getSubjectX500Principal(), + "anchor limits. " + algorithm + extendedMsg(cp), null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); } } @@ -615,7 +601,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { * constraints. Throw an exception if this is the last constraint. */ @Override - public void permits(CertConstraintParameters cp) + public void permits(ConstraintsParameters cp) throws CertPathValidatorException { Date currentDate; String errmsg; @@ -628,7 +614,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { errmsg = "PKIXParameter date: "; } else { currentDate = new Date(); - errmsg = "Certificate date: "; + errmsg = "Current date: "; } if (!denyAfterDate.after(currentDate)) { @@ -637,9 +623,9 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { } throw new CertPathValidatorException( "denyAfter constraint check failed: " + algorithm + - " used with Constraint date: " + - dateFormat.format(denyAfterDate) + "; " - + errmsg + dateFormat.format(currentDate), + " used with Constraint date: " + + dateFormat.format(denyAfterDate) + "; " + errmsg + + dateFormat.format(currentDate) + extendedMsg(cp), null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); } } @@ -660,6 +646,54 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { } } + /* + * The usage constraint is for the "usage" keyword. It checks against the + * variant value in ConstraintsParameters. + */ + private static class UsageConstraint extends Constraint { + String[] usages; + + UsageConstraint(String algorithm, String[] usages) { + this.algorithm = algorithm; + this.usages = usages; + } + + public void permits(ConstraintsParameters cp) + throws CertPathValidatorException { + for (String usage : usages) { + + String v = null; + if (usage.compareToIgnoreCase("TLSServer") == 0) { + v = Validator.VAR_TLS_SERVER; + } else if (usage.compareToIgnoreCase("TLSClient") == 0) { + v = Validator.VAR_TLS_CLIENT; + } else if (usage.compareToIgnoreCase("SignedJAR") == 0) { + v = Validator.VAR_PLUGIN_CODE_SIGNING; + } + + if (debug != null) { + debug.println("Checking if usage constraint \"" + v + + "\" matches \"" + cp.getVariant() + "\""); + // Because usage checking can come from many places + // a stack trace is very helpful. + ByteArrayOutputStream ba = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(ba); + (new Exception()).printStackTrace(ps); + debug.println(ba.toString()); + } + if (cp.getVariant().compareTo(v) == 0) { + if (next(cp)) { + return; + } + throw new CertPathValidatorException("Usage constraint " + + usage + " check failed: " + algorithm + + extendedMsg(cp), + null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); + } + } + } + } + /* * This class contains constraints dealing with the key size * support limits per algorithm. e.g. "keySize <= 1024" @@ -713,17 +747,22 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { * constraint Any permitted constraint will exit the linked list * to allow the operation. */ - public void permits(CertConstraintParameters cp) + public void permits(ConstraintsParameters cp) throws CertPathValidatorException { - if (!permitsImpl(cp.getCertificate().getPublicKey())) { + Key key = null; + if (cp.getPublicKey() != null) { + key = cp.getPublicKey(); + } else if (cp.getCertificate() != null) { + key = cp.getCertificate().getPublicKey(); + } + if (key != null && !permitsImpl(key)) { if (nextConstraint != null) { nextConstraint.permits(cp); return; } throw new CertPathValidatorException( "Algorithm constraints check failed on keysize limits. " - + algorithm + " " + size + "bit key used with " - + cp.getCertificate().getSubjectX500Principal(), + + algorithm + " " + size + "bit key" + extendedMsg(cp), null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); } } @@ -762,5 +801,26 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { return true; } } + + /* + * This constraint is used for the complete disabling of the algorithm. + */ + private static class DisabledConstraint extends Constraint { + DisabledConstraint(String algo) { + algorithm = algo; + } + + public void permits(ConstraintsParameters cp) + throws CertPathValidatorException { + throw new CertPathValidatorException( + "Algorithm constraints check failed on disabled " + + "algorithm: " + algorithm + extendedMsg(cp), + null, null, -1, BasicReason.ALGORITHM_CONSTRAINED); + } + + public boolean permits(Key key) { + return false; + } + } } diff --git a/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java b/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java index afa0fe0bbcf..145dff297f3 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java +++ b/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java @@ -28,17 +28,15 @@ package sun.security.util; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.*; - import java.security.Principal; import java.security.cert.*; - +import java.util.*; import javax.security.auth.x500.X500Principal; -import sun.security.ssl.ClientKeyExchangeService; -import sun.security.x509.X500Name; - import sun.net.util.IPAddressUtil; +import sun.security.ssl.ClientKeyExchangeService; +import sun.security.ssl.Debug; +import sun.security.x509.X500Name; /** * Class to check hostnames against the names specified in a certificate as @@ -61,6 +59,8 @@ public class HostnameChecker { private static final int ALTNAME_DNS = 2; private static final int ALTNAME_IP = 7; + private static final Debug debug = Debug.getInstance("ssl"); + // the algorithm to follow to perform the check. Currently unused. private final byte checkType; @@ -84,18 +84,27 @@ public class HostnameChecker { /** * Perform the check. * - * @exception CertificateException if the name does not match any of - * the names specified in the certificate + * @param expectedName the expected host name or ip address + * @param cert the certificate to check against + * @param chainsToPublicCA true if the certificate chains to a public + * root CA (as pre-installed in the cacerts file) + * @throws CertificateException if the name does not match any of + * the names specified in the certificate */ - public void match(String expectedName, X509Certificate cert) - throws CertificateException { + public void match(String expectedName, X509Certificate cert, + boolean chainsToPublicCA) throws CertificateException { if (isIpAddress(expectedName)) { matchIP(expectedName, cert); } else { - matchDNS(expectedName, cert); + matchDNS(expectedName, cert, chainsToPublicCA); } } + public void match(String expectedName, X509Certificate cert) + throws CertificateException { + match(expectedName, cert, false); + } + /** * Perform the check for Kerberos. */ @@ -185,20 +194,21 @@ public class HostnameChecker { * Certification Authorities are encouraged to use the dNSName instead. * * Matching is performed using the matching rules specified by - * [RFC2459]. If more than one identity of a given type is present in + * [RFC5280]. If more than one identity of a given type is present in * the certificate (e.g., more than one dNSName name, a match in any one * of the set is considered acceptable.) */ - private void matchDNS(String expectedName, X509Certificate cert) + private void matchDNS(String expectedName, X509Certificate cert, + boolean chainsToPublicCA) throws CertificateException { Collection> subjAltNames = cert.getSubjectAlternativeNames(); if (subjAltNames != null) { boolean foundDNS = false; - for ( List next : subjAltNames) { + for (List next : subjAltNames) { if (((Integer)next.get(0)).intValue() == ALTNAME_DNS) { foundDNS = true; String dnsName = (String)next.get(1); - if (isMatched(expectedName, dnsName)) { + if (isMatched(expectedName, dnsName, chainsToPublicCA)) { return; } } @@ -215,7 +225,8 @@ public class HostnameChecker { (X500Name.commonName_oid); if (derValue != null) { try { - if (isMatched(expectedName, derValue.getAsString())) { + if (isMatched(expectedName, derValue.getAsString(), + chainsToPublicCA)) { return; } } catch (IOException e) { @@ -261,7 +272,11 @@ public class HostnameChecker { * The template parameter * may contain the wildcard character * */ - private boolean isMatched(String name, String template) { + private boolean isMatched(String name, String template, + boolean chainsToPublicCA) { + if (hasIllegalWildcard(name, template, chainsToPublicCA)) { + return false; + } if (checkType == TYPE_TLS) { return matchAllWildcards(name, template); } else if (checkType == TYPE_LDAP) { @@ -271,6 +286,61 @@ public class HostnameChecker { } } + /** + * Returns true if the template contains an illegal wildcard character. + */ + private static boolean hasIllegalWildcard(String domain, String template, + boolean chainsToPublicCA) { + // not ok if it is a single wildcard character or "*." + if (template.equals("*") || template.equals("*.")) { + if (debug != null) { + debug.println("Certificate domain name has illegal single " + + "wildcard character: " + template); + } + return true; + } + + int lastWildcardIndex = template.lastIndexOf("*"); + + // ok if it has no wildcard character + if (lastWildcardIndex == -1) { + return false; + } + + String afterWildcard = template.substring(lastWildcardIndex); + int firstDotIndex = afterWildcard.indexOf("."); + + // not ok if there is no dot after wildcard (ex: "*com") + if (firstDotIndex == -1) { + if (debug != null) { + debug.println("Certificate domain name has illegal wildcard, " + + "no dot after wildcard character: " + template); + } + return true; + } + + // If the wildcarded domain is a top-level domain under which names + // can be registered, then a wildcard is not allowed. + + if (!chainsToPublicCA) { + return false; // skip check for non-public certificates + } + Optional rd = RegisteredDomain.from(domain) + .filter(d -> d.type() == RegisteredDomain.Type.ICANN); + + if (rd.isPresent()) { + String wDomain = afterWildcard.substring(firstDotIndex + 1); + if (rd.get().publicSuffix().equalsIgnoreCase(wDomain)) { + if (debug != null) { + debug.println("Certificate domain name has illegal " + + "wildcard for public suffix: " + template); + } + return true; + } + } + + return false; + } /** * Returns true if name matches against template.

              @@ -317,9 +387,9 @@ public class HostnameChecker { name = name.toLowerCase(Locale.ENGLISH); template = template.toLowerCase(Locale.ENGLISH); - // Retreive leftmost component - int templateIdx = template.indexOf('.'); - int nameIdx = name.indexOf('.'); + // Retrieve leftmost component + int templateIdx = template.indexOf("."); + int nameIdx = name.indexOf("."); if (templateIdx == -1) templateIdx = template.length(); @@ -344,7 +414,7 @@ public class HostnameChecker { */ private static boolean matchWildCards(String name, String template) { - int wildcardIdx = template.indexOf('*'); + int wildcardIdx = template.indexOf("*"); if (wildcardIdx == -1) return name.equals(template); @@ -367,7 +437,7 @@ public class HostnameChecker { // update the match scope name = name.substring(beforeStartIdx + beforeWildcard.length()); - wildcardIdx = afterWildcard.indexOf('*'); + wildcardIdx = afterWildcard.indexOf("*"); } return name.endsWith(afterWildcard); } diff --git a/jdk/src/java.base/share/classes/sun/security/util/RegisteredDomain.java b/jdk/src/java.base/share/classes/sun/security/util/RegisteredDomain.java new file mode 100644 index 00000000000..ec601d51db4 --- /dev/null +++ b/jdk/src/java.base/share/classes/sun/security/util/RegisteredDomain.java @@ -0,0 +1,93 @@ +/* + * 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 sun.security.util; + +import java.util.Optional; + +/** + * A domain that is registered under a "public suffix". The public suffix is + * a top-level domain under which names can be registered. For example, + * "com" and "co.uk" are public suffixes, and "example.com" and "example.co.uk" + * are registered domains. + *

              + * The primary purpose of this class is to determine if domains are safe to + * use in various use-cases. + */ +public interface RegisteredDomain { + + public enum Type { + /** + * An ICANN registered domain. + */ + ICANN, + /** + * A private registered domain. + */ + PRIVATE + } + + /** + * Returns the name of the registered domain. + * + * @return the name of the registered domain + */ + String name(); + + /** + * Returns the type of the registered domain. + * + * @return the type of the registered domain + */ + Type type(); + + /** + * Returns the public suffix of the registered domain. + * + * @return the public suffix of the registered domain + */ + String publicSuffix(); + + /** + * Returns an {@code Optional} representing the + * registered part of the specified domain. + * + * {@implNote} + * The default implementation is based on the legacy + * {@code sun.net.RegisteredDomain} class which is no longer maintained. + * It should be updated or replaced with an appropriate implementation. + * + * @param domain the domain name + * @return an {@code Optional}; the {@code Optional} is + * empty if the domain is unknown or not registerable + * @throws NullPointerException if domain is null + */ + public static Optional from(String domain) { + if (domain == null) { + throw new NullPointerException(); + } + return Optional.ofNullable(sun.net.RegisteredDomain.registeredDomain(domain)); + } +} diff --git a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java index f8022c5ca94..0663f0573ae 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.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 @@ -28,25 +28,23 @@ package sun.security.util; import java.io.ByteArrayInputStream; import java.io.IOException; import java.security.CodeSigner; -import java.security.CryptoPrimitive; +import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; +import java.security.Timestamp; import java.security.cert.CertPath; import java.security.cert.X509Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.util.ArrayList; import java.util.Base64; -import java.util.Collections; -import java.util.EnumSet; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.jar.Attributes; import java.util.jar.JarException; import java.util.jar.JarFile; @@ -61,9 +59,6 @@ public class SignatureFileVerifier { /* Are we debugging ? */ private static final Debug debug = Debug.getInstance("jar"); - private static final Set DIGEST_PRIMITIVE_SET = - Collections.unmodifiableSet(EnumSet.of(CryptoPrimitive.MESSAGE_DIGEST)); - private static final DisabledAlgorithmConstraints JAR_DISABLED_CHECK = new DisabledAlgorithmConstraints( DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS); @@ -97,6 +92,14 @@ public class SignatureFileVerifier { /* for generating certpath objects */ private CertificateFactory certificateFactory = null; + /** Algorithms that have been checked if they are weak. */ + private Map permittedAlgs= new HashMap<>(); + + /** TSA timestamp of signed jar. The newest timestamp is used. If there + * was no TSA timestamp used when signed, current time is used ("null"). + */ + private Timestamp timestamp = null; + /** * Create the named SignatureFileVerifier. * @@ -222,15 +225,8 @@ public class SignatureFileVerifier { /** get digest from cache */ - private MessageDigest getDigest(String algorithm) throws SignatureException { - // check that algorithm is not restricted - if (!JAR_DISABLED_CHECK.permits(DIGEST_PRIMITIVE_SET, algorithm, null)) { - SignatureException e = - new SignatureException("SignatureFile check failed. " + - "Disabled algorithm used: " + algorithm); - throw e; - } - + private MessageDigest getDigest(String algorithm) + throws SignatureException { if (createdDigests == null) createdDigests = new HashMap<>(); @@ -302,6 +298,27 @@ public class SignatureFileVerifier { if (newSigners == null) return; + /* + * Look for the latest timestamp in the signature block. If an entry + * has no timestamp, use current time (aka null). + */ + for (CodeSigner s: newSigners) { + if (debug != null) { + debug.println("Gathering timestamp for: " + s.toString()); + } + if (s.getTimestamp() == null) { + timestamp = null; + break; + } else if (timestamp == null) { + timestamp = s.getTimestamp(); + } else { + if (timestamp.getTimestamp().before( + s.getTimestamp().getTimestamp())) { + timestamp = s.getTimestamp(); + } + } + } + Iterator> entries = sf.getEntries().entrySet().iterator(); @@ -344,6 +361,68 @@ public class SignatureFileVerifier { updateSigners(newSigners, signers, JarFile.MANIFEST_NAME); } + /** + * Check if algorithm is permitted using the permittedAlgs Map. + * If the algorithm is not in the map, check against disabled algorithms and + * store the result. If the algorithm is in the map use that result. + * False is returned for weak algorithm, true for good algorithms. + */ + boolean permittedCheck(String key, String algorithm) { + Boolean permitted = permittedAlgs.get(algorithm); + if (permitted == null) { + try { + JAR_DISABLED_CHECK.permits(algorithm, + new ConstraintsParameters(timestamp)); + } catch(GeneralSecurityException e) { + permittedAlgs.put(algorithm, Boolean.FALSE); + permittedAlgs.put(key.toUpperCase(), Boolean.FALSE); + if (debug != null) { + if (e.getMessage() != null) { + debug.println(key + ": " + e.getMessage()); + } else { + debug.println(key + ": " + algorithm + + " was disabled, no exception msg given."); + e.printStackTrace(); + } + } + return false; + } + + permittedAlgs.put(algorithm, Boolean.TRUE); + return true; + } + + // Algorithm has already been checked, return the value from map. + return permitted.booleanValue(); + } + + /** + * With a given header (*-DIGEST*), return a string that lists all the + * algorithms associated with the header. + * If there are none, return "Unknown Algorithm". + */ + String getWeakAlgorithms(String header) { + String w = ""; + try { + for (String key : permittedAlgs.keySet()) { + if (key.endsWith(header)) { + w += key.substring(0, key.length() - header.length()) + " "; + } + } + } catch (RuntimeException e) { + w = "Unknown Algorithm(s). Error processing " + header + ". " + + e.getMessage(); + } + + // This means we have an error in finding weak algorithms, run in + // debug mode to see permittedAlgs map's values. + if (w.length() == 0) { + return "Unknown Algorithm(s)"; + } + + return w; + } + /** * See if the whole manifest was signed. */ @@ -354,6 +433,10 @@ public class SignatureFileVerifier { { Attributes mattr = sf.getMainAttributes(); boolean manifestSigned = false; + // If only weak algorithms are used. + boolean weakAlgs = true; + // If a "*-DIGEST-MANIFEST" entry is found. + boolean validEntry = false; // go through all the attributes and process *-Digest-Manifest entries for (Map.Entry se : mattr.entrySet()) { @@ -363,6 +446,16 @@ public class SignatureFileVerifier { if (key.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST-MANIFEST")) { // 16 is length of "-Digest-Manifest" String algorithm = key.substring(0, key.length()-16); + validEntry = true; + + // Check if this algorithm is permitted, skip if false. + if (!permittedCheck(key, algorithm)) { + continue; + } + + // A non-weak algorithm was used, any weak algorithms found do + // not need to be reported. + weakAlgs = false; manifestDigests.add(key); manifestDigests.add(se.getValue()); @@ -373,15 +466,14 @@ public class SignatureFileVerifier { Base64.getMimeDecoder().decode((String)se.getValue()); if (debug != null) { - debug.println("Signature File: Manifest digest " + - digest.getAlgorithm()); - debug.println( " sigfile " + toHex(expectedHash)); - debug.println( " computed " + toHex(computedHash)); - debug.println(); + debug.println("Signature File: Manifest digest " + + algorithm); + debug.println( " sigfile " + toHex(expectedHash)); + debug.println( " computed " + toHex(computedHash)); + debug.println(); } - if (MessageDigest.isEqual(computedHash, - expectedHash)) { + if (MessageDigest.isEqual(computedHash, expectedHash)) { manifestSigned = true; } else { //XXX: we will continue and verify each section @@ -389,15 +481,33 @@ public class SignatureFileVerifier { } } } + + if (debug != null) { + debug.println("PermittedAlgs mapping: "); + for (String key : permittedAlgs.keySet()) { + debug.println(key + " : " + + permittedAlgs.get(key).toString()); + } + } + + // If there were only weak algorithms entries used, throw an exception. + if (validEntry && weakAlgs) { + throw new SignatureException("Manifest hash check failed " + + "(DIGEST-MANIFEST). Disabled algorithm(s) used: " + + getWeakAlgorithms("-DIGEST-MANIFEST")); + } return manifestSigned; } - private boolean verifyManifestMainAttrs(Manifest sf, - ManifestDigester md) + private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md) throws IOException, SignatureException { Attributes mattr = sf.getMainAttributes(); boolean attrsVerified = true; + // If only weak algorithms are used. + boolean weakAlgs = true; + // If a ATTR_DIGEST entry is found. + boolean validEntry = false; // go through all the attributes and process // digest entries for the manifest main attributes @@ -407,6 +517,16 @@ public class SignatureFileVerifier { if (key.toUpperCase(Locale.ENGLISH).endsWith(ATTR_DIGEST)) { String algorithm = key.substring(0, key.length() - ATTR_DIGEST.length()); + validEntry = true; + + // Check if this algorithm is permitted, skip if false. + if (!permittedCheck(key, algorithm)) { + continue; + } + + // A non-weak algorithm was used, any weak algorithms found do + // not need to be reported. + weakAlgs = false; MessageDigest digest = getDigest(algorithm); if (digest != null) { @@ -425,8 +545,7 @@ public class SignatureFileVerifier { debug.println(); } - if (MessageDigest.isEqual(computedHash, - expectedHash)) { + if (MessageDigest.isEqual(computedHash, expectedHash)) { // good } else { // we will *not* continue and verify each section @@ -442,6 +561,22 @@ public class SignatureFileVerifier { } } + if (debug != null) { + debug.println("PermittedAlgs mapping: "); + for (String key : permittedAlgs.keySet()) { + debug.println(key + " : " + + permittedAlgs.get(key).toString()); + } + } + + // If there were only weak algorithms entries used, throw an exception. + if (validEntry && weakAlgs) { + throw new SignatureException("Manifest Main Attribute check " + + "failed (" + ATTR_DIGEST + "). " + + "Disabled algorithm(s) used: " + + getWeakAlgorithms(ATTR_DIGEST)); + } + // this method returns 'true' if either: // . manifest main attributes were not signed, or // . manifest main attributes were signed and verified @@ -464,6 +599,10 @@ public class SignatureFileVerifier { { boolean oneDigestVerified = false; ManifestDigester.Entry mde = md.get(name,block.isOldStyle()); + // If only weak algorithms are used. + boolean weakAlgs = true; + // If a "*-DIGEST" entry is found. + boolean validEntry = false; if (mde == null) { throw new SecurityException( @@ -471,7 +610,6 @@ public class SignatureFileVerifier { } if (sfAttr != null) { - //sun.security.util.HexDumpEncoder hex = new sun.security.util.HexDumpEncoder(); //hex.encodeBuffer(data, System.out); @@ -482,6 +620,16 @@ public class SignatureFileVerifier { if (key.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST")) { // 7 is length of "-Digest" String algorithm = key.substring(0, key.length()-7); + validEntry = true; + + // Check if this algorithm is permitted, skip if false. + if (!permittedCheck(key, algorithm)) { + continue; + } + + // A non-weak algorithm was used, any weak algorithms found do + // not need to be reported. + weakAlgs = false; MessageDigest digest = getDigest(algorithm); @@ -532,6 +680,22 @@ public class SignatureFileVerifier { } } } + + if (debug != null) { + debug.println("PermittedAlgs mapping: "); + for (String key : permittedAlgs.keySet()) { + debug.println(key + " : " + + permittedAlgs.get(key).toString()); + } + } + + // If there were only weak algorithms entries used, throw an exception. + if (validEntry && weakAlgs) { + throw new SignatureException("Manifest Main Attribute check " + + "failed (DIGEST). Disabled algorithm(s) used: " + + getWeakAlgorithms("DIGEST")); + } + return oneDigestVerified; } diff --git a/jdk/src/java.base/share/classes/sun/security/validator/PKIXValidator.java b/jdk/src/java.base/share/classes/sun/security/validator/PKIXValidator.java index 8d63ea2b8f5..9f9b36afcb3 100644 --- a/jdk/src/java.base/share/classes/sun/security/validator/PKIXValidator.java +++ b/jdk/src/java.base/share/classes/sun/security/validator/PKIXValidator.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 @@ -33,7 +33,7 @@ import java.security.cert.*; import javax.security.auth.x500.X500Principal; import sun.security.action.GetBooleanAction; import sun.security.provider.certpath.AlgorithmChecker; -import sun.security.provider.certpath.PKIXTimestampParameters; +import sun.security.provider.certpath.PKIXExtendedParameters; /** * Validator implementation built on the PKIX CertPath API. This @@ -195,23 +195,22 @@ public final class PKIXValidator extends Validator { ("null or zero-length certificate chain"); } - // Check if 'parameter' affects 'pkixParameters' + // Use PKIXExtendedParameters for timestamp and variant additions PKIXBuilderParameters pkixParameters = null; - if (parameter instanceof Timestamp && plugin) { - try { - pkixParameters = new PKIXTimestampParameters( - (PKIXBuilderParameters) parameterTemplate.clone(), - (Timestamp) parameter); - } catch (InvalidAlgorithmParameterException e) { - // ignore exception - } - } else { - pkixParameters = (PKIXBuilderParameters) parameterTemplate.clone(); + try { + pkixParameters = new PKIXExtendedParameters( + (PKIXBuilderParameters) parameterTemplate.clone(), + (parameter instanceof Timestamp) ? + (Timestamp) parameter : null, + variant); + } catch (InvalidAlgorithmParameterException e) { + // ignore exception } // add new algorithm constraints checker if (constraints != null) { - pkixParameters.addCertPathChecker(new AlgorithmChecker(constraints)); + pkixParameters.addCertPathChecker( + new AlgorithmChecker(constraints, null, variant)); } // attach it to the PKIXBuilderParameters. diff --git a/jdk/src/java.base/share/classes/sun/security/validator/SimpleValidator.java b/jdk/src/java.base/share/classes/sun/security/validator/SimpleValidator.java index 58f7a5db419..a90c8c77382 100644 --- a/jdk/src/java.base/share/classes/sun/security/validator/SimpleValidator.java +++ b/jdk/src/java.base/share/classes/sun/security/validator/SimpleValidator.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 @@ -155,12 +155,14 @@ public final class SimpleValidator extends Validator { // create default algorithm constraints checker TrustAnchor anchor = new TrustAnchor(anchorCert, null); - AlgorithmChecker defaultAlgChecker = new AlgorithmChecker(anchor); + AlgorithmChecker defaultAlgChecker = + new AlgorithmChecker(anchor, variant); // create application level algorithm constraints checker AlgorithmChecker appAlgChecker = null; if (constraints != null) { - appAlgChecker = new AlgorithmChecker(anchor, constraints); + appAlgChecker = new AlgorithmChecker(anchor, constraints, null, + null, variant); } // verify top down, starting at the certificate issued by diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java index 1fc5bed4c83..364d47b5f4d 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java @@ -536,13 +536,18 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { * @return value of this CRL in a printable form. */ public String toString() { + return toStringWithAlgName("" + sigAlgId); + } + + // Specifically created for keytool to append a (weak) label to sigAlg + public String toStringWithAlgName(String name) { StringBuilder sb = new StringBuilder(); sb.append("X.509 CRL v") .append(version+1) .append('\n'); if (sigAlgId != null) sb.append("Signature Algorithm: ") - .append(sigAlgId) + .append(name) .append(", OID=") .append(sigAlgId.getOID()) .append('\n'); diff --git a/jdk/src/java.base/share/conf/net.properties b/jdk/src/java.base/share/conf/net.properties index b490e174a3f..ac94b30f119 100644 --- a/jdk/src/java.base/share/conf/net.properties +++ b/jdk/src/java.base/share/conf/net.properties @@ -3,7 +3,7 @@ # # This file may contain default values for the networking system properties. # These values are only used when the system properties are not specified -# on the command line or set programatically. +# on the command line or set programmatically. # For now, only the various proxy settings can be configured here. ############################################################ @@ -11,7 +11,7 @@ # settings when they do exist. # Set it to 'true' to enable this feature and check for platform # specific proxy settings -# Note that the system properties that do explicitely set proxies +# Note that the system properties that do explicitly set proxies # (like http.proxyHost) do take precedence over the system settings # even if java.net.useSystemProxies is set to true. diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index 5e778810bb7..a564f7c367b 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -116,6 +116,13 @@ security.provider.tbd=SunPKCS11 # Example: # jdk.security.provider.preferred=AES/GCM/NoPadding:SunJCE, \ # MessageDigest.SHA-256:SUN, Group.HmacSHA2:SunJCE +# +#ifdef solaris-sparc +# Optional Solaris-SPARC configuration for non-FIPS 140 configurations. +# jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, \ +# HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE +# +#endif #jdk.security.provider.preferred= @@ -240,6 +247,7 @@ securerandom.strongAlgorithms=NativePRNGBlocking:SUN,DRBG:SUN # # The default value is an empty string, which is equivalent to # securerandom.drbg.config=Hash_DRBG,SHA-256,128,none +# securerandom.drbg.config= # @@ -262,23 +270,27 @@ policy.provider=sun.security.provider.PolicyFile # The default is to have a single system-wide policy file, # and a policy file in the user's home directory. +# policy.url.1=file:${java.home}/conf/security/java.policy policy.url.2=file:${user.home}/.java.policy # whether or not we expand properties in the policy file # if this is set to false, properties (${...}) will not be expanded in policy # files. +# policy.expandProperties=true # whether or not we allow an extra policy to be passed on the command line # with -Djava.security.policy=somefile. Comment out this line to disable # this feature. +# policy.allowSystemProperty=true # whether or not we look into the IdentityScope for trusted Identities # when encountering a 1.1 signed JAR file. If the identity is found # and is trusted, we grant it AllPermission. Note: the default policy # provider (sun.security.provider.PolicyFile) does not support this property. +# policy.ignoreIdentityScope=false # @@ -360,7 +372,6 @@ ssl.TrustManagerFactory.algorithm=PKIX # For this reason the default caching policy is to maintain these # results for 10 seconds. # -# networkaddress.cache.negative.ttl=10 # @@ -460,8 +471,10 @@ networkaddress.cache.negative.ttl=10 # Example, # krb5.kdc.bad.policy = tryLast # krb5.kdc.bad.policy = tryLess:2,2000 +# krb5.kdc.bad.policy = tryLast +# # Algorithm restrictions for certification path (CertPath) processing # # In some environments, certain algorithms or key lengths may be undesirable @@ -481,7 +494,8 @@ krb5.kdc.bad.policy = tryLast # (see below) # # Constraint: -# KeySizeConstraint | CAConstraint | DenyAfterConstraint +# KeySizeConstraint | CAConstraint | DenyAfterConstraint | +# UsageConstraint # # KeySizeConstraint: # keySize Operator KeyLength @@ -498,6 +512,9 @@ krb5.kdc.bad.policy = tryLast # DenyAfterConstraint: # denyAfter YYYY-MM-DD # +# UsageConstraint: +# usage [TLSServer] [TLSClient] [SignedJAR] +# # The "AlgorithmName" is the standard algorithm name of the disabled # algorithm. See "Java Cryptography Architecture Standard Algorithm Name # Documentation" for information about Standard Algorithm Names. Matching @@ -547,6 +564,19 @@ krb5.kdc.bad.policy = tryLast # Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020, # use the following: "RSA keySize == 2048 & denyAfter 2020-02-03" # +# UsageConstraint: +# usage [TLSServer] [TLSClient] [SignedJAR] +# This constraint prohibits the specified algorithm for +# a specified usage. This should be used when disabling an algorithm +# for all usages is not practical. 'TLSServer' restricts the algorithm +# in TLS server certificate chains when server authentication is +# performed. 'TLSClient' restricts the algorithm in TLS client +# certificate chains when client authentication is performed. +# 'SignedJAR' constrains use of certificates in signed jar files. +# The usage type follows the keyword and more than one usage type can +# be specified with a whitespace delimiter. +# Example: "SHA1 usage TLSServer TLSClient" +# # When an algorithm must satisfy more than one constraint, it must be # delimited by an ampersand '&'. For example, to restrict certificates in a # chain that terminate at a distribution provided trust anchor and contain @@ -568,39 +598,10 @@ krb5.kdc.bad.policy = tryLast # jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 # # -jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & denyAfter 2017-01-01, \ +jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer, \ 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 @@ -615,17 +616,20 @@ jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & denyAfter 2017-01-01, \ # " DisabledAlgorithm { , DisabledAlgorithm } " # # DisabledAlgorithm: -# AlgorithmName [Constraint] +# AlgorithmName [Constraint] { '&' Constraint } # # AlgorithmName: # (see below) # # Constraint: -# KeySizeConstraint +# KeySizeConstraint | DenyAfterConstraint # # KeySizeConstraint: # keySize Operator KeyLength # +# DenyAfterConstraint: +# denyAfter YYYY-MM-DD +# # Operator: # <= | < | == | != | >= | > # @@ -636,9 +640,12 @@ jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & denyAfter 2017-01-01, \ # implementation. It is not guaranteed to be examined and used by other # implementations. # +# See "jdk.certpath.disabledAlgorithms" for syntax descriptions. +# jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \ DSA keySize < 1024 +# # Algorithm restrictions for Secure Socket Layer/Transport Layer Security # (SSL/TLS/DTLS) processing # @@ -939,3 +946,32 @@ jdk.xml.dsig.secureValidationPolicy=\ # #jdk.serialFilter=pattern;pattern +# +# 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 diff --git a/jdk/src/java.base/share/legal/zlib.md b/jdk/src/java.base/share/legal/zlib.md index bbf40f9814b..69198f1ef4f 100644 --- a/jdk/src/java.base/share/legal/zlib.md +++ b/jdk/src/java.base/share/legal/zlib.md @@ -1,9 +1,9 @@ -## zlib v1.2.8 +## zlib v1.2.11 ### zlib License

               
              -Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
              +Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
               
               This software is provided 'as-is', without any express or implied
               warranty.  In no event will the authors be held liable for any damages
              diff --git a/jdk/src/java.base/share/lib/security/default.policy b/jdk/src/java.base/share/lib/security/default.policy
              index 7f7ad4ff4b3..033d80b064a 100644
              --- a/jdk/src/java.base/share/lib/security/default.policy
              +++ b/jdk/src/java.base/share/lib/security/default.policy
              @@ -69,6 +69,8 @@ grant codeBase "jrt:/java.sql.rowset" {
               };
               
               grant codeBase "jrt:/java.xml.bind" {
              +    permission java.lang.RuntimePermission
              +                   "accessClassInPackage.sun.misc";
                   permission java.lang.RuntimePermission
                                  "accessClassInPackage.com.sun.xml.internal.*";
                   permission java.lang.RuntimePermission
              @@ -102,18 +104,16 @@ grant codeBase "jrt:/java.xml.crypto" {
               };
               
               grant codeBase "jrt:/java.xml.ws" {
              +    permission java.net.NetPermission
              +                   "getProxySelector";
                   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";
              +                   "accessClassInPackage.sun.misc";
                   permission java.lang.RuntimePermission
                                  "accessClassInPackage.com.sun.xml.internal.*";
                   permission java.lang.RuntimePermission
                                  "accessClassInPackage.com.sun.istack.internal";
                   permission java.lang.RuntimePermission
                                  "accessClassInPackage.com.sun.istack.internal.*";
              -    permission java.lang.RuntimePermission
              -                   "accessClassInPackage.com.sun.org.apache.xerces.internal.*";
                   permission java.lang.RuntimePermission "accessDeclaredMembers";
                   permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
                   permission java.util.PropertyPermission "*", "read";
              @@ -213,3 +213,7 @@ grant {
                   permission java.lang.RuntimePermission "accessClassInPackage.com.sun.java.swing.plaf.*";
                   permission java.lang.RuntimePermission "accessClassInPackage.com.apple.*";
               };
              +
              +grant codeBase "jrt:/jdk.internal.vm.compiler" {
              +    permission java.security.AllPermission;
              +};
              diff --git a/jdk/src/java.base/share/native/launcher/main.c b/jdk/src/java.base/share/native/launcher/main.c
              index acbff5ff316..8e27a2a2ed9 100644
              --- a/jdk/src/java.base/share/native/launcher/main.c
              +++ b/jdk/src/java.base/share/native/launcher/main.c
              @@ -130,10 +130,10 @@ main(int argc, char **argv)
               
                       // Add first arg, which is the app name
                       JLI_List_add(args, JLI_StringDup(argv[0]));
              -        // Append JAVA_OPTIONS
              -        if (JLI_AddArgsFromEnvVar(args, JAVA_OPTIONS)) {
              +        // Append JDK_JAVA_OPTIONS
              +        if (JLI_AddArgsFromEnvVar(args, JDK_JAVA_OPTIONS)) {
                           // JLI_SetTraceLauncher is not called yet
              -            // Show _JAVA_OPTIONS content along with JAVA_OPTIONS to aid diagnosis
              +            // Show _JAVA_OPTIONS content along with JDK_JAVA_OPTIONS to aid diagnosis
                           if (getenv(JLDEBUG_ENV_ENTRY)) {
                               char *tmp = getenv("_JAVA_OPTIONS");
                               if (NULL != tmp) {
              diff --git a/jdk/src/java.base/share/native/libjava/ClassLoader.c b/jdk/src/java.base/share/native/libjava/ClassLoader.c
              index 5a8d86156b9..f3803805c59 100644
              --- a/jdk/src/java.base/share/native/libjava/ClassLoader.c
              +++ b/jdk/src/java.base/share/native/libjava/ClassLoader.c
              @@ -72,23 +72,9 @@ getUTF(JNIEnv *env, jstring str, char* localBuf, int bufSize)
                   return utfStr;
               }
               
              -// The existence or signature of this method is not guaranteed since it
              -// supports a private method.  This method will be changed in 1.7.
              -JNIEXPORT jclass JNICALL
              -Java_java_lang_ClassLoader_defineClass0(JNIEnv *env,
              -                                        jobject loader,
              -                                        jstring name,
              -                                        jbyteArray data,
              -                                        jint offset,
              -                                        jint length,
              -                                        jobject pd)
              -{
              -    return Java_java_lang_ClassLoader_defineClass1(env, loader, name, data, offset,
              -                                                   length, pd, NULL);
              -}
              -
               JNIEXPORT jclass JNICALL
               Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
              +                                        jclass cls,
                                                       jobject loader,
                                                       jstring name,
                                                       jbyteArray data,
              @@ -163,6 +149,7 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
               
               JNIEXPORT jclass JNICALL
               Java_java_lang_ClassLoader_defineClass2(JNIEnv *env,
              +                                        jclass cls,
                                                       jobject loader,
                                                       jstring name,
                                                       jobject data,
              diff --git a/jdk/src/java.base/share/native/libjava/Module.c b/jdk/src/java.base/share/native/libjava/Module.c
              index 26067555a33..f396b8dfc49 100644
              --- a/jdk/src/java.base/share/native/libjava/Module.c
              +++ b/jdk/src/java.base/share/native/libjava/Module.c
              @@ -29,12 +29,12 @@
               #include "jni_util.h"
               #include "jvm.h"
               
              -#include "java_lang_reflect_Module.h"
              +#include "java_lang_Module.h"
               
               /*
                * Gets the UTF-8 chars for the string and translates '.' to '/'.  Does no
                * further validation, assumption being that both calling code in
              - * java.lang.reflect.Module and VM will do deeper validation.
              + * java.lang.Module and VM will do deeper validation.
                */
               static char*
               GetInternalPackageName(JNIEnv *env, jstring pkg, char* buf, jsize buf_size)
              @@ -68,35 +68,37 @@ GetInternalPackageName(JNIEnv *env, jstring pkg, char* buf, jsize buf_size)
               }
               
               JNIEXPORT void JNICALL
              -Java_java_lang_reflect_Module_defineModule0(JNIEnv *env, jclass cls, jobject module,
              +Java_java_lang_Module_defineModule0(JNIEnv *env, jclass cls, jobject module,
                                                           jboolean is_open, jstring version,
                                                           jstring location, jobjectArray packages)
               {
                   char** pkgs = NULL;
              -    jsize idx;
                   jsize num_packages = (*env)->GetArrayLength(env, packages);
               
                   if (num_packages != 0 && (pkgs = calloc(num_packages, sizeof(char*))) == NULL) {
                       JNU_ThrowOutOfMemoryError(env, NULL);
                       return;
              -    } else {
              -        int valid = 1;
              +    } else if ((*env)->EnsureLocalCapacity(env, (jint)num_packages) == 0) {
              +        jboolean failed = JNI_FALSE;
              +        int idx;
                       for (idx = 0; idx < num_packages; idx++) {
                           jstring pkg = (*env)->GetObjectArrayElement(env, packages, idx);
              -            pkgs[idx] = GetInternalPackageName(env, pkg, NULL, 0);
              -            if (pkgs[idx] == NULL) {
              -                valid = 0;
              +            char* name = GetInternalPackageName(env, pkg, NULL, 0);
              +            if (name != NULL) {
              +                pkgs[idx] = name;
              +            } else {
              +                failed = JNI_TRUE;
                               break;
                           }
                       }
              -
              -        if (valid != 0) {
              +        if (!failed) {
                           JVM_DefineModule(env, module, is_open, version, location,
              -                    (const char* const*)pkgs, num_packages);
              +                             (const char* const*)pkgs, num_packages);
                       }
                   }
               
                   if (num_packages > 0) {
              +        int idx;
                       for (idx = 0; idx < num_packages; idx++) {
                           if (pkgs[idx] != NULL) {
                               free(pkgs[idx]);
              @@ -107,14 +109,14 @@ Java_java_lang_reflect_Module_defineModule0(JNIEnv *env, jclass cls, jobject mod
               }
               
               JNIEXPORT void JNICALL
              -Java_java_lang_reflect_Module_addReads0(JNIEnv *env, jclass cls, jobject from, jobject to)
              +Java_java_lang_Module_addReads0(JNIEnv *env, jclass cls, jobject from, jobject to)
               {
                   JVM_AddReadsModule(env, from, to);
               }
               
               JNIEXPORT void JNICALL
              -Java_java_lang_reflect_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
              -                                          jstring pkg, jobject to)
              +Java_java_lang_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
              +                                  jstring pkg, jobject to)
               {
                   char buf[128];
                   char* pkg_name;
              @@ -134,8 +136,8 @@ Java_java_lang_reflect_Module_addExports0(JNIEnv *env, jclass cls, jobject from,
               }
               
               JNIEXPORT void JNICALL
              -Java_java_lang_reflect_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject from,
              -                                               jstring pkg)
              +Java_java_lang_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject from,
              +                                       jstring pkg)
               {
                   char buf[128];
                   char* pkg_name;
              @@ -155,8 +157,8 @@ Java_java_lang_reflect_Module_addExportsToAll0(JNIEnv *env, jclass cls, jobject
               }
               
               JNIEXPORT void JNICALL
              -Java_java_lang_reflect_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
              -                                                      jobject from, jstring pkg)
              +Java_java_lang_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
              +                                              jobject from, jstring pkg)
               {
                   char buf[128];
                   char* pkg_name;
              @@ -176,7 +178,7 @@ Java_java_lang_reflect_Module_addExportsToAllUnnamed0(JNIEnv *env, jclass cls,
               }
               
               JNIEXPORT void JNICALL
              -Java_java_lang_reflect_Module_addPackage0(JNIEnv *env, jclass cls, jobject m, jstring pkg)
              +Java_java_lang_Module_addPackage0(JNIEnv *env, jclass cls, jobject m, jstring pkg)
               {
                   char buf[128];
                   char* pkg_name;
              diff --git a/jdk/src/java.base/share/native/libjimage/endian.hpp b/jdk/src/java.base/share/native/libjimage/endian.hpp
              index 81eca199191..b14c39ec0f3 100644
              --- a/jdk/src/java.base/share/native/libjimage/endian.hpp
              +++ b/jdk/src/java.base/share/native/libjimage/endian.hpp
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
              + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
                *
                * Redistribution and use in source and binary forms, with or without
                * modification, are permitted provided that the following conditions
              diff --git a/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp b/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp
              index e2dbb79ce6f..96a175c57e7 100644
              --- a/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp
              +++ b/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
              + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
                *
                * Redistribution and use in source and binary forms, with or without
                * modification, are permitted provided that the following conditions
              diff --git a/jdk/src/java.base/share/native/libjimage/imageDecompressor.hpp b/jdk/src/java.base/share/native/libjimage/imageDecompressor.hpp
              index c5a758abbcb..ed98b32e8cb 100644
              --- a/jdk/src/java.base/share/native/libjimage/imageDecompressor.hpp
              +++ b/jdk/src/java.base/share/native/libjimage/imageDecompressor.hpp
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
              + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
                *
                * Redistribution and use in source and binary forms, with or without
                * modification, are permitted provided that the following conditions
              diff --git a/jdk/src/java.base/share/native/libjimage/imageFile.hpp b/jdk/src/java.base/share/native/libjimage/imageFile.hpp
              index 9e02d87460c..c32d2fed8c8 100644
              --- a/jdk/src/java.base/share/native/libjimage/imageFile.hpp
              +++ b/jdk/src/java.base/share/native/libjimage/imageFile.hpp
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
              + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
                *
                * Redistribution and use in source and binary forms, with or without
                * modification, are permitted provided that the following conditions
              diff --git a/jdk/src/java.base/share/native/libjimage/inttypes.hpp b/jdk/src/java.base/share/native/libjimage/inttypes.hpp
              index d66b05418f1..c5947265245 100644
              --- a/jdk/src/java.base/share/native/libjimage/inttypes.hpp
              +++ b/jdk/src/java.base/share/native/libjimage/inttypes.hpp
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
              + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
                *
                * Redistribution and use in source and binary forms, with or without
                * modification, are permitted provided that the following conditions
              @@ -47,4 +47,3 @@ typedef          long long s8;
               #endif
               
               #endif // LIBJIMAGE_INTTYPES_HPP
              -
              diff --git a/jdk/src/java.base/share/native/libjimage/jimage.hpp b/jdk/src/java.base/share/native/libjimage/jimage.hpp
              index 8521307bbf8..305c6e2b387 100644
              --- a/jdk/src/java.base/share/native/libjimage/jimage.hpp
              +++ b/jdk/src/java.base/share/native/libjimage/jimage.hpp
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
              + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
                *
                * Redistribution and use in source and binary forms, with or without
                * modification, are permitted provided that the following conditions
              @@ -202,4 +202,3 @@ extern "C" bool JIMAGE_ResourcePath(JImageFile* image, JImageLocationRef locatio
               
               typedef bool (*JImage_ResourcePath_t)(JImageFile* jimage, JImageLocationRef location,
                       char* buffer, jlong size);
              -
              diff --git a/jdk/src/java.base/share/native/libjimage/osSupport.hpp b/jdk/src/java.base/share/native/libjimage/osSupport.hpp
              index 8fa15e3c0a7..aeb6c6a79d7 100644
              --- a/jdk/src/java.base/share/native/libjimage/osSupport.hpp
              +++ b/jdk/src/java.base/share/native/libjimage/osSupport.hpp
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
              + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
                *
                * Redistribution and use in source and binary forms, with or without
                * modification, are permitted provided that the following conditions
              diff --git a/jdk/src/java.base/share/native/libjli/args.c b/jdk/src/java.base/share/native/libjli/args.c
              index d24301c3db9..adbff674bf9 100644
              --- a/jdk/src/java.base/share/native/libjli/args.c
              +++ b/jdk/src/java.base/share/native/libjli/args.c
              @@ -34,7 +34,7 @@
                   #define NO_JNI
                 #endif
                 #define JLI_ReportMessage(...) printf(__VA_ARGS__)
              -  #define JAVA_OPTIONS "JAVA_OPTIONS"
              +  #define JDK_JAVA_OPTIONS "JDK_JAVA_OPTIONS"
                 int IsWhiteSpaceOption(const char* name) { return 1; }
               #else
                 #include "java.h"
              @@ -429,10 +429,6 @@ int isTerminalOpt(char *arg) {
               }
               
               jboolean JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name) {
              -
              -#ifndef ENABLE_JAVA_OPTIONS
              -    return JNI_FALSE;
              -#else
                   char *env = getenv(var_name);
                   char *p, *arg;
                   char quote;
              @@ -519,7 +515,6 @@ jboolean JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name) {
                   }
               
                   return JNI_TRUE;
              -#endif
               }
               
               #ifdef DEBUG_ARGFILE
              diff --git a/jdk/src/java.base/share/native/libjli/emessages.h b/jdk/src/java.base/share/native/libjli/emessages.h
              index 8c3c34199ea..c5ae8d74b5e 100644
              --- a/jdk/src/java.base/share/native/libjli/emessages.h
              +++ b/jdk/src/java.base/share/native/libjli/emessages.h
              @@ -43,13 +43,14 @@
               #define ARG_ERROR2      "Error: %s requires jar file specification"
               #define ARG_ERROR3      "Error: The -J option should not be followed by a space."
               #define ARG_ERROR4      "Error: %s requires module path specification"
              -#define ARG_ERROR5      "Error: %s requires module id"
              +#define ARG_ERROR5      "Error: %s requires module name"
               #define ARG_ERROR6      "Error: %s requires modules to be specified"
               #define ARG_ERROR7      "Error: %s can only be specified once"
               #define ARG_ERROR8      "Error: Unmatched quote in environment variable %s"
               #define ARG_ERROR9      "Error: Option %s is not allowed in environment variable %s"
               #define ARG_ERROR10     "Error: Option %s in %s is not allowed in environment variable %s"
               #define ARG_ERROR11     "Error: Cannot specify main class in environment variable %s"
              +#define ARG_ERROR12     "Error: %s requires module name"
               
               #define JVM_ERROR1      "Error: Could not create the Java Virtual Machine.\n" GEN_ERROR
               #define JVM_ERROR2      "Error: Could not detach main thread.\n" JNI_ERROR
              diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c
              index f8265eeb110..927c09f5d14 100644
              --- a/jdk/src/java.base/share/native/libjli/java.c
              +++ b/jdk/src/java.base/share/native/libjli/java.c
              @@ -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
              @@ -71,7 +71,10 @@ static jboolean printTo = USE_STDERR;     /* where to print version/usage */
               static jboolean printXUsage = JNI_FALSE;  /* print and exit*/
               static jboolean dryRun = JNI_FALSE;       /* initialize VM and exit */
               static char     *showSettings = NULL;     /* print but continue */
              -static char     *listModules = NULL;
              +static jboolean showResolvedModules = JNI_FALSE;
              +static jboolean listModules = JNI_FALSE;
              +static char     *describeModule = NULL;
              +static jboolean validateModules = JNI_FALSE;
               
               static const char *_program_name;
               static const char *_launcher_name;
              @@ -118,7 +121,10 @@ static void SetApplicationClassPath(const char**);
               static void PrintJavaVersion(JNIEnv *env, jboolean extraLF);
               static void PrintUsage(JNIEnv* env, jboolean doXUsage);
               static void ShowSettings(JNIEnv* env, char *optString);
              -static void ListModules(JNIEnv* env, char *optString);
              +static void ShowResolvedModules(JNIEnv* env);
              +static void ListModules(JNIEnv* env);
              +static void DescribeModule(JNIEnv* env, char* optString);
              +static jboolean ValidateModules(JNIEnv* env);
               
               static void SetPaths(int argc, char **argv);
               
              @@ -409,9 +415,31 @@ JavaMain(void * _args)
                       CHECK_EXCEPTION_LEAVE(1);
                   }
               
              -    if (listModules != NULL) {
              -        ListModules(env, listModules);
              +    // show resolved modules and continue
              +    if (showResolvedModules) {
              +        ShowResolvedModules(env);
                       CHECK_EXCEPTION_LEAVE(1);
              +    }
              +
              +    // list observable modules, then exit
              +    if (listModules) {
              +        ListModules(env);
              +        CHECK_EXCEPTION_LEAVE(1);
              +        LEAVE();
              +    }
              +
              +    // describe a module, then exit
              +    if (describeModule != NULL) {
              +        DescribeModule(env, describeModule);
              +        CHECK_EXCEPTION_LEAVE(1);
              +        LEAVE();
              +    }
              +
              +    // validate modules on the module path, then exit
              +    if (validateModules) {
              +        jboolean okay = ValidateModules(env);
              +        CHECK_EXCEPTION_LEAVE(1);
              +        if (!okay) ret = 1;
                       LEAVE();
                   }
               
              @@ -552,7 +580,8 @@ static jboolean
               IsLauncherOption(const char* name) {
                   return IsClassPathOption(name) ||
                          IsLauncherMainOption(name) ||
              -           JLI_StrCmp(name, "--list-modules") == 0;
              +           JLI_StrCmp(name, "--describe-module") == 0 ||
              +           JLI_StrCmp(name, "-d") == 0;
               }
               
               /*
              @@ -1199,7 +1228,7 @@ GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) {
               
                   } else if (JLI_StrCCmp(arg, "--") == 0 && (equals = JLI_StrChr(arg, '=')) != NULL) {
                       value = equals+1;
              -        if (JLI_StrCCmp(arg, "--list-modules=") == 0 ||
              +        if (JLI_StrCCmp(arg, "--describe-module=") == 0 ||
                           JLI_StrCCmp(arg, "--module=") == 0 ||
                           JLI_StrCCmp(arg, "--class-path=") == 0) {
                           kind = LAUNCHER_OPTION_WITH_ARGUMENT;
              @@ -1263,18 +1292,18 @@ ParseArguments(int *pargc, char ***pargv,
                           REPORT_ERROR (has_arg_any_len, ARG_ERROR1, arg);
                           SetClassPath(value);
                           mode = LM_CLASS;
              -        } else if (JLI_StrCmp(arg, "--list-modules") == 0 ||
              -                   JLI_StrCCmp(arg, "--list-modules=") == 0) {
              -            listModules = arg;
              -
              -            // set listModules to --list-modules= if argument is specified
              -            if (JLI_StrCmp(arg, "--list-modules") == 0 && has_arg) {
              -                static const char format[] = "%s=%s";
              -                size_t buflen = JLI_StrLen(option) + 2 + JLI_StrLen(value);
              -                listModules = JLI_MemAlloc(buflen);
              -                JLI_Snprintf(listModules, buflen, format, option, value);
              -            }
              -            return JNI_TRUE;
              +        } else if (JLI_StrCmp(arg, "--list-modules") == 0) {
              +            listModules = JNI_TRUE;
              +        } else if (JLI_StrCmp(arg, "--show-resolved-modules") == 0) {
              +            showResolvedModules = JNI_TRUE;
              +        } else if (JLI_StrCmp(arg, "--validate-modules") == 0) {
              +            AddOption("-Djdk.module.minimumBoot=true", NULL);
              +            validateModules = JNI_TRUE;
              +        } else if (JLI_StrCmp(arg, "--describe-module") == 0 ||
              +                   JLI_StrCCmp(arg, "--describe-module=") == 0 ||
              +                   JLI_StrCmp(arg, "-d") == 0) {
              +            REPORT_ERROR (has_arg_any_len, ARG_ERROR12, arg);
              +            describeModule = value;
               /*
                * Parse white-space options
                */
              @@ -1336,9 +1365,8 @@ ParseArguments(int *pargc, char ***pargv,
                           showSettings = arg;
                       } else if (JLI_StrCmp(arg, "-Xdiag") == 0) {
                           AddOption("-Dsun.java.launcher.diag=true", NULL);
              -            AddOption("-Djdk.launcher.traceResolver=true", NULL);
              -        } else if (JLI_StrCmp(arg, "-Xdiag:resolver") == 0) {
              -            AddOption("-Djdk.launcher.traceResolver=true", NULL);
              +        } else if (JLI_StrCmp(arg, "--show-module-resolution") == 0) {
              +            AddOption("-Djdk.module.showModuleResolution=true", NULL);
               /*
                * The following case provide backward compatibility with old-style
                * command line options.
              @@ -1399,7 +1427,10 @@ ParseArguments(int *pargc, char ***pargv,
                   }
               
                   if (*pwhat == NULL) {
              -        *pret = 1;
              +        /* LM_UNKNOWN okay for options that exit */
              +        if (!listModules && !describeModule && !validateModules) {
              +            *pret = 1;
              +        }
                   } else if (mode == LM_UNKNOWN) {
                       /* default to LM_CLASS if -m, -jar and -cp options are
                        * not specified */
              @@ -1828,21 +1859,61 @@ ShowSettings(JNIEnv *env, char *optString)
               }
               
               /**
              - * List modules supported by the runtime
              + * Show resolved modules
                */
               static void
              -ListModules(JNIEnv *env, char *optString)
              +ShowResolvedModules(JNIEnv *env)
              +{
              +    jmethodID showResolvedModulesID;
              +    jclass cls = GetLauncherHelperClass(env);
              +    NULL_CHECK(cls);
              +    NULL_CHECK(showResolvedModulesID = (*env)->GetStaticMethodID(env, cls,
              +            "showResolvedModules", "()V"));
              +    (*env)->CallStaticVoidMethod(env, cls, showResolvedModulesID);
              +}
              +
              +/**
              + * List observable modules
              + */
              +static void
              +ListModules(JNIEnv *env)
               {
                   jmethodID listModulesID;
              -    jstring joptString = NULL;
                   jclass cls = GetLauncherHelperClass(env);
                   NULL_CHECK(cls);
                   NULL_CHECK(listModulesID = (*env)->GetStaticMethodID(env, cls,
              -            "listModules", "(ZLjava/lang/String;)V"));
              +            "listModules", "()V"));
              +    (*env)->CallStaticVoidMethod(env, cls, listModulesID);
              +}
              +
              +/**
              + * Describe a module
              + */
              +static void
              +DescribeModule(JNIEnv *env, char *optString)
              +{
              +    jmethodID describeModuleID;
              +    jstring joptString = NULL;
              +    jclass cls = GetLauncherHelperClass(env);
              +    NULL_CHECK(cls);
              +    NULL_CHECK(describeModuleID = (*env)->GetStaticMethodID(env, cls,
              +            "describeModule", "(Ljava/lang/String;)V"));
                   NULL_CHECK(joptString = (*env)->NewStringUTF(env, optString));
              -    (*env)->CallStaticVoidMethod(env, cls, listModulesID,
              -                                 USE_STDOUT,
              -                                 joptString);
              +    (*env)->CallStaticVoidMethod(env, cls, describeModuleID, joptString);
              +}
              +
              +/**
              + * Validate modules
              + */
              +static jboolean
              +ValidateModules(JNIEnv *env)
              +{
              +    jmethodID validateModulesID;
              +    jclass cls = GetLauncherHelperClass(env);
              +    NULL_CHECK_RETURN_VALUE(cls, JNI_FALSE);
              +    validateModulesID = (*env)->GetStaticMethodID(env, cls, "validateModules", "()Z");
              +    NULL_CHECK_RETURN_VALUE(cls, JNI_FALSE);
              +    return (*env)->CallStaticBooleanMethod(env, cls, validateModulesID);
               }
               
               /*
              diff --git a/jdk/src/java.base/share/native/libjli/java.h b/jdk/src/java.base/share/native/libjli/java.h
              index d035a080d9d..842dcc9cf9d 100644
              --- a/jdk/src/java.base/share/native/libjli/java.h
              +++ b/jdk/src/java.base/share/native/libjli/java.h
              @@ -71,7 +71,7 @@
               
               #define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
               #define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
              -#define JAVA_OPTIONS "JAVA_OPTIONS"
              +#define JDK_JAVA_OPTIONS "JDK_JAVA_OPTIONS"
               
               /*
                * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/patches/ChangeLog_java b/jdk/src/java.base/share/native/libzip/zlib-1.2.8/patches/ChangeLog_java
              deleted file mode 100644
              index 6f013dbb2fa..00000000000
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/patches/ChangeLog_java
              +++ /dev/null
              @@ -1,10 +0,0 @@
              -(1)renamed
              -   adler32.c -> zadler32.c
              -   zcrc32c -> zcrc32.c
              -
              -(2)added _LP64 to make uLong a 32-bit int on 64-bit platform
              -   zconf.h:
              -   uLong -> 32-bit int
              -
              -(3)updated crc32.c/crc32()
              -   unsigned long      -> uLong
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/uncompr.c b/jdk/src/java.base/share/native/libzip/zlib-1.2.8/uncompr.c
              deleted file mode 100644
              index 1bcf06feeb0..00000000000
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/uncompr.c
              +++ /dev/null
              @@ -1,83 +0,0 @@
              -/*
              - * 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.
              - */
              -
              -/* uncompr.c -- decompress a memory buffer
              - * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
              - * For conditions of distribution and use, see copyright notice in zlib.h
              - */
              -
              -/* @(#) $Id$ */
              -
              -#define ZLIB_INTERNAL
              -#include "zlib.h"
              -
              -/* ===========================================================================
              -     Decompresses the source buffer into the destination buffer.  sourceLen is
              -   the byte length of the source buffer. Upon entry, destLen is the total
              -   size of the destination buffer, which must be large enough to hold the
              -   entire uncompressed data. (The size of the uncompressed data must have
              -   been saved previously by the compressor and transmitted to the decompressor
              -   by some mechanism outside the scope of this compression library.)
              -   Upon exit, destLen is the actual size of the compressed buffer.
              -
              -     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
              -   enough memory, Z_BUF_ERROR if there was not enough room in the output
              -   buffer, or Z_DATA_ERROR if the input data was corrupted.
              -*/
              -int ZEXPORT uncompress (dest, destLen, source, sourceLen)
              -    Bytef *dest;
              -    uLongf *destLen;
              -    const Bytef *source;
              -    uLong sourceLen;
              -{
              -    z_stream stream;
              -    int err;
              -
              -    stream.next_in = (z_const Bytef *)source;
              -    stream.avail_in = (uInt)sourceLen;
              -    /* Check for source > 64K on 16-bit machine: */
              -    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
              -
              -    stream.next_out = dest;
              -    stream.avail_out = (uInt)*destLen;
              -    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
              -
              -    stream.zalloc = (alloc_func)0;
              -    stream.zfree = (free_func)0;
              -
              -    err = inflateInit(&stream);
              -    if (err != Z_OK) return err;
              -
              -    err = inflate(&stream, Z_FINISH);
              -    if (err != Z_STREAM_END) {
              -        inflateEnd(&stream);
              -        if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
              -            return Z_DATA_ERROR;
              -        return err;
              -    }
              -    *destLen = stream.total_out;
              -
              -    err = inflateEnd(&stream);
              -    return err;
              -}
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/ChangeLog b/jdk/src/java.base/share/native/libzip/zlib/ChangeLog
              similarity index 96%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/ChangeLog
              rename to jdk/src/java.base/share/native/libzip/zlib/ChangeLog
              index f22aabaef53..30199a65a03 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/ChangeLog
              +++ b/jdk/src/java.base/share/native/libzip/zlib/ChangeLog
              @@ -1,10 +1,53 @@
               
                               ChangeLog file for zlib
               
              +Changes in 1.2.11 (15 Jan 2017)
              +- Fix deflate stored bug when pulling last block from window
              +- Permit immediate deflateParams changes before any deflate input
              +
              +Changes in 1.2.10 (2 Jan 2017)
              +- Avoid warnings on snprintf() return value
              +- Fix bug in deflate_stored() for zero-length input
              +- Fix bug in gzwrite.c that produced corrupt gzip files
              +- Remove files to be installed before copying them in Makefile.in
              +- Add warnings when compiling with assembler code
              +
              +Changes in 1.2.9 (31 Dec 2016)
              +- Fix contrib/minizip to permit unzipping with desktop API [Zouzou]
              +- Improve contrib/blast to return unused bytes
              +- Assure that gzoffset() is correct when appending
              +- Improve compress() and uncompress() to support large lengths
              +- Fix bug in test/example.c where error code not saved
              +- Remedy Coverity warning [Randers-Pehrson]
              +- Improve speed of gzprintf() in transparent mode
              +- Fix inflateInit2() bug when windowBits is 16 or 32
              +- Change DEBUG macro to ZLIB_DEBUG
              +- Avoid uninitialized access by gzclose_w()
              +- Allow building zlib outside of the source directory
              +- Fix bug that accepted invalid zlib header when windowBits is zero
              +- Fix gzseek() problem on MinGW due to buggy _lseeki64 there
              +- Loop on write() calls in gzwrite.c in case of non-blocking I/O
              +- Add --warn (-w) option to ./configure for more compiler warnings
              +- Reject a window size of 256 bytes if not using the zlib wrapper
              +- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE
              +- Add --debug (-d) option to ./configure to define ZLIB_DEBUG
              +- Fix bugs in creating a very large gzip header
              +- Add uncompress2() function, which returns the input size used
              +- Assure that deflateParams() will not switch functions mid-block
              +- Dramatically speed up deflation for level 0 (storing)
              +- Add gzfread(), duplicating the interface of fread()
              +- Add gzfwrite(), duplicating the interface of fwrite()
              +- Add deflateGetDictionary() function
              +- Use snprintf() for later versions of Microsoft C
              +- Fix *Init macros to use z_ prefix when requested
              +- Replace as400 with os400 for OS/400 support [Monnerat]
              +- Add crc32_z() and adler32_z() functions with size_t lengths
              +- Update Visual Studio project files [AraHaan]
              +
               Changes in 1.2.8 (28 Apr 2013)
               - Update contrib/minizip/iowin32.c for Windows RT [Vollant]
               - Do not force Z_CONST for C++
              -- Clean up contrib/vstudio [Ro§]
              +- Clean up contrib/vstudio [Roß]
               - Correct spelling error in zlib.h
               - Fix mixed line endings in contrib/vstudio
               
              @@ -34,7 +77,7 @@ Changes in 1.2.7.1 (24 Mar 2013)
               - Clean up the usage of z_const and respect const usage within zlib
               - Clean up examples/gzlog.[ch] comparisons of different types
               - Avoid shift equal to bits in type (caused endless loop)
              -- Fix unintialized value bug in gzputc() introduced by const patches
              +- Fix uninitialized value bug in gzputc() introduced by const patches
               - Fix memory allocation error in examples/zran.c [Nor]
               - Fix bug where gzopen(), gzclose() would write an empty file
               - Fix bug in gzclose() when gzwrite() runs out of memory
              @@ -194,7 +237,7 @@ Changes in 1.2.5.2 (17 Dec 2011)
               - Add a transparent write mode to gzopen() when 'T' is in the mode
               - Update python link in zlib man page
               - Get inffixed.h and MAKEFIXED result to match
              -- Add a ./config --solo option to make zlib subset with no libary use
              +- Add a ./config --solo option to make zlib subset with no library use
               - Add undocumented inflateResetKeep() function for CAB file decoding
               - Add --cover option to ./configure for gcc coverage testing
               - Add #define ZLIB_CONST option to use const in the z_stream interface
              @@ -564,7 +607,7 @@ Changes in 1.2.3.1 (16 August 2006)
               - Update make_vms.com [Zinser]
               - Use -fPIC for shared build in configure [Teredesai, Nicholson]
               - Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
              -- Use fdopen() (not _fdopen()) for Interix in zutil.h [BŠck]
              +- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck]
               - Add some FAQ entries about the contrib directory
               - Update the MVS question in the FAQ
               - Avoid extraneous reads after EOF in gzio.c [Brown]
              @@ -1178,7 +1221,7 @@ Changes in 1.0.6 (19 Jan 1998)
                       386 asm code replacing longest_match().
                  contrib/iostream/ by Kevin Ruland 
                       A C++ I/O streams interface to the zlib gz* functions
              -   contrib/iostream2/  by Tyge Løvset 
              +   contrib/iostream2/  by Tyge Løvset 
                       Another C++ I/O streams interface
                  contrib/untgz/  by "Pedro A. Aranda Guti\irrez" 
                       A very simple tar.gz file extractor using zlib
              @@ -1267,7 +1310,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
               - fix array overlay in deflate.c which sometimes caused bad compressed data
               - fix inflate bug with empty stored block
               - fix MSDOS medium model which was broken in 0.99
              -- fix deflateParams() which could generated bad compressed data.
              +- fix deflateParams() which could generate bad compressed data.
               - Bytef is define'd instead of typedef'ed (work around Borland bug)
               - added an INDEX file
               - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/README b/jdk/src/java.base/share/native/libzip/zlib/README
              similarity index 96%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/README
              rename to jdk/src/java.base/share/native/libzip/zlib/README
              index 5ca9d127eda..51106de4753 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/README
              +++ b/jdk/src/java.base/share/native/libzip/zlib/README
              @@ -1,6 +1,6 @@
               ZLIB DATA COMPRESSION LIBRARY
               
              -zlib 1.2.8 is a general purpose data compression library.  All the code is
              +zlib 1.2.11 is a general purpose data compression library.  All the code is
               thread safe.  The data format used by the zlib library is described by RFCs
               (Request for Comments) 1950 to 1952 in the files
               http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
              @@ -31,7 +31,7 @@ Mark Nelson  wrote an article about zlib for the Jan.  1997
               issue of Dr.  Dobb's Journal; a copy of the article is available at
               http://marknelson.us/1997/01/01/zlib-engine/ .
               
              -The changes made in version 1.2.8 are documented in the file ChangeLog.
              +The changes made in version 1.2.11 are documented in the file ChangeLog.
               
               Unsupported third party contributions are provided in directory contrib/ .
               
              @@ -84,7 +84,7 @@ Acknowledgments:
               
               Copyright notice:
               
              - (C) 1995-2013 Jean-loup Gailly and Mark Adler
              + (C) 1995-2017 Jean-loup Gailly and Mark Adler
               
                 This software is provided 'as-is', without any express or implied
                 warranty.  In no event will the authors be held liable for any damages
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/compress.c b/jdk/src/java.base/share/native/libzip/zlib/compress.c
              similarity index 81%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/compress.c
              rename to jdk/src/java.base/share/native/libzip/zlib/compress.c
              index cdc51e08172..a9d3b983486 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/compress.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/compress.c
              @@ -23,7 +23,7 @@
                */
               
               /* compress.c -- compress a memory buffer
              - * Copyright (C) 1995-2005 Jean-loup Gailly.
              + * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -52,16 +52,11 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
               {
                   z_stream stream;
                   int err;
              +    const uInt max = (uInt)-1;
              +    uLong left;
               
              -    stream.next_in = (z_const Bytef *)source;
              -    stream.avail_in = (uInt)sourceLen;
              -#ifdef MAXSEG_64K
              -    /* Check for source > 64K on 16-bit machine: */
              -    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
              -#endif
              -    stream.next_out = dest;
              -    stream.avail_out = (uInt)*destLen;
              -    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
              +    left = *destLen;
              +    *destLen = 0;
               
                   stream.zalloc = (alloc_func)0;
                   stream.zfree = (free_func)0;
              @@ -70,15 +65,26 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
                   err = deflateInit(&stream, level);
                   if (err != Z_OK) return err;
               
              -    err = deflate(&stream, Z_FINISH);
              -    if (err != Z_STREAM_END) {
              -        deflateEnd(&stream);
              -        return err == Z_OK ? Z_BUF_ERROR : err;
              -    }
              -    *destLen = stream.total_out;
              +    stream.next_out = dest;
              +    stream.avail_out = 0;
              +    stream.next_in = (z_const Bytef *)source;
              +    stream.avail_in = 0;
               
              -    err = deflateEnd(&stream);
              -    return err;
              +    do {
              +        if (stream.avail_out == 0) {
              +            stream.avail_out = left > (uLong)max ? max : (uInt)left;
              +            left -= stream.avail_out;
              +        }
              +        if (stream.avail_in == 0) {
              +            stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
              +            sourceLen -= stream.avail_in;
              +        }
              +        err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
              +    } while (err == Z_OK);
              +
              +    *destLen = stream.total_out;
              +    deflateEnd(&stream);
              +    return err == Z_STREAM_END ? Z_OK : err;
               }
               
               /* ===========================================================================
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/crc32.h b/jdk/src/java.base/share/native/libzip/zlib/crc32.h
              similarity index 100%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/crc32.h
              rename to jdk/src/java.base/share/native/libzip/zlib/crc32.h
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/deflate.c b/jdk/src/java.base/share/native/libzip/zlib/deflate.c
              similarity index 76%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/deflate.c
              rename to jdk/src/java.base/share/native/libzip/zlib/deflate.c
              index 5cc66c5e537..d0ee5feadf7 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/deflate.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/deflate.c
              @@ -23,7 +23,7 @@
                */
               
               /* deflate.c -- compress data using the deflation algorithm
              - * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
              + * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -76,7 +76,7 @@
               #include "deflate.h"
               
               const char deflate_copyright[] =
              -   " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
              +   " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
               /*
                 If you use the zlib library in a product, an acknowledgment is welcome
                 in the documentation of your product. If for some reason you cannot
              @@ -97,6 +97,8 @@ typedef enum {
               typedef block_state (*compress_func) OF((deflate_state *s, int flush));
               /* Compression function. Returns the block state after the call. */
               
              +local int deflateStateCheck      OF((z_streamp strm));
              +local void slide_hash     OF((deflate_state *s));
               local void fill_window    OF((deflate_state *s));
               local block_state deflate_stored OF((deflate_state *s, int flush));
               local block_state deflate_fast   OF((deflate_state *s, int flush));
              @@ -108,15 +110,16 @@ local block_state deflate_huff   OF((deflate_state *s, int flush));
               local void lm_init        OF((deflate_state *s));
               local void putShortMSB    OF((deflate_state *s, uInt b));
               local void flush_pending  OF((z_streamp strm));
              -local int read_buf        OF((z_streamp strm, Bytef *buf, unsigned size));
              +local unsigned read_buf   OF((z_streamp strm, Bytef *buf, unsigned size));
               #ifdef ASMV
              +#  pragma message("Assembler code may have bugs -- use at your own risk")
                     void match_init OF((void)); /* asm code initialization */
                     uInt longest_match  OF((deflate_state *s, IPos cur_match));
               #else
               local uInt longest_match  OF((deflate_state *s, IPos cur_match));
               #endif
               
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
               local  void check_match OF((deflate_state *s, IPos start, IPos match,
                                           int length));
               #endif
              @@ -172,21 +175,14 @@ local const config configuration_table[10] = {
                * meaning.
                */
               
              -#define EQUAL 0
              -/* result of memcmp for equal strings */
              -
              -#ifndef NO_DUMMY_DECL
              -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
              -#endif
              -
               /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
              -#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
              +#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
               
               /* ===========================================================================
                * Update a hash value with the given input byte
              - * IN  assertion: all calls to to UPDATE_HASH are made with consecutive
              - *    input characters, so that a running hash key can be computed from the
              - *    previous key instead of complete recalculation each time.
              + * IN  assertion: all calls to UPDATE_HASH are made with consecutive input
              + *    characters, so that a running hash key can be computed from the previous
              + *    key instead of complete recalculation each time.
                */
               #define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask)
               
              @@ -197,9 +193,9 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
                * the previous length of the hash chain.
                * If this file is compiled with -DFASTEST, the compression level is forced
                * to 1, and no hash chains are maintained.
              - * IN  assertion: all calls to to INSERT_STRING are made with consecutive
              - *    input characters and the first MIN_MATCH bytes of str are valid
              - *    (except for the last MIN_MATCH-1 bytes of the input file).
              + * IN  assertion: all calls to INSERT_STRING are made with consecutive input
              + *    characters and the first MIN_MATCH bytes of str are valid (except for
              + *    the last MIN_MATCH-1 bytes of the input file).
                */
               #ifdef FASTEST
               #define INSERT_STRING(s, str, match_head) \
              @@ -221,6 +217,37 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
                   s->head[s->hash_size-1] = NIL; \
                   zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
               
              +/* ===========================================================================
              + * Slide the hash table when sliding the window down (could be avoided with 32
              + * bit values at the expense of memory usage). We slide even when level == 0 to
              + * keep the hash table consistent if we switch back to level > 0 later.
              + */
              +local void slide_hash(s)
              +    deflate_state *s;
              +{
              +    unsigned n, m;
              +    Posf *p;
              +    uInt wsize = s->w_size;
              +
              +    n = s->hash_size;
              +    p = &s->head[n];
              +    do {
              +        m = *--p;
              +        *p = (Pos)(m >= wsize ? m - wsize : NIL);
              +    } while (--n);
              +    n = wsize;
              +#ifndef FASTEST
              +    p = &s->prev[n];
              +    do {
              +        m = *--p;
              +        *p = (Pos)(m >= wsize ? m - wsize : NIL);
              +        /* If n is not on any hash chain, prev[n] is garbage but
              +         * its value will never be used.
              +         */
              +    } while (--n);
              +#endif
              +}
              +
               /* ========================================================================= */
               int ZEXPORT deflateInit_(strm, level, version, stream_size)
                   z_streamp strm;
              @@ -294,7 +321,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
               #endif
                   if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
                       windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
              -        strategy < 0 || strategy > Z_FIXED) {
              +        strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
                       return Z_STREAM_ERROR;
                   }
                   if (windowBits == 8) windowBits = 9;  /* until 256-byte window bug fixed */
              @@ -302,14 +329,15 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
                   if (s == Z_NULL) return Z_MEM_ERROR;
                   strm->state = (struct internal_state FAR *)s;
                   s->strm = strm;
              +    s->status = INIT_STATE;     /* to pass state test in deflateReset() */
               
                   s->wrap = wrap;
                   s->gzhead = Z_NULL;
              -    s->w_bits = windowBits;
              +    s->w_bits = (uInt)windowBits;
                   s->w_size = 1 << s->w_bits;
                   s->w_mask = s->w_size - 1;
               
              -    s->hash_bits = memLevel + 7;
              +    s->hash_bits = (uInt)memLevel + 7;
                   s->hash_size = 1 << s->hash_bits;
                   s->hash_mask = s->hash_size - 1;
                   s->hash_shift =  ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
              @@ -343,6 +371,31 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
                   return deflateReset(strm);
               }
               
              +/* =========================================================================
              + * Check for a valid deflate stream state. Return 0 if ok, 1 if not.
              + */
              +local int deflateStateCheck (strm)
              +    z_streamp strm;
              +{
              +    deflate_state *s;
              +    if (strm == Z_NULL ||
              +        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
              +        return 1;
              +    s = strm->state;
              +    if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
              +#ifdef GZIP
              +                                           s->status != GZIP_STATE &&
              +#endif
              +                                           s->status != EXTRA_STATE &&
              +                                           s->status != NAME_STATE &&
              +                                           s->status != COMMENT_STATE &&
              +                                           s->status != HCRC_STATE &&
              +                                           s->status != BUSY_STATE &&
              +                                           s->status != FINISH_STATE))
              +        return 1;
              +    return 0;
              +}
              +
               /* ========================================================================= */
               int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
                   z_streamp strm;
              @@ -355,7 +408,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
                   unsigned avail;
                   z_const unsigned char *next;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
              +    if (deflateStateCheck(strm) || dictionary == Z_NULL)
                       return Z_STREAM_ERROR;
                   s = strm->state;
                   wrap = s->wrap;
              @@ -412,14 +465,35 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
                   return Z_OK;
               }
               
              +/* ========================================================================= */
              +int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
              +    z_streamp strm;
              +    Bytef *dictionary;
              +    uInt  *dictLength;
              +{
              +    deflate_state *s;
              +    uInt len;
              +
              +    if (deflateStateCheck(strm))
              +        return Z_STREAM_ERROR;
              +    s = strm->state;
              +    len = s->strstart + s->lookahead;
              +    if (len > s->w_size)
              +        len = s->w_size;
              +    if (dictionary != Z_NULL && len)
              +        zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len);
              +    if (dictLength != Z_NULL)
              +        *dictLength = len;
              +    return Z_OK;
              +}
              +
               /* ========================================================================= */
               int ZEXPORT deflateResetKeep (strm)
                   z_streamp strm;
               {
                   deflate_state *s;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL ||
              -        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
              +    if (deflateStateCheck(strm)) {
                       return Z_STREAM_ERROR;
                   }
               
              @@ -434,7 +508,11 @@ int ZEXPORT deflateResetKeep (strm)
                   if (s->wrap < 0) {
                       s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
                   }
              -    s->status = s->wrap ? INIT_STATE : BUSY_STATE;
              +    s->status =
              +#ifdef GZIP
              +        s->wrap == 2 ? GZIP_STATE :
              +#endif
              +        s->wrap ? INIT_STATE : BUSY_STATE;
                   strm->adler =
               #ifdef GZIP
                       s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
              @@ -464,8 +542,8 @@ int ZEXPORT deflateSetHeader (strm, head)
                   z_streamp strm;
                   gz_headerp head;
               {
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              -    if (strm->state->wrap != 2) return Z_STREAM_ERROR;
              +    if (deflateStateCheck(strm) || strm->state->wrap != 2)
              +        return Z_STREAM_ERROR;
                   strm->state->gzhead = head;
                   return Z_OK;
               }
              @@ -476,7 +554,7 @@ int ZEXPORT deflatePending (strm, pending, bits)
                   int *bits;
                   z_streamp strm;
               {
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
                   if (pending != Z_NULL)
                       *pending = strm->state->pending;
                   if (bits != Z_NULL)
              @@ -493,7 +571,7 @@ int ZEXPORT deflatePrime (strm, bits, value)
                   deflate_state *s;
                   int put;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
                   s = strm->state;
                   if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
                       return Z_BUF_ERROR;
              @@ -518,9 +596,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
               {
                   deflate_state *s;
                   compress_func func;
              -    int err = Z_OK;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
                   s = strm->state;
               
               #ifdef FASTEST
              @@ -534,13 +611,22 @@ int ZEXPORT deflateParams(strm, level, strategy)
                   func = configuration_table[s->level].func;
               
                   if ((strategy != s->strategy || func != configuration_table[level].func) &&
              -        strm->total_in != 0) {
              +        s->high_water) {
                       /* Flush the last buffer: */
              -        err = deflate(strm, Z_BLOCK);
              -        if (err == Z_BUF_ERROR && s->pending == 0)
              -            err = Z_OK;
              +        int err = deflate(strm, Z_BLOCK);
              +        if (err == Z_STREAM_ERROR)
              +            return err;
              +        if (strm->avail_out == 0)
              +            return Z_BUF_ERROR;
                   }
                   if (s->level != level) {
              +        if (s->level == 0 && s->matches != 0) {
              +            if (s->matches == 1)
              +                slide_hash(s);
              +            else
              +                CLEAR_HASH(s);
              +            s->matches = 0;
              +        }
                       s->level = level;
                       s->max_lazy_match   = configuration_table[level].max_lazy;
                       s->good_match       = configuration_table[level].good_length;
              @@ -548,7 +634,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
                       s->max_chain_length = configuration_table[level].max_chain;
                   }
                   s->strategy = strategy;
              -    return err;
              +    return Z_OK;
               }
               
               /* ========================================================================= */
              @@ -561,12 +647,12 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
               {
                   deflate_state *s;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
                   s = strm->state;
              -    s->good_match = good_length;
              -    s->max_lazy_match = max_lazy;
              +    s->good_match = (uInt)good_length;
              +    s->max_lazy_match = (uInt)max_lazy;
                   s->nice_match = nice_length;
              -    s->max_chain_length = max_chain;
              +    s->max_chain_length = (uInt)max_chain;
                   return Z_OK;
               }
               
              @@ -593,14 +679,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
               {
                   deflate_state *s;
                   uLong complen, wraplen;
              -    Bytef *str;
               
                   /* conservative upper bound for compressed data */
                   complen = sourceLen +
                             ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
               
                   /* if can't get parameters, return conservative bound plus zlib wrapper */
              -    if (strm == Z_NULL || strm->state == Z_NULL)
              +    if (deflateStateCheck(strm))
                       return complen + 6;
               
                   /* compute wrapper length */
              @@ -612,9 +697,11 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
                   case 1:                                 /* zlib wrapper */
                       wraplen = 6 + (s->strstart ? 4 : 0);
                       break;
              +#ifdef GZIP
                   case 2:                                 /* gzip wrapper */
                       wraplen = 18;
                       if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */
              +            Bytef *str;
                           if (s->gzhead->extra != Z_NULL)
                               wraplen += 2 + s->gzhead->extra_len;
                           str = s->gzhead->name;
              @@ -631,6 +718,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
                               wraplen += 2;
                       }
                       break;
              +#endif
                   default:                                /* for compiler happiness */
                       wraplen = 6;
                   }
              @@ -658,10 +746,10 @@ local void putShortMSB (s, b)
               }
               
               /* =========================================================================
              - * Flush as much pending output as possible. All deflate() output goes
              - * through this function so some applications may wish to modify it
              - * to avoid allocating a large strm->next_out buffer and copying into it.
              - * (See also read_buf()).
              + * Flush as much pending output as possible. All deflate() output, except for
              + * some deflate_stored() output, goes through this function so some
              + * applications may wish to modify it to avoid allocating a large
              + * strm->next_out buffer and copying into it. (See also read_buf()).
                */
               local void flush_pending(strm)
                   z_streamp strm;
              @@ -678,13 +766,23 @@ local void flush_pending(strm)
                   strm->next_out  += len;
                   s->pending_out  += len;
                   strm->total_out += len;
              -    strm->avail_out  -= len;
              -    s->pending -= len;
              +    strm->avail_out -= len;
              +    s->pending      -= len;
                   if (s->pending == 0) {
                       s->pending_out = s->pending_buf;
                   }
               }
               
              +/* ===========================================================================
              + * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1].
              + */
              +#define HCRC_UPDATE(beg) \
              +    do { \
              +        if (s->gzhead->hcrc && s->pending > (beg)) \
              +            strm->adler = crc32(strm->adler, s->pending_buf + (beg), \
              +                                s->pending - (beg)); \
              +    } while (0)
              +
               /* ========================================================================= */
               int ZEXPORT deflate (strm, flush)
                   z_streamp strm;
              @@ -693,203 +791,21 @@ int ZEXPORT deflate (strm, flush)
                   int old_flush; /* value of flush param for previous deflate call */
                   deflate_state *s;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL ||
              -        flush > Z_BLOCK || flush < 0) {
              +    if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
                       return Z_STREAM_ERROR;
                   }
                   s = strm->state;
               
                   if (strm->next_out == Z_NULL ||
              -        (strm->next_in == Z_NULL && strm->avail_in != 0) ||
              +        (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
                       (s->status == FINISH_STATE && flush != Z_FINISH)) {
                       ERR_RETURN(strm, Z_STREAM_ERROR);
                   }
                   if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
               
              -    s->strm = strm; /* just in case */
                   old_flush = s->last_flush;
                   s->last_flush = flush;
               
              -    /* Write the header */
              -    if (s->status == INIT_STATE) {
              -#ifdef GZIP
              -        if (s->wrap == 2) {
              -            strm->adler = crc32(0L, Z_NULL, 0);
              -            put_byte(s, 31);
              -            put_byte(s, 139);
              -            put_byte(s, 8);
              -            if (s->gzhead == Z_NULL) {
              -                put_byte(s, 0);
              -                put_byte(s, 0);
              -                put_byte(s, 0);
              -                put_byte(s, 0);
              -                put_byte(s, 0);
              -                put_byte(s, s->level == 9 ? 2 :
              -                            (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
              -                             4 : 0));
              -                put_byte(s, OS_CODE);
              -                s->status = BUSY_STATE;
              -            }
              -            else {
              -                put_byte(s, (s->gzhead->text ? 1 : 0) +
              -                            (s->gzhead->hcrc ? 2 : 0) +
              -                            (s->gzhead->extra == Z_NULL ? 0 : 4) +
              -                            (s->gzhead->name == Z_NULL ? 0 : 8) +
              -                            (s->gzhead->comment == Z_NULL ? 0 : 16)
              -                        );
              -                put_byte(s, (Byte)(s->gzhead->time & 0xff));
              -                put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
              -                put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
              -                put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
              -                put_byte(s, s->level == 9 ? 2 :
              -                            (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
              -                             4 : 0));
              -                put_byte(s, s->gzhead->os & 0xff);
              -                if (s->gzhead->extra != Z_NULL) {
              -                    put_byte(s, s->gzhead->extra_len & 0xff);
              -                    put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
              -                }
              -                if (s->gzhead->hcrc)
              -                    strm->adler = crc32(strm->adler, s->pending_buf,
              -                                        s->pending);
              -                s->gzindex = 0;
              -                s->status = EXTRA_STATE;
              -            }
              -        }
              -        else
              -#endif
              -        {
              -            uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
              -            uInt level_flags;
              -
              -            if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
              -                level_flags = 0;
              -            else if (s->level < 6)
              -                level_flags = 1;
              -            else if (s->level == 6)
              -                level_flags = 2;
              -            else
              -                level_flags = 3;
              -            header |= (level_flags << 6);
              -            if (s->strstart != 0) header |= PRESET_DICT;
              -            header += 31 - (header % 31);
              -
              -            s->status = BUSY_STATE;
              -            putShortMSB(s, header);
              -
              -            /* Save the adler32 of the preset dictionary: */
              -            if (s->strstart != 0) {
              -                putShortMSB(s, (uInt)(strm->adler >> 16));
              -                putShortMSB(s, (uInt)(strm->adler & 0xffff));
              -            }
              -            strm->adler = adler32(0L, Z_NULL, 0);
              -        }
              -    }
              -#ifdef GZIP
              -    if (s->status == EXTRA_STATE) {
              -        if (s->gzhead->extra != Z_NULL) {
              -            uInt beg = s->pending;  /* start of bytes to update crc */
              -
              -            while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
              -                if (s->pending == s->pending_buf_size) {
              -                    if (s->gzhead->hcrc && s->pending > beg)
              -                        strm->adler = crc32(strm->adler, s->pending_buf + beg,
              -                                            s->pending - beg);
              -                    flush_pending(strm);
              -                    beg = s->pending;
              -                    if (s->pending == s->pending_buf_size)
              -                        break;
              -                }
              -                put_byte(s, s->gzhead->extra[s->gzindex]);
              -                s->gzindex++;
              -            }
              -            if (s->gzhead->hcrc && s->pending > beg)
              -                strm->adler = crc32(strm->adler, s->pending_buf + beg,
              -                                    s->pending - beg);
              -            if (s->gzindex == s->gzhead->extra_len) {
              -                s->gzindex = 0;
              -                s->status = NAME_STATE;
              -            }
              -        }
              -        else
              -            s->status = NAME_STATE;
              -    }
              -    if (s->status == NAME_STATE) {
              -        if (s->gzhead->name != Z_NULL) {
              -            uInt beg = s->pending;  /* start of bytes to update crc */
              -            int val;
              -
              -            do {
              -                if (s->pending == s->pending_buf_size) {
              -                    if (s->gzhead->hcrc && s->pending > beg)
              -                        strm->adler = crc32(strm->adler, s->pending_buf + beg,
              -                                            s->pending - beg);
              -                    flush_pending(strm);
              -                    beg = s->pending;
              -                    if (s->pending == s->pending_buf_size) {
              -                        val = 1;
              -                        break;
              -                    }
              -                }
              -                val = s->gzhead->name[s->gzindex++];
              -                put_byte(s, val);
              -            } while (val != 0);
              -            if (s->gzhead->hcrc && s->pending > beg)
              -                strm->adler = crc32(strm->adler, s->pending_buf + beg,
              -                                    s->pending - beg);
              -            if (val == 0) {
              -                s->gzindex = 0;
              -                s->status = COMMENT_STATE;
              -            }
              -        }
              -        else
              -            s->status = COMMENT_STATE;
              -    }
              -    if (s->status == COMMENT_STATE) {
              -        if (s->gzhead->comment != Z_NULL) {
              -            uInt beg = s->pending;  /* start of bytes to update crc */
              -            int val;
              -
              -            do {
              -                if (s->pending == s->pending_buf_size) {
              -                    if (s->gzhead->hcrc && s->pending > beg)
              -                        strm->adler = crc32(strm->adler, s->pending_buf + beg,
              -                                            s->pending - beg);
              -                    flush_pending(strm);
              -                    beg = s->pending;
              -                    if (s->pending == s->pending_buf_size) {
              -                        val = 1;
              -                        break;
              -                    }
              -                }
              -                val = s->gzhead->comment[s->gzindex++];
              -                put_byte(s, val);
              -            } while (val != 0);
              -            if (s->gzhead->hcrc && s->pending > beg)
              -                strm->adler = crc32(strm->adler, s->pending_buf + beg,
              -                                    s->pending - beg);
              -            if (val == 0)
              -                s->status = HCRC_STATE;
              -        }
              -        else
              -            s->status = HCRC_STATE;
              -    }
              -    if (s->status == HCRC_STATE) {
              -        if (s->gzhead->hcrc) {
              -            if (s->pending + 2 > s->pending_buf_size)
              -                flush_pending(strm);
              -            if (s->pending + 2 <= s->pending_buf_size) {
              -                put_byte(s, (Byte)(strm->adler & 0xff));
              -                put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
              -                strm->adler = crc32(0L, Z_NULL, 0);
              -                s->status = BUSY_STATE;
              -            }
              -        }
              -        else
              -            s->status = BUSY_STATE;
              -    }
              -#endif
              -
                   /* Flush as much pending output as possible */
                   if (s->pending != 0) {
                       flush_pending(strm);
              @@ -918,15 +834,197 @@ int ZEXPORT deflate (strm, flush)
                       ERR_RETURN(strm, Z_BUF_ERROR);
                   }
               
              +    /* Write the header */
              +    if (s->status == INIT_STATE) {
              +        /* zlib header */
              +        uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
              +        uInt level_flags;
              +
              +        if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
              +            level_flags = 0;
              +        else if (s->level < 6)
              +            level_flags = 1;
              +        else if (s->level == 6)
              +            level_flags = 2;
              +        else
              +            level_flags = 3;
              +        header |= (level_flags << 6);
              +        if (s->strstart != 0) header |= PRESET_DICT;
              +        header += 31 - (header % 31);
              +
              +        putShortMSB(s, header);
              +
              +        /* Save the adler32 of the preset dictionary: */
              +        if (s->strstart != 0) {
              +            putShortMSB(s, (uInt)(strm->adler >> 16));
              +            putShortMSB(s, (uInt)(strm->adler & 0xffff));
              +        }
              +        strm->adler = adler32(0L, Z_NULL, 0);
              +        s->status = BUSY_STATE;
              +
              +        /* Compression must start with an empty pending buffer */
              +        flush_pending(strm);
              +        if (s->pending != 0) {
              +            s->last_flush = -1;
              +            return Z_OK;
              +        }
              +    }
              +#ifdef GZIP
              +    if (s->status == GZIP_STATE) {
              +        /* gzip header */
              +        strm->adler = crc32(0L, Z_NULL, 0);
              +        put_byte(s, 31);
              +        put_byte(s, 139);
              +        put_byte(s, 8);
              +        if (s->gzhead == Z_NULL) {
              +            put_byte(s, 0);
              +            put_byte(s, 0);
              +            put_byte(s, 0);
              +            put_byte(s, 0);
              +            put_byte(s, 0);
              +            put_byte(s, s->level == 9 ? 2 :
              +                     (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
              +                      4 : 0));
              +            put_byte(s, OS_CODE);
              +            s->status = BUSY_STATE;
              +
              +            /* Compression must start with an empty pending buffer */
              +            flush_pending(strm);
              +            if (s->pending != 0) {
              +                s->last_flush = -1;
              +                return Z_OK;
              +            }
              +        }
              +        else {
              +            put_byte(s, (s->gzhead->text ? 1 : 0) +
              +                     (s->gzhead->hcrc ? 2 : 0) +
              +                     (s->gzhead->extra == Z_NULL ? 0 : 4) +
              +                     (s->gzhead->name == Z_NULL ? 0 : 8) +
              +                     (s->gzhead->comment == Z_NULL ? 0 : 16)
              +                     );
              +            put_byte(s, (Byte)(s->gzhead->time & 0xff));
              +            put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
              +            put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
              +            put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
              +            put_byte(s, s->level == 9 ? 2 :
              +                     (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
              +                      4 : 0));
              +            put_byte(s, s->gzhead->os & 0xff);
              +            if (s->gzhead->extra != Z_NULL) {
              +                put_byte(s, s->gzhead->extra_len & 0xff);
              +                put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
              +            }
              +            if (s->gzhead->hcrc)
              +                strm->adler = crc32(strm->adler, s->pending_buf,
              +                                    s->pending);
              +            s->gzindex = 0;
              +            s->status = EXTRA_STATE;
              +        }
              +    }
              +    if (s->status == EXTRA_STATE) {
              +        if (s->gzhead->extra != Z_NULL) {
              +            ulg beg = s->pending;   /* start of bytes to update crc */
              +            uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
              +            while (s->pending + left > s->pending_buf_size) {
              +                uInt copy = s->pending_buf_size - s->pending;
              +                zmemcpy(s->pending_buf + s->pending,
              +                        s->gzhead->extra + s->gzindex, copy);
              +                s->pending = s->pending_buf_size;
              +                HCRC_UPDATE(beg);
              +                s->gzindex += copy;
              +                flush_pending(strm);
              +                if (s->pending != 0) {
              +                    s->last_flush = -1;
              +                    return Z_OK;
              +                }
              +                beg = 0;
              +                left -= copy;
              +            }
              +            zmemcpy(s->pending_buf + s->pending,
              +                    s->gzhead->extra + s->gzindex, left);
              +            s->pending += left;
              +            HCRC_UPDATE(beg);
              +            s->gzindex = 0;
              +        }
              +        s->status = NAME_STATE;
              +    }
              +    if (s->status == NAME_STATE) {
              +        if (s->gzhead->name != Z_NULL) {
              +            ulg beg = s->pending;   /* start of bytes to update crc */
              +            int val;
              +            do {
              +                if (s->pending == s->pending_buf_size) {
              +                    HCRC_UPDATE(beg);
              +                    flush_pending(strm);
              +                    if (s->pending != 0) {
              +                        s->last_flush = -1;
              +                        return Z_OK;
              +                    }
              +                    beg = 0;
              +                }
              +                val = s->gzhead->name[s->gzindex++];
              +                put_byte(s, val);
              +            } while (val != 0);
              +            HCRC_UPDATE(beg);
              +            s->gzindex = 0;
              +        }
              +        s->status = COMMENT_STATE;
              +    }
              +    if (s->status == COMMENT_STATE) {
              +        if (s->gzhead->comment != Z_NULL) {
              +            ulg beg = s->pending;   /* start of bytes to update crc */
              +            int val;
              +            do {
              +                if (s->pending == s->pending_buf_size) {
              +                    HCRC_UPDATE(beg);
              +                    flush_pending(strm);
              +                    if (s->pending != 0) {
              +                        s->last_flush = -1;
              +                        return Z_OK;
              +                    }
              +                    beg = 0;
              +                }
              +                val = s->gzhead->comment[s->gzindex++];
              +                put_byte(s, val);
              +            } while (val != 0);
              +            HCRC_UPDATE(beg);
              +        }
              +        s->status = HCRC_STATE;
              +    }
              +    if (s->status == HCRC_STATE) {
              +        if (s->gzhead->hcrc) {
              +            if (s->pending + 2 > s->pending_buf_size) {
              +                flush_pending(strm);
              +                if (s->pending != 0) {
              +                    s->last_flush = -1;
              +                    return Z_OK;
              +                }
              +            }
              +            put_byte(s, (Byte)(strm->adler & 0xff));
              +            put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
              +            strm->adler = crc32(0L, Z_NULL, 0);
              +        }
              +        s->status = BUSY_STATE;
              +
              +        /* Compression must start with an empty pending buffer */
              +        flush_pending(strm);
              +        if (s->pending != 0) {
              +            s->last_flush = -1;
              +            return Z_OK;
              +        }
              +    }
              +#endif
              +
                   /* Start a new block or continue the current one.
                    */
                   if (strm->avail_in != 0 || s->lookahead != 0 ||
                       (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
                       block_state bstate;
               
              -        bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
              -                    (s->strategy == Z_RLE ? deflate_rle(s, flush) :
              -                        (*(configuration_table[s->level].func))(s, flush));
              +        bstate = s->level == 0 ? deflate_stored(s, flush) :
              +                 s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
              +                 s->strategy == Z_RLE ? deflate_rle(s, flush) :
              +                 (*(configuration_table[s->level].func))(s, flush);
               
                       if (bstate == finish_started || bstate == finish_done) {
                           s->status = FINISH_STATE;
              @@ -968,7 +1066,6 @@ int ZEXPORT deflate (strm, flush)
                           }
                       }
                   }
              -    Assert(strm->avail_out > 0, "bug2");
               
                   if (flush != Z_FINISH) return Z_OK;
                   if (s->wrap <= 0) return Z_STREAM_END;
              @@ -1005,18 +1102,9 @@ int ZEXPORT deflateEnd (strm)
               {
                   int status;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
               
                   status = strm->state->status;
              -    if (status != INIT_STATE &&
              -        status != EXTRA_STATE &&
              -        status != NAME_STATE &&
              -        status != COMMENT_STATE &&
              -        status != HCRC_STATE &&
              -        status != BUSY_STATE &&
              -        status != FINISH_STATE) {
              -      return Z_STREAM_ERROR;
              -    }
               
                   /* Deallocate in reverse order of allocations: */
                   TRY_FREE(strm, strm->state->pending_buf);
              @@ -1047,7 +1135,7 @@ int ZEXPORT deflateCopy (dest, source)
                   ushf *overlay;
               
               
              -    if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
              +    if (deflateStateCheck(source) || dest == Z_NULL) {
                       return Z_STREAM_ERROR;
                   }
               
              @@ -1097,7 +1185,7 @@ int ZEXPORT deflateCopy (dest, source)
                * allocating a large strm->next_in buffer and copying from it.
                * (See also flush_pending()).
                */
              -local int read_buf(strm, buf, size)
              +local unsigned read_buf(strm, buf, size)
                   z_streamp strm;
                   Bytef *buf;
                   unsigned size;
              @@ -1121,7 +1209,7 @@ local int read_buf(strm, buf, size)
                   strm->next_in  += len;
                   strm->total_in += len;
               
              -    return (int)len;
              +    return len;
               }
               
               /* ===========================================================================
              @@ -1175,9 +1263,9 @@ local uInt longest_match(s, cur_match)
               {
                   unsigned chain_length = s->max_chain_length;/* max hash chain length */
                   register Bytef *scan = s->window + s->strstart; /* current string */
              -    register Bytef *match;                       /* matched string */
              +    register Bytef *match;                      /* matched string */
                   register int len;                           /* length of current match */
              -    int best_len = s->prev_length;              /* best match length so far */
              +    int best_len = (int)s->prev_length;         /* best match length so far */
                   int nice_match = s->nice_match;             /* stop if match long enough */
                   IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
                       s->strstart - (IPos)MAX_DIST(s) : NIL;
              @@ -1212,7 +1300,7 @@ local uInt longest_match(s, cur_match)
                   /* Do not look for matches beyond the end of the input. This is necessary
                    * to make deflate deterministic.
                    */
              -    if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
              +    if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
               
                   Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
               
              @@ -1373,7 +1461,11 @@ local uInt longest_match(s, cur_match)
               
               #endif /* FASTEST */
               
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
              +
              +#define EQUAL 0
              +/* result of memcmp for equal strings */
              +
               /* ===========================================================================
                * Check that the match at match_start is indeed a match.
                */
              @@ -1399,7 +1491,7 @@ local void check_match(s, start, match, length)
               }
               #else
               #  define check_match(s, start, match, length)
              -#endif /* DEBUG */
              +#endif /* ZLIB_DEBUG */
               
               /* ===========================================================================
                * Fill the window when the lookahead becomes insufficient.
              @@ -1414,8 +1506,7 @@ local void check_match(s, start, match, length)
               local void fill_window(s)
                   deflate_state *s;
               {
              -    register unsigned n, m;
              -    register Posf *p;
              +    unsigned n;
                   unsigned more;    /* Amount of free space at the end of the window. */
                   uInt wsize = s->w_size;
               
              @@ -1442,35 +1533,11 @@ local void fill_window(s)
                        */
                       if (s->strstart >= wsize+MAX_DIST(s)) {
               
              -            zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
              +            zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
                           s->match_start -= wsize;
                           s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
                           s->block_start -= (long) wsize;
              -
              -            /* Slide the hash table (could be avoided with 32 bit values
              -               at the expense of memory usage). We slide even when level == 0
              -               to keep the hash table consistent if we switch back to level > 0
              -               later. (Using level 0 permanently is not an optimal usage of
              -               zlib, so we don't care about this pathological case.)
              -             */
              -            n = s->hash_size;
              -            p = &s->head[n];
              -            do {
              -                m = *--p;
              -                *p = (Pos)(m >= wsize ? m-wsize : NIL);
              -            } while (--n);
              -
              -            n = wsize;
              -#ifndef FASTEST
              -            p = &s->prev[n];
              -            do {
              -                m = *--p;
              -                *p = (Pos)(m >= wsize ? m-wsize : NIL);
              -                /* If n is not on any hash chain, prev[n] is garbage but
              -                 * its value will never be used.
              -                 */
              -            } while (--n);
              -#endif
              +            slide_hash(s);
                           more += wsize;
                       }
                       if (s->strm->avail_in == 0) break;
              @@ -1576,70 +1643,199 @@ local void fill_window(s)
                  if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
               }
               
              +/* Maximum stored block length in deflate format (not including header). */
              +#define MAX_STORED 65535
              +
              +/* Minimum of a and b. */
              +#define MIN(a, b) ((a) > (b) ? (b) : (a))
              +
               /* ===========================================================================
                * Copy without compression as much as possible from the input stream, return
                * the current block state.
              - * This function does not insert new strings in the dictionary since
              - * uncompressible data is probably not useful. This function is used
              - * only for the level=0 compression option.
              - * NOTE: this function should be optimized to avoid extra copying from
              - * window to pending_buf.
              + *
              + * In case deflateParams() is used to later switch to a non-zero compression
              + * level, s->matches (otherwise unused when storing) keeps track of the number
              + * of hash table slides to perform. If s->matches is 1, then one hash table
              + * slide will be done when switching. If s->matches is 2, the maximum value
              + * allowed here, then the hash table will be cleared, since two or more slides
              + * is the same as a clear.
              + *
              + * deflate_stored() is written to minimize the number of times an input byte is
              + * copied. It is most efficient with large input and output buffers, which
              + * maximizes the opportunites to have a single copy from next_in to next_out.
                */
               local block_state deflate_stored(s, flush)
                   deflate_state *s;
                   int flush;
               {
              -    /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
              -     * to pending_buf_size, and each stored block has a 5 byte header:
              +    /* Smallest worthy block size when not flushing or finishing. By default
              +     * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
              +     * large input and output buffers, the stored block size will be larger.
                    */
              -    ulg max_block_size = 0xffff;
              -    ulg max_start;
              +    unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);
               
              -    if (max_block_size > s->pending_buf_size - 5) {
              -        max_block_size = s->pending_buf_size - 5;
              -    }
              -
              -    /* Copy as much as possible from input to output: */
              -    for (;;) {
              -        /* Fill the window as much as possible: */
              -        if (s->lookahead <= 1) {
              -
              -            Assert(s->strstart < s->w_size+MAX_DIST(s) ||
              -                   s->block_start >= (long)s->w_size, "slide too late");
              -
              -            fill_window(s);
              -            if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
              -
              -            if (s->lookahead == 0) break; /* flush the current block */
              -        }
              -        Assert(s->block_start >= 0L, "block gone");
              -
              -        s->strstart += s->lookahead;
              -        s->lookahead = 0;
              -
              -        /* Emit a stored block if pending_buf will be full: */
              -        max_start = s->block_start + max_block_size;
              -        if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
              -            /* strstart == 0 is possible when wraparound on 16-bit machine */
              -            s->lookahead = (uInt)(s->strstart - max_start);
              -            s->strstart = (uInt)max_start;
              -            FLUSH_BLOCK(s, 0);
              -        }
              -        /* Flush if we may have to slide, otherwise block_start may become
              -         * negative and the data will be gone:
              +    /* Copy as many min_block or larger stored blocks directly to next_out as
              +     * possible. If flushing, copy the remaining available input to next_out as
              +     * stored blocks, if there is enough space.
              +     */
              +    unsigned len, left, have, last = 0;
              +    unsigned used = s->strm->avail_in;
              +    do {
              +        /* Set len to the maximum size block that we can copy directly with the
              +         * available input data and output space. Set left to how much of that
              +         * would be copied from what's left in the window.
                        */
              -        if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
              -            FLUSH_BLOCK(s, 0);
              +        len = MAX_STORED;       /* maximum deflate stored block length */
              +        have = (s->bi_valid + 42) >> 3;         /* number of header bytes */
              +        if (s->strm->avail_out < have)          /* need room for header */
              +            break;
              +            /* maximum stored block length that will fit in avail_out: */
              +        have = s->strm->avail_out - have;
              +        left = s->strstart - s->block_start;    /* bytes left in window */
              +        if (len > (ulg)left + s->strm->avail_in)
              +            len = left + s->strm->avail_in;     /* limit len to the input */
              +        if (len > have)
              +            len = have;                         /* limit len to the output */
              +
              +        /* If the stored block would be less than min_block in length, or if
              +         * unable to copy all of the available input when flushing, then try
              +         * copying to the window and the pending buffer instead. Also don't
              +         * write an empty block when flushing -- deflate() does that.
              +         */
              +        if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
              +                                flush == Z_NO_FLUSH ||
              +                                len != left + s->strm->avail_in))
              +            break;
              +
              +        /* Make a dummy stored block in pending to get the header bytes,
              +         * including any pending bits. This also updates the debugging counts.
              +         */
              +        last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
              +        _tr_stored_block(s, (char *)0, 0L, last);
              +
              +        /* Replace the lengths in the dummy stored block with len. */
              +        s->pending_buf[s->pending - 4] = len;
              +        s->pending_buf[s->pending - 3] = len >> 8;
              +        s->pending_buf[s->pending - 2] = ~len;
              +        s->pending_buf[s->pending - 1] = ~len >> 8;
              +
              +        /* Write the stored block header bytes. */
              +        flush_pending(s->strm);
              +
              +#ifdef ZLIB_DEBUG
              +        /* Update debugging counts for the data about to be copied. */
              +        s->compressed_len += len << 3;
              +        s->bits_sent += len << 3;
              +#endif
              +
              +        /* Copy uncompressed bytes from the window to next_out. */
              +        if (left) {
              +            if (left > len)
              +                left = len;
              +            zmemcpy(s->strm->next_out, s->window + s->block_start, left);
              +            s->strm->next_out += left;
              +            s->strm->avail_out -= left;
              +            s->strm->total_out += left;
              +            s->block_start += left;
              +            len -= left;
                       }
              +
              +        /* Copy uncompressed bytes directly from next_in to next_out, updating
              +         * the check value.
              +         */
              +        if (len) {
              +            read_buf(s->strm, s->strm->next_out, len);
              +            s->strm->next_out += len;
              +            s->strm->avail_out -= len;
              +            s->strm->total_out += len;
              +        }
              +    } while (last == 0);
              +
              +    /* Update the sliding window with the last s->w_size bytes of the copied
              +     * data, or append all of the copied data to the existing window if less
              +     * than s->w_size bytes were copied. Also update the number of bytes to
              +     * insert in the hash tables, in the event that deflateParams() switches to
              +     * a non-zero compression level.
              +     */
              +    used -= s->strm->avail_in;      /* number of input bytes directly copied */
              +    if (used) {
              +        /* If any input was used, then no unused input remains in the window,
              +         * therefore s->block_start == s->strstart.
              +         */
              +        if (used >= s->w_size) {    /* supplant the previous history */
              +            s->matches = 2;         /* clear hash */
              +            zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
              +            s->strstart = s->w_size;
              +        }
              +        else {
              +            if (s->window_size - s->strstart <= used) {
              +                /* Slide the window down. */
              +                s->strstart -= s->w_size;
              +                zmemcpy(s->window, s->window + s->w_size, s->strstart);
              +                if (s->matches < 2)
              +                    s->matches++;   /* add a pending slide_hash() */
              +            }
              +            zmemcpy(s->window + s->strstart, s->strm->next_in - used, used);
              +            s->strstart += used;
              +        }
              +        s->block_start = s->strstart;
              +        s->insert += MIN(used, s->w_size - s->insert);
                   }
              -    s->insert = 0;
              -    if (flush == Z_FINISH) {
              -        FLUSH_BLOCK(s, 1);
              +    if (s->high_water < s->strstart)
              +        s->high_water = s->strstart;
              +
              +    /* If the last block was written to next_out, then done. */
              +    if (last)
                       return finish_done;
              +
              +    /* If flushing and all input has been consumed, then done. */
              +    if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
              +        s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
              +        return block_done;
              +
              +    /* Fill the window with any remaining input. */
              +    have = s->window_size - s->strstart - 1;
              +    if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
              +        /* Slide the window down. */
              +        s->block_start -= s->w_size;
              +        s->strstart -= s->w_size;
              +        zmemcpy(s->window, s->window + s->w_size, s->strstart);
              +        if (s->matches < 2)
              +            s->matches++;           /* add a pending slide_hash() */
              +        have += s->w_size;          /* more space now */
                   }
              -    if ((long)s->strstart > s->block_start)
              -        FLUSH_BLOCK(s, 0);
              -    return block_done;
              +    if (have > s->strm->avail_in)
              +        have = s->strm->avail_in;
              +    if (have) {
              +        read_buf(s->strm, s->window + s->strstart, have);
              +        s->strstart += have;
              +    }
              +    if (s->high_water < s->strstart)
              +        s->high_water = s->strstart;
              +
              +    /* There was not enough avail_out to write a complete worthy or flushed
              +     * stored block to next_out. Write a stored block to pending instead, if we
              +     * have enough input for a worthy block, or if flushing and there is enough
              +     * room for the remaining input as a stored block in the pending buffer.
              +     */
              +    have = (s->bi_valid + 42) >> 3;         /* number of header bytes */
              +        /* maximum stored block length that will fit in pending: */
              +    have = MIN(s->pending_buf_size - have, MAX_STORED);
              +    min_block = MIN(have, s->w_size);
              +    left = s->strstart - s->block_start;
              +    if (left >= min_block ||
              +        ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
              +         s->strm->avail_in == 0 && left <= have)) {
              +        len = MIN(left, have);
              +        last = flush == Z_FINISH && s->strm->avail_in == 0 &&
              +               len == left ? 1 : 0;
              +        _tr_stored_block(s, (charf *)s->window + s->block_start, len, last);
              +        s->block_start += len;
              +        flush_pending(s->strm);
              +    }
              +
              +    /* We've done all we can with the available input and output. */
              +    return last ? finish_started : need_more;
               }
               
               /* ===========================================================================
              @@ -1916,7 +2112,7 @@ local block_state deflate_rle(s, flush)
                                        prev == *++scan && prev == *++scan &&
                                        prev == *++scan && prev == *++scan &&
                                        scan < strend);
              -                s->match_length = MAX_MATCH - (int)(strend - scan);
              +                s->match_length = MAX_MATCH - (uInt)(strend - scan);
                               if (s->match_length > s->lookahead)
                                   s->match_length = s->lookahead;
                           }
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/deflate.h b/jdk/src/java.base/share/native/libzip/zlib/deflate.h
              similarity index 93%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/deflate.h
              rename to jdk/src/java.base/share/native/libzip/zlib/deflate.h
              index 8be47fa013b..183c22d430a 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/deflate.h
              +++ b/jdk/src/java.base/share/native/libzip/zlib/deflate.h
              @@ -23,7 +23,7 @@
                */
               
               /* deflate.h -- internal compression state
              - * Copyright (C) 1995-2012 Jean-loup Gailly
              + * Copyright (C) 1995-2016 Jean-loup Gailly
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -75,13 +75,16 @@
               #define Buf_size 16
               /* size of bit buffer in bi_buf */
               
              -#define INIT_STATE    42
              -#define EXTRA_STATE   69
              -#define NAME_STATE    73
              -#define COMMENT_STATE 91
              -#define HCRC_STATE   103
              -#define BUSY_STATE   113
              -#define FINISH_STATE 666
              +#define INIT_STATE    42    /* zlib header -> BUSY_STATE */
              +#ifdef GZIP
              +#  define GZIP_STATE  57    /* gzip header -> BUSY_STATE | EXTRA_STATE */
              +#endif
              +#define EXTRA_STATE   69    /* gzip extra block -> NAME_STATE */
              +#define NAME_STATE    73    /* gzip file name -> COMMENT_STATE */
              +#define COMMENT_STATE 91    /* gzip comment -> HCRC_STATE */
              +#define HCRC_STATE   103    /* gzip header CRC -> BUSY_STATE */
              +#define BUSY_STATE   113    /* deflate -> FINISH_STATE */
              +#define FINISH_STATE 666    /* stream complete */
               /* Stream status */
               
               
              @@ -107,7 +110,7 @@ typedef struct static_tree_desc_s  static_tree_desc;
               typedef struct tree_desc_s {
                   ct_data *dyn_tree;           /* the dynamic tree */
                   int     max_code;            /* largest code with non zero frequency */
              -    static_tree_desc *stat_desc; /* the corresponding static tree */
              +    const static_tree_desc *stat_desc;  /* the corresponding static tree */
               } FAR tree_desc;
               
               typedef ush Pos;
              @@ -124,10 +127,10 @@ typedef struct internal_state {
                   Bytef *pending_buf;  /* output still pending */
                   ulg   pending_buf_size; /* size of pending_buf */
                   Bytef *pending_out;  /* next pending byte to output to the stream */
              -    uInt   pending;      /* nb of bytes in the pending buffer */
              +    ulg   pending;       /* nb of bytes in the pending buffer */
                   int   wrap;          /* bit 0 true for zlib, bit 1 true for gzip */
                   gz_headerp  gzhead;  /* gzip header information to write */
              -    uInt   gzindex;      /* where in extra, name, or comment */
              +    ulg   gzindex;       /* where in extra, name, or comment */
                   Byte  method;        /* can only be DEFLATED */
                   int   last_flush;    /* value of flush param for previous deflate call */
               
              @@ -273,7 +276,7 @@ typedef struct internal_state {
                   uInt matches;       /* number of string matches in current block */
                   uInt insert;        /* bytes at end of window left to insert */
               
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                   ulg compressed_len; /* total bit length of compressed file mod 2^32 */
                   ulg bits_sent;      /* bit length of compressed data sent mod 2^32 */
               #endif
              @@ -299,7 +302,7 @@ typedef struct internal_state {
               /* Output a byte on the stream.
                * IN assertion: there is enough room in pending_buf.
                */
              -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
              +#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
               
               
               #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
              @@ -333,7 +336,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
                * used.
                */
               
              -#ifndef DEBUG
              +#ifndef ZLIB_DEBUG
               /* Inline versions of _tr_tally for speed: */
               
               #if defined(GEN_TREES_H) || !defined(STDC)
              @@ -352,8 +355,8 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
                   flush = (s->last_lit == s->lit_bufsize-1); \
                  }
               # define _tr_tally_dist(s, distance, length, flush) \
              -  { uch len = (length); \
              -    ush dist = (distance); \
              +  { uch len = (uch)(length); \
              +    ush dist = (ush)(distance); \
                   s->d_buf[s->last_lit] = dist; \
                   s->l_buf[s->last_lit++] = len; \
                   dist--; \
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzclose.c b/jdk/src/java.base/share/native/libzip/zlib/gzclose.c
              similarity index 100%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzclose.c
              rename to jdk/src/java.base/share/native/libzip/zlib/gzclose.c
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzguts.h b/jdk/src/java.base/share/native/libzip/zlib/gzguts.h
              similarity index 91%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzguts.h
              rename to jdk/src/java.base/share/native/libzip/zlib/gzguts.h
              index 5889f45c784..26464b4e6c8 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzguts.h
              +++ b/jdk/src/java.base/share/native/libzip/zlib/gzguts.h
              @@ -23,7 +23,7 @@
                */
               
               /* gzguts.h -- zlib internal header definitions for gz* operations
              - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
              + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -49,6 +49,10 @@
               #  include 
               #  include 
               #endif
              +
              +#ifndef _POSIX_SOURCE
              +#  define _POSIX_SOURCE
              +#endif
               #include 
               
               #ifdef _WIN32
              @@ -59,6 +63,10 @@
               #  include 
               #endif
               
              +#if defined(_WIN32) || defined(__CYGWIN__)
              +#  define WIDECHAR
              +#endif
              +
               #ifdef WINAPI_FAMILY
               #  define open _open
               #  define read _read
              @@ -119,18 +127,19 @@
               #  endif
               #endif
               
              -/* unlike snprintf (which is required in C99, yet still not supported by
              -   Microsoft more than a decade later!), _snprintf does not guarantee null
              -   termination of the result -- however this is only used in gzlib.c where
              +/* unlike snprintf (which is required in C99), _snprintf does not guarantee
              +   null termination of the result -- however this is only used in gzlib.c where
                  the result is assured to fit in the space provided */
              -#ifdef _MSC_VER
              +#if defined(_MSC_VER) && _MSC_VER < 1900
               #  define snprintf _snprintf
               #endif
               
               #ifndef local
               #  define local static
               #endif
              -/* compile with -Dlocal if your debugger can't find static symbols */
              +/* since "static" is used to mean two completely different things in C, we
              +   define "local" for the non-static meaning of "static", for readability
              +   (compile with -Dlocal if your debugger can't find static symbols) */
               
               /* gz* functions always use library allocation functions */
               #ifndef STDC
              @@ -194,7 +203,7 @@ typedef struct {
                   char *path;             /* path or fd for error messages */
                   unsigned size;          /* buffer size, zero if not allocated yet */
                   unsigned want;          /* requested buffer size, default is GZBUFSIZE */
              -    unsigned char *in;      /* input buffer */
              +    unsigned char *in;      /* input buffer (double-sized when writing) */
                   unsigned char *out;     /* output buffer (double-sized when reading) */
                   int direct;             /* 0 if processing gzip, 1 if transparent */
                       /* just for reading */
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzlib.c b/jdk/src/java.base/share/native/libzip/zlib/gzlib.c
              similarity index 96%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzlib.c
              rename to jdk/src/java.base/share/native/libzip/zlib/gzlib.c
              index 4dce9b96ef7..a814dd8c7b6 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzlib.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/gzlib.c
              @@ -23,13 +23,13 @@
                */
               
               /* gzlib.c -- zlib functions common to reading and writing gzip files
              - * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
              + * Copyright (C) 2004-2017 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
               #include "gzguts.h"
               
              -#if defined(_WIN32) && !defined(__BORLANDC__)
              +#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
               #  define LSEEK _lseeki64
               #else
               #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
              @@ -118,7 +118,7 @@ local gzFile gz_open(path, fd, mode)
                   const char *mode;
               {
                   gz_statep state;
              -    size_t len;
              +    z_size_t len;
                   int oflag;
               #ifdef O_CLOEXEC
                   int cloexec = 0;
              @@ -212,10 +212,10 @@ local gzFile gz_open(path, fd, mode)
                   }
               
                   /* save the path name for error messages */
              -#ifdef _WIN32
              +#ifdef WIDECHAR
                   if (fd == -2) {
                       len = wcstombs(NULL, path, 0);
              -        if (len == (size_t)-1)
              +        if (len == (z_size_t)-1)
                           len = 0;
                   }
                   else
              @@ -226,7 +226,7 @@ local gzFile gz_open(path, fd, mode)
                       free(state);
                       return NULL;
                   }
              -#ifdef _WIN32
              +#ifdef WIDECHAR
                   if (fd == -2)
                       if (len)
                           wcstombs(state->path, path, len + 1);
              @@ -235,7 +235,7 @@ local gzFile gz_open(path, fd, mode)
                   else
               #endif
               #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
              -        snprintf(state->path, len + 1, "%s", (const char *)path);
              +        (void)snprintf(state->path, len + 1, "%s", (const char *)path);
               #else
                       strcpy(state->path, path);
               #endif
              @@ -263,7 +263,7 @@ local gzFile gz_open(path, fd, mode)
               
                   /* open the file with the appropriate flags (or just use fd) */
                   state->fd = fd > -1 ? fd : (
              -#ifdef _WIN32
              +#ifdef WIDECHAR
                       fd == -2 ? _wopen(path, oflag, 0666) :
               #endif
                       open((const char *)path, oflag, 0666));
              @@ -272,8 +272,10 @@ local gzFile gz_open(path, fd, mode)
                       free(state);
                       return NULL;
                   }
              -    if (state->mode == GZ_APPEND)
              +    if (state->mode == GZ_APPEND) {
              +        LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */
                       state->mode = GZ_WRITE;         /* simplify later checks */
              +    }
               
                   /* save the current position for rewinding (only if reading) */
                   if (state->mode == GZ_READ) {
              @@ -315,7 +317,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
                   if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
                       return NULL;
               #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
              -    snprintf(path, 7 + 3 * sizeof(int), "", fd); /* for debugging */
              +    (void)snprintf(path, 7 + 3 * sizeof(int), "", fd);
               #else
                   sprintf(path, "", fd);   /* for debugging */
               #endif
              @@ -325,7 +327,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
               }
               
               /* -- see zlib.h -- */
              -#ifdef _WIN32
              +#ifdef WIDECHAR
               gzFile ZEXPORT gzopen_w(path, mode)
                   const wchar_t *path;
                   const char *mode;
              @@ -353,6 +355,8 @@ int ZEXPORT gzbuffer(file, size)
                       return -1;
               
                   /* check and set requested size */
              +    if ((size << 1) < size)
              +        return -1;              /* need to be able to double it */
                   if (size < 2)
                       size = 2;               /* need two bytes to check magic header */
                   state->want = size;
              @@ -628,14 +632,13 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
                       return;
                   }
               #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
              -    snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
              -             "%s%s%s", state->path, ": ", msg);
              +    (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
              +                   "%s%s%s", state->path, ": ", msg);
               #else
                   strcpy(state->msg, state->path);
                   strcat(state->msg, ": ");
                   strcat(state->msg, msg);
               #endif
              -    return;
               }
               
               #ifndef INT_MAX
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzread.c b/jdk/src/java.base/share/native/libzip/zlib/gzread.c
              similarity index 86%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzread.c
              rename to jdk/src/java.base/share/native/libzip/zlib/gzread.c
              index cd87098b95a..14394c59a9b 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzread.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/gzread.c
              @@ -23,7 +23,7 @@
                */
               
               /* gzread.c -- zlib functions for reading gzip files
              - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
              + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -36,6 +36,7 @@ local int gz_look OF((gz_statep));
               local int gz_decomp OF((gz_statep));
               local int gz_fetch OF((gz_statep));
               local int gz_skip OF((gz_statep, z_off64_t));
              +local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
               
               /* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
                  state->fd, and update state->eof, state->err, and state->msg as appropriate.
              @@ -48,13 +49,17 @@ local int gz_load(state, buf, len, have)
                   unsigned *have;
               {
                   int ret;
              +    unsigned get, max = ((unsigned)-1 >> 2) + 1;
               
                   *have = 0;
                   do {
              -        ret = read(state->fd, buf + *have, len - *have);
              +        get = len - *have;
              +        if (get > max)
              +            get = max;
              +        ret = read(state->fd, buf + *have, get);
                       if (ret <= 0)
                           break;
              -        *have += ret;
              +        *have += (unsigned)ret;
                   } while (*have < len);
                   if (ret < 0) {
                       gz_error(state, Z_ERRNO, zstrerror());
              @@ -118,10 +123,8 @@ local int gz_look(state)
                       state->in = (unsigned char *)malloc(state->want);
                       state->out = (unsigned char *)malloc(state->want << 1);
                       if (state->in == NULL || state->out == NULL) {
              -            if (state->out != NULL)
              -                free(state->out);
              -            if (state->in != NULL)
              -                free(state->in);
              +            free(state->out);
              +            free(state->in);
                           gz_error(state, Z_MEM_ERROR, "out of memory");
                           return -1;
                       }
              @@ -308,33 +311,17 @@ local int gz_skip(state, len)
                   return 0;
               }
               
              -/* -- see zlib.h -- */
              -int ZEXPORT gzread(file, buf, len)
              -    gzFile file;
              -    voidp buf;
              -    unsigned len;
              -{
              -    unsigned got, n;
              +/* Read len bytes into buf from file, or less than len up to the end of the
              +   input.  Return the number of bytes read.  If zero is returned, either the
              +   end of file was reached, or there was an error.  state->err must be
              +   consulted in that case to determine which. */
              +local z_size_t gz_read(state, buf, len)
                   gz_statep state;
              -    z_streamp strm;
              -
              -    /* get internal structure */
              -    if (file == NULL)
              -        return -1;
              -    state = (gz_statep)file;
              -    strm = &(state->strm);
              -
              -    /* check that we're reading and that there's no (serious) error */
              -    if (state->mode != GZ_READ ||
              -            (state->err != Z_OK && state->err != Z_BUF_ERROR))
              -        return -1;
              -
              -    /* since an int is returned, make sure len fits in one, otherwise return
              -       with an error (this avoids the flaw in the interface) */
              -    if ((int)len < 0) {
              -        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
              -        return -1;
              -    }
              +    voidp buf;
              +    z_size_t len;
              +{
              +    z_size_t got;
              +    unsigned n;
               
                   /* if len is zero, avoid unnecessary operations */
                   if (len == 0)
              @@ -344,32 +331,38 @@ int ZEXPORT gzread(file, buf, len)
                   if (state->seek) {
                       state->seek = 0;
                       if (gz_skip(state, state->skip) == -1)
              -            return -1;
              +            return 0;
                   }
               
                   /* get len bytes to buf, or less than len if at the end */
                   got = 0;
                   do {
              +        /* set n to the maximum amount of len that fits in an unsigned int */
              +        n = -1;
              +        if (n > len)
              +            n = (unsigned)len;
              +
                       /* first just try copying data from the output buffer */
                       if (state->x.have) {
              -            n = state->x.have > len ? len : state->x.have;
              +            if (state->x.have < n)
              +                n = state->x.have;
                           memcpy(buf, state->x.next, n);
                           state->x.next += n;
                           state->x.have -= n;
                       }
               
                       /* output buffer empty -- return if we're at the end of the input */
              -        else if (state->eof && strm->avail_in == 0) {
              +        else if (state->eof && state->strm.avail_in == 0) {
                           state->past = 1;        /* tried to read past end */
                           break;
                       }
               
                       /* need output data -- for small len or new stream load up our output
                          buffer */
              -        else if (state->how == LOOK || len < (state->size << 1)) {
              +        else if (state->how == LOOK || n < (state->size << 1)) {
                           /* get more output, looking for header if required */
                           if (gz_fetch(state) == -1)
              -                return -1;
              +                return 0;
                           continue;       /* no progress yet -- go back to copy above */
                           /* the copy above assures that we will leave with space in the
                              output buffer, allowing at least one gzungetc() to succeed */
              @@ -377,16 +370,16 @@ int ZEXPORT gzread(file, buf, len)
               
                       /* large len -- read directly into user buffer */
                       else if (state->how == COPY) {      /* read directly */
              -            if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
              -                return -1;
              +            if (gz_load(state, (unsigned char *)buf, n, &n) == -1)
              +                return 0;
                       }
               
                       /* large len -- decompress directly into user buffer */
                       else {  /* state->how == GZIP */
              -            strm->avail_out = len;
              -            strm->next_out = (unsigned char *)buf;
              +            state->strm.avail_out = n;
              +            state->strm.next_out = (unsigned char *)buf;
                           if (gz_decomp(state) == -1)
              -                return -1;
              +                return 0;
                           n = state->x.have;
                           state->x.have = 0;
                       }
              @@ -398,8 +391,75 @@ int ZEXPORT gzread(file, buf, len)
                       state->x.pos += n;
                   } while (len);
               
              -    /* return number of bytes read into user buffer (will fit in int) */
              -    return (int)got;
              +    /* return number of bytes read into user buffer */
              +    return got;
              +}
              +
              +/* -- see zlib.h -- */
              +int ZEXPORT gzread(file, buf, len)
              +    gzFile file;
              +    voidp buf;
              +    unsigned len;
              +{
              +    gz_statep state;
              +
              +    /* get internal structure */
              +    if (file == NULL)
              +        return -1;
              +    state = (gz_statep)file;
              +
              +    /* check that we're reading and that there's no (serious) error */
              +    if (state->mode != GZ_READ ||
              +            (state->err != Z_OK && state->err != Z_BUF_ERROR))
              +        return -1;
              +
              +    /* since an int is returned, make sure len fits in one, otherwise return
              +       with an error (this avoids a flaw in the interface) */
              +    if ((int)len < 0) {
              +        gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
              +        return -1;
              +    }
              +
              +    /* read len or fewer bytes to buf */
              +    len = (unsigned)gz_read(state, buf, len);
              +
              +    /* check for an error */
              +    if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
              +        return -1;
              +
              +    /* return the number of bytes read (this is assured to fit in an int) */
              +    return (int)len;
              +}
              +
              +/* -- see zlib.h -- */
              +z_size_t ZEXPORT gzfread(buf, size, nitems, file)
              +    voidp buf;
              +    z_size_t size;
              +    z_size_t nitems;
              +    gzFile file;
              +{
              +    z_size_t len;
              +    gz_statep state;
              +
              +    /* get internal structure */
              +    if (file == NULL)
              +        return 0;
              +    state = (gz_statep)file;
              +
              +    /* check that we're reading and that there's no (serious) error */
              +    if (state->mode != GZ_READ ||
              +            (state->err != Z_OK && state->err != Z_BUF_ERROR))
              +        return 0;
              +
              +    /* compute bytes to read -- error on overflow */
              +    len = nitems * size;
              +    if (size && len / size != nitems) {
              +        gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
              +        return 0;
              +    }
              +
              +    /* read len or fewer bytes to buf, return the number of full items read */
              +    return len ? gz_read(state, buf, len) / size : 0;
               }
               
               /* -- see zlib.h -- */
              @@ -432,8 +492,8 @@ int ZEXPORT gzgetc(file)
                       return *(state->x.next)++;
                   }
               
              -    /* nothing there -- try gzread() */
              -    ret = gzread(file, buf, 1);
              +    /* nothing there -- try gz_read() */
              +    ret = (int)gz_read(state, buf, 1);
                   return ret < 1 ? -1 : buf[0];
               }
               
              @@ -475,7 +535,7 @@ int ZEXPORT gzungetc(c, file)
                   if (state->x.have == 0) {
                       state->x.have = 1;
                       state->x.next = state->out + (state->size << 1) - 1;
              -        state->x.next[0] = c;
              +        state->x.next[0] = (unsigned char)c;
                       state->x.pos--;
                       state->past = 0;
                       return c;
              @@ -497,7 +557,7 @@ int ZEXPORT gzungetc(c, file)
                   }
                   state->x.have++;
                   state->x.next--;
              -    state->x.next[0] = c;
              +    state->x.next[0] = (unsigned char)c;
                   state->x.pos--;
                   state->past = 0;
                   return c;
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzwrite.c b/jdk/src/java.base/share/native/libzip/zlib/gzwrite.c
              similarity index 64%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzwrite.c
              rename to jdk/src/java.base/share/native/libzip/zlib/gzwrite.c
              index 1955cf763b4..7a73b7cadf3 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/gzwrite.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/gzwrite.c
              @@ -23,7 +23,7 @@
                */
               
               /* gzwrite.c -- zlib functions for writing gzip files
              - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
              + * Copyright (C) 2004-2017 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -33,17 +33,19 @@
               local int gz_init OF((gz_statep));
               local int gz_comp OF((gz_statep, int));
               local int gz_zero OF((gz_statep, z_off64_t));
              +local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
               
               /* Initialize state for writing a gzip file.  Mark initialization by setting
              -   state->size to non-zero.  Return -1 on failure or 0 on success. */
              +   state->size to non-zero.  Return -1 on a memory allocation failure, or 0 on
              +   success. */
               local int gz_init(state)
                   gz_statep state;
               {
                   int ret;
                   z_streamp strm = &(state->strm);
               
              -    /* allocate input buffer */
              -    state->in = (unsigned char *)malloc(state->want);
              +    /* allocate input buffer (double size for gzprintf) */
              +    state->in = (unsigned char *)malloc(state->want << 1);
                   if (state->in == NULL) {
                       gz_error(state, Z_MEM_ERROR, "out of memory");
                       return -1;
              @@ -71,6 +73,7 @@ local int gz_init(state)
                           gz_error(state, Z_MEM_ERROR, "out of memory");
                           return -1;
                       }
              +        strm->next_in = NULL;
                   }
               
                   /* mark state as initialized */
              @@ -86,17 +89,17 @@ local int gz_init(state)
               }
               
               /* Compress whatever is at avail_in and next_in and write to the output file.
              -   Return -1 if there is an error writing to the output file, otherwise 0.
              -   flush is assumed to be a valid deflate() flush value.  If flush is Z_FINISH,
              -   then the deflate() state is reset to start a new gzip stream.  If gz->direct
              -   is true, then simply write to the output file without compressing, and
              -   ignore flush. */
              +   Return -1 if there is an error writing to the output file or if gz_init()
              +   fails to allocate memory, otherwise 0.  flush is assumed to be a valid
              +   deflate() flush value.  If flush is Z_FINISH, then the deflate() state is
              +   reset to start a new gzip stream.  If gz->direct is true, then simply write
              +   to the output file without compressing, and ignore flush. */
               local int gz_comp(state, flush)
                   gz_statep state;
                   int flush;
               {
              -    int ret, got;
              -    unsigned have;
              +    int ret, writ;
              +    unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
                   z_streamp strm = &(state->strm);
               
                   /* allocate memory if this is the first time through */
              @@ -105,12 +108,16 @@ local int gz_comp(state, flush)
               
                   /* write directly if requested */
                   if (state->direct) {
              -        got = write(state->fd, strm->next_in, strm->avail_in);
              -        if (got < 0 || (unsigned)got != strm->avail_in) {
              -            gz_error(state, Z_ERRNO, zstrerror());
              -            return -1;
              +        while (strm->avail_in) {
              +            put = strm->avail_in > max ? max : strm->avail_in;
              +            writ = write(state->fd, strm->next_in, put);
              +            if (writ < 0) {
              +                gz_error(state, Z_ERRNO, zstrerror());
              +                return -1;
              +            }
              +            strm->avail_in -= (unsigned)writ;
              +            strm->next_in += writ;
                       }
              -        strm->avail_in = 0;
                       return 0;
                   }
               
              @@ -121,17 +128,21 @@ local int gz_comp(state, flush)
                          doing Z_FINISH then don't write until we get to Z_STREAM_END */
                       if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
                           (flush != Z_FINISH || ret == Z_STREAM_END))) {
              -            have = (unsigned)(strm->next_out - state->x.next);
              -            if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
              -                         (unsigned)got != have)) {
              -                gz_error(state, Z_ERRNO, zstrerror());
              -                return -1;
              +            while (strm->next_out > state->x.next) {
              +                put = strm->next_out - state->x.next > (int)max ? max :
              +                      (unsigned)(strm->next_out - state->x.next);
              +                writ = write(state->fd, state->x.next, put);
              +                if (writ < 0) {
              +                    gz_error(state, Z_ERRNO, zstrerror());
              +                    return -1;
              +                }
              +                state->x.next += writ;
                           }
                           if (strm->avail_out == 0) {
                               strm->avail_out = state->size;
                               strm->next_out = state->out;
              +                state->x.next = state->out;
                           }
              -            state->x.next = strm->next_out;
                       }
               
                       /* compress */
              @@ -153,7 +164,8 @@ local int gz_comp(state, flush)
                   return 0;
               }
               
              -/* Compress len zeros to output.  Return -1 on error, 0 on success. */
              +/* Compress len zeros to output.  Return -1 on a write error or memory
              +   allocation failure by gz_comp(), or 0 on success. */
               local int gz_zero(state, len)
                   gz_statep state;
                   z_off64_t len;
              @@ -185,32 +197,14 @@ local int gz_zero(state, len)
                   return 0;
               }
               
              -/* -- see zlib.h -- */
              -int ZEXPORT gzwrite(file, buf, len)
              -    gzFile file;
              -    voidpc buf;
              -    unsigned len;
              -{
              -    unsigned put = len;
              +/* Write len bytes from buf to file.  Return the number of bytes written.  If
              +   the returned value is less than len, then there was an error. */
              +local z_size_t gz_write(state, buf, len)
                   gz_statep state;
              -    z_streamp strm;
              -
              -    /* get internal structure */
              -    if (file == NULL)
              -        return 0;
              -    state = (gz_statep)file;
              -    strm = &(state->strm);
              -
              -    /* check that we're writing and that there's no error */
              -    if (state->mode != GZ_WRITE || state->err != Z_OK)
              -        return 0;
              -
              -    /* since an int is returned, make sure len fits in one, otherwise return
              -       with an error (this avoids the flaw in the interface) */
              -    if ((int)len < 0) {
              -        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
              -        return 0;
              -    }
              +    voidpc buf;
              +    z_size_t len;
              +{
              +    z_size_t put = len;
               
                   /* if len is zero, avoid unnecessary operations */
                   if (len == 0)
              @@ -233,14 +227,15 @@ int ZEXPORT gzwrite(file, buf, len)
                       do {
                           unsigned have, copy;
               
              -            if (strm->avail_in == 0)
              -                strm->next_in = state->in;
              -            have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
              +            if (state->strm.avail_in == 0)
              +                state->strm.next_in = state->in;
              +            have = (unsigned)((state->strm.next_in + state->strm.avail_in) -
              +                              state->in);
                           copy = state->size - have;
                           if (copy > len)
              -                copy = len;
              +                copy = (unsigned)len;
                           memcpy(state->in + have, buf, copy);
              -            strm->avail_in += copy;
              +            state->strm.avail_in += copy;
                           state->x.pos += copy;
                           buf = (const char *)buf + copy;
                           len -= copy;
              @@ -250,19 +245,83 @@ int ZEXPORT gzwrite(file, buf, len)
                   }
                   else {
                       /* consume whatever's left in the input buffer */
              -        if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
              +        if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
                           return 0;
               
                       /* directly compress user buffer to file */
              -        strm->avail_in = len;
              -        strm->next_in = (z_const Bytef *)buf;
              -        state->x.pos += len;
              -        if (gz_comp(state, Z_NO_FLUSH) == -1)
              -            return 0;
              +        state->strm.next_in = (z_const Bytef *)buf;
              +        do {
              +            unsigned n = (unsigned)-1;
              +            if (n > len)
              +                n = (unsigned)len;
              +            state->strm.avail_in = n;
              +            state->x.pos += n;
              +            if (gz_comp(state, Z_NO_FLUSH) == -1)
              +                return 0;
              +            len -= n;
              +        } while (len);
                   }
               
              -    /* input was all buffered or compressed (put will fit in int) */
              -    return (int)put;
              +    /* input was all buffered or compressed */
              +    return put;
              +}
              +
              +/* -- see zlib.h -- */
              +int ZEXPORT gzwrite(file, buf, len)
              +    gzFile file;
              +    voidpc buf;
              +    unsigned len;
              +{
              +    gz_statep state;
              +
              +    /* get internal structure */
              +    if (file == NULL)
              +        return 0;
              +    state = (gz_statep)file;
              +
              +    /* check that we're writing and that there's no error */
              +    if (state->mode != GZ_WRITE || state->err != Z_OK)
              +        return 0;
              +
              +    /* since an int is returned, make sure len fits in one, otherwise return
              +       with an error (this avoids a flaw in the interface) */
              +    if ((int)len < 0) {
              +        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
              +        return 0;
              +    }
              +
              +    /* write len bytes from buf (the return value will fit in an int) */
              +    return (int)gz_write(state, buf, len);
              +}
              +
              +/* -- see zlib.h -- */
              +z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
              +    voidpc buf;
              +    z_size_t size;
              +    z_size_t nitems;
              +    gzFile file;
              +{
              +    z_size_t len;
              +    gz_statep state;
              +
              +    /* get internal structure */
              +    if (file == NULL)
              +        return 0;
              +    state = (gz_statep)file;
              +
              +    /* check that we're writing and that there's no error */
              +    if (state->mode != GZ_WRITE || state->err != Z_OK)
              +        return 0;
              +
              +    /* compute bytes to read -- error on overflow */
              +    len = nitems * size;
              +    if (size && len / size != nitems) {
              +        gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
              +        return 0;
              +    }
              +
              +    /* write len bytes to buf, return the number of full items written */
              +    return len ? gz_write(state, buf, len) / size : 0;
               }
               
               /* -- see zlib.h -- */
              @@ -299,7 +358,7 @@ int ZEXPORT gzputc(file, c)
                           strm->next_in = state->in;
                       have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
                       if (have < state->size) {
              -            state->in[have] = c;
              +            state->in[have] = (unsigned char)c;
                           strm->avail_in++;
                           state->x.pos++;
                           return c & 0xff;
              @@ -307,8 +366,8 @@ int ZEXPORT gzputc(file, c)
                   }
               
                   /* no room in buffer or not initialized, use gz_write() */
              -    buf[0] = c;
              -    if (gzwrite(file, buf, 1) != 1)
              +    buf[0] = (unsigned char)c;
              +    if (gz_write(state, buf, 1) != 1)
                       return -1;
                   return c & 0xff;
               }
              @@ -319,11 +378,21 @@ int ZEXPORT gzputs(file, str)
                   const char *str;
               {
                   int ret;
              -    unsigned len;
              +    z_size_t len;
              +    gz_statep state;
              +
              +    /* get internal structure */
              +    if (file == NULL)
              +        return -1;
              +    state = (gz_statep)file;
              +
              +    /* check that we're writing and that there's no error */
              +    if (state->mode != GZ_WRITE || state->err != Z_OK)
              +        return -1;
               
                   /* write string */
              -    len = (unsigned)strlen(str);
              -    ret = gzwrite(file, str, len);
              +    len = strlen(str);
              +    ret = (int)gz_write(state, str, len);
                   return ret == 0 && len != 0 ? -1 : ret;
               }
               
              @@ -333,63 +402,73 @@ int ZEXPORT gzputs(file, str)
               /* -- see zlib.h -- */
               int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
               {
              -    int size, len;
              +    int len;
              +    unsigned left;
              +    char *next;
                   gz_statep state;
                   z_streamp strm;
               
                   /* get internal structure */
                   if (file == NULL)
              -        return -1;
              +        return Z_STREAM_ERROR;
                   state = (gz_statep)file;
                   strm = &(state->strm);
               
                   /* check that we're writing and that there's no error */
                   if (state->mode != GZ_WRITE || state->err != Z_OK)
              -        return 0;
              +        return Z_STREAM_ERROR;
               
                   /* make sure we have some buffer space */
                   if (state->size == 0 && gz_init(state) == -1)
              -        return 0;
              +        return state->err;
               
                   /* check for seek request */
                   if (state->seek) {
                       state->seek = 0;
                       if (gz_zero(state, state->skip) == -1)
              -            return 0;
              +            return state->err;
                   }
               
              -    /* consume whatever's left in the input buffer */
              -    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
              -        return 0;
              -
              -    /* do the printf() into the input buffer, put length in len */
              -    size = (int)(state->size);
              -    state->in[size - 1] = 0;
              +    /* do the printf() into the input buffer, put length in len -- the input
              +       buffer is double-sized just for this function, so there is guaranteed to
              +       be state->size bytes available after the current contents */
              +    if (strm->avail_in == 0)
              +        strm->next_in = state->in;
              +    next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
              +    next[state->size - 1] = 0;
               #ifdef NO_vsnprintf
               #  ifdef HAS_vsprintf_void
              -    (void)vsprintf((char *)(state->in), format, va);
              -    for (len = 0; len < size; len++)
              -        if (state->in[len] == 0) break;
              +    (void)vsprintf(next, format, va);
              +    for (len = 0; len < state->size; len++)
              +        if (next[len] == 0) break;
               #  else
              -    len = vsprintf((char *)(state->in), format, va);
              +    len = vsprintf(next, format, va);
               #  endif
               #else
               #  ifdef HAS_vsnprintf_void
              -    (void)vsnprintf((char *)(state->in), size, format, va);
              -    len = strlen((char *)(state->in));
              +    (void)vsnprintf(next, state->size, format, va);
              +    len = strlen(next);
               #  else
              -    len = vsnprintf((char *)(state->in), size, format, va);
              +    len = vsnprintf(next, state->size, format, va);
               #  endif
               #endif
               
                   /* check that printf() results fit in buffer */
              -    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
              +    if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
                       return 0;
               
              -    /* update buffer and position, defer compression until needed */
              -    strm->avail_in = (unsigned)len;
              -    strm->next_in = state->in;
              +    /* update buffer and position, compress first half if past that */
              +    strm->avail_in += (unsigned)len;
                   state->x.pos += len;
              +    if (strm->avail_in >= state->size) {
              +        left = strm->avail_in - state->size;
              +        strm->avail_in = state->size;
              +        if (gz_comp(state, Z_NO_FLUSH) == -1)
              +            return state->err;
              +        memcpy(state->in, state->in + state->size, left);
              +        strm->next_in = state->in;
              +        strm->avail_in = left;
              +    }
                   return len;
               }
               
              @@ -414,73 +493,82 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
                   int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
                       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
               {
              -    int size, len;
              +    unsigned len, left;
              +    char *next;
                   gz_statep state;
                   z_streamp strm;
               
                   /* get internal structure */
                   if (file == NULL)
              -        return -1;
              +        return Z_STREAM_ERROR;
                   state = (gz_statep)file;
                   strm = &(state->strm);
               
                   /* check that can really pass pointer in ints */
                   if (sizeof(int) != sizeof(void *))
              -        return 0;
              +        return Z_STREAM_ERROR;
               
                   /* check that we're writing and that there's no error */
                   if (state->mode != GZ_WRITE || state->err != Z_OK)
              -        return 0;
              +        return Z_STREAM_ERROR;
               
                   /* make sure we have some buffer space */
                   if (state->size == 0 && gz_init(state) == -1)
              -        return 0;
              +        return state->error;
               
                   /* check for seek request */
                   if (state->seek) {
                       state->seek = 0;
                       if (gz_zero(state, state->skip) == -1)
              -            return 0;
              +            return state->error;
                   }
               
              -    /* consume whatever's left in the input buffer */
              -    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
              -        return 0;
              -
              -    /* do the printf() into the input buffer, put length in len */
              -    size = (int)(state->size);
              -    state->in[size - 1] = 0;
              +    /* do the printf() into the input buffer, put length in len -- the input
              +       buffer is double-sized just for this function, so there is guaranteed to
              +       be state->size bytes available after the current contents */
              +    if (strm->avail_in == 0)
              +        strm->next_in = state->in;
              +    next = (char *)(strm->next_in + strm->avail_in);
              +    next[state->size - 1] = 0;
               #ifdef NO_snprintf
               #  ifdef HAS_sprintf_void
              -    sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
              -            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
              +    sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
              +            a13, a14, a15, a16, a17, a18, a19, a20);
                   for (len = 0; len < size; len++)
              -        if (state->in[len] == 0) break;
              +        if (next[len] == 0)
              +            break;
               #  else
              -    len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
              -                  a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
              +    len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
              +                  a12, a13, a14, a15, a16, a17, a18, a19, a20);
               #  endif
               #else
               #  ifdef HAS_snprintf_void
              -    snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
              -             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
              -    len = strlen((char *)(state->in));
              +    snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,
              +             a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
              +    len = strlen(next);
               #  else
              -    len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
              -                   a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
              -                   a19, a20);
              +    len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,
              +                   a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
               #  endif
               #endif
               
                   /* check that printf() results fit in buffer */
              -    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
              +    if (len == 0 || len >= state->size || next[state->size - 1] != 0)
                       return 0;
               
              -    /* update buffer and position, defer compression until needed */
              -    strm->avail_in = (unsigned)len;
              -    strm->next_in = state->in;
              +    /* update buffer and position, compress first half if past that */
              +    strm->avail_in += len;
                   state->x.pos += len;
              -    return len;
              +    if (strm->avail_in >= state->size) {
              +        left = strm->avail_in - state->size;
              +        strm->avail_in = state->size;
              +        if (gz_comp(state, Z_NO_FLUSH) == -1)
              +            return state->err;
              +        memcpy(state->in, state->in + state->size, left);
              +        strm->next_in = state->in;
              +        strm->avail_in = left;
              +    }
              +    return (int)len;
               }
               
               #endif
              @@ -494,7 +582,7 @@ int ZEXPORT gzflush(file, flush)
               
                   /* get internal structure */
                   if (file == NULL)
              -        return -1;
              +        return Z_STREAM_ERROR;
                   state = (gz_statep)file;
               
                   /* check that we're writing and that there's no error */
              @@ -509,11 +597,11 @@ int ZEXPORT gzflush(file, flush)
                   if (state->seek) {
                       state->seek = 0;
                       if (gz_zero(state, state->skip) == -1)
              -            return -1;
              +            return state->err;
                   }
               
                   /* compress remaining data with requested flush */
              -    gz_comp(state, flush);
              +    (void)gz_comp(state, flush);
                   return state->err;
               }
               
              @@ -544,13 +632,13 @@ int ZEXPORT gzsetparams(file, level, strategy)
                   if (state->seek) {
                       state->seek = 0;
                       if (gz_zero(state, state->skip) == -1)
              -            return -1;
              +            return state->err;
                   }
               
                   /* change compression parameters for subsequent input */
                   if (state->size) {
                       /* flush previous input with previous parameters before changing */
              -        if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
              +        if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
                           return state->err;
                       deflateParams(strm, level, strategy);
                   }
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/infback.c b/jdk/src/java.base/share/native/libzip/zlib/infback.c
              similarity index 99%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/infback.c
              rename to jdk/src/java.base/share/native/libzip/zlib/infback.c
              index 7001b4bfe62..4c8283909c1 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/infback.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/infback.c
              @@ -23,7 +23,7 @@
                */
               
               /* infback.c -- inflate using a call-back interface
              - * Copyright (C) 1995-2011 Mark Adler
              + * Copyright (C) 1995-2016 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -85,7 +85,7 @@ int stream_size;
                   Tracev((stderr, "inflate: allocated\n"));
                   strm->state = (struct internal_state FAR *)state;
                   state->dmax = 32768U;
              -    state->wbits = windowBits;
              +    state->wbits = (uInt)windowBits;
                   state->wsize = 1U << windowBits;
                   state->window = window;
                   state->wnext = 0;
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inffast.c b/jdk/src/java.base/share/native/libzip/zlib/inffast.c
              similarity index 86%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/inffast.c
              rename to jdk/src/java.base/share/native/libzip/zlib/inffast.c
              index 4b9cddd7040..4bfc995f4cc 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inffast.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/inffast.c
              @@ -23,7 +23,7 @@
                */
               
               /* inffast.c -- fast decoding
              - * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
              + * Copyright (C) 1995-2017 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -32,26 +32,9 @@
               #include "inflate.h"
               #include "inffast.h"
               
              -#ifndef ASMINF
              -
              -/* Allow machine dependent optimization for post-increment or pre-increment.
              -   Based on testing to date,
              -   Pre-increment preferred for:
              -   - PowerPC G3 (Adler)
              -   - MIPS R5000 (Randers-Pehrson)
              -   Post-increment preferred for:
              -   - none
              -   No measurable difference:
              -   - Pentium III (Anderson)
              -   - M68060 (Nikl)
              - */
              -#ifdef POSTINC
              -#  define OFF 0
              -#  define PUP(a) *(a)++
              +#ifdef ASMINF
              +#  pragma message("Assembler code may have bugs -- use at your own risk")
               #else
              -#  define OFF 1
              -#  define PUP(a) *++(a)
              -#endif
               
               /*
                  Decode literal, length, and distance codes and write out the resulting
              @@ -120,9 +103,9 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
               
                   /* copy state to local variables */
                   state = (struct inflate_state FAR *)strm->state;
              -    in = strm->next_in - OFF;
              +    in = strm->next_in;
                   last = in + (strm->avail_in - 5);
              -    out = strm->next_out - OFF;
              +    out = strm->next_out;
                   beg = out - (start - strm->avail_out);
                   end = out + (strm->avail_out - 257);
               #ifdef INFLATE_STRICT
              @@ -143,9 +126,9 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                      input data or output space */
                   do {
                       if (bits < 15) {
              -            hold += (unsigned long)(PUP(in)) << bits;
              +            hold += (unsigned long)(*in++) << bits;
                           bits += 8;
              -            hold += (unsigned long)(PUP(in)) << bits;
              +            hold += (unsigned long)(*in++) << bits;
                           bits += 8;
                       }
                       here = lcode[hold & lmask];
              @@ -158,14 +141,14 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                           Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
                                   "inflate:         literal '%c'\n" :
                                   "inflate:         literal 0x%02x\n", here.val));
              -            PUP(out) = (unsigned char)(here.val);
              +            *out++ = (unsigned char)(here.val);
                       }
                       else if (op & 16) {                     /* length base */
                           len = (unsigned)(here.val);
                           op &= 15;                           /* number of extra bits */
                           if (op) {
                               if (bits < op) {
              -                    hold += (unsigned long)(PUP(in)) << bits;
              +                    hold += (unsigned long)(*in++) << bits;
                                   bits += 8;
                               }
                               len += (unsigned)hold & ((1U << op) - 1);
              @@ -174,9 +157,9 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                           }
                           Tracevv((stderr, "inflate:         length %u\n", len));
                           if (bits < 15) {
              -                hold += (unsigned long)(PUP(in)) << bits;
              +                hold += (unsigned long)(*in++) << bits;
                               bits += 8;
              -                hold += (unsigned long)(PUP(in)) << bits;
              +                hold += (unsigned long)(*in++) << bits;
                               bits += 8;
                           }
                           here = dcode[hold & dmask];
              @@ -189,10 +172,10 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                               dist = (unsigned)(here.val);
                               op &= 15;                       /* number of extra bits */
                               if (bits < op) {
              -                    hold += (unsigned long)(PUP(in)) << bits;
              +                    hold += (unsigned long)(*in++) << bits;
                                   bits += 8;
                                   if (bits < op) {
              -                        hold += (unsigned long)(PUP(in)) << bits;
              +                        hold += (unsigned long)(*in++) << bits;
                                       bits += 8;
                                   }
                               }
              @@ -220,30 +203,30 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
               #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
                                       if (len <= op - whave) {
                                           do {
              -                                PUP(out) = 0;
              +                                *out++ = 0;
                                           } while (--len);
                                           continue;
                                       }
                                       len -= op - whave;
                                       do {
              -                            PUP(out) = 0;
              +                            *out++ = 0;
                                       } while (--op > whave);
                                       if (op == 0) {
                                           from = out - dist;
                                           do {
              -                                PUP(out) = PUP(from);
              +                                *out++ = *from++;
                                           } while (--len);
                                           continue;
                                       }
               #endif
                                   }
              -                    from = window - OFF;
              +                    from = window;
                                   if (wnext == 0) {           /* very common case */
                                       from += wsize - op;
                                       if (op < len) {         /* some from window */
                                           len -= op;
                                           do {
              -                                PUP(out) = PUP(from);
              +                                *out++ = *from++;
                                           } while (--op);
                                           from = out - dist;  /* rest from output */
                                       }
              @@ -254,14 +237,14 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                                       if (op < len) {         /* some from end of window */
                                           len -= op;
                                           do {
              -                                PUP(out) = PUP(from);
              +                                *out++ = *from++;
                                           } while (--op);
              -                            from = window - OFF;
              +                            from = window;
                                           if (wnext < len) {  /* some from start of window */
                                               op = wnext;
                                               len -= op;
                                               do {
              -                                    PUP(out) = PUP(from);
              +                                    *out++ = *from++;
                                               } while (--op);
                                               from = out - dist;      /* rest from output */
                                           }
              @@ -272,35 +255,35 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                                       if (op < len) {         /* some from window */
                                           len -= op;
                                           do {
              -                                PUP(out) = PUP(from);
              +                                *out++ = *from++;
                                           } while (--op);
                                           from = out - dist;  /* rest from output */
                                       }
                                   }
                                   while (len > 2) {
              -                        PUP(out) = PUP(from);
              -                        PUP(out) = PUP(from);
              -                        PUP(out) = PUP(from);
              +                        *out++ = *from++;
              +                        *out++ = *from++;
              +                        *out++ = *from++;
                                       len -= 3;
                                   }
                                   if (len) {
              -                        PUP(out) = PUP(from);
              +                        *out++ = *from++;
                                       if (len > 1)
              -                            PUP(out) = PUP(from);
              +                            *out++ = *from++;
                                   }
                               }
                               else {
                                   from = out - dist;          /* copy direct from output */
                                   do {                        /* minimum length is three */
              -                        PUP(out) = PUP(from);
              -                        PUP(out) = PUP(from);
              -                        PUP(out) = PUP(from);
              +                        *out++ = *from++;
              +                        *out++ = *from++;
              +                        *out++ = *from++;
                                       len -= 3;
                                   } while (len > 2);
                                   if (len) {
              -                        PUP(out) = PUP(from);
              +                        *out++ = *from++;
                                       if (len > 1)
              -                            PUP(out) = PUP(from);
              +                            *out++ = *from++;
                                   }
                               }
                           }
              @@ -337,8 +320,8 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                   hold &= (1U << bits) - 1;
               
                   /* update state and return */
              -    strm->next_in = in + OFF;
              -    strm->next_out = out + OFF;
              +    strm->next_in = in;
              +    strm->next_out = out;
                   strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
                   strm->avail_out = (unsigned)(out < end ?
                                                257 + (end - out) : 257 - (out - end));
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inffast.h b/jdk/src/java.base/share/native/libzip/zlib/inffast.h
              similarity index 100%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/inffast.h
              rename to jdk/src/java.base/share/native/libzip/zlib/inffast.h
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inffixed.h b/jdk/src/java.base/share/native/libzip/zlib/inffixed.h
              similarity index 100%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/inffixed.h
              rename to jdk/src/java.base/share/native/libzip/zlib/inffixed.h
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inflate.c b/jdk/src/java.base/share/native/libzip/zlib/inflate.c
              similarity index 94%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/inflate.c
              rename to jdk/src/java.base/share/native/libzip/zlib/inflate.c
              index b159c1543a6..ca904e74427 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inflate.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/inflate.c
              @@ -23,7 +23,7 @@
                */
               
               /* inflate.c -- zlib decompression
              - * Copyright (C) 1995-2012 Mark Adler
              + * Copyright (C) 1995-2016 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -116,6 +116,7 @@
               #endif
               
               /* function prototypes */
              +local int inflateStateCheck OF((z_streamp strm));
               local void fixedtables OF((struct inflate_state FAR *state));
               local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
                                          unsigned copy));
              @@ -125,12 +126,26 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
               local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
                                             unsigned len));
               
              +local int inflateStateCheck(strm)
              +z_streamp strm;
              +{
              +    struct inflate_state FAR *state;
              +    if (strm == Z_NULL ||
              +        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
              +        return 1;
              +    state = (struct inflate_state FAR *)strm->state;
              +    if (state == Z_NULL || state->strm != strm ||
              +        state->mode < HEAD || state->mode > SYNC)
              +        return 1;
              +    return 0;
              +}
              +
               int ZEXPORT inflateResetKeep(strm)
               z_streamp strm;
               {
                   struct inflate_state FAR *state;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   strm->total_in = strm->total_out = state->total = 0;
                   strm->msg = Z_NULL;
              @@ -155,7 +170,7 @@ z_streamp strm;
               {
                   struct inflate_state FAR *state;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   state->wsize = 0;
                   state->whave = 0;
              @@ -171,7 +186,7 @@ int windowBits;
                   struct inflate_state FAR *state;
               
                   /* get the state */
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
               
                   /* extract wrap request from windowBits parameter */
              @@ -180,7 +195,7 @@ int windowBits;
                       windowBits = -windowBits;
                   }
                   else {
              -        wrap = (windowBits >> 4) + 1;
              +        wrap = (windowBits >> 4) + 5;
               #ifdef GUNZIP
                       if (windowBits < 48)
                           windowBits &= 15;
              @@ -234,7 +249,9 @@ int stream_size;
                   if (state == Z_NULL) return Z_MEM_ERROR;
                   Tracev((stderr, "inflate: allocated\n"));
                   strm->state = (struct internal_state FAR *)state;
              +    state->strm = strm;
                   state->window = Z_NULL;
              +    state->mode = HEAD;     /* to pass state test in inflateReset2() */
                   ret = inflateReset2(strm, windowBits);
                   if (ret != Z_OK) {
                       ZFREE(strm, state);
              @@ -258,17 +275,17 @@ int value;
               {
                   struct inflate_state FAR *state;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   if (bits < 0) {
                       state->hold = 0;
                       state->bits = 0;
                       return Z_OK;
                   }
              -    if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
              +    if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
                   value &= (1L << bits) - 1;
              -    state->hold += value << state->bits;
              -    state->bits += bits;
              +    state->hold += (unsigned)value << state->bits;
              +    state->bits += (uInt)bits;
                   return Z_OK;
               }
               
              @@ -649,7 +666,7 @@ int flush;
                   static const unsigned short order[19] = /* permutation of code lengths */
                       {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
               
              -    if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
              +    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
                       (strm->next_in == Z_NULL && strm->avail_in != 0))
                       return Z_STREAM_ERROR;
               
              @@ -669,6 +686,8 @@ int flush;
                           NEEDBITS(16);
               #ifdef GUNZIP
                           if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
              +                if (state->wbits == 0)
              +                    state->wbits = 15;
                               state->check = crc32(0L, Z_NULL, 0);
                               CRC2(state->check, hold);
                               INITBITS();
              @@ -696,7 +715,7 @@ int flush;
                           len = BITS(4) + 8;
                           if (state->wbits == 0)
                               state->wbits = len;
              -            else if (len > state->wbits) {
              +            if (len > 15 || len > state->wbits) {
                               strm->msg = (char *)"invalid window size";
                               state->mode = BAD;
                               break;
              @@ -723,14 +742,16 @@ int flush;
                           }
                           if (state->head != Z_NULL)
                               state->head->text = (int)((hold >> 8) & 1);
              -            if (state->flags & 0x0200) CRC2(state->check, hold);
              +            if ((state->flags & 0x0200) && (state->wrap & 4))
              +                CRC2(state->check, hold);
                           INITBITS();
                           state->mode = TIME;
                       case TIME:
                           NEEDBITS(32);
                           if (state->head != Z_NULL)
                               state->head->time = hold;
              -            if (state->flags & 0x0200) CRC4(state->check, hold);
              +            if ((state->flags & 0x0200) && (state->wrap & 4))
              +                CRC4(state->check, hold);
                           INITBITS();
                           state->mode = OS;
                       case OS:
              @@ -739,7 +760,8 @@ int flush;
                               state->head->xflags = (int)(hold & 0xff);
                               state->head->os = (int)(hold >> 8);
                           }
              -            if (state->flags & 0x0200) CRC2(state->check, hold);
              +            if ((state->flags & 0x0200) && (state->wrap & 4))
              +                CRC2(state->check, hold);
                           INITBITS();
                           state->mode = EXLEN;
                       case EXLEN:
              @@ -748,7 +770,8 @@ int flush;
                               state->length = (unsigned)(hold);
                               if (state->head != Z_NULL)
                                   state->head->extra_len = (unsigned)hold;
              -                if (state->flags & 0x0200) CRC2(state->check, hold);
              +                if ((state->flags & 0x0200) && (state->wrap & 4))
              +                    CRC2(state->check, hold);
                               INITBITS();
                           }
                           else if (state->head != Z_NULL)
              @@ -766,7 +789,7 @@ int flush;
                                               len + copy > state->head->extra_max ?
                                               state->head->extra_max - len : copy);
                                   }
              -                    if (state->flags & 0x0200)
              +                    if ((state->flags & 0x0200) && (state->wrap & 4))
                                       state->check = crc32(state->check, next, copy);
                                   have -= copy;
                                   next += copy;
              @@ -785,9 +808,9 @@ int flush;
                                   if (state->head != Z_NULL &&
                                           state->head->name != Z_NULL &&
                                           state->length < state->head->name_max)
              -                        state->head->name[state->length++] = len;
              +                        state->head->name[state->length++] = (Bytef)len;
                               } while (len && copy < have);
              -                if (state->flags & 0x0200)
              +                if ((state->flags & 0x0200) && (state->wrap & 4))
                                   state->check = crc32(state->check, next, copy);
                               have -= copy;
                               next += copy;
              @@ -806,9 +829,9 @@ int flush;
                                   if (state->head != Z_NULL &&
                                           state->head->comment != Z_NULL &&
                                           state->length < state->head->comm_max)
              -                        state->head->comment[state->length++] = len;
              +                        state->head->comment[state->length++] = (Bytef)len;
                               } while (len && copy < have);
              -                if (state->flags & 0x0200)
              +                if ((state->flags & 0x0200) && (state->wrap & 4))
                                   state->check = crc32(state->check, next, copy);
                               have -= copy;
                               next += copy;
              @@ -820,7 +843,7 @@ int flush;
                       case HCRC:
                           if (state->flags & 0x0200) {
                               NEEDBITS(16);
              -                if (hold != (state->check & 0xffff)) {
              +                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
                                   strm->msg = (char *)"header crc mismatch";
                                   state->mode = BAD;
                                   break;
              @@ -1201,11 +1224,11 @@ int flush;
                               out -= left;
                               strm->total_out += out;
                               state->total += out;
              -                if (out)
              +                if ((state->wrap & 4) && out)
                                   strm->adler = state->check =
                                       UPDATE(state->check, put - out, out);
                               out = left;
              -                if ((
              +                if ((state->wrap & 4) && (
               #ifdef GUNZIP
                                    state->flags ? hold :
               #endif
              @@ -1264,10 +1287,10 @@ int flush;
                   strm->total_in += in;
                   strm->total_out += out;
                   state->total += out;
              -    if (state->wrap && out)
              +    if ((state->wrap & 4) && out)
                       strm->adler = state->check =
                           UPDATE(state->check, strm->next_out - out, out);
              -    strm->data_type = state->bits + (state->last ? 64 : 0) +
              +    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
                                     (state->mode == TYPE ? 128 : 0) +
                                     (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
                   if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
              @@ -1279,7 +1302,7 @@ int ZEXPORT inflateEnd(strm)
               z_streamp strm;
               {
                   struct inflate_state FAR *state;
              -    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
              +    if (inflateStateCheck(strm))
                       return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   if (state->window != Z_NULL) ZFREE(strm, state->window);
              @@ -1297,7 +1320,7 @@ uInt *dictLength;
                   struct inflate_state FAR *state;
               
                   /* check state */
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
               
                   /* copy dictionary */
              @@ -1322,7 +1345,7 @@ uInt dictLength;
                   int ret;
               
                   /* check state */
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   if (state->wrap != 0 && state->mode != DICT)
                       return Z_STREAM_ERROR;
              @@ -1354,7 +1377,7 @@ gz_headerp head;
                   struct inflate_state FAR *state;
               
                   /* check state */
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
               
              @@ -1407,7 +1430,7 @@ z_streamp strm;
                   struct inflate_state FAR *state;
               
                   /* check parameters */
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
               
              @@ -1454,7 +1477,7 @@ z_streamp strm;
               {
                   struct inflate_state FAR *state;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
                   return state->mode == STORED && state->bits == 0;
               }
              @@ -1469,8 +1492,7 @@ z_streamp source;
                   unsigned wsize;
               
                   /* check input */
              -    if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
              -        source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
              +    if (inflateStateCheck(source) || dest == Z_NULL)
                       return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)source->state;
               
              @@ -1491,6 +1513,7 @@ z_streamp source;
                   /* copy state */
                   zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
                   zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
              +    copy->strm = dest;
                   if (state->lencode >= state->codes &&
                       state->lencode <= state->codes + ENOUGH - 1) {
                       copy->lencode = copy->codes + (state->lencode - state->codes);
              @@ -1512,25 +1535,51 @@ int subvert;
               {
                   struct inflate_state FAR *state;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
                   state = (struct inflate_state FAR *)strm->state;
              -    state->sane = !subvert;
               #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
              +    state->sane = !subvert;
                   return Z_OK;
               #else
              +    (void)subvert;
                   state->sane = 1;
                   return Z_DATA_ERROR;
               #endif
               }
               
              +int ZEXPORT inflateValidate(strm, check)
              +z_streamp strm;
              +int check;
              +{
              +    struct inflate_state FAR *state;
              +
              +    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
              +    state = (struct inflate_state FAR *)strm->state;
              +    if (check)
              +        state->wrap |= 4;
              +    else
              +        state->wrap &= ~4;
              +    return Z_OK;
              +}
              +
               long ZEXPORT inflateMark(strm)
               z_streamp strm;
               {
                   struct inflate_state FAR *state;
               
              -    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
              +    if (inflateStateCheck(strm))
              +        return -(1L << 16);
                   state = (struct inflate_state FAR *)strm->state;
              -    return ((long)(state->back) << 16) +
              +    return (long)(((unsigned long)((long)state->back)) << 16) +
                       (state->mode == COPY ? state->length :
                           (state->mode == MATCH ? state->was - state->length : 0));
               }
              +
              +unsigned long ZEXPORT inflateCodesUsed(strm)
              +z_streamp strm;
              +{
              +    struct inflate_state FAR *state;
              +    if (inflateStateCheck(strm)) return (unsigned long)-1;
              +    state = (struct inflate_state FAR *)strm->state;
              +    return (unsigned long)(state->next - state->codes);
              +}
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inflate.h b/jdk/src/java.base/share/native/libzip/zlib/inflate.h
              similarity index 94%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/inflate.h
              rename to jdk/src/java.base/share/native/libzip/zlib/inflate.h
              index 090cb8a792f..060f7fc7a93 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inflate.h
              +++ b/jdk/src/java.base/share/native/libzip/zlib/inflate.h
              @@ -23,7 +23,7 @@
                */
               
               /* inflate.h -- internal inflate state definition
              - * Copyright (C) 1995-2009 Mark Adler
              + * Copyright (C) 1995-2016 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -42,7 +42,7 @@
               
               /* Possible inflate modes between inflate() calls */
               typedef enum {
              -    HEAD,       /* i: waiting for magic header */
              +    HEAD = 16180,   /* i: waiting for magic header */
                   FLAGS,      /* i: waiting for method and flags (gzip) */
                   TIME,       /* i: waiting for modification time (gzip) */
                   OS,         /* i: waiting for extra flags and operating system (gzip) */
              @@ -101,11 +101,14 @@ typedef enum {
                       CHECK -> LENGTH -> DONE
                */
               
              -/* state maintained between inflate() calls.  Approximately 10K bytes. */
              +/* State maintained between inflate() calls -- approximately 7K bytes, not
              +   including the allocated sliding window, which is up to 32K bytes. */
               struct inflate_state {
              +    z_streamp strm;             /* pointer back to this zlib stream */
                   inflate_mode mode;          /* current inflate mode */
                   int last;                   /* true if processing last block */
              -    int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip */
              +    int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip,
              +                                   bit 2 true to validate check value */
                   int havedict;               /* true if dictionary provided */
                   int flags;                  /* gzip header method and flags (0 if zlib) */
                   unsigned dmax;              /* zlib header max distance (INFLATE_STRICT) */
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inftrees.c b/jdk/src/java.base/share/native/libzip/zlib/inftrees.c
              similarity index 96%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/inftrees.c
              rename to jdk/src/java.base/share/native/libzip/zlib/inftrees.c
              index c4b0bf2dd4a..5b882ed0df6 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inftrees.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/inftrees.c
              @@ -23,7 +23,7 @@
                */
               
               /* inftrees.c -- generate Huffman trees for efficient decoding
              - * Copyright (C) 1995-2013 Mark Adler
              + * Copyright (C) 1995-2017 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -33,7 +33,7 @@
               #define MAXBITS 15
               
               const char inflate_copyright[] =
              -   " inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
              +   " inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
               /*
                 If you use the zlib library in a product, an acknowledgment is welcome
                 in the documentation of your product. If for some reason you cannot
              @@ -78,7 +78,7 @@ unsigned short FAR *work;
                   code FAR *next;             /* next available space in table */
                   const unsigned short FAR *base;     /* base value table to use */
                   const unsigned short FAR *extra;    /* extra bits table to use */
              -    int end;                    /* use base and extra for symbol > end */
              +    unsigned match;             /* use base and extra for symbol >= match */
                   unsigned short count[MAXBITS+1];    /* number of codes of each length */
                   unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
                   static const unsigned short lbase[31] = { /* Length codes 257..285 base */
              @@ -86,7 +86,7 @@ unsigned short FAR *work;
                       35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
                   static const unsigned short lext[31] = { /* Length codes 257..285 extra */
                       16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
              -        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
              +        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
                   static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
                       1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
                       257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
              @@ -205,19 +205,17 @@ unsigned short FAR *work;
                   switch (type) {
                   case CODES:
                       base = extra = work;    /* dummy value--not used */
              -        end = 19;
              +        match = 20;
                       break;
                   case LENS:
                       base = lbase;
              -        base -= 257;
                       extra = lext;
              -        extra -= 257;
              -        end = 256;
              +        match = 257;
                       break;
              -    default:            /* DISTS */
              +    default:    /* DISTS */
                       base = dbase;
                       extra = dext;
              -        end = -1;
              +        match = 0;
                   }
               
                   /* initialize state for loop */
              @@ -240,13 +238,13 @@ unsigned short FAR *work;
                   for (;;) {
                       /* create table entry */
                       here.bits = (unsigned char)(len - drop);
              -        if ((int)(work[sym]) < end) {
              +        if (work[sym] + 1U < match) {
                           here.op = (unsigned char)0;
                           here.val = work[sym];
                       }
              -        else if ((int)(work[sym]) > end) {
              -            here.op = (unsigned char)(extra[work[sym]]);
              -            here.val = base[work[sym]];
              +        else if (work[sym] >= match) {
              +            here.op = (unsigned char)(extra[work[sym] - match]);
              +            here.val = base[work[sym] - match];
                       }
                       else {
                           here.op = (unsigned char)(32 + 64);         /* end of block */
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/inftrees.h b/jdk/src/java.base/share/native/libzip/zlib/inftrees.h
              similarity index 100%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/inftrees.h
              rename to jdk/src/java.base/share/native/libzip/zlib/inftrees.h
              diff --git a/jdk/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java b/jdk/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
              new file mode 100644
              index 00000000000..d5615a62140
              --- /dev/null
              +++ b/jdk/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
              @@ -0,0 +1,81 @@
              +(1) renamed adler32.c -> zadler32.c, zcrc32c -> zcrc32.c
              +
              +(2) zconf.h:
              +    - added _LP64 to make uLong a 32-bit int on 64-bit platform
              +    uLong -> 32-bit int
              +
              +--------------------------
              +35,37d10
              +< /* for _LP64 */
              +< #include 
              +<
              +421,424d393
              +<
              +< #ifdef _LP64
              +< typedef unsigned int  uLong;  /* 32 bits or more */
              +< #else
              +426d394
              +< #endif
              +--------------------------
              +
              +(3) updated crc32.c/crc32(), crc32_z()
              +   unsigned long      -> uLong
              +
              +--------------------------
              +
              +226,227c202,203
              +< uLong ZEXPORT crc32_z(crc, buf, len)
              +<     uLong crc;
              +---
              +> unsigned long ZEXPORT crc32_z(crc, buf, len)
              +>     unsigned long crc;
              +244c220
              +<             return (uLong)crc32_little(crc, buf, len);
              +---
              +>             return crc32_little(crc, buf, len);
              +246c222
              +<             return (uLong)crc32_big(crc, buf, len);
              +---
              +>             return crc32_big(crc, buf, len);
              +261,262c237,238
              +< uLong ZEXPORT crc32(crc, buf, len)
              +<     uLong crc;
              +---
              +> unsigned long ZEXPORT crc32(crc, buf, len)
              +>     unsigned long crc;
              +
              +--------------------------
              +
              +(4) gzread.c
              +
              +--------------------------
              +343c319
              +<             n = (unsigned)len;
              +---
              +>             n = len;
              +424c400
              +<     len = (unsigned)gz_read(state, buf, len);
              +---
              +>     len = gz_read(state, buf, len);
              +496c472
              +<     ret = (int)gz_read(state, buf, 1);
              +---
              +>     ret = gz_read(state, buf, 1);
              +--------------------------
              +
              +(5) gzwrite.c
              +
              +--------------------------
              +236c212
              +<                 copy = (unsigned)len;
              +---
              +>                 copy = len;
              +256c232
              +<                 n = (unsigned)len;
              +---
              +>                 n = len;
              +--------------------------
              +
              +
              +
              +  
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/trees.c b/jdk/src/java.base/share/native/libzip/zlib/trees.c
              similarity index 95%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/trees.c
              rename to jdk/src/java.base/share/native/libzip/zlib/trees.c
              index e4ecffea093..c3703c0e763 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/trees.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/trees.c
              @@ -23,7 +23,7 @@
                */
               
               /* trees.c -- output deflated data using Huffman coding
              - * Copyright (C) 1995-2012 Jean-loup Gailly
              + * Copyright (C) 1995-2017 Jean-loup Gailly
                * detect_data_type() function provided freely by Cosmin Truta, 2006
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
              @@ -60,7 +60,7 @@
               
               #include "deflate.h"
               
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
               #  include 
               #endif
               
              @@ -146,13 +146,13 @@ struct static_tree_desc_s {
                   int     max_length;          /* max bit length for the codes */
               };
               
              -local static_tree_desc  static_l_desc =
              +local const static_tree_desc  static_l_desc =
               {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
               
              -local static_tree_desc  static_d_desc =
              +local const static_tree_desc  static_d_desc =
               {static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
               
              -local static_tree_desc  static_bl_desc =
              +local const static_tree_desc  static_bl_desc =
               {(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
               
               /* ===========================================================================
              @@ -176,18 +176,16 @@ local int  detect_data_type OF((deflate_state *s));
               local unsigned bi_reverse OF((unsigned value, int length));
               local void bi_windup      OF((deflate_state *s));
               local void bi_flush       OF((deflate_state *s));
              -local void copy_block     OF((deflate_state *s, charf *buf, unsigned len,
              -                              int header));
               
               #ifdef GEN_TREES_H
               local void gen_trees_header OF((void));
               #endif
               
              -#ifndef DEBUG
              +#ifndef ZLIB_DEBUG
               #  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
                  /* Send a code of the given tree. c and tree must not have side effects */
               
              -#else /* DEBUG */
              +#else /* !ZLIB_DEBUG */
               #  define send_code(s, c, tree) \
                    { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
                      send_bits(s, tree[c].Code, tree[c].Len); }
              @@ -206,7 +204,7 @@ local void gen_trees_header OF((void));
                * Send a value on a given number of bits.
                * IN assertion: length <= 16 and value fits in length bits.
                */
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
               local void send_bits      OF((deflate_state *s, int value, int length));
               
               local void send_bits(s, value, length)
              @@ -232,12 +230,12 @@ local void send_bits(s, value, length)
                       s->bi_valid += length;
                   }
               }
              -#else /* !DEBUG */
              +#else /* !ZLIB_DEBUG */
               
               #define send_bits(s, value, length) \
               { int len = length;\
                 if (s->bi_valid > (int)Buf_size - len) {\
              -    int val = value;\
              +    int val = (int)value;\
                   s->bi_buf |= (ush)val << s->bi_valid;\
                   put_short(s, s->bi_buf);\
                   s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
              @@ -247,7 +245,7 @@ local void send_bits(s, value, length)
                   s->bi_valid += len;\
                 }\
               }
              -#endif /* DEBUG */
              +#endif /* ZLIB_DEBUG */
               
               
               /* the arguments must not have side effects */
              @@ -341,7 +339,7 @@ local void tr_static_init()
                * Genererate the file trees.h describing the static trees.
                */
               #ifdef GEN_TREES_H
              -#  ifndef DEBUG
              +#  ifndef ZLIB_DEBUG
               #    include 
               #  endif
               
              @@ -418,7 +416,7 @@ void ZLIB_INTERNAL _tr_init(s)
               
                   s->bi_buf = 0;
                   s->bi_valid = 0;
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                   s->compressed_len = 0L;
                   s->bits_sent = 0L;
               #endif
              @@ -546,12 +544,12 @@ local void gen_bitlen(s, desc)
                       xbits = 0;
                       if (n >= base) xbits = extra[n-base];
                       f = tree[n].Freq;
              -        s->opt_len += (ulg)f * (bits + xbits);
              -        if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
              +        s->opt_len += (ulg)f * (unsigned)(bits + xbits);
              +        if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
                   }
                   if (overflow == 0) return;
               
              -    Trace((stderr,"\nbit length overflow\n"));
              +    Tracev((stderr,"\nbit length overflow\n"));
                   /* This happens for example on obj2 and pic of the Calgary corpus */
               
                   /* Find the first bit length which could increase: */
              @@ -578,9 +576,8 @@ local void gen_bitlen(s, desc)
                           m = s->heap[--h];
                           if (m > max_code) continue;
                           if ((unsigned) tree[m].Len != (unsigned) bits) {
              -                Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
              -                s->opt_len += ((long)bits - (long)tree[m].Len)
              -                              *(long)tree[m].Freq;
              +                Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
              +                s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq;
                               tree[m].Len = (ush)bits;
                           }
                           n--;
              @@ -602,7 +599,7 @@ local void gen_codes (tree, max_code, bl_count)
                   ushf *bl_count;            /* number of codes at each bit length */
               {
                   ush next_code[MAX_BITS+1]; /* next code value for each bit length */
              -    ush code = 0;              /* running code value */
              +    unsigned code = 0;         /* running code value */
                   int bits;                  /* bit index */
                   int n;                     /* code index */
               
              @@ -610,7 +607,8 @@ local void gen_codes (tree, max_code, bl_count)
                    * without bit reversal.
                    */
                   for (bits = 1; bits <= MAX_BITS; bits++) {
              -        next_code[bits] = code = (code + bl_count[bits-1]) << 1;
              +        code = (code + bl_count[bits-1]) << 1;
              +        next_code[bits] = (ush)code;
                   }
                   /* Check that the bit counts in bl_count are consistent. The last code
                    * must be all ones.
              @@ -623,7 +621,7 @@ local void gen_codes (tree, max_code, bl_count)
                       int len = tree[n].Len;
                       if (len == 0) continue;
                       /* Now reverse the bits */
              -        tree[n].Code = bi_reverse(next_code[len]++, len);
              +        tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
               
                       Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
                            n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
              @@ -845,7 +843,7 @@ local int build_bl_tree(s)
                       if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
                   }
                   /* Update opt_len to include the bit length tree and counts */
              -    s->opt_len += 3*(max_blindex+1) + 5+5+4;
              +    s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;
                   Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
                           s->opt_len, s->static_len));
               
              @@ -893,11 +891,17 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
                   int last;         /* one if this is the last block for a file */
               {
                   send_bits(s, (STORED_BLOCK<<1)+last, 3);    /* send block type */
              -#ifdef DEBUG
              +    bi_windup(s);        /* align on byte boundary */
              +    put_short(s, (ush)stored_len);
              +    put_short(s, (ush)~stored_len);
              +    zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
              +    s->pending += stored_len;
              +#ifdef ZLIB_DEBUG
                   s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
                   s->compressed_len += (stored_len + 4) << 3;
              +    s->bits_sent += 2*16;
              +    s->bits_sent += stored_len<<3;
               #endif
              -    copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
               }
               
               /* ===========================================================================
              @@ -918,7 +922,7 @@ void ZLIB_INTERNAL _tr_align(s)
               {
                   send_bits(s, STATIC_TREES<<1, 3);
                   send_code(s, END_BLOCK, static_ltree);
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                   s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
               #endif
                   bi_flush(s);
              @@ -926,7 +930,7 @@ void ZLIB_INTERNAL _tr_align(s)
               
               /* ===========================================================================
                * Determine the best encoding for the current block: dynamic trees, static
              - * trees or store, and output the encoded block to the zip file.
              + * trees or store, and write out the encoded block.
                */
               void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
                   deflate_state *s;
              @@ -998,7 +1002,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
                       send_bits(s, (STATIC_TREES<<1)+last, 3);
                       compress_block(s, (const ct_data *)static_ltree,
                                      (const ct_data *)static_dtree);
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                       s->compressed_len += 3 + s->static_len;
               #endif
                   } else {
              @@ -1007,7 +1011,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
                                      max_blindex+1);
                       compress_block(s, (const ct_data *)s->dyn_ltree,
                                      (const ct_data *)s->dyn_dtree);
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                       s->compressed_len += 3 + s->opt_len;
               #endif
                   }
              @@ -1019,7 +1023,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
               
                   if (last) {
                       bi_windup(s);
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                       s->compressed_len += 7;  /* align on byte boundary */
               #endif
                   }
              @@ -1114,7 +1118,7 @@ local void compress_block(s, ltree, dtree)
                           send_code(s, code, dtree);       /* send the distance code */
                           extra = extra_dbits[code];
                           if (extra != 0) {
              -                dist -= base_dist[code];
              +                dist -= (unsigned)base_dist[code];
                               send_bits(s, dist, extra);   /* send the extra distance bits */
                           }
                       } /* literal or match pair ? */
              @@ -1217,34 +1221,7 @@ local void bi_windup(s)
                   }
                   s->bi_buf = 0;
                   s->bi_valid = 0;
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                   s->bits_sent = (s->bits_sent+7) & ~7;
               #endif
               }
              -
              -/* ===========================================================================
              - * Copy a stored block, storing first the length and its
              - * one's complement if requested.
              - */
              -local void copy_block(s, buf, len, header)
              -    deflate_state *s;
              -    charf    *buf;    /* the input data */
              -    unsigned len;     /* its length */
              -    int      header;  /* true if block header must be written */
              -{
              -    bi_windup(s);        /* align on byte boundary */
              -
              -    if (header) {
              -        put_short(s, (ush)len);
              -        put_short(s, (ush)~len);
              -#ifdef DEBUG
              -        s->bits_sent += 2*16;
              -#endif
              -    }
              -#ifdef DEBUG
              -    s->bits_sent += (ulg)len<<3;
              -#endif
              -    while (len--) {
              -        put_byte(s, *buf++);
              -    }
              -}
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/trees.h b/jdk/src/java.base/share/native/libzip/zlib/trees.h
              similarity index 100%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/trees.h
              rename to jdk/src/java.base/share/native/libzip/zlib/trees.h
              diff --git a/jdk/src/java.base/share/native/libzip/zlib/uncompr.c b/jdk/src/java.base/share/native/libzip/zlib/uncompr.c
              new file mode 100644
              index 00000000000..bd4766ffbf4
              --- /dev/null
              +++ b/jdk/src/java.base/share/native/libzip/zlib/uncompr.c
              @@ -0,0 +1,117 @@
              +/*
              + * 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.
              + */
              +
              +/* uncompr.c -- decompress a memory buffer
              + * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
              + * For conditions of distribution and use, see copyright notice in zlib.h
              + */
              +
              +/* @(#) $Id$ */
              +
              +#define ZLIB_INTERNAL
              +#include "zlib.h"
              +
              +/* ===========================================================================
              +     Decompresses the source buffer into the destination buffer.  *sourceLen is
              +   the byte length of the source buffer. Upon entry, *destLen is the total size
              +   of the destination buffer, which must be large enough to hold the entire
              +   uncompressed data. (The size of the uncompressed data must have been saved
              +   previously by the compressor and transmitted to the decompressor by some
              +   mechanism outside the scope of this compression library.) Upon exit,
              +   *destLen is the size of the decompressed data and *sourceLen is the number
              +   of source bytes consumed. Upon return, source + *sourceLen points to the
              +   first unused input byte.
              +
              +     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
              +   memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
              +   Z_DATA_ERROR if the input data was corrupted, including if the input data is
              +   an incomplete zlib stream.
              +*/
              +int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
              +    Bytef *dest;
              +    uLongf *destLen;
              +    const Bytef *source;
              +    uLong *sourceLen;
              +{
              +    z_stream stream;
              +    int err;
              +    const uInt max = (uInt)-1;
              +    uLong len, left;
              +    Byte buf[1];    /* for detection of incomplete stream when *destLen == 0 */
              +
              +    len = *sourceLen;
              +    if (*destLen) {
              +        left = *destLen;
              +        *destLen = 0;
              +    }
              +    else {
              +        left = 1;
              +        dest = buf;
              +    }
              +
              +    stream.next_in = (z_const Bytef *)source;
              +    stream.avail_in = 0;
              +    stream.zalloc = (alloc_func)0;
              +    stream.zfree = (free_func)0;
              +    stream.opaque = (voidpf)0;
              +
              +    err = inflateInit(&stream);
              +    if (err != Z_OK) return err;
              +
              +    stream.next_out = dest;
              +    stream.avail_out = 0;
              +
              +    do {
              +        if (stream.avail_out == 0) {
              +            stream.avail_out = left > (uLong)max ? max : (uInt)left;
              +            left -= stream.avail_out;
              +        }
              +        if (stream.avail_in == 0) {
              +            stream.avail_in = len > (uLong)max ? max : (uInt)len;
              +            len -= stream.avail_in;
              +        }
              +        err = inflate(&stream, Z_NO_FLUSH);
              +    } while (err == Z_OK);
              +
              +    *sourceLen -= len + stream.avail_in;
              +    if (dest != buf)
              +        *destLen = stream.total_out;
              +    else if (stream.total_out && err == Z_BUF_ERROR)
              +        left = 1;
              +
              +    inflateEnd(&stream);
              +    return err == Z_STREAM_END ? Z_OK :
              +           err == Z_NEED_DICT ? Z_DATA_ERROR  :
              +           err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
              +           err;
              +}
              +
              +int ZEXPORT uncompress (dest, destLen, source, sourceLen)
              +    Bytef *dest;
              +    uLongf *destLen;
              +    const Bytef *source;
              +    uLong sourceLen;
              +{
              +    return uncompress2(dest, destLen, source, &sourceLen);
              +}
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zadler32.c b/jdk/src/java.base/share/native/libzip/zlib/zadler32.c
              similarity index 93%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/zadler32.c
              rename to jdk/src/java.base/share/native/libzip/zlib/zadler32.c
              index a3108315221..e1480226310 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zadler32.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/zadler32.c
              @@ -23,7 +23,7 @@
                */
               
               /* adler32.c -- compute the Adler-32 checksum of a data stream
              - * Copyright (C) 1995-2011 Mark Adler
              + * Copyright (C) 1995-2011, 2016 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -31,11 +31,9 @@
               
               #include "zutil.h"
               
              -#define local static
              -
               local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
               
              -#define BASE 65521      /* largest prime smaller than 65536 */
              +#define BASE 65521U     /* largest prime smaller than 65536 */
               #define NMAX 5552
               /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
               
              @@ -86,10 +84,10 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
               #endif
               
               /* ========================================================================= */
              -uLong ZEXPORT adler32(adler, buf, len)
              +uLong ZEXPORT adler32_z(adler, buf, len)
                   uLong adler;
                   const Bytef *buf;
              -    uInt len;
              +    z_size_t len;
               {
                   unsigned long sum2;
                   unsigned n;
              @@ -156,6 +154,15 @@ uLong ZEXPORT adler32(adler, buf, len)
                   return adler | (sum2 << 16);
               }
               
              +/* ========================================================================= */
              +uLong ZEXPORT adler32(adler, buf, len)
              +    uLong adler;
              +    const Bytef *buf;
              +    uInt len;
              +{
              +    return adler32_z(adler, buf, len);
              +}
              +
               /* ========================================================================= */
               local uLong adler32_combine_(adler1, adler2, len2)
                   uLong adler1;
              @@ -180,7 +187,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
                   sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
                   if (sum1 >= BASE) sum1 -= BASE;
                   if (sum1 >= BASE) sum1 -= BASE;
              -    if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
              +    if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
                   if (sum2 >= BASE) sum2 -= BASE;
                   return sum1 | (sum2 << 16);
               }
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zconf.h b/jdk/src/java.base/share/native/libzip/zlib/zconf.h
              similarity index 93%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/zconf.h
              rename to jdk/src/java.base/share/native/libzip/zlib/zconf.h
              index c7edbed7d12..9b920116be8 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zconf.h
              +++ b/jdk/src/java.base/share/native/libzip/zlib/zconf.h
              @@ -23,7 +23,7 @@
                */
               
               /* zconf.h -- configuration of the zlib compression library
              - * Copyright (C) 1995-2013 Jean-loup Gailly.
              + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -44,7 +44,7 @@
               #ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
               #  define Z_PREFIX_SET
               
              -/* all linked symbols */
              +/* all linked symbols and init macros */
               #  define _dist_code            z__dist_code
               #  define _length_code          z__length_code
               #  define _tr_align             z__tr_align
              @@ -56,6 +56,7 @@
               #  define adler32               z_adler32
               #  define adler32_combine       z_adler32_combine
               #  define adler32_combine64     z_adler32_combine64
              +#  define adler32_z             z_adler32_z
               #  ifndef Z_SOLO
               #    define compress              z_compress
               #    define compress2             z_compress2
              @@ -64,10 +65,14 @@
               #  define crc32                 z_crc32
               #  define crc32_combine         z_crc32_combine
               #  define crc32_combine64       z_crc32_combine64
              +#  define crc32_z               z_crc32_z
               #  define deflate               z_deflate
               #  define deflateBound          z_deflateBound
               #  define deflateCopy           z_deflateCopy
               #  define deflateEnd            z_deflateEnd
              +#  define deflateGetDictionary  z_deflateGetDictionary
              +#  define deflateInit           z_deflateInit
              +#  define deflateInit2          z_deflateInit2
               #  define deflateInit2_         z_deflateInit2_
               #  define deflateInit_          z_deflateInit_
               #  define deflateParams         z_deflateParams
              @@ -94,6 +99,8 @@
               #    define gzeof                 z_gzeof
               #    define gzerror               z_gzerror
               #    define gzflush               z_gzflush
              +#    define gzfread               z_gzfread
              +#    define gzfwrite              z_gzfwrite
               #    define gzgetc                z_gzgetc
               #    define gzgetc_               z_gzgetc_
               #    define gzgets                z_gzgets
              @@ -105,7 +112,6 @@
               #      define gzopen_w              z_gzopen_w
               #    endif
               #    define gzprintf              z_gzprintf
              -#    define gzvprintf             z_gzvprintf
               #    define gzputc                z_gzputc
               #    define gzputs                z_gzputs
               #    define gzread                z_gzread
              @@ -116,32 +122,39 @@
               #    define gztell                z_gztell
               #    define gztell64              z_gztell64
               #    define gzungetc              z_gzungetc
              +#    define gzvprintf             z_gzvprintf
               #    define gzwrite               z_gzwrite
               #  endif
               #  define inflate               z_inflate
               #  define inflateBack           z_inflateBack
               #  define inflateBackEnd        z_inflateBackEnd
              +#  define inflateBackInit       z_inflateBackInit
               #  define inflateBackInit_      z_inflateBackInit_
              +#  define inflateCodesUsed      z_inflateCodesUsed
               #  define inflateCopy           z_inflateCopy
               #  define inflateEnd            z_inflateEnd
              +#  define inflateGetDictionary  z_inflateGetDictionary
               #  define inflateGetHeader      z_inflateGetHeader
              +#  define inflateInit           z_inflateInit
              +#  define inflateInit2          z_inflateInit2
               #  define inflateInit2_         z_inflateInit2_
               #  define inflateInit_          z_inflateInit_
               #  define inflateMark           z_inflateMark
               #  define inflatePrime          z_inflatePrime
               #  define inflateReset          z_inflateReset
               #  define inflateReset2         z_inflateReset2
              +#  define inflateResetKeep      z_inflateResetKeep
               #  define inflateSetDictionary  z_inflateSetDictionary
              -#  define inflateGetDictionary  z_inflateGetDictionary
               #  define inflateSync           z_inflateSync
               #  define inflateSyncPoint      z_inflateSyncPoint
               #  define inflateUndermine      z_inflateUndermine
              -#  define inflateResetKeep      z_inflateResetKeep
              +#  define inflateValidate       z_inflateValidate
               #  define inflate_copyright     z_inflate_copyright
               #  define inflate_fast          z_inflate_fast
               #  define inflate_table         z_inflate_table
               #  ifndef Z_SOLO
               #    define uncompress            z_uncompress
              +#    define uncompress2           z_uncompress2
               #  endif
               #  define zError                z_zError
               #  ifndef Z_SOLO
              @@ -251,9 +264,19 @@
               #  define z_const
               #endif
               
              -/* Some Mac compilers merge all .h files incorrectly: */
              -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
              -#  define NO_DUMMY_DECL
              +#ifdef Z_SOLO
              +   typedef unsigned long z_size_t;
              +#else
              +#  define z_longlong long long
              +#  if defined(NO_SIZE_T)
              +     typedef unsigned NO_SIZE_T z_size_t;
              +#  elif defined(STDC)
              +#    include 
              +     typedef size_t z_size_t;
              +#  else
              +     typedef unsigned long z_size_t;
              +#  endif
              +#  undef z_longlong
               #endif
               
               /* Maximum value for memLevel in deflateInit2 */
              @@ -283,7 +306,7 @@
                Of course this will generally degrade compression (there's no free lunch).
               
                  The memory requirements for inflate are (in bytes) 1 << windowBits
              - that is, 32K for windowBits=15 (default value) plus a few kilobytes
              + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
                for small objects.
               */
               
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zcrc32.c b/jdk/src/java.base/share/native/libzip/zlib/zcrc32.c
              similarity index 92%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/zcrc32.c
              rename to jdk/src/java.base/share/native/libzip/zlib/zcrc32.c
              index 0fe90df9799..c1965fd0e8d 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zcrc32.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/zcrc32.c
              @@ -23,7 +23,7 @@
                */
               
               /* crc32.c -- compute the CRC-32 of a data stream
              - * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
              + * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                *
                * Thanks to Rodney Brown  for his contribution of faster
              @@ -54,17 +54,15 @@
               
               #include "zutil.h"      /* for STDC and FAR definitions */
               
              -#define local static
              -
               /* Definitions for doing the crc four data bytes at a time. */
               #if !defined(NOBYFOUR) && defined(Z_U4)
               #  define BYFOUR
               #endif
               #ifdef BYFOUR
                  local unsigned long crc32_little OF((unsigned long,
              -                        const unsigned char FAR *, unsigned));
              +                        const unsigned char FAR *, z_size_t));
                  local unsigned long crc32_big OF((unsigned long,
              -                        const unsigned char FAR *, unsigned));
              +                        const unsigned char FAR *, z_size_t));
               #  define TBLS 8
               #else
               #  define TBLS 1
              @@ -225,10 +223,10 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
               #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
               
               /* ========================================================================= */
              -uLong ZEXPORT crc32(crc, buf, len)
              +uLong ZEXPORT crc32_z(crc, buf, len)
                   uLong crc;
                   const unsigned char FAR *buf;
              -    uInt len;
              +    z_size_t len;
               {
                   if (buf == Z_NULL) return 0UL;
               
              @@ -259,8 +257,29 @@ uLong ZEXPORT crc32(crc, buf, len)
                   return crc ^ 0xffffffffUL;
               }
               
              +/* ========================================================================= */
              +uLong ZEXPORT crc32(crc, buf, len)
              +    uLong crc;
              +    const unsigned char FAR *buf;
              +    uInt len;
              +{
              +    return crc32_z(crc, buf, len);
              +}
              +
               #ifdef BYFOUR
               
              +/*
              +   This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit
              +   integer pointer type. This violates the strict aliasing rule, where a
              +   compiler can assume, for optimization purposes, that two pointers to
              +   fundamentally different types won't ever point to the same memory. This can
              +   manifest as a problem only if one of the pointers is written to. This code
              +   only reads from those pointers. So long as this code remains isolated in
              +   this compilation unit, there won't be a problem. For this reason, this code
              +   should not be copied and pasted into a compilation unit in which other code
              +   writes to the buffer that is passed to these routines.
              + */
              +
               /* ========================================================================= */
               #define DOLIT4 c ^= *buf4++; \
                       c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
              @@ -271,7 +290,7 @@ uLong ZEXPORT crc32(crc, buf, len)
               local unsigned long crc32_little(crc, buf, len)
                   unsigned long crc;
                   const unsigned char FAR *buf;
              -    unsigned len;
              +    z_size_t len;
               {
                   register z_crc_t c;
                   register const z_crc_t FAR *buf4;
              @@ -302,7 +321,7 @@ local unsigned long crc32_little(crc, buf, len)
               }
               
               /* ========================================================================= */
              -#define DOBIG4 c ^= *++buf4; \
              +#define DOBIG4 c ^= *buf4++; \
                       c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
                           crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
               #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
              @@ -311,7 +330,7 @@ local unsigned long crc32_little(crc, buf, len)
               local unsigned long crc32_big(crc, buf, len)
                   unsigned long crc;
                   const unsigned char FAR *buf;
              -    unsigned len;
              +    z_size_t len;
               {
                   register z_crc_t c;
                   register const z_crc_t FAR *buf4;
              @@ -324,7 +343,6 @@ local unsigned long crc32_big(crc, buf, len)
                   }
               
                   buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
              -    buf4--;
                   while (len >= 32) {
                       DOBIG32;
                       len -= 32;
              @@ -333,7 +351,6 @@ local unsigned long crc32_big(crc, buf, len)
                       DOBIG4;
                       len -= 4;
                   }
              -    buf4++;
                   buf = (const unsigned char FAR *)buf4;
               
                   if (len) do {
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zlib.h b/jdk/src/java.base/share/native/libzip/zlib/zlib.h
              similarity index 82%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/zlib.h
              rename to jdk/src/java.base/share/native/libzip/zlib/zlib.h
              index 8779cadf207..e383d0e4508 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zlib.h
              +++ b/jdk/src/java.base/share/native/libzip/zlib/zlib.h
              @@ -23,9 +23,9 @@
                */
               
               /* zlib.h -- interface of the 'zlib' general purpose compression library
              -  version 1.2.8, April 28th, 2013
              +  version 1.2.11, January 15th, 2017
               
              -  Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
              +  Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
               
                 This software is provided 'as-is', without any express or implied
                 warranty.  In no event will the authors be held liable for any damages
              @@ -61,11 +61,11 @@
               extern "C" {
               #endif
               
              -#define ZLIB_VERSION "1.2.8"
              -#define ZLIB_VERNUM 0x1280
              +#define ZLIB_VERSION "1.2.11"
              +#define ZLIB_VERNUM 0x12b0
               #define ZLIB_VER_MAJOR 1
               #define ZLIB_VER_MINOR 2
              -#define ZLIB_VER_REVISION 8
              +#define ZLIB_VER_REVISION 11
               #define ZLIB_VER_SUBREVISION 0
               
               /*
              @@ -89,7 +89,8 @@ extern "C" {
                 with "gz".  The gzip format is different from the zlib format.  gzip is a
                 gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
               
              -    This library can optionally read and write gzip streams in memory as well.
              +    This library can optionally read and write gzip and raw deflate streams in
              +  memory as well.
               
                   The zlib format was designed to be compact and fast for use in memory
                 and on communications channels.  The gzip format was designed for single-
              @@ -98,7 +99,7 @@ extern "C" {
               
                   The library does not install any signal handler.  The decoder checks
                 the consistency of the compressed data, so the library should never crash
              -  even in case of corrupted input.
              +  even in the case of corrupted input.
               */
               
               typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
              @@ -111,7 +112,7 @@ typedef struct z_stream_s {
                   uInt     avail_in;  /* number of bytes available at next_in */
                   uLong    total_in;  /* total number of input bytes read so far */
               
              -    Bytef    *next_out; /* next output byte should be put there */
              +    Bytef    *next_out; /* next output byte will go here */
                   uInt     avail_out; /* remaining free space at next_out */
                   uLong    total_out; /* total number of bytes output so far */
               
              @@ -122,8 +123,9 @@ typedef struct z_stream_s {
                   free_func  zfree;   /* used to free the internal state */
                   voidpf     opaque;  /* private data object passed to zalloc and zfree */
               
              -    int     data_type;  /* best guess about the data type: binary or text */
              -    uLong   adler;      /* adler32 value of the uncompressed data */
              +    int     data_type;  /* best guess about the data type: binary or text
              +                           for deflate, or the decoding state for inflate */
              +    uLong   adler;      /* Adler-32 or CRC-32 value of the uncompressed data */
                   uLong   reserved;   /* reserved for future use */
               } z_stream;
               
              @@ -166,7 +168,9 @@ typedef gz_header FAR *gz_headerp;
               
                    zalloc must return Z_NULL if there is not enough memory for the object.
                  If zlib is used in a multi-threaded application, zalloc and zfree must be
              -   thread safe.
              +   thread safe.  In that case, zlib is thread-safe.  When zalloc and zfree are
              +   Z_NULL on entry to the initialization function, they are set to internal
              +   routines that use the standard library functions malloc() and free().
               
                    On 16-bit systems, the functions zalloc and zfree must be able to allocate
                  exactly 65536 bytes, but will not be required to allocate more than this if
              @@ -179,7 +183,7 @@ typedef gz_header FAR *gz_headerp;
               
                    The fields total_in and total_out can be used for statistics or progress
                  reports.  After compression, total_in holds the total size of the
              -   uncompressed data and may be saved for use in the decompressor (particularly
              +   uncompressed data and may be saved for use by the decompressor (particularly
                  if the decompressor wants to decompress everything in a single step).
               */
               
              @@ -224,7 +228,7 @@ typedef gz_header FAR *gz_headerp;
               #define Z_TEXT     1
               #define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
               #define Z_UNKNOWN  2
              -/* Possible values of the data_type field (though see inflate()) */
              +/* Possible values of the data_type field for deflate() */
               
               #define Z_DEFLATED   8
               /* The deflate compression method (the only one supported in this version) */
              @@ -282,11 +286,11 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
                   enough room in the output buffer), next_in and avail_in are updated and
                   processing will resume at this point for the next call of deflate().
               
              -  - Provide more output starting at next_out and update next_out and avail_out
              +  - Generate more output starting at next_out and update next_out and avail_out
                   accordingly.  This action is forced if the parameter flush is non zero.
                   Forcing flush frequently degrades the compression ratio, so this parameter
              -    should be set only when necessary (in interactive applications).  Some
              -    output may be provided even if flush is not set.
              +    should be set only when necessary.  Some output may be provided even if
              +    flush is zero.
               
                   Before the call of deflate(), the application should ensure that at least
                 one of the actions is possible, by providing more input and/or consuming more
              @@ -295,7 +299,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
                 output when it wants, for example when the output buffer is full (avail_out
                 == 0), or after each call of deflate().  If deflate returns Z_OK and with
                 zero avail_out, it must be called again after making room in the output
              -  buffer because there might be more output pending.
              +  buffer because there might be more output pending. See deflatePending(),
              +  which can be used if desired to determine whether or not there is more ouput
              +  in that case.
               
                   Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
                 decide how much data to accumulate before producing output, in order to
              @@ -316,8 +322,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
                 input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
                 This completes the current deflate block and follows it with an empty fixed
                 codes block that is 10 bits long.  This assures that enough bytes are output
              -  in order for the decompressor to finish the block before the empty fixed code
              -  block.
              +  in order for the decompressor to finish the block before the empty fixed
              +  codes block.
               
                   If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
                 for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
              @@ -343,34 +349,38 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
               
                   If the parameter flush is set to Z_FINISH, pending input is processed,
                 pending output is flushed and deflate returns with Z_STREAM_END if there was
              -  enough output space; if deflate returns with Z_OK, this function must be
              -  called again with Z_FINISH and more output space (updated avail_out) but no
              -  more input data, until it returns with Z_STREAM_END or an error.  After
              -  deflate has returned Z_STREAM_END, the only possible operations on the stream
              -  are deflateReset or deflateEnd.
              +  enough output space.  If deflate returns with Z_OK or Z_BUF_ERROR, this
              +  function must be called again with Z_FINISH and more output space (updated
              +  avail_out) but no more input data, until it returns with Z_STREAM_END or an
              +  error.  After deflate has returned Z_STREAM_END, the only possible operations
              +  on the stream are deflateReset or deflateEnd.
               
              -    Z_FINISH can be used immediately after deflateInit if all the compression
              -  is to be done in a single step.  In this case, avail_out must be at least the
              -  value returned by deflateBound (see below).  Then deflate is guaranteed to
              -  return Z_STREAM_END.  If not enough output space is provided, deflate will
              -  not return Z_STREAM_END, and it must be called again as described above.
              +    Z_FINISH can be used in the first deflate call after deflateInit if all the
              +  compression is to be done in a single step.  In order to complete in one
              +  call, avail_out must be at least the value returned by deflateBound (see
              +  below).  Then deflate is guaranteed to return Z_STREAM_END.  If not enough
              +  output space is provided, deflate will not return Z_STREAM_END, and it must
              +  be called again as described above.
               
              -    deflate() sets strm->adler to the adler32 checksum of all input read
              -  so far (that is, total_in bytes).
              +    deflate() sets strm->adler to the Adler-32 checksum of all input read
              +  so far (that is, total_in bytes).  If a gzip stream is being generated, then
              +  strm->adler will be the CRC-32 checksum of the input read so far.  (See
              +  deflateInit2 below.)
               
                   deflate() may update strm->data_type if it can make a good guess about
              -  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered
              -  binary.  This field is only for information purposes and does not affect the
              -  compression algorithm in any manner.
              +  the input data type (Z_BINARY or Z_TEXT).  If in doubt, the data is
              +  considered binary.  This field is only for information purposes and does not
              +  affect the compression algorithm in any manner.
               
                   deflate() returns Z_OK if some progress has been made (more input
                 processed or more output produced), Z_STREAM_END if all input has been
                 consumed and all output has been produced (only when flush is set to
                 Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
              -  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
              -  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not
              -  fatal, and deflate() can be called again with more input and more output
              -  space to continue compressing.
              +  if next_in or next_out was Z_NULL or the state was inadvertently written over
              +  by the application), or Z_BUF_ERROR if no progress is possible (for example
              +  avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not fatal, and
              +  deflate() can be called again with more input and more output space to
              +  continue compressing.
               */
               
               
              @@ -393,23 +403,21 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
               
                    Initializes the internal stream state for decompression.  The fields
                  next_in, avail_in, zalloc, zfree and opaque must be initialized before by
              -   the caller.  If next_in is not Z_NULL and avail_in is large enough (the
              -   exact value depends on the compression method), inflateInit determines the
              -   compression method from the zlib header and allocates all data structures
              -   accordingly; otherwise the allocation will be deferred to the first call of
              -   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
              -   use default allocation functions.
              +   the caller.  In the current version of inflate, the provided input is not
              +   read or consumed.  The allocation of a sliding window will be deferred to
              +   the first call of inflate (if the decompression does not complete on the
              +   first call).  If zalloc and zfree are set to Z_NULL, inflateInit updates
              +   them to use default allocation functions.
               
                    inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
                  memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
                  version assumed by the caller, or Z_STREAM_ERROR if the parameters are
                  invalid, such as a null pointer to the structure.  msg is set to null if
              -   there is no error message.  inflateInit does not perform any decompression
              -   apart from possibly reading the zlib header if present: actual decompression
              -   will be done by inflate().  (So next_in and avail_in may be modified, but
              -   next_out and avail_out are unused and unchanged.) The current implementation
              -   of inflateInit() does not process any header information -- that is deferred
              -   until inflate() is called.
              +   there is no error message.  inflateInit does not perform any decompression.
              +   Actual decompression will be done by inflate().  So next_in, and avail_in,
              +   next_out, and avail_out are unused and unchanged.  The current
              +   implementation of inflateInit() does not process any header information --
              +   that is deferred until inflate() is called.
               */
               
               
              @@ -425,17 +433,20 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
               
                 - Decompress more input starting at next_in and update next_in and avail_in
                   accordingly.  If not all input can be processed (because there is not
              -    enough room in the output buffer), next_in is updated and processing will
              -    resume at this point for the next call of inflate().
              +    enough room in the output buffer), then next_in and avail_in are updated
              +    accordingly, and processing will resume at this point for the next call of
              +    inflate().
               
              -  - Provide more output starting at next_out and update next_out and avail_out
              +  - Generate more output starting at next_out and update next_out and avail_out
                   accordingly.  inflate() provides as much output as possible, until there is
                   no more input data or no more space in the output buffer (see below about
                   the flush parameter).
               
                   Before the call of inflate(), the application should ensure that at least
                 one of the actions is possible, by providing more input and/or consuming more
              -  output, and updating the next_* and avail_* values accordingly.  The
              +  output, and updating the next_* and avail_* values accordingly.  If the
              +  caller of inflate() does not provide both available input and available
              +  output space, it is possible that there will be no progress made.  The
                 application can consume the uncompressed output when it wants, for example
                 when the output buffer is full (avail_out == 0), or after each call of
                 inflate().  If inflate returns Z_OK and with zero avail_out, it must be
              @@ -452,7 +463,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
                 gets to the end of that block, or when it runs out of data.
               
                   The Z_BLOCK option assists in appending to or combining deflate streams.
              -  Also to assist in this, on return inflate() will set strm->data_type to the
              +  To assist in this, on return inflate() always sets strm->data_type to the
                 number of unused bits in the last byte taken from strm->next_in, plus 64 if
                 inflate() is currently decoding the last block in the deflate stream, plus
                 128 if inflate() returned immediately after decoding an end-of-block code or
              @@ -478,7 +489,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
                 this case all pending input is processed and all pending output is flushed;
                 avail_out must be large enough to hold all of the uncompressed data for the
                 operation to complete.  (The size of the uncompressed data may have been
              -  saved by the compressor for this purpose.) The use of Z_FINISH is not
              +  saved by the compressor for this purpose.)  The use of Z_FINISH is not
                 required to perform an inflation in one step.  However it may be used to
                 inform inflate that a faster approach can be used for the single inflate()
                 call.  Z_FINISH also informs inflate to not maintain a sliding window if the
              @@ -500,32 +511,33 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
                 chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
                 strm->adler to the Adler-32 checksum of all output produced so far (that is,
                 total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
              -  below.  At the end of the stream, inflate() checks that its computed adler32
              +  below.  At the end of the stream, inflate() checks that its computed Adler-32
                 checksum is equal to that saved by the compressor and returns Z_STREAM_END
                 only if the checksum is correct.
               
                   inflate() can decompress and check either zlib-wrapped or gzip-wrapped
                 deflate data.  The header type is detected automatically, if requested when
                 initializing with inflateInit2().  Any information contained in the gzip
              -  header is not retained, so applications that need that information should
              -  instead use raw inflate, see inflateInit2() below, or inflateBack() and
              -  perform their own processing of the gzip header and trailer.  When processing
              +  header is not retained unless inflateGetHeader() is used.  When processing
                 gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
              -  producted so far.  The CRC-32 is checked against the gzip trailer.
              +  produced so far.  The CRC-32 is checked against the gzip trailer, as is the
              +  uncompressed length, modulo 2^32.
               
                   inflate() returns Z_OK if some progress has been made (more input processed
                 or more output produced), Z_STREAM_END if the end of the compressed data has
                 been reached and all uncompressed output has been produced, Z_NEED_DICT if a
                 preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
                 corrupted (input stream not conforming to the zlib format or incorrect check
              -  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
              -  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
              -  Z_BUF_ERROR if no progress is possible or if there was not enough room in the
              -  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
              +  value, in which case strm->msg points to a string with a more specific
              +  error), Z_STREAM_ERROR if the stream structure was inconsistent (for example
              +  next_in or next_out was Z_NULL, or the state was inadvertently written over
              +  by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR
              +  if no progress was possible or if there was not enough room in the output
              +  buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
                 inflate() can be called again with more input and more output space to
                 continue decompressing.  If Z_DATA_ERROR is returned, the application may
                 then call inflateSync() to look for a good compression block if a partial
              -  recovery of the data is desired.
              +  recovery of the data is to be attempted.
               */
               
               
              @@ -535,9 +547,8 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
                  This function discards any unprocessed input and does not flush any pending
                  output.
               
              -     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
              -   was inconsistent.  In the error case, msg may be set but then points to a
              -   static string (which must not be deallocated).
              +     inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state
              +   was inconsistent.
               */
               
               
              @@ -568,16 +579,29 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
                  compression at the expense of memory usage.  The default value is 15 if
                  deflateInit is used instead.
               
              +     For the current implementation of deflate(), a windowBits value of 8 (a
              +   window size of 256 bytes) is not supported.  As a result, a request for 8
              +   will result in 9 (a 512-byte window).  In that case, providing 8 to
              +   inflateInit2() will result in an error when the zlib header with 9 is
              +   checked against the initialization of inflate().  The remedy is to not use 8
              +   with deflateInit2() with this initialization, or at least in that case use 9
              +   with inflateInit2().
              +
                    windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits
                  determines the window size.  deflate() will then generate raw deflate data
              -   with no zlib header or trailer, and will not compute an adler32 check value.
              +   with no zlib header or trailer, and will not compute a check value.
               
                    windowBits can also be greater than 15 for optional gzip encoding.  Add
                  16 to windowBits to write a simple gzip header and trailer around the
                  compressed data instead of a zlib wrapper.  The gzip header will have no
                  file name, no extra data, no comment, no modification time (set to zero), no
              -   header crc, and the operating system will be set to 255 (unknown).  If a
              -   gzip stream is being written, strm->adler is a crc32 instead of an adler32.
              +   header crc, and the operating system will be set to the appropriate value,
              +   if the operating system was determined at compile time.  If a gzip stream is
              +   being written, strm->adler is a CRC-32 instead of an Adler-32.
              +
              +     For raw deflate or gzip encoding, a request for a 256-byte window is
              +   rejected as invalid, since only the zlib header provides a means of
              +   transmitting the window size to the decompressor.
               
                    The memLevel parameter specifies how much memory should be allocated
                  for the internal compression state.  memLevel=1 uses minimum memory but is
              @@ -638,12 +662,12 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
                  addition, the current implementation of deflate will use at most the window
                  size minus 262 bytes of the provided dictionary.
               
              -     Upon return of this function, strm->adler is set to the adler32 value
              +     Upon return of this function, strm->adler is set to the Adler-32 value
                  of the dictionary; the decompressor may later use this value to determine
              -   which dictionary has been used by the compressor.  (The adler32 value
              +   which dictionary has been used by the compressor.  (The Adler-32 value
                  applies to the whole dictionary even if only a subset of the dictionary is
                  actually used by the compressor.) If a raw deflate was requested, then the
              -   adler32 value is not computed and strm->adler is not set.
              +   Adler-32 value is not computed and strm->adler is not set.
               
                    deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
                  parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
              @@ -652,6 +676,28 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
                  not perform any compression: this will be done by deflate().
               */
               
              +ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
              +                                             Bytef *dictionary,
              +                                             uInt  *dictLength));
              +/*
              +     Returns the sliding dictionary being maintained by deflate.  dictLength is
              +   set to the number of bytes in the dictionary, and that many bytes are copied
              +   to dictionary.  dictionary must have enough space, where 32768 bytes is
              +   always enough.  If deflateGetDictionary() is called with dictionary equal to
              +   Z_NULL, then only the dictionary length is returned, and nothing is copied.
              +   Similary, if dictLength is Z_NULL, then it is not set.
              +
              +     deflateGetDictionary() may return a length less than the window size, even
              +   when more than the window size in input has been provided. It may return up
              +   to 258 bytes less in that case, due to how zlib's implementation of deflate
              +   manages the sliding window and lookahead for matches, where matches can be
              +   up to 258 bytes long. If the application needs the last window-size bytes of
              +   input, then that would need to be saved by the application outside of zlib.
              +
              +     deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
              +   stream state is inconsistent.
              +*/
              +
               ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
                                                   z_streamp source));
               /*
              @@ -672,10 +718,10 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
               
               ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
               /*
              -     This function is equivalent to deflateEnd followed by deflateInit,
              -   but does not free and reallocate all the internal compression state.  The
              -   stream will keep the same compression level and any other attributes that
              -   may have been set by deflateInit2.
              +     This function is equivalent to deflateEnd followed by deflateInit, but
              +   does not free and reallocate the internal compression state.  The stream
              +   will leave the compression level and any other attributes that may have been
              +   set unchanged.
               
                    deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
                  stream state was inconsistent (such as zalloc or state being Z_NULL).
              @@ -686,20 +732,36 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
                                                     int strategy));
               /*
                    Dynamically update the compression level and compression strategy.  The
              -   interpretation of level and strategy is as in deflateInit2.  This can be
              +   interpretation of level and strategy is as in deflateInit2().  This can be
                  used to switch between compression and straight copy of the input data, or
                  to switch to a different kind of input data requiring a different strategy.
              -   If the compression level is changed, the input available so far is
              -   compressed with the old level (and may be flushed); the new level will take
              -   effect only at the next call of deflate().
              +   If the compression approach (which is a function of the level) or the
              +   strategy is changed, and if any input has been consumed in a previous
              +   deflate() call, then the input available so far is compressed with the old
              +   level and strategy using deflate(strm, Z_BLOCK).  There are three approaches
              +   for the compression levels 0, 1..3, and 4..9 respectively.  The new level
              +   and strategy will take effect at the next call of deflate().
               
              -     Before the call of deflateParams, the stream state must be set as for
              -   a call of deflate(), since the currently available input may have to be
              -   compressed and flushed.  In particular, strm->avail_out must be non-zero.
              +     If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
              +   not have enough output space to complete, then the parameter change will not
              +   take effect.  In this case, deflateParams() can be called again with the
              +   same parameters and more output space to try again.
               
              -     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
              -   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
              -   strm->avail_out was zero.
              +     In order to assure a change in the parameters on the first try, the
              +   deflate stream should be flushed using deflate() with Z_BLOCK or other flush
              +   request until strm.avail_out is not zero, before calling deflateParams().
              +   Then no more input data should be provided before the deflateParams() call.
              +   If this is done, the old level and strategy will be applied to the data
              +   compressed before deflateParams(), and the new level and strategy will be
              +   applied to the the data compressed after deflateParams().
              +
              +     deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream
              +   state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if
              +   there was not enough output space to complete the compression of the
              +   available input data before a change in the strategy or approach.  Note that
              +   in the case of a Z_BUF_ERROR, the parameters are not changed.  A return
              +   value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be
              +   retried with more output space.
               */
               
               ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
              @@ -817,7 +879,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
                  is for use with other formats that use the deflate compressed data format
                  such as zip.  Those formats provide their own check values.  If a custom
                  format is developed using the raw deflate format for compressed data, it is
              -   recommended that a check value such as an adler32 or a crc32 be applied to
              +   recommended that a check value such as an Adler-32 or a CRC-32 be applied to
                  the uncompressed data as is done in the zlib, gzip, and zip formats.  For
                  most applications, the zlib format should be used as is.  Note that comments
                  above on the use in deflateInit2() applies to the magnitude of windowBits.
              @@ -826,7 +888,10 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
                  32 to windowBits to enable zlib and gzip decoding with automatic header
                  detection, or add 16 to decode only the gzip format (the zlib format will
                  return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
              -   crc32 instead of an adler32.
              +   CRC-32 instead of an Adler-32.  Unlike the gunzip utility and gzread() (see
              +   below), inflate() will not automatically decode concatenated gzip streams.
              +   inflate() will return Z_STREAM_END at the end of the gzip stream.  The state
              +   would need to be reset to continue decoding a subsequent gzip stream.
               
                    inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
                  memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
              @@ -847,7 +912,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
                    Initializes the decompression dictionary from the given uncompressed byte
                  sequence.  This function must be called immediately after a call of inflate,
                  if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor
              -   can be determined from the adler32 value returned by that call of inflate.
              +   can be determined from the Adler-32 value returned by that call of inflate.
                  The compressor and decompressor must use exactly the same dictionary (see
                  deflateSetDictionary).  For raw inflate, this function can be called at any
                  time to set the dictionary.  If the provided dictionary is smaller than the
              @@ -858,7 +923,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
                    inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
                  parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
                  inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
              -   expected one (incorrect adler32 value).  inflateSetDictionary does not
              +   expected one (incorrect Adler-32 value).  inflateSetDictionary does not
                  perform any decompression: this will be done by subsequent calls of
                  inflate().
               */
              @@ -916,7 +981,7 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
               ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
               /*
                    This function is equivalent to inflateEnd followed by inflateInit,
              -   but does not free and reallocate all the internal decompression state.  The
              +   but does not free and reallocate the internal decompression state.  The
                  stream will keep attributes that may have been set by inflateInit2.
               
                    inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
              @@ -928,7 +993,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
               /*
                    This function is the same as inflateReset, but it also permits changing
                  the wrap and window size requests.  The windowBits parameter is interpreted
              -   the same as it is for inflateInit2.
              +   the same as it is for inflateInit2.  If the window size is changed, then the
              +   memory allocated for the window is freed, and the window will be reallocated
              +   by inflate() if needed.
               
                    inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
                  stream state was inconsistent (such as zalloc or state being Z_NULL), or if
              @@ -980,7 +1047,7 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
                  location in the input stream can be determined from avail_in and data_type
                  as noted in the description for the Z_BLOCK flush parameter for inflate.
               
              -     inflateMark returns the value noted above or -1 << 16 if the provided
              +     inflateMark returns the value noted above, or -65536 if the provided
                  source stream state was inconsistent.
               */
               
              @@ -1072,9 +1139,9 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
                  This routine would normally be used in a utility that reads zip or gzip
                  files and writes out uncompressed files.  The utility would decode the
                  header and process the trailer on its own, hence this routine expects only
              -   the raw deflate stream to decompress.  This is different from the normal
              -   behavior of inflate(), which expects either a zlib or gzip header and
              -   trailer around the deflate stream.
              +   the raw deflate stream to decompress.  This is different from the default
              +   behavior of inflate(), which expects a zlib header and trailer around the
              +   deflate stream.
               
                    inflateBack() uses two subroutines supplied by the caller that are then
                  called by inflateBack() for input and output.  inflateBack() calls those
              @@ -1083,12 +1150,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
                  parameters and return types are defined above in the in_func and out_func
                  typedefs.  inflateBack() will call in(in_desc, &buf) which should return the
                  number of bytes of provided input, and a pointer to that input in buf.  If
              -   there is no input available, in() must return zero--buf is ignored in that
              -   case--and inflateBack() will return a buffer error.  inflateBack() will call
              -   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()
              -   should return zero on success, or non-zero on failure.  If out() returns
              -   non-zero, inflateBack() will return with an error.  Neither in() nor out()
              -   are permitted to change the contents of the window provided to
              +   there is no input available, in() must return zero -- buf is ignored in that
              +   case -- and inflateBack() will return a buffer error.  inflateBack() will
              +   call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].
              +   out() should return zero on success, or non-zero on failure.  If out()
              +   returns non-zero, inflateBack() will return with an error.  Neither in() nor
              +   out() are permitted to change the contents of the window provided to
                  inflateBackInit(), which is also the buffer that out() uses to write from.
                  The length written by out() will be at most the window size.  Any non-zero
                  amount of input may be provided by in().
              @@ -1116,7 +1183,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
                  using strm->next_in which will be Z_NULL only if in() returned an error.  If
                  strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
                  non-zero.  (in() will always be called before out(), so strm->next_in is
              -   assured to be defined if out() returns non-zero.) Note that inflateBack()
              +   assured to be defined if out() returns non-zero.)  Note that inflateBack()
                  cannot return Z_OK.
               */
               
              @@ -1138,7 +1205,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
                    7.6: size of z_off_t
               
                   Compiler, assembler, and debug options:
              -     8: DEBUG
              +     8: ZLIB_DEBUG
                    9: ASMV or ASMINF -- use ASM code
                    10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
                    11: 0 (reserved)
              @@ -1188,7 +1255,8 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
                  the byte length of the source buffer.  Upon entry, destLen is the total size
                  of the destination buffer, which must be at least the value returned by
                  compressBound(sourceLen).  Upon exit, destLen is the actual size of the
              -   compressed buffer.
              +   compressed data.  compress() is equivalent to compress2() with a level
              +   parameter of Z_DEFAULT_COMPRESSION.
               
                    compress returns Z_OK if success, Z_MEM_ERROR if there was not
                  enough memory, Z_BUF_ERROR if there was not enough room in the output
              @@ -1204,7 +1272,7 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
                  length of the source buffer.  Upon entry, destLen is the total size of the
                  destination buffer, which must be at least the value returned by
                  compressBound(sourceLen).  Upon exit, destLen is the actual size of the
              -   compressed buffer.
              +   compressed data.
               
                    compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
                  memory, Z_BUF_ERROR if there was not enough room in the output buffer,
              @@ -1227,7 +1295,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
                  uncompressed data.  (The size of the uncompressed data must have been saved
                  previously by the compressor and transmitted to the decompressor by some
                  mechanism outside the scope of this compression library.) Upon exit, destLen
              -   is the actual size of the uncompressed buffer.
              +   is the actual size of the uncompressed data.
               
                    uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
                  enough memory, Z_BUF_ERROR if there was not enough room in the output
              @@ -1236,6 +1304,14 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
                  buffer with the uncompressed data up to that point.
               */
               
              +ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest,   uLongf *destLen,
              +                                    const Bytef *source, uLong *sourceLen));
              +/*
              +     Same as uncompress, except that sourceLen is a pointer, where the
              +   length of the source is *sourceLen.  On return, *sourceLen is the number of
              +   source bytes consumed.
              +*/
              +
                                       /* gzip file access functions */
               
               /*
              @@ -1314,10 +1390,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
                  default buffer size is 8192 bytes.  This function must be called after
                  gzopen() or gzdopen(), and before any other calls that read or write the
                  file.  The buffer memory allocation is always deferred to the first read or
              -   write.  Two buffers are allocated, either both of the specified size when
              -   writing, or one of the specified size and the other twice that size when
              -   reading.  A larger buffer size of, for example, 64K or 128K bytes will
              -   noticeably increase the speed of decompression (reading).
              +   write.  Three times that size in buffer space is allocated.  A larger buffer
              +   size of, for example, 64K or 128K bytes will noticeably increase the speed
              +   of decompression (reading).
               
                    The new buffer size also affects the maximum length for gzprintf().
               
              @@ -1328,10 +1403,12 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
               ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
               /*
                    Dynamically update the compression level or strategy.  See the description
              -   of deflateInit2 for the meaning of these parameters.
              +   of deflateInit2 for the meaning of these parameters.  Previously provided
              +   data is flushed before the parameter change.
               
              -     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
              -   opened for writing.
              +     gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
              +   opened for writing, Z_ERRNO if there is an error writing the flushed data,
              +   or Z_MEM_ERROR if there is a memory allocation error.
               */
               
               ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
              @@ -1359,7 +1436,35 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
                  case.
               
                    gzread returns the number of uncompressed bytes actually read, less than
              -   len for end of file, or -1 for error.
              +   len for end of file, or -1 for error.  If len is too large to fit in an int,
              +   then nothing is read, -1 is returned, and the error state is set to
              +   Z_STREAM_ERROR.
              +*/
              +
              +ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
              +                                     gzFile file));
              +/*
              +     Read up to nitems items of size size from file to buf, otherwise operating
              +   as gzread() does.  This duplicates the interface of stdio's fread(), with
              +   size_t request and return types.  If the library defines size_t, then
              +   z_size_t is identical to size_t.  If not, then z_size_t is an unsigned
              +   integer type that can contain a pointer.
              +
              +     gzfread() returns the number of full items read of size size, or zero if
              +   the end of the file was reached and a full item could not be read, or if
              +   there was an error.  gzerror() must be consulted if zero is returned in
              +   order to determine if there was an error.  If the multiplication of size and
              +   nitems overflows, i.e. the product does not fit in a z_size_t, then nothing
              +   is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
              +
              +     In the event that the end of file is reached and only a partial item is
              +   available at the end, i.e. the remaining uncompressed data length is not a
              +   multiple of size, then the final partial item is nevetheless read into buf
              +   and the end-of-file flag is set.  The length of the partial item read is not
              +   provided, but could be inferred from the result of gztell().  This behavior
              +   is the same as the behavior of fread() implementations in common libraries,
              +   but it prevents the direct use of gzfread() to read a concurrently written
              +   file, reseting and retrying on end-of-file, when size is not 1.
               */
               
               ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
              @@ -1370,19 +1475,33 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
                  error.
               */
               
              +ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
              +                                      z_size_t nitems, gzFile file));
              +/*
              +     gzfwrite() writes nitems items of size size from buf to file, duplicating
              +   the interface of stdio's fwrite(), with size_t request and return types.  If
              +   the library defines size_t, then z_size_t is identical to size_t.  If not,
              +   then z_size_t is an unsigned integer type that can contain a pointer.
              +
              +     gzfwrite() returns the number of full items written of size size, or zero
              +   if there was an error.  If the multiplication of size and nitems overflows,
              +   i.e. the product does not fit in a z_size_t, then nothing is written, zero
              +   is returned, and the error state is set to Z_STREAM_ERROR.
              +*/
              +
               ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
               /*
                    Converts, formats, and writes the arguments to the compressed file under
                  control of the format string, as in fprintf.  gzprintf returns the number of
              -   uncompressed bytes actually written, or 0 in case of error.  The number of
              -   uncompressed bytes written is limited to 8191, or one less than the buffer
              -   size given to gzbuffer().  The caller should assure that this limit is not
              -   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with
              -   nothing written.  In this case, there may also be a buffer overflow with
              -   unpredictable consequences, which is possible only if zlib was compiled with
              -   the insecure functions sprintf() or vsprintf() because the secure snprintf()
              -   or vsnprintf() functions were not available.  This can be determined using
              -   zlibCompileFlags().
              +   uncompressed bytes actually written, or a negative zlib error code in case
              +   of error.  The number of uncompressed bytes written is limited to 8191, or
              +   one less than the buffer size given to gzbuffer().  The caller should assure
              +   that this limit is not exceeded.  If it is exceeded, then gzprintf() will
              +   return an error (0) with nothing written.  In this case, there may also be a
              +   buffer overflow with unpredictable consequences, which is possible only if
              +   zlib was compiled with the insecure functions sprintf() or vsprintf()
              +   because the secure snprintf() or vsnprintf() functions were not available.
              +   This can be determined using zlibCompileFlags().
               */
               
               ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
              @@ -1442,7 +1561,7 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
                    If the flush parameter is Z_FINISH, the remaining data is written and the
                  gzip stream is completed in the output.  If gzwrite() is called again, a new
                  gzip stream will be started in the output.  gzread() is able to read such
              -   concatented gzip streams.
              +   concatenated gzip streams.
               
                    gzflush should be called only when strictly necessary because it will
                  degrade compression if called too often.
              @@ -1596,7 +1715,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
                  return the updated checksum.  If buf is Z_NULL, this function returns the
                  required initial value for the checksum.
               
              -     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
              +     An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
                  much faster.
               
                  Usage example:
              @@ -1609,6 +1728,12 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
                    if (adler != original_adler) error();
               */
               
              +ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,
              +                                    z_size_t len));
              +/*
              +     Same as adler32(), but with a size_t length.
              +*/
              +
               /*
               ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
                                                         z_off_t len2));
              @@ -1638,6 +1763,12 @@ ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
                    if (crc != original_crc) error();
               */
               
              +ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
              +                                  z_size_t len));
              +/*
              +     Same as crc32(), but with a size_t length.
              +*/
              +
               /*
               ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
               
              @@ -1668,19 +1799,35 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
                                                        unsigned char FAR *window,
                                                        const char *version,
                                                        int stream_size));
              -#define deflateInit(strm, level) \
              -        deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
              -#define inflateInit(strm) \
              -        inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
              -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
              -        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
              -                      (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
              -#define inflateInit2(strm, windowBits) \
              -        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
              -                      (int)sizeof(z_stream))
              -#define inflateBackInit(strm, windowBits, window) \
              -        inflateBackInit_((strm), (windowBits), (window), \
              -                      ZLIB_VERSION, (int)sizeof(z_stream))
              +#ifdef Z_PREFIX_SET
              +#  define z_deflateInit(strm, level) \
              +          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
              +#  define z_inflateInit(strm) \
              +          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
              +#  define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
              +          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
              +                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
              +#  define z_inflateInit2(strm, windowBits) \
              +          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
              +                        (int)sizeof(z_stream))
              +#  define z_inflateBackInit(strm, windowBits, window) \
              +          inflateBackInit_((strm), (windowBits), (window), \
              +                           ZLIB_VERSION, (int)sizeof(z_stream))
              +#else
              +#  define deflateInit(strm, level) \
              +          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
              +#  define inflateInit(strm) \
              +          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
              +#  define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
              +          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
              +                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
              +#  define inflateInit2(strm, windowBits) \
              +          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
              +                        (int)sizeof(z_stream))
              +#  define inflateBackInit(strm, windowBits, window) \
              +          inflateBackInit_((strm), (windowBits), (window), \
              +                           ZLIB_VERSION, (int)sizeof(z_stream))
              +#endif
               
               #ifndef Z_SOLO
               
              @@ -1700,10 +1847,10 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
               #ifdef Z_PREFIX_SET
               #  undef z_gzgetc
               #  define z_gzgetc(g) \
              -          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
              +          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
               #else
               #  define gzgetc(g) \
              -          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
              +          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
               #endif
               
               /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
              @@ -1761,19 +1908,16 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
               
               #endif /* !Z_SOLO */
               
              -/* hack for buggy compilers */
              -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
              -    struct internal_state {int dummy;};
              -#endif
              -
               /* undocumented functions */
               ZEXTERN const char   * ZEXPORT zError           OF((int));
               ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
               ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));
               ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
              +ZEXTERN int            ZEXPORT inflateValidate OF((z_streamp, int));
              +ZEXTERN unsigned long  ZEXPORT inflateCodesUsed OF ((z_streamp));
               ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
               ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
              -#if defined(_WIN32) && !defined(Z_SOLO)
              +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
               ZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,
                                                           const char *mode));
               #endif
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zutil.c b/jdk/src/java.base/share/native/libzip/zlib/zutil.c
              similarity index 88%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/zutil.c
              rename to jdk/src/java.base/share/native/libzip/zlib/zutil.c
              index e54347610c8..a0c88928068 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zutil.c
              +++ b/jdk/src/java.base/share/native/libzip/zlib/zutil.c
              @@ -23,32 +23,30 @@
                */
               
               /* zutil.c -- target dependent utility functions for the compression library
              - * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
              + * Copyright (C) 1995-2017 Jean-loup Gailly
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
               /* @(#) $Id$ */
               
               #include "zutil.h"
              +
               #ifndef Z_SOLO
               #  include "gzguts.h"
               #endif
               
              -#ifndef NO_DUMMY_DECL
              -struct internal_state      {int dummy;}; /* for buggy compilers */
              -#endif
              -
               z_const char * const z_errmsg[10] = {
              -"need dictionary",     /* Z_NEED_DICT       2  */
              -"stream end",          /* Z_STREAM_END      1  */
              -"",                    /* Z_OK              0  */
              -"file error",          /* Z_ERRNO         (-1) */
              -"stream error",        /* Z_STREAM_ERROR  (-2) */
              -"data error",          /* Z_DATA_ERROR    (-3) */
              -"insufficient memory", /* Z_MEM_ERROR     (-4) */
              -"buffer error",        /* Z_BUF_ERROR     (-5) */
              -"incompatible version",/* Z_VERSION_ERROR (-6) */
              -""};
              +    (z_const char *)"need dictionary",     /* Z_NEED_DICT       2  */
              +    (z_const char *)"stream end",          /* Z_STREAM_END      1  */
              +    (z_const char *)"",                    /* Z_OK              0  */
              +    (z_const char *)"file error",          /* Z_ERRNO         (-1) */
              +    (z_const char *)"stream error",        /* Z_STREAM_ERROR  (-2) */
              +    (z_const char *)"data error",          /* Z_DATA_ERROR    (-3) */
              +    (z_const char *)"insufficient memory", /* Z_MEM_ERROR     (-4) */
              +    (z_const char *)"buffer error",        /* Z_BUF_ERROR     (-5) */
              +    (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
              +    (z_const char *)""
              +};
               
               
               const char * ZEXPORT zlibVersion()
              @@ -85,7 +83,7 @@ uLong ZEXPORT zlibCompileFlags()
                   case 8:     flags += 2 << 6;        break;
                   default:    flags += 3 << 6;
                   }
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
                   flags += 1 << 8;
               #endif
               #if defined(ASMV) || defined(ASMINF)
              @@ -139,8 +137,8 @@ uLong ZEXPORT zlibCompileFlags()
                   return flags;
               }
               
              -#ifdef DEBUG
              -
              +#ifdef ZLIB_DEBUG
              +#include 
               #  ifndef verbose
               #    define verbose 0
               #  endif
              @@ -243,9 +241,11 @@ local ptr_table table[MAX_PTR];
               
               voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
               {
              -    voidpf buf = opaque; /* just to make some compilers happy */
              +    voidpf buf;
                   ulg bsize = (ulg)items*size;
               
              +    (void)opaque;
              +
                   /* If we allocate less than 65520 bytes, we assume that farmalloc
                    * will return a usable pointer which doesn't have to be normalized.
                    */
              @@ -268,6 +268,9 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
               void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
               {
                   int n;
              +
              +    (void)opaque;
              +
                   if (*(ush*)&ptr != 0) { /* object < 64K */
                       farfree(ptr);
                       return;
              @@ -283,7 +286,6 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
                       next_ptr--;
                       return;
                   }
              -    ptr = opaque; /* just to make some compilers happy */
                   Assert(0, "zcfree: ptr not found");
               }
               
              @@ -302,13 +304,13 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
               
               voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
               {
              -    if (opaque) opaque = 0; /* to make compiler happy */
              +    (void)opaque;
                   return _halloc((long)items, size);
               }
               
               void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
               {
              -    if (opaque) opaque = 0; /* to make compiler happy */
              +    (void)opaque;
                   _hfree(ptr);
               }
               
              @@ -330,7 +332,7 @@ voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
                   unsigned items;
                   unsigned size;
               {
              -    if (opaque) items += size - size; /* make compiler happy */
              +    (void)opaque;
                   return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
                                             (voidpf)calloc(items, size);
               }
              @@ -339,8 +341,8 @@ void ZLIB_INTERNAL zcfree (opaque, ptr)
                   voidpf opaque;
                   voidpf ptr;
               {
              +    (void)opaque;
                   free(ptr);
              -    if (opaque) return; /* make compiler happy */
               }
               
               #endif /* MY_ZCALLOC */
              diff --git a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zutil.h b/jdk/src/java.base/share/native/libzip/zlib/zutil.h
              similarity index 89%
              rename from jdk/src/java.base/share/native/libzip/zlib-1.2.8/zutil.h
              rename to jdk/src/java.base/share/native/libzip/zlib/zutil.h
              index b82b14d4a5e..c9e1273efc0 100644
              --- a/jdk/src/java.base/share/native/libzip/zlib-1.2.8/zutil.h
              +++ b/jdk/src/java.base/share/native/libzip/zlib/zutil.h
              @@ -23,7 +23,7 @@
                */
               
               /* zutil.h -- internal interface and configuration of the compression library
              - * Copyright (C) 1995-2013 Jean-loup Gailly.
              + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
                * For conditions of distribution and use, see copyright notice in zlib.h
                */
               
              @@ -60,7 +60,9 @@
               #ifndef local
               #  define local static
               #endif
              -/* compile with -Dlocal if your debugger can't find static symbols */
              +/* since "static" is used to mean two completely different things in C, we
              +   define "local" for the non-static meaning of "static", for readability
              +   (compile with -Dlocal if your debugger can't find static symbols) */
               
               typedef unsigned char  uch;
               typedef uch FAR uchf;
              @@ -122,28 +124,38 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
               #endif
               
               #ifdef AMIGA
              -#  define OS_CODE  0x01
              +#  define OS_CODE  1
               #endif
               
               #if defined(VAXC) || defined(VMS)
              -#  define OS_CODE  0x02
              +#  define OS_CODE  2
               #  define F_OPEN(name, mode) \
                    fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
               #endif
               
              +#ifdef __370__
              +#  if __TARGET_LIB__ < 0x20000000
              +#    define OS_CODE 4
              +#  elif __TARGET_LIB__ < 0x40000000
              +#    define OS_CODE 11
              +#  else
              +#    define OS_CODE 8
              +#  endif
              +#endif
              +
               #if defined(ATARI) || defined(atarist)
              -#  define OS_CODE  0x05
              +#  define OS_CODE  5
               #endif
               
               #ifdef OS2
              -#  define OS_CODE  0x06
              +#  define OS_CODE  6
               #  if defined(M_I86) && !defined(Z_SOLO)
               #    include 
               #  endif
               #endif
               
               #if defined(MACOS) || defined(TARGET_OS_MAC)
              -#  define OS_CODE  0x07
              +#  define OS_CODE  7
               #  ifndef Z_SOLO
               #    if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
               #      include  /* for fdopen */
              @@ -155,18 +167,24 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
               #  endif
               #endif
               
              -#ifdef TOPS20
              -#  define OS_CODE  0x0a
              +#ifdef __acorn
              +#  define OS_CODE 13
               #endif
               
              -#ifdef WIN32
              -#  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */
              -#    define OS_CODE  0x0b
              -#  endif
              +#if defined(WIN32) && !defined(__CYGWIN__)
              +#  define OS_CODE  10
               #endif
               
              -#ifdef __50SERIES /* Prime/PRIMOS */
              -#  define OS_CODE  0x0f
              +#ifdef _BEOS_
              +#  define OS_CODE  16
              +#endif
              +
              +#ifdef __TOS_OS400__
              +#  define OS_CODE 18
              +#endif
              +
              +#ifdef __APPLE__
              +#  define OS_CODE 19
               #endif
               
               #if defined(_BEOS_) || defined(RISCOS)
              @@ -201,7 +219,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
                       /* common defaults */
               
               #ifndef OS_CODE
              -#  define OS_CODE  0x03  /* assume Unix */
              +#  define OS_CODE  3     /* assume Unix */
               #endif
               
               #ifndef F_OPEN
              @@ -240,7 +258,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
               #endif
               
               /* Diagnostic functions */
              -#ifdef DEBUG
              +#ifdef ZLIB_DEBUG
               #  include 
                  extern int ZLIB_INTERNAL z_verbose;
                  extern void ZLIB_INTERNAL z_error OF((char *m));
              diff --git a/jdk/src/java.base/share/specs/serialization/class.md b/jdk/src/java.base/share/specs/serialization/class.md
              new file mode 100644
              index 00000000000..03b94b7d099
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/class.md
              @@ -0,0 +1,362 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](input.html) | [NEXT](version.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](input.html) | [NEXT](version.html)'
              +
              +title: 'Java Object Serialization Specification: 4 - Class Descriptors'
              +---
              +
              +-   [The ObjectStreamClass Class](#the-objectstreamclass-class)
              +-   [Dynamic Proxy Class Descriptors](#dynamic-proxy-class-descriptors)
              +-   [Serialized Form](#serialized-form)
              +-   [The ObjectStreamField Class](#the-objectstreamfield-class)
              +-   [Inspecting Serializable Classes](#inspecting-serializable-classes)
              +-   [Stream Unique Identifiers](#stream-unique-identifiers)
              +
              +-------------------------------------------------------------------------------
              +
              +## 4.1 The ObjectStreamClass Class
              +
              +The `ObjectStreamClass` provides information about classes that are saved in a
              +Serialization stream. The descriptor provides the fully-qualified name of the
              +class and its serialization version UID. A `SerialVersionUID` identifies the
              +unique original class version for which this class is capable of writing
              +streams and from which it can read.
              +
              +```
              +package java.io;
              +
              +public class ObjectStreamClass
              +{
              +    public static ObjectStreamClass lookup(Class cl);
              +
              +        public static ObjectStreamClass lookupAny(Class cl);
              +
              +    public String getName();
              +
              +    public Class forClass();
              +
              +    public ObjectStreamField[] getFields();
              +
              +    public long getSerialVersionUID();
              +
              +    public String toString();
              +}
              +```
              +
              +The `lookup` method returns the `ObjectStreamClass` descriptor for the
              +specified class in the virtual machine. If the class has defined
              +`serialVersionUID` it is retrieved from the class. If the `serialVersionUID` is
              +not defined by the class, it is computed from the definition of the class in
              +the virtual machine. *I*f the specified class is not serializable or
              +externalizable, *null* is returned.
              +
              +The `lookupAny` method behaves like the `lookup` method, except that it returns
              +the descriptor for any class, regardless of whether it implements
              +`Serializable`. The `serialVersionUID` of a class that does not implement
              +`Serializable` is *0L.*
              +
              +The `getName` method returns the name of the class, in the same format that is
              +used by the `Class.getName` method.
              +
              +The `forClass` method returns the `Class` in the local virtual machine if one
              +was found by `ObjectInputStream.resolveClass` method. Otherwise, it returns
              +*null*.
              +
              +The `getFields` method returns an array of `ObjectStreamField` objects that
              +represent the serializable fields of this class.
              +
              +The `getSerialVersionUID` method returns the `serialVersionUID` of this class.
              +Refer to [Section 4.6, "Stream Unique
              +Identifiers"](#stream-unique-identifiers). If not specified by the class, the
              +value returned is a hash computed from the class's name, interfaces, methods,
              +and fields using the Secure Hash Algorithm (SHA) as defined by the National
              +Institute of Standards.
              +
              +The `toString` method returns a printable representation of the class
              +descriptor including the name of the class and the `serialVersionUID`.
              +
              +## 4.2 Dynamic Proxy Class Descriptors
              +
              +ObjectStreamClass descriptors are also used to provide information about
              +dynamic proxy classes (e.g., classes obtained via calls to the getProxyClass
              +method of java.lang.reflect.Proxy) saved in a serialization stream. A dynamic
              +proxy class itself has no serializable fields and a serialVersionUID of 0L. In
              +other words, when the Class object for a dynamic proxy class is passed to the
              +static lookup method of ObjectStreamClass, the returned ObjectStreamClass
              +instance will have the following properties:
              +
              +-   Invoking its getSerialVersionUID method will return 0L.
              +-   Invoking its getFields method will return an array of length zero.
              +-   Invoking its getField method with any String argument will return null.
              +
              +## 4.3 Serialized Form
              +
              +The serialized form of an ObjectStreamClass instance depends on whether or not
              +the Class object it represents is serializable, externalizable, or a dynamic
              +proxy class.
              +
              +When an `ObjectStreamClass` instance that does not represent a dynamic proxy
              +class is written to the stream, it writes the class name and
              +`serialVersionUID`, flags, and the number of fields. Depending on the class,
              +additional information may be written:
              +
              +-   For non-serializable classes, the number of fields is always zero. Neither
              +    the `SC_SERIALIZABLE` nor the `SC_EXTERNALIZABLE` flag bits are set.
              +
              +-   For serializable classes, the `SC_SERIALIZABLE` flag is set, the number of
              +    fields counts the number of serializable fields and is followed by a
              +    descriptor for each serializable field. The descriptors are written in
              +    canonical order. The descriptors for primitive typed fields are written
              +    first sorted by field name followed by descriptors for the object typed
              +    fields sorted by field name. The names are sorted using `String.compareTo`.
              +    For details of the format, refer to [Section 6.4, "Grammar for the Stream
              +    Format"](protocol.html#grammar-for-the-stream-format).
              +
              +-   For externalizable classes, flags includes the `SC_EXTERNALIZABLE` flag,
              +    and the number of fields is always zero.
              +
              +-   For enum types, flags includes the `SC_ENUM` flag, and the number of fields
              +    is always zero.
              +
              +When an ObjectOutputStream serializes the ObjectStreamClass descriptor for a
              +dynamic proxy class, as determined by passing its Class object to the
              +isProxyClass method of java.lang.reflect.Proxy, it writes the number of
              +interfaces that the dynamic proxy class implements, followed by the interface
              +names. Interfaces are listed in the order that they are returned by invoking
              +the getInterfaces method on the Class object of the dynamic proxy class.
              +
              +The serialized representations of ObjectStreamClass descriptors for dynamic
              +proxy classes and non-dynamic proxy classes are differentiated through the use
              +of different typecodes (`TC_PROXYCLASSDESC` and `TC_CLASSDESC`, respectively);
              +for a more detailed specification of the grammar, see [Section 6.4, "Grammar
              +for the Stream Format"](protocol.html#grammar-for-the-stream-format).
              +
              +## 4.4 The ObjectStreamField Class
              +
              +An `ObjectStreamField` represents a serializable field of a serializable class.
              +The serializable fields of a class can be retrieved from the
              +`ObjectStreamClass`.
              +
              +The special static serializable field, `serialPersistentFields`, is an array of
              +`ObjectStreamField` components that is used to override the default
              +serializable fields.
              +
              +```
              +package java.io;
              +
              +public class ObjectStreamField implements Comparable {
              +
              +    public ObjectStreamField(String fieldName,
              +                             Class fieldType);
              +
              +    public ObjectStreamField(String fieldName,
              +                             Class fieldType,
              +                             boolean unshared);
              +
              +    public String getName();
              +
              +    public Class getType();
              +
              +    public String getTypeString();
              +
              +    public char getTypeCode();
              +
              +    public boolean isPrimitive();
              +
              +    public boolean isUnshared();
              +
              +    public int getOffset();
              +
              +    protected void setOffset(int offset);
              +
              +    public int compareTo(Object obj);
              +
              +    public String toString();
              +}
              +```
              +
              +`ObjectStreamField` objects are used to specify the serializable fields of a
              +class or to describe the fields present in a stream. Its constructors accept
              +arguments describing the field to represent: a string specifying the name of
              +the field, a `Class` object specifying the type of the field, and a `boolean`
              +flag (implicitly `false` for the two-argument constructor) indicating whether
              +or not values of the represented field should be read and written as "unshared"
              +objects if default serialization/deserialization is in use (see the
              +descriptions of the `ObjectInputStream.readUnshared` and
              +`ObjectOutputStream.writeUnshared` methods in [Section 3.1, "The
              +ObjectInputStream Class"](input.html#the-objectinputstream-class) and [Section
              +2.1, "The ObjectOutputStream Class"](output.html#the-objectoutputstream-class),
              +respectively).
              +
              +The `getName` method returns the name of the serializable field.
              +
              +The `getType` method returns the type of the field.
              +
              +The `getTypeString` method returns the type signature of the field.
              +
              +The `getTypeCode` method returns a character encoding of the field type ('`B`'
              +for `byte`, '`C`' for `char`, '`D`' for `double`, '`F`' for `float`, '`I`' for
              +`int`, '`J`' for `long`, '`L`' for non-array object types, '`S`' for `short`,
              +'`Z`' for `boolean`, and '`[`' for arrays).
              +
              +The `isPrimitive` method returns `true` if the field is of primitive type, or
              +`false` otherwise.
              +
              +The `isUnshared` method returns `true` if values of the field should be written
              +as "unshared" objects, or `false` otherwise.
              +
              +The `getOffset` method returns the offset of the field's value within instance
              +data of the class defining the field.
              +
              +The `setOffset` method allows `ObjectStreamField` subclasses to modify the
              +offset value returned by the `getOffset` method.
              +
              +The `compareTo` method compares `ObjectStreamFields` for use in sorting.
              +Primitive fields are ranked as "smaller" than non-primitive fields; fields
              +otherwise equal are ranked alphabetically.
              +
              +The `toString` method returns a printable representation with name and type.
              +
              +## 4.5 Inspecting Serializable Classes
              +
              +The program *serialver* can be used to find out if a class is serializable and
              +to get its `serialVersionUID`. 
              +
              +When invoked on the command line with one or more class names, serialver prints
              +the `serialVersionUID` for each class in a form suitable for copying into an
              +evolving class. When invoked with no arguments, it prints a usage line.
              +
              +## 4.6 Stream Unique Identifiers
              +
              +Each versioned class must identify the original class version for which it is
              +capable of writing streams and from which it can read. For example, a versioned
              +class must declare:
              +
              +```
              +private static final long serialVersionUID = 3487495895819393L;
              +```
              +
              +The stream-unique identifier is a 64-bit hash of the class name, interface
              +class names, methods, and fields. The value must be declared in all versions of
              +a class except the first. It may be declared in the original class but is not
              +required. The value is fixed for all compatible classes. If the SUID is not
              +declared for a class, the value defaults to the hash for that class. The
              +`serialVersionUID` for dynamic proxy classes and enum types always have the
              +value *0L*. Array classes cannot declare an explicit `serialVersionUID`, so
              +they always have the default computed value, but the requirement for matching
              +`serialVersionUID` values is waived for array classes.
              +
              +**Note:** It is strongly recommended that all serializable classes explicitly
              +declare `serialVersionUID` values, since the default `serialVersionUID`
              +computation is highly sensitive to class details that may vary depending on
              +compiler implementations, and can thus result in unexpected `serialVersionUID`
              +conflicts during deserialization, causing deserialization to fail.
              +
              +The initial version of an `Externalizable` class must output a stream data
              +format that is extensible in the future. The initial version of the method
              +`readExternal` has to be able to read the output format of all future versions
              +of the method `writeExternal`.
              +
              +The `serialVersionUID` is computed using the signature of a stream of bytes
              +that reflect the class definition. The National Institute of Standards and
              +Technology (NIST) Secure Hash Algorithm (SHA-1) is used to compute a signature
              +for the stream. The first two 32-bit quantities are used to form a 64-bit hash.
              +A `java.lang.DataOutputStream` is used to convert primitive data types to a
              +sequence of bytes. The values input to the stream are defined by the Java
              +Virtual Machine (VM) specification for classes. Class modifiers may include the
              +`ACC_PUBLIC`, `ACC_FINAL`, `ACC_INTERFACE`, and `ACC_ABSTRACT` flags; other
              +flags are ignored and do not affect `serialVersionUID` computation. Similarly,
              +for field modifiers, only the `ACC_PUBLIC`, `ACC_PRIVATE`, `ACC_PROTECTED`,
              +`ACC_STATIC`, `ACC_FINAL`, `ACC_VOLATILE`, and `ACC_TRANSIENT` flags are used
              +when computing `serialVersionUID` values. For constructor and method modifiers,
              +only the `ACC_PUBLIC`, `ACC_PRIVATE`, `ACC_PROTECTED`, `ACC_STATIC`,
              +`ACC_FINAL`, `ACC_SYNCHRONIZED`, `ACC_NATIVE`, `ACC_ABSTRACT` and `ACC_STRICT`
              +flags are used. Names and descriptors are written in the format used by the
              +`java.io.DataOutputStream.writeUTF` method.
              +
              +The sequence of items in the stream is as follows:
              +
              +1.  The class name.
              +
              +2.  The class modifiers written as a 32-bit integer.
              +
              +3.  The name of each interface sorted by name.
              +
              +4.  For each field of the class sorted by field name (except `private static`
              +    and `private transient` fields:
              +
              +    a.  The name of the field.
              +
              +    b.  The modifiers of the field written as a 32-bit integer.
              +
              +    c.  The descriptor of the field.
              +
              +5.  If a class initializer exists, write out the following:
              +
              +    a.  The name of the method, ``.
              +
              +    b.  The modifier of the method, `java.lang.reflect.Modifier.STATIC`,
              +        written as a 32-bit integer.
              +
              +    c.  The descriptor of the method, `()V`.
              +
              +6.  For each non-`private` constructor sorted by method name and signature:
              +
              +    a.  The name of the method, ``.
              +
              +    b.  The modifiers of the method written as a 32-bit integer.
              +
              +    c.  The descriptor of the method.
              +
              +7.  For each non-`private` method sorted by method name and signature:
              +
              +    a.  The name of the method.
              +
              +    b.  The modifiers of the method written as a 32-bit integer.
              +
              +    c.  The descriptor of the method.
              +
              +8.  The SHA-1 algorithm is executed on the stream of bytes produced by
              +    `DataOutputStream` and produces five 32-bit values `sha[0..4]`.
              +
              +9.  The hash value is assembled from the first and second 32-bit values of the
              +    SHA-1 message digest. If the result of the message digest, the five 32-bit
              +    words `H0 H1 H2 H3 H4`, is in an array of five `int` values named `sha`,
              +    the hash value would be computed as follows:
              +
              +```
              +      long hash = ((sha[0] >>> 24) & 0xFF) |
              +                  ((sha[0] >>> 16) & 0xFF) << 8 |
              +                  ((sha[0] >>> 8) & 0xFF) << 16 |
              +                  ((sha[0] >>> 0) & 0xFF) << 24 |
              +                  ((sha[1] >>> 24) & 0xFF) << 32 |
              +                  ((sha[1] >>> 16) & 0xFF) << 40 |
              +                  ((sha[1] >>> 8) & 0xFF) << 48 |
              +                  ((sha[1] >>> 0) & 0xFF) << 56;
              +```
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/examples.md b/jdk/src/java.base/share/specs/serialization/examples.md
              new file mode 100644
              index 00000000000..3817fca2889
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/examples.md
              @@ -0,0 +1,111 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](exceptions.html) | NEXT'
              +include-after: '[CONTENTS](index.html) | [PREV](exceptions.html) | NEXT'
              +
              +title: 'Java Object Serialization Specification: C - Example of Serializable Fields'
              +---
              +
              +-   [Example Alternate Implementation of
              +    java.io.File](#c.1-example-alternate-implementation-of-java.io.file)
              +
              +-------------------------------------------------------------------------------
              +
              +## C.1 Example Alternate Implementation of java.io.File
              +
              +This appendix provides a brief example of how an existing class could be
              +specified and implemented to interoperate with the existing implementation but
              +without requiring the same assumptions about the representation of the file
              +name as a *String*.
              +
              +The system class `java.io.File` represents a filename and has methods for
              +parsing, manipulating files and directories by name. It has a single private
              +field that contains the current file name. The semantics of the methods that
              +parse paths depend on the current path separator which is held in a static
              +field. This path separator is part of the serialized state of a file so that
              +file name can be adjusted when read.
              +
              +The serialized state of a `File` object is defined as the serializable fields
              +and the sequence of data values for the file. In this case, there is one of
              +each.
              +
              +```
              +Serializable Fields:
              +    String path;     // path name with embedded separators
              +Serializable Data:
              +    char            // path name separator for path name
              +```
              +
              +An alternate implementation might be defined as follows:
              +
              +```
              +class File implements java.io.Serializable {
              +    ...
              +    private String[] pathcomponents;
              +    // Define serializable fields with the ObjectStreamClass
              +
              +    /**
              +     * @serialField path String
              +     *              Path components separated by separator.
              +     */
              +
              +    private static final ObjectStreamField[] serialPersistentFields
              +        = { new ObjectStreamField("path", String.class) };
              +    ...
              +        /**
              +         * @serialData  Default fields followed by separator character.
              +         */
              +
              +    private void writeObject(ObjectOutputStream s)
              +        throws IOException
              +    {
              +        ObjectOutputStream.PutField fields = s.putFields();
              +        StringBuffer str = new StringBuffer();
              +        for(int i = 0; i < pathcomponents; i++) {
              +            str.append(separator);
              +            str.append(pathcomponents[i]);
              +        }
              +        fields.put("path", str.toString());
              +        s.writeFields();
              +        s.writeChar(separatorChar); // Add the separator character
              +    }
              +    ...
              +
              +    private void readObject(ObjectInputStream s)
              +        throws IOException
              +    {
              +        ObjectInputStream.GetField fields = s.readFields();
              +        String path = (String)fields.get("path", null);
              +        ...
              +        char sep = s.readChar(); // read the previous separator char
              +
              +        // parse path into components using the separator
              +        // and store into pathcomponents array.
              +    }
              +}
              +```
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/exceptions.md b/jdk/src/java.base/share/specs/serialization/exceptions.md
              new file mode 100644
              index 00000000000..a476d62c8a8
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/exceptions.md
              @@ -0,0 +1,97 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](security.html) | [NEXT](examples.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](security.html) | [NEXT](examples.html)'
              +
              +title: 'Java Object Serialization Specification: B - Exceptions In Object Serialization'
              +---
              +
              +-------------------------------------------------------------------------------
              +
              +All exceptions thrown by serialization classes are subclasses of
              +`ObjectStreamException` which is a subclass of `IOException`.
              +
              +### `ObjectStreamException`
              +
              +Superclass of all serialization exceptions.
              +
              +### `InvalidClassException`
              +
              +Thrown when a class cannot be used to restore objects for any of these reasons:
              +
              +-   The class does not match the serial version of the class in the stream.
              +-   The class contains fields with invalid primitive data types.
              +-   The `Externalizable` class does not have a public no-arg constructor.
              +-   The `Serializable` class can not access the no-arg constructor of its
              +    closest non-Serializable superclass.
              +
              +### `NotSerializableException`
              +
              +Thrown by a `readObject` or `writeObject` method to terminate serialization or
              +deserialization.
              +
              +### `StreamCorruptedException`
              +
              +Thrown:
              +
              +-   If the stream header is invalid.
              +-   If control information not found.
              +-   If control information is invalid.
              +-   JDK 1.1.5 or less attempts to call `readExternal` on a `PROTOCOL_VERSION_2`
              +    stream.
              +
              +### `NotActiveException`
              +
              +Thrown if `writeObject` state is invalid within the following
              +`ObjectOutputStream` methods:
              +
              +-   `defaultWriteObject`
              +-   `putFields`
              +-   `writeFields`
              +
              +Thrown if `readObject` state is invalid within the following
              +`ObjectInputStream` methods:
              +
              +-   `defaultReadObject`
              +-   `readFields`
              +-   `registerValidation`
              +
              +### `InvalidObjectException`
              +
              +Thrown when a restored object cannot be made valid.
              +
              +### `OptionalDataException`
              +
              +Thrown by `readObject` when there is primitive data in the stream and an object
              +is expected. The length field of the exception indicates the number of bytes
              +that are available in the current block.
              +
              +### `WriteAbortedException`
              +
              +Thrown when reading a stream terminated by an exception that occurred while the
              +stream was being written.
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/images/version.gif b/jdk/src/java.base/share/specs/serialization/images/version.gif
              new file mode 100644
              index 00000000000..79be14380d4
              Binary files /dev/null and b/jdk/src/java.base/share/specs/serialization/images/version.gif differ
              diff --git a/jdk/src/java.base/share/specs/serialization/index.md b/jdk/src/java.base/share/specs/serialization/index.md
              new file mode 100644
              index 00000000000..1ad49f7cbdc
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/index.md
              @@ -0,0 +1,132 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: 'CONTENTS | PREV | [NEXT](serial-arch.html)'
              +include-after: 'CONTENTS | PREV | [NEXT](serial-arch.html)'
              +
              +title: 'Java Object Serialization Specification: Contents'
              +---
              +
              +-------------------------------------------------------------------------------
              +
              +## Table of Contents
              +
              +### 1 [System Architecture](serial-arch.html)
              +
              +-   1.1 [Overview](serial-arch.html#overview)
              +-   1.2 [Writing to an Object
              +    Stream](serial-arch.html#writing-to-an-object-stream)
              +-   1.3 [Reading from an Object
              +    Stream](serial-arch.html#reading-from-an-object-stream)
              +-   1.4 [Object Streams as
              +    Containers](serial-arch.html#object-streams-as-containers)
              +-   1.5 [Defining Serializable Fields for a
              +    Class](serial-arch.html#defining-serializable-fields-for-a-class)
              +-   1.6 [Documenting Serializable Fields and Data for a
              +    Class](serial-arch.html#documenting-serializable-fields-and-data-for-a-class)
              +-   1.7 [Accessing Serializable Fields of a
              +    Class](serial-arch.html#accessing-serializable-fields-of-a-class)
              +-   1.8 [The ObjectOutput
              +    Interface](serial-arch.html#the-objectoutput-interface)
              +-   1.9 [The ObjectInput Interface](serial-arch.html#the-objectinput-interface)
              +-   1.10 [The Serializable
              +    Interface](serial-arch.html#the-serializable-interface)
              +-   1.11 [The Externalizable
              +    Interface](serial-arch.html#the-externalizable-interface)
              +-   1.12 [Serialization of Enum
              +    Constants](serial-arch.html#serialization-of-enum-constants)
              +-   1.13 [Protecting Sensitive
              +    Information](serial-arch.html#protecting-sensitive-information)
              +
              +### 2 [Object Output Classes](output.html)
              +
              +-   2.1 [The ObjectOutputStream
              +    Class](output.html#the-objectoutputstream-class)
              +-   2.2 [The ObjectOutputStream.PutField
              +    Class](output.html#the-objectoutputstream.putfield-class)
              +-   2.3 [The writeObject Method](output.html#the-writeobject-method)
              +-   2.4 [The writeExternal Method](output.html#the-writeexternal-method)
              +-   2.5 [The writeReplace Method](output.html#the-writereplace-method)
              +-   2.6 [The useProtocolVersion
              +    Method](output.html#the-useprotocolversion-method)
              +
              +### 3 [Object Input Classes](input.html)
              +
              +-   3.1 [The ObjectInputStream Class](input.html#the-objectinputstream-class)
              +-   3.2 [The ObjectInputStream.GetField
              +    Class](input.html#the-objectinputstream.getfield-class)
              +-   3.3 [The ObjectInputValidation
              +    Interface](input.html#the-objectinputvalidation-interface)
              +-   3.4 [The readObject Method](input.html#the-readobject-method)
              +-   3.5 [The readObjectNoData Method](input.html#the-readobjectnodata-method)
              +-   3.6 [The readExternal Method](input.html#the-readexternal-method)
              +-   3.7 [The readResolve Method](input.html#the-readresolve-method)
              +
              +### 4 [Class Descriptors](class.html)
              +
              +-   4.1 [The ObjectStreamClass Class](class.html#the-objectstreamclass-class)
              +-   4.2 [Dynamic Proxy Class
              +    Descriptors](class.html#dynamic-proxy-class-descriptors)
              +-   4.3 [Serialized Form](class.html#serialized-form)
              +-   4.4 [The ObjectStreamField Class](class.html#the-objectstreamfield-class)
              +-   4.5 [Inspecting Serializable
              +    Classes](class.html#inspecting-serializable-classes)
              +-   4.6 [Stream Unique Identifiers](class.html#stream-unique-identifiers)
              +
              +### 5 [Versioning of Serializable Objects](version.html)
              +
              +-   5.1 [Overview](version.html#overview)
              +-   5.2 [Goals](version.html#goals)
              +-   5.3 [Assumptions](version.html#assumptions)
              +-   5.4 [Who's Responsible for Versioning of
              +    Streams](version.html#whos-responsible-for-versioning-of-streams)
              +-   5.5 [Compatible Java Type
              +    Evolution](version.html#compatible-java-type-evolution)
              +-   5.6 [Type Changes Affecting
              +    Serialization](version.html#type-changes-affecting-serialization)
              +    -   5.6.1 [Incompatible Changes](version.html#incompatible-changes)
              +    -   5.6.2 [Compatible Changes](version.html#compatible-changes)
              +
              +### 6 [Object Serialization Stream Protocol](protocol.html)
              +
              +-   6.1 [Overview](protocol.html#overview)
              +-   6.2 [Stream Elements](protocol.html#stream-elements)
              +-   6.3 [Stream Protocol Versions](protocol.html#stream-protocol-versions)
              +-   6.4 [Grammar for the Stream
              +    Format](protocol.html#grammar-for-the-stream-format)
              +    -   6.4.1 [Rules of the Grammar](protocol.html#rules-of-the-grammar)
              +    -   6.4.2 [Terminal Symbols and
              +        Constants](protocol.html#terminal-symbols-and-constants)
              +
              +### A [Security in Object Serialization](security.html)
              +
              +### B [Exceptions In Object Serialization](exceptions.html)
              +
              +### C [Example of Serializable Fields](examples.html)
              +
              +-   [C.1 Example Alternate Implementation of
              +    `java.io.File`](examples.html#c.1-example-alternate-implementation-of-java.io.file)
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/input.md b/jdk/src/java.base/share/specs/serialization/input.md
              new file mode 100644
              index 00000000000..dd3e2b21a35
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/input.md
              @@ -0,0 +1,672 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](output.html) | [NEXT](class.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](output.html) | [NEXT](class.html)'
              +
              +title: 'Java Object Serialization Specification: 3 - Object Input Classes'
              +---
              +
              +-   [The ObjectInputStream Class](#the-objectinputstream-class)
              +-   [The ObjectInputStream.GetField
              +    Class](#the-objectinputstream.getfield-class)
              +-   [The ObjectInputValidation Interface](#the-objectinputvalidation-interface)
              +-   [The readObject Method](#the-readobject-method)
              +-   [The readExternal Method](#the-readexternal-method)
              +-   [The readResolve Method](#the-readresolve-method)
              +
              +-------------------------------------------------------------------------------
              +
              +## 3.1 The ObjectInputStream Class
              +
              +Class `ObjectInputStream` implements object deserialization. It maintains the
              +state of the stream including the set of objects already deserialized. Its
              +methods allow primitive types and objects to be read from a stream written by
              +`ObjectOutputStream`. It manages restoration of the object and the objects that
              +it refers to from the stream.
              +
              +```
              +package java.io;
              +
              +public class ObjectInputStream
              +    extends InputStream
              +    implements ObjectInput, ObjectStreamConstants
              +{
              +    public ObjectInputStream(InputStream in)
              +        throws StreamCorruptedException, IOException;
              +
              +    public final Object readObject()
              +        throws OptionalDataException, ClassNotFoundException,
              +            IOException;
              +
              +    public Object readUnshared()
              +        throws OptionalDataException, ClassNotFoundException,
              +            IOException;
              +
              +    public void defaultReadObject()
              +        throws IOException, ClassNotFoundException,
              +            NotActiveException;
              +
              +    public GetField readFields()
              +        throws IOException;
              +
              +    public synchronized void registerValidation(
              +        ObjectInputValidation obj, int prio)
              +        throws NotActiveException, InvalidObjectException;
              +
              +    protected ObjectStreamClass readClassDescriptor()
              +        throws IOException, ClassNotFoundException;
              +
              +    protected Class resolveClass(ObjectStreamClass v)
              +        throws IOException, ClassNotFoundException;
              +
              +    protected Object resolveObject(Object obj)
              +        throws IOException;
              +
              +    protected boolean enableResolveObject(boolean enable)
              +        throws SecurityException;
              +
              +    protected void readStreamHeader()
              +        throws IOException, StreamCorruptedException;
              +
              +    public int read() throws IOException;
              +
              +    public int read(byte[] data, int offset, int length)
              +        throws IOException
              +
              +    public int available() throws IOException;
              +
              +    public void close() throws IOException;
              +
              +    public boolean readBoolean() throws IOException;
              +
              +    public byte readByte() throws IOException;
              +
              +    public int readUnsignedByte() throws IOException;
              +
              +    public short readShort() throws IOException;
              +
              +    public int readUnsignedShort() throws IOException;
              +
              +    public char readChar() throws IOException;
              +
              +    public int readInt() throws IOException;
              +
              +    public long readLong() throws IOException;
              +
              +    public float readFloat() throws IOException;
              +
              +    public double readDouble() throws IOException;
              +
              +    public void readFully(byte[] data) throws IOException;
              +
              +    public void readFully(byte[] data, int offset, int size)
              +        throws IOException;
              +
              +    public int skipBytes(int len) throws IOException;
              +
              +    public String readLine() throws IOException;
              +
              +    public String readUTF() throws IOException;
              +
              +    // Class to provide access to serializable fields.
              +    static abstract public class GetField
              +    {
              +        public ObjectStreamClass getObjectStreamClass();
              +
              +        public boolean defaulted(String name)
              +            throws IOException, IllegalArgumentException;
              +
              +        public char get(String name, char default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public boolean get(String name, boolean default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public byte get(String name, byte default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public short get(String name, short default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public int get(String name, int default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public long get(String name, long default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public float get(String name, float default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public double get(String name, double default)
              +            throws IOException, IllegalArgumentException;
              +
              +        public Object get(String name, Object default)
              +            throws IOException, IllegalArgumentException;
              +    }
              +
              +    protected ObjectInputStream()
              +        throws StreamCorruptedException, IOException;
              +
              +    protected readObjectOverride()
              +        throws OptionalDataException, ClassNotFoundException,
              +            IOException;
              +}
              +```
              +
              +The single-argument `ObjectInputStream` constructor requires an `InputStream`.
              +The constructor calls `readStreamHeader` to read and verifies the header and
              +version written by the corresponding `ObjectOutputStream.writeStreamHeader`
              +method. If a security manager is installed, this constructor checks for the
              +`"enableSubclassImplementation"` `SerializablePermission` when invoked directly
              +or indirectly by the constructor of a subclass which overrides the `readFields`
              +and/or `readUnshared` methods.
              +
              +**Note:** The `ObjectInputStream` constructor blocks until it completes reading
              +the serialization stream header. Code which waits for an `ObjectInputStream` to
              +be constructed before creating the corresponding `ObjectOutputStream` for that
              +stream will deadlock, since the `ObjectInputStream` constructor will block
              +until a header is written to the stream, and the header will not be written to
              +the stream until the `ObjectOutputStream` constructor executes. This problem
              +can be resolved by creating the `ObjectOutputStream` before the
              +`ObjectInputStream`, or otherwise removing the timing dependency between
              +completion of `ObjectInputStream` construction and the creation of the
              +`ObjectOutputStream`.
              +
              +The `readObject` method is used to deserialize an object from the stream. It
              +reads from the stream to reconstruct an object.
              +
              +1.  If the `ObjectInputStream` subclass is overriding the implementation, call
              +    the `readObjectOverride` method and return. Reimplementation is described
              +    at the end of this section.
              +
              +2.  If a block data record occurs in the stream, throw a `BlockDataException`
              +    with the number of available bytes.
              +
              +3.  If the object in the stream is null, return null.
              +
              +4.  If the object in the stream is a handle to a previous object, return the
              +    object.
              +
              +5.  If the object in the stream is a `Class`, read its `ObjectStreamClass`
              +    descriptor, add it and its handle to the set of known objects, and return
              +    the corresponding `Class` object.
              +
              +6.  If the object in the stream is an `ObjectStreamClass`, read in its data
              +    according to the formats described in [Section 4.3, "Serialized
              +    Form"](class.html#serialized-form). Add it and its handle to the set of
              +    known objects. In versions 1.3 and later of the Java 2 SDK, Standard
              +    Edition, the `readClassDescriptor` method is called to read in the
              +    `ObjectStreamClass` if it represents a class that is not a dynamic proxy
              +    class, as indicated in the stream data. If the class descriptor represents
              +    a dynamic proxy class, call the `resolveProxyClass` method on the stream to
              +    get the local class for the descriptor; otherwise, call the `resolveClass`
              +    method on the stream to get the local class. If the class cannot be
              +    resolved, throw a ClassNotFoundException. Return the resulting
              +    `ObjectStreamClass` object.
              +
              +7.  If the object in the stream is a `String`, read its length information
              +    followed by the contents of the string encoded in modified UTF-8. For
              +    details, refer to [Section 6.2, "Stream
              +    Elements"](protocol.html#stream-elements). Add the `String` and its handle
              +    to the set of known objects, and proceed to Step 12.
              +
              +8.  If the object in the stream is an array, read its `ObjectStreamClass` and
              +    the length of the array. Allocate the array, and add it and its handle in
              +    the set of known objects. Read each element using the appropriate method
              +    for its type and assign it to the array. Proceed to Step 12.
              +
              +9.  If the object in the stream is an enum constant, read its
              +    `ObjectStreamClass` and the enum constant name. If the `ObjectStreamClass`
              +    represents a class that is not an enum type, an `InvalidClassException` is
              +    thrown. Obtain a reference to the enum constant by calling the
              +    `java.lang.Enum.valueOf` method, passing the enum type bound to the
              +    received `ObjectStreamClass` along with the received name as arguments. If
              +    the `valueOf` method throws an `IllegalArgumentException`, an
              +    `InvalidObjectException` is thrown with the `IllegalArgumentException` as
              +    its cause. Add the enum constant and its handle in the set of known
              +    objects, and proceed to Step 12.
              +
              +10. For all other objects, the `ObjectStreamClass` of the object is read from
              +    the stream. The local class for that `ObjectStreamClass` is retrieved. The
              +    class must be serializable or externalizable, and must not be an enum type.
              +    If the class does not satisfy these criteria, an `InvalidClassException` is
              +    thrown.
              +
              +11. An instance of the class is allocated. The instance and its handle are
              +    added to the set of known objects. The contents restored appropriately:
              +
              +    a.  For serializable objects, the no-arg constructor for the first
              +        non-serializable supertype is run. For serializable classes, the fields
              +        are initialized to the default value appropriate for its type. Then the
              +        fields of each class are restored by calling class-specific
              +        `readObject` methods, or if these are not defined, by calling the
              +        `defaultReadObject` method. Note that field initializers and
              +        constructors are not executed for serializable classes during
              +        deserialization. In the normal case, the version of the class that
              +        wrote the stream will be the same as the class reading the stream. In
              +        this case, all of the supertypes of the object in the stream will match
              +        the supertypes in the currently-loaded class. If the version of the
              +        class that wrote the stream had different supertypes than the loaded
              +        class, the `ObjectInputStream` must be more careful about restoring or
              +        initializing the state of the differing classes. It must step through
              +        the classes, matching the available data in the stream with the classes
              +        of the object being restored. Data for classes that occur in the
              +        stream, but do not occur in the object, is discarded. For classes that
              +        occur in the object, but not in the stream, the class fields are set to
              +        default values by default serialization.
              +
              +    b.  For externalizable objects, the no-arg constructor for the class is run
              +        and then the `readExternal` method is called to restore the contents of
              +        the object.
              +
              +12. Process potential substitutions by the class of the object and/or by a
              +    subclass of `ObjectInputStream`:
              +
              +    a.  If the class of the object is not an enum type and defines the
              +        appropriate `readResolve` method, the method is called to allow the
              +        object to replace itself.
              +
              +    b.  Then if previously enabled by `enableResolveObject,` the
              +        `resolveObject` method is called to allow subclasses of the stream to
              +        examine and replace the object. If the previous step did replace the
              +        original object, the `resolveObject` method is called with the
              +        replacement object. If a replacement took place, the table of known
              +        objects is updated so the replacement object is associated with the
              +        handle. The replacement object is then returned from `readObject`.
              +
              +All of the methods for reading primitives types only consume bytes from the
              +block data records in the stream. If a read for primitive data occurs when the
              +next item in the stream is an object, the read methods return *-1* or the
              +`EOFException` as appropriate. The value of a primitive type is read by a
              +`DataInputStream` from the block data record.
              +
              +The exceptions thrown reflect errors during the traversal or exceptions that
              +occur on the underlying stream. If any exception is thrown, the underlying
              +stream is left in an unknown and unusable state.
              +
              +When the reset token occurs in the stream, all of the state of the stream is
              +discarded. The set of known objects is cleared.
              +
              +When the exception token occurs in the stream, the exception is read and a new
              +`WriteAbortedException` is thrown with the terminating exception as an
              +argument. The stream context is reset as described earlier.
              +
              +The `readUnshared` method is used to read "unshared" objects from the stream.
              +This method is identical to `readObject`, except that it prevents subsequent
              +calls to `readObject` and `readUnshared` from returning additional references
              +to the deserialized instance returned by the original call to `readUnshared`.
              +Specifically:
              +
              +-   If `readUnshared` is called to deserialize a back-reference (the stream
              +    representation of an object which has been written previously to the
              +    stream), an `ObjectStreamException` will be thrown.
              +
              +-   If `readUnshared` returns successfully, then any subsequent attempts to
              +    deserialize back-references to the stream handle deserialized by
              +    `readUnshared` will cause an `ObjectStreamException` to be thrown.
              +
              +Deserializing an object via `readUnshared` invalidates the stream handle
              +associated with the returned object. Note that this in itself does not always
              +guarantee that the reference returned by `readUnshared` is unique; the
              +deserialized object may define a `readResolve` method which returns an object
              +visible to other parties, or `readUnshared` may return a `Class` object or enum
              +constant obtainable elsewhere in the stream or through external means. If the
              +deserialized object defines a `readResolve` method and the invocation of that
              +method returns an array, then `readUnshared` returns a shallow clone of that
              +array; this guarantees that the returned array object is unique and cannot be
              +obtained a second time from an invocation of `readObject` or `readUnshared` on
              +the `ObjectInputStream`, even if the underlying data stream has been
              +manipulated.
              +
              +The `defaultReadObject` method is used to read the fields and object from the
              +stream. It uses the class descriptor in the stream to read the fields in the
              +canonical order by name and type from the stream. The values are assigned to
              +the matching fields by name in the current class. Details of the versioning
              +mechanism can be found in [Section 5.5, "Compatible Java Type
              +Evolution"](version.html#compatible-java-type-evolution). Any field of the
              +object that does not appear in the stream is set to its default value. Values
              +that appear in the stream, but not in the object, are discarded. This occurs
              +primarily when a later version of a class has written additional fields that do
              +not occur in the earlier version. This method may only be called from the
              +`readObject` method while restoring the fields of a class. When called at any
              +other time, the `NotActiveException` is thrown.
              +
              +The `readFields` method reads the values of the serializable fields from the
              +stream and makes them available via the `GetField` class. The `readFields`
              +method is only callable from within the `readObject` method of a serializable
              +class. It cannot be called more than once or if `defaultReadObject` has been
              +called. The `GetFields` object uses the current object's `ObjectStreamClass` to
              +verify the fields that can be retrieved for this class. The `GetFields` object
              +returned by `readFields` is only valid during this call to the classes
              +`readObject` method. The fields may be retrieved in any order. Additional data
              +may only be read directly from stream after `readFields` has been called.
              +
              +The `registerValidation` method can be called to request a callback when the
              +entire graph has been restored but before the object is returned to the
              +original caller of `readObject`. The order of validate callbacks can be
              +controlled using the priority. Callbacks registered with higher values are
              +called before those with lower values. The object to be validated must support
              +the `ObjectInputValidation` interface and implement the `validateObject`
              +method. It is only correct to register validations during a call to a class's
              +`readObject` method. Otherwise, a `NotActiveException` is thrown. If the
              +callback object supplied to `registerValidation` is null, an
              +`InvalidObjectException` is thrown.
              +
              +Starting with the Java SDK, Standard Edition, v1.3, the `readClassDescriptor`
              +method is used to read in all `ObjectStreamClass` objects.
              +`readClassDescriptor` is called when the `ObjectInputStream` expects a class
              +descriptor as the next item in the serialization stream. Subclasses of
              +`ObjectInputStream` may override this method to read in class descriptors that
              +have been written in non-standard formats (by subclasses of
              +`ObjectOutputStream` which have overridden the `writeClassDescriptor` method).
              +By default, this method reads class descriptors according to the format
              +described in [Section 6.4, "Grammar for the Stream
              +Format"](protocol.html#grammar-for-the-stream-format).
              +
              +The `resolveClass` method is called while a class is being deserialized, and
              +after the class descriptor has been read. Subclasses may extend this method to
              +read other information about the class written by the corresponding subclass of
              +`ObjectOutputStream`. The method must find and return the class with the given
              +name and `serialVersionUID`. The default implementation locates the class by
              +calling the class loader of the closest caller of `readObject` that has a class
              +loader. If the class cannot be found `ClassNotFoundException` should be thrown.
              +Prior to JDK 1.1.6, the `resolveClass` method was required to return the same
              +fully qualified class name as the class name in the stream. In order to
              +accommodate package renaming across releases, `method` `resolveClass` only
              +needs to return a class with the same base class name and `SerialVersionUID` in
              +JDK 1.1.6 and later versions.
              +
              +The `resolveObject` method is used by trusted subclasses to monitor or
              +substitute one object for another during deserialization. Resolving objects
              +must be enabled explicitly by calling `enableResolveObject` before calling
              +`readObject` for the first object to be resolved. Once enabled, `resolveObject`
              +is called once for each serializable object just prior to the first time it is
              +being returned from `readObject`. Note that the `resolveObject` method is not
              +called for objects of the specially handled classes, `Class`,
              +`ObjectStreamClass`, `String`, and arrays. A subclass's implementation of
              +`resolveObject` may return a substitute object that will be assigned or
              +returned instead of the original. The object returned must be of a type that is
              +consistent and assignable to every reference of the original object or else a
              +`ClassCastException` will be thrown. All assignments are type-checked. All
              +references in the stream to the original object will be replaced by references
              +to the substitute object.
              +
              +The `enableResolveObject` method is called by trusted subclasses of
              +`ObjectOutputStream` to enable the monitoring or substitution of one object for
              +another during deserialization. Replacing objects is disabled until
              +`enableResolveObject` is called with a `true` value. It may thereafter be
              +disabled by setting it to `false`. The previous setting is returned. The
              +`enableResolveObject` method checks if the stream has permission to request
              +substitution during serialization. To ensure that the private state of objects
              +is not unintentionally exposed, only trusted streams may use `resolveObject`.
              +Trusted classes are those classes with a class loader equal to null or belong
              +to a security protection domain that provides permission to enable
              +substitution.
              +
              +If the subclass of `ObjectInputStream` is not considered part of the system
              +domain, a line has to be added to the security policy file to provide to a
              +subclass of `ObjectInputStream` permission to call `enableResolveObject`. The
              +`SerializablePermission` to add is `"enableSubstitution"`.
              +`AccessControlException` is thrown if the protection domain of the subclass of
              +`ObjectStreamClass` does not have permission to `"enableSubstitution"` by
              +calling `enableResolveObject`. See the document Java Security Architecture (JDK
              +1.2) for additional information about the security model.
              +
              +The `readStreamHeader` method reads and verifies the magic number and version
              +of the stream. If they do not match, the `StreamCorruptedMismatch` is thrown.
              +
              +To override the implementation of deserialization, a subclass of
              +`ObjectInputStream` should call the protected no-arg `ObjectInputStream`,
              +constructor. There is a security check within the no-arg constructor for
              +`SerializablePermission "enableSubclassImplementation"` to ensure that only
              +trusted classes are allowed to override the default implementation. This
              +constructor does not allocate any private data for `ObjectInputStream` and sets
              +a flag that indicates that the final `readObject` method should invoke the
              +`readObjectOverride` method and return. All other `ObjectInputStream` methods
              +are not final and can be directly overridden by the subclass.
              +
              +## 3.2 The ObjectInputStream.GetField Class
              +
              +The class `ObjectInputStream.GetField` provides the API for getting the values
              +of serializable fields. The protocol of the stream is the same as used by
              +`defaultReadObject.` Using `readFields` to access the serializable fields does
              +not change the format of the stream. It only provides an alternate API to
              +access the values which does not require the class to have the corresponding
              +non-transient and non-static fields for each named serializable field. The
              +serializable fields are those declared using `serialPersistentFields` or if it
              +is not declared the non-transient and non-static fields of the object. When the
              +stream is read the available serializable fields are those written to the
              +stream when the object was serialized. If the class that wrote the stream is a
              +different version not all fields will correspond to the serializable fields of
              +the current class. The available fields can be retrieved from the
              +`ObjectStreamClass` of the `GetField` object.
              +
              +The `getObjectStreamClass` method returns an `ObjectStreamClass` object
              +representing the class in the stream. It contains the list of serializable
              +fields.
              +
              +The `defaulted` method returns *true* if the field is not present in the
              +stream. An `IllegalArgumentException` is thrown if the requested field is not a
              +serializable field of the current class.
              +
              +Each `get` method returns the specified serializable field from the stream. I/O
              +exceptions will be thrown if the underlying stream throws an exception. An
              +`IllegalArgumentException` is thrown if the name or type does not match the
              +name and type of an field serializable field of the current class. The default
              +value is returned if the stream does not contain an explicit value for the
              +field.
              +
              +## 3.3 The ObjectInputValidation Interface
              +
              +This interface allows an object to be called when a complete graph of objects
              +has been deserialized. If the object cannot be made valid, it should throw the
              +`ObjectInvalidException`. Any exception that occurs during a call to
              +`validateObject` will terminate the validation process, and the
              +`InvalidObjectException` will be thrown.
              +
              +```
              +package java.io;
              +
              +public interface ObjectInputValidation
              +{
              +    public void validateObject()
              +        throws InvalidObjectException;
              +}
              +```
              +
              +## 3.4 The readObject Method
              +
              +For serializable objects, the `readObject` method allows a class to control the
              +deserialization of its own fields. Here is its signature:
              +
              +```
              +private void readObject(ObjectInputStream stream)
              +    throws IOException, ClassNotFoundException;
              +```
              +
              +Each subclass of a serializable object may define its own `readObject` method.
              +If a class does not implement the method, the default serialization provided by
              +`defaultReadObject` will be used. When implemented, the class is only
              +responsible for restoring its own fields, not those of its supertypes or
              +subtypes.
              +
              +The `readObject` method of the class, if implemented, is responsible for
              +restoring the state of the class. The values of every field of the object
              +whether transient or not, static or not are set to the default value for the
              +fields type. Either `ObjectInputStream`'s `defaultReadObject` or `readFields`
              +method must be called once (and only once) before reading any optional data
              +written by the corresponding `writeObject` method; even if no optional data is
              +read, `defaultReadObject` or `readFields` must still be invoked once. If the
              +`readObject` method of the class attempts to read more data than is present in
              +the optional part of the stream for this class, the stream will return `-1` for
              +bytewise reads, throw an `EOFException` for primitive data reads (e.g.,
              +`readInt`, `readFloat`), or throw an `OptionalDataException` with the `eof`
              +field set to `true` for object reads.
              +
              +The responsibility for the format, structure, and versioning of the optional
              +data lies completely with the class. The `@serialData` javadoc tag within the
              +javadoc comment for the `readObject` method should be used to document the
              +format and structure of the optional data.
              +
              +If the class being restored is not present in the stream being read, then its
              +`readObjectNoData` method, if defined, is invoked (instead of `readObject`);
              +otherwise, its fields are initialized to the appropriate default values. For
              +further detail, see [Section 3.5, "The readObjectNoData
              +Method"](#the-readobjectnodata-method).
              +
              +Reading an object from the `ObjectInputStream` is analogous to creating a new
              +object. Just as a new object's constructors are invoked in the order from the
              +superclass to the subclass, an object being read from a stream is deserialized
              +from superclass to subclass. The `readObject` or `readObjectNoData` method is
              +called instead of the constructor for each `Serializable` subclass during
              +deserialization.
              +
              +One last similarity between a constructor and a `readObject` method is that
              +both provide the opportunity to invoke a method on an object that is not fully
              +constructed. Any overridable (neither private, static nor final) method called
              +while an object is being constructed can potentially be overridden by a
              +subclass. Methods called during the construction phase of an object are
              +resolved by the actual type of the object, not the type currently being
              +initialized by either its constructor or `readObject`/`readObjectNoData`
              +method. Therefore, calling an overridable method from within a `readObject` or
              +`readObjectNoData` method may result in the unintentional invocation of a
              +subclass method before the superclass has been fully initialized.
              +
              +## 3.5 The readObjectNoData Method
              +
              +For serializable objects, the `readObjectNoData` method allows a class to
              +control the initialization of its own fields in the event that a subclass
              +instance is deserialized and the serialization stream does not list the class
              +in question as a superclass of the deserialized object. This may occur in cases
              +where the receiving party uses a different version of the deserialized
              +instance's class than the sending party, and the receiver's version extends
              +classes that are not extended by the sender's version. This may also occur if
              +the serialization stream has been tampered; hence, `readObjectNoData` is useful
              +for initializing deserialized objects properly despite a "hostile" or
              +incomplete source stream.
              +
              +```
              +private void readObjectNoData() throws ObjectStreamException;
              +```
              +
              +Each serializable class may define its own `readObjectNoData` method. If a
              +serializable class does not define a `readObjectNoData` method, then in the
              +circumstances listed above the fields of the class will be initialized to their
              +default values (as listed in The Java Language Specification); this behavior is
              +consistent with that of `ObjectInputStream` prior to version 1.4 of the Java 2
              +SDK, Standard Edition, when support for `readObjectNoData` methods was
              +introduced. If a serializable class does define a `readObjectNoData` method and
              +the aforementioned conditions arise, then `readObjectNoData` will be invoked at
              +the point during deserialization when a class-defined `readObject` method would
              +otherwise be called had the class in question been listed by the stream as a
              +superclass of the instance being deserialized.
              +
              +## 3.6 The readExternal Method
              +
              +Objects implementing `java.io.Externalizable` must implement the `readExternal`
              +method to restore the entire state of the object. It must coordinate with its
              +superclasses to restore their state. All of the methods of `ObjectInput` are
              +available to restore the object's primitive typed fields and object fields.
              +
              +```
              +public void readExternal(ObjectInput stream)
              +    throws IOException;
              +```
              +
              +**Note:** The `readExternal` method is public, and it raises the risk of a
              +client being able to overwrite an existing object from a stream. The class may
              +add its own checks to insure that this is only called when appropriate.
              +
              +A new stream protocol version has been introduced in JDK 1.2 to correct a
              +problem with `Externalizable` objects. The old definition of `Externalizable`
              +objects required the local virtual machine to find a `readExternal` method to
              +be able to properly read an `Externalizable` object from the stream. The new
              +format adds enough information to the stream protocol so serialization can skip
              +an `Externalizable` object when the local `readExternal` method is not
              +available. Due to class evolution rules, serialization must be able to skip an
              +`Externalizable` object in the input stream if there is not a mapping for the
              +object using the local classes.
              +
              +An additional benefit of the new `Externalizable` stream format is that
              +`ObjectInputStream` can detect attempts to read more External data than is
              +available, and can also skip by any data that is left unconsumed by a
              +`readExternal` method. The behavior of `ObjectInputStream` in response to a
              +read past the end of External data is the same as the behavior when a
              +class-defined `readObject` method attempts to read past the end of its optional
              +data: bytewise reads will return `-1`, primitive reads will throw
              +`EOFException`s, and object reads will throw `OptionalDataException`s with the
              +`eof` field set to `true`.
              +
              +Due to the format change, JDK 1.1.6 and earlier releases are not able to read
              +the new format. `StreamCorruptedException` is thrown when JDK 1.1.6 or earlier
              +attempts to read an `Externalizable` object from a stream written in
              +`PROTOCOL_VERSION_2`. Compatibility issues are discussed in more detail in
              +[Section 6.3, "Stream Protocol
              +Versions"](protocol.html#stream-protocol-versions).
              +
              +## 3.7 The readResolve Method
              +
              +For Serializable and Externalizable classes, the `readResolve` method allows a
              +class to replace/resolve the object read from the stream before it is returned
              +to the caller. By implementing the `readResolve` method, a class can directly
              +control the types and instances of its own instances being deserialized. The
              +method is defined as follows:
              +
              +```
              +ANY-ACCESS-MODIFIER Object readResolve()
              +            throws ObjectStreamException;
              +```
              +
              +The `readResolve` method is called when `ObjectInputStream` has read an object
              +from the stream and is preparing to return it to the caller.
              +`ObjectInputStream` checks whether the class of the object defines the
              +`readResolve` method. If the method is defined, the `readResolve` method is
              +called to allow the object in the stream to designate the object to be
              +returned. The object returned should be of a type that is compatible with all
              +uses. If it is not compatible, a `ClassCastException` will be thrown when the
              +type mismatch is discovered.
              +
              +For example, a `Symbol` class could be created for which only a single instance
              +of each symbol binding existed within a virtual machine. The `readResolve`
              +method would be implemented to determine if that symbol was already defined and
              +substitute the preexisting equivalent `Symbol` object to maintain the identity
              +constraint. In this way the uniqueness of `Symbol` objects can be maintained
              +across serialization.
              +
              +**Note:** The `readResolve` method is not invoked on the object until the
              +object is fully constructed, so any references to this object in its object
              +graph will not be updated to the new object nominated by `readResolve`.
              +However, during the serialization of an object with the `writeReplace` method,
              +all references to the original object in the replacement object's object graph
              +are replaced with references to the replacement object. Therefore in cases
              +where an object being serialized nominates a replacement object whose object
              +graph has a reference to the original object, deserialization will result in an
              +incorrect graph of objects. Furthermore, if the reference types of the object
              +being read (nominated by `writeReplace`) and the original object are not
              +compatible, the construction of the object graph will raise a
              +`ClassCastException`.
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/output.md b/jdk/src/java.base/share/specs/serialization/output.md
              new file mode 100644
              index 00000000000..46b47cc45e6
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/output.md
              @@ -0,0 +1,514 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](serial-arch.html) | [NEXT](input.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](serial-arch.html) | [NEXT](input.html)'
              +
              +title: 'Java Object Serialization Specification: 2 - Object Output Classes'
              +---
              +
              +-   [The ObjectOutputStream Class](#the-objectoutputstream-class)
              +-   [The ObjectOutputStream.PutField
              +    Class](#the-objectoutputstream.putfield-class)
              +-   [The writeObject Method](#the-writeobject-method)
              +-   [The writeExternal Method](#the-writeexternal-method)
              +-   [The writeReplace Method](#the-writereplace-method)
              +-   [The useProtocolVersion Method](#the-useprotocolversion-method)
              +
              +-------------------------------------------------------------------------------
              +
              +## 2.1 The ObjectOutputStream Class
              +
              +Class `ObjectOutputStream` implements object serialization. It maintains the
              +state of the stream including the set of objects already serialized. Its
              +methods control the traversal of objects to be serialized to save the specified
              +objects and the objects to which they refer.
              +
              +```
              +package java.io;
              +
              +public class ObjectOutputStream
              +    extends OutputStream
              +    implements ObjectOutput, ObjectStreamConstants
              +{
              +    public ObjectOutputStream(OutputStream out)
              +        throws IOException;
              +
              +    public final void writeObject(Object obj)
              +        throws IOException;
              +
              +    public void writeUnshared(Object obj)
              +        throws IOException;
              +
              +    public void defaultWriteObject()
              +        throws IOException, NotActiveException;
              +
              +    public PutField putFields()
              +        throws IOException;
              +
              +    public writeFields()
              +        throws IOException;
              +
              +    public void reset() throws IOException;
              +
              +    protected void annotateClass(Class cl) throws IOException;
              +
              +    protected void writeClassDescriptor(ObjectStreamClass desc)
              +        throws IOException;
              +
              +    protected Object replaceObject(Object obj) throws IOException;
              +
              +    protected boolean enableReplaceObject(boolean enable)
              +        throws SecurityException;
              +
              +    protected void writeStreamHeader() throws IOException;
              +
              +    public void write(int data) throws IOException;
              +
              +    public void write(byte b[]) throws IOException;
              +
              +    public void write(byte b[], int off, int len) throws IOException;
              +
              +    public void flush() throws IOException;
              +
              +    protected void drain() throws IOException;
              +
              +    public void close() throws IOException;
              +
              +    public void writeBoolean(boolean data) throws IOException;
              +
              +    public void writeByte(int data) throws IOException;
              +
              +    public void writeShort(int data) throws IOException;
              +
              +    public void writeChar(int data) throws IOException;
              +
              +    public void writeInt(int data) throws IOException;
              +
              +    public void writeLong(long data) throws IOException;
              +
              +    public void writeFloat(float data) throws IOException;
              +
              +    public void writeDouble(double data) throws IOException;
              +
              +    public void writeBytes(String data) throws IOException;
              +
              +    public void writeChars(String data) throws IOException;
              +
              +    public void writeUTF(String data) throws IOException;
              +
              +    // Inner class to provide access to serializable fields.
              +    abstract static public class PutField
              +    {
              +        public void put(String name, boolean value)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, char data)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, byte data)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, short data)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, int data)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, long data)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, float data)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, double data)
              +            throws IOException, IllegalArgumentException;
              +
              +        public void put(String name, Object data)
              +            throws IOException, IllegalArgumentException;
              +    }
              +
              +    public void useProtocolVersion(int version) throws IOException;
              +
              +    protected ObjectOutputStream()
              +        throws IOException;
              +
              +     protected writeObjectOverride()
              +        throws NotActiveException, IOException;
              +}
              +```
              +
              +The single-argument `ObjectOutputStream` constructor creates an
              +`ObjectOutputStream` that serializes objects to the given `OutputStream`. The
              +constructor calls `writeStreamHeader` to write a magic number and version to
              +the stream that will be read and verified by a corresponding call to
              +`readStreamHeader` in the single-argument `ObjectInputStream` constructor. If a
              +security manager is installed, this constructor checks for the
              +`"enableSubclassImplementation"` `SerializablePermission` when invoked directly
              +or indirectly by the constructor of a subclass which overrides the `putFields`
              +and/or `writeUnshared` methods.
              +
              +The `writeObject` method is used to serialize an object to the stream. An
              +object is serialized as follows:
              +
              +1.  If a subclass is overriding the implementation, call the
              +    `writeObjectOverride` method and return. Overriding the implementation is
              +    described at the end of this section.
              +
              +2.  If there is data in the block-data buffer, the data is written to the
              +    stream and the buffer is reset.
              +
              +3.  If the object is null, null is put in the stream and `writeObject` returns.
              +
              +4.  If the object has been previously replaced, as described in Step 8, write
              +    the handle of the replacement to the stream and `writeObject` returns.
              +
              +5.  If the object has already been written to the stream, its handle is written
              +    to the stream and `writeObject` returns.
              +
              +6.  If the object is a `Class`, the corresponding `ObjectStreamClass` is
              +    written to the stream, a handle is assigned for the class, and
              +    `writeObject` returns.
              +
              +7.  If the object is an `ObjectStreamClass`, a handle is assigned to the
              +    object, after which it is written to the stream using one of the class
              +    descriptor formats described in [Section 4.3, "Serialized
              +    Form"](class.html#serialized-form). In versions 1.3 and later of the Java 2
              +    SDK, Standard Edition, the `writeClassDescriptor` method is called to
              +    output the `ObjectStreamClass` if it represents a class that is not a
              +    dynamic proxy class, as determined by passing the associated `Class` object
              +    to the `isProxyClass` method of `java.lang.reflect.Proxy`. Afterwards, an
              +    annotation for the represented class is written: if the class is a dynamic
              +    proxy class, then the `annotateProxyClass` method is called; otherwise, the
              +    `annotateClass` method is called. The `writeObject` method then returns.
              +
              +8.  Process potential substitutions by the class of the object and/or by a
              +    subclass of `ObjectInputStream`.
              +
              +    a.  If the class of an object is not an enum type and defines the
              +        appropriate `writeReplace` method, the method is called. Optionally, it
              +        can return a substitute object to be serialized.
              +
              +    b.  Then, if enabled by calling the `enableReplaceObject` method, the
              +        `replaceObject` method is called to allow subclasses of
              +        `ObjectOutputStream` to substitute for the object being serialized. If
              +        the original object was replaced in the previous step, the
              +        `replaceObject` method is called with the replacement object.
              +
              +    If the original object was replaced by either one or both steps above, the
              +    mapping from the original object to the replacement is recorded for later
              +    use in Step 4. Then, Steps 3 through 7 are repeated on the new object. 
              +
              +    If the replacement object is not one of the types covered by Steps 3
              +    through 7, processing resumes using the replacement object at Step 10.
              +
              +9.  
              +    If the object is a `java.lang.String,` the string is written as length
              +    information followed by the contents of the string encoded in modified
              +    UTF-8. For details, refer to [Section 6.2, "Stream
              +    Elements"](protocol.html#stream-elements). A handle is assigned to the
              +    string, and `writeObject` returns.
              +
              +10. If the object is an array, `writeObject` is called recursively to write the
              +    `ObjectStreamClass` of the array. The handle for the array is assigned. It
              +    is followed by the length of the array. Each element of the array is then
              +    written to the stream, after which `writeObject` returns.
              +
              +11. If the object is an enum constant, the `ObjectStreamClass` for the enum
              +    type of the constant is written by recursively calling `writeObject`. It
              +    will appear in the stream only the first time it is referenced. A handle is
              +    assigned for the enum constant. Next, the value returned by the `name`
              +    method of the enum constant is written as a `String` object, as described
              +    in step 9. Note that if the same name string has appeared previously in the
              +    stream, a back reference to it will be written. The `writeObject` method
              +    then returns.
              +
              +12. For regular objects, the `ObjectStreamClass` for the class of the object is
              +    written by recursively calling `writeObject`. It will appear in the stream
              +    only the first time it is referenced. A handle is assigned for the object.
              +
              +13. The contents of the object are written to the stream.
              +
              +    a.  If the object is serializable, the highest serializable class is
              +        located. For that class, and each derived class, that class's fields
              +        are written. If the class does not have a `writeObject` method, the
              +        `defaultWriteObject` method is called to write the serializable fields
              +        to the stream. If the class does have a `writeObject` method, it is
              +        called. It may call `defaultWriteObject` or `putFields` and
              +        `writeFields` to save the state of the object, and then it can write
              +        other information to the stream.
              +
              +    b.  If the object is externalizable, the `writeExternal` method of the
              +        object is called.
              +
              +    c.  If the object is neither serializable or externalizable, the
              +        `NotSerializableException` is thrown.
              +
              +Exceptions may occur during the traversal or may occur in the underlying
              +stream. For any subclass of `IOException`, the exception is written to the
              +stream using the exception protocol and the stream state is discarded. If a
              +second `IOException` is thrown while attempting to write the first exception
              +into the stream, the stream is left in an unknown state and
              +`StreamCorruptedException` is thrown from `writeObject`. For other exceptions,
              +the stream is aborted and left in an unknown and unusable state.
              +
              +The `writeUnshared` method writes an "unshared" object to the
              +`ObjectOutputStream`. This method is identical to `writeObject`, except that it
              +always writes the given object as a new, unique object in the stream (as
              +opposed to a back-reference pointing to a previously serialized instance).
              +Specifically:
              +
              +-   An object written via `writeUnshared` is always serialized in the same
              +    manner as a newly appearing object (an object that has not been written to
              +    the stream yet), regardless of whether or not the object has been written
              +    previously.
              +
              +-   If `writeObject` is used to write an object that has been previously
              +    written with `writeUnshared`, the previous `writeUnshared` operation is
              +    treated as if it were a write of a separate object. In other words,
              +    `ObjectOutputStream` will never generate back-references to object data
              +    written by calls to `writeUnshared`.
              +
              +While writing an object via `writeUnshared` does not in itself guarantee a
              +unique reference to the object when it is deserialized, it allows a single
              +object to be defined multiple times in a stream, so that multiple calls to the
              +`ObjectInputStream.readUnshared` method (see [Section 3.1, "The
              +ObjectInputStream Class"](input.html#the-objectinputstream-class)) by the
              +receiver will not conflict. Note that the rules described above only apply to
              +the base-level object written with `writeUnshared`, and not to any transitively
              +referenced sub-objects in the object graph to be serialized.
              +
              +The `defaultWriteObject` method implements the default serialization mechanism
              +for the current class. This method may be called only from a class's
              +`writeObject` method. The method writes all of the serializable fields of the
              +current class to the stream. If called from outside the `writeObject` method,
              +the `NotActiveException` is thrown.
              +
              +The `putFields` method returns a `PutField` object the caller uses to set the
              +values of the serializable fields in the stream. The fields may be set in any
              +order. After all of the fields have been set, `writeFields` must be called to
              +write the field values in the canonical order to the stream. If a field is not
              +set, the default value appropriate for its type will be written to the stream.
              +This method may only be called from within the `writeObject` method of a
              +serializable class. It may not be called more than once or if
              +`defaultWriteObject` has been called. Only after `writeFields` has been called
              +can other data be written to the stream.
              +
              +The `reset` method resets the stream state to be the same as if it had just
              +been constructed. `Reset` will discard the state of any objects already written
              +to the stream. The current point in the stream is marked as reset, so the
              +corresponding `ObjectInputStream` will reset at the same point. Objects
              +previously written to the stream will not be remembered as already having been
              +written to the stream. They will be written to the stream again. This is useful
              +when the contents of an object or objects must be sent again. `Reset` may not
              +be called while objects are being serialized. If called inappropriately, an
              +`IOException` is thrown.
              +
              +Starting with the Java 2 SDK, Standard Edition, v1.3, the
              +`writeClassDescriptor` method is called when an `ObjectStreamClass` needs to be
              +serialized. `writeClassDescriptor` is responsible for writing a representation
              +of the `ObjectStreamClass` to the serialization stream. Subclasses may override
              +this method to customize the way in which class descriptors are written to the
              +serialization stream. If this method is overridden, then the corresponding
              +`readClassDescriptor` method in `ObjectInputStream` should also be overridden
              +to reconstitute the class descriptor from its custom stream representation. By
              +default, `writeClassDescriptor` writes class descriptors according to the
              +format specified in [Section 6.4, "Grammar for the Stream
              +Format"](protocol.html#grammar-for-the-stream-format). Note that this method
              +will only be called if the `ObjectOutputStream` is not using the old
              +serialization stream format (see [Section 6.3, "Stream Protocol
              +Versions"](protocol.html#stream-protocol-versions)). If the serialization
              +stream is using the old format (`ObjectStreamConstants.PROTOCOL_VERSION_1`),
              +the class descriptor will be written internally in a manner that cannot be
              +overridden or customized.
              +
              +The `annotateClass` method is called while a `Class` is being serialized, and
              +after the class descriptor has been written to the stream. Subclasses may
              +extend this method and write other information to the stream about the class.
              +This information must be read by the `resolveClass` method in a corresponding
              +`ObjectInputStream` subclass.
              +
              +An `ObjectOutputStream` subclass can implement the `replaceObject` method to
              +monitor or replace objects during serialization. Replacing objects must be
              +enabled explicitly by calling `enableReplaceObject` before calling
              +`writeObject` with the first object to be replaced. Once enabled,
              +`replaceObject` is called for each object just prior to serializing the object
              +for the first time. Note that the `replaceObject` method is not called for
              +objects of the specially handled classes, `Class` and `ObjectStreamClass`. An
              +implementation of a subclass may return a substitute object that will be
              +serialized instead of the original. The substitute object must be serializable.
              +All references in the stream to the original object will be replaced by the
              +substitute object.
              +
              +When objects are being replaced, the subclass must ensure that the substituted
              +object is compatible with every field where the reference will be stored, or
              +that a complementary substitution will be made during deserialization. Objects,
              +whose type is not a subclass of the type of the field or array element, will
              +later abort the deserialization by raising a `ClassCastException` and the
              +reference will not be stored.
              +
              +The `enableReplaceObject` method can be called by trusted subclasses of
              +`ObjectOutputStream` to enable the substitution of one object for another
              +during serialization. Replacing objects is disabled until `enableReplaceObject`
              +is called with a `true` value. It may thereafter be disabled by setting it to
              +`false`. The previous setting is returned. The `enableReplaceObject` method
              +checks that the stream requesting the replacement can be trusted. To ensure
              +that the private state of objects is not unintentionally exposed, only trusted
              +stream subclasses may use `replaceObject`. Trusted classes are those classes
              +that belong to a security protection domain with permission to enable
              +Serializable substitution.
              +
              +If the subclass of `ObjectOutputStream` is not considered part of the system
              +domain, `SerializablePermission "enableSubstitution"` must be added to the
              +security policy file. `AccessControlException` is thrown if the protection
              +domain of the subclass of `ObjectInputStream` does not have permission to
              +`"enableSubstitution"` by calling `enableReplaceObject`. See the document Java
              +Security Architecture (JDK1.2) for additional information about the security
              +model.
              +
              +The `writeStreamHeader` method writes the magic number and version to the
              +stream. This information must be read by the `readStreamHeader` method of
              +`ObjectInputStream`. Subclasses may need to implement this method to identify
              +the stream's unique format.
              +
              +The `flush` method is used to empty any buffers being held by the stream and to
              +forward the flush to the underlying stream. The `drain` method may be used by
              +subclassers to empty only the `ObjectOutputStream`'s buffers without forcing
              +the underlying stream to be flushed.
              +
              +All of the write methods for primitive types encode their values using a
              +`DataOutputStream` to put them in the standard stream format. The bytes are
              +buffered into block data records so they can be distinguished from the encoding
              +of objects. This buffering allows primitive data to be skipped if necessary for
              +class versioning. It also allows the stream to be parsed without invoking
              +class-specific methods.
              +
              +To override the implementation of serialization, the subclass of
              +`ObjectOutputStream` should call the protected no-arg `ObjectOutputStream`,
              +constructor. There is a security check within the no-arg constructor for
              +`SerializablePermission "enableSubclassImplementation"` to ensure that only
              +trusted classes are allowed to override the default implementation. This
              +constructor does not allocate any private data for `ObjectOutputStream` and
              +sets a flag that indicates that the final `writeObject` method should invoke
              +the `writeObjectOverride` method and return. All other `ObjectOutputStream`
              +methods are not final and can be directly overridden by the subclass.
              +
              +## 2.2 The ObjectOutputStream.PutField Class
              +
              +Class `PutField` provides the API for setting values of the serializable fields
              +for a class when the class does not use default serialization. Each method puts
              +the specified named value into the stream. An `IllegalArgumentException` is
              +thrown if `name` does not match the name of a serializable field for the class
              +whose fields are being written, or if the type of the named field does not
              +match the second parameter type of the specific `put` method invoked.
              +
              +## 2.3 The writeObject Method
              +
              +For serializable objects, the `writeObject` method allows a class to control
              +the serialization of its own fields. Here is its signature:
              +
              +```
              +private void writeObject(ObjectOutputStream stream)
              +    throws IOException;
              +```
              +
              +Each subclass of a serializable object may define its own `writeObject` method.
              +If a class does not implement the method, the default serialization provided by
              +`defaultWriteObject` will be used. When implemented, the class is only
              +responsible for writing its own fields, not those of its supertypes or
              +subtypes.
              +
              +The class's `writeObject` method, if implemented, is responsible for saving the
              +state of the class. Either `ObjectOutputStream`'s `defaultWriteObject` or
              +`writeFields` method must be called once (and only once) before writing any
              +optional data that will be needed by the corresponding `readObject` method to
              +restore the state of the object; even if no optional data is written,
              +`defaultWriteObject` or `writeFields` must still be invoked once. If
              +`defaultWriteObject` or `writeFields` is not invoked once prior to the writing
              +of optional data (if any), then the behavior of instance deserialization is
              +undefined in cases where the `ObjectInputStream` cannot resolve the class which
              +defined the `writeObject` method in question.
              +
              +The responsibility for the format, structure, and versioning of the optional
              +data lies completely with the class.
              +
              +## 2.4 The writeExternal Method
              +
              +Objects implementing `java.io.Externalizable` must implement the
              +`writeExternal` method to save the entire state of the object. It must
              +coordinate with its superclasses to save their state. All of the methods of
              +`ObjectOutput` are available to save the object's primitive typed fields and
              +object fields.
              +
              +```
              +public void writeExternal(ObjectOutput stream)
              +    throws IOException;
              +```
              +
              +A new default format for writing Externalizable data has been introduced in JDK
              +1.2. The new format specifies that primitive data will be written in block data
              +mode by `writeExternal` methods. Additionally, a tag denoting the end of the
              +External object is appended to the stream after the `writeExternal` method
              +returns. The benefits of this format change are discussed in [Section 3.6, "The
              +readExternal Method"](input.html#the-readexternal-method). Compatibility issues
              +caused by this change are discussed in [Section 2.6, "The useProtocolVersion
              +Method"](#the-useprotocolversion-method).
              +
              +## 2.5 The writeReplace Method
              +
              +For Serializable and Externalizable classes, the `writeReplace` method allows a
              +class of an object to nominate its own replacement in the stream before the
              +object is written. By implementing the `writeReplace` method, a class can
              +directly control the types and instances of its own instances being serialized.
              +
              +The method is defined as follows:
              +
              +```
              +ANY-ACCESS-MODIFIER Object writeReplace()
              +             throws ObjectStreamException;
              +```
              +
              +The `writeReplace` method is called when `ObjectOutputStream` is preparing to
              +write the object to the stream. The `ObjectOutputStream` checks whether the
              +class defines the `writeReplace` method. If the method is defined, the
              +`writeReplace` method is called to allow the object to designate its
              +replacement in the stream. The object returned should be either of the same
              +type as the object passed in or an object that when read and resolved will
              +result in an object of a type that is compatible with all references to the
              +object. If it is not, a `ClassCastException` will occur when the type mismatch
              +is discovered.
              +
              +## 2.6 The useProtocolVersion Method
              +
              +Due to a stream protocol change that was not backwards compatible, a mechanism
              +has been added to enable the current Virtual Machine to write a serialization
              +stream that is readable by a previous release. Of course, the problems that are
              +corrected by the new stream format will exist when using the backwards
              +compatible protocol.
              +
              +Stream protocol versions are discussed in [Section 6.3, "Stream Protocol
              +Versions"](protocol.html#stream-protocol-versions).
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/protocol.md b/jdk/src/java.base/share/specs/serialization/protocol.md
              new file mode 100644
              index 00000000000..affc6886f98
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/protocol.md
              @@ -0,0 +1,504 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](version.html) | [NEXT](security.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](version.html) | [NEXT](security.html)'
              +
              +title: 'Java Object Serialization Specification: 6 - Object Serialization Stream Protocol'
              +---
              +
              +-   [Overview](#overview)
              +-   [Stream Elements](#stream-elements)
              +-   [Stream Protocol Versions](#stream-protocol-versions)
              +-   [Grammar for the Stream Format](#grammar-for-the-stream-format)
              +-   [Example](#example)
              +
              +-------------------------------------------------------------------------------
              +
              +## 6.1 Overview
              +
              +The stream format satisfies the following design goals:
              +
              +-   Is compact and is structured for efficient reading.
              +-   Allows skipping through the stream using only the knowledge of the
              +    structure and format of the stream. Does not require invoking any per class
              +    code.
              +-   Requires only stream access to the data.
              +
              +## 6.2 Stream Elements
              +
              +A basic structure is needed to represent objects in a stream. Each attribute of
              +the object needs to be represented: its classes, its fields, and data written
              +and later read by class-specific methods. The representation of objects in the
              +stream can be described with a grammar. There are special representations for
              +null objects, new objects, classes, arrays, strings, and back references to any
              +object already in the stream. Each object written to the stream is assigned a
              +handle that is used to refer back to the object. Handles are assigned
              +sequentially starting from 0x7E0000. The handles restart at 0x7E0000 when the
              +stream is reset.
              +
              +A class object is represented by the following:
              +
              +-   Its `ObjectStreamClass` object.
              +
              +An `ObjectStreamClass` object for a Class that is not a dynamic proxy class is
              +represented by the following:
              +
              +-   The Stream Unique Identifier (SUID) of compatible classes.
              +
              +-   A set of flags indicating various properties of the class, such as whether
              +    the class defines a `writeObject` method, and whether the class is
              +    serializable, externalizable, or an enum type
              +
              +-   The number of serializable fields
              +
              +-   The array of fields of the class that are serialized by the default
              +    mechanismFor arrays and object fields, the type of the field is included as
              +    a string which must be in "field descriptor" format (e.g.,
              +    "`Ljava/lang/Object;`") as specified in The Java Virtual Machine
              +    Specification.
              +
              +-   Optional block-data records or objects written by the `annotateClass`
              +    method
              +
              +-   The `ObjectStreamClass` of its supertype (null if the superclass is not
              +    serializable)
              +
              +An `ObjectStreamClass` object for a dynamic proxy class is represented by the
              +following:
              +
              +-   The number of interfaces that the dynamic proxy class implements
              +
              +-   The names of all of the interfaces implemented by the dynamic proxy class,
              +    listed in the order that they are returned by invoking the `getInterfaces`
              +    method on the Class object.
              +
              +-   Optional block-data records or objects written by the `annotateProxyClass`
              +    method.
              +
              +-   The ObjectStreamClass of its supertype, `java.lang.reflect.Proxy`.
              +
              +The representation of `String` objects consists of length information followed
              +by the contents of the string encoded in modified UTF-8. The modified UTF-8
              +encoding is the same as used in the Java Virtual Machine and in the
              +`java.io.DataInput` and `DataOutput` interfaces; it differs from standard UTF-8
              +in the representation of supplementary characters and of the null character.
              +The form of the length information depends on the length of the string in
              +modified UTF-8 encoding. If the modified UTF-8 encoding of the given `String`
              +is less than 65536 bytes in length, the length is written as 2 bytes
              +representing an unsigned 16-bit integer. Starting with the Java 2 platform,
              +Standard Edition, v1.3, if the length of the string in modified UTF-8 encoding
              +is 65536 bytes or more, the length is written in 8 bytes representing a signed
              +64-bit integer. The typecode preceding the `String` in the serialization stream
              +indicates which format was used to write the `String`.
              +
              +Arrays are represented by the following:
              +
              +-   Their `ObjectStreamClass` object.
              +
              +-   The number of elements.
              +
              +-   The sequence of values. The type of the values is implicit in the type of
              +    the array. for example the values of a byte array are of type byte.
              +
              +Enum constants are represented by the following:
              +
              +-   The `ObjectStreamClass` object of the constant's base enum type.
              +
              +-   The constant's name string.
              +
              +New objects in the stream are represented by the following:
              +
              +-   The most derived class of the object.
              +
              +-   Data for each serializable class of the object, with the highest superclass
              +    first. For each class the stream contains the following:
              +
              +    -   The serializable fields.See [Section 1.5, "Defining Serializable Fields
              +        for a
              +        Class"](serial-arch.html#defining-serializable-fields-for-a-class).
              +
              +    -   If the class has `writeObject`/`readObject` methods, there may be
              +        optional objects and/or block-data records of primitive types written
              +        by the `writeObject` method followed by an `endBlockData` code.
              +
              +All primitive data written by classes is buffered and wrapped in block-data
              +records, regardless if the data is written to the stream within a `writeObject`
              +method or written directly to the stream from outside a `writeObject` method.
              +This data can only be read by the corresponding `readObject` methods or be read
              +directly from the stream. Objects written by the `writeObject` method terminate
              +any previous block-data record and are written either as regular objects or
              +null or back references, as appropriate. The block-data records allow error
              +recovery to discard any optional data. When called from within a class, the
              +stream can discard any data or objects until the `endBlockData`.
              +
              +## 6.3 Stream Protocol Versions
              +
              +It was necessary to make a change to the serialization stream format in JDK 1.2
              +that is not backwards compatible to all minor releases of JDK 1.1. To provide
              +for cases where backwards compatibility is required, a capability has been
              +added to indicate what `PROTOCOL_VERSION` to use when writing a serialization
              +stream. The method `ObjectOutputStream.useProtocolVersion` takes as a parameter
              +the protocol version to use to write the serialization stream.
              +
              +The Stream Protocol Versions are as follows:
              +
              +-   `ObjectStreamConstants.PROTOCOL_VERSION_1`: Indicates the initial stream
              +    format.
              +
              +-   `ObjectStreamConstants.PROTOCOL_VERSION_2`: Indicates the new external data
              +    format. Primitive data is written in block data mode and is terminated with
              +    `TC_ENDBLOCKDATA`.
              +
              +    Block data boundaries have been standardized. Primitive data written in
              +    block data mode is normalized to not exceed 1024 byte chunks. The benefit
              +    of this change was to tighten the specification of serialized data format
              +    within the stream. This change is fully backward and forward compatible.
              +
              +JDK 1.2 defaults to writing `PROTOCOL_VERSION_2`.
              +
              +JDK 1.1 defaults to writing `PROTOCOL_VERSION_1`.
              +
              +JDK 1.1.7 and greater can read both versions.
              +
              +Releases prior to JDK 1.1.7 can only read `PROTOCOL_VERSION_1`.
              +
              +## 6.4 Grammar for the Stream Format
              +
              +The table below contains the grammar for the stream format. Nonterminal symbols
              +are shown in italics. Terminal symbols in a *fixed width font*. Definitions of
              +nonterminals are followed by a ":". The definition is followed by one or more
              +alternatives, each on a separate line. The following table describes the
              +notation:
              +
              +  -------------  --------------------------------------------------------------
              +  **Notation**   **Meaning**
              +  -------------  --------------------------------------------------------------
              +  (*datatype*)   This token has the data type specified, such as byte.
              +
              +  *token*\[n\]   A predefined number of occurrences of the token, that is an
              +                 array.
              +
              +  *x0001*        A literal value expressed in hexadecimal. The number of hex
              +                 digits reflects the size of the value.
              +
              +  <*xxx*>  A value read from the stream used to indicate the length of an
              +                 array.
              +  -------------  --------------------------------------------------------------
              +
              +Note that the symbol (utf) is used to designate a string written using 2-byte
              +length information, and (long-utf) is used to designate a string written using
              +8-byte length information. For details, refer to [Section 6.2, "Stream
              +Elements"](#stream-elements).
              +
              +### 6.4.1 Rules of the Grammar
              +
              +A Serialized stream is represented by any stream satisfying the *stream* rule.
              +
              +```
              +stream:
              +  magic version contents
              +
              +contents:
              +  content
              +  contents content
              +
              +content:
              +  object
              +  blockdata
              +
              +object:
              +  newObject
              +  newClass
              +  newArray
              +  newString
              +  newEnum
              +  newClassDesc
              +  prevObject
              +  nullReference
              +  exception
              +  TC_RESET
              +
              +newClass:
              +  TC_CLASS classDesc newHandle
              +
              +classDesc:
              +  newClassDesc
              +  nullReference
              +  (ClassDesc)prevObject      // an object required to be of type ClassDesc
              +
              +superClassDesc:
              +  classDesc
              +
              +newClassDesc:
              +  TC_CLASSDESC className serialVersionUID newHandle classDescInfo
              +  TC_PROXYCLASSDESC newHandle proxyClassDescInfo
              +
              +classDescInfo:
              +  classDescFlags fields classAnnotation superClassDesc
              +
              +className:
              +  (utf)
              +
              +serialVersionUID:
              +  (long)
              +
              +classDescFlags:
              +  (byte)                  // Defined in Terminal Symbols and Constants
              +
              +proxyClassDescInfo:
              +  (int) proxyInterfaceName[count] classAnnotation
              +      superClassDesc
              +
              +proxyInterfaceName:
              +  (utf)
              +
              +fields:
              +  (short) fieldDesc[count]
              +
              +fieldDesc:
              +  primitiveDesc
              +  objectDesc
              +
              +primitiveDesc:
              +  prim_typecode fieldName
              +
              +objectDesc:
              +  obj_typecode fieldName className1
              +
              +fieldName:
              +  (utf)
              +
              +className1:
              +  (String)object             // String containing the field's type,
              +                             // in field descriptor format
              +
              +classAnnotation:
              +  endBlockData
              +  contents endBlockData      // contents written by annotateClass
              +
              +prim_typecode:
              +  'B'       // byte
              +  'C'       // char
              +  'D'       // double
              +  'F'       // float
              +  'I'       // integer
              +  'J'       // long
              +  'S'       // short
              +  'Z'       // boolean
              +
              +obj_typecode:
              +  '['       // array
              +  'L'       // object
              +
              +newArray:
              +  TC_ARRAY classDesc newHandle (int) values[size]
              +
              +newObject:
              +  TC_OBJECT classDesc newHandle classdata[]  // data for each class
              +
              +classdata:
              +  nowrclass                 // SC_SERIALIZABLE & classDescFlag &&
              +                            // !(SC_WRITE_METHOD & classDescFlags)
              +  wrclass objectAnnotation  // SC_SERIALIZABLE & classDescFlag &&
              +                            // SC_WRITE_METHOD & classDescFlags
              +  externalContents          // SC_EXTERNALIZABLE & classDescFlag &&
              +                            // !(SC_BLOCKDATA  & classDescFlags
              +  objectAnnotation          // SC_EXTERNALIZABLE & classDescFlag&&
              +                            // SC_BLOCKDATA & classDescFlags
              +
              +nowrclass:
              +  values                    // fields in order of class descriptor
              +
              +wrclass:
              +  nowrclass
              +
              +objectAnnotation:
              +  endBlockData
              +  contents endBlockData     // contents written by writeObject
              +                            // or writeExternal PROTOCOL_VERSION_2.
              +
              +blockdata:
              +  blockdatashort
              +  blockdatalong
              +
              +blockdatashort:
              +  TC_BLOCKDATA (unsigned byte) (byte)[size]
              +
              +blockdatalong:
              +  TC_BLOCKDATALONG (int) (byte)[size]
              +
              +endBlockData:
              +  TC_ENDBLOCKDATA
              +
              +externalContent:         // Only parseable by readExternal
              +  (bytes)                // primitive data
              +   object
              +
              +externalContents:         // externalContent written by
              +  externalContent         // writeExternal in PROTOCOL_VERSION_1.
              +  externalContents externalContent
              +
              +newString:
              +  TC_STRING newHandle (utf)
              +  TC_LONGSTRING newHandle (long-utf)
              +
              +newEnum:
              +  TC_ENUM classDesc newHandle enumConstantName
              +
              +enumConstantName:
              +  (String)object
              +
              +prevObject:
              +  TC_REFERENCE (int)handle
              +
              +nullReference:
              +  TC_NULL
              +
              +exception:
              +  TC_EXCEPTION reset (Throwable)object reset
              +
              +magic:
              +  STREAM_MAGIC
              +
              +version:
              +  STREAM_VERSION
              +
              +values:          // The size and types are described by the
              +                 // classDesc for the current object
              +
              +newHandle:       // The next number in sequence is assigned
              +                 // to the object being serialized or deserialized
              +
              +reset:           // The set of known objects is discarded
              +                 // so the objects of the exception do not
              +                 // overlap with the previously sent objects
              +                 // or with objects that may be sent after
              +                 // the exception
              +```
              +
              +### 6.4.2 Terminal Symbols and Constants
              +
              +The following symbols in `java.io.ObjectStreamConstants` define the terminal
              +and constant values expected in a stream.
              +
              +```
              +final static short STREAM_MAGIC = (short)0xaced;
              +final static short STREAM_VERSION = 5;
              +final static byte TC_NULL = (byte)0x70;
              +final static byte TC_REFERENCE = (byte)0x71;
              +final static byte TC_CLASSDESC = (byte)0x72;
              +final static byte TC_OBJECT = (byte)0x73;
              +final static byte TC_STRING = (byte)0x74;
              +final static byte TC_ARRAY = (byte)0x75;
              +final static byte TC_CLASS = (byte)0x76;
              +final static byte TC_BLOCKDATA = (byte)0x77;
              +final static byte TC_ENDBLOCKDATA = (byte)0x78;
              +final static byte TC_RESET = (byte)0x79;
              +final static byte TC_BLOCKDATALONG = (byte)0x7A;
              +final static byte TC_EXCEPTION = (byte)0x7B;
              +final static byte TC_LONGSTRING = (byte) 0x7C;
              +final static byte TC_PROXYCLASSDESC = (byte) 0x7D;
              +final static byte TC_ENUM = (byte) 0x7E;
              +final static  int   baseWireHandle = 0x7E0000;
              +```
              +
              +The flag byte *classDescFlags* may include values of
              +
              +```
              +final static byte SC_WRITE_METHOD = 0x01; //if SC_SERIALIZABLE
              +final static byte SC_BLOCK_DATA = 0x08;    //if SC_EXTERNALIZABLE
              +final static byte SC_SERIALIZABLE = 0x02;
              +final static byte SC_EXTERNALIZABLE = 0x04;
              +final static byte SC_ENUM = 0x10;
              +```
              +
              +The flag `SC_WRITE_METHOD` is set if the Serializable class writing the stream
              +had a `writeObject` method that may have written additional data to the stream.
              +In this case a `TC_ENDBLOCKDATA` marker is always expected to terminate the
              +data for that class.
              +
              +The flag `SC_BLOCKDATA` is set if the `Externalizable` class is written into
              +the stream using `STREAM_PROTOCOL_2`. By default, this is the protocol used to
              +write `Externalizable` objects into the stream in JDK 1.2. JDK 1.1 writes
              +`STREAM_PROTOCOL_1`.
              +
              +The flag `SC_SERIALIZABLE` is set if the class that wrote the stream extended
              +`java.io.Serializable` but not `java.io.Externalizable`, the class reading the
              +stream must also extend `java.io.Serializable` and the default serialization
              +mechanism is to be used.
              +
              +The flag `SC_EXTERNALIZABLE` is set if the class that wrote the stream extended
              +`java.io.Externalizable`, the class reading the data must also extend
              +`Externalizable` and the data will be read using its `writeExternal` and
              +`readExternal` methods.
              +
              +The flag `SC_ENUM` is set if the class that wrote the stream was an enum type.
              +The receiver's corresponding class must also be an enum type. Data for
              +constants of the enum type will be written and read as described in [Section
              +1.12, "Serialization of Enum
              +Constants"](serial-arch.html#serialization-of-enum-constants).
              +
              +#### Example
              +
              +Consider the case of an original class and two instances in a linked list:
              +
              +```
              +class List implements java.io.Serializable {
              +    int value;
              +    List next;
              +    public static void main(String[] args) {
              +        try {
              +            List list1 = new List();
              +            List list2 = new List();
              +            list1.value = 17;
              +            list1.next = list2;
              +            list2.value = 19;
              +            list2.next = null;
              +
              +            ByteArrayOutputStream o = new ByteArrayOutputStream();
              +            ObjectOutputStream out = new ObjectOutputStream(o);
              +            out.writeObject(list1);
              +            out.writeObject(list2);
              +            out.flush();
              +            ...
              +        } catch (Exception ex) {
              +            ex.printStackTrace();
              +        }
              +    }
              +}
              +```
              +
              +The resulting stream contains:
              +
              +```
              +    00: ac ed 00 05 73 72 00 04 4c 69 73 74 69 c8 8a 15 >....sr..Listi...<
              +    10: 40 16 ae 68 02 00 02 49 00 05 76 61 6c 75 65 4c >Z......I..valueL<
              +    20: 00 04 6e 65 78 74 74 00 06 4c 4c 69 73 74 3b 78 >..nextt..LList;x<
              +    30: 70 00 00 00 11 73 71 00 7e 00 00 00 00 00 13 70 >p....sq.~......p<
              +    40: 71 00 7e 00 03                                  >q.~..<
              +```
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties b/jdk/src/java.base/share/specs/serialization/security.md
              similarity index 50%
              rename from jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties
              rename to jdk/src/java.base/share/specs/serialization/security.md
              index c0267b823ea..9f26748daa9 100644
              --- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties
              +++ b/jdk/src/java.base/share/specs/serialization/security.md
              @@ -1,12 +1,10 @@
              -#
              -# Copyright (c) 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
               # 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.
              +# 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
              @@ -21,6 +19,20 @@
               # 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.
              -#
               
              -FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
              +include-before: '[CONTENTS](index.html) | [PREV](protocol.html) | [NEXT](exceptions.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](protocol.html) | [NEXT](exceptions.html)'
              +
              +title: 'Java Object Serialization Specification: A - Security in Object Serialization'
              +---
              +
              +-------------------------------------------------------------------------------
              +
              +Refer to the [Secure Coding Guidelines for the Java Programming 
              +Language](http://www.oracle.com/pls/topic/lookup?ctx=javase9&id=secure_coding_guidelines_javase) 
              +for information about security in object serialization.
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/serial-arch.md b/jdk/src/java.base/share/specs/serialization/serial-arch.md
              new file mode 100644
              index 00000000000..4ff54731688
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/serial-arch.md
              @@ -0,0 +1,575 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](index.html) | [NEXT](output.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](index.html) | [NEXT](output.html)'
              +
              +title: 'Java Object Serialization Specification: 1 - System Architecture'
              +---
              +
              +-   [Overview](#overview)
              +-   [Writing to an Object Stream](#writing-to-an-object-stream)
              +-   [Reading from an Object Stream](#reading-from-an-object-stream)
              +-   [Object Streams as Containers](#object-streams-as-containers)
              +-   [Defining Serializable Fields for a
              +    Class](#defining-serializable-fields-for-a-class)
              +-   [Documenting Serializable Fields and Data for a
              +    Class](#documenting-serializable-fields-and-data-for-a-class)
              +-   [Accessing Serializable Fields of a
              +    Class](#accessing-serializable-fields-of-a-class)
              +-   [The ObjectOutput Interface](#the-objectoutput-interface)
              +-   [The ObjectInput Interface](#the-objectinput-interface)
              +-   [The Serializable Interface](#the-serializable-interface)
              +-   [The Externalizable Interface](#the-externalizable-interface)
              +-   [Serialization of Enum Constants](#serialization-of-enum-constants)
              +-   [Protecting Sensitive Information](#protecting-sensitive-information)
              +
              +-------------------------------------------------------------------------------
              +
              +## 1.1 Overview
              +
              +The ability to store and retrieve Java^TM^ objects is essential to building all
              +but the most transient applications. The key to storing and retrieving objects
              +in a serialized form is representing the state of objects sufficient to
              +reconstruct the object(s). Objects to be saved in the stream may support either
              +the `Serializable` or the `Externalizable` interface. For Java^TM^ objects, the
              +serialized form must be able to identify and verify the Java^TM^ class from
              +which the contents of the object were saved and to restore the contents to a
              +new instance. For serializable objects, the stream includes sufficient
              +information to restore the fields in the stream to a compatible version of the
              +class. For Externalizable objects, the class is solely responsible for the
              +external format of its contents.
              +
              +Objects to be stored and retrieved frequently refer to other objects. Those
              +other objects must be stored and retrieved at the same time to maintain the
              +relationships between the objects. When an object is stored, all of the objects
              +that are reachable from that object are stored as well.
              +
              +The goals for serializing Java^TM^ objects are to:
              +
              +-   Have a simple yet extensible mechanism.
              +-   Maintain the Java^TM^ object type and safety properties in the serialized
              +    form.
              +-   Be extensible to support marshaling and unmarshaling as needed for remote
              +    objects.
              +-   Be extensible to support simple persistence of Java^TM^ objects.
              +-   Require per class implementation only for customization.
              +-   Allow the object to define its external format.
              +
              +## 1.2 Writing to an Object Stream
              +
              +Writing objects and primitives to a stream is a straightforward process. For
              +example:
              +
              +```
              +// Serialize today's date to a file.
              +    FileOutputStream f = new FileOutputStream("tmp");
              +    ObjectOutput s = new ObjectOutputStream(f);
              +    s.writeObject("Today");
              +    s.writeObject(new Date());
              +    s.flush();
              +```
              +
              +First an `OutputStream`, in this case a `FileOutputStream`, is needed to
              +receive the bytes. Then an `ObjectOutputStream` is created that writes to the
              +`FileOutputStream`. Next, the string "Today" and a Date object are written to
              +the stream. More generally, objects are written with the `writeObject` method
              +and primitives are written to the stream with the methods of `DataOutput`.
              +
              +The `writeObject` method (see [Section 2.3, "The writeObject
              +Method"](output.html#the-writeobject-method)) serializes the specified object
              +and traverses its references to other objects in the object graph recursively
              +to create a complete serialized representation of the graph. Within a stream,
              +the first reference to any object results in the object being serialized or
              +externalized and the assignment of a handle for that object. Subsequent
              +references to that object are encoded as the handle. Using object handles
              +preserves sharing and circular references that occur naturally in object
              +graphs. Subsequent references to an object use only the handle allowing a very
              +compact representation.
              +
              +Special handling is required for arrays, enum constants, and objects of type
              +`Class`, `ObjectStreamClass`, and `String`. Other objects must implement either
              +the `Serializable` or the `Externalizable` interface to be saved in or restored
              +from a stream.
              +
              +Primitive data types are written to the stream with the methods in the
              +`DataOutput` interface, such as `writeInt`, `writeFloat`, or `writeUTF`.
              +Individual bytes and arrays of bytes are written with the methods of
              +`OutputStream`. Except for serializable fields, primitive data is written to
              +the stream in block-data records, with each record prefixed by a marker and an
              +indication of the number of bytes in the record.
              +
              +`ObjectOutputStream` can be extended to customize the information about classes
              +in the stream or to replace objects to be serialized. Refer to the
              +`annotateClass` and `replaceObject` method descriptions for details.
              +
              +## 1.3 Reading from an Object Stream
              +
              +Reading an object from a stream, like writing, is straightforward:
              +
              +```
              +// Deserialize a string and date from a file.
              +    FileInputStream in = new FileInputStream("tmp");
              +    ObjectInputStream s = new ObjectInputStream(in);
              +    String today = (String)s.readObject();
              +    Date date = (Date)s.readObject();
              +```
              +
              +First an `InputStream`, in this case a `FileInputStream`, is needed as the
              +source stream. Then an `ObjectInputStream` is created that reads from the
              +`InputStream`. Next, the string "Today" and a Date object are read from the
              +stream. Generally, objects are read with the `readObject` method and primitives
              +are read from the stream with the methods of `DataInput`.
              +
              +The `readObject` method deserializes the next object in the stream and
              +traverses its references to other objects recursively to create the complete
              +graph of objects serialized.
              +
              +Primitive data types are read from the stream with the methods in the
              +`DataInput` interface, such as `readInt`, `readFloat`, or `readUTF`. Individual
              +bytes and arrays of bytes are read with the methods of `InputStream`. Except
              +for serializable fields, primitive data is read from block-data records.
              +
              +`ObjectInputStream` can be extended to utilize customized information in the
              +stream about classes or to replace objects that have been deserialized. Refer
              +to the `resolveClass` and `resolveObject` method descriptions for details.
              +
              +## 1.4 Object Streams as Containers
              +
              +Object Serialization produces and consumes a stream of bytes that contain one
              +or more primitives and objects. The objects written to the stream, in turn,
              +refer to other objects, which are also represented in the stream. Object
              +Serialization produces just one stream format that encodes and stores the
              +contained objects.
              +
              +Each object that acts as a container implements an interface which allows
              +primitives and objects to be stored in or retrieved from it. These interfaces
              +are the `ObjectOutput` and `ObjectInput` interfaces which:
              +
              +-   Provide a stream to write to and to read from
              +-   Handle requests to write primitive types and objects to the stream
              +-   Handle requests to read primitive types and objects from the stream
              +
              +Each object which is to be stored in a stream must explicitly allow itself to
              +be stored and must implement the protocols needed to save and restore its
              +state. Object Serialization defines two such protocols. The protocols allow the
              +container to ask the object to write and read its state.
              +
              +To be stored in an Object Stream, each object must implement either the
              +`Serializable` or the `Externalizable` interface:
              +
              +-   For a `Serializable` class, Object Serialization can automatically save and
              +    restore fields of each class of an object and automatically handle classes
              +    that evolve by adding fields or supertypes. A serializable class can
              +    declare which of its fields are saved or restored, and write and read
              +    optional values and objects.
              +
              +-   For an `Externalizable` class, Object Serialization delegates to the class
              +    complete control over its external format and how the state of the
              +    supertype(s) is saved and restored.
              +
              +## 1.5 Defining Serializable Fields for a Class
              +
              +The serializable fields of a class can be defined two different ways. Default
              +serializable fields of a class are defined to be the non-transient and
              +non-static fields. This default computation can be overridden by declaring a
              +special field in the `Serializable` class, `serialPersistentFields`. This field
              +must be initialized with an array of `ObjectStreamField` objects that list the
              +names and types of the serializable fields. The modifiers for the field are
              +required to be private, static, and final. If the field's value is null or is
              +otherwise not an instance of `ObjectStreamField[]`, or if the field does not
              +have the required modifiers, then the behavior is as if the field were not
              +declared at all.
              +
              +For example, the following declaration duplicates the default behavior.
              +
              +```
              +class List implements Serializable {
              +    List next;
              +
              +    private static final ObjectStreamField[] serialPersistentFields
              +                 = {new ObjectStreamField("next", List.class)};
              +
              +}
              +```
              +
              +By using `serialPersistentFields` to define the Serializable fields for a
              +class, there no longer is a limitation that a serializable field must be a
              +field within the current definition of the `Serializable` class. The
              +`writeObject` and `readObject` methods of the `Serializable` class can map the
              +current implementation of the class to the serializable fields of the class
              +using the interface that is described in [Section 1.7, "Accessing Serializable
              +Fields of a Class"](#accessing-serializable-fields-of-a-class). Therefore, the
              +fields for a `Serializable` class can change in a later release, as long as it
              +maintains the mapping back to its Serializable fields that must remain
              +compatible across release boundaries.
              +
              +**Note:** There is, however, a limitation to the use of this mechanism to
              +specify serializable fields for inner classes. Inner classes can only contain
              +final static fields that are initialized to constants or expressions built up
              +from constants. Consequently, it is not possible to set
              +`serialPersistentFields` for an inner class (though it is possible to set it
              +for static member classes). For other restrictions pertaining to serialization
              +of inner class instances, see section [Section 1.10, "The Serializable
              +Interface"](#the-serializable-interface).
              +
              +## 1.6 Documenting Serializable Fields and Data for a Class
              +
              +It is important to document the serializable state of a class to enable
              +interoperability with alternative implementations of a Serializable class and
              +to document class evolution. Documenting a serializable field gives one a final
              +opportunity to review whether or not the field should be serializable. The
              +serialization javadoc tags, `@serial`, `@serialField`, and `@serialData`,
              +provide a way to document the serialized form for a Serializable class within
              +the source code.
              +
              +-   The `@serial` tag should be placed in the javadoc comment for a default
              +    serializable field. The syntax is as follows: `@serial` *field-description*
              +    The optional *field-description* describes the meaning of the field and its
              +    acceptable values. The *field-description* can span multiple lines. When a
              +    field is added after the initial release, a *@since* tag indicates the
              +    version the field was added. The *field-description* for `@serial` provides
              +    serialization-specific documentation and is appended to the javadoc comment
              +    for the field within the serialized form documentation.
              +
              +-   The `@serialField` tag is used to document an `ObjectStreamField` component
              +    of a `serialPersistentFields` array. One of these tags should be used for
              +    each `ObjectStreamField` component. The syntax is as follows:
              +    `@serialField` *field-name field-type field-description*
              +
              +-   The `@serialData` tag describes the sequences and types of data written or
              +    read. The tag describes the sequence and type of optional data written by
              +    `writeObject` or all data written by the `Externalizable.writeExternal`
              +    method. The syntax is as follows: `@serialData` *data-description*
              +
              +The javadoc application recognizes the serialization javadoc tags and generates
              +a specification for each Serializable and Externalizable class. See [Section
              +C.1, "Example Alternate Implementation of
              +java.io.File"](examples.html#c.1-example-alternate-implementation-of-java.io.file)
              +for an example that uses these tags.
              +
              +When a class is declared Serializable, the serializable state of the object is
              +defined by serializable fields (by name and type) plus optional data. Optional
              +data can only be written explicitly by the `writeObject` method of a
              +`Serializable` class. Optional data can be read by the `Serializable` class'
              +`readObject` method or serialization will skip unread optional data.
              +
              +When a class is declared Externalizable, the data that is written to the stream
              +by the class itself defines the serialized state. The class must specify the
              +order, types, and meaning of each datum that is written to the stream. The
              +class must handle its own evolution, so that it can continue to read data
              +written by and write data that can be read by previous versions. The class must
              +coordinate with the superclass when saving and restoring data. The location of
              +the superclasses data in the stream must be specified.
              +
              +The designer of a Serializable class must ensure that the information saved for
              +the class is appropriate for persistence and follows the
              +serialization-specified rules for interoperability and evolution. Class
              +evolution is explained in greater detail in [Chapter
              +5](version.html#versioning-of-serializable-objects), "Versioning of
              +Serializable Objects".
              +
              +## 1.7 Accessing Serializable Fields of a Class
              +
              +Serialization provides two mechanisms for accessing the serializable fields in
              +a stream:
              +
              +-   The default mechanism requires no customization
              +-   The Serializable Fields API allows a class to explicitly access/set the
              +    serializable fields by name and type
              +
              +The default mechanism is used automatically when reading or writing objects
              +that implement the `Serializable` interface and do no further customization.
              +The serializable fields are mapped to the corresponding fields of the class and
              +values are either written to the stream from those fields or are read in and
              +assigned respectively. If the class provides `writeObject` and `readObject`
              +methods, the default mechanism can be invoked by calling `defaultWriteObject`
              +and `defaultReadObject`. When the `writeObject` and `readObject` methods are
              +implemented, the class has an opportunity to modify the serializable field
              +values before they are written or after they are read.
              +
              +When the default mechanism cannot be used, the serializable class can use the
              +`putFields` method of `ObjectOutputStream` to put the values for the
              +serializable fields into the stream. The `writeFields` method of
              +`ObjectOutputStream` puts the values in the correct order, then writes them to
              +the stream using the existing protocol for serialization. Correspondingly, the
              +`readFields` method of `ObjectInputStream` reads the values from the stream and
              +makes them available to the class by name in any order. See [Section 2.2, "The
              +ObjectOutputStream.PutField
              +Class"](output.html#the-objectoutputstream.putfield-class) and [Section 3.2,
              +"The ObjectInputStream.GetField
              +Class"](input.html#the-objectinputstream.getfield-class) for a detailed
              +description of the Serializable Fields API.
              +
              +## 1.8 The ObjectOutput Interface
              +
              +The `ObjectOutput` interface provides an abstract, stream-based interface to
              +object storage. It extends the DataOutput interface so those methods can be
              +used for writing primitive data types. Objects that implement this interface
              +can be used to store primitives and objects.
              +
              +```
              +package java.io;
              +
              +public interface ObjectOutput extends DataOutput
              +{
              +    public void writeObject(Object obj) throws IOException;
              +    public void write(int b) throws IOException;
              +    public void write(byte b[]) throws IOException;
              +    public void write(byte b[], int off, int len) throws IOException;
              +    public void flush() throws IOException;
              +    public void close() throws IOException;
              +}
              +```
              +
              +`The` `writeObject` method is used to write an object. The exceptions thrown
              +reflect errors while accessing the object or its fields, or exceptions that
              +occur in writing to storage. If any exception is thrown, the underlying storage
              +may be corrupted. If this occurs, refer to the object that is implementing this
              +interface for more information.
              +
              +## 1.9 The ObjectInput Interface
              +
              +The `ObjectInput` interface provides an abstract stream based interface to
              +object retrieval. It extends the `DataInput` interface so those methods for
              +reading primitive data types are accessible in this interface.
              +
              +```
              +package java.io;
              +
              +public interface ObjectInput extends DataInput
              +{
              +    public Object readObject()
              +        throws ClassNotFoundException, IOException;
              +    public int read() throws IOException;
              +    public int read(byte b[]) throws IOException;
              +    public int read(byte b[], int off, int len) throws IOException;
              +    public long skip(long n) throws IOException;
              +    public int available() throws IOException;
              +    public void close() throws IOException;
              +}
              +```
              +
              +The `readObject` method is used to read and return an object. The exceptions
              +thrown reflect errors while accessing the objects or its fields or exceptions
              +that occur in reading from the storage. If any exception is thrown, the
              +underlying storage may be corrupted. If this occurs, refer to the object
              +implementing this interface for additional information.
              +
              +## 1.10 The Serializable Interface
              +
              +Object Serialization produces a stream with information about the Java^TM^
              +classes for the objects which are being saved. For serializable objects,
              +sufficient information is kept to restore those objects even if a different
              +(but compatible) version of the implementation of the class is present. The
              +`Serializable` interface is defined to identify classes which implement the
              +serializable protocol:
              +
              +```
              +package java.io;
              +
              +public interface Serializable {};
              +```
              +
              +A Serializable class must do the following:
              +
              +-   Implement the `java.io.Serializable` interface
              +
              +-   Identify the fields that should be serializable
              +
              +    (Use the `serialPersistentFields` member to explicitly declare them
              +    serializable or use the transient keyword to denote nonserializable
              +    fields.)
              +
              +-   Have access to the no-arg constructor of its first nonserializable
              +    superclass
              +
              +The class can optionally define the following methods:
              +
              +-   A `writeObject` method to control what information is saved or to append
              +    additional information to the stream
              +
              +-   A `readObject` method either to read the information written by the
              +    corresponding `writeObject` method or to update the state of the object
              +    after it has been restored
              +
              +-   A `writeReplace` method to allow a class to nominate a replacement object
              +    to be written to the stream
              +
              +    (See [Section 2.5, "The writeReplace
              +    Method"](output.html#the-writereplace-method) for additional information.)
              +
              +-   A `readResolve` method to allow a class to designate a replacement object
              +    for the object just read from the stream
              +
              +    (See [Section 3.7, "The readResolve
              +    Method](input.html#the-readresolve-method) for additional information.)
              +
              +`ObjectOutputStream` and `ObjectInputStream` allow the serializable classes on
              +which they operate to evolve (allow changes to the classes that are compatible
              +with the earlier versions of the classes). See [Section 5.5, "Compatible Java
              +Type Evolution"](version.html#compatible-java-type-evolution) for information
              +about the mechanism which is used to allow compatible changes.
              +
              +**Note:** Serialization of inner classes (i.e., nested classes that are not
              +static member classes), including local and anonymous classes, is strongly
              +discouraged for several reasons. Because inner classes declared in non-static
              +contexts contain implicit non-transient references to enclosing class
              +instances, serializing such an inner class instance will result in
              +serialization of its associated outer class instance as well. Synthetic fields
              +generated by `javac` (or other Java^TM^ compilers) to implement inner classes
              +are implementation dependent and may vary between compilers; differences in
              +such fields can disrupt compatibility as well as result in conflicting default
              +`serialVersionUID` values. The names assigned to local and anonymous inner
              +classes are also implementation dependent and may differ between compilers.
              +Since inner classes cannot declare static members other than compile-time
              +constant fields, they cannot use the `serialPersistentFields` mechanism to
              +designate serializable fields. Finally, because inner classes associated with
              +outer instances do not have zero-argument constructors (constructors of such
              +inner classes implicitly accept the enclosing instance as a prepended
              +parameter), they cannot implement `Externalizable`. None of the issues listed
              +above, however, apply to static member classes.
              +
              +## 1.11 The Externalizable Interface
              +
              +For Externalizable objects, only the identity of the class of the object is
              +saved by the container; the class must save and restore the contents. The
              +`Externalizable` interface is defined as follows:
              +
              +```
              +package java.io;
              +
              +public interface Externalizable extends Serializable
              +{
              +    public void writeExternal(ObjectOutput out)
              +        throws IOException;
              +
              +    public void readExternal(ObjectInput in)
              +        throws IOException, java.lang.ClassNotFoundException;
              +}
              +```
              +
              +The class of an Externalizable object must do the following:
              +
              +-   Implement the `java.io.Externalizable` interface
              +
              +-   Implement a `writeExternal` method to save the state of the object
              +
              +    (It must explicitly coordinate with its supertype to save its state.)
              +
              +-   Implement a `readExternal` method to read the data written by the
              +    `writeExternal` method from the stream and restore the state of the object
              +
              +    (It must explicitly coordinate with the supertype to save its state.)
              +
              +-   Have the `writeExternal` and `readExternal` methods be solely responsible
              +    for the format, if an externally defined format is written
              +
              +    **Note:** The `writeExternal` and `readExternal` methods are public and
              +    raise the risk that a client may be able to write or read information in
              +    the object other than by using its methods and fields. These methods must
              +    be used only when the information held by the object is not sensitive or
              +    when exposing it does not present a security risk.
              +
              +-   Have a public no-arg constructor
              +
              +    **Note:** Inner classes associated with enclosing instances cannot have
              +    no-arg constructors, since constructors of such classes implicitly accept
              +    the enclosing instance as a prepended parameter. Consequently the
              +    `Externalizable` interface mechanism cannot be used for inner classes and
              +    they should implement the `Serializable` interface, if they must be
              +    serialized. Several limitations exist for serializable inner classes as
              +    well, however; see [Section 1.10, "The Serializable
              +    Interface"](#the-serializable-interface), for a full enumeration.
              +
              +An Externalizable class can optionally define the following methods:
              +
              +-   A `writeReplace` method to allow a class to nominate a replacement object
              +    to be written to the stream
              +
              +    (See [Section 2.5, "The writeReplace
              +    Method"](output.html#the-writereplace-method) for additional information.)
              +
              +-   A `readResolve` method to allow a class to designate a replacement object
              +    for the object just read from the stream
              +
              +    (See [Section 3.7, "The readResolve
              +    Method"](input.html#the-readresolve-method) for additional information.)
              +
              +## 1.12 Serialization of Enum Constants
              +
              +Enum constants are serialized differently than ordinary serializable or
              +externalizable objects. The serialized form of an enum constant consists solely
              +of its name; field values of the constant are not present in the form. To
              +serialize an enum constant, `ObjectOutputStream` writes the value returned by
              +the enum constant's `name` method. To deserialize an enum constant,
              +`ObjectInputStream` reads the constant name from the stream; the deserialized
              +constant is then obtained by calling the `java.lang.Enum.valueOf` method,
              +passing the constant's enum type along with the received constant name as
              +arguments. Like other serializable or externalizable objects, enum constants
              +can function as the targets of back references appearing subsequently in the
              +serialization stream.
              +
              +The process by which enum constants are serialized cannot be customized: any
              +class-specific `writeObject`, `readObject`, `readObjectNoData`, `writeReplace`,
              +and `readResolve` methods defined by enum types are ignored during
              +serialization and deserialization. Similarly, any `serialPersistentFields` or
              +`serialVersionUID` field declarations are also ignored--all enum types have a
              +fixed `serialVersionUID` of `0L`. Documenting serializable fields and data for
              +enum types is unnecessary, since there is no variation in the type of data
              +sent.
              +
              +## 1.13 Protecting Sensitive Information
              +
              +When developing a class that provides controlled access to resources, care must
              +be taken to protect sensitive information and functions. During
              +deserialization, the private state of the object is restored. For example, a
              +file descriptor contains a handle that provides access to an operating system
              +resource. Being able to forge a file descriptor would allow some forms of
              +illegal access, since restoring state is done from a stream. Therefore, the
              +serializing runtime must take the conservative approach and not trust the
              +stream to contain only valid representations of objects. To avoid compromising
              +a class, the sensitive state of an object must not be restored from the stream,
              +or it must be reverified by the class. Several techniques are available to
              +protect sensitive data in classes.
              +
              +The easiest technique is to mark fields that contain sensitive data as *private
              +transient*. Transient fields are not persistent and will not be saved by any
              +persistence mechanism. Marking the field will prevent the state from appearing
              +in the stream and from being restored during deserialization. Since writing and
              +reading (of private fields) cannot be superseded outside of the class, the
              +transient fields of the class are safe.
              +
              +Particularly sensitive classes should not be serialized at all. To accomplish
              +this, the object should not implement either the `Serializable` or the
              +`Externalizable` interface.
              +
              +Some classes may find it beneficial to allow writing and reading but
              +specifically handle and revalidate the state as it is deserialized. The class
              +should implement `writeObject` and `readObject` methods to save and restore
              +only the appropriate state. If access should be denied, throwing a
              +`NotSerializableException` will prevent further access.
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/share/specs/serialization/version.md b/jdk/src/java.base/share/specs/serialization/version.md
              new file mode 100644
              index 00000000000..5f4d0e7d4a9
              --- /dev/null
              +++ b/jdk/src/java.base/share/specs/serialization/version.md
              @@ -0,0 +1,304 @@
              +---
              +# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
              +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
              +#
              +# This code is free software; you can redistribute it and/or modify it
              +# under the terms of the GNU General Public License version 2 only, as
              +# published by the Free Software Foundation.
              +#
              +# This code is distributed in the hope that it will be useful, but WITHOUT
              +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
              +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
              +# version 2 for more details (a copy is included in the LICENSE file that
              +# accompanied this code).
              +#
              +# You should have received a copy of the GNU General Public License version
              +# 2 along with this work; if not, write to the Free Software Foundation,
              +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
              +#
              +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
              +# or visit www.oracle.com if you need additional information or have any
              +# questions.
              +
              +include-before: '[CONTENTS](index.html) | [PREV](class.html) | [NEXT](protocol.html)'
              +include-after: '[CONTENTS](index.html) | [PREV](class.html) | [NEXT](protocol.html)'
              +
              +title: 'Java Object Serialization Specification: 5 - Versioning of Serializable Objects'
              +---
              +
              +-   [Overview](#overview)
              +-   [Goals](#goals)
              +-   [Assumptions](#assumptions)
              +-   [Who's Responsible for Versioning of
              +    Streams](#whos-responsible-for-versioning-of-streams)
              +-   [Compatible Java Type Evolution](#compatible-java-type-evolution)
              +-   [Type Changes Affecting
              +    Serialization](#type-changes-affecting-serialization)
              +
              +-------------------------------------------------------------------------------
              +
              +## 5.1 Overview
              +
              +When Java objects use serialization to save state in files, or as blobs in
              +databases, the potential arises that the version of a class reading the data is
              +different than the version that wrote the data.
              +
              +Versioning raises some fundamental questions about the identity of a class,
              +including what constitutes a compatible change. A ***compatible change*** is a
              +change that does not affect the contract between the class and its callers.
              +
              +This section describes the goals, assumptions, and a solution that attempts to
              +address this problem by restricting the kinds of changes allowed and by
              +carefully choosing the mechanisms.
              +
              +The proposed solution provides a mechanism for "automatic" handling of classes
              +that evolve by adding fields and adding classes. Serialization will handle
              +versioning without class-specific methods to be implemented for each version.
              +The stream format can be traversed without invoking class-specific methods.
              +
              +## 5.2 Goals
              +
              +The goals are to:
              +
              +-   Support bidirectional communication between different versions of a class
              +    operating in different virtual machines by:
              +
              +    -   Defining a mechanism that allows Java classes to read streams written
              +        by older versions of the same class.
              +
              +    -   Defining a mechanism that allows Java classes to write streams intended
              +        to be read by older versions of the same class.
              +
              +-   Provide default serialization for persistence and for RMI.
              +
              +-   Perform well and produce compact streams in simple cases, so that RMI can
              +    use serialization.
              +
              +-   Be able to identify and load classes that match the exact class used to
              +    write the stream.
              +
              +-   Keep the overhead low for nonversioned classes.
              +
              +-   Use a stream format that allows the traversal of the stream without having
              +    to invoke methods specific to the objects saved in the stream.
              +
              +## 5.3 Assumptions
              +
              +The assumptions are that:
              +
              +-   Versioning will only apply to serializable classes since it must control
              +    the stream format to achieve it goals. Externalizable classes will be
              +    responsible for their own versioning which is tied to the external format.
              +
              +-   All data and objects must be read from, or skipped in, the stream in the
              +    same order as they were written.
              +
              +-   Classes evolve individually as well as in concert with supertypes and
              +    subtypes.
              +
              +-   Classes are identified by name. Two classes with the same name may be
              +    different versions or completely different classes that can be
              +    distinguished only by comparing their interfaces or by comparing hashes of
              +    the interfaces.
              +
              +-   Default serialization will not perform any type conversions.
              +
              +-   The stream format only needs to support a linear sequence of type changes,
              +    not arbitrary branching of a type.
              +
              +## 5.4 Who's Responsible for Versioning of Streams
              +
              +In the evolution of classes, it is the responsibility of the evolved (later
              +version) class to maintain the contract established by the nonevolved class.
              +This takes two forms. First, the evolved class must not break the existing
              +assumptions about the interface provided by the original version, so that the
              +evolved class can be used in place of the original. Secondly, when
              +communicating with the original (or previous) versions, the evolved class must
              +provide sufficient and equivalent information to allow the earlier version to
              +continue to satisfy the nonevolved contract.
              +
              +>   ![*Private serialization protocol and contract with supertype relationships
              +    between evolved and nonevolved classes and their
              +    instances*](images/version.gif)
              +
              +For the purposes of the discussion here, each class implements and extends the
              +interface or contract defined by its supertype. New versions of a class, for
              +example `foo'`, must continue to satisfy the contract for `foo` and may extend
              +the interface or modify its implementation.
              +
              +Communication between objects via serialization is not part of the contract
              +defined by these interfaces. Serialization is a private protocol between the
              +implementations. It is the responsibility of the implementations to communicate
              +sufficiently to allow each implementation to continue to satisfy the contract
              +expected by its clients.
              +
              +## 5.5 Compatible Java Type Evolution
              +
              +The Java Language Specification discusses binary compatibility of Java classes
              +as those classes evolve. Most of the flexibility of binary compatibility comes
              +from the use of late binding of symbolic references for the names of classes,
              +interfaces, fields, methods, and so on.
              +
              +The following are the principle aspects of the design for versioning of
              +serialized object streams.
              +
              +-   The default serialization mechanism will use a symbolic model for binding
              +    the fields in the stream to the fields in the corresponding class in the
              +    virtual machine.
              +
              +-   Each class referenced in the stream will uniquely identify itself, its
              +    supertype, and the types and names of each serializable field written to
              +    the stream. The fields are ordered with the primitive types first sorted by
              +    field name, followed by the object fields sorted by field name.
              +
              +-   Two types of data may occur in the stream for each class: required data
              +    (corresponding directly to the serializable fields of the object); and
              +    optional data (consisting of an arbitrary sequence of primitives and
              +    objects). The stream format defines how the required and optional data
              +    occur in the stream so that the whole class, the required, or the optional
              +    parts can be skipped if necessary.
              +
              +    -   The required data consists of the fields of the object in the order
              +        defined by the class descriptor.
              +
              +    -   The optional data is written to the stream and does not correspond
              +        directly to fields of the class. The class itself is responsible for
              +        the length, types, and versioning of this optional information.
              +
              +-   If defined for a class, the `writeObject`/`readObject` methods supersede
              +    the default mechanism to write/read the state of the class. These methods
              +    write and read the optional data for a class. The required data is written
              +    by calling `defaultWriteObject` and read by calling `defaultReadObject`.
              +
              +-   The stream format of each class is identified by the use of a Stream Unique
              +    Identifier (SUID). By default, this is the hash of the class. All later
              +    versions of the class must declare the Stream Unique Identifier (SUID) that
              +    they are compatible with. This guards against classes with the same name
              +    that might inadvertently be identified as being versions of a single class.
              +
              +-   Subtypes of `ObjectOutputStream` and `ObjectInputStream` may include their
              +    own information identifying the class using the `annotateClass` method; for
              +    example, `MarshalOutputStream` embeds the URL of the class.
              +
              +## 5.6 Type Changes Affecting Serialization
              +
              +With these concepts, we can now describe how the design will cope with the
              +different cases of an evolving class. The cases are described in terms of a
              +stream written by some version of a class. When the stream is read back by the
              +same version of the class, there is no loss of information or functionality.
              +The stream is the only source of information about the original class. Its
              +class descriptions, while a subset of the original class description, are
              +sufficient to match up the data in the stream with the version of the class
              +being reconstituted.
              +
              +The descriptions are from the perspective of the stream being read in order to
              +reconstitute either an earlier or later version of the class. In the parlance
              +of RPC systems, this is a "receiver makes right" system. The writer writes its
              +data in the most suitable form and the receiver must interpret that information
              +to extract the parts it needs and to fill in the parts that are not available.
              +
              +### 5.6.1 Incompatible Changes
              +
              +Incompatible changes to classes are those changes for which the guarantee of
              +interoperability cannot be maintained. The incompatible changes that may occur
              +while evolving a class are:
              +
              +-   Deleting fields - If a field is deleted in a class, the stream written will
              +    not contain its value. When the stream is read by an earlier class, the
              +    value of the field will be set to the default value because no value is
              +    available in the stream. However, this default value may adversely impair
              +    the ability of the earlier version to fulfill its contract.
              +
              +-   Moving classes up or down the hierarchy - This cannot be allowed since the
              +    data in the stream appears in the wrong sequence.
              +
              +-   Changing a nonstatic field to static or a nontransient field to transient -
              +    When relying on default serialization, this change is equivalent to
              +    deleting a field from the class. This version of the class will not write
              +    that data to the stream, so it will not be available to be read by earlier
              +    versions of the class. As when deleting a field, the field of the earlier
              +    version will be initialized to the default value, which can cause the class
              +    to fail in unexpected ways.
              +
              +-   Changing the declared type of a primitive field - Each version of the class
              +    writes the data with its declared type. Earlier versions of the class
              +    attempting to read the field will fail because the type of the data in the
              +    stream does not match the type of the field.
              +
              +-   Changing the `writeObject` or `readObject` method so that it no longer
              +    writes or reads the default field data or changing it so that it attempts
              +    to write it or read it when the previous version did not. The default field
              +    data must consistently either appear or not appear in the stream.
              +
              +-   Changing a class from `Serializable` to `Externalizable` or vice versa is
              +    an incompatible change since the stream will contain data that is
              +    incompatible with the implementation of the available class.
              +
              +-   Changing a class from a non-enum type to an enum type or vice versa since
              +    the stream will contain data that is incompatible with the implementation
              +    of the available class.
              +
              +-   Removing either `Serializable` or `Externalizable` is an incompatible
              +    change since when written it will no longer supply the fields needed by
              +    older versions of the class.
              +
              +-   Adding the `writeReplace` or `readResolve` method to a class is
              +    incompatible if the behavior would produce an object that is incompatible
              +    with any older version of the class.
              +
              +### 5.6.2 Compatible Changes
              +
              +The compatible changes to a class are handled as follows:
              +
              +-   Adding fields - When the class being reconstituted has a field that does
              +    not occur in the stream, that field in the object will be initialized to
              +    the default value for its type. If class-specific initialization is needed,
              +    the class may provide a readObject method that can initialize the field to
              +    nondefault values.
              +
              +-   Adding classes - The stream will contain the type hierarchy of each object
              +    in the stream. Comparing this hierarchy in the stream with the current
              +    class can detect additional classes. Since there is no information in the
              +    stream from which to initialize the object, the class's fields will be
              +    initialized to the default values.
              +
              +-   Removing classes - Comparing the class hierarchy in the stream with that of
              +    the current class can detect that a class has been deleted. In this case,
              +    the fields and objects corresponding to that class are read from the
              +    stream. Primitive fields are discarded, but the objects referenced by the
              +    deleted class are created, since they may be referred to later in the
              +    stream. They will be garbage-collected when the stream is garbage-collected
              +    or reset.
              +
              +-   Adding `writeObject`/`readObject` methods - If the version reading the
              +    stream has these methods then `readObject` is expected, as usual, to read
              +    the required data written to the stream by the default serialization. It
              +    should call `defaultReadObject` first before reading any optional data. The
              +    `writeObject` method is expected as usual to call `defaultWriteObject` to
              +    write the required data and then may write optional data.
              +
              +-   Removing `writeObject`/`readObject` methods - If the class reading the
              +    stream does not have these methods, the required data will be read by
              +    default serialization, and the optional data will be discarded.
              +
              +-   Adding `java.io.Serializable` - This is equivalent to adding types. There
              +    will be no values in the stream for this class so its fields will be
              +    initialized to default values. The support for subclassing nonserializable
              +    classes requires that the class's supertype have a no-arg constructor and
              +    the class itself will be initialized to default values. If the no-arg
              +    constructor is not available, the `InvalidClassException` is thrown.
              +
              +-   Changing the access to a field - The access modifiers public, package,
              +    protected, and private have no effect on the ability of serialization to
              +    assign values to the fields.
              +
              +-   Changing a field from static to nonstatic or transient to nontransient -
              +    When relying on default serialization to compute the serializable fields,
              +    this change is equivalent to adding a field to the class. The new field
              +    will be written to the stream but earlier classes will ignore the value
              +    since serialization will not assign values to static or transient fields.
              +
              +-------------------------------------------------------------------------------
              +
              +*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle
              +and/or its affiliates. All rights reserved.*
              diff --git a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java
              index 78d9f7fc061..c08f0bfa868 100644
              --- a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java
              +++ b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.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
              @@ -617,7 +617,7 @@ final class ProcessImpl extends Process {
                   }
               
                   @Override
              -    public long getPid() {
              +    public long pid() {
                       return pid;
                   }
               
              diff --git a/jdk/src/java.base/unix/classes/module-info.java.extra b/jdk/src/java.base/unix/classes/module-info.java.extra
              index 43f85b0309a..2dc36bf4b53 100644
              --- a/jdk/src/java.base/unix/classes/module-info.java.extra
              +++ b/jdk/src/java.base/unix/classes/module-info.java.extra
              @@ -23,14 +23,5 @@
                * questions.
                */
               
              -// jdk.vm.compiler uses Unsafe and VM classes from jdk.internal.misc
              -exports jdk.internal.misc to jdk.vm.compiler;
              -opens   jdk.internal.misc to jdk.vm.compiler;
              -
              -// jdk.vm.compiler uses com.sun.crypto.provider to generate crypto intrinsics
              -opens com.sun.crypto.provider to jdk.vm.compiler;
              -
              -exports jdk.internal.module to jdk.vm.compiler;
              -
               // AOT uses jdk.internal.misc.Unsafe
               exports jdk.internal.misc to jdk.aot;
              diff --git a/jdk/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/jdk/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
              index 01213c04360..878f6d52f59 100644
              --- a/jdk/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
              +++ b/jdk/src/java.base/unix/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
              @@ -35,6 +35,7 @@ import java.net.URL;
               import java.security.GeneralSecurityException;
               import java.util.Base64;
               import java.util.Objects;
              +import java.util.Properties;
               
               import sun.net.www.HeaderParser;
               import sun.net.www.protocol.http.AuthenticationInfo;
              @@ -76,8 +77,15 @@ public class NTLMAuthentication extends AuthenticationInfo {
               
                   private String hostname;
                   /* Domain to use if not specified by user */
              -    private static String defaultDomain =
              -            GetPropertyAction.privilegedGetProperty("http.auth.ntlm.domain", "");
              +    private static final String defaultDomain;
              +    /* Whether cache is enabled for NTLM */
              +    private static final boolean ntlmCache;
              +    static {
              +        Properties props = GetPropertyAction.privilegedGetProperties();
              +        defaultDomain = props.getProperty("http.auth.ntlm.domain", "");
              +        String ntlmCacheProp = props.getProperty("jdk.ntlm.cache", "true");
              +        ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
              +    }
               
                   public static boolean supportsTransparentAuth () {
                       return false;
              @@ -171,6 +179,11 @@ public class NTLMAuthentication extends AuthenticationInfo {
                       init (pw);
                   }
               
              +    @Override
              +    protected boolean useAuthCache() {
              +        return ntlmCache && super.useAuthCache();
              +    }
              +
                   /**
                    * @return true if this authentication supports preemptive authorization
                    */
              diff --git a/jdk/src/java.base/unix/native/launcher/jexec.c b/jdk/src/java.base/unix/native/launcher/jexec.c
              index d2888234674..bd6458c67a1 100644
              --- a/jdk/src/java.base/unix/native/launcher/jexec.c
              +++ b/jdk/src/java.base/unix/native/launcher/jexec.c
              @@ -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
              @@ -332,7 +332,7 @@ const char * isJar(const char * path) {
               
                               if (end <= count) {
                                   end -= 4; // make sure there are 4 bytes to read at start
              -                    while (start < end) {
              +                    while (start <= end) {
                                       off_t xhid  = SH(buf, start);
                                       off_t xdlen = SH(buf, start + 2);
               
              diff --git a/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c b/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
              index 6c0e1cc1cd1..2702849c4a2 100644
              --- a/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
              +++ b/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
              @@ -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
              @@ -244,7 +244,8 @@ Java_java_lang_ProcessHandleImpl_waitForProcessExit0(JNIEnv* env,
                       int status;
                       while (waitpid(pid, &status, 0) < 0) {
                           switch (errno) {
              -                case ECHILD: return 0;
              +                case ECHILD:
              +                    return java_lang_ProcessHandleImpl_NOT_A_CHILD; // No child
                               case EINTR: break;
                               default: return -1;
                           }
              @@ -269,9 +270,10 @@ Java_java_lang_ProcessHandleImpl_waitForProcessExit0(JNIEnv* env,
                       memset(&siginfo, 0, sizeof siginfo);
                       while (waitid(P_PID, pid, &siginfo, options) < 0) {
                           switch (errno) {
              -            case ECHILD: return 0;
              -            case EINTR: break;
              -            default: return -1;
              +                case ECHILD:
              +                    return java_lang_ProcessHandleImpl_NOT_A_CHILD; // No child
              +                case EINTR: break;
              +                default: return -1;
                           }
                       }
               
              diff --git a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java
              index 988234daf51..d4063bdc606 100644
              --- a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java
              +++ b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java
              @@ -1,5 +1,5 @@
               /*
              - * Copyright (c) 1995, 2015, 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
              @@ -523,7 +523,7 @@ final class ProcessImpl extends Process {
               
                   @Override
                   public CompletableFuture onExit() {
              -        return ProcessHandleImpl.completion(getPid(), false)
              +        return ProcessHandleImpl.completion(pid(), false)
                               .handleAsync((exitStatus, unusedThrowable) -> this);
                   }
               
              @@ -550,8 +550,8 @@ final class ProcessImpl extends Process {
                   private static native void terminateProcess(long handle);
               
                   @Override
              -    public long getPid() {
              -        return processHandle.getPid();
              +    public long pid() {
              +        return processHandle.pid();
                   }
               
                   private static native int getProcessId0(long handle);
              @@ -572,7 +572,7 @@ final class ProcessImpl extends Process {
                   @Override
                   public String toString() {
                       int exitCode = getExitCodeProcess(handle);
              -        return new StringBuilder("Process[pid=").append(getPid())
              +        return new StringBuilder("Process[pid=").append(pid())
                               .append(", exitValue=").append(exitCode == STILL_ACTIVE ? "\"not exited\"" : exitCode)
                               .append("]").toString();
                   }
              diff --git a/jdk/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/jdk/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
              index 212e03e834f..a3a5059d9b7 100644
              --- a/jdk/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
              +++ b/jdk/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
              @@ -31,6 +31,7 @@ import java.net.PasswordAuthentication;
               import java.net.UnknownHostException;
               import java.net.URL;
               import java.util.Objects;
              +import java.util.Properties;
               import sun.net.www.HeaderParser;
               import sun.net.www.protocol.http.AuthenticationInfo;
               import sun.net.www.protocol.http.AuthScheme;
              @@ -51,12 +52,16 @@ public class NTLMAuthentication extends AuthenticationInfo {
                       NTLMAuthenticationCallback.getNTLMAuthenticationCallback();
               
                   private String hostname;
              -    private static String defaultDomain; /* Domain to use if not specified by user */
              -
              +    /* Domain to use if not specified by user */
              +    private static final String defaultDomain;
              +    /* Whether cache is enabled for NTLM */
              +    private static final boolean ntlmCache;
                   static {
              -        defaultDomain = GetPropertyAction
              -                .privilegedGetProperty("http.auth.ntlm.domain", "domain");
              -    };
              +        Properties props = GetPropertyAction.privilegedGetProperties();
              +        defaultDomain = props.getProperty("http.auth.ntlm.domain", "domain");
              +        String ntlmCacheProp = props.getProperty("jdk.ntlm.cache", "true");
              +        ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
              +    }
               
                   private void init0() {
               
              @@ -136,6 +141,11 @@ public class NTLMAuthentication extends AuthenticationInfo {
                       init (pw);
                   }
               
              +    @Override
              +    protected boolean useAuthCache() {
              +        return ntlmCache && super.useAuthCache();
              +    }
              +
                   /**
                    * @return true if this authentication supports preemptive authorization
                    */
              diff --git a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c
              index f984885ed01..955775f9d42 100644
              --- a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c
              +++ b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c
              @@ -205,9 +205,9 @@ void JLI_CmdToArgs(char* cmdline) {
                   size_t i, cnt;
               
                   JLI_List envArgs = JLI_List_new(1);
              -    if (JLI_AddArgsFromEnvVar(envArgs, JAVA_OPTIONS)) {
              +    if (JLI_AddArgsFromEnvVar(envArgs, JDK_JAVA_OPTIONS)) {
                       // JLI_SetTraceLauncher is not called yet
              -        // Show _JAVA_OPTIONS content along with JAVA_OPTIONS to aid diagnosis
              +        // Show _JAVA_OPTIONS content along with JDK_JAVA_OPTIONS to aid diagnosis
                       if (getenv(JLDEBUG_ENV_ENTRY)) {
                           char *tmp = getenv("_JAVA_OPTIONS");
                           if (NULL != tmp) {
              diff --git a/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java b/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java
              index becfd0563ba..7cc256e9e6d 100644
              --- a/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java
              +++ b/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java
              @@ -211,6 +211,9 @@ public class DataFlavor implements Externalizable, Cloneable {
                    *     representationClass = java.awt.Image
                    *     mimeType            = "image/x-java-image"
                    * 
              + * Will be {@code null} if {@code java.awt.Image} is not visible, the + * {@code java.desktop} module is not loaded, or the {@code java.desktop} + * module is not in the run-time image. */ public static final DataFlavor imageFlavor = createConstant("image/x-java-image; class=java.awt.Image", "Image"); diff --git a/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/package-info.java b/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/package-info.java new file mode 100644 index 00000000000..c13a4be834b --- /dev/null +++ b/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/package-info.java @@ -0,0 +1,42 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides interfaces and classes for transferring data between and within + * applications. It defines the notion of a "transferable" object, which is an + * object capable of being transferred between or within applications. An object + * identifies itself as being transferable by implementing the Transferable + * interface. + *

              + * It also provides a clipboard mechanism, which is an object that temporarily + * holds a transferable object that can be transferred between or within an + * application. The clipboard is typically used for copy and paste operations. + * Although it is possible to create a clipboard to use within an application, + * most applications will use the system clipboard to ensure the data can be + * transferred across applications running on the platform. + * + * @since 1.1 + */ +package java.awt.datatransfer; diff --git a/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/package.html b/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/package.html deleted file mode 100644 index c3b55e88340..00000000000 --- a/jdk/src/java.datatransfer/share/classes/java/awt/datatransfer/package.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - -Provides interfaces and classes for transferring data -between and within applications. It defines the notion of a -"transferable" object, which is an object capable of being -transferred between or within applications. An object identifies -itself as being transferable by implementing the Transferable -interface. -

              -It also provides a clipboard mechanism, which is an object that -temporarily holds a transferable object that can be transferred -between or within an application. The clipboard is typically used -for copy and paste operations. Although it is possible to create -a clipboard to use within an application, most applications will -use the system clipboard to ensure the data can be transferred -across applications running on the platform. - - - -@since 1.1 - - diff --git a/jdk/src/java.datatransfer/share/classes/module-info.java b/jdk/src/java.datatransfer/share/classes/module-info.java index ea3f9c2a53c..41fbc8d7b0c 100644 --- a/jdk/src/java.datatransfer/share/classes/module-info.java +++ b/jdk/src/java.datatransfer/share/classes/module-info.java @@ -24,7 +24,10 @@ */ /** - * Defines an API for transferring data between and within applications. + * Defines the API for transferring data between and within applications. + * + * @moduleGraph + * @since 9 */ module java.datatransfer { exports java.awt.datatransfer; diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java index 8e105132eaa..175af75f73d 100644 --- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java +++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java @@ -78,7 +78,7 @@ public final class JRSUIConstants { return "THUMB_START"; } else if (hit == WINDOW_TITLE_BAR_HEIGHT) { return "WINDOW_TITLE_BAR_HEIGHT"; - } else if (hit == THUMB_START) { + } else if (hit == ANIMATION_FRAME) { return "ANIMATION_FRAME"; } return getClass().getSimpleName(); diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java index 115002b5825..e3579449b75 100644 --- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java +++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.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 @@ -114,6 +114,7 @@ public final class JRSUIControl { changes.putAll(other.changes); } + @SuppressWarnings("deprecation") protected synchronized void finalize() throws Throwable { if (cfDictionaryPtr == 0) return; disposeCFDictionary(cfDictionaryPtr); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/Application.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/Application.java index c0a4009bd6c..9bcafeae1b1 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/Application.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/Application.java @@ -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 @@ -29,7 +29,24 @@ import java.awt.Image; import java.awt.PopupMenu; import java.awt.Toolkit; import java.awt.Window; -import java.awt.desktop.*; +import java.awt.desktop.AboutHandler; +import java.awt.desktop.AppForegroundListener; +import java.awt.desktop.AppHiddenListener; +import java.awt.desktop.AppReopenedListener; +import java.awt.desktop.OpenFilesEvent; +import java.awt.desktop.OpenFilesHandler; +import java.awt.desktop.OpenURIEvent; +import java.awt.desktop.OpenURIHandler; +import java.awt.desktop.PreferencesHandler; +import java.awt.desktop.PrintFilesEvent; +import java.awt.desktop.PrintFilesHandler; +import java.awt.desktop.QuitHandler; +import java.awt.desktop.QuitResponse; +import java.awt.desktop.QuitStrategy; +import java.awt.desktop.ScreenSleepListener; +import java.awt.desktop.SystemEventListener; +import java.awt.desktop.SystemSleepListener; +import java.awt.desktop.UserSessionListener; import java.beans.Beans; import javax.swing.JMenuBar; @@ -108,10 +125,10 @@ public class Application { * * @see AppForegroundListener * @see AppHiddenListener - * @see AppReOpenedListener - * @see AppScreenSleepListener - * @see AppSystemSleepListener - * @see AppUserSessionListener + * @see AppReopenedListener + * @see ScreenSleepListener + * @see SystemSleepListener + * @see UserSessionListener * * @param listener * @since Java for Mac OS X 10.6 Update 3 @@ -126,10 +143,10 @@ public class Application { * * @see AppForegroundListener * @see AppHiddenListener - * @see AppReOpenedListener - * @see AppScreenSleepListener - * @see AppSystemSleepListener - * @see AppUserSessionListener + * @see AppReopenedListener + * @see ScreenSleepListener + * @see SystemSleepListener + * @see UserSessionListener * * @param listener * @since Java for Mac OS X 10.6 Update 3 @@ -144,7 +161,7 @@ public class Application { * * Setting the {@link AboutHandler} to {@code null} reverts it to the default Cocoa About window. * - * @param aboutHandler the handler to respond to the {@link AboutHandler#handleAbout()} message + * @param aboutHandler the handler to respond to the {@link AboutHandler#handleAbout} message * @since Java for Mac OS X 10.6 Update 3 * @since Java for Mac OS X 10.5 Update 8 */ @@ -167,7 +184,7 @@ public class Application { /** * Installs the handler which is notified when the application is asked to open a list of files. - * The {@link OpenFilesHandler#openFiles(AppEvent.OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist. + * The {@link OpenFilesHandler#openFiles(OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist. * See the Info.plist Key Reference for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist. * * @param openFileHandler @@ -180,7 +197,7 @@ public class Application { /** * Installs the handler which is notified when the application is asked to print a list of files. - * The {@link PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist. + * The {@link PrintFilesHandler#printFiles(PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist. * See the Info.plist Key Reference for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist. * * @param printFileHandler @@ -193,10 +210,10 @@ public class Application { /** * Installs the handler which is notified when the application is asked to open a URL. - * The {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleURLTypes} array present in it's Info.plist. + * The {@link OpenURIHandler#openURI(OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleURLTypes} array present in it's Info.plist. * See the Info.plist Key Reference for more information about adding a {@code CFBundleURLTypes} key to your app's Info.plist. * - * Setting the handler to {@code null} causes all {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be enqueued until another handler is set. + * Setting the handler to {@code null} causes all {@link OpenURIHandler#openURI(OpenURIEvent)} requests to be enqueued until another handler is set. * * @param openURIHandler * @since Java for Mac OS X 10.6 Update 3 diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java index aba03e9f744..da1c967b090 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationAdapter.java @@ -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,12 +25,26 @@ package com.apple.eawt; +import java.awt.desktop.AboutHandler; +import java.awt.desktop.AppForegroundListener; +import java.awt.desktop.AppHiddenListener; +import java.awt.desktop.AppReopenedListener; +import java.awt.desktop.OpenFilesHandler; +import java.awt.desktop.OpenURIHandler; +import java.awt.desktop.PreferencesHandler; +import java.awt.desktop.PrintFilesHandler; +import java.awt.desktop.QuitHandler; +import java.awt.desktop.ScreenSleepListener; +import java.awt.desktop.SystemEventListener; +import java.awt.desktop.SystemSleepListener; +import java.awt.desktop.UserSessionListener; + /** * An abstract adapter class for receiving {@code ApplicationEvents}. * * ApplicationEvents are deprecated. Use individual app event listeners or handlers instead. * - * @see Application#addAppEventListener(AppEventListener) + * @see Application#addAppEventListener(SystemEventListener) * * @see AboutHandler * @see PreferencesHandler @@ -39,14 +53,14 @@ package com.apple.eawt; * @see PrintFilesHandler * @see QuitHandler * - * @see AppReOpenedListener + * @see AppReopenedListener * @see AppForegroundListener * @see AppHiddenListener * @see UserSessionListener * @see ScreenSleepListener * @see SystemSleepListener * - * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse}. + * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReopenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse}. * @since 1.4 */ @SuppressWarnings("deprecation") diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java index 49617f6c852..98c1bc5cbe7 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationEvent.java @@ -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,12 +25,18 @@ package com.apple.eawt; +import java.awt.desktop.AboutHandler; +import java.awt.desktop.AppReopenedListener; +import java.awt.desktop.OpenFilesHandler; +import java.awt.desktop.PreferencesHandler; +import java.awt.desktop.PrintFilesHandler; +import java.awt.desktop.QuitHandler; import java.util.EventObject; /** * The class of events sent to the deprecated ApplicationListener callbacks. * - * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse} + * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReopenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse} * @since 1.4 */ @Deprecated diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java index eabcb92aafe..74bec650a12 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/ApplicationListener.java @@ -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,12 +25,25 @@ package com.apple.eawt; +import java.awt.desktop.AboutHandler; +import java.awt.desktop.AppForegroundListener; +import java.awt.desktop.AppHiddenListener; +import java.awt.desktop.AppReopenedListener; +import java.awt.desktop.OpenFilesHandler; +import java.awt.desktop.OpenURIHandler; +import java.awt.desktop.PreferencesHandler; +import java.awt.desktop.PrintFilesHandler; +import java.awt.desktop.QuitHandler; +import java.awt.desktop.ScreenSleepListener; +import java.awt.desktop.SystemEventListener; +import java.awt.desktop.SystemSleepListener; +import java.awt.desktop.UserSessionListener; import java.util.EventListener; /** * ApplicationEvents are deprecated. Use individual AppEvent listeners or handlers instead. * - * @see Application#addAppEventListener(AppEventListener) + * @see Application#addAppEventListener(SystemEventListener) * * @see AboutHandler * @see PreferencesHandler @@ -39,7 +52,7 @@ import java.util.EventListener; * @see PrintFilesHandler * @see QuitHandler * - * @see AppReOpenedListener + * @see AppReopenedListener * @see AppForegroundListener * @see AppHiddenListener * @see UserSessionListener @@ -47,7 +60,7 @@ import java.util.EventListener; * @see SystemSleepListener * * @since 1.4 - * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse} + * @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReopenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link MacQuitResponse} */ @SuppressWarnings("deprecation") @Deprecated @@ -146,7 +159,7 @@ public interface ApplicationListener extends EventListener { * event is sent from another application, include that code as part of this handler. * * @param event the Reopen Application event - * @deprecated use {@link AppReOpenedListener} + * @deprecated use {@link AppReopenedListener} */ @Deprecated public void handleReOpenApplication(ApplicationEvent event); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java index 4a124da6e38..79fcd34b920 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenAdapter.java @@ -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,13 +25,15 @@ package com.apple.eawt; +import java.awt.Window; + import com.apple.eawt.event.FullScreenEvent; /** * Abstract adapter class for receiving fullscreen events. This class is provided * as a convenience for creating listeners. * - * Subclasses registered with {@link FullScreenUtilities#addFullScreenListenerTo(javax.swing.RootPaneContainer, FullScreenListener)} + * Subclasses registered with {@link FullScreenUtilities#addFullScreenListenerTo(Window, FullScreenListener)} * will receive all entering/entered/exiting/exited full screen events. * * @see FullScreenUtilities diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java index 737a67f6f83..d3490efcde7 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenListener.java @@ -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 @@ -37,25 +37,25 @@ import java.util.EventListener; public interface FullScreenListener extends EventListener { /** * Invoked when a window has started to enter full screen. - * @param event containing the specific window entering full screen. + * @param e containing the specific window entering full screen. */ public void windowEnteringFullScreen(final FullScreenEvent e); /** * Invoked when a window has fully entered full screen. - * @param event containing the specific window which has entered full screen. + * @param e containing the specific window which has entered full screen. */ public void windowEnteredFullScreen(final FullScreenEvent e); /** * Invoked when a window has started to exit full screen. - * @param event containing the specific window exiting full screen. + * @param e containing the specific window exiting full screen. */ public void windowExitingFullScreen(final FullScreenEvent e); /** * Invoked when a window has fully exited full screen. - * @param event containing the specific window which has exited full screen. + * @param e containing the specific window which has exited full screen. */ public void windowExitedFullScreen(final FullScreenEvent e); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenUtilities.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenUtilities.java index 682c07e721d..38472121b8b 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenUtilities.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/FullScreenUtilities.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 @@ -36,7 +36,7 @@ import com.apple.eawt.event.GestureUtilities; /** * Utility class perform animated full screen actions to top-level {@link Window}s. * - * This class manages the relationship between {@link Windows}s and the {@link FullScreenListener}s + * This class manages the relationship between {@link Window}s and the {@link FullScreenListener}s * attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities} * class which adds additional functionality to AWT Windows, without adding new API to the * {@link java.awt.Window} class. diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java index ab37dfc93d9..5b9eb054c33 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/MacQuitResponse.java @@ -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,11 +25,14 @@ package com.apple.eawt; +import java.awt.desktop.QuitEvent; +import java.awt.desktop.QuitHandler; import java.awt.desktop.QuitResponse; +import java.awt.desktop.QuitStrategy; /** * Used to respond to a request to quit the application. - * The QuitResponse may be used after the {@link QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, MacQuitResponse)} method has returned, and may be used from any thread. + * The QuitResponse may be used after the {@link QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse)} method has returned, and may be used from any thread. * * @see Application#setQuitHandler(QuitHandler) * @see QuitHandler diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java index c9c0c9bcf4d..8f1363f774c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java @@ -73,8 +73,7 @@ class _AppDockIconHandler { public void setDockIconImage(final Image image) { try { final CImage cImage = CImage.createFromImage(image); - final long nsImagePtr = getNSImagePtrFrom(cImage); - nativeSetDockIconImage(nsImagePtr); + cImage.execute(_AppDockIconHandler::nativeSetDockIconImage); } catch (final Throwable e) { throw new RuntimeException(e); } @@ -101,16 +100,4 @@ class _AppDockIconHandler { void setDockIconProgress(int value) { nativeSetDockIconProgress(value); } - - static long getNSImagePtrFrom(final CImage cImage) { - if (cImage == null) return 0; - - try { - final Field cImagePtrField = CFRetainedResource.class.getDeclaredField("ptr"); - cImagePtrField.setAccessible(true); - return cImagePtrField.getLong(cImage); - } catch (final Throwable e) { - throw new RuntimeException(e); - } - } } 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 e017b32538a..7eb35adc58a 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 @@ -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,9 +25,13 @@ package com.apple.eawt; +import java.awt.Container; import java.awt.Frame; -import javax.swing.*; + +import javax.swing.JFrame; +import javax.swing.JLayeredPane; +import javax.swing.JMenuBar; import javax.swing.plaf.MenuBarUI; import com.apple.laf.ScreenMenuBar; @@ -102,10 +106,15 @@ class _AppMenuBarHandler { return; } - final MenuBarUI ui = menuBar.getUI(); + Container parent = menuBar.getParent(); + if (parent instanceof JLayeredPane) { + ((JLayeredPane) parent).remove(menuBar); + } + + MenuBarUI ui = menuBar.getUI(); if (!(ui instanceof AquaMenuBarUI)) { - // Aqua was not installed - throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel"); + ui = new AquaMenuBarUI(); + menuBar.setUI(ui); } final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.java index 6e17f534218..0f6c6d9ee7f 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureAdapter.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 @@ -29,7 +29,7 @@ package com.apple.eawt.event; * Abstract adapter class for receiving gesture events. This class is provided * as a convenience for creating listeners. * - * Subclasses registered with {@link GestureUtilities#addGestureListenerTo()} + * Subclasses registered with {@link GestureUtilities#addGestureListenerTo} * will receive all phase, magnification, rotation, and swipe events. * * @see GestureUtilities diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureEvent.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureEvent.java index 7c35589d54e..6e313b086d5 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureEvent.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GestureEvent.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,6 +26,7 @@ package com.apple.eawt.event; import java.awt.*; +import java.awt.event.InputEvent; /** * Abstract event all gestures inherit from. diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseListener.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseListener.java index c0fc3431c14..e6d90db7b98 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseListener.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/GesturePhaseListener.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 @@ -39,13 +39,13 @@ package com.apple.eawt.event; public interface GesturePhaseListener extends GestureListener { /** * Invoked when the user has started a continuous gesture. - * @param event representing the start of a continuous gesture. + * @param e representing the start of a continuous gesture. */ public void gestureBegan(final GesturePhaseEvent e); /** * Invoked when the user has stopped a continuous gesture. - * @param event representing the end of a continuous gesture. + * @param e representing the end of a continuous gesture. */ public void gestureEnded(final GesturePhaseEvent e); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationListener.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationListener.java index 35130ba7061..d327b70287f 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationListener.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/MagnificationListener.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 @@ -37,7 +37,7 @@ package com.apple.eawt.event; public interface MagnificationListener extends GestureListener { /** * Invoked when a magnification gesture is performed by the user. - * @param event containing the scale of the magnification. + * @param e containing the scale of the magnification. */ public void magnify(final MagnificationEvent e); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationListener.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationListener.java index ae3ed067770..9fcbed76175 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationListener.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/RotationListener.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 @@ -37,7 +37,7 @@ package com.apple.eawt.event; public interface RotationListener extends GestureListener { /** * Invoked when a rotation gesture is performed by the user. - * @param event containing an abstract measure of rotation. + * @param e containing an abstract measure of rotation. */ public void rotate(final RotationEvent e); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeListener.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeListener.java index cfbbdc2aa07..598eb38185f 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeListener.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/SwipeListener.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 @@ -38,25 +38,25 @@ package com.apple.eawt.event; public interface SwipeListener extends GestureListener { /** * Invoked when an upwards swipe gesture is performed by the user. - * @param event representing the occurrence of a swipe. + * @param e representing the occurrence of a swipe. */ public void swipedUp(final SwipeEvent e); /** * Invoked when a downward swipe gesture is performed by the user. - * @param event representing the occurrence of a swipe. + * @param e representing the occurrence of a swipe. */ public void swipedDown(final SwipeEvent e); /** * Invoked when a leftward swipe gesture is performed by the user. - * @param event representing the occurrence of a swipe. + * @param e representing the occurrence of a swipe. */ public void swipedLeft(final SwipeEvent e); /** * Invoked when a rightward swipe gesture is performed by the user. - * @param event representing the occurrence of a swipe. + * @param e representing the occurrence of a swipe. */ public void swipedRight(final SwipeEvent e); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/package-info.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/package-info.java new file mode 100644 index 00000000000..bb8020d6b19 --- /dev/null +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/package-info.java @@ -0,0 +1,34 @@ +/* + * 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. 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. + */ + +/** + * Classes for receiving gesture events. Provides a mechanism to receive various + * gesture events on JComponents. Gesture notifications are relayed up the + * component hierarchy from the deepest component under the cursor to the + * top-level container. Events may be consumed by deeper components to prevent + * them from propagating to higher components. Gesture listeners are added to + * components using the GestureUtilities helper class. + */ +package com.apple.eawt.event; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/package.html b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/package.html deleted file mode 100644 index 0946e60f309..00000000000 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/event/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - -Classes for receiving gesture events. - -Provides a mechanism to receive various gesture events on JComponents. Gesture notifications are relayed up the component hierarchy from the deepest component under the cursor to the top-level container. Events may be consumed by deeper components to prevent them from propagating to higher components. - -Gesture listeners are added to components using the GestureUtilities helper class. - - diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/package-info.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/package-info.java new file mode 100644 index 00000000000..105bc093af6 --- /dev/null +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/package-info.java @@ -0,0 +1,36 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes for integrating Java applications with the native + * application environment. These classes provide a simple way to implement + * native features to fine tune Java applications on Mac OS X. These listeners + * and handlers can help make Java applications behaviors and user interface + * indistinguishable from native applications. For further information on the + * Mac OS X user interface, consult the + * Aqua Human Interface Guidelines. + */ +package com.apple.eawt; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/package.html b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/package.html deleted file mode 100644 index 81bc1a8d3f8..00000000000 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/package.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - -Provides classes for integrating Java applications with the native application environment. - -These classes provide a simple way to implement native features to fine tune Java applications on Mac OS X. These listeners and handlers can help make Java applications behaviors and user interface indistinguishable from native applications. For further information on the Mac OS X user interface, consult the Aqua Human Interface Guidelines. - diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eio/package-info.java b/jdk/src/java.desktop/macosx/classes/com/apple/eio/package-info.java new file mode 100644 index 00000000000..ba664d653ec --- /dev/null +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eio/package-info.java @@ -0,0 +1,36 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes to allow you to take advantage of functionality of the + * underlying Mac OS X operating system. The classes in this package provide + * access to features of Mac OS X that may or may not be present on other + * platforms. It should be noted that depending on any of these features ties + * Java applications to Mac OS X. For more thorough explanation of some of the + * topics discussed here, please refer to + * Inside Mac OS X: System Overview. + */ +package com.apple.eio; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eio/package.html b/jdk/src/java.desktop/macosx/classes/com/apple/eio/package.html deleted file mode 100644 index 922b5b4b84f..00000000000 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eio/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - -Provides classes to allow you to take advantage of functionality of the underlying Mac OS X operating system. -The classes in this package provide access to features of Mac OS X that may or may not be present on other platforms. It should be noted that depending on any of these features ties Java applications to Mac OS X. For more thorough explanation of some of the topics discussed here, please refer to Inside Mac OS X: System Overview. - diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonBorder.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonBorder.java index aa2947cb87d..f58c518d2d4 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonBorder.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonBorder.java @@ -37,7 +37,7 @@ import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.*; public abstract class AquaButtonBorder extends AquaBorder implements Border, UIResource { - public static final RecyclableSingleton fDynamic = new RecyclableSingletonFromDefaultConstructor(Dynamic.class); + private static final RecyclableSingleton fDynamic = new RecyclableSingletonFromDefaultConstructor(Dynamic.class); public static AquaButtonBorder getDynamicButtonBorder() { return fDynamic.get(); } @@ -47,12 +47,12 @@ public abstract class AquaButtonBorder extends AquaBorder implements Border, UIR return fToggle.get(); } - public static final RecyclableSingleton fToolBar = new RecyclableSingletonFromDefaultConstructor(Toolbar.class); + private static final RecyclableSingleton fToolBar = new RecyclableSingletonFromDefaultConstructor(Toolbar.class); public static Border getToolBarButtonBorder() { return fToolBar.get(); } - public static final RecyclableSingleton fBevel = new RecyclableSingleton() { + private static final RecyclableSingleton fBevel = new RecyclableSingleton() { protected Named getInstance() { return new Named(Widget.BUTTON_BEVEL, new SizeDescriptor(new SizeVariant().alterMargins(2, 4, 2, 4))); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java index d467ccab533..bef9fe83fc5 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonCheckBoxUI.java @@ -34,8 +34,8 @@ import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.*; public class AquaButtonCheckBoxUI extends AquaButtonLabeledUI { - protected static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaButtonCheckBoxUI.class); - protected static final RecyclableSingleton sizingIcon = new RecyclableSingleton() { + private static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaButtonCheckBoxUI.class); + private static final RecyclableSingleton sizingIcon = new RecyclableSingleton() { protected ImageIcon getInstance() { return new ImageIcon(AquaNativeResources.getRadioButtonSizerImage()); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java index 0d48390c6f8..aa48414e801 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonExtendedTypes.java @@ -138,7 +138,7 @@ public class AquaButtonExtendedTypes { return typeDefinitions.get().get(name); } - protected static final RecyclableSingleton> typeDefinitions = new RecyclableSingleton>() { + private static final RecyclableSingleton> typeDefinitions = new RecyclableSingleton>() { protected Map getInstance() { return getAllTypes(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java index c05f191ef38..5f6a076c755 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonLabeledUI.java @@ -42,9 +42,9 @@ import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.RecyclableSingleton; public abstract class AquaButtonLabeledUI extends AquaButtonToggleUI implements Sizeable { - protected static RecyclableSizingIcon regularIcon = new RecyclableSizingIcon(18); - protected static RecyclableSizingIcon smallIcon = new RecyclableSizingIcon(16); - protected static RecyclableSizingIcon miniIcon = new RecyclableSizingIcon(14); + private static final RecyclableSizingIcon regularIcon = new RecyclableSizingIcon(18); + private static final RecyclableSizingIcon smallIcon = new RecyclableSizingIcon(16); + private static final RecyclableSizingIcon miniIcon = new RecyclableSizingIcon(14); protected static class RecyclableSizingIcon extends RecyclableSingleton { final int iconSize; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java index cb465345853..a8da1803fdb 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonRadioUI.java @@ -34,8 +34,8 @@ import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.*; public class AquaButtonRadioUI extends AquaButtonLabeledUI { - protected static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaButtonRadioUI.class); - protected static final RecyclableSingleton sizingIcon = new RecyclableSingleton() { + private static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaButtonRadioUI.class); + private static final RecyclableSingleton sizingIcon = new RecyclableSingleton() { protected ImageIcon getInstance() { return new ImageIcon(AquaNativeResources.getRadioButtonSizerImage()); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java index d61126e7e97..d4f55f3c874 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonToggleUI.java @@ -32,7 +32,7 @@ import com.apple.laf.AquaUtils.*; public class AquaButtonToggleUI extends AquaButtonUI { // Create PLAF - static final RecyclableSingleton aquaToggleButtonUI = new RecyclableSingletonFromDefaultConstructor(AquaButtonToggleUI.class); + private static final RecyclableSingleton aquaToggleButtonUI = new RecyclableSingletonFromDefaultConstructor(AquaButtonToggleUI.class); public static ComponentUI createUI(final JComponent b) { return aquaToggleButtonUI.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java index 4d6d463fa5c..b173ee114e1 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java @@ -48,7 +48,7 @@ public class AquaButtonUI extends BasicButtonUI implements Sizeable { private static final String BUTTON_TYPE = "JButton.buttonType"; private static final String SEGMENTED_BUTTON_POSITION = "JButton.segmentPosition"; - protected static final RecyclableSingleton buttonUI = new RecyclableSingletonFromDefaultConstructor(AquaButtonUI.class); + private static final RecyclableSingleton buttonUI = new RecyclableSingletonFromDefaultConstructor(AquaButtonUI.class); public static ComponentUI createUI(final JComponent c) { return buttonUI.get(); } @@ -462,7 +462,7 @@ public class AquaButtonUI extends BasicButtonUI implements Sizeable { return d; } - static final RecyclableSingleton fHierListener = new RecyclableSingletonFromDefaultConstructor(AquaHierarchyButtonListener.class); + private static final RecyclableSingleton fHierListener = new RecyclableSingletonFromDefaultConstructor(AquaHierarchyButtonListener.class); static AquaHierarchyButtonListener getAquaHierarchyButtonListener() { return fHierListener.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java index 88faf6b06e8..7336fbd703c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.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 @@ -25,18 +25,29 @@ package com.apple.laf; -import java.awt.*; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.Insets; +import java.awt.Point; import java.awt.Rectangle; -import java.awt.event.*; +import java.awt.Toolkit; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; -import javax.swing.*; +import javax.swing.Box; +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import javax.swing.SwingUtilities; import javax.swing.plaf.basic.BasicComboPopup; import sun.lwawt.macosx.CPlatformWindow; @SuppressWarnings("serial") // Superclass is not serializable across versions -class AquaComboBoxPopup extends BasicComboPopup { +final class AquaComboBoxPopup extends BasicComboPopup { static final int FOCUS_RING_PAD_LEFT = 6; static final int FOCUS_RING_PAD_RIGHT = 6; static final int FOCUS_RING_PAD_BOTTOM = 5; @@ -154,9 +165,15 @@ class AquaComboBoxPopup extends BasicComboPopup { protected JList createList() { return new JList(comboBox.getModel()) { @Override + @SuppressWarnings("deprecation") public void processMouseEvent(MouseEvent e) { if (e.isMetaDown()) { - e = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ InputEvent.META_MASK, e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); + e = new MouseEvent((Component) e.getSource(), e.getID(), + e.getWhen(), + e.getModifiers() ^ InputEvent.META_MASK, + e.getX(), e.getY(), e.getXOnScreen(), + e.getYOnScreen(), e.getClickCount(), + e.isPopupTrigger(), MouseEvent.NOBUTTON); } super.processMouseEvent(e); } @@ -195,9 +212,6 @@ class AquaComboBoxPopup extends BasicComboPopup { //System.err.println("GetBestScreenBounds p: "+ p.x + ", " + p.y); final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] gs = ge.getScreenDevices(); - //System.err.println(" gs.length = " + gs.length); - final Rectangle comboBoxBounds = comboBox.getBounds(); - for (final GraphicsDevice gd : gs) { final GraphicsConfiguration[] gc = gd.getConfigurations(); for (final GraphicsConfiguration element0 : gc) { @@ -209,15 +223,14 @@ class AquaComboBoxPopup extends BasicComboPopup { } // Hmm. Origin's off screen, but is any part on? + final Rectangle comboBoxBounds = comboBox.getBounds(); comboBoxBounds.setLocation(p); for (final GraphicsDevice gd : gs) { final GraphicsConfiguration[] gc = gd.getConfigurations(); for (final GraphicsConfiguration element0 : gc) { final Rectangle gcBounds = element0.getBounds(); if (gcBounds.intersects(comboBoxBounds)) { - if (gcBounds.contains(p)) { - return getAvailableScreenArea(gcBounds, element0); - } + return getAvailableScreenArea(gcBounds, element0); } } } @@ -228,8 +241,15 @@ class AquaComboBoxPopup extends BasicComboPopup { private Rectangle getAvailableScreenArea(Rectangle bounds, GraphicsConfiguration gc) { Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); - return new Rectangle(0, insets.top, bounds.width, - bounds.height - insets.top); + return new Rectangle(bounds.x + insets.left, bounds.y + insets.top, + bounds.width - insets.left - insets.right, + bounds.height - insets.top - insets.bottom); + } + + private int getComboBoxEdge(int py, boolean bottom) { + int offset = bottom ? 9 : -9; + // if py is less than new y we have a clipped combo, so leave it alone. + return Math.min((py / 2) + offset, py); } @Override @@ -240,7 +260,7 @@ class AquaComboBoxPopup extends BasicComboPopup { if (isPopdown && !isTableCellEditor) { // place the popup just below the button, which is // near the center of a large combo box - py = Math.min((py / 2) + 9, py); // if py is less than new y we have a clipped combo, so leave it alone. + py = getComboBoxEdge(py, true); } // px & py are relative to the combo box @@ -285,8 +305,12 @@ class AquaComboBoxPopup extends BasicComboPopup { // Make sure it's all on the screen - shift it by the amount it's off p.x += px; p.y += py; // Screen location of px & py - if (p.x < scrBounds.x) px -= (p.x + scrBounds.x); - if (p.y < scrBounds.y) py -= (p.y + scrBounds.y); + if (p.x < scrBounds.x) { + px = px + (scrBounds.x - p.x); + } + if (p.y < scrBounds.y) { + py = py + (scrBounds.y - p.y); + } final Point top = new Point(0, 0); SwingUtilities.convertPointFromScreen(top, comboBox); @@ -318,22 +342,27 @@ class AquaComboBoxPopup extends BasicComboPopup { } final Rectangle r = new Rectangle(px, py, pw, ph); - if (py + ph > scrBounds.y + scrBounds.height) { - if (ph <= -scrBounds.y ) { - // popup goes above - r.y = -ph ; - } else { - // a full screen height popup - r.y = scrBounds.y + Math.max(0, (scrBounds.height - ph) / 2 ); - r.height = Math.min(scrBounds.height, ph); - } + if (r.y + r.height < top.y + scrBounds.y + scrBounds.height) { + return r; + } + // Check whether it goes below the bottom of the screen, if so flip it + int newY = getComboBoxEdge(comboBoxBounds.height, false) - ph - comboBoxInsets.top; + if (newY > top.y + scrBounds.y) { + return new Rectangle(px, newY, r.width, r.height); + } else { + // There are no place at top, move popup to the center of the screen + r.y = top.y + scrBounds.y + Math.max(0, (scrBounds.height - ph) / 2 ); + r.height = Math.min(scrBounds.height, ph); } return r; } // The one to use when itemCount <= maxRowCount. Size never adjusts for arrows // We want it positioned so the selected item is right above the combo box - protected Rectangle computePopupBoundsForMenu(final int px, final int py, final int pw, final int ph, final int itemCount, final Rectangle scrBounds) { + protected Rectangle computePopupBoundsForMenu(final int px, final int py, + final int pw, final int ph, + final int itemCount, + final Rectangle scrBounds) { //System.err.println("computePopupBoundsForMenu: " + px + "," + py + " " + pw + "," + ph); //System.err.println("itemCount: " +itemCount +" src: "+ scrBounds); int elementSize = 0; //kDefaultItemSize; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java index 3cc7b55f871..e501b122727 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java @@ -594,7 +594,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { } @SuppressWarnings("unchecked") - static final RecyclableSingleton, AquaComboBoxUI>> APPLICATOR = new + private static final RecyclableSingleton, AquaComboBoxUI>> APPLICATOR = new RecyclableSingleton, AquaComboBoxUI>>() { @Override protected ClientPropertyApplicator, AquaComboBoxUI> getInstance() { diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java index b69d2d09e7c..6e0aa18ac49 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java @@ -75,7 +75,7 @@ class AquaFileView extends FileView { private static native int getNativeLSInfo(final byte[] pathBytes, final boolean isDirectory); private static native String getNativePathForResolvedAlias(final byte[] absolutePath, final boolean isDirectory); - static final RecyclableSingleton machineName = new RecyclableSingleton() { + private static final RecyclableSingleton machineName = new RecyclableSingleton() { @Override protected String getInstance() { return getNativeMachineName(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java index 2916eb15ebd..59a437d4aaf 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java @@ -35,17 +35,17 @@ import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public abstract class AquaGroupBorder extends AquaBorder { - static final RecyclableSingletonFromDefaultConstructor tabbedPaneGroupBorder = new RecyclableSingletonFromDefaultConstructor(TabbedPane.class); + private static final RecyclableSingletonFromDefaultConstructor tabbedPaneGroupBorder = new RecyclableSingletonFromDefaultConstructor(TabbedPane.class); public static Border getTabbedPaneGroupBorder() { return tabbedPaneGroupBorder.get(); } - static final RecyclableSingletonFromDefaultConstructor titleBorderGroupBorder = new RecyclableSingletonFromDefaultConstructor(Titled.class); + private static final RecyclableSingletonFromDefaultConstructor titleBorderGroupBorder = new RecyclableSingletonFromDefaultConstructor(Titled.class); public static Border getBorderForTitledBorder() { return titleBorderGroupBorder.get(); } - static final RecyclableSingletonFromDefaultConstructor titlelessGroupBorder = new RecyclableSingletonFromDefaultConstructor(Titleless.class); + private static final RecyclableSingletonFromDefaultConstructor titlelessGroupBorder = new RecyclableSingletonFromDefaultConstructor(Titleless.class); public static Border getTitlelessBorder() { return titlelessGroupBorder.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java index 9f4f81f7458..7b1a1c8d507 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaHighlighter.java @@ -37,7 +37,7 @@ import javax.swing.text.*; import com.apple.laf.AquaUtils.RecyclableSingleton; public class AquaHighlighter extends DefaultHighlighter implements UIResource { - static final RecyclableSingleton instance = new RecyclableSingleton() { + private static final RecyclableSingleton instance = new RecyclableSingleton() { protected LayerPainter getInstance() { return new AquaHighlightPainter(null); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java index 5d43a41e502..1970bc776ae 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java @@ -240,14 +240,14 @@ public class AquaImageFactory { } } - protected static final NamedImageSingleton northArrow = new NamedImageSingleton("NSMenuScrollUp"); - protected static final IconUIResourceSingleton northArrowIcon = new IconUIResourceSingleton(northArrow); - protected static final NamedImageSingleton southArrow = new NamedImageSingleton("NSMenuScrollDown"); - protected static final IconUIResourceSingleton southArrowIcon = new IconUIResourceSingleton(southArrow); - protected static final NamedImageSingleton westArrow = new NamedImageSingleton("NSMenuSubmenuLeft"); - protected static final IconUIResourceSingleton westArrowIcon = new IconUIResourceSingleton(westArrow); - protected static final NamedImageSingleton eastArrow = new NamedImageSingleton("NSMenuSubmenu"); - protected static final IconUIResourceSingleton eastArrowIcon = new IconUIResourceSingleton(eastArrow); + private static final NamedImageSingleton northArrow = new NamedImageSingleton("NSMenuScrollUp"); + private static final IconUIResourceSingleton northArrowIcon = new IconUIResourceSingleton(northArrow); + private static final NamedImageSingleton southArrow = new NamedImageSingleton("NSMenuScrollDown"); + private static final IconUIResourceSingleton southArrowIcon = new IconUIResourceSingleton(southArrow); + private static final NamedImageSingleton westArrow = new NamedImageSingleton("NSMenuSubmenuLeft"); + private static final IconUIResourceSingleton westArrowIcon = new IconUIResourceSingleton(westArrow); + private static final NamedImageSingleton eastArrow = new NamedImageSingleton("NSMenuSubmenu"); + private static final IconUIResourceSingleton eastArrowIcon = new IconUIResourceSingleton(eastArrow); static Image getArrowImageForDirection(final int direction) { switch(direction) { diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java index 4a72d0fd371..58fc7da278f 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java @@ -55,7 +55,7 @@ public class AquaInternalFrameBorder implements Border, UIResource { private static final int kContentTester = 100; // For getting region insets - static final RecyclableSingleton documentWindowFrame = new RecyclableSingleton() { + private static final RecyclableSingleton documentWindowFrame = new RecyclableSingleton() { protected AquaInternalFrameBorder getInstance() { return new AquaInternalFrameBorder(WindowType.DOCUMENT); } @@ -64,7 +64,7 @@ public class AquaInternalFrameBorder implements Border, UIResource { return documentWindowFrame.get(); } - static final RecyclableSingleton utilityWindowFrame = new RecyclableSingleton() { + private static final RecyclableSingleton utilityWindowFrame = new RecyclableSingleton() { protected AquaInternalFrameBorder getInstance() { return new AquaInternalFrameBorder(WindowType.UTILITY); } @@ -73,7 +73,7 @@ public class AquaInternalFrameBorder implements Border, UIResource { return utilityWindowFrame.get(); } - static final RecyclableSingleton dialogWindowFrame = new RecyclableSingleton() { + private static final RecyclableSingleton dialogWindowFrame = new RecyclableSingleton() { protected AquaInternalFrameBorder getInstance() { return new AquaInternalFrameBorder(WindowType.DOCUMENT); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java index af2aaf05ed6..3a40c49ae3f 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java @@ -137,6 +137,7 @@ public final class AquaInternalFrameDockIconUI extends DesktopIconUI } @Override + @SuppressWarnings("deprecation") public void mouseEntered(final MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) return; String title = fFrame.getTitle(); @@ -146,6 +147,7 @@ public final class AquaInternalFrameDockIconUI extends DesktopIconUI } @Override + @SuppressWarnings("deprecation") public void mouseExited(final MouseEvent e) { if (fDockLabel != null && (e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) fDockLabel.hide(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java index fd6bccf2260..4b09210e9e4 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java @@ -147,7 +147,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo southPane = c; } - static final RecyclableSingleton closeIcon = new RecyclableSingleton() { + private static final RecyclableSingleton closeIcon = new RecyclableSingleton() { @Override protected Icon getInstance() { return new AquaInternalFrameButtonIcon(Widget.TITLE_BAR_CLOSE_BOX); @@ -157,7 +157,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo return closeIcon.get(); } - static final RecyclableSingleton minimizeIcon = new RecyclableSingleton() { + private static final RecyclableSingleton minimizeIcon = new RecyclableSingleton() { @Override protected Icon getInstance() { return new AquaInternalFrameButtonIcon(Widget.TITLE_BAR_COLLAPSE_BOX); @@ -167,7 +167,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo return minimizeIcon.get(); } - static final RecyclableSingleton zoomIcon = new RecyclableSingleton() { + private static final RecyclableSingleton zoomIcon = new RecyclableSingleton() { @Override protected Icon getInstance() { return new AquaInternalFrameButtonIcon(Widget.TITLE_BAR_ZOOM_BOX); @@ -555,6 +555,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo } @Override + @SuppressWarnings("deprecation") public void mouseDragged(final MouseEvent e) { // do not forward drags // if (didForwardEvent(e)) return; @@ -621,7 +622,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo return didForwardEvent; } - + @SuppressWarnings("deprecation") boolean didForwardEventInternal(final MouseEvent e) { if (fDraggingFrame) return false; @@ -737,7 +738,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo } } // end class PaletteListener - static final InternalFrameShadow documentWindowShadow = new InternalFrameShadow() { + private static final InternalFrameShadow documentWindowShadow = new InternalFrameShadow() { @Override Border getForegroundShadowBorder() { return new AquaUtils.SlicedShadowBorder(new Painter() { @@ -777,7 +778,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo } }; - static final InternalFrameShadow paletteWindowShadow = new InternalFrameShadow() { + private static final InternalFrameShadow paletteWindowShadow = new InternalFrameShadow() { @Override Border getForegroundShadowBorder() { return new AquaUtils.SlicedShadowBorder(new Painter() { @@ -833,7 +834,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo } } - static final RecyclableSingleton RESIZE_ICON = new RecyclableSingleton() { + private static final RecyclableSingleton RESIZE_ICON = new RecyclableSingleton() { @Override protected Icon getInstance() { return new AquaIcon.ScalingJRSUIIcon(11, 11) { @@ -927,11 +928,15 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo return (w - x) + (h - y) < 12; } + @SuppressWarnings("deprecation") void forwardEventToFrame(final MouseEvent e) { final Point pt = new Point(); final Component c = getComponentToForwardTo(e, pt); if (c == null) return; - c.dispatchEvent(new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiers(), pt.x, pt.y, e.getClickCount(), e.isPopupTrigger(), e.getButton())); + c.dispatchEvent( + new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiers(), + pt.x, pt.y, e.getClickCount(), + e.isPopupTrigger(), e.getButton())); } Component getComponentToForwardTo(final MouseEvent e, final Point dst) { @@ -993,6 +998,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo public void mouseMoved(final MouseEvent e) { } @Override + @SuppressWarnings("deprecation") public void mouseWheelMoved(final MouseWheelEvent e) { final Point pt = new Point(); final Component c = getComponentToForwardTo(e, pt); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java index d6395accd00..cb32bfc7978 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java @@ -37,7 +37,7 @@ import com.apple.laf.AquaUtils.RecyclableSingleton; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public class AquaKeyBindings { - static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaKeyBindings.class); + private static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaKeyBindings.class); static AquaKeyBindings instance() { return instance.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java index bb24f60a6a7..fb5682d0541 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java @@ -37,7 +37,7 @@ import com.apple.laf.AquaUtils.RecyclableSingleton; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public class AquaLabelUI extends BasicLabelUI { - protected static final RecyclableSingleton aquaLabelUI = new RecyclableSingletonFromDefaultConstructor(AquaLabelUI.class); + private static final RecyclableSingleton aquaLabelUI = new RecyclableSingletonFromDefaultConstructor(AquaLabelUI.class); public static ComponentUI createUI(final JComponent c) { return aquaLabelUI.get(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java index 7aaf0893e71..affb99b766c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.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 @@ -50,7 +50,7 @@ public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvid public void uninstallUI(final JComponent c) { if (fScreenMenuBar != null) { final JFrame frame = (JFrame)(c.getTopLevelAncestor()); - if (frame.getMenuBar() == fScreenMenuBar) { + if (frame != null && frame.getMenuBar() == fScreenMenuBar) { frame.setMenuBar((MenuBar)null); } fScreenMenuBar = null; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java index 53feb4184be..69c22af8eb4 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuPainter.java @@ -74,7 +74,10 @@ public class AquaMenuPainter { kUCapsLockGlyph = 0x21EA; static final int ALT_GRAPH_MASK = 1 << 5; // New to Java2 - static final int sUnsupportedModifiersMask = ~(InputEvent.CTRL_MASK | InputEvent.ALT_MASK | InputEvent.SHIFT_MASK | InputEvent.META_MASK | ALT_GRAPH_MASK); + @SuppressWarnings("deprecation") + static final int sUnsupportedModifiersMask = + ~(InputEvent.CTRL_MASK | InputEvent.ALT_MASK | InputEvent.SHIFT_MASK + | InputEvent.META_MASK | ALT_GRAPH_MASK); interface Client { public void paintBackground(Graphics g, JComponent c, int menuWidth, int menuHeight); @@ -86,6 +89,7 @@ public class AquaMenuPainter { } // Return a string with the proper modifier glyphs + @SuppressWarnings("deprecation") private static String getKeyModifiersUnicode(final int modifiers, final boolean isLeftToRight) { final StringBuilder buf = new StringBuilder(2); // Order (from StandardMenuDef.c): control, option(alt), shift, cmd @@ -121,7 +125,7 @@ public class AquaMenuPainter { return buf.toString(); } - static final RecyclableSingleton sPainter = new RecyclableSingletonFromDefaultConstructor(AquaMenuPainter.class); + private static final RecyclableSingleton sPainter = new RecyclableSingletonFromDefaultConstructor(AquaMenuPainter.class); static AquaMenuPainter instance() { return sPainter.get(); } @@ -135,9 +139,9 @@ public class AquaMenuPainter { protected Border getInstance() { return UIManager.getBorder(borderName); } } - protected final RecyclableBorder menuBarPainter = new RecyclableBorder("MenuBar.backgroundPainter"); - protected final RecyclableBorder selectedMenuBarItemPainter = new RecyclableBorder("MenuBar.selectedBackgroundPainter"); - protected final RecyclableBorder selectedMenuItemPainter = new RecyclableBorder("MenuItem.selectedBackgroundPainter"); + private static final RecyclableBorder menuBarPainter = new RecyclableBorder("MenuBar.backgroundPainter"); + private static final RecyclableBorder selectedMenuBarItemPainter = new RecyclableBorder("MenuBar.selectedBackgroundPainter"); + private static final RecyclableBorder selectedMenuItemPainter = new RecyclableBorder("MenuItem.selectedBackgroundPainter"); public void paintMenuBarBackground(final Graphics g, final int width, final int height, final JComponent c) { g.setColor(c == null ? Color.white : c.getBackground()); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMnemonicHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMnemonicHandler.java index be5ab659c01..76c97358828 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMnemonicHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMnemonicHandler.java @@ -34,7 +34,7 @@ import com.apple.laf.AquaUtils.RecyclableSingleton; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public class AquaMnemonicHandler { - static final RecyclableSingleton altProcessor = new RecyclableSingletonFromDefaultConstructor(AltProcessor.class); + private static final RecyclableSingleton altProcessor = new RecyclableSingletonFromDefaultConstructor(AltProcessor.class); public static KeyEventPostProcessor getInstance() { return altProcessor.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java index 48c69422f26..1aa700dcf5c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java @@ -54,7 +54,7 @@ public class AquaNativeResources { } } - static final RecyclableSingleton sBackgroundColor = new RecyclableSingleton() { + private static final RecyclableSingleton sBackgroundColor = new RecyclableSingleton() { @Override protected Color getInstance() { final long backgroundID = getWindowBackgroundColor(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java index f03a7f949be..b6509ef3254 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPanelUI.java @@ -35,7 +35,7 @@ import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; import java.awt.Graphics; public class AquaPanelUI extends BasicPanelUI { - static RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaPanelUI.class); + private static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaPanelUI.class); public static ComponentUI createUI(final JComponent c) { return instance.get(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java index be4a06f5c78..64291c1f8b1 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaPopupMenuSeparatorUI.java @@ -34,7 +34,7 @@ import javax.swing.plaf.basic.BasicSeparatorUI; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public class AquaPopupMenuSeparatorUI extends BasicSeparatorUI { - protected static RecyclableSingletonFromDefaultConstructor instance = new RecyclableSingletonFromDefaultConstructor(AquaPopupMenuSeparatorUI.class); + private static final RecyclableSingletonFromDefaultConstructor instance = new RecyclableSingletonFromDefaultConstructor(AquaPopupMenuSeparatorUI.class); public static ComponentUI createUI(final JComponent c) { return instance.get(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java index 1745c910b9c..bf66a1b4b08 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaProgressBarUI.java @@ -46,7 +46,7 @@ import com.apple.laf.AquaUtils.RecyclableSingleton; public class AquaProgressBarUI extends ProgressBarUI implements ChangeListener, PropertyChangeListener, AncestorListener, Sizeable { private static final boolean ADJUSTTIMER = true; - protected static final RecyclableSingleton sizeDescriptor = new RecyclableSingleton() { + private static final RecyclableSingleton sizeDescriptor = new RecyclableSingleton() { @Override protected SizeDescriptor getInstance() { return new SizeDescriptor(new SizeVariant(146, 20)) { diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java index 92e342325ad..9d87013c48e 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollBarUI.java @@ -154,7 +154,7 @@ public class AquaScrollBarUI extends ScrollBarUI { return State.ACTIVE; } - static final RecyclableSingleton> hitToPressedPartMap = new RecyclableSingleton>(){ + private static final RecyclableSingleton> hitToPressedPartMap = new RecyclableSingleton>(){ @Override protected Map getInstance() { final Map map = new HashMap(7); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java index 596506f6a90..d09aa654b5c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaScrollRegionBorder.java @@ -40,7 +40,7 @@ import com.apple.laf.AquaUtilControlSize.SizeVariant; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public class AquaScrollRegionBorder extends AquaBorder { - static final RecyclableSingletonFromDefaultConstructor instance = new RecyclableSingletonFromDefaultConstructor(AquaScrollRegionBorder.class); + private static final RecyclableSingletonFromDefaultConstructor instance = new RecyclableSingletonFromDefaultConstructor(AquaScrollRegionBorder.class); public static AquaScrollRegionBorder getScrollRegionBorder() { return instance.get(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java index 65ed9d7b8c1..3775fc859e4 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaSliderUI.java @@ -45,7 +45,7 @@ public class AquaSliderUI extends BasicSliderUI implements Sizeable { // static final Dimension roundThumbSize = new Dimension(21 + 4, 21 + 4); // +2px on both sides for focus fuzz // static final Dimension pointingThumbSize = new Dimension(19 + 4, 22 + 4); - protected static final RecyclableSingleton roundThumbDescriptor = new RecyclableSingleton() { + private static final RecyclableSingleton roundThumbDescriptor = new RecyclableSingleton() { protected SizeDescriptor getInstance() { return new SizeDescriptor(new SizeVariant(25, 25)) { public SizeVariant deriveSmall(final SizeVariant v) { @@ -57,7 +57,7 @@ public class AquaSliderUI extends BasicSliderUI implements Sizeable { }; } }; - protected static final RecyclableSingleton pointingThumbDescriptor = new RecyclableSingleton() { + private static final RecyclableSingleton pointingThumbDescriptor = new RecyclableSingleton() { protected SizeDescriptor getInstance() { return new SizeDescriptor(new SizeVariant(23, 26)) { public SizeVariant deriveSmall(final SizeVariant v) { diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java index ad78bc26ca3..798df58442c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.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 @@ -515,6 +515,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing /** * Adds the specified mnemonic at the specified index. */ + @SuppressWarnings("deprecation") private void addMnemonic(final int index, final int mnemonic) { if (mnemonicToIndexMap == null) { initMnemonics(); @@ -3731,7 +3732,6 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing *

              * This should be used if the ActionMap can be shared. * - * @param c JComponent to install the ActionMap on. * @param loaderClass Class object that gets loadActionMap invoked * on. * @param defaultsKey Key to use to defaults table to check for diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java index 17f412b8d42..68aafa5119e 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java @@ -126,7 +126,7 @@ public class AquaTableHeaderBorder extends AbstractBorder { return State.ACTIVE; } - static final RecyclableSingleton alternateBorder = new RecyclableSingleton() { + private static final RecyclableSingleton alternateBorder = new RecyclableSingleton() { @Override protected Border getInstance() { return BorderFactory.createRaisedBevelBorder(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java index 35b87aac27e..85577ce46ca 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderUI.java @@ -67,7 +67,7 @@ public class AquaTableHeaderUI extends BasicTableHeaderUI { super.uninstallDefaults(); } - static final RecyclableSingleton> TABLE_HEADER_APPLICATORS = new RecyclableSingleton>() { + private static final RecyclableSingleton> TABLE_HEADER_APPLICATORS = new RecyclableSingleton>() { @Override @SuppressWarnings("unchecked") protected ClientPropertyApplicator getInstance() { diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java index 6f161b70469..29191725d20 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldBorder.java @@ -36,7 +36,7 @@ import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.*; public class AquaTextFieldBorder extends AquaBorder { - protected static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaTextFieldBorder.class); + private static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaTextFieldBorder.class); public static AquaTextFieldBorder getTextFieldBorder() { return instance.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java index 4117d895f6e..ba7ea8de064 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextFieldSearch.java @@ -90,7 +90,7 @@ public class AquaTextFieldSearch { return (c.getClientProperty(FIND_POPUP_KEY) instanceof JPopupMenu); } - protected static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(SearchFieldBorder.class); + private static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(SearchFieldBorder.class); public static SearchFieldBorder getSearchTextFieldBorder() { return instance.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java index 82f32a50287..0cdcc9c8006 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTextPasswordFieldUI.java @@ -38,7 +38,7 @@ import com.apple.laf.AquaUtils.RecyclableSingleton; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public class AquaTextPasswordFieldUI extends AquaTextFieldUI { - static final RecyclableSingleton capsLockPainter = new RecyclableSingletonFromDefaultConstructor(CapsLockSymbolPainter.class); + private static final RecyclableSingleton capsLockPainter = new RecyclableSingletonFromDefaultConstructor(CapsLockSymbolPainter.class); static CapsLockSymbolPainter getCapsLockPainter() { return capsLockPainter.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java index a3d7b6ef581..555ea8b33a2 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarSeparatorUI.java @@ -34,7 +34,7 @@ import javax.swing.plaf.basic.BasicToolBarSeparatorUI; import com.apple.laf.AquaUtils.*; public class AquaToolBarSeparatorUI extends BasicToolBarSeparatorUI { - protected static RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaToolBarSeparatorUI.class); + private static final RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaToolBarSeparatorUI.class); public static ComponentUI createUI(final JComponent c) { return instance.get(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java index 05773dd6429..7ea41a4ae35 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolBarUI.java @@ -35,7 +35,7 @@ import javax.swing.plaf.basic.BasicToolBarUI; import com.apple.laf.AquaUtils.*; public class AquaToolBarUI extends BasicToolBarUI implements SwingConstants { - private static RecyclableSingleton toolBarBorder = new RecyclableSingletonFromDefaultConstructor(ToolBarBorder.class); + private static final RecyclableSingleton toolBarBorder = new RecyclableSingletonFromDefaultConstructor(ToolBarBorder.class); public static Border getToolBarBorder() { return toolBarBorder.get(); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java index 9a9f5b31de1..19e9c1cb593 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaToolTipUI.java @@ -34,7 +34,7 @@ import javax.swing.plaf.basic.BasicToolTipUI; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; public class AquaToolTipUI extends BasicToolTipUI { - static final RecyclableSingletonFromDefaultConstructor sharedAquaInstance = new RecyclableSingletonFromDefaultConstructor(AquaToolTipUI.class); + private static final RecyclableSingletonFromDefaultConstructor sharedAquaInstance = new RecyclableSingletonFromDefaultConstructor(AquaToolTipUI.class); public static ComponentUI createUI(final JComponent c) { return sharedAquaInstance.get(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java index 999d24a7886..63ab4383c0e 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java @@ -49,7 +49,7 @@ public class AquaUtilControlSize { void applySizeFor(final JComponent c, final Size size); } - protected static final RecyclableSingleton sizeListener + private static final RecyclableSingleton sizeListener = new RecyclableSingletonFromDefaultConstructor<>(PropertySizeListener.class); protected static PropertySizeListener getSizeListener() { return sizeListener.get(); diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.java index cce93832795..1176a82cfc1 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuPropertyListener.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 @@ -39,7 +39,7 @@ class ScreenMenuPropertyListener implements PropertyChangeListener { /** * This method gets called when a bound property is changed. - * @param evt A PropertyChangeEvent object describing the event source + * @param e A PropertyChangeEvent object describing the event source * and the property that has changed. */ public void propertyChange(final PropertyChangeEvent e) { diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/resources/aqua_de.properties b/jdk/src/java.desktop/macosx/classes/com/apple/laf/resources/aqua_de.properties index b85ed0c8547..83105561c30 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/resources/aqua_de.properties +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/resources/aqua_de.properties @@ -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 @@ -46,7 +46,7 @@ FileChooser.saveButton.textAndMnemonic=Speichern FileChooser.openButton.textAndMnemonic=\u00D6ffnen FileChooser.saveDialogTitle.textAndMnemonic=Speichern FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen -FileChooser.updateButton.textAndMnemonic=Updaten +FileChooser.updateButton.textAndMnemonic=Aktualisieren FileChooser.helpButton.textAndMnemonic=Hilfe FileChooser.directoryOpenButton.textAndMnemonic=\u00D6ffnen diff --git a/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java b/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java index f84397a76fe..ce5ed8b141e 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java +++ b/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.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 @@ -79,6 +79,10 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment { /** Available CoreGraphics displays. */ private final Map devices = new HashMap<>(5); + /** + * The key in the {@link #devices} for the main display. + */ + private int mainDisplayID; /** Reference to the display reconfiguration callback context. */ private final long displayReconfigContext; @@ -120,6 +124,7 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment { } @Override + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { try { super.finalize(); @@ -136,15 +141,15 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment { final Map old = new HashMap<>(devices); devices.clear(); - int mainID = getMainDisplayID(); + mainDisplayID = getMainDisplayID(); // initialization of the graphics device may change // list of displays on hybrid systems via an activation // of discrete video. // So, we initialize the main display first, and then // retrieve actual list of displays. - if (!old.containsKey(mainID)) { - old.put(mainID, new CGraphicsDevice(mainID)); + if (!old.containsKey(mainDisplayID)) { + old.put(mainDisplayID, new CGraphicsDevice(mainDisplayID)); } for (final int id : getDisplayIDs()) { @@ -157,7 +162,6 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment { @Override public synchronized GraphicsDevice getDefaultScreenDevice() throws HeadlessException { - final int mainDisplayID = getMainDisplayID(); CGraphicsDevice d = devices.get(mainDisplayID); if (d == null) { // we do not expect that this may happen, the only response diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CCharToGlyphMapper.java b/jdk/src/java.desktop/macosx/classes/sun/font/CCharToGlyphMapper.java index d2f9a548763..5a2cf766cf6 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CCharToGlyphMapper.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CCharToGlyphMapper.java @@ -75,37 +75,9 @@ public class CCharToGlyphMapper extends CharToGlyphMapper { } } - if (code < 0x0590) { + if (code < FontUtilities.MIN_LAYOUT_CHARCODE) { continue; - } else if (code <= 0x05ff) { - // Hebrew 0x0590->0x05ff - return true; - } else if (code >= 0x0600 && code <= 0x06ff) { - // Arabic - return true; - } else if (code >= 0x0900 && code <= 0x0d7f) { - // if Indic, assume shaping for conjuncts, reordering: - // 0900 - 097F Devanagari - // 0980 - 09FF Bengali - // 0A00 - 0A7F Gurmukhi - // 0A80 - 0AFF Gujarati - // 0B00 - 0B7F Oriya - // 0B80 - 0BFF Tamil - // 0C00 - 0C7F Telugu - // 0C80 - 0CFF Kannada - // 0D00 - 0D7F Malayalam - return true; - } else if (code >= 0x0e00 && code <= 0x0e7f) { - // if Thai, assume shaping for vowel, tone marks - return true; - } else if (code >= 0x200c && code <= 0x200d) { - // zwj or zwnj - return true; - } else if (code >= 0x202a && code <= 0x202e) { - // directional control - return true; - } else if (code >= 0x206a && code <= 0x206f) { - // directional control + } else if (FontUtilities.isComplexCharCode(code)) { return true; } else if (code >= 0x10000) { i += 1; // Empty glyph slot after surrogate diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java index 049dbb58619..15abdda711d 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.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 @@ -211,6 +211,10 @@ public final class CFont extends PhysicalFont implements FontSubstitution { ArrayList listOfString = new ArrayList(); getCascadeList(nativeFontPtr, listOfString); + // add JRE "Lucida Sans Regular" to the cascade list to enable fallback + // to happen to this JRE font in case the intended glyph is missing in + // fonts provided in the CoreText provided cascaded list + listOfString.add("Lucida Sans Regular"); FontManager fm = FontManagerFactory.getInstance(); int numFonts = 1 + listOfString.size(); PhysicalFont[] fonts = new PhysicalFont[numFonts]; @@ -246,6 +250,7 @@ public final class CFont extends PhysicalFont implements FontSubstitution { return compFont; } + @SuppressWarnings("deprecation") protected synchronized void finalize() { if (nativeFontPtr != 0) { disposeNativeFont(nativeFontPtr); diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java index ed3838886c9..7eba9678020 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.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 @@ -127,6 +127,7 @@ public final class CStrike extends PhysicalStrike { return nativeStrikePtr; } + @SuppressWarnings("deprecation") protected synchronized void finalize() throws Throwable { if (nativeStrikePtr != 0) { disposeNativeStrikePtr(nativeStrikePtr); diff --git a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java index 641f95bae04..553cd7183d6 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java @@ -108,7 +108,7 @@ public class CGLLayer extends CFRetainedResource { OGLRenderQueue rq = OGLRenderQueue.getInstance(); rq.lock(); try { - validate(getPointer(), cglsd); + execute(ptr -> validate(ptr, cglsd)); } finally { rq.unlock(); } @@ -124,7 +124,7 @@ public class CGLLayer extends CFRetainedResource { private void setScale(final int _scale) { if (scale != _scale) { scale = _scale; - nativeSetScale(getPointer(), scale); + execute(ptr -> nativeSetScale(ptr, scale)); } } @@ -138,7 +138,7 @@ public class CGLLayer extends CFRetainedResource { OGLRenderQueue rq = OGLRenderQueue.getInstance(); rq.lock(); try { - blitTexture(getPointer()); + execute(ptr -> blitTexture(ptr)); } finally { rq.unlock(); } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java index a024da398b5..e43c4db68a0 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -1224,6 +1224,7 @@ public abstract class LWComponentPeer * Changes the target of the AWTEvent from awt component to appropriate * swing delegate. */ + @SuppressWarnings("deprecation") private AWTEvent createDelegateEvent(final AWTEvent e) { // TODO modifiers should be changed to getModifiers()|getModifiersEx()? AWTEvent delegateEvent = null; diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWListPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWListPeer.java index e6e1ec38c3d..f9d7db6c862 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWListPeer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWListPeer.java @@ -302,6 +302,7 @@ final class LWListPeer extends LWComponentPeer } @Override + @SuppressWarnings("deprecation") protected void processMouseEvent(final MouseEvent e) { super.processMouseEvent(e); if (e.getID() == MouseEvent.MOUSE_CLICKED && e.getClickCount() == 2) { @@ -314,6 +315,7 @@ final class LWListPeer extends LWComponentPeer } @Override + @SuppressWarnings("deprecation") protected void processKeyEvent(final KeyEvent e) { super.processKeyEvent(e); if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ENTER) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java index daa02981c27..a6eec6eec3b 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java @@ -358,13 +358,6 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { // ---- NON-COMPONENT PEERS ---- // - @Override - public final ColorModel getColorModel() throws HeadlessException { - return GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice() - .getDefaultConfiguration().getColorModel(); - } - @Override public final boolean isDesktopSupported() { return true; diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java index 6a0f49a92b1..2d3ce3e9a10 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java @@ -93,6 +93,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { InputEvent triggerEvent = trigger.getTriggerEvent(); Point dragOrigin = new Point(trigger.getDragOrigin()); + @SuppressWarnings("deprecation") int extModifiers = (triggerEvent.getModifiers() | triggerEvent.getModifiersEx()); long timestamp = triggerEvent.getWhen(); int clickCount = ((triggerEvent instanceof MouseEvent) ? (((MouseEvent) triggerEvent).getClickCount()) : 1); 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 f69ad201ef8..de0553501e6 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 @@ -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 @@ -25,6 +25,10 @@ package sun.lwawt.macosx; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + /** * Safely holds and disposes of native AppKit resources, using the * correct AppKit threading and Objective-C GC semantics. @@ -36,6 +40,10 @@ public class CFRetainedResource { // TODO this pointer should be private and accessed via CFNativeAction class protected volatile long ptr; + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + private final Lock writeLock = lock.writeLock(); + private final Lock readLock = lock.readLock(); + /** * @param ptr CFRetained native object pointer * @param disposeOnAppKitThread is the object needs to be CFReleased on the main thread @@ -50,21 +58,31 @@ public class CFRetainedResource { * @param ptr CFRetained native object pointer */ protected void setPtr(final long ptr) { - synchronized (this) { - if (this.ptr != 0) dispose(); + writeLock.lock(); + try { + if (this.ptr != 0) { + dispose(); + } this.ptr = ptr; + } finally { + writeLock.unlock(); } } /** - * Manually CFReleases the native resource + * Manually CFReleases the native resource. */ protected void dispose() { long oldPtr = 0L; - synchronized (this) { - if (ptr == 0) return; + writeLock.lock(); + try { + if (ptr == 0) { + return; + } oldPtr = ptr; ptr = 0; + } finally { + writeLock.unlock(); } nativeCFRelease(oldPtr, disposeOnAppKitThread); // perform outside of the synchronized block @@ -109,9 +127,14 @@ public class CFRetainedResource { * * @param action The native operation */ - public final synchronized void execute(final CFNativeAction action) { - if (ptr != 0) { - action.run(ptr); + public final void execute(final CFNativeAction action) { + readLock.lock(); + try { + if (ptr != 0) { + action.run(ptr); + } + } finally { + readLock.unlock(); } } @@ -127,14 +150,20 @@ public class CFRetainedResource { * @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); + final long executeGet(final CFNativeActionGet action) { + readLock.lock(); + try { + if (ptr != 0) { + return action.run(ptr); + } + } finally { + readLock.unlock(); } return 0; } @Override + @SuppressWarnings("deprecation") protected final void finalize() throws Throwable { dispose(); } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java index 61f41a2c70f..8985d631ccb 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.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 @@ -32,6 +32,8 @@ import java.awt.image.*; import java.util.Arrays; import java.util.List; import java.awt.image.MultiResolutionImage; +import java.util.concurrent.atomic.AtomicReference; + import sun.awt.image.MultiResolutionCachedImage; import sun.awt.image.SunWritableRaster; @@ -254,15 +256,26 @@ public class CImage extends CFRetainedResource { /** @return A MultiResolution image created from nsImagePtr, or null. */ private Image toImage() { - if (ptr == 0) return null; + if (ptr == 0) { + return null; + } - final Dimension2D size = nativeGetNSImageSize(ptr); + AtomicReference sizeRef = new AtomicReference<>(); + execute(ptr -> { + sizeRef.set(nativeGetNSImageSize(ptr)); + }); + final Dimension2D size = sizeRef.get(); + if (size == null) { + return null; + } final int w = (int)size.getWidth(); final int h = (int)size.getHeight(); - - Dimension2D[] sizes - = nativeGetNSImageRepresentationSizes(ptr, - size.getWidth(), size.getHeight()); + AtomicReference repRef = new AtomicReference<>(); + execute(ptr -> { + repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(), + size.getHeight())); + }); + Dimension2D[] sizes = repRef.get(); return sizes == null || sizes.length < 2 ? new MultiResolutionCachedImage(w, h, (width, height) @@ -275,18 +288,18 @@ public class CImage extends CFRetainedResource { final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE); final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer(); final int[] buffer = SunWritableRaster.stealData(dbi, 0); - nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight); + execute(ptr->nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight)); SunWritableRaster.markDirty(dbi); return bimg; } /** If nsImagePtr != 0 then scale this NSImage. @return *this* */ CImage resize(final double w, final double h) { - if (ptr != 0) nativeSetNSImageSize(ptr, w, h); + execute(ptr -> nativeSetNSImageSize(ptr, w, h)); return this; } void resizeRepresentations(double w, double h) { - if (ptr != 0) nativeResizeNSImageRepresentations(ptr, w, h); + execute(ptr -> nativeResizeNSImageRepresentations(ptr, w, h)); } } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java index 3deba1e33f9..891972ff130 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.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 @@ -57,15 +57,19 @@ public class CInputMethodDescriptor implements InputMethodDescriptor { } static Object[] getAvailableLocalesInternal() { - List workList = nativeGetAvailableLocales(); + List workList = nativeGetAvailableLocales(); + Locale currentLocale = CInputMethod.getNativeLocale(); - if (workList != null) { + if (workList == null || workList.isEmpty()) { + return new Object[] { + currentLocale != null ? currentLocale : Locale.getDefault() + }; + } else { + if (currentLocale != null && !workList.contains(currentLocale)) { + workList.add(currentLocale); + } return workList.toArray(); } - - return new Object[] { - Locale.getDefault() - }; } /** @@ -119,5 +123,5 @@ public class CInputMethodDescriptor implements InputMethodDescriptor { } private static native void nativeInit(); - private static native List nativeGetAvailableLocales(); + private static native List nativeGetAvailableLocales(); } 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 0230c4e842f..f7cd2ceba74 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 @@ -63,7 +63,7 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { CMenuComponent parent = (CMenuComponent)LWToolkit.targetToPeer(getTarget().getParent()); return parent.executeGet(ptr->nativeCreate(ptr, isSeparator())); } - + @SuppressWarnings("deprecation") public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { @@ -113,7 +113,13 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer { */ public final void setImage(final java.awt.Image img) { CImage cimg = CImage.getCreator().createFromImage(img); - execute(ptr -> nativeSetImage(ptr, cimg == null ? 0L : cimg.ptr)); + execute(ptr -> { + if (cimg == null) { + nativeSetImage(ptr, 0L); + } else { + cimg.execute(imgPtr -> nativeSetImage(ptr, imgPtr)); + } + }); } /** diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java index 65a4392ca9f..a98b5529845 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformComponent.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 @@ -44,6 +44,9 @@ class CPlatformComponent extends CFRetainedResource super(0, true); } + /** + * Used by JAWT. + */ public long getPointer() { return ptr; } @@ -61,7 +64,7 @@ class CPlatformComponent extends CFRetainedResource // translates values from the coordinate system of the top-level window // to the coordinate system of the content view final Insets insets = platformWindow.getPeer().getInsets(); - nativeSetBounds(getPointer(), x - insets.left, y - insets.top, w, h); + execute(ptr->nativeSetBounds(ptr, x - insets.left, y - insets.top, w, h)); } @Override diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java index 1f42ab9de68..2c2593fd73c 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java @@ -106,11 +106,6 @@ public class CPlatformLWWindow extends CPlatformWindow { public void updateIconImages() { } - @Override - public long getNSWindowPtr() { - return 0; - } - @Override public SurfaceData getSurfaceData() { return null; diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java index de99473a176..c0172f60ff0 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java @@ -265,9 +265,8 @@ final class CPlatformResponder { static class DeltaAccumulator { - static final double MIN_THRESHOLD = 0.1; - static final double MAX_THRESHOLD = 0.5; double accumulatedDelta; + boolean accumulate; int getRoundedDelta(double delta, int scrollPhase) { @@ -278,25 +277,23 @@ final class CPlatformResponder { roundDelta = delta > 0 ? 1 : -1; } } else { // trackpad - boolean begin = scrollPhase == NSEvent.SCROLL_PHASE_BEGAN; - boolean end = scrollPhase == NSEvent.SCROLL_MASK_PHASE_ENDED - || scrollPhase == NSEvent.SCROLL_MASK_PHASE_CANCELLED; - - if (begin) { + if (scrollPhase == NSEvent.SCROLL_PHASE_BEGAN) { accumulatedDelta = 0; + accumulate = true; } + else if (scrollPhase == NSEvent.SCROLL_PHASE_MOMENTUM_BEGAN) { + accumulate = true; + } + if (accumulate) { - accumulatedDelta += delta; + accumulatedDelta += delta; - double absAccumulatedDelta = Math.abs(accumulatedDelta); - if (absAccumulatedDelta > MAX_THRESHOLD) { roundDelta = (int) Math.round(accumulatedDelta); - accumulatedDelta -= roundDelta; - } - if (end) { - if (roundDelta == 0 && absAccumulatedDelta > MIN_THRESHOLD) { - roundDelta = accumulatedDelta > 0 ? 1 : -1; + accumulatedDelta -= roundDelta; + + if (scrollPhase == NSEvent.SCROLL_PHASE_ENDED) { + accumulate = false; } } } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java index 5dcf376646a..f6e1c14c937 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.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 @@ -27,6 +27,9 @@ package sun.lwawt.macosx; import java.awt.*; import java.awt.geom.Rectangle2D; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsEnvironment; @@ -83,7 +86,7 @@ public class CPlatformView extends CFRetainedResource { * Cocoa coordinates). */ public void setBounds(int x, int y, int width, int height) { - CWrapper.NSView.setFrame(ptr, x, y, width, height); + execute(ptr->CWrapper.NSView.setFrame(ptr, x, y, width, height)); } // REMIND: CGLSurfaceData expects top-level's size @@ -96,7 +99,7 @@ public class CPlatformView extends CFRetainedResource { } public void setToolTip(String msg) { - CWrapper.NSView.setToolTip(ptr, msg); + execute(ptr -> CWrapper.NSView.setToolTip(ptr, msg)); } // ---------------------------------------------------------------------- @@ -147,18 +150,25 @@ public class CPlatformView extends CFRetainedResource { } public void setAutoResizable(boolean toResize) { - nativeSetAutoResizable(this.getAWTView(), toResize); + execute(ptr -> nativeSetAutoResizable(ptr, toResize)); } public boolean isUnderMouse() { - return nativeIsViewUnderMouse(getAWTView()); + AtomicBoolean ref = new AtomicBoolean(); + execute(ptr -> { + ref.set(nativeIsViewUnderMouse(ptr)); + }); + return ref.get(); } public GraphicsDevice getGraphicsDevice() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); CGraphicsEnvironment cge = (CGraphicsEnvironment)ge; - int displayID = nativeGetNSViewDisplayID(getAWTView()); - GraphicsDevice gd = cge.getScreenDevice(displayID); + AtomicInteger ref = new AtomicInteger(); + execute(ptr -> { + ref.set(nativeGetNSViewDisplayID(ptr)); + }); + GraphicsDevice gd = cge.getScreenDevice(ref.get()); if (gd == null) { // this could possibly happen during device removal // use the default screen device in this case @@ -168,8 +178,15 @@ public class CPlatformView extends CFRetainedResource { } public Point getLocationOnScreen() { - Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds(); - return new Point(r.x, r.y); + AtomicReference ref = new AtomicReference<>(); + execute(ptr -> { + ref.set(nativeGetLocationOnScreen(ptr).getBounds()); + }); + Rectangle r = ref.get(); + if (r != null) { + return new Point(r.x, r.y); + } + return new Point(0, 0); } // ---------------------------------------------------------------------- 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 102851f3b87..cbb9142d8cd 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 @@ -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 @@ -35,6 +35,9 @@ import java.beans.*; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import javax.swing.*; @@ -201,16 +204,16 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo c.setStyleBits(FULLSCREENABLE, fullscrenable); }}, new Property(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) { - nativeRevalidateNSWindowShadow(c.getNSWindowPtr()); + c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr)); }}, new Property(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) { if (value == null || !(value instanceof java.io.File)) { - nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null); + c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null)); return; } final String filename = ((java.io.File)value).getAbsolutePath(); - nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename); + c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename)); }} }) { @SuppressWarnings("deprecation") @@ -232,6 +235,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo private volatile boolean isInFullScreen; private volatile boolean isIconifyAnimationActive; + private volatile boolean isZoomed; private Window target; private LWWindowPeer peer; @@ -260,7 +264,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo contentView = createContentView(); contentView.initialize(peer, responder); - final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L; Rectangle bounds; if (!IS(DECORATED, styleBits)) { // For undecorated frames the move/resize event does not come if the frame is centered on the screen @@ -269,9 +272,21 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo } else { bounds = _peer.constrainBounds(_target.getBounds()); } - final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), - ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height); - setPtr(nativeWindowPtr); + AtomicLong ref = new AtomicLong(); + contentView.execute(viewPtr -> { + if (owner != null) { + owner.execute(ownerPtr -> { + ref.set(nativeCreateNSWindow(viewPtr, ownerPtr, styleBits, + bounds.x, bounds.y, + bounds.width, bounds.height)); + }); + } else { + ref.set(nativeCreateNSWindow(viewPtr, 0, + styleBits, bounds.x, bounds.y, + bounds.width, bounds.height)); + } + }); + setPtr(ref.get()); if (target instanceof javax.swing.RootPaneContainer) { final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane(); @@ -435,30 +450,31 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // this is the counter-point to -[CWindow _nativeSetStyleBit:] private void setStyleBits(final int mask, final boolean value) { - nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0); + execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0)); } private native void _toggleFullScreenMode(final long model); public void toggleFullScreen() { - _toggleFullScreenMode(getNSWindowPtr()); + execute(this::_toggleFullScreenMode); } @Override // PlatformWindow public void setMenuBar(MenuBar mb) { - final long nsWindowPtr = getNSWindowPtr(); CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb); - if (mbPeer != null) { - mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr)); - } else { - nativeSetNSWindowMenuBar(nsWindowPtr, 0); - } + execute(nsWindowPtr->{ + if (mbPeer != null) { + mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr)); + } else { + nativeSetNSWindowMenuBar(nsWindowPtr, 0); + } + }); } @Override // PlatformWindow public void dispose() { contentView.dispose(); - nativeDispose(getNSWindowPtr()); + execute(CPlatformWindow::nativeDispose); CPlatformWindow.super.dispose(); } @@ -471,7 +487,11 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override // PlatformWindow public Insets getInsets() { - return nativeGetNSWindowInsets(getNSWindowPtr()); + AtomicReference ref = new AtomicReference<>(); + execute(ptr -> { + ref.set(nativeGetNSWindowInsets(ptr)); + }); + return ref.get() != null ? ref.get() : new Insets(0, 0, 0, 0); } @Override // PlatformWindow @@ -497,16 +517,16 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override // PlatformWindow public void setBounds(int x, int y, int w, int h) { - nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h); + execute(ptr -> nativeSetNSWindowBounds(ptr, x, y, w, h)); } public void setMaximizedBounds(int x, int y, int w, int h) { - nativeSetNSWindowStandardFrame(getNSWindowPtr(), x, y, w, h); + execute(ptr -> nativeSetNSWindowStandardFrame(ptr, x, y, w, h)); } private boolean isMaximized() { return undecorated ? this.normalBounds != null - : CWrapper.NSWindow.isZoomed(getNSWindowPtr()); + : isZoomed; } private void maximize() { @@ -514,7 +534,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo return; } if (!undecorated) { - CWrapper.NSWindow.zoom(getNSWindowPtr()); + execute(CWrapper.NSWindow::zoom); } else { deliverZoom(true); @@ -533,7 +553,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo return; } if (!undecorated) { - CWrapper.NSWindow.zoom(getNSWindowPtr()); + execute(CWrapper.NSWindow::zoom); } else { deliverZoom(false); @@ -549,8 +569,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override // PlatformWindow public void setVisible(boolean visible) { - final long nsWindowPtr = getNSWindowPtr(); - // Configure stuff updateIconImages(); updateFocusabilityForAutoRequestFocus(false); @@ -558,7 +576,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo boolean wasMaximized = isMaximized(); if (visible && target.isLocationByPlatform()) { - nativeSetNSWindowLocationByPlatform(getNSWindowPtr()); + execute(CPlatformWindow::nativeSetNSWindowLocationByPlatform); } // Actually show or hide the window @@ -566,30 +584,44 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo if (blocker == null || !visible) { // If it ain't blocked, or is being hidden, go regular way if (visible) { - CWrapper.NSWindow.makeFirstResponder(nsWindowPtr, contentView.getAWTView()); + contentView.execute(viewPtr -> { + execute(ptr -> CWrapper.NSWindow.makeFirstResponder(ptr, + viewPtr)); + }); boolean isPopup = (target.getType() == Window.Type.POPUP); - if (isPopup) { - // Popups in applets don't activate applet's process - CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr); - } else { - CWrapper.NSWindow.orderFront(nsWindowPtr); - } + execute(ptr -> { + if (isPopup) { + // Popups in applets don't activate applet's process + CWrapper.NSWindow.orderFrontRegardless(ptr); + } else { + CWrapper.NSWindow.orderFront(ptr); + } - boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr); - if (!isKeyWindow) { - CWrapper.NSWindow.makeKeyWindow(nsWindowPtr); - } + boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(ptr); + if (!isKeyWindow) { + CWrapper.NSWindow.makeKeyWindow(ptr); + } + }); } else { - // immediately hide the window - CWrapper.NSWindow.orderOut(nsWindowPtr); - // process the close - CWrapper.NSWindow.close(nsWindowPtr); + execute(ptr->{ + // immediately hide the window + CWrapper.NSWindow.orderOut(ptr); + // process the close + CWrapper.NSWindow.close(ptr); + }); } } else { // otherwise, put it in a proper z-order - CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow, - ((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr()); + CPlatformWindow bw + = (CPlatformWindow) blocker.getPlatformWindow(); + bw.execute(blockerPtr -> { + execute(ptr -> { + CWrapper.NSWindow.orderWindow(ptr, + CWrapper.NSWindow.NSWindowBelow, + blockerPtr); + }); + }); } this.visible = visible; @@ -608,7 +640,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo } switch (frameState) { case Frame.ICONIFIED: - CWrapper.NSWindow.miniaturize(nsWindowPtr); + execute(CWrapper.NSWindow::miniaturize); break; case Frame.MAXIMIZED_BOTH: maximize(); @@ -632,7 +664,11 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo if (visible) { // Order myself above my parent if (owner != null && owner.isVisible()) { - CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr()); + owner.execute(ownerPtr -> { + execute(ptr -> { + CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr); + }); + }); applyWindowLevel(target); } @@ -642,7 +678,11 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo if (p instanceof LWWindowPeer) { CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow(); if (pw != null && pw.isVisible()) { - CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove, nsWindowPtr); + pw.execute(childPtr -> { + execute(ptr -> { + CWrapper.NSWindow.orderWindow(childPtr, CWrapper.NSWindow.NSWindowAbove, ptr); + }); + }); pw.applyWindowLevel(w); } } @@ -658,25 +698,22 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override // PlatformWindow public void setTitle(String title) { - nativeSetNSWindowTitle(getNSWindowPtr(), title); + execute(ptr -> nativeSetNSWindowTitle(ptr, title)); } // Should be called on every window key property change. @Override // PlatformWindow public void updateIconImages() { - final long nsWindowPtr = getNSWindowPtr(); final CImage cImage = getImageForTarget(); - nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr); - } - - public long getNSWindowPtr() { - final long nsWindowPtr = ptr; - if (nsWindowPtr == 0L) { - if(logger.isLoggable(PlatformLogger.Level.FINE)) { - logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid.")); + execute(ptr -> { + if (cImage == null) { + nativeSetNSWindowMinimizedIcon(ptr, 0L); + } else { + cImage.execute(imagePtr -> { + nativeSetNSWindowMinimizedIcon(ptr, imagePtr); + }); } - } - return nsWindowPtr; + }); } public SurfaceData getSurfaceData() { @@ -685,13 +722,11 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override // PlatformWindow public void toBack() { - final long nsWindowPtr = getNSWindowPtr(); - nativePushNSWindowToBack(nsWindowPtr); + execute(CPlatformWindow::nativePushNSWindowToBack); } @Override // PlatformWindow public void toFront() { - final long nsWindowPtr = getNSWindowPtr(); LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit(); Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); @@ -701,7 +736,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo lwcToolkit.activateApplicationIgnoringOtherApps(); } updateFocusabilityForAutoRequestFocus(false); - nativePushNSWindowToFront(nsWindowPtr); + execute(CPlatformWindow::nativePushNSWindowToFront); updateFocusabilityForAutoRequestFocus(true); } @@ -728,7 +763,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override public void setSizeConstraints(int minW, int minH, int maxW, int maxH) { - nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH); + execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH)); } @Override @@ -745,19 +780,22 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override public boolean requestWindowFocus() { - - long ptr = getNSWindowPtr(); - if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) { - CWrapper.NSWindow.makeMainWindow(ptr); - } - CWrapper.NSWindow.makeKeyAndOrderFront(ptr); + execute(ptr -> { + if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) { + CWrapper.NSWindow.makeMainWindow(ptr); + } + CWrapper.NSWindow.makeKeyAndOrderFront(ptr); + }); return true; } @Override public boolean isActive() { - long ptr = getNSWindowPtr(); - return CWrapper.NSWindow.isKeyWindow(ptr); + AtomicBoolean ref = new AtomicBoolean(); + execute(ptr -> { + ref.set(CWrapper.NSWindow.isKeyWindow(ptr)); + }); + return ref.get(); } @Override @@ -773,21 +811,21 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override public void setOpacity(float opacity) { - CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity); + execute(ptr -> CWrapper.NSWindow.setAlphaValue(ptr, opacity)); } @Override public void setOpaque(boolean isOpaque) { - CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque); + execute(ptr -> CWrapper.NSWindow.setOpaque(ptr, isOpaque)); boolean isTextured = (peer == null) ? false : peer.isTextured(); if (!isTextured) { if (!isOpaque) { - CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), 0); + execute(ptr -> CWrapper.NSWindow.setBackgroundColor(ptr, 0)); } else if (peer != null) { Color color = peer.getBackground(); if (color != null) { int rgb = color.getRGB(); - CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), rgb); + execute(ptr->CWrapper.NSWindow.setBackgroundColor(ptr, rgb)); } } } @@ -800,12 +838,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override public void enterFullScreenMode() { isFullScreenMode = true; - nativeEnterFullScreenMode(getNSWindowPtr()); + execute(CPlatformWindow::nativeEnterFullScreenMode); } @Override public void exitFullScreenMode() { - nativeExitFullScreenMode(getNSWindowPtr()); + execute(CPlatformWindow::nativeExitFullScreenMode); isFullScreenMode = false; } @@ -824,7 +862,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo int prevWindowState = peer.getState(); if (prevWindowState == windowState) return; - final long nsWindowPtr = getNSWindowPtr(); if ((windowState & Frame.ICONIFIED) != 0) { // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. windowState = Frame.ICONIFIED; @@ -836,18 +873,18 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // the zoom call toggles between the normal and the max states unmaximize(); } - CWrapper.NSWindow.miniaturize(nsWindowPtr); + execute(CWrapper.NSWindow::miniaturize); break; case Frame.MAXIMIZED_BOTH: if (prevWindowState == Frame.ICONIFIED) { // let's return into the normal states first - CWrapper.NSWindow.deminiaturize(nsWindowPtr); + execute(CWrapper.NSWindow::deminiaturize); } maximize(); break; case Frame.NORMAL: if (prevWindowState == Frame.ICONIFIED) { - CWrapper.NSWindow.deminiaturize(nsWindowPtr); + execute(CWrapper.NSWindow::deminiaturize); } else if (prevWindowState == Frame.MAXIMIZED_BOTH) { // the zoom call toggles between the normal and the max states unmaximize(); @@ -871,15 +908,15 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // We are going to show a modal window. Previously displayed window will be // blocked/disabled. So we have to send mouse exited event to it now, since // all mouse events are discarded for blocked/disabled windows. - nativeSynthesizeMouseEnteredExitedEvents(getNSWindowPtr(), CocoaConstants.NSMouseExited); + execute(ptr -> nativeSynthesizeMouseEnteredExitedEvents(ptr, CocoaConstants.NSMouseExited)); } - nativeSetEnabled(getNSWindowPtr(), !blocked); + execute(ptr -> nativeSetEnabled(ptr, !blocked)); checkBlockingAndOrder(); } - public final void invalidateShadow(){ - nativeRevalidateNSWindowShadow(getNSWindowPtr()); + public final void invalidateShadow() { + execute(ptr -> nativeRevalidateNSWindowShadow(ptr)); } // ---------------------------------------------------------------------- @@ -974,6 +1011,11 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo protected void deliverMoveResizeEvent(int x, int y, int width, int height, boolean byUser) { + AtomicBoolean ref = new AtomicBoolean(); + execute(ptr -> { + ref.set(CWrapper.NSWindow.isZoomed(ptr)); + }); + isZoomed = ref.get(); checkZoom(); final Rectangle oldB = nativeBounds; @@ -1067,11 +1109,11 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo pWindow.orderAboveSiblings(); - final long nsWindowPtr = pWindow.getNSWindowPtr(); - CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr); - CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr); - CWrapper.NSWindow.makeMainWindow(nsWindowPtr); - + pWindow.execute(ptr -> { + CWrapper.NSWindow.orderFrontRegardless(ptr); + CWrapper.NSWindow.makeKeyAndOrderFront(ptr); + CWrapper.NSWindow.makeMainWindow(ptr); + }); return true; } @@ -1110,7 +1152,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // which is going to become 'main window', are placed above their siblings. CPlatformWindow rootOwner = getRootOwner(); if (rootOwner.isVisible() && !rootOwner.isIconified()) { - CWrapper.NSWindow.orderFront(rootOwner.getNSWindowPtr()); + rootOwner.execute(CWrapper.NSWindow::orderFront); } // Do not order child windows of iconified owner. if (!rootOwner.isIconified()) { @@ -1137,10 +1179,13 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // the window should be ordered above its siblings; otherwise the window is just ordered // above its nearest parent. if (pw.isOneOfOwnersOrSelf(this)) { - CWrapper.NSWindow.orderFront(pw.getNSWindowPtr()); + pw.execute(CWrapper.NSWindow::orderFront); } else { - CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove, - pw.owner.getNSWindowPtr()); + pw.owner.execute(ownerPtr -> { + pw.execute(ptr -> { + CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr); + }); + }); } pw.applyWindowLevel(w); } @@ -1162,9 +1207,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo protected void applyWindowLevel(Window target) { if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) { - CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel); + execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSFloatingWindowLevel)); } else if (target.getType() == Window.Type.POPUP) { - CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel); + execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSPopUpMenuWindowLevel)); } } 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 b73f67a0f79..95f83055cbc 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 @@ -46,6 +46,7 @@ final class CPopupMenu extends CMenu implements PopupMenuPeer { private native long nativeShowPopupMenu(long modelPtr, int x, int y); @Override + @SuppressWarnings("deprecation") public void show(Event e) { Component origin = (Component)e.target; if (origin != null) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java index cb1ee148707..1e492b9103c 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java @@ -68,6 +68,7 @@ public class CPrinterDialogPeer extends LWWindowPeer { public void setResizable(boolean resizable) {} public void setEnabled(boolean enable) {} public void setBounds(int x, int y, int width, int height) {} + @SuppressWarnings("deprecation") public boolean handleEvent(Event e) { return false; } public void setForeground(Color c) {} public void setBackground(Color c) {} diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java index 2d54d62b799..e54e1532666 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java @@ -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 @@ -556,6 +556,7 @@ public final class CPrinterJob extends RasterPrinterJob { // The following methods are CPrinterJob specific. @Override + @SuppressWarnings("deprecation") protected void finalize() { synchronized (fNSPrintInfoLock) { if (fNSPrintInfo != -1) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java index 940858e1d4f..744b85a0a05 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.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 @@ -174,7 +174,8 @@ class CRobot implements RobotPeer { @Override public int getRGBPixel(int x, int y) { int c[] = new int[1]; - getScreenPixels(new Rectangle(x, y, 1, 1), c); + double scale = fDevice.getScaleFactor(); + getScreenPixels(new Rectangle(x, y, (int) scale, (int) scale), c); return c[0]; } @@ -198,7 +199,8 @@ class CRobot implements RobotPeer { boolean isMouseMove); private native void keyEvent(int javaKeyCode, boolean keydown); private void getScreenPixels(Rectangle r, int[] pixels){ - nativeGetScreenPixels(r.x, r.y, r.width, r.height, pixels); + double scale = fDevice.getScaleFactor(); + nativeGetScreenPixels(r.x, r.y, r.width, r.height, scale, pixels); } - private native void nativeGetScreenPixels(int x, int y, int width, int height, int[] pixels); + private native void nativeGetScreenPixels(int x, int y, int width, int height, double scale, int[] pixels); } 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 bcbb242f949..dc168a4ab1f 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 @@ -36,6 +36,7 @@ import java.awt.image.BufferedImage; import java.awt.peer.TrayIconPeer; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.concurrent.atomic.AtomicReference; import static sun.awt.AWTAccessor.*; @@ -91,10 +92,6 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { return nativeCreate(); } - private long getModel() { - return ptr; - } - private native long nativeCreate(); //invocation from the AWTTrayIcon.m @@ -168,7 +165,7 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { @Override public void setToolTip(String tooltip) { - nativeSetToolTip(getModel(), tooltip); + execute(ptr -> nativeSetToolTip(ptr, tooltip)); } //adds tooltip to the NSStatusBar's NSButton. @@ -197,7 +194,12 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { } CImage cimage = CImage.getCreator().createFromImage(image); - setNativeImage(getModel(), cimage.ptr, target.isImageAutoSize()); + boolean imageAutoSize = target.isImageAutoSize(); + cimage.execute(imagePtr -> { + execute(ptr -> { + setNativeImage(ptr, imagePtr, imageAutoSize); + }); + }); } private native void setNativeImage(final long model, final long nsimage, final boolean autosize); @@ -377,7 +379,14 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer { private void showMessageDialog() { Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); - Point2D iconLoc = nativeGetIconLocation(getModel()); + AtomicReference ref = new AtomicReference<>(); + execute(ptr -> { + ref.set(nativeGetIconLocation(ptr)); + }); + Point2D iconLoc = ref.get(); + if (iconLoc == null) { + return; + } int dialogY = (int)iconLoc.getY(); int dialogX = (int)iconLoc.getX(); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java index 2312fbb94be..5c658ef8e33 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java @@ -73,13 +73,13 @@ public class CViewPlatformEmbeddedFrame implements PlatformWindow { @Override public void dispose() { - CWrapper.NSView.removeFromSuperview(view.getAWTView()); + view.execute(CWrapper.NSView::removeFromSuperview); view.dispose(); } @Override public void setVisible(boolean visible) { - CWrapper.NSView.setHidden(view.getAWTView(), !visible); + view.execute(ptr -> CWrapper.NSView.setHidden(ptr, !visible)); } @Override diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java index ee44dbf09c9..a8cad346cff 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java @@ -204,14 +204,14 @@ public final class CWarningWindow extends CPlatformWindow @Override public void setVisible(boolean visible) { synchronized (lock) { - final long nsWindowPtr = getNSWindowPtr(); - - // Actually show or hide the window - if (visible) { - CWrapper.NSWindow.orderFront(nsWindowPtr); - } else { - CWrapper.NSWindow.orderOut(nsWindowPtr); - } + execute(ptr -> { + // Actually show or hide the window + if (visible) { + CWrapper.NSWindow.orderFront(ptr); + } else { + CWrapper.NSWindow.orderOut(ptr); + } + }); this.visible = visible; @@ -219,8 +219,13 @@ public final class CWarningWindow extends CPlatformWindow if (visible) { // Order myself above my parent if (owner != null && owner.isVisible()) { - CWrapper.NSWindow.orderWindow(nsWindowPtr, - CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr()); + owner.execute(ownerPtr -> { + execute(ptr -> { + CWrapper.NSWindow.orderWindow(ptr, + CWrapper.NSWindow.NSWindowAbove, + ownerPtr); + }); + }); // do not allow security warning to be obscured by other windows applyWindowLevel(ownerWindow); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 9c463003a93..6f5e5c85c9a 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -358,18 +358,6 @@ public final class LWCToolkit extends LWToolkit { return new OSXPlatformFont(name, style); } - @Override - protected int getScreenHeight() { - return GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice().getDefaultConfiguration().getBounds().height; - } - - @Override - protected int getScreenWidth() { - return GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice().getDefaultConfiguration().getBounds().width; - } - @Override protected void initializeDesktopProperties() { super.initializeDesktopProperties(); @@ -532,6 +520,7 @@ public final class LWCToolkit extends LWToolkit { * @since 1.1 */ @Override + @SuppressWarnings("deprecation") public int getMenuShortcutKeyMask() { return Event.META_MASK; } @@ -768,6 +757,7 @@ public final class LWCToolkit extends LWToolkit { * stroke. */ @Override + @SuppressWarnings("deprecation") public int getFocusAcceleratorKeyMask() { return InputEvent.CTRL_MASK | InputEvent.ALT_MASK; } @@ -777,6 +767,7 @@ public final class LWCToolkit extends LWToolkit { * printable character. */ @Override + @SuppressWarnings("deprecation") public boolean isPrintableCharacterModifiersMask(int mods) { return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0); } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java index 5710988643d..252ce1122c9 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java @@ -36,8 +36,8 @@ final class NSEvent { static final int SCROLL_PHASE_UNSUPPORTED = 1; static final int SCROLL_PHASE_BEGAN = 2; static final int SCROLL_PHASE_CONTINUED = 3; - static final int SCROLL_MASK_PHASE_CANCELLED = 4; - static final int SCROLL_MASK_PHASE_ENDED = 5; + static final int SCROLL_PHASE_MOMENTUM_BEGAN = 4; + static final int SCROLL_PHASE_ENDED = 5; private int type; private int modifierFlags; diff --git a/jdk/src/java.desktop/macosx/native/include/jawt_md.h b/jdk/src/java.desktop/macosx/native/include/jawt_md.h index c6859fdbf90..94a13c9ab40 100644 --- a/jdk/src/java.desktop/macosx/native/include/jawt_md.h +++ b/jdk/src/java.desktop/macosx/native/include/jawt_md.h @@ -37,7 +37,7 @@ extern "C" { #endif /* - * Mac OS X specific declarations for AWT native interface. + * MacOS specific declarations for AWT native interface. * See notes in jawt.h for an example of use. */ diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.h b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.h index 5045be3a59c..f217605ed7c 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.h +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.h @@ -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,6 +41,8 @@ CALayer *windowLayer; } +@property (atomic, retain) CALayer *windowLayer; + - (id) initWithWindowLayer: (CALayer *)windowLayer; - (void) setBounds: (CGRect)rect; diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m index 39fc4c2b82a..c03ff90a375 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.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 @@ -38,11 +38,15 @@ self = [super init]; if (self == nil) return self; - windowLayer = aWindowLayer; + self.windowLayer = aWindowLayer; return self; } +- (void) dealloc { + self.windowLayer = nil; + [super dealloc]; +} - (CALayer *) layer { return layer; diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m index 208d22d69ff..186a002dd5f 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m @@ -381,6 +381,13 @@ static BOOL shouldUsePressAndHold() { } else { clickCount = [event clickCount]; } + + jdouble deltaX = [event deltaX]; + jdouble deltaY = [event deltaY]; + if ([AWTToolkit hasPreciseScrollingDeltas: event]) { + deltaX = [event scrollingDeltaX] * 0.1; + deltaY = [event scrollingDeltaY] * 0.1; + } static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V"); @@ -391,8 +398,8 @@ static BOOL shouldUsePressAndHold() { [event buttonNumber], (jint)localPoint.x, (jint)localPoint.y, (jint)absP.x, (jint)absP.y, - [event deltaY], - [event deltaX], + deltaY, + deltaX, [AWTToolkit scrollStateWithEvent: event]); CHECK_NULL(jEvent); diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m index 03a32ddd8e7..db54e27faca 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m @@ -376,7 +376,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I"); - static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;"); + static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;"); NSMutableDictionary* printingDictionary = [dst dictionary]; @@ -412,7 +412,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage]; [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage]; - jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat); + jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat, (jint)0); if (page != NULL) { javaPageFormatToNSPrintInfo(env, NULL, page, dst); } diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m index d3ee81c2175..c394854a5c6 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m @@ -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 @@ -276,7 +276,7 @@ Java_sun_lwawt_macosx_CRobot_keyEvent JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CRobot_nativeGetScreenPixels (JNIEnv *env, jobject peer, - jint x, jint y, jint width, jint height, jintArray pixels) + jint x, jint y, jint width, jint height, jdouble scale, jintArray pixels) { JNF_COCOA_ENTER(env); @@ -285,10 +285,11 @@ Java_sun_lwawt_macosx_CRobot_nativeGetScreenPixels jint picWidth = width; jint picHeight = height; - CGRect screenRect = CGRectMake(picX, picY, picWidth, picHeight); + CGRect screenRect = CGRectMake(picX / scale, picY / scale, + picWidth / scale, picHeight / scale); CGImageRef screenPixelsImage = CGWindowListCreateImage(screenRect, kCGWindowListOptionOnScreenOnly, - kCGNullWindowID, kCGWindowImageDefault); + kCGNullWindowID, kCGWindowImageBestResolution); if (screenPixelsImage == NULL) { return; diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m index 8057972d301..bfce2fde5c7 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m @@ -139,7 +139,14 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) { jint clickCount; clickCount = [event clickCount]; - + + jdouble deltaX = [event deltaX]; + jdouble deltaY = [event deltaY]; + if ([AWTToolkit hasPreciseScrollingDeltas: event]) { + deltaX = [event scrollingDeltaX] * 0.1; + deltaY = [event scrollingDeltaY] * 0.1; + } + static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V"); jobject jEvent = JNFNewObject(env, jctor_NSEvent, @@ -149,8 +156,8 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) { [event buttonNumber], (jint)localPoint.x, (jint)localPoint.y, (jint)absP.x, (jint)absP.y, - [event deltaY], - [event deltaX], + deltaY, + deltaX, [AWTToolkit scrollStateWithEvent: event]); CHECK_NULL(jEvent); diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m index 5a91adf70b5..01b495be605 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m @@ -136,7 +136,7 @@ static NSObject *sAttributeNamesLOCK = nil; fJavaRole = [javaRole retain]; fAccessible = (*env)->NewWeakGlobalRef(env, accessible); - + (*env)->ExceptionClear(env); // in case of OOME jobject jcomponent = [(AWTView *)fView awtComponent:env]; fComponent = (*env)->NewWeakGlobalRef(env, jcomponent); (*env)->DeleteLocalRef(env, jcomponent); diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h index c581cb45be1..34532ecb05f 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h @@ -42,6 +42,7 @@ extern jint* gButtonDownMasks; + (long) getEventCount; + (void) eventCountPlusPlus; + (jint) scrollStateWithEvent: (NSEvent*) event; ++ (BOOL) hasPreciseScrollingDeltas: (NSEvent*) event; @end /* diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m index 41e966894ce..8cba8ccb8a9 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m @@ -47,7 +47,7 @@ #define SCROLL_PHASE_UNSUPPORTED 1 #define SCROLL_PHASE_BEGAN 2 #define SCROLL_PHASE_CONTINUED 3 -#define SCROLL_PHASE_CANCELLED 4 +#define SCROLL_PHASE_MOMENTUM_BEGAN 4 #define SCROLL_PHASE_ENDED 5 int gNumberOfButtons; @@ -85,16 +85,33 @@ static long eventCount; return 0; } - NSEventPhase phase = [event phase]; - NSEventPhase momentumPhase = [event momentumPhase]; - - if (!phase && !momentumPhase) return SCROLL_PHASE_UNSUPPORTED; - switch (phase) { - case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN; - case NSEventPhaseCancelled: return SCROLL_PHASE_CANCELLED; - case NSEventPhaseEnded: return SCROLL_PHASE_ENDED; - default: return SCROLL_PHASE_CONTINUED; + if ([event phase]) { + // process a phase of manual scrolling + switch ([event phase]) { + case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN; + case NSEventPhaseCancelled: return SCROLL_PHASE_ENDED; + case NSEventPhaseEnded: return SCROLL_PHASE_ENDED; + default: return SCROLL_PHASE_CONTINUED; + } } + + if ([event momentumPhase]) { + // process a phase of automatic scrolling + switch ([event momentumPhase]) { + case NSEventPhaseBegan: return SCROLL_PHASE_MOMENTUM_BEGAN; + case NSEventPhaseCancelled: return SCROLL_PHASE_ENDED; + case NSEventPhaseEnded: return SCROLL_PHASE_ENDED; + default: return SCROLL_PHASE_CONTINUED; + } + } + // phase and momentum phase both are not set + return SCROLL_PHASE_UNSUPPORTED; +} + ++ (BOOL) hasPreciseScrollingDeltas: (NSEvent*) event { + return [event type] == NSScrollWheel + && [event respondsToSelector:@selector(hasPreciseScrollingDeltas)] + && [event hasPreciseScrollingDeltas]; } @end diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m index 01f24de6ec7..017c46aa013 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m @@ -284,28 +284,21 @@ PRINT(" contextQuartzLinearGradientPath"); CGFloat components[component_size]; CGGradientRef gradient = NULL; - for (int i = 0; i < num_locations; i++) { + for (i = 0; i < num_locations; i++) { locations[i] = gradientInfo->fractionsdata[i]; -//fprintf(stderr, "locations[%d] %f\n", i, locations[i]); } for (i = 0; i < component_size; i++) { components[i] = gradientInfo->colordata[i]; -//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n", -// i, components[i], i, gradientInfo->colordata[i]); } CGContextSaveGState(cgRef); gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations); -//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n", -// gradientInfo->start.x, gradientInfo->start.y); -//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n", -// gradientInfo->end.x, gradientInfo->end.y); if (qsdo->isEvenOddFill) { CGContextEOClip(cgRef); } else { CGContextClip(cgRef); } CGContextDrawLinearGradient(cgRef, gradient, gradientInfo->start, gradientInfo->end, kCGGradientDrawsAfterEndLocation); - + CGContextRestoreGState(cgRef); CGColorSpaceRelease(colorspace); CGGradientRelease(gradient); @@ -332,27 +325,19 @@ PRINT(" contextQuartzRadialGradientPath"); CGFloat startRadius = gradientInfo->radius; CGFloat endRadius = gradientInfo->radius; - for (int i = 0; i < num_locations; i++) { + for (i = 0; i < num_locations; i++) { locations[i] = gradientInfo->fractionsdata[i]; -//fprintf(stderr, "locations[%d] %f\n", i, locations[i]); } for (i = 0; i < component_size; i++) { components[i] = gradientInfo->colordata[i]; -//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n", -// i, components[i], i, gradientInfo->colordata[i]); } CGContextSaveGState(cgRef); gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations); -//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n", -// gradientInfo->start.x, gradientInfo->start.y); -//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n", -// gradientInfo->end.x, gradientInfo->end.y); if (qsdo->isEvenOddFill) { CGContextEOClip(cgRef); } else { CGContextClip(cgRef); } -//fprintf(stderr, "gradientInfo->startRadius %f, gradientInfo->endRadius %f\n",startRadius,endRadius); CGContextDrawRadialGradient(cgRef, gradient, gradientInfo->start, 0, gradientInfo->end, endRadius, kCGGradientDrawsAfterEndLocation); CGContextRestoreGState(cgRef); @@ -944,54 +929,41 @@ void setupGradient(JNIEnv *env, QuartzSDOps* qsdo, jfloat* javaFloatGraphicsStat if (colorArray != NULL) { jint length = (*env)->GetArrayLength(env, colorArray); -//fprintf(stderr, "length %d\n", length); jint* jcolorData = (jint*)(*env)->GetPrimitiveArrayCritical(env, colorArray, NULL); - CGFloat* colors= (CGFloat*)calloc(0, sizeof(CGFloat)*length); + qsdo->gradientInfo->colordata = (CGFloat*)malloc(sizeof(CGFloat)*4*length); + memset(qsdo->gradientInfo->colordata, 0, sizeof(CGFloat)*4*length); if (jcolorData != NULL) { - jint i; + int i; for (i=0; igradientInfo->colordata[i*4] = ((jcolorData[i]>>16)&0xff)*kColorConversionMultiplier; + + qsdo->gradientInfo->colordata[i*4+1] = ((jcolorData[i]>>8)&0xff)*kColorConversionMultiplier; + + qsdo->gradientInfo->colordata[i*4+2] = ((jcolorData[i]>>0)&0xff)*kColorConversionMultiplier; + + qsdo->gradientInfo->colordata[i*4+3] = ((jcolorData[i]>>24)&0xff)*kColorConversionMultiplier; } } (*env)->ReleasePrimitiveArrayCritical(env, colorArray, jcolorData, 0); - qsdo->gradientInfo->colordata = (CGFloat*)calloc(0, sizeof(CGFloat)*4*length); - for (int i = 0; i < length; i++) - { - jint c1 = colors[i]; -//fprintf(stderr, "c1 %x\n", c1); - qsdo->gradientInfo->colordata[i*4] = ((c1>>16)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4, qsdo->gradientInfo->colordata[i*4]); - - qsdo->gradientInfo->colordata[i*4+1] = ((c1>>8)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+1, qsdo->gradientInfo->colordata[i*4+1]); - - qsdo->gradientInfo->colordata[i*4+2] = ((c1>>0)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+2, qsdo->gradientInfo->colordata[i*4+2]); - - qsdo->gradientInfo->colordata[i*4+3] = ((c1>>24)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+3, qsdo->gradientInfo->colordata[i*4+3]); - } - free(colors); } jobject fractionsArray = ((*env)->GetObjectArrayElement(env, qsdo->javaGraphicsStatesObjects, sun_java2d_OSXSurfaceData_kFractionsArrayIndex)); if (fractionsArray != NULL) { jint length = (*env)->GetArrayLength(env, fractionsArray); -//fprintf(stderr, "fractions length %d\n", length); qsdo->gradientInfo->fractionsLength = length; jfloat* jfractionsData = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, fractionsArray, NULL); if (jfractionsData != NULL) { + int i; qsdo->gradientInfo->fractionsdata = (CGFloat *)malloc(sizeof(CGFloat) *length); - jint i; + memset(qsdo->gradientInfo->fractionsdata, 0, sizeof(CGFloat)*length); for (i=0; igradientInfo->fractionsdata[i] = jfractionsData[i]; -//fprintf(stderr, "jfrationsData[%d] %f, qsdo->gradientInfo->fractionsdata[%d] = %f\n", i, jfractionsData[i], i, qsdo->gradientInfo->fractionsdata[i]); } (*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, jfractionsData, 0); } diff --git a/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java b/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java index 1ba10acd72f..e699937bd7f 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java +++ b/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 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 @@ -27,6 +27,8 @@ package com.sun.awt; import java.awt.*; +import javax.swing.JRootPane; + import sun.awt.AWTAccessor; import sun.awt.SunToolkit; @@ -323,7 +325,7 @@ public final class AWTUtilities { * is thrown. *

              If the window is a {@code Frame} or a {@code Dialog}, the window must * be undecorated prior to enabling the per-pixel translucency effect (see - * {@link Frame#setUndecorated()} and/or {@link Dialog#setUndecorated()}). + * {@link Frame#setUndecorated} and/or {@link Dialog#setUndecorated}). * If the window becomes decorated through a subsequent call to the * corresponding {@code setUndecorated()} method, the per-pixel * translucency effect will be disabled and the opaque property reset to @@ -431,7 +433,7 @@ public final class AWTUtilities { * *

              * The most common example when the 'mixing-cutout' shape is needed is a - * glass pane component. The {@link JRootPane#setGlassPane()} method + * glass pane component. The {@link JRootPane#setGlassPane} method * automatically sets the empty-shape as the 'mixing-cutout' shape * for the given glass pane component. If a developer needs some other * 'mixing-cutout' shape for the glass pane (which is rare), this must be @@ -456,8 +458,7 @@ public final class AWTUtilities { "The component argument should not be null."); } - AWTAccessor.getComponentAccessor().setMixingCutoutShape(component, - shape); + component.setMixingCutoutShape(shape); } } diff --git a/jdk/src/java.desktop/share/classes/com/sun/awt/SecurityWarning.java b/jdk/src/java.desktop/share/classes/com/sun/awt/SecurityWarning.java index a33a8b3493f..02c65c0c227 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/awt/SecurityWarning.java +++ b/jdk/src/java.desktop/share/classes/com/sun/awt/SecurityWarning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 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 @@ -59,7 +59,7 @@ public final class SecurityWarning { * * The returned value is not valid until the peer has been created. Before * invoking this method a developer must call the {@link Window#pack()}, - * {@link Window#setVisible()}, or some other method that creates the peer. + * {@link Window#setVisible}, or some other method that creates the peer. * * @param window the window to get the security warning size for * diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java index ee178527dac..81baecc21cb 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java @@ -1439,51 +1439,72 @@ public class BMPImageReader extends ImageReader implements BMPConstants { decodeRLE8(imSize, padding, values, bdata); } + private boolean copyRLE8ScanlineToDst(int lineNo, + byte[] val, + byte[] bdata) { + // Return value + boolean isSuccess = false; + + // Reusing the code to copy 1 row of pixels or scanline to required + // destination buffer. + if (lineNo >= sourceRegion.y && + lineNo < sourceRegion.y + sourceRegion.height) { + if (noTransform) { + int pos = lineNo * width; + for(int i = 0; i < width; i++) + bdata[pos++] = val[i]; + processImageUpdate(bi, 0, lineNo, + destinationRegion.width, 1, 1, 1, + new int[]{0}); + isSuccess = true; + } else if ((lineNo - sourceRegion.y) % scaleY == 0) { + int lineStride = + ((ComponentSampleModel)sampleModel).getScanlineStride(); + int currentLine = (lineNo - sourceRegion.y) / scaleY + + destinationRegion.y; + int pos = currentLine * lineStride; + pos += destinationRegion.x; + for (int i = sourceRegion.x; + i < sourceRegion.x + sourceRegion.width; + i += scaleX) + bdata[pos++] = val[i]; + processImageUpdate(bi, 0, currentLine, + destinationRegion.width, 1, 1, 1, + new int[]{0}); + isSuccess = true; + } + // Ensure to reset the scanline buffer once the copy is complete. + for(int scIndex = 0; scIndex < width; scIndex++) { + val[scIndex] = 0; + } + } + + return isSuccess; + } + private void decodeRLE8(int imSize, int padding, byte[] values, byte[] bdata) throws IOException { - byte val[] = new byte[width * height]; + byte val[] = new byte[width]; int count = 0, l = 0; int value; boolean flag = false; int lineNo = isBottomUp ? height - 1 : 0; - int lineStride = - ((ComponentSampleModel)sampleModel).getScanlineStride(); int finished = 0; - while (count != imSize) { + // Ensure image source has sufficient data to decode + while ((count + 1) < imSize) { value = values[count++] & 0xff; if (value == 0) { switch(values[count++] & 0xff) { case 0: // End-of-scanline marker - if (lineNo >= sourceRegion.y && - lineNo < sourceRegion.y + sourceRegion.height) { - if (noTransform) { - int pos = lineNo * width; - for(int i = 0; i < width; i++) - bdata[pos++] = val[i]; - processImageUpdate(bi, 0, lineNo, - destinationRegion.width, 1, 1, 1, - new int[]{0}); - finished++; - } else if ((lineNo - sourceRegion.y) % scaleY == 0) { - int currentLine = (lineNo - sourceRegion.y) / scaleY + - destinationRegion.y; - int pos = currentLine * lineStride; - pos += destinationRegion.x; - for (int i = sourceRegion.x; - i < sourceRegion.x + sourceRegion.width; - i += scaleX) - bdata[pos++] = val[i]; - processImageUpdate(bi, 0, currentLine, - destinationRegion.width, 1, 1, 1, - new int[]{0}); - finished++; - } + // Copy the decoded scanline to destination + if (copyRLE8ScanlineToDst(lineNo, val, bdata)) { + finished++; } processImageProgress(100.0F * finished / destinationRegion.height); lineNo += isBottomUp ? -1 : 1; @@ -1492,26 +1513,62 @@ public class BMPImageReader extends ImageReader implements BMPConstants { if (abortRequested()) { flag = true; } - break; case 1: // End-of-RLE marker flag = true; + + // Check if the last decoded scanline was copied to + // destination bitmap + if (l != 0) { + // Copy the decoded scanline to destination + if (copyRLE8ScanlineToDst(lineNo, val, bdata)) { + finished++; + } + processImageProgress(100.0F * finished / destinationRegion.height); + lineNo += isBottomUp ? -1 : 1; + l = 0; + } break; case 2: // delta or vector marker - int xoff = values[count++] & 0xff; - int yoff = values[count] & 0xff; - // Move to the position xoff, yoff down - l += xoff + yoff*width; + if ((count+1) < imSize) { + int xoff = values[count++] & 0xff; + int yoff = values[count++] & 0xff; + + // Check if the yOffset shifts the decoding to another + // row. In such cases, the decoded pixels in scanline + // buffer-val must be copied to the destination image. + if (yoff != 0) { + // Copy the decoded scanline to destination + if (copyRLE8ScanlineToDst(lineNo, val, bdata)) { + finished++; + } + processImageProgress(100.0F * finished + / destinationRegion.height); + lineNo += isBottomUp ? -yoff : yoff; + } + + // Move to the position xoff, yoff down + l += xoff + yoff*width; + l %= width; + } break; default: int end = values[count-1] & 0xff; - for (int i=0; i markerSequence = new ArrayList<>(); diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java index f1660f8a159..3fbc55c82b9 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.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 @@ -143,6 +143,7 @@ final class ChunkStream extends ImageOutputStreamImpl { } @Override + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { // Empty finalizer (for improved performance; no need to call // super.finalize() in this case) @@ -279,6 +280,7 @@ final class IDATOutputStream extends ImageOutputStreamImpl { } @Override + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { // Empty finalizer (for improved performance; no need to call // super.finalize() in this case) diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java index 46185618913..d78cb1cbdd9 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.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 @@ -74,13 +74,13 @@ public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor { /** * ImageWriteParam for JPEG writer. - * May be initialized by {@link #initJPEGWriter()}. + * May be initialized by {@link #initJPEGWriter}. */ protected JPEGImageWriteParam JPEGParam = null; /** * The JPEG writer. - * May be initialized by {@link #initJPEGWriter()}. + * May be initialized by {@link #initJPEGWriter}. */ protected ImageWriter JPEGWriter = null; @@ -95,7 +95,7 @@ public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor { * Stream metadata equivalent to a tables-only stream such as in * the {@code JPEGTables}. Default value is {@code null}. * This should be set by any subclass which sets - * {@link writeAbbreviatedStream} to {@code true}. + * {@link #writeAbbreviatedStream} to {@code true}. */ protected IIOMetadata JPEGStreamMetadata = null; @@ -435,6 +435,7 @@ public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor { return compDataLength; } + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); if(JPEGWriter != null) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDecompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDecompressor.java index acfa6985f3c..a1b04390977 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDecompressor.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDecompressor.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 @@ -1322,7 +1322,7 @@ public abstract class TIFFDecompressor { * Sets the index of the planar configuration band to be decoded. This value * is ignored for chunky (interleaved) images. * - * @param the index of the planar band to decode + * @param planarBand the index of the planar band to decode */ public void setPlanarBand(int planarBand) { this.planarBand = planarBand; } @@ -2069,7 +2069,7 @@ public abstract class TIFFDecompressor { *

              The default implementation calls {@code decodeRaw(byte[] b, * ...)} and copies the resulting data into {@code f}. * - * @param f a {@code double} array to be written. + * @param d a {@code double} array to be written. * @param dstOffset the starting offset in {@code f} to be * written. * @param bitsPerPixel the number of bits for each pixel. diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java index 966ca9575d9..384687f8344 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.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 @@ -139,6 +139,7 @@ public class TIFFJPEGDecompressor extends TIFFDecompressor { JPEGReader.read(0, JPEGParam); } + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); JPEGReader.dispose(); diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java index 2837754ddb2..67dd60f8a79 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.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 @@ -610,6 +610,7 @@ public class TIFFOldJPEGDecompressor extends TIFFJPEGDecompressor { JPEGReader.read(0, JPEGParam); } + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); JPEGReader.dispose(); diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageWriter.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageWriter.java index 8fd3a459fe1..90bc2c41ab2 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageWriter.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageWriter.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 @@ -58,8 +58,6 @@ import com.sun.imageio.plugins.common.I18N; * * The encoding process may clip, subsample using the parameters * specified in the {@code ImageWriteParam}. - * - * @see com.sun.media.imageio.plugins.WBMPImageWriteParam */ public class WBMPImageWriter extends ImageWriter { /** The output stream to write into */ diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java index 36954988f1b..be1e659ee6e 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 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 @@ -60,6 +60,7 @@ public class StreamFinalizer { this.stream = stream; } + @SuppressWarnings("deprecation") protected void finalize() throws Throwable { try { stream.close(); diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKColorType.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKColorType.java index 1d619c1e984..85358c84185 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKColorType.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKColorType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, 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 @@ -138,9 +138,9 @@ public class GTKColorType extends ColorType { * arguments to scale. * * @param color Color to alter - * @param hFactory Amount to scale the hue + * @param hFactor Amount to scale the hue * @param lFactor Amount to scale the lightness - * @param sFactory Amount to sacle saturation + * @param sFactor Amount to sacle saturation * @return newly created color */ static Color adjustColor(Color color, float hFactor, float lFactor, diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java index b1b30da2454..956726234ff 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.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 @@ -82,7 +82,7 @@ class GTKGraphicsUtils extends SynthGraphicsUtils { * render the text as html nor will it offset by the insets of the * component. * - * @param ss SynthContext + * @param context SynthContext * @param g Graphics used to render string in. * @param text Text to render * @param bounds Bounds of the text to be drawn. diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index 23c3f872fb6..2c45d6f1e3e 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.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 @@ -319,7 +319,7 @@ class GTKStyle extends SynthStyle implements GTKConstants { * insets will be placed in it, otherwise a new Insets object will be * created and returned. * - * @param context SynthContext identifying requestor + * @param state SynthContext identifying requestor * @param insets Where to place Insets * @return Insets. */ diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifDesktopIconUI.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifDesktopIconUI.java index 16f56e2f9c9..f4d6c8e5146 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifDesktopIconUI.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifDesktopIconUI.java @@ -236,7 +236,7 @@ public class MotifDesktopIconUI extends BasicDesktopIconUI } }); } - + @SuppressWarnings("deprecation") void forwardEventToParent(MouseEvent e) { getParent().dispatchEvent(new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), @@ -329,7 +329,7 @@ public class MotifDesktopIconUI extends BasicDesktopIconUI } }); } - + @SuppressWarnings("deprecation") void forwardEventToParent(MouseEvent e) { getParent().dispatchEvent(new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifGraphicsUtils.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifGraphicsUtils.java index 47bed21ffb8..c15a7b773cd 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifGraphicsUtils.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifGraphicsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, 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 @@ -89,7 +89,6 @@ public class MotifGraphicsUtils implements SwingConstants * drawStringInRect() does not clip to the rectangle, but instead * uses this rectangle and the desired justification to compute the point * at which to begin drawing the text. - * @see #drawString */ public static void drawStringInRect(Graphics g, String aString, int x, int y, int width, int height, int justification) { @@ -139,10 +138,11 @@ public class MotifGraphicsUtils implements SwingConstants } /** - * This method is not being used to paint menu item since + * @deprecated This method is not being used to paint menu item since * 6.0 This code left for compatibility only. Do not use or * override it, this will not cause any visible effect. */ + @Deprecated(since = "9") public static void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifInternalFrameTitlePane.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifInternalFrameTitlePane.java index 3d38e3b4b71..a12485928f5 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifInternalFrameTitlePane.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifInternalFrameTitlePane.java @@ -361,7 +361,7 @@ public class MotifInternalFrameTitlePane } }); } - + @SuppressWarnings("deprecation") void forwardEventToParent(MouseEvent e) { getParent().dispatchEvent(new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java index 7c8fd8a7bca..dc459e81be5 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java @@ -523,7 +523,8 @@ public class MotifLookAndFeel extends BasicLookAndFeel Object optionPaneMessageAreaBorder = new BorderUIResource.EmptyBorderUIResource(10,10,12,10); - + @SuppressWarnings("deprecation") + final int metaMask = KeyEvent.META_MASK; Object[] defaults = { "Desktop.background", table.get("desktop"), @@ -635,8 +636,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "Menu.submenuPopupOffsetX", -2, "Menu.submenuPopupOffsetY", 3, "Menu.shortcutKeys", new int[]{ - SwingUtilities2.getSystemMnemonicKeyMask(), - KeyEvent.META_MASK + SwingUtilities2.getSystemMnemonicKeyMask(), metaMask }, "Menu.cancelMode", "hideMenuTree", diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifPopupMenuUI.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifPopupMenuUI.java index 402bcc528b1..a0b182b8019 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifPopupMenuUI.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifPopupMenuUI.java @@ -107,6 +107,7 @@ public class MotifPopupMenuUI extends BasicPopupMenuUI { }; } + @SuppressWarnings("deprecation") public boolean isPopupTrigger(MouseEvent e) { return ((e.getID()==MouseEvent.MOUSE_PRESSED) && ((e.getModifiers() & MouseEvent.BUTTON3_MASK)!=0)); diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifTextUI.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifTextUI.java index 208a96840f6..a2a85e9cbff 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifTextUI.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifTextUI.java @@ -155,6 +155,7 @@ public class MotifTextUI { /** * Default bindings all keymaps implementing the Motif feel. */ + @SuppressWarnings("deprecation") static final JTextComponent.KeyBinding[] defaultBindings = { new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK), diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java index eb47262b29c..10a9e358cd5 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java @@ -36,7 +36,6 @@ import java.awt.event.*; import javax.swing.*; - import com.sun.java.swing.plaf.windows.TMSchema.State; import static com.sun.java.swing.plaf.windows.TMSchema.State.*; import com.sun.java.swing.plaf.windows.TMSchema.Part; @@ -383,18 +382,25 @@ class AnimationController implements ActionListener, PropertyChangeListener { updateProgress(); if (! isDone()) { Graphics2D g = (Graphics2D) _g.create(); - skin.paintSkinRaw(g, dx, dy, dw, dh, startState); - float alpha; - if (isForward) { - alpha = progress; + if (skin.haveToSwitchStates()) { + skin.paintSkinRaw(g, dx, dy, dw, dh, state); + g.setComposite(AlphaComposite.SrcOver.derive(1 - progress)); + skin.paintSkinRaw(g, dx, dy, dw, dh, startState); } else { - alpha = 1 - progress; + skin.paintSkinRaw(g, dx, dy, dw, dh, startState); + float alpha; + if (isForward) { + alpha = progress; + } else { + alpha = 1 - progress; + } + g.setComposite(AlphaComposite.SrcOver.derive(alpha)); + skin.paintSkinRaw(g, dx, dy, dw, dh, state); } - g.setComposite(AlphaComposite.SrcOver.derive(alpha)); - skin.paintSkinRaw(g, dx, dy, dw, dh, state); g.dispose(); } else { skin.paintSkinRaw(_g, dx, dy, dw, dh, state); + skin.switchStates(false); } } boolean isDone() { diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/TMSchema.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/TMSchema.java index 0bca0dd2172..f45a077e91d 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/TMSchema.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/TMSchema.java @@ -121,6 +121,12 @@ class TMSchema { LBP_LISTBOX(Control.LISTBOX, 0), + LBCP_BORDER_HSCROLL (Control.LISTBOX, 1), + LBCP_BORDER_HVSCROLL (Control.LISTBOX, 2), + LBCP_BORDER_NOSCROLL (Control.LISTBOX, 3), + LBCP_BORDER_VSCROLL (Control.LISTBOX, 4), + LBCP_ITEM (Control.LISTBOX, 5), + LVP_LISTVIEW(Control.LISTVIEW, 0), PP_PROGRESS (Control.PROGRESS, 0), @@ -343,6 +349,12 @@ class TMSchema { stateMap.put(Part.HP_HEADERSORTARROW, new State[] {SORTEDDOWN, SORTEDUP}); + State[] listBoxStates = new State[] { NORMAL, PRESSED, HOT, DISABLED}; + stateMap.put(Part.LBCP_BORDER_HSCROLL, listBoxStates); + stateMap.put(Part.LBCP_BORDER_HVSCROLL, listBoxStates); + stateMap.put(Part.LBCP_BORDER_NOSCROLL, listBoxStates); + stateMap.put(Part.LBCP_BORDER_VSCROLL, listBoxStates); + State[] scrollBarStates = new State[] { NORMAL, HOT, PRESSED, DISABLED, HOVER }; stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates); stateMap.put(Part.SBP_THUMBBTNVERT, scrollBarStates); diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java index 80217555bcb..c14f328c0fa 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java @@ -41,6 +41,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; import sun.swing.DefaultLookup; import sun.swing.StringUIClientPropertyKey; +import com.sun.java.swing.plaf.windows.WindowsBorders.DashedBorder; /** * Windows combo box. @@ -97,6 +98,9 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { } else if (source instanceof XPComboBoxButton) { rv = ((XPComboBoxButton) source) .getWindowsComboBoxUI().comboBox; + } else if (source instanceof JTextField && + ((JTextField) source).getParent() instanceof JComboBox) { + rv = (JComboBox) ((JTextField) source).getParent(); } return rv; } @@ -149,6 +153,8 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { //is initialized after installListeners is invoked comboBox.addMouseListener(rolloverListener); arrowButton.addMouseListener(rolloverListener); + // set empty border as default to see vista animated border + comboBox.setBorder(new EmptyBorder(0,0,0,0)); } } @@ -224,6 +230,9 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { state = State.DISABLED; } else if (isPopupVisible(comboBox)) { state = State.PRESSED; + } else if (comboBox.isEditable() + && comboBox.getEditor().getEditorComponent().isFocusOwner()) { + state = State.PRESSED; } else if (isRollover) { state = State.HOT; } @@ -242,7 +251,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { skin = xp.getSkin(c, Part.CP_READONLY); } if (skin == null) { - skin = xp.getSkin(c, Part.CP_COMBOBOX); + skin = xp.getSkin(c, Part.CP_BORDER); } skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state); } @@ -330,11 +339,16 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { public Dimension getMinimumSize( JComponent c ) { Dimension d = super.getMinimumSize(c); if (XPStyle.getXP() != null) { - d.width += 5; + d.width += 7; + boolean isEditable = false; + if (c instanceof JComboBox) { + isEditable = ((JComboBox) c).isEditable(); + } + d.height += isEditable ? 4 : 6; } else { d.width += 4; + d.height += 2; } - d.height += 2; return d; } @@ -368,7 +382,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { } protected ComboPopup createPopup() { - return super.createPopup(); + return new WinComboPopUp(comboBox); } /** @@ -414,8 +428,10 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { @SuppressWarnings("serial") // Superclass is not serializable across versions private class XPComboBoxButton extends XPStyle.GlyphButton { + private State prevState = null; + public XPComboBoxButton(XPStyle xp) { - super(null, + super(comboBox, (! xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) ? Part.CP_DROPDOWNBUTTON : (comboBox.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) @@ -428,18 +444,33 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { @Override protected State getState() { State rv; + + getModel().setPressed(comboBox.isPopupVisible()); + rv = super.getState(); XPStyle xp = XPStyle.getXP(); if (rv != State.DISABLED - && comboBox != null && ! comboBox.isEditable() - && xp != null && xp.isSkinDefined(comboBox, - Part.CP_DROPDOWNBUTTONRIGHT)) { + && comboBox != null && ! comboBox.isEditable() + && xp != null && xp.isSkinDefined(comboBox, + Part.CP_DROPDOWNBUTTONRIGHT)) { /* * for non editable ComboBoxes Vista seems to have the * same glyph for all non DISABLED states */ rv = State.NORMAL; } + if (rv == State.NORMAL && (prevState == State.HOT || prevState == State.PRESSED)) { + /* + * State NORMAL of combobox button cannot overpaint states HOT or PRESSED + * Therefore HOT state must be painted from alpha 1 to 0 and not as usual that + * NORMAL state is painted from alpha 0 to alpha 1. + */ + skin.switchStates(true); + } + if (rv != prevState) { + prevState = rv; + } + return rv; } @@ -484,6 +515,39 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { } } + @SuppressWarnings("serial") // Same-version serialization only + protected class WinComboPopUp extends BasicComboPopup { + private Skin listBoxBorder = null; + private XPStyle xp; + + public WinComboPopUp(JComboBox combo) { + super(combo); + xp = XPStyle.getXP(); + if (xp != null && xp.isSkinDefined(combo, Part.LBCP_BORDER_NOSCROLL)) { + this.listBoxBorder = new Skin(combo, Part.LBCP_BORDER_NOSCROLL); + this.setBorder(new EmptyBorder(1,1,1,1)); + } + } + + protected KeyListener createKeyListener() { + return new InvocationKeyHandler(); + } + + protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler { + protected InvocationKeyHandler() { + WinComboPopUp.this.super(); + } + } + + protected void paintComponent(Graphics g) { + super.paintComponent(g); + if (this.listBoxBorder != null) { + this.listBoxBorder.paintSkinRaw(g, this.getX(), this.getY(), + this.getWidth(), this.getHeight(), State.HOT); + } + } + } + /** * Subclassed to highlight selected item in an editable combo box. @@ -498,6 +562,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { protected JTextField createEditorComponent() { JTextField editor = super.createEditorComponent(); Border border = (Border)UIManager.get("ComboBox.editorBorder"); + if (border != null) { editor.setBorder(border); } @@ -524,6 +589,31 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { private static final Object BORDER_KEY = new StringUIClientPropertyKey("BORDER_KEY"); private static final Border NULL_BORDER = new EmptyBorder(0, 0, 0, 0); + + // Create own version of DashedBorder with more space on left side + private class WindowsComboBoxDashedBorder extends DashedBorder { + + public WindowsComboBoxDashedBorder(Color color, int thickness) { + super(color, thickness); + } + + public WindowsComboBoxDashedBorder(Color color) { + super(color); + } + + @Override + public Insets getBorderInsets(Component c, Insets i) { + return new Insets(0,2,0,0); + } + } + + public WindowsComboBoxRenderer() { + super(); + + // correct space on the left side of text items in the combo popup list + Insets i = getBorder().getBorderInsets(this); + setBorder(new EmptyBorder(0, 2, 0, i.right)); + } /** * {@inheritDoc} */ @@ -542,7 +632,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { if (index == -1 && isSelected) { Border border = component.getBorder(); Border dashedBorder = - new WindowsBorders.DashedBorder(list.getForeground()); + new WindowsComboBoxDashedBorder(list.getForeground()); component.setBorder(dashedBorder); //store current border in client property if needed if (component.getClientProperty(BORDER_KEY) == null) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java index 598b0815ad0..fa50e94ec92 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java @@ -672,7 +672,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel "ComboBox.buttonHighlight", ControlHighlightColor, "ComboBox.selectionBackground", SelectionBackgroundColor, "ComboBox.selectionForeground", SelectionTextColor, - "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,2,1,1), + "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,4,1,1), new EmptyBorder(1,4,1,4)), "ComboBox.disabledBackground", new XPColorValue(Part.CP_COMBOBOX, State.DISABLED, diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java index 8f730949684..be22c7300da 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java @@ -165,8 +165,11 @@ public class WindowsRootPaneUI extends BasicRootPaneUI { } public boolean postProcessKeyEvent(KeyEvent ev) { - if(ev.isConsumed()) { - // do not manage consumed event + if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) { + // mnemonic combination, it's consumed, but we need + // set altKeyPressed to false, otherwise after selection + // component by mnemonic combination a menu will be open + altKeyPressed = false; return false; } if (ev.getKeyCode() == KeyEvent.VK_ALT) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java index 30f348d9770..eb8080ba3c9 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java @@ -63,6 +63,7 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI { private boolean contentOpaque = true; + @SuppressWarnings("deprecation") protected void installDefaults() { super.installDefaults(); contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque"); diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java index 0dbe039f54c..2c60209186f 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014, 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 @@ -127,7 +127,7 @@ class XPStyle { * * @param part a Part * @param state a String - * @param attributeKey a String + * @param prop a String * @return a String or null if key is not found * in the current style * @@ -172,7 +172,6 @@ class XPStyle { /** Get a named Dimension value from the current style * - * @param key a String * @return a Dimension or null if key is not found * in the current style * @@ -189,7 +188,6 @@ class XPStyle { /** Get a named Point (e.g. a location or an offset) value * from the current style * - * @param key a String * @return a Point or null if key is not found * in the current style * @@ -205,7 +203,6 @@ class XPStyle { /** Get a named Insets value from the current style * - * @param key a String * @return an Insets object or null if key is not found * in the current style * @@ -223,7 +220,6 @@ class XPStyle { /** Get a named Color value from the current style * - * @param part a Part * @return a Color or null if key is not found * in the current style */ @@ -479,6 +475,7 @@ class XPStyle { private final String string; private Dimension size = null; + private boolean switchStates = false; Skin(Component component, Part part) { this(component, part, null); @@ -513,6 +510,14 @@ class XPStyle { return (insets != null) ? insets : new Insets(0, 0, 0, 0); } + boolean haveToSwitchStates() { + return switchStates; + } + + void switchStates(boolean b) { + switchStates = b; + } + private int getWidth(State state) { if (size == null) { size = getPartSize(part, state); @@ -689,7 +694,7 @@ class XPStyle { @SuppressWarnings("serial") // Superclass is not serializable across versions static class GlyphButton extends JButton { - private Skin skin; + protected Skin skin; public GlyphButton(Component parent, Part part) { XPStyle xp = getXP(); diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java index 672b76f926b..bea9f5daf24 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.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 @@ -444,6 +444,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice * close this device if discarded by the garbage collector. */ @Override + @SuppressWarnings("deprecation") protected final void finalize() { close(); } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMixer.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMixer.java index 7389e8dbeac..c040c558419 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMixer.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AbstractMixer.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 @@ -90,7 +90,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Constructs a new AbstractMixer. - * @param mixer the mixer with which this line is associated + * @param mixerInfo the mixer with which this line is associated * @param controls set of supported controls */ protected AbstractMixer(Mixer.Info mixerInfo, diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java index b7d292a57e5..4f01291c22d 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 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 @@ -27,6 +27,7 @@ package com.sun.media.sound; import java.util.Map; +import javax.sound.midi.MidiSystem; import javax.sound.midi.MidiUnavailableException; import javax.sound.midi.Synthesizer; import javax.sound.sampled.AudioFormat; diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java index 7553353153a..ef995f81294 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.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 @@ -163,7 +163,6 @@ abstract class SunFileReader extends AudioFileReader { * rllong * Protected helper method to read 64 bits and changing the order of * each bytes. - * @param DataInputStream * @return 32 bits swapped value. * @exception IOException */ @@ -187,7 +186,6 @@ abstract class SunFileReader extends AudioFileReader { /** * big2little * Protected helper method to swap the order of bytes in a 32 bit int - * @param int * @return 32 bits swapped value */ final int big2little(int i) { @@ -207,7 +205,6 @@ abstract class SunFileReader extends AudioFileReader { /** * rlshort * Protected helper method to read 16 bits value. Swap high with low byte. - * @param DataInputStream * @return the swapped value. * @exception IOException */ @@ -229,7 +226,6 @@ abstract class SunFileReader extends AudioFileReader { /** * big2little * Protected helper method to swap the order of bytes in a 16 bit short - * @param int * @return 16 bits swapped value */ final short big2littleShort(short i) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileWriter.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileWriter.java index 50b200fa75e..9e78425c865 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileWriter.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileWriter.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 @@ -69,7 +69,6 @@ abstract class SunFileWriter extends AudioFileWriter { * rllong * Protected helper method to read 64 bits and changing the order of * each bytes. - * @param DataInputStream * @return 32 bits swapped value. * @exception IOException */ @@ -93,7 +92,6 @@ abstract class SunFileWriter extends AudioFileWriter { /** * big2little * Protected helper method to swap the order of bytes in a 32 bit int - * @param int * @return 32 bits swapped value */ final int big2little(int i) { @@ -113,7 +111,6 @@ abstract class SunFileWriter extends AudioFileWriter { /** * rlshort * Protected helper method to read 16 bits value. Swap high with low byte. - * @param DataInputStream * @return the swapped value. * @exception IOException */ @@ -135,7 +132,6 @@ abstract class SunFileWriter extends AudioFileWriter { /** * big2little * Protected helper method to swap the order of bytes in a 16 bit short - * @param int * @return 16 bits swapped value */ final short big2littleShort(short i) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.java index 1b903a3bcf1..2105248c907 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.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 @@ -54,7 +54,7 @@ public final class Toolkit { /** * Swaps bytes. - * @throws ArrayOutOfBoundsException if len is not a multiple of 2. + * @throws ArrayIndexOutOfBoundsException if len is not a multiple of 2. */ static void getByteSwapped(byte[] b, int off, int len) { diff --git a/jdk/src/java.desktop/share/classes/java/applet/package-info.java b/jdk/src/java.desktop/share/classes/java/applet/package-info.java new file mode 100644 index 00000000000..351a58be015 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/applet/package-info.java @@ -0,0 +1,49 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides the classes necessary to create an applet and the classes an applet + * uses to communicate with its applet context. + *

              + * The applet framework involves two entities: the applet and the + * applet context. An applet is an embeddable window (see the Panel + * class) with a few extra methods that the applet context can use to + * initialize, start, and stop the applet. + *

              + * The applet context is an application that is responsible for loading and + * running applets. For example, the applet context could be a Web browser or an + * applet development environment. + *

              + * The APIs in this package are all deprecated. Alternative technologies such as + * Java Web Start or installable applications should be used instead. + * See JEP 289 and + * the Oracle White Paper + * + * "Migrating from Java Applets to plugin-free Java technologies" for more + * information. + * + * @since 1.0 + */ +package java.applet; diff --git a/jdk/src/java.desktop/share/classes/java/applet/package.html b/jdk/src/java.desktop/share/classes/java/applet/package.html deleted file mode 100644 index a95395b900e..00000000000 --- a/jdk/src/java.desktop/share/classes/java/applet/package.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -Provides the classes necessary to create an applet and the classes an applet -uses to communicate with its applet context. -

              -The applet framework involves two -entities: the applet and the applet context. An applet is an -embeddable window (see the Panel class) with a few extra methods that the applet -context can use to initialize, start, and stop the applet. -

              -The applet context is an application that is responsible for loading and running -applets. For example, the applet context could be a Web browser or an applet -development environment. -

              -The APIs in this package are all deprecated. Alternative technologies such as Java Web Start -or installable applications should be used instead. See JEP 289 -and the Oracle White Paper -"Migrating from Java Applets to plugin-free Java technologies" for more information. -

              - - -@since 1.0 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java index 9250597ac81..fe0b169b467 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java @@ -292,8 +292,12 @@ public abstract class AWTEvent extends EventObject { /** * Constructs an AWTEvent object from the parameters of a 1.0-style event. + * * @param event the old-style event + * @deprecated It is recommended that {@link #AWTEvent(Object, int)} be used + * instead */ + @Deprecated(since = "9") public AWTEvent(Event event) { this(event.target, event.id); } @@ -436,6 +440,7 @@ public abstract class AWTEvent extends EventObject { * event class in java.awt.event because we don't want to make * it public and it needs to be called from java.awt. */ + @SuppressWarnings("deprecation") Event convertToOld() { Object src = getSource(); int newid = id; diff --git a/jdk/src/java.desktop/share/classes/java/awt/AWTKeyStroke.java b/jdk/src/java.desktop/share/classes/java/awt/AWTKeyStroke.java index 6e85f2b1bbf..075d5a6ebbc 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/AWTKeyStroke.java +++ b/jdk/src/java.desktop/share/classes/java/awt/AWTKeyStroke.java @@ -350,6 +350,7 @@ public class AWTKeyStroke implements Serializable { * @throws NullPointerException if {@code anEvent} is null * @return the {@code AWTKeyStroke} that precipitated the event */ + @SuppressWarnings("deprecation") public static AWTKeyStroke getAWTKeyStrokeForEvent(KeyEvent anEvent) { int id = anEvent.getID(); switch(id) { @@ -397,6 +398,7 @@ public class AWTKeyStroke implements Serializable { * @throws IllegalArgumentException if {@code s} is {@code null}, * or is formatted incorrectly */ + @SuppressWarnings("deprecation") public static AWTKeyStroke getAWTKeyStroke(String s) { if (s == null) { throw new IllegalArgumentException("String cannot be null"); @@ -708,6 +710,7 @@ public class AWTKeyStroke implements Serializable { } } + @SuppressWarnings("deprecation") private static int mapOldModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_MASK) != 0) { modifiers |= InputEvent.SHIFT_DOWN_MASK; @@ -737,6 +740,7 @@ public class AWTKeyStroke implements Serializable { return modifiers; } + @SuppressWarnings("deprecation") private static int mapNewModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { modifiers |= InputEvent.SHIFT_MASK; diff --git a/jdk/src/java.desktop/share/classes/java/awt/AlphaComposite.java b/jdk/src/java.desktop/share/classes/java/awt/AlphaComposite.java index dc650632d08..abf70255cd3 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/AlphaComposite.java +++ b/jdk/src/java.desktop/share/classes/java/awt/AlphaComposite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -74,7 +74,7 @@ import sun.java2d.SunCompositeContext; * *

              * - *
              Factor  Definition + *
              Factor  Definition *
              Asthe alpha component of the source pixel *
              Csa color component of the source pixel in premultiplied form *
              Adthe alpha component of the destination pixel @@ -114,7 +114,7 @@ import sun.java2d.SunCompositeContext; * *
              * - *
              Factor  Definition + *
              Factor  Definition *
              Csr one of the raw color components of the source pixel *
              Cdr one of the raw color components of the destination pixel *
              Aac the "extra" alpha component from the AlphaComposite instance @@ -205,7 +205,7 @@ import sun.java2d.SunCompositeContext; * appropriate conversions are performed before and after the compositing * operation. * - *

              Implementation Caveats

              + *

              Implementation Caveats

              * *
                *
              • diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java index dca2674c2fd..68588597f9c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Component.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Component.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 @@ -58,6 +58,7 @@ import java.security.AccessControlContext; import javax.accessibility.*; import java.applet.Applet; import javax.swing.JComponent; +import javax.swing.JRootPane; import sun.awt.ComponentFactory; import sun.security.action.GetPropertyAction; @@ -5036,6 +5037,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * * Returns whether or not event was dispatched to an ancestor */ + @SuppressWarnings("deprecation") boolean dispatchMouseWheelToAncestor(MouseWheelEvent e) { int newX, newY; newX = e.getX() + getX(); // Coordinates take into account at least @@ -6231,7 +6233,7 @@ public abstract class Component implements ImageObserver, MenuContainer, /** * Indicates whether a class or its superclasses override coalesceEvents. * Must be called with lock on coalesceMap and privileged. - * @see checkCoalescing + * @see #checkCoalescing */ private static boolean isCoalesceEventsOverriden(Class clazz) { assert Thread.holdsLock(coalesceMap); @@ -10379,7 +10381,11 @@ public abstract class Component implements ImageObserver, MenuContainer, } /** - * Sets a 'mixing-cutout' shape for the given component. + * Sets a 'mixing-cutout' shape for this lightweight component. + * + * This method is used exclusively for the purposes of the + * Heavyweight/Lightweight Components Mixing feature and will + * have no effect if applied to a heavyweight component. * * By default a lightweight component is treated as an opaque rectangle for * the purposes of the Heavyweight/Lightweight Components Mixing feature. @@ -10392,7 +10398,7 @@ public abstract class Component implements ImageObserver, MenuContainer, *
              • {@code null} - reverts the default cutout shape (the rectangle equal * to the component's {@code getBounds()}) *
              • empty-shape - does not cut out anything from heavyweight - * components. This makes the given lightweight component effectively + * components. This makes this lightweight component effectively * transparent. Note that descendants of the lightweight component still * affect the shapes of heavyweight components. An example of an * empty-shape is {@code new Rectangle()}. @@ -10401,21 +10407,16 @@ public abstract class Component implements ImageObserver, MenuContainer, *
              *

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

              - * Note that the 'mixing-cutout' shape neither affects painting, nor the - * mouse events handling for the given component. It is used exclusively - * for the purposes of the Heavyweight/Lightweight Components Mixing - * feature. * * @param shape the new 'mixing-cutout' shape * @since 9 */ - void setMixingCutoutShape(Shape shape) { + public void setMixingCutoutShape(Shape shape) { Region region = shape == null ? null : Region.getInstance(shape, null); synchronized (getTreeLock()) { diff --git a/jdk/src/java.desktop/share/classes/java/awt/Container.java b/jdk/src/java.desktop/share/classes/java/awt/Container.java index 13d5e23ed1c..e0bb5e0f5e7 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Container.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java @@ -4728,6 +4728,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { * Listen for drag events posted in other hw components so we can * track enter/exit regardless of where a drag originated */ + @SuppressWarnings("deprecation") public void eventDispatched(AWTEvent e) { boolean isForeignDrag = (e instanceof MouseEvent) && !(e instanceof SunDropTargetEvent) && @@ -4826,6 +4827,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { * If the target has been removed, we don't bother to send the * message. */ + @SuppressWarnings("deprecation") void retargetMouseEvent(Component target, int id, MouseEvent e) { if (target == null) { return; // mouse is over another hw component or target is disabled diff --git a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java b/jdk/src/java.desktop/share/classes/java/awt/Desktop.java index fac3def4de0..de415da2eb5 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Desktop.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 @@ -25,9 +25,12 @@ package java.awt; +import java.awt.desktop.AboutEvent; import java.awt.desktop.AboutHandler; import java.awt.desktop.OpenFilesHandler; +import java.awt.desktop.OpenURIEvent; import java.awt.desktop.OpenURIHandler; +import java.awt.desktop.PreferencesEvent; import java.awt.desktop.PreferencesHandler; import java.awt.desktop.PrintFilesHandler; import java.awt.desktop.QuitHandler; @@ -42,8 +45,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import sun.awt.SunToolkit; import javax.swing.JMenuBar; + +import sun.awt.SunToolkit; import sun.security.util.SecurityConstants; /** @@ -335,7 +339,7 @@ public class Desktop { * most of the platforms support the {@link Desktop.Action#OPEN} * action. But for a specific file, there may not be an * application registered to open it. In this case, {@link - * #isSupported} may return {@code true}, but the corresponding + * #isSupported(Action)} may return {@code true}, but the corresponding * action method will throw an {@link IOException}. * * @param action the specified {@link Action} @@ -720,7 +724,7 @@ public class Desktop { * default behavior. * * @param aboutHandler the handler to respond to the - * {@link java.awt.desktop.AboutHandler#handleAbout} )} message + * {@link java.awt.desktop.AboutHandler#handleAbout(AboutEvent)} message * * @throws SecurityException if a security manager exists and it * denies the @@ -828,7 +832,7 @@ public class Desktop { * open a URL. * * Setting the handler to {@code null} causes all - * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be + * {@link OpenURIHandler#openURI(OpenURIEvent)} requests to be * enqueued until another handler is set. * * @implNote Please note that for Mac OS, notifications @@ -988,8 +992,6 @@ public class Desktop { /** * Sets the default menu bar to use when there are no active frames. * - * @implNote Aqua Look and Feel should be active to support this on Mac OS. - * * @param menuBar to use when no other frames are active * @throws SecurityException if a security manager exists and it denies the * {@code RuntimePermission("canProcessApplicationEvents")} permission. diff --git a/jdk/src/java.desktop/share/classes/java/awt/Event.java b/jdk/src/java.desktop/share/classes/java/awt/Event.java index b00b09876ea..da33b237625 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Event.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Event.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 @@ -24,8 +24,7 @@ */ package java.awt; -import java.awt.event.*; -import java.io.*; +import java.awt.event.KeyEvent; /** * NOTE: The {@code Event} class is obsolete and is @@ -56,9 +55,12 @@ import java.io.*; * {@code Event} class ({@code PGUP}, * {@code PGDN}, {@code F1}, {@code F2}, etc). * + * @deprecated It is recommended that {@code AWTEvent} and its subclasses be + * used instead * @author Sami Shaio * @since 1.0 */ +@Deprecated(since = "9") public class Event implements java.io.Serializable { private transient long data; diff --git a/jdk/src/java.desktop/share/classes/java/awt/Font.java b/jdk/src/java.desktop/share/classes/java/awt/Font.java index 18046fd9ea3..2440a665c7c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Font.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Font.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, 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 @@ -41,6 +41,7 @@ import java.security.AccessController; import java.security.PrivilegedExceptionAction; import java.text.AttributedCharacterIterator.Attribute; import java.text.CharacterIterator; +import java.util.EventListener; import java.util.Hashtable; import java.util.Locale; import java.util.Map; diff --git a/jdk/src/java.desktop/share/classes/java/awt/Graphics.java b/jdk/src/java.desktop/share/classes/java/awt/Graphics.java index 932a89d5ade..317a93fad22 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Graphics.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Graphics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, 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 @@ -1159,8 +1159,18 @@ public abstract class Graphics { /** * Disposes of this graphics context once it is no longer referenced. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. * @see #dispose */ + @Deprecated(since="9") public void finalize() { dispose(); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/Graphics2D.java b/jdk/src/java.desktop/share/classes/java/awt/Graphics2D.java index ec5f9bd73bb..ed6f406b2f0 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Graphics2D.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Graphics2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, 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 @@ -78,7 +78,7 @@ import java.util.Map; *

              * When creating a {@code Graphics2D} object, the * {@code GraphicsConfiguration} - * specifies the default transform for + * specifies the default transform for * the target of the {@code Graphics2D} (a * {@link Component} or {@link Image}). This default transform maps the * user space coordinate system to screen and printer device coordinates @@ -129,7 +129,7 @@ import java.util.Map; * of their particular rendering processes are: *

                *
              1. - * {@code Shape} operations + * {@code Shape} operations *
                  *
                1. * If the operation is a {@code draw(Shape)} operation, then @@ -160,7 +160,7 @@ import java.util.Map; * colors to render in device space. *
                *
              2. - * Text operations + * Text operations *
                  *
                1. * The following steps are used to determine the set of glyphs required @@ -201,7 +201,7 @@ import java.util.Map; * the colors to render in device space. *
                *
              3. - * {@code Image} Operations + * {@code Image} Operations *
                  *
                1. * The region of interest is defined by the bounding box of the source diff --git a/jdk/src/java.desktop/share/classes/java/awt/GridBagLayout.java b/jdk/src/java.desktop/share/classes/java/awt/GridBagLayout.java index 1ecf40840ea..e17d85d73f1 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/GridBagLayout.java +++ b/jdk/src/java.desktop/share/classes/java/awt/GridBagLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, 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 @@ -122,7 +122,7 @@ import java.util.Arrays; * are not. Baseline relative values are calculated relative to the * baseline. Valid values are: * - *
                  * * @@ -198,7 +198,7 @@ import java.util.Arrays; * The following figure shows a baseline layout and includes a * component that spans rows: *

                  Absolute Values

                  - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * *
                  * The following text describes this graphic (Figure 1). @@ -252,15 +252,15 @@ import java.util.Arrays; * left-to-right container and Figure 3 shows the layout for a horizontal, * right-to-left container. * - *
                  - * + *
                  + * * * - * + * * * * diff --git a/jdk/src/java.desktop/share/classes/java/awt/GridLayout.java b/jdk/src/java.desktop/share/classes/java/awt/GridLayout.java index a5eab8ad9ab..f096fce0693 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/GridLayout.java +++ b/jdk/src/java.desktop/share/classes/java/awt/GridLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, 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 @@ -55,20 +55,20 @@ package java.awt; * If the container's {@code ComponentOrientation} property is horizontal * and right-to-left, the example produces the output shown in Figure 2. * - *
                  * The preceding text describes this graphic (Figure 1). * * The preceding text describes this graphic (Figure 2). *
                  Figure 2: Horizontal, Left-to-RightFigure 3: Horizontal, Right-to-Left
                  - * + *
                  + * * * - * * * - * + * * * * diff --git a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java index 1e9e2f4bfd0..f2fb6d2b7af 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java +++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java @@ -415,6 +415,7 @@ public abstract class KeyboardFocusManager * Initializes a KeyboardFocusManager. */ public KeyboardFocusManager() { + @SuppressWarnings("deprecation") AWTKeyStroke[][] defaultFocusTraversalKeyStrokes = { { AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0, false), diff --git a/jdk/src/java.desktop/share/classes/java/awt/LinearGradientPaint.java b/jdk/src/java.desktop/share/classes/java/awt/LinearGradientPaint.java index ad70a60ac0a..179405dfd11 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/LinearGradientPaint.java +++ b/jdk/src/java.desktop/share/classes/java/awt/LinearGradientPaint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, 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 @@ -91,10 +91,9 @@ import java.beans.ConstructorProperties; *

                  * This image demonstrates the example code above for each * of the three cycle methods: - *

                  + *

                  * image showing the output of the example code - *

                  * * @see java.awt.Paint * @see java.awt.Graphics2D#setPaint diff --git a/jdk/src/java.desktop/share/classes/java/awt/Menu.java b/jdk/src/java.desktop/share/classes/java/awt/Menu.java index 4bd1bba8a0e..acadfeb414e 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Menu.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Menu.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 @@ -29,7 +29,9 @@ import java.awt.event.KeyEvent; import java.awt.peer.MenuPeer; import java.io.IOException; import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.util.Enumeration; +import java.util.EventListener; import java.util.Vector; import javax.accessibility.Accessible; diff --git a/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java b/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java index 8d0d51d6360..6a6d3043bc4 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java +++ b/jdk/src/java.desktop/share/classes/java/awt/MenuBar.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 @@ -29,7 +29,9 @@ import java.awt.event.KeyEvent; import java.awt.peer.MenuBarPeer; import java.io.IOException; import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.util.Enumeration; +import java.util.EventListener; import java.util.Vector; import javax.accessibility.Accessible; @@ -44,7 +46,7 @@ import sun.awt.AWTAccessor; * the menu bar with a {@code Frame} object, call the * frame's {@code setMenuBar} method. *

                  - * + * * This is what a menu bar might look like: *

                  * 0); diff --git a/jdk/src/java.desktop/share/classes/java/awt/MenuShortcut.java b/jdk/src/java.desktop/share/classes/java/awt/MenuShortcut.java index 57526ff4e6d..0704b32c000 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/MenuShortcut.java +++ b/jdk/src/java.desktop/share/classes/java/awt/MenuShortcut.java @@ -180,6 +180,7 @@ public class MenuShortcut implements java.io.Serializable * @return a string representation of this MenuShortcut. * @since 1.1 */ + @SuppressWarnings("deprecation") public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { diff --git a/jdk/src/java.desktop/share/classes/java/awt/PaintContext.java b/jdk/src/java.desktop/share/classes/java/awt/PaintContext.java index faca59d2c8b..f1e93fd03cc 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/PaintContext.java +++ b/jdk/src/java.desktop/share/classes/java/awt/PaintContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2007, 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 @@ -25,8 +25,10 @@ package java.awt; -import java.awt.image.Raster; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; import java.awt.image.ColorModel; +import java.awt.image.Raster; /** * The {@code PaintContext} interface defines the encapsulated diff --git a/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java b/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java index 48460749d6e..7e8737a8310 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java +++ b/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java @@ -154,6 +154,7 @@ public class PopupMenu extends Menu { * parent's hierarchy * @exception RuntimeException if the parent is not showing on screen */ + @SuppressWarnings("deprecation") public void show(Component origin, int x, int y) { // Use localParent for thread safety. MenuContainer localParent = parent; diff --git a/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java b/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java index fcc6afebf2a..9012608584f 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java +++ b/jdk/src/java.desktop/share/classes/java/awt/PrintJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, 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 @@ -79,8 +79,18 @@ public abstract class PrintJob { /** * Ends this print job once it is no longer referenced. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. * @see #end */ + @Deprecated(since="9") public void finalize() { end(); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java b/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java index a58fdf6b8ad..51bea64a373 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java +++ b/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, 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 @@ -79,18 +79,18 @@ import java.beans.ConstructorProperties; * The gradient color proportions are equal for any particular line drawn * from the focus point. The following figure shows that the distance AB * is equal to the distance BC, and the distance AD is equal to the distance DE. - *

                  + *

                  * image showing the
  * distance AB=BC, and AD=DE - *

                  + *

                  * If the gradient and graphics rendering transforms are uniformly scaled and * the user sets the focus so that it coincides with the center of the circle, * the gradient color proportions are equal for any line drawn from the center. * The following figure shows the distances AB, BC, AD, and DE. They are all equal. - *

                  + *

                  * image showing the
  * distance of AB, BC, AD, and DE are all equal - *

                  + *

                  * Note that some minor variations in distances may occur due to sampling at * the granularity of a pixel. * If no cycle method is specified, {@code NO_CYCLE} will be chosen by @@ -116,11 +116,9 @@ import java.beans.ConstructorProperties; *

                  * This image demonstrates the example code above, with default * (centered) focus for each of the three cycle methods: - *

                  + *

                  * image showing the
  * output of the sameple code - *

                  - * *

                  * It is also possible to specify a non-centered focus point, as * in the following code: @@ -139,10 +137,9 @@ import java.beans.ConstructorProperties; *

                  * This image demonstrates the previous example code, with non-centered * focus for each of the three cycle methods: - *

                  + *

                  * image showing the
  * output of the sample code - *

                  * * @see java.awt.Paint * @see java.awt.Graphics2D#setPaint diff --git a/jdk/src/java.desktop/share/classes/java/awt/Rectangle.java b/jdk/src/java.desktop/share/classes/java/awt/Rectangle.java index fcc5cf3c729..ecc531c1473 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Rectangle.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Rectangle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, 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 @@ -39,7 +39,7 @@ import java.beans.Transient; * that create a {@code Rectangle}, and the methods that can modify * one, do not prevent setting a negative value for width or height. *

                  - * + * * A {@code Rectangle} whose width or height is exactly zero has location * along those axes with zero dimension, but is otherwise considered empty. * The {@link #isEmpty} method will return true for such a {@code Rectangle}. @@ -49,7 +49,7 @@ import java.beans.Transient; * will include the location of the {@code Rectangle} on that axis in the * result as if the {@link #add(Point)} method were being called. *

                  - * + * * A {@code Rectangle} whose width or height is negative has neither * location nor dimension along those axes with negative dimensions. * Such a {@code Rectangle} is treated as non-existent along those axes. diff --git a/jdk/src/java.desktop/share/classes/java/awt/Robot.java b/jdk/src/java.desktop/share/classes/java/awt/Robot.java index 8483ed35297..1f24684d093 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Robot.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Robot.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 @@ -27,6 +27,9 @@ package java.awt; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.awt.geom.AffineTransform; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.MultiResolutionImage; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.awt.image.DirectColorModel; @@ -38,6 +41,7 @@ import sun.awt.AWTPermissions; import sun.awt.ComponentFactory; import sun.awt.SunToolkit; import sun.awt.image.SunWritableRaster; +import sun.swing.SwingUtilities2; /** * This class is used to generate native system input events @@ -95,15 +99,14 @@ public class Robot { /** * Creates a Robot for the given screen device. Coordinates passed - * to Robot method calls like mouseMove and createScreenCapture will - * be interpreted as being in the same coordinate system as the - * specified screen. Note that depending on the platform configuration, - * multiple screens may either: + * to Robot method calls like mouseMove, getPixelColor and + * createScreenCapture will be interpreted as being in the same coordinate + * system as the specified screen. Note that depending on the platform + * configuration, multiple screens may either: *

                  - * This constructor is meant for the latter case. *

                  * If screen devices are reconfigured such that the coordinate system is * affected, the behavior of existing Robot objects is undefined. @@ -137,6 +140,7 @@ public class Robot { initLegalButtonMask(); } + @SuppressWarnings("deprecation") private static synchronized void initLegalButtonMask() { if (LEGAL_BUTTON_MASK != 0) return; @@ -390,6 +394,11 @@ public class Robot { * @return Color of the pixel */ public synchronized Color getPixelColor(int x, int y) { + AffineTransform tx = GraphicsEnvironment. + getLocalGraphicsEnvironment().getDefaultScreenDevice(). + getDefaultConfiguration().getDefaultTransform(); + x = (int) (x * tx.getScaleX()); + y = (int) (y * tx.getScaleY()); Color color = new Color(peer.getRGBPixel(x, y)); return color; } @@ -405,13 +414,70 @@ public class Robot { * @see AWTPermission */ public synchronized BufferedImage createScreenCapture(Rectangle screenRect) { + return createCompatibleImage(screenRect, false)[0]; + } + + /** + * Creates an image containing pixels read from the screen. + * This image does not include the mouse cursor. + * This method can be used in case there is a scaling transform + * from user space to screen (device) space. + * Typically this means that the display is a high resolution screen, + * although strictly it means any case in which there is such a transform. + * Returns a {@link java.awt.image.MultiResolutionImage}. + *

                  + * For a non-scaled display, the {@code MultiResolutionImage} + * will have one image variant: + *

                    + *
                  • Base Image with user specified size. + *
                  + *

                  + * For a high resolution display where there is a scaling transform, + * the {@code MultiResolutionImage} will have two image variants: + *

                    + *
                  • Base Image with user specified size. This is scaled from the screen. + *
                  • Native device resolution image with device size pixels. + *
                  + *

                  + * Example: + *

                  {@code
                  +     *      Image nativeResImage;
                  +     *      MultiResolutionImage mrImage = robot.createMultiResolutionScreenCapture(frame.getBounds());
                  +     *      List resolutionVariants = mrImage.getResolutionVariants();
                  +     *      if (resolutionVariants.size() > 1) {
                  +     *          nativeResImage = resolutionVariants.get(1);
                  +     *      } else {
                  +     *          nativeResImage = resolutionVariants.get(0);
                  +     *      }
                  +     * }
                  + * @param screenRect Rect to capture in screen coordinates + * @return The captured image + * @throws IllegalArgumentException if {@code screenRect} width and height are not greater than zero + * @throws SecurityException if {@code readDisplayPixels} permission is not granted + * @see SecurityManager#checkPermission + * @see AWTPermission + * + * @since 9 + */ + public synchronized MultiResolutionImage + createMultiResolutionScreenCapture(Rectangle screenRect) { + + return new BaseMultiResolutionImage( + createCompatibleImage(screenRect, true)); + } + + private synchronized BufferedImage[] + createCompatibleImage(Rectangle screenRect, boolean isHiDPI) { + checkScreenCaptureAllowed(); checkValidRect(screenRect); - BufferedImage image; + BufferedImage lowResolutionImage; + BufferedImage highResolutionImage; DataBufferInt buffer; WritableRaster raster; + BufferedImage[] imageArray; if (screenCapCM == null) { /* @@ -421,31 +487,98 @@ public class Robot { */ screenCapCM = new DirectColorModel(24, - /* red mask */ 0x00FF0000, - /* green mask */ 0x0000FF00, - /* blue mask */ 0x000000FF); + /* red mask */ 0x00FF0000, + /* green mask */ 0x0000FF00, + /* blue mask */ 0x000000FF); } + int[] bandmasks = new int[3]; + bandmasks[0] = screenCapCM.getRedMask(); + bandmasks[1] = screenCapCM.getGreenMask(); + bandmasks[2] = screenCapCM.getBlueMask(); + // need to sync the toolkit prior to grabbing the pixels since in some // cases rendering to the screen may be delayed Toolkit.getDefaultToolkit().sync(); + GraphicsConfiguration gc = GraphicsEnvironment + .getLocalGraphicsEnvironment() + .getDefaultScreenDevice(). + getDefaultConfiguration(); + gc = SwingUtilities2.getGraphicsConfigurationAtPoint( + gc, screenRect.getCenterX(), screenRect.getCenterY()); + + AffineTransform tx = gc.getDefaultTransform(); + double uiScaleX = tx.getScaleX(); + double uiScaleY = tx.getScaleY(); int pixels[]; - int[] bandmasks = new int[3]; - pixels = peer.getRGBPixels(screenRect); - buffer = new DataBufferInt(pixels, pixels.length); + if (uiScaleX == 1 && uiScaleY == 1) { - bandmasks[0] = screenCapCM.getRedMask(); - bandmasks[1] = screenCapCM.getGreenMask(); - bandmasks[2] = screenCapCM.getBlueMask(); + pixels = peer.getRGBPixels(screenRect); + buffer = new DataBufferInt(pixels, pixels.length); - raster = Raster.createPackedRaster(buffer, screenRect.width, screenRect.height, screenRect.width, bandmasks, null); - SunWritableRaster.makeTrackable(buffer); + bandmasks[0] = screenCapCM.getRedMask(); + bandmasks[1] = screenCapCM.getGreenMask(); + bandmasks[2] = screenCapCM.getBlueMask(); - image = new BufferedImage(screenCapCM, raster, false, null); + raster = Raster.createPackedRaster(buffer, screenRect.width, + screenRect.height, screenRect.width, bandmasks, null); + SunWritableRaster.makeTrackable(buffer); - return image; + highResolutionImage = new BufferedImage(screenCapCM, raster, + false, null); + imageArray = new BufferedImage[1]; + imageArray[0] = highResolutionImage; + + } else { + + int sX = (int) Math.floor(screenRect.x * uiScaleX); + int sY = (int) Math.floor(screenRect.y * uiScaleY); + int sWidth = (int) Math.ceil(screenRect.width * uiScaleX); + int sHeight = (int) Math.ceil(screenRect.height * uiScaleY); + int temppixels[]; + Rectangle scaledRect = new Rectangle(sX, sY, sWidth, sHeight); + temppixels = peer.getRGBPixels(scaledRect); + + // HighResolutionImage + pixels = temppixels; + buffer = new DataBufferInt(pixels, pixels.length); + raster = Raster.createPackedRaster(buffer, scaledRect.width, + scaledRect.height, scaledRect.width, bandmasks, null); + SunWritableRaster.makeTrackable(buffer); + + highResolutionImage = new BufferedImage(screenCapCM, raster, + false, null); + + + // LowResolutionImage + lowResolutionImage = new BufferedImage(screenRect.width, + screenRect.height, highResolutionImage.getType()); + Graphics2D g = lowResolutionImage.createGraphics(); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g.setRenderingHint(RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_QUALITY); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g.drawImage(highResolutionImage, 0, 0, + screenRect.width, screenRect.height, + 0, 0, scaledRect.width, scaledRect.height, null); + g.dispose(); + + if(!isHiDPI) { + imageArray = new BufferedImage[1]; + imageArray[0] = lowResolutionImage; + } else { + imageArray = new BufferedImage[2]; + imageArray[0] = lowResolutionImage; + imageArray[1] = highResolutionImage; + } + + } + + return imageArray; } private static void checkValidRect(Rectangle rect) { diff --git a/jdk/src/java.desktop/share/classes/java/awt/Shape.java b/jdk/src/java.desktop/share/classes/java/awt/Shape.java index 209063c46a2..d8c385f200c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Shape.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Shape.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, 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 @@ -43,7 +43,7 @@ import java.awt.geom.Rectangle2D; * object that describes the trajectory path of the {@code Shape} * outline. *

                  - * Definition of insideness: + * Definition of insideness: * A point is considered to lie inside a * {@code Shape} if and only if: *

                    diff --git a/jdk/src/java.desktop/share/classes/java/awt/SystemTray.java b/jdk/src/java.desktop/share/classes/java/awt/SystemTray.java index 46ed1ff807c..0a7e44bb656 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/SystemTray.java +++ b/jdk/src/java.desktop/share/classes/java/awt/SystemTray.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 @@ -25,15 +25,17 @@ package java.awt; -import java.util.Vector; +import java.awt.event.ActionListener; import java.awt.peer.SystemTrayPeer; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; -import sun.awt.AppContext; -import sun.awt.SunToolkit; -import sun.awt.HeadlessToolkit; +import java.util.Vector; + import sun.awt.AWTAccessor; import sun.awt.AWTPermissions; +import sun.awt.AppContext; +import sun.awt.HeadlessToolkit; +import sun.awt.SunToolkit; /** * The {@code SystemTray} class represents the system tray for a diff --git a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java index 112ccb59001..82a64d0f380 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java @@ -274,6 +274,10 @@ public class Taskbar { /** * Requests user attention to the specified window. * + * Has no effect if a window representation is not displayable in + * the task area. Whether it is displayable is dependent on all + * of window type, platform, and implementation. + * * @param w window * @throws SecurityException if a security manager exists and it denies the * {@code RuntimePermission("canProcessApplicationEvents")} permission. @@ -375,6 +379,10 @@ public class Taskbar { * for the specified window. * It may be disabled by system settings. * + * Has no effect if a window representation is not displayable in + * the task area. Whether it is displayable is dependent on all + * of window type, platform, and implementation. + * * @param w window to update * @param badge image to affix to the icon * @throws SecurityException if a security manager exists and it denies the @@ -409,6 +417,11 @@ public class Taskbar { /** * Displays a determinate progress bar in the task area for the specified * window. + * + * Has no effect if a window representation is not displayable in + * the task area. Whether it is displayable is dependent on all + * of window type, platform, and implementation. + * *
                    * The visual behavior is platform and {@link State} dependent. *
                    @@ -437,6 +450,10 @@ public class Taskbar { /** * Sets a progress state for a specified window. + * + * Has no effect if a window representation is not displayable in + * the task area. Whether it is displayable is dependent on all + * of window type, platform, and implementation. *
                    * Each state displays a progress in a platform-dependent way. *
                    diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java index f4bfd11072e..baa74568fcb 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.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 @@ -451,7 +451,7 @@ public abstract class Toolkit { * * @param s the error message * @param e the original exception - * @throws the new AWTError including the cause (the original exception) + * @throws AWTError the new AWTError including the cause (the original exception) */ private static void newAWTError(Throwable e, String s) { AWTError newAWTError = new AWTError(s); @@ -1067,6 +1067,7 @@ public abstract class Toolkit { * @see java.awt.MenuShortcut * @since 1.1 */ + @SuppressWarnings("deprecation") public int getMenuShortcutKeyMask() throws HeadlessException { GraphicsEnvironment.checkHeadless(); diff --git a/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java b/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java index 3adc80fa59f..f3c11c0b4ce 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java +++ b/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.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 @@ -751,7 +751,17 @@ public class ICC_Profile implements Serializable { /** * Frees the resources associated with an ICC_Profile object. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize () { if (cmmProfile != null) { CMSManager.getModule().freeProfile(cmmProfile); @@ -1071,7 +1081,7 @@ public class ICC_Profile implements Serializable { * when loading this profile. * If deferring is enabled, then the deferred activation * code will take care of access privileges. - * @see activateDeferredProfile() + * @see #activateDeferredProfile() */ static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi) { if (!ProfileDeferralMgr.deferring) { @@ -1864,7 +1874,8 @@ public class ICC_Profile implements Serializable { return PCMM.class.getResourceAsStream("profiles/" + fileName); } - }, null, new FilePermission("<>", "read")); + }, null, new FilePermission("<>", "read"), + new RuntimePermission("accessSystemModules")); } /** diff --git a/jdk/src/java.desktop/share/classes/java/awt/color/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/color/package-info.java new file mode 100644 index 00000000000..ea9d72f7e05 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/color/package-info.java @@ -0,0 +1,34 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes for color spaces. It contains an implementation of a color + * space based on the International Color Consortium (ICC) Profile Format + * Specification, Version 3.4, August 15, 1997. It also contains color profiles + * based on the ICC Profile Format Specification. + * + * @since 1.2 + */ +package java.awt.color; diff --git a/jdk/src/java.desktop/share/classes/java/awt/color/package.html b/jdk/src/java.desktop/share/classes/java/awt/color/package.html deleted file mode 100644 index 41fa95a2f8d..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/color/package.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - -Provides classes for color spaces. It contains an -implementation of a color space based on the International Color -Consortium (ICC) Profile Format Specification, Version 3.4, August 15, -1997. It also contains color profiles based on the ICC Profile Format -Specification. - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/AppForegroundEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppForegroundEvent.java index 9d7107b84db..d5442b5b18f 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/AppForegroundEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppForegroundEvent.java @@ -30,8 +30,8 @@ package java.awt.desktop; * Event sent when the application has become the foreground app, and when it is * no longer the foreground app. * - * @see AppForegroundListener#appRaisedToForeground(AppEvent.AppForegroundEvent) - * @see AppForegroundListener#appMovedToBackground(AppEvent.AppForegroundEvent) + * @see AppForegroundListener#appRaisedToForeground(AppForegroundEvent) + * @see AppForegroundListener#appMovedToBackground(AppForegroundEvent) * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/AppHiddenEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppHiddenEvent.java index 1a41cc271a3..39ac364ce63 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/AppHiddenEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppHiddenEvent.java @@ -29,8 +29,8 @@ package java.awt.desktop; /** * Event sent when the application has been hidden or shown. * - * @see AppHiddenListener#appHidden(AppEvent.AppHiddenEvent) - * @see AppHiddenListener#appUnhidden(AppEvent.AppHiddenEvent) + * @see AppHiddenListener#appHidden(AppHiddenEvent) + * @see AppHiddenListener#appUnhidden(AppHiddenEvent) * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/AppReopenedEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppReopenedEvent.java index 2e7f9f14be6..526cd872de8 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/AppReopenedEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/AppReopenedEvent.java @@ -29,7 +29,7 @@ package java.awt.desktop; /** * Event sent when the application is asked to re-open itself. * - * @see AppReopenedListener#appReopened(AppEvent.AppReopenedEvent) + * @see AppReopenedListener#appReopened(AppReopenedEvent) * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/FilesEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/FilesEvent.java index aa9b8aa82ad..5989a1b1f6e 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/FilesEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/FilesEvent.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 @@ -42,7 +42,6 @@ public class FilesEvent extends AppEvent { /** * Constructs a {@code FilesEvent} * @param files files - * @param searchTerm searchTerm */ FilesEvent(final List files) { this.files = files; diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenURIEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenURIEvent.java index 61b0aae7ee2..d29ce26ef45 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenURIEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/OpenURIEvent.java @@ -31,7 +31,7 @@ import java.net.URI; /** * Event sent when the app is asked to open a {@code URI}. * - * @see OpenURIHandler#openURI(AppEvent.OpenURIEvent) + * @see OpenURIHandler#openURI(OpenURIEvent) * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/PrintFilesEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/PrintFilesEvent.java index 0ec9d006395..c3e5a46c328 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/PrintFilesEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/PrintFilesEvent.java @@ -33,7 +33,7 @@ import java.util.List; /** * Event sent when the app is asked to print a list of files. * - * @see PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent) + * @see PrintFilesHandler#printFiles(PrintFilesEvent) * @since 9 */ public final class PrintFilesEvent extends FilesEvent { diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitEvent.java index ea9f4b48d7c..c0e1bd4b217 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/QuitEvent.java @@ -28,7 +28,7 @@ package java.awt.desktop; /** * Event sent when the application is asked to quit. * - * @see QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, QuitResponse) + * @see QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse) * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepEvent.java index 880187878e8..3f6505ccad0 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/ScreenSleepEvent.java @@ -28,8 +28,8 @@ package java.awt.desktop; * Event sent when the displays attached to the system enter and exit power save * sleep. * - * @see ScreenSleepListener#screenAboutToSleep(AppEvent.ScreenSleepEvent) - * @see ScreenSleepListener#screenAwoke(AppEvent.ScreenSleepEvent) + * @see ScreenSleepListener#screenAboutToSleep(ScreenSleepEvent) + * @see ScreenSleepListener#screenAwoke(ScreenSleepEvent) * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/SystemSleepEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/SystemSleepEvent.java index b9fab3bd137..b38b76d710b 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/SystemSleepEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/SystemSleepEvent.java @@ -28,8 +28,8 @@ package java.awt.desktop; /** * Event sent when the system enters and exits power save sleep. * - * @see SystemSleepListener#systemAboutToSleep(AppEvent.SystemSleepEvent) - * @see SystemSleepListener#systemAwoke(AppEvent.SystemSleepEvent) + * @see SystemSleepListener#systemAboutToSleep(SystemSleepEvent) + * @see SystemSleepListener#systemAwoke(SystemSleepEvent) * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/UserSessionEvent.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/UserSessionEvent.java index 5daca855d3e..aaf1ceace16 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/UserSessionEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/UserSessionEvent.java @@ -29,8 +29,8 @@ package java.awt.desktop; * * Some systems may provide a reason of a user session change. * - * @see UserSessionListener#userSessionActivated(AppEvent.UserSessionEvent) - * @see UserSessionListener#userSessionDeactivated(AppEvent.UserSessionEvent) + * @see UserSessionListener#userSessionActivated(UserSessionEvent) + * @see UserSessionListener#userSessionDeactivated(UserSessionEvent) * * @since 9 */ diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/desktop/package-info.java similarity index 76% rename from langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/package-info.java rename to jdk/src/java.desktop/share/classes/java/awt/desktop/package-info.java index 066f5e61472..7f74a1f2ed7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/package-info.java +++ b/jdk/src/java.desktop/share/classes/java/awt/desktop/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 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 @@ -24,14 +24,9 @@ */ /** - * The Taglet API provides a way to declare custom tags that can be - * used by the standard doclet. - * - *

                    - * Note: The declarations in this package supersede those - * in the older package {@code com.sun.tools.doclets}. - *

                    + * Provides interfaces and classes for interaction with various desktop + * capabilities. * * @since 9 */ -package jdk.javadoc.doclet.taglet; +package java.awt.desktop; diff --git a/jdk/src/java.desktop/share/classes/java/awt/desktop/package.html b/jdk/src/java.desktop/share/classes/java/awt/desktop/package.html deleted file mode 100644 index c0043f4fc64..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/desktop/package.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - -Provides interfaces and classes for interaction with various -desktop capabilities. - -@since 9 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java index 63ceb3f1706..1de393a51cb 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java +++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, 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 @@ -65,7 +65,7 @@ import sun.awt.ComponentFactory; * itself between the platform and the * listeners provided by the initiator of the drag operation. *

                    - * + * * By default, {@code DragSourceContext} sets the cursor as appropriate * for the current state of the drag and drop operation. For example, if * the user has chosen {@linkplain DnDConstants#ACTION_MOVE the move action}, diff --git a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java index b8d89d2b575..141603f1320 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceDragEvent.java @@ -281,6 +281,7 @@ public class DragSourceDragEvent extends DragSourceEvent { * The mouse modifiers have higher priority than overlaying key * modifiers. */ + @SuppressWarnings("deprecation") private void setNewModifiers() { if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK; @@ -305,6 +306,7 @@ public class DragSourceDragEvent extends DragSourceEvent { /** * Sets old modifiers by the new ones. */ + @SuppressWarnings("deprecation") private void setOldModifiers() { if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON1_MASK; diff --git a/jdk/src/java.desktop/share/classes/java/awt/dnd/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/dnd/package-info.java new file mode 100644 index 00000000000..c9561defd87 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/package-info.java @@ -0,0 +1,110 @@ +/* + * 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 + * 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. + */ + +/** + * Drag and Drop is a direct manipulation gesture found in many Graphical User + * Interface systems that provides a mechanism to transfer information between + * two entities logically associated with presentation elements in the GUI. + * Normally driven by a physical gesture of a human user using an appropriate + * input device, Drag and Drop provides both a mechanism to enable continuous + * feedback regarding the possible outcome of any subsequent data transfer to + * the user during navigation over the presentation elements in the GUI, and the + * facilities to provide for any subsequent data negotiation and transfer. + *

                    + * This package defines the classes and interfaces necessary to perform Drag and + * Drop operations in Java. It defines classes for the drag-source and the + * drop-target, as well as events for transferring the data being dragged. This + * package also provides a means for giving visual feedback to the user + * throughout the duration of the Drag and Drop operation. + *

                    + * A typical Drag and Drop operation can be decomposed into the following states + * (not entirely sequentially): + *

                      + *
                    • A {@code DragSource} comes into existence, associated with some + * presentation element ({@code Component}) in the GUI, to initiate a Drag + * and Drop of some potentially {@code Transferable} data.
                    • + *
                    • 1 or more {@code DropTarget}(s) come into/go out of existence, + * associated with presentation elements in the GUI (Components), + * potentially capable of consuming {@code Transferable} data types.
                    • + *
                    • A {@code DragGestureRecognizer} is obtained from the + * {@code DragSource} and is associated with a {@code Component} in order to + * track and identify any Drag initiating gesture by the user over the + * {@code Component}.
                    • + *
                    • A user makes a Drag gesture over the {@code Component}, which the + * registered {@code DragGestureRecognizer} detects, and notifies its + * {@code DragGestureListener} of. + *

                      + * Note: Although this API consistently refers to the stimulus for a drag + * and drop operation being a physical gesture by a human user, this does + * not preclude a programmatically driven DnD operation given the + * appropriate implementation of a {@code DragSource}. This package + * contains the abstract class {@code MouseDragGestureRecognizer} for + * recognizing mouse device gestures. Other abstract subclasses may be + * provided by the platform to support other input devices or particular + * {@code Component} class semantics.

                    • + *
                    • The {@code DragGestureListener} causes the {@code DragSource} to + * initiate the Drag and Drop operation on behalf of the user, perhaps + * animating the GUI Cursor and/or rendering an {@code Image} of the item(s) + * that are the subject of the operation.
                    • + *
                    • As the user gestures navigate over {@code Component}(s) in the GUI + * with associated {@code DropTarget}(s), the {@code DragSource} receives + * notifications in order to provide "Drag Over" feedback effects, and the + * {@code DropTarget}(s) receive notifications in order to provide + * "Drag Under" feedback effects based upon the operation(s) supported and + * the data type(s) involved.
                    • + *
                    + *

                    + * The gesture itself moves a logical cursor across the GUI hierarchy, + * intersecting the geometry of GUI Component(s), possibly resulting in the + * logical "Drag" cursor entering, crossing, and subsequently leaving + * {@code Component}(s) and associated {@code DropTarget}(s). + *

                    + * The {@code DragSource} object manifests "Drag Over" feedback to the user, in + * the typical case by animating the GUI {@code Cursor} associated with the + * logical cursor. + *

                    + * {@code DropTarget} objects manifest "Drag Under" feedback to the user, in the + * typical case, by rendering animations into their associated GUI + * {@code Component}(s) under the GUI Cursor. + *

                    + * The determination of the feedback effects, and the ultimate success or + * failure of the data transfer, should one occur, is parameterized as follows: + *

                      + *
                    • By the transfer "operation" selected by the user, and supported by + * both the {@code DragSource} and {@code DropTarget}: Copy, Move or + * Reference(link).
                    • + *
                    • By the intersection of the set of data types provided by the + * {@code DragSource} and the set of data types comprehensible by the + * {@code DropTarget}.
                    • + *
                    • When the user terminates the drag operation, normally resulting in a + * successful Drop, both the {@code DragSource} and {@code DropTarget} + * receive notifications that include, and result in the type negotiation + * and transfer of, the information associated with the {@code DragSource} + * via a {@code Transferable} object.
                    • + *
                    + * + * @since 1.2 + */ +package java.awt.dnd; diff --git a/jdk/src/java.desktop/share/classes/java/awt/dnd/package.html b/jdk/src/java.desktop/share/classes/java/awt/dnd/package.html deleted file mode 100644 index 467348506a5..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/dnd/package.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - -Drag and Drop is a direct manipulation gesture found in many Graphical -User Interface systems that provides a mechanism to transfer -information between two entities logically associated with presentation -elements in the GUI. Normally driven by a physical gesture of a -human user using an appropriate input device, Drag and Drop provides both -a mechanism to enable continuous feedback regarding the -possible outcome of any subsequent data transfer to the user during -navigation over the presentation elements in the GUI, and the facilities -to provide for any subsequent data negotiation and transfer. -

                    -This package defines the classes and interfaces necessary to perform Drag -and Drop operations in Java. It -defines classes for the drag-source and the drop-target, as well as -events for transferring the data being dragged. This package also provides -a means for giving visual feedback to the user throughout the -duration of the Drag and Drop operation. -

                    -A typical Drag and Drop operation can be decomposed into the following -states (not entirely sequentially): -

                      -
                    • A DragSource comes into existence, -associated with some presentation -element (Component) in the GUI, to initiate a Drag and Drop of -some potentially Transferable data. -

                      -
                    • 1 or more DropTarget(s) come into/go out of -existence, associated -with presentation elements in the GUI (Components), potentially -capable of consuming Transferable data types. -

                      -
                    • A DragGestureRecognizer is -obtained from the DragSource and is -associated with a Component in order -to track and identify any Drag -initiating gesture by the user over the Component. -

                      -
                    • A user makes a Drag gesture over the Component, -which the registered -DragGestureRecognizer detects, and notifies its -DragGestureListener of. -

                      -Note: Although this API consistently refers to the stimulus for a -drag and drop operation being a physical gesture by a human user, this -does not preclude a programmatically driven DnD operation given the -appropriate implementation of a DragSource. This package -contains the abstract class MouseDragGestureRecognizer for -recognizing mouse device gestures. Other abstract subclasses may be -provided by the platform to support other input devices or -particular Component class semantics. -

                      -

                    • The DragGestureListener causes the -DragSource to initiate the Drag -and Drop operation on behalf of the user, perhaps animating the -GUI Cursor and/or rendering an Image of the item(s) that are the -subject of the operation. -

                      -
                    • As the user gestures navigate over Component(s) -in the GUI with -associated DropTarget(s), the DragSource -receives notifications in order -to provide "Drag Over" feedback effects, and the DropTarget(s) -receive notifications in order to provide "Drag Under" feedback effects -based upon the operation(s) supported and the data type(s) involved. -
                    -

                    - -The gesture itself moves a logical cursor across the GUI hierarchy, -intersecting the geometry of GUI Component(s), possibly resulting in -the logical "Drag" cursor entering, crossing, and subsequently -leaving Component(s) and associated DropTarget(s). -

                    -The DragSource object manifests "Drag Over" feedback to the user, in the typical case by animating the GUI Cursor associated with the -logical cursor. -

                    -DropTarget objects manifest "Drag Under" feedback to the user, in -the typical case, by rendering animations into their associated GUI -Component(s) under the GUI Cursor. -

                    -The determination of the feedback effects, and the ultimate success -or failure of the data transfer, should one occur, is parameterized -as follows: -

                      -
                    • By the transfer "operation" selected by the user, and supported by -both the DragSource and DropTarget: Copy, Move or Reference(link). -

                      -
                    • By the intersection of the set of data types provided by the -DragSource and the set of data types comprehensible by the -DropTarget. -

                      -
                    • When the user terminates the drag operation, normally resulting in a -successful Drop, both the DragSource and DropTarget -receive -notifications that include, and result in the type negotiation and -transfer of, the information associated with the DragSource via a -Transferable object. -
                    - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/dnd/peer/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/dnd/peer/package-info.java new file mode 100644 index 00000000000..8505e24ea6a --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/peer/package-info.java @@ -0,0 +1,33 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides for interfacing with the underlying window system in order to access + * its platform-dependent drag-and-drop facilities. This package is only used by + * AWT toolkit developers. + * + * @since 1.2 + */ +package java.awt.dnd.peer; diff --git a/jdk/src/java.desktop/share/classes/java/awt/dnd/peer/package.html b/jdk/src/java.desktop/share/classes/java/awt/dnd/peer/package.html deleted file mode 100644 index 6c83292c2c6..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/dnd/peer/package.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -Provides for interfacing with the underlying window system -in order to access its platform-dependent drag-and-drop facilities. -This package is only used by AWT toolkit developers. - - -

                    Package Specification

                    - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### - - -

                    Related Documentation

                    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/ActionEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/ActionEvent.java index 6ce79554eeb..3d422453e51 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/ActionEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/ActionEvent.java @@ -26,7 +26,6 @@ package java.awt.event; import java.awt.AWTEvent; -import java.awt.Event; import java.lang.annotation.Native; /** @@ -63,25 +62,25 @@ public class ActionEvent extends AWTEvent { * The shift modifier. An indicator that the shift key was held * down during the event. */ - public static final int SHIFT_MASK = Event.SHIFT_MASK; + public static final int SHIFT_MASK = 1 << 0; /** * The control modifier. An indicator that the control key was held * down during the event. */ - public static final int CTRL_MASK = Event.CTRL_MASK; + public static final int CTRL_MASK = 1 << 1; /** * The meta modifier. An indicator that the meta key was held * down during the event. */ - public static final int META_MASK = Event.META_MASK; + public static final int META_MASK = 1 << 2; /** * The alt modifier. An indicator that the alt key was held * down during the event. */ - public static final int ALT_MASK = Event.ALT_MASK; + public static final int ALT_MASK = 1 << 3; /** @@ -274,6 +273,7 @@ public class ActionEvent extends AWTEvent { * * @return a string identifying the event and its associated command */ + @SuppressWarnings("deprecation") public String paramString() { String typeStr; switch(id) { diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java index ec9bd0be0a1..09a08a0d010 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,51 +62,76 @@ public abstract class InputEvent extends ComponentEvent { /** * The Shift key modifier constant. - * It is recommended that SHIFT_DOWN_MASK be used instead. + * + * @deprecated It is recommended that SHIFT_DOWN_MASK and + * {@link #getModifiersEx()} be used instead */ + @Deprecated(since = "9") public static final int SHIFT_MASK = Event.SHIFT_MASK; /** * The Control key modifier constant. - * It is recommended that CTRL_DOWN_MASK be used instead. + * + * @deprecated It is recommended that CTRL_DOWN_MASK and + * {@link #getModifiersEx()} be used instead */ + @Deprecated(since = "9") public static final int CTRL_MASK = Event.CTRL_MASK; /** * The Meta key modifier constant. - * It is recommended that META_DOWN_MASK be used instead. + * + * @deprecated It is recommended that META_DOWN_MASK and + * {@link #getModifiersEx()} be used instead */ + @Deprecated(since = "9") public static final int META_MASK = Event.META_MASK; /** * The Alt key modifier constant. - * It is recommended that ALT_DOWN_MASK be used instead. + * + * @deprecated It is recommended that ALT_DOWN_MASK and + * {@link #getModifiersEx()} be used instead */ + @Deprecated(since = "9") public static final int ALT_MASK = Event.ALT_MASK; /** * The AltGraph key modifier constant. + * + * @deprecated It is recommended that ALT_GRAPH_DOWN_MASK and + * {@link #getModifiersEx()} be used instead */ + @Deprecated(since = "9") public static final int ALT_GRAPH_MASK = 1 << 5; /** * The Mouse Button1 modifier constant. - * It is recommended that BUTTON1_DOWN_MASK be used instead. + * + * @deprecated It is recommended that BUTTON1_DOWN_MASK and + * {@link #getModifiersEx()} be used instead */ + @Deprecated(since = "9") public static final int BUTTON1_MASK = 1 << 4; /** * The Mouse Button2 modifier constant. - * It is recommended that BUTTON2_DOWN_MASK be used instead. - * Note that BUTTON2_MASK has the same value as ALT_MASK. + * + * @deprecated It is recommended that BUTTON2_DOWN_MASK and + * {@link #getModifiersEx()} be used instead. Note that + * BUTTON2_MASK has the same value as ALT_MASK. */ + @Deprecated(since = "9") public static final int BUTTON2_MASK = Event.ALT_MASK; /** * The Mouse Button3 modifier constant. - * It is recommended that BUTTON3_DOWN_MASK be used instead. - * Note that BUTTON3_MASK has the same value as META_MASK. + * + * @deprecated It is recommended that BUTTON3_DOWN_MASK and + * {@link #getModifiersEx()} be used instead. Note that + * BUTTON3_MASK has the same value as META_MASK. */ + @Deprecated(since = "9") public static final int BUTTON3_MASK = Event.META_MASK; /** @@ -159,7 +184,7 @@ public abstract class InputEvent extends ComponentEvent { /** * An array of extended modifiers for additional buttons. - * @see getButtonDownMasks + * @see #getButtonDownMasks() * There are twenty buttons fit into 4byte space. * one more bit is reserved for FIRST_HIGH_BIT. * @since 1.7 @@ -382,7 +407,7 @@ public abstract class InputEvent extends ComponentEvent { * @return whether or not the Shift modifier is down on this event */ public boolean isShiftDown() { - return (modifiers & SHIFT_MASK) != 0; + return (modifiers & SHIFT_DOWN_MASK) != 0; } /** @@ -390,7 +415,7 @@ public abstract class InputEvent extends ComponentEvent { * @return whether or not the Control modifier is down on this event */ public boolean isControlDown() { - return (modifiers & CTRL_MASK) != 0; + return (modifiers & CTRL_DOWN_MASK) != 0; } /** @@ -398,7 +423,7 @@ public abstract class InputEvent extends ComponentEvent { * @return whether or not the Meta modifier is down on this event */ public boolean isMetaDown() { - return (modifiers & META_MASK) != 0; + return (modifiers & META_DOWN_MASK) != 0; } /** @@ -406,7 +431,7 @@ public abstract class InputEvent extends ComponentEvent { * @return whether or not the Alt modifier is down on this event */ public boolean isAltDown() { - return (modifiers & ALT_MASK) != 0; + return (modifiers & ALT_DOWN_MASK) != 0; } /** @@ -414,7 +439,7 @@ public abstract class InputEvent extends ComponentEvent { * @return whether or not the AltGraph modifier is down on this event */ public boolean isAltGraphDown() { - return (modifiers & ALT_GRAPH_MASK) != 0; + return (modifiers & ALT_GRAPH_DOWN_MASK) != 0; } /** @@ -428,8 +453,12 @@ public abstract class InputEvent extends ComponentEvent { /** * Returns the modifier mask for this event. + * * @return the modifier mask for this event + * @deprecated It is recommended that extended modifier keys and + * {@link #getModifiersEx()} be used instead */ + @Deprecated(since = "9") public int getModifiers() { return modifiers & (JDK_1_3_MODIFIERS | HIGH_MODIFIERS); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java index 0ca378d556b..2c028901007 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java @@ -1169,6 +1169,7 @@ public class KeyEvent extends InputEvent { * @see #getKeyLocation() * @since 1.4 */ + @SuppressWarnings("deprecation") public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation) { super(source, id, when, modifiers); @@ -1561,7 +1562,10 @@ public class KeyEvent extends InputEvent { * @return string a text description of the combination of modifier * keys that were held down during the event * @see InputEvent#getModifiersExText(int) + * @deprecated It is recommended that extended modifier keys and + * {@link InputEvent#getModifiersExText(int)} be used instead */ + @Deprecated(since = "9") public static String getKeyModifiersText(int modifiers) { StringBuilder buf = new StringBuilder(); if ((modifiers & InputEvent.META_MASK) != 0) { @@ -1696,6 +1700,7 @@ public class KeyEvent extends InputEvent { * * @return a string identifying the event and its attributes */ + @SuppressWarnings("deprecation") public String paramString() { StringBuilder str = new StringBuilder(100); @@ -1821,6 +1826,7 @@ public class KeyEvent extends InputEvent { * Sets new modifiers by the old ones. The key modifiers * override overlapping mouse modifiers. */ + @SuppressWarnings("deprecation") private void setNewModifiers() { if ((modifiers & SHIFT_MASK) != 0) { modifiers |= SHIFT_DOWN_MASK; @@ -1845,6 +1851,7 @@ public class KeyEvent extends InputEvent { /** * Sets old modifiers by the new ones. */ + @SuppressWarnings("deprecation") private void setOldModifiers() { if ((modifiers & SHIFT_DOWN_MASK) != 0) { modifiers |= SHIFT_MASK; @@ -1871,6 +1878,7 @@ public class KeyEvent extends InputEvent { * override overlapping mouse modifiers. * @serial */ + @SuppressWarnings("deprecation") private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/MouseEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/MouseEvent.java index 2ae987b8144..a4e166844c0 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/MouseEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/MouseEvent.java @@ -733,6 +733,7 @@ public class MouseEvent extends InputEvent { * @see InputEvent#getMaskForButton(int) * @since 1.6 */ + @SuppressWarnings("deprecation") public MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger, int button) @@ -943,6 +944,7 @@ public class MouseEvent extends InputEvent { * @see InputEvent#getModifiersExText(int) * @since 1.4 */ + @SuppressWarnings("deprecation") public static String getMouseModifiersText(int modifiers) { StringBuilder buf = new StringBuilder(); if ((modifiers & InputEvent.ALT_MASK) != 0) { @@ -1007,6 +1009,7 @@ public class MouseEvent extends InputEvent { * * @return a string identifying the event and its attributes */ + @SuppressWarnings("deprecation") public String paramString() { StringBuilder str = new StringBuilder(80); @@ -1066,6 +1069,7 @@ public class MouseEvent extends InputEvent { * Sets new modifiers by the old ones. * Also sets button. */ + @SuppressWarnings("deprecation") private void setNewModifiers() { if ((modifiers & BUTTON1_MASK) != 0) { modifiers |= BUTTON1_DOWN_MASK; @@ -1120,6 +1124,7 @@ public class MouseEvent extends InputEvent { /** * Sets old modifiers by the new ones. */ + @SuppressWarnings("deprecation") private void setOldModifiers() { if (id == MOUSE_PRESSED || id == MOUSE_RELEASED @@ -1168,6 +1173,7 @@ public class MouseEvent extends InputEvent { * Sets new modifiers by the old ones. * @serial */ + @SuppressWarnings("deprecation") private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/event/package-info.java new file mode 100644 index 00000000000..c4dc383729f --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/event/package-info.java @@ -0,0 +1,37 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides interfaces and classes for dealing with different types of events + * fired by AWT components. See the {@link java.awt.AWTEvent java.awt.AWTEvent} + * class for details on the AWT event model. Events are fired by event sources. + * An event listener registers with an event source to receive notifications + * about the events of a particular type. This package defines events and event + * listeners, as well as event listener adapters, which are convenience classes + * to make easier the process of writing event listeners. + * + * @since 1.1 + */ +package java.awt.event; diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/package.html b/jdk/src/java.desktop/share/classes/java/awt/event/package.html deleted file mode 100644 index 0e2ae752b3e..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/event/package.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - -Provides interfaces and classes for dealing with different -types of events fired by AWT components. See the java.awt.AWTEvent -class for details on the AWT event model. Events are fired by event -sources. An event listener registers with an event source to receive -notifications about the events of a particular type. This package -defines events and event listeners, as well as event listener -adapters, which are convenience classes to make easier the process of -writing event listeners. - - - -@since 1.1 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/CharArrayIterator.java b/jdk/src/java.desktop/share/classes/java/awt/font/CharArrayIterator.java index 5c35beaa9f1..c7a00bdb67b 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/CharArrayIterator.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/CharArrayIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 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 @@ class CharArrayIterator implements CharacterIterator { * Sets the position to getBeginIndex() and returns the character at that * position. * @return the first character in the text, or DONE if the text is empty - * @see getBeginIndex + * @see #getBeginIndex */ public char first() { @@ -59,7 +59,7 @@ class CharArrayIterator implements CharacterIterator { * Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) * and returns the character at that position. * @return the last character in the text, or DONE if the text is empty - * @see getEndIndex + * @see #getEndIndex */ public char last() { @@ -76,7 +76,7 @@ class CharArrayIterator implements CharacterIterator { * Gets the character at the current position (as returned by getIndex()). * @return the character at the current position or DONE if the current * position is off the end of the text. - * @see getIndex + * @see #getIndex */ public char current() { diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/LineBreakMeasurer.java b/jdk/src/java.desktop/share/classes/java/awt/font/LineBreakMeasurer.java index 0467c0d24ca..079ee9ff55c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/LineBreakMeasurer.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/LineBreakMeasurer.java @@ -115,26 +115,27 @@ import java.awt.font.FontRenderContext; *
                    {@code
                      * public void paint(Graphics graphics) {
                      *
                    - *     Point2D pen = new Point2D(10, 20);
                    + *     float dx = 0f, dy = 5f;
                      *     Graphics2D g2d = (Graphics2D)graphics;
                      *     FontRenderContext frc = g2d.getFontRenderContext();
                      *
                    - *     // let styledText be an AttributedCharacterIterator containing at least
                    - *     // one character
                    + *     AttributedString text = new AttributedString(".....");
                    + *     AttributedCharacterIterator paragraph = text.getIterator();
                      *
                    - *     LineBreakMeasurer measurer = new LineBreakMeasurer(styledText, frc);
                    - *     float wrappingWidth = getSize().width - 15;
                    + *     LineBreakMeasurer measurer = new LineBreakMeasurer(paragraph, frc);
                    + *     measurer.setPosition(paragraph.getBeginIndex());
                    + *     float wrappingWidth = (float)getSize().width;
                      *
                    - *     while (measurer.getPosition() < fStyledText.length()) {
                    + *     while (measurer.getPosition() < paragraph.getEndIndex()) {
                      *
                      *         TextLayout layout = measurer.nextLayout(wrappingWidth);
                      *
                    - *         pen.y += (layout.getAscent());
                    + *         dy += (layout.getAscent());
                      *         float dx = layout.isLeftToRight() ?
                      *             0 : (wrappingWidth - layout.getAdvance());
                      *
                    - *         layout.draw(graphics, pen.x + dx, pen.y);
                    - *         pen.y += layout.getDescent() + layout.getLeading();
                    + *         layout.draw(graphics, dx, dy);
                    + *         dy += layout.getDescent() + layout.getLeading();
                      *     }
                      * }
                      * }
                    diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java index c9ae83659f6..d9170d18ab5 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -96,14 +96,14 @@ import jdk.internal.misc.SharedSecrets; *
                  * *

                  Summary of attributes

                  - *
                  Shows 6 buttons in rows of 2. Row 1 shows buttons 1 then 2.
  * Row 2 shows buttons 3 then 4. Row 3 shows buttons 5 then 6. * Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
+ * <td style=Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
  * Row 2 shows buttons 4 then 3. Row 3 shows buttons 6 then 5. *
                  Figure 1: Horizontal, Left-to-RightFigure 2: Horizontal, Right-to-Left
                  * - * - * - * - * + * + * + * + * * * * diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/font/package-info.java new file mode 100644 index 00000000000..6cdcd3dc367 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/font/package-info.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes and interface relating to fonts. It contains support for + * representing Type 1, Type 1 Multiple Master fonts, OpenType fonts, and + * TrueType fonts. + * + * @since 1.2 + */ +package java.awt.font; diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/package.html b/jdk/src/java.desktop/share/classes/java/awt/font/package.html deleted file mode 100644 index 22e71ba1c59..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/font/package.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - -Provides classes and interface relating to fonts. It -contains support for representing Type 1, Type 1 Multiple Master -fonts, OpenType fonts, and TrueType fonts. - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java b/jdk/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java index 019abbeb5c1..4bdb3d189f2 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java +++ b/jdk/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, 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 @@ -46,7 +46,7 @@ import java.beans.ConstructorProperties; * [ y'] = [ m10 m11 m12 ] [ y ] = [ m10x + m11y + m12 ] * [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ] * - *

                  Handling 90-Degree Rotations

                  + *

                  Handling 90-Degree Rotations

                  *

                  * In some variations of the {@code rotate} methods in the * {@code AffineTransform} class, a double-precision argument diff --git a/jdk/src/java.desktop/share/classes/java/awt/geom/Arc2D.java b/jdk/src/java.desktop/share/classes/java/awt/geom/Arc2D.java index c5bb52aca24..00e553bbbbb 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/geom/Arc2D.java +++ b/jdk/src/java.desktop/share/classes/java/awt/geom/Arc2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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,11 +33,11 @@ import java.io.Serializable; * start angle, angular extent (length of the arc), and a closure type * ({@code OPEN}, {@code CHORD}, or {@code PIE}). *

                  - * + * * The arc is a partial section of a full ellipse which * inscribes the framing rectangle of its parent {@link RectangularShape}. * - * + * * The angles are specified relative to the non-square * framing rectangle such that 45 degrees always falls on the line from * the center of the ellipse to the upper right corner of the framing diff --git a/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.java b/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.java index e93b9e32ac8..98f70b7eb8a 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.java +++ b/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.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 @@ -31,12 +31,7 @@ import java.io.Serializable; /** * This {@code Line2D} represents a line segment in {@code (x,y)} - * coordinate space. This class, like all of the Java 2D API, uses a - * default coordinate system called user space in which the y-axis - * values increase downward and x-axis values increase to the right. For - * more information on the user space coordinate system, see the - * - * Coordinate Systems section of the Java 2D Programmer's Guide. + * coordinate space. *

                  * This class is only the abstract superclass for all objects that * store a 2D line segment. @@ -623,7 +618,7 @@ public abstract class Line2D implements Shape, Cloneable { * specified line segment * @param y2 the Y coordinate of the end point of the * specified line segment - * @return {@code } if this line segment and the specified line segment + * @return {@code true} if this line segment and the specified line segment * intersect each other; {@code false} otherwise. * @since 1.2 */ diff --git a/jdk/src/java.desktop/share/classes/java/awt/geom/Path2D.java b/jdk/src/java.desktop/share/classes/java/awt/geom/Path2D.java index 9ef2bb1bfd8..08df1a7451d 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/geom/Path2D.java +++ b/jdk/src/java.desktop/share/classes/java/awt/geom/Path2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, 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 @@ -846,7 +846,7 @@ public abstract class Path2D implements Shape, Cloneable { * path. * * @serialData - * + * *

                    *
                  1. The default serializable fields. * There are no default serializable fields as of 1.6. @@ -1605,7 +1605,7 @@ public abstract class Path2D implements Shape, Cloneable { * path. * * @serialData - * + * *
                      *
                    1. The default serializable fields. * There are no default serializable fields as of 1.6. diff --git a/jdk/src/java.desktop/share/classes/java/awt/geom/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/geom/package-info.java new file mode 100644 index 00000000000..2ef69baf446 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/geom/package-info.java @@ -0,0 +1,41 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides the Java 2D classes for defining and performing operations on + * objects related to two-dimensional geometry. Some important features of the + * package include: + *
                        + *
                      • classes for manipulating geometry, such as AffineTransform and the + * PathIterator interface which is implemented by all Shape objects.
                      • + *
                      • classes that implement the Shape interface, such as CubicCurve2D, + * Ellipse2D, Line2D, Rectangle2D, and GeneralShape.
                      • + *
                      • the Area class which provides mechanisms for add (union), subtract, + * intersect, and exclusiveOR operations on other Shape objects.
                      • + *
                      + * + * @since 1.2 + */ +package java.awt.geom; diff --git a/jdk/src/java.desktop/share/classes/java/awt/geom/package.html b/jdk/src/java.desktop/share/classes/java/awt/geom/package.html deleted file mode 100644 index de8b62c9a6f..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/geom/package.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - -Provides the Java 2D classes for defining and performing operations -on objects related to two-dimensional geometry. Some important features -of the package include: -
                        -
                      • classes for manipulating geometry, such as AffineTransform and -the PathIterator interface which is implemented by all Shape objects. - -
                      • classes that implement the Shape interface, such as -CubicCurve2D, Ellipse2D, Line2D, Rectangle2D, and GeneralShape. - -
                      • the Area class which provides mechanisms for add (union), subtract, -intersect, and exclusiveOR operations on other Shape objects. -
                      - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/im/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/im/package-info.java new file mode 100644 index 00000000000..bc21b5bad2c --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/im/package-info.java @@ -0,0 +1,42 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes and interfaces for the input method framework. This package + * enables text editing components to receive text input through input methods. + * Input methods are software components that let the user enter text in ways + * other than simple typing on a keyboard. They are commonly used to enter + * Japanese, Chinese, or Korean - languages using thousands of different + * characters - on keyboards with far fewer keys. However, the framework also + * supports input methods for other languages and the use of entirely different + * input mechanisms, such as handwriting or speech recognition. + * + *

                      Related Documentation

                      + * For overviews, tutorials, examples, guides, and tool documentation, please + * see {@extLink imf_overview Input Method Framework Overview}. + * + * @since 1.2 + */ +package java.awt.im; diff --git a/jdk/src/java.desktop/share/classes/java/awt/im/package.html b/jdk/src/java.desktop/share/classes/java/awt/im/package.html deleted file mode 100644 index 552ca18e0a4..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/im/package.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - -

                      Provides classes and interfaces for the input method framework. -This package enables text editing components to receive text input -through input methods. Input methods are software components that let -the user enter text in ways other than simple typing on a keyboard. -They are commonly used to enter Japanese, Chinese, or Korean - -languages using thousands of different characters - on keyboards with -far fewer keys. However, the framework also supports input methods -for other languages and the use of entirely different input -mechanisms, such as handwriting or speech recognition.

                      - -

                      Package Specification

                      - - - -

                      Related Documentation

                      - -

                      For overviews, tutorials, examples, guides, and tool -documentation, please see:

                      - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/im/spi/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/im/spi/package-info.java new file mode 100644 index 00000000000..ca2e5337413 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/im/spi/package-info.java @@ -0,0 +1,87 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides interfaces that enable the development of input methods that can be + * used with any Java runtime environment. Input methods are software components + * that let the user enter text in ways other than simple typing on a keyboard. + * They are commonly used to enter Japanese, Chinese, or Korean - languages + * using thousands of different characters - on keyboards with far fewer keys. + * However, this package also allows the development of input methods for other + * languages and the use of entirely different input mechanisms, such as + * handwriting recognition. + * + *

                      Packaging Input Methods

                      + * Input methods can be made available by adding them to the application's class + * path. The main JAR file of an input method must contain the file: + *
                      + *     META-INF/services/java.awt.im.spi.InputMethodDescriptor
                      + * 
                      + * The file should contain a list of fully-qualified class names, one per line, + * of classes implementing the {@code java.awt.im.spi.InputMethodDescriptor} + * interface. Space and tab characters surrounding each name, as well as blank + * lines, are ignored. The comment character is {@code '#'} + * ({@code \u005Cu0023}); on each line all characters following the first + * comment character are ignored. The file must be encoded in UTF-8. + *

                      + * For example, if the fully-qualified name of the class that implements + * {@code java.awt.im.spi.InputMethodDesciptor} for the Foo input + * method is {@code com.sun.ime.FooInputMethodDescriptor}, the file + * {@code META-INF/services/java.awt.im.spi.InputMethodDescriptor} + * contains a line: + *

                      + *     com.sun.ime.FooInputMethodDescriptor
                      + * 
                      + * The input method must also provide at least two classes: one class + * implementing the {@code java.awt.im.spi.InputMethodDescriptor} interface, one + * class implementing the {@code java.awt.im.spi.InputMethod} interface. The + * input method should separate the implementations for these interfaces, so + * that loading of the class implementing {@code InputMethod} can be deferred + * until actually needed. + * + *

                      Loading Input Methods

                      + * The input method framework will usually defer loading of input method + * classes until they are absolutely needed. It loads only the + * {@code InputMethodDescriptor} implementations during AWT initialization. It + * loads an {@code InputMethod} implementation when the input method has been + * selected. + * + *

                      Java Input Methods and Peered Text + * Components

                      + * The Java input method framework intends to support all combinations of input + * methods (host input methods and Java input methods) and components (peered + * and lightweight). However, because of limitations in the underlying platform, + * it may not always be possible to enable the communication between Java input + * methods and peered AWT components. Support for this specific combination is + * therefore platform dependent. In Sun's Java SE Runtime Environments, this + * combination is supported on Windows, but not on Solaris. + * + *

                      Related Documentation

                      + * For overviews, tutorials, examples, guides, and tool documentation, please + * see {@extLink imf_overview Input Method Framework Overview}. + * + * @since 1.3 + */ +package java.awt.im.spi; diff --git a/jdk/src/java.desktop/share/classes/java/awt/im/spi/package.html b/jdk/src/java.desktop/share/classes/java/awt/im/spi/package.html deleted file mode 100644 index 2e63c9297cd..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/im/spi/package.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - Package java.awt.im.spi Description - - - - - -

                      Provides interfaces that enable the development of input methods -that can be used with any Java runtime environment. Input methods are -software components that let the user enter text in ways other than -simple typing on a keyboard. They are commonly used to enter -Japanese, Chinese, or Korean - languages using thousands of different -characters - on keyboards with far fewer keys. However, this package -also allows the development of input methods for other languages and -the use of entirely different input mechanisms, such as handwriting -recognition.

                      - -

                      Package Specification

                      - - - -

                      Packaging Input Methods

                      - -

                      Input methods can be made available by adding them to the application's -class path. The main JAR file of an input method must contain the -file:

                      - -
                          META-INF/services/java.awt.im.spi.InputMethodDescriptor
                      - -

                      The file should contain a list of fully-qualified class names, one -per line, of classes implementing the -java.awt.im.spi.InputMethodDescriptor interface. Space -and tab characters surrounding each name, as well as blank lines, are -ignored. The comment character is '#' -(\u0023); on each line all characters following the -first comment character are ignored. The file must be encoded in -UTF-8.

                      - -

                      For example, if the fully-qualified name of the class that -implements java.awt.im.spi.InputMethodDesciptor for the -Foo input method is -com.sun.ime.FooInputMethodDescriptor, the file -META-INF/services/java.awt.im.spi.InputMethodDescriptor -contains a line:

                      - -
                          com.sun.ime.FooInputMethodDescriptor
                      - -

                      The input method must also provide at least two classes: one class -implementing the java.awt.im.spi.InputMethodDescriptor -interface, one class implementing the -java.awt.im.spi.InputMethod interface. The input method -should separate the implementations for these interfaces, so that -loading of the class implementing InputMethod can be -deferred until actually needed.

                      - -

                      Loading Input Methods

                      - -

                      The input method framework will usually defer loading of input -method classes until they are absolutely needed. It loads only the -InputMethodDescriptor implementations during AWT -initialization. It loads an InputMethod implementation -when the input method has been selected.

                      - -

                      Java Input Methods and Peered Text -Components

                      - -

                      The Java input method framework intends to support all -combinations of input methods (host input methods and Java input -methods) and components (peered and lightweight). However, because of -limitations in the underlying platform, it may not always be possible -to enable the communication between Java input methods and peered AWT -components. Support for this specific combination is therefore -platform dependent. In Sun's Java SE Runtime Environments, this -combination is supported on Windows, but not on Solaris.

                      - -

                      Related Documentation

                      - -

                      For overviews, tutorials, examples, guides, and tool -documentation, please see:

                      - - - -@since 1.3 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java index 89c43879ac3..aa105ccea75 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java @@ -29,7 +29,8 @@ import java.awt.Image; /** * This class provides default implementations of several {@code Image} methods - * for classes that want to implement the {@MultiResolutionImage} interface. + * for classes that want to implement the {@code MultiResolutionImage} + * interface. * * For example, *
                       {@code
                      diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java b/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java
                      index 9c226320a0b..2be7f7e844f 100644
                      --- a/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java
                      +++ b/jdk/src/java.desktop/share/classes/java/awt/image/ColorModel.java
                      @@ -1,5 +1,5 @@
                       /*
                      - * Copyright (c) 1995, 2013, 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
                      @@ -31,10 +31,10 @@ import java.awt.color.ICC_ColorSpace;
                       import sun.java2d.cmm.CMSManager;
                       import sun.java2d.cmm.ColorTransform;
                       import sun.java2d.cmm.PCMM;
                      -import java.awt.Toolkit;
                       import java.util.Collections;
                       import java.util.Map;
                       import java.util.WeakHashMap;
                      +import java.util.Arrays;
                       
                       /**
                        * The {@code ColorModel} abstract class encapsulates the
                      @@ -362,7 +362,14 @@ public abstract class ColorModel implements Transparency{
                                   this.transparency         = transparency;
                               }
                       
                      -        nBits = bits.clone();
                      +        /*
                      +         * We need significant bits value only for the length
                      +         * of number of components, so we truncate remaining part.
                      +         * It also helps in hashCode calculation since bits[] can contain
                      +         * different values after the length of number of components between
                      +         * two ColorModels.
                      +         */
                      +        nBits = Arrays.copyOf(bits, numComponents);
                               this.pixel_bits = pixel_bits;
                               if (pixel_bits <= 0) {
                                   throw new IllegalArgumentException("Number of pixel bits must "+
                      @@ -1441,69 +1448,53 @@ public abstract class ColorModel implements Transparency{
                           }
                       
                           /**
                      -     * Tests if the specified {@code Object} is an instance of
                      -     * {@code ColorModel} and if it equals this
                      -     * {@code ColorModel}.
                      -     * @param obj the {@code Object} to test for equality
                      -     * @return {@code true} if the specified {@code Object}
                      -     * is an instance of {@code ColorModel} and equals this
                      -     * {@code ColorModel}; {@code false} otherwise.
                      +     * This method simply delegates to the default implementation in {@code Object}
                      +     * which is identical to an {@code ==} test since this class cannot enforce the
                      +     * issues of a proper equality test among multiple independent subclass
                      +     * branches.
                      +     * Subclasses are encouraged to override this method and provide equality
                      +     * testing for their own properties in addition to equality tests for the
                      +     * following common base properties of {@code ColorModel}:
                      +     * 
                        + *
                      • Support for alpha component.
                      • + *
                      • Is alpha premultiplied.
                      • + *
                      • Number of bits per pixel.
                      • + *
                      • Type of transparency like Opaque, Bitmask or Translucent.
                      • + *
                      • Number of components in a pixel.
                      • + *
                      • {@code ColorSpace} type.
                      • + *
                      • Type of the array used to represent pixel values.
                      • + *
                      • Number of significant bits per color and alpha component.
                      • + *
                      + * @param obj the reference object with which to compare. + * @return {@code true} if this object is the same as the obj + * argument; {@code false} otherwise. */ + @Override public boolean equals(Object obj) { - if (!(obj instanceof ColorModel)) { - return false; - } - ColorModel cm = (ColorModel) obj; - - if (this == cm) { - return true; - } - if (supportsAlpha != cm.hasAlpha() || - isAlphaPremultiplied != cm.isAlphaPremultiplied() || - pixel_bits != cm.getPixelSize() || - transparency != cm.getTransparency() || - numComponents != cm.getNumComponents()) - { - return false; - } - - int[] nb = cm.getComponentSize(); - - if ((nBits != null) && (nb != null)) { - for (int i = 0; i < numComponents; i++) { - if (nBits[i] != nb[i]) { - return false; - } - } - } else { - return ((nBits == null) && (nb == null)); - } - - return true; + return super.equals(obj); } /** - * Returns the hash code for this ColorModel. - * - * @return a hash code for this ColorModel. + * This method simply delegates to the default implementation in {@code Object} + * which returns the system ID for the class. + * Subclasses are encouraged to override this method and provide a hash + * for their own properties in addition to hashing the values of the + * following common base properties of {@code ColorModel}: + *
                        + *
                      • Support for alpha component.
                      • + *
                      • Is alpha premultiplied.
                      • + *
                      • Number of bits per pixel.
                      • + *
                      • Type of transparency like Opaque, Bitmask or Translucent.
                      • + *
                      • Number of components in a pixel.
                      • + *
                      • {@code ColorSpace} type.
                      • + *
                      • Type of the array used to represent pixel values.
                      • + *
                      • Number of significant bits per color and alpha component.
                      • + *
                      + * @return a hash code value for this object. */ + @Override public int hashCode() { - - int result = 0; - - result = (supportsAlpha ? 2 : 3) + - (isAlphaPremultiplied ? 4 : 5) + - pixel_bits * 6 + - transparency * 7 + - numComponents * 8; - - if (nBits != null) { - for (int i = 0; i < numComponents; i++) { - result = result + nBits[i] * (i + 9); - } - } - - return result; + return super.hashCode(); } /** @@ -1629,7 +1620,17 @@ public abstract class ColorModel implements Transparency{ * Disposes of system resources associated with this * {@code ColorModel} once this {@code ColorModel} is no * longer referenced. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") public void finalize() { } diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java b/jdk/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java index 60c5b0dfbd2..1e6a4d9c337 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/ComponentColorModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -27,6 +27,7 @@ package java.awt.image; import java.awt.color.ColorSpace; import java.awt.color.ICC_ColorSpace; +import java.util.Arrays; /** * A {@code ColorModel} class that works with pixel values that @@ -200,6 +201,7 @@ public class ComponentColorModel extends ColorModel { private float[] diffMinMax; private float[] compOffset; private float[] compScale; + private volatile int hashCode; /** * Constructs a {@code ComponentColorModel} from the specified @@ -2927,22 +2929,59 @@ public class ComponentColorModel extends ColorModel { } /** - * Compares this color model with another for equality. - * - * @param obj The object to compare with this color model. - * @return {@code true} if the color model objects are equal, - * {@code false} if they are not. + * Tests if the specified {@code Object} is an instance + * of {@code ComponentColorModel} and equals this + * {@code ComponentColorModel}. + * @param obj the {@code Object} to test for equality + * @return {@code true} if the specified {@code Object} + * is an instance of {@code ComponentColorModel} and equals this + * {@code ComponentColorModel}; {@code false} otherwise. */ + @Override public boolean equals(Object obj) { - if (!super.equals(obj)) { + if (!(obj instanceof ComponentColorModel)) { return false; } - if (obj.getClass() != getClass()) { + ComponentColorModel cm = (ComponentColorModel) obj; + if (supportsAlpha != cm.hasAlpha() || + isAlphaPremultiplied != cm.isAlphaPremultiplied() || + pixel_bits != cm.getPixelSize() || + transparency != cm.getTransparency() || + numComponents != cm.getNumComponents() || + (!(colorSpace.equals(cm.colorSpace))) || + transferType != cm.transferType) + { + return false; + } + + if (!(Arrays.equals(nBits, cm.getComponentSize()))) { return false; } return true; } -} + /** + * Returns the hash code for this ComponentColorModel. + * + * @return a hash code for this ComponentColorModel. + */ + @Override + public int hashCode() { + int result = hashCode; + if (result == 0) { + result = 7; + result = 89 * result + this.pixel_bits; + result = 89 * result + Arrays.hashCode(this.nBits); + result = 89 * result + this.transparency; + result = 89 * result + (this.supportsAlpha ? 1 : 0); + result = 89 * result + (this.isAlphaPremultiplied ? 1 : 0); + result = 89 * result + this.numComponents; + result = 89 * result + this.colorSpace.hashCode(); + result = 89 * result + this.transferType; + hashCode = result; + } + return result; + } +} \ No newline at end of file diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferByte.java b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferByte.java index e1c32674858..d6fadd97c31 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferByte.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -42,7 +42,7 @@ import static sun.java2d.StateTrackable.State.*; * Values stored in the byte array(s) of this {@code DataBuffer} are treated as * unsigned values. *

                      - * + * * Note that some implementations may function more efficiently * if they can maintain control over how the data for an image is * stored. diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferDouble.java b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferDouble.java index 4ca5471cd18..cfd78cd8f0e 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferDouble.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, 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 @@ -31,7 +31,7 @@ import static sun.java2d.StateTrackable.State.*; * This class extends {@code DataBuffer} and stores data internally * in {@code double} form. *

                      - * + * * Note that some implementations may function more efficiently * if they can maintain control over how the data for an image is * stored. diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferFloat.java b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferFloat.java index 48e0cf437ff..259f0699780 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferFloat.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, 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 @@ -31,7 +31,7 @@ import static sun.java2d.StateTrackable.State.*; * This class extends {@code DataBuffer} and stores data internally * in {@code float} form. *

                      - * + * * Note that some implementations may function more efficiently * if they can maintain control over how the data for an image is * stored. diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferInt.java b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferInt.java index cdf43cedb2a..58d8e658f17 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferInt.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -41,7 +41,7 @@ import static sun.java2d.StateTrackable.State.*; * This class extends {@code DataBuffer} and stores data internally * as integers. *

                      - * + * * Note that some implementations may function more efficiently * if they can maintain control over how the data for an image is * stored. diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferShort.java b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferShort.java index 1c90a5fd171..90d8148fbb8 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferShort.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -40,7 +40,7 @@ import static sun.java2d.StateTrackable.State.*; /** * This class extends {@code DataBuffer} and stores data internally as shorts. *

                      - * + * * Note that some implementations may function more efficiently * if they can maintain control over how the data for an image is * stored. diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferUShort.java b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferUShort.java index d2009f90a0e..f8ec77a0711 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferUShort.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferUShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -42,7 +42,7 @@ import static sun.java2d.StateTrackable.State.*; * shorts. Values stored in the short array(s) of this {@code DataBuffer} * are treated as unsigned values. *

                      - * + * * Note that some implementations may function more efficiently * if they can maintain control over how the data for an image is * stored. diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java b/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java index bc6e8051f89..2ef638ee0f5 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, 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 @@ -28,6 +28,7 @@ package java.awt.image; import java.awt.Transparency; import java.awt.color.ColorSpace; import java.math.BigInteger; +import java.util.Arrays; /** * The {@code IndexColorModel} class is a {@code ColorModel} @@ -54,7 +55,7 @@ import java.math.BigInteger; * {@code IndexColorModel} objects are never pre-multiplied with * the alpha components. *

                      - * + * * The transparency of an {@code IndexColorModel} object is * determined by examining the alpha components of the colors in the * colormap and choosing the most specific value after considering @@ -85,7 +86,7 @@ import java.math.BigInteger; * and {@code getNumComponents} returns 4. * *

                      - * + * * The values used to index into the colormap are taken from the least * significant n bits of pixel representations where * n is based on the pixel size specified in the constructor. @@ -129,6 +130,7 @@ public class IndexColorModel extends ColorModel { private int transparent_index = -1; private boolean allgrayopaque; private BigInteger validBits; + private volatile int hashCode; private sun.awt.image.BufImgSurfaceData.ICMColorData colorData = null; @@ -1512,7 +1514,17 @@ public class IndexColorModel extends ColorModel { * Disposes of system resources associated with this * {@code ColorModel} once this {@code ColorModel} is no * longer referenced. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") public void finalize() { } @@ -1532,4 +1544,100 @@ public class IndexColorModel extends ColorModel { + " isAlphaPre = "+isAlphaPremultiplied ); } + + /** + * Tests if the specified {@code Object} is an + * instance of {@code IndexColorModel} + * and if it equals this {@code IndexColorModel} + * @param obj the {@code Object} to test for equality + * @return {@code true} if the specified {@code Object} + * equals this {@code IndexColorModel}; {@code false} otherwise. + */ + @Override + public boolean equals(Object obj) { + + if (!(obj instanceof IndexColorModel)) { + return false; + } + + IndexColorModel cm = (IndexColorModel) obj; + if (supportsAlpha != cm.hasAlpha() || + isAlphaPremultiplied != cm.isAlphaPremultiplied() || + pixel_bits != cm.getPixelSize() || + transparency != cm.getTransparency() || + numComponents != cm.getNumComponents() || + (!(colorSpace.equals(cm.colorSpace))) || + transferType != cm.transferType || + map_size != cm.map_size || + transparent_index != cm.transparent_index) + { + return false; + } + + if (!(Arrays.equals(nBits, cm.getComponentSize()))) { + return false; + } + + // verify whether we have to check equality of all bits in validBits + boolean testValidBits; + if (validBits == cm.validBits) { + testValidBits = false; + } else if (validBits == null || cm.validBits == null) { + return false; + } else if (validBits.equals(cm.validBits)) { + testValidBits = false; + } else { + testValidBits = true; + } + + if (testValidBits) { + for (int i = 0; i < map_size; i++) { + if (rgb[i] != cm.rgb[i] || + validBits.testBit(i) != cm.validBits.testBit(i)) + { + return false; + } + } + } else { + for (int i = 0; i < map_size; i++) { + if (rgb[i] != cm.rgb[i]) { + return false; + } + } + } + return true; + } + + /** + * Returns the hash code for IndexColorModel. + * + * @return a hash code for IndexColorModel + */ + @Override + public int hashCode() { + int result = hashCode; + if (result == 0) { + /* + * We are intentionally not calculating hashCode for validBits, + * because it is only used for 8-bit indexed screens and they + * are very rare. It is very unlikely for 2 IndexColorModels + * to have different valiBits and have same value for all + * other properties. + */ + result = 7; + result = 89 * result + this.pixel_bits; + result = 89 * result + Arrays.hashCode(this.nBits); + result = 89 * result + this.transparency; + result = 89 * result + (this.supportsAlpha ? 1 : 0); + result = 89 * result + (this.isAlphaPremultiplied ? 1 : 0); + result = 89 * result + this.numComponents; + result = 89 * result + this.colorSpace.hashCode(); + result = 89 * result + this.transferType; + result = 89 * result + Arrays.hashCode(this.rgb); + result = 89 * result + this.map_size; + result = 89 * result + this.transparent_index; + hashCode = result; + } + return result; + } } diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java b/jdk/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java index 0db6ff17441..bb432f9d513 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -27,6 +27,7 @@ package java.awt.image; import java.awt.Transparency; import java.awt.color.ColorSpace; +import java.util.Arrays; /** * The {@code PackedColorModel} class is an abstract @@ -88,6 +89,7 @@ public abstract class PackedColorModel extends ColorModel { int[] maskArray; int[] maskOffsets; float[] scaleFactors; + private volatile int hashCode; /** * Constructs a {@code PackedColorModel} from a color mask array, @@ -393,25 +395,63 @@ public abstract class PackedColorModel extends ColorModel { * is an instance of {@code PackedColorModel} and equals this * {@code PackedColorModel}; {@code false} otherwise. */ + @Override public boolean equals(Object obj) { if (!(obj instanceof PackedColorModel)) { return false; } - if (!super.equals(obj)) { + PackedColorModel cm = (PackedColorModel) obj; + + if (supportsAlpha != cm.hasAlpha() || + isAlphaPremultiplied != cm.isAlphaPremultiplied() || + pixel_bits != cm.getPixelSize() || + transparency != cm.getTransparency() || + numComponents != cm.getNumComponents() || + (!(colorSpace.equals(cm.colorSpace))) || + transferType != cm.transferType) + { return false; } - PackedColorModel cm = (PackedColorModel) obj; int numC = cm.getNumComponents(); for(int i=0; i < numC; i++) { if (maskArray[i] != cm.getMask(i)) { return false; } } + + if (!(Arrays.equals(nBits, cm.getComponentSize()))) { + return false; + } + return true; } + /** + * Returns the hash code for this PackedColorModel. + * + * @return a hash code for this PackedColorModel. + */ + @Override + public int hashCode() { + int result = hashCode; + if (result == 0) { + result = 7; + result = 89 * result + this.pixel_bits; + result = 89 * result + Arrays.hashCode(this.nBits); + result = 89 * result + this.transparency; + result = 89 * result + (this.supportsAlpha ? 1 : 0); + result = 89 * result + (this.isAlphaPremultiplied ? 1 : 0); + result = 89 * result + this.numComponents; + result = 89 * result + this.colorSpace.hashCode(); + result = 89 * result + this.transferType; + result = 89 * result + Arrays.hashCode(this.maskArray); + hashCode = result; + } + return result; + } + private static final int[] createBitsArray(int[]colorMaskArray, int alphaMask) { int numColors = colorMaskArray.length; @@ -480,4 +520,4 @@ public abstract class PackedColorModel extends ColorModel { return count; } -} +} \ No newline at end of file diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/image/package-info.java new file mode 100644 index 00000000000..d7be6d13963 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/image/package-info.java @@ -0,0 +1,38 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes for creating and modifying images. Images are processed + * using a streaming framework that involves an image producer, optional image + * filters, and an image consumer. This framework makes it possible to + * progressively render an image while it is being fetched and generated. + * Moreover, the framework allows an application to discard the storage used by + * an image and to regenerate it at any time. This package provides a number of + * image producers, consumers, and filters that you can configure for your image + * processing needs. + * + * @since 1.0 + */ +package java.awt.image; diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/package.html b/jdk/src/java.desktop/share/classes/java/awt/image/package.html deleted file mode 100644 index 5ea3b800a63..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/image/package.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - -Provides classes for creating and modifying images. -Images are processed using a streaming framework that involves an -image producer, optional image filters, and an image consumer. This -framework makes it possible to progressively render an image while it -is being fetched and generated. Moreover, the framework allows an -application to discard the storage used by an image and to regenerate -it at any time. This package provides a number of image producers, -consumers, and filters that you can configure for your image -processing needs. - - -@since 1.0 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/package-info.java new file mode 100644 index 00000000000..dc02c0d5c2a --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/package-info.java @@ -0,0 +1,31 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes and interfaces for producing rendering-independent images. + * + * @since 1.2 + */ +package java.awt.image.renderable; diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/package.html b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/package.html deleted file mode 100644 index c75fb1f166b..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/package.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - -Provides classes and interfaces for producing -rendering-independent images. - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/package-info.java new file mode 100644 index 00000000000..682a371dd83 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/package-info.java @@ -0,0 +1,63 @@ +/* + * 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 + * 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. + */ + +/** + * Contains all of the classes for creating user interfaces and for painting + * graphics and images. A user interface object such as a button or a scrollbar + * is called, in AWT terminology, a component. The Component class is the root + * of all AWT components. See Component for a detailed description of properties + * that all AWT components share. + *

                      + * Some components fire events when a user interacts with the components. The + * AWTEvent class and its subclasses are used to represent the events that AWT + * components can fire. See AWTEvent for a description of the AWT event model. + *

                      + * A container is a component that can contain components and other containers. + * A container can also have a layout manager that controls the visual placement + * of components in the container. The AWT package contains several layout + * manager classes and an interface for building your own layout manager. See + * Container and LayoutManager for more information. + *

                      + * Each {@code Component} object is limited in its maximum size and its location + * because the values are stored as an integer. Also, a platform may further + * restrict maximum size and location coordinates. The exact maximum values are + * dependent on the platform. There is no way to change these maximum values, + * either in Java code or in native code. These limitations also impose + * restrictions on component layout. If the bounds of a Component object exceed + * a platform limit, there is no way to properly arrange them within a Container + * object. The object's bounds are defined by any object's coordinate in + * combination with its size on a respective axis. + * + *

                      Additional Specification

                      + * + * + * @since 1.0 + */ +package java.awt; diff --git a/jdk/src/java.desktop/share/classes/java/awt/package.html b/jdk/src/java.desktop/share/classes/java/awt/package.html deleted file mode 100644 index ebab6ec0eb4..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/package.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - -Contains all of the classes for creating user -interfaces and for painting graphics and images. A user interface object such as a button or a -scrollbar is called, in AWT terminology, a component. The Component class is the root of all -AWT components. See Component for a detailed description of properties that all AWT -components share. -

                      -Some components fire events when a user interacts with the components. The AWTEvent -class and its subclasses are used to represent the events that AWT components can fire. See -AWTEvent for a description of the AWT event model. -

                      -A container is a component that can contain components and other containers. A con -tainer can also have a layout manager that controls the visual placement of components in the -container. The AWT package contains several layout manager classes and an interface for -building your own layout manager. See Container and LayoutManager for more information. -

                      -Each {@code Component} object is limited in its maximum size and -its location because the values are stored as an integer. -Also, a platform may further restrict maximum size and location -coordinates. The exact maximum values are dependent on the platform. -There is no way to change these maximum values, either in Java -code or in native code. -These limitations also impose restrictions on component layout. -If the bounds of a Component object exceed a platform limit, -there is no way to properly arrange them within a Container object. -The object's bounds are defined by any object's coordinate -in combination with its size on a respective axis. - - -

                      Additional Specification

                      - - - - -@since 1.0 - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java b/jdk/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java index 9751458cf07..67eda40dd6c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java +++ b/jdk/src/java.desktop/share/classes/java/awt/peer/DesktopPeer.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 @@ -24,18 +24,21 @@ */ package java.awt.peer; -import java.io.File; -import java.io.IOException; -import java.net.URI; import java.awt.Desktop.Action; import java.awt.desktop.AboutHandler; -import java.awt.desktop.SystemEventListener; import java.awt.desktop.OpenFilesHandler; +import java.awt.desktop.OpenURIEvent; import java.awt.desktop.OpenURIHandler; +import java.awt.desktop.PreferencesEvent; import java.awt.desktop.PreferencesHandler; import java.awt.desktop.PrintFilesHandler; import java.awt.desktop.QuitHandler; import java.awt.desktop.QuitStrategy; +import java.awt.desktop.SystemEventListener; +import java.io.File; +import java.io.IOException; +import java.net.URI; + import javax.swing.JMenuBar; /** @@ -162,7 +165,7 @@ public interface DesktopPeer { * the default behavior * * @param preferencesHandler the handler to respond to the - * {@link java.awt.desktop.PreferencesHandler#handlePreferences(java.awt.PreferencesEvent) } + * {@link java.awt.desktop.PreferencesHandler#handlePreferences(PreferencesEvent) } */ default void setPreferencesHandler(final PreferencesHandler preferencesHandler) { } @@ -191,7 +194,7 @@ public interface DesktopPeer { * open a URL. * * Setting the handler to {@code null} causes all - * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be + * {@link OpenURIHandler#openURI(OpenURIEvent)} requests to be * enqueued until another handler is set. * * @param openURIHandler handler diff --git a/jdk/src/java.desktop/share/classes/java/awt/peer/PopupMenuPeer.java b/jdk/src/java.desktop/share/classes/java/awt/peer/PopupMenuPeer.java index 3d3b677a19c..3e42310527d 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/peer/PopupMenuPeer.java +++ b/jdk/src/java.desktop/share/classes/java/awt/peer/PopupMenuPeer.java @@ -46,5 +46,6 @@ public interface PopupMenuPeer extends MenuPeer { * * @see PopupMenu#show(java.awt.Component, int, int) */ + @SuppressWarnings("deprecation") void show(Event e); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/peer/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/peer/package-info.java new file mode 100644 index 00000000000..49b68401db0 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/peer/package-info.java @@ -0,0 +1,31 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides for interfacing with the underlying window system. It is for + * accessing the platform-specific facilities in order to build AWT toolkits. It + * is only used by AWT toolkit developers. + */ +package java.awt.peer; diff --git a/jdk/src/java.desktop/share/classes/java/awt/peer/package.html b/jdk/src/java.desktop/share/classes/java/awt/peer/package.html deleted file mode 100644 index aeb98b2115d..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/peer/package.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -Provides for interfacing with the underlying window system. -It is for accessing the platform-specific facilities in order to -build AWT toolkits. It is only used by AWT toolkit developers. - - -

                      Package Specification

                      - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### - - -

                      Related Documentation

                      - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - diff --git a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java index 0e4d7f96e05..f549388c957 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java +++ b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, 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 @@ -27,12 +27,12 @@ package java.awt.print; import java.awt.AWTError; import java.awt.HeadlessException; -import java.util.Enumeration; import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.PrintServiceLookup; import javax.print.StreamPrintServiceFactory; +import javax.print.attribute.AttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Media; import javax.print.attribute.standard.MediaPrintableArea; @@ -40,8 +40,6 @@ import javax.print.attribute.standard.MediaSize; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.OrientationRequested; -import sun.security.action.GetPropertyAction; - /** * The {@code PrinterJob} class is the principal class that controls * printing. An application calls methods in this class to set up a job, diff --git a/jdk/src/java.desktop/share/classes/java/awt/print/package-info.java b/jdk/src/java.desktop/share/classes/java/awt/print/package-info.java new file mode 100644 index 00000000000..76dfb743339 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/awt/print/package-info.java @@ -0,0 +1,37 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes and interfaces for a general printing API. The API includes + * such features as: + *
                        + *
                      • the ability to specify document types
                      • + *
                      • mechanisms for control of page setup and page formats
                      • + *
                      • the ability to manage job control dialogs
                      • + *
                      + * + * @since 1.2 + */ +package java.awt.print; diff --git a/jdk/src/java.desktop/share/classes/java/awt/print/package.html b/jdk/src/java.desktop/share/classes/java/awt/print/package.html deleted file mode 100644 index 6c708d59c67..00000000000 --- a/jdk/src/java.desktop/share/classes/java/awt/print/package.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - -Provides classes and interfaces for a general printing API. The -API includes such features as: -
                        -
                      • the ability to specify document types -
                      • mechanisms for control of page setup and page formats -
                      • the ability to manage job control dialogs -
                      - - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/beans/ChangeListenerMap.java b/jdk/src/java.desktop/share/classes/java/beans/ChangeListenerMap.java index fa8be4722f3..8f246b00cfb 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/ChangeListenerMap.java +++ b/jdk/src/java.desktop/share/classes/java/beans/ChangeListenerMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 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 @@ -39,8 +39,8 @@ import java.util.Set; * for the {@link PropertyChangeSupport PropertyChangeSupport} class * and the {@link VetoableChangeSupport VetoableChangeSupport} class. * - * @see PropertyChangeListenerMap - * @see VetoableChangeListenerMap + * @see PropertyChangeSupport.PropertyChangeListenerMap + * @see VetoableChangeSupport.VetoableChangeListenerMap * * @author Sergey A. Malenkov */ diff --git a/jdk/src/java.desktop/share/classes/java/beans/beancontext/package-info.java b/jdk/src/java.desktop/share/classes/java/beans/beancontext/package-info.java new file mode 100644 index 00000000000..f1b22cf7da0 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/beans/beancontext/package-info.java @@ -0,0 +1,36 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes and interfaces relating to bean context. A bean context is a + * container for beans and defines the execution environment for the beans it + * contains. There can be several beans in a single bean context, and a bean + * context can be nested within another bean context. This package also + * contains events and listener interface for beans being added and removed from + * a bean context. + * + * @since 1.2 + */ +package java.beans.beancontext; diff --git a/jdk/src/java.desktop/share/classes/java/beans/beancontext/package.html b/jdk/src/java.desktop/share/classes/java/beans/beancontext/package.html deleted file mode 100644 index 739356e24fa..00000000000 --- a/jdk/src/java.desktop/share/classes/java/beans/beancontext/package.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - -Provides classes and interfaces relating to bean context. -A bean context is a container for beans and defines the execution -environment for the beans it contains. There can be several beans in -a single bean context, and a bean context can be nested within another -bean context. This package also contains events and listener -interface for beans being added and removed from a bean context. - - - -@since 1.2 - - diff --git a/jdk/src/java.desktop/share/classes/java/beans/package-info.java b/jdk/src/java.desktop/share/classes/java/beans/package-info.java new file mode 100644 index 00000000000..c841669ac0e --- /dev/null +++ b/jdk/src/java.desktop/share/classes/java/beans/package-info.java @@ -0,0 +1,112 @@ +/* + * 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 + * 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. + */ + +/** + * Contains classes related to developing beans -- components based on + * the JavaBeans™ architecture. A few of the classes are used by beans + * while they run in an application. For example, the event classes are used by + * beans that fire property and vetoable change events (see + * {@link java.beans.PropertyChangeEvent}). However, most of the classes in this + * package are meant to be used by a bean editor (that is, a development + * environment for customizing and putting together beans to create an + * application). In particular, these classes help the bean editor create a user + * interface that the user can use to customize the bean. For example, a bean + * may contain a property of a special type that a bean editor may not know how + * to handle. By using the {@code PropertyEditor} interface, a bean developer + * can provide an editor for this special type. + *

                      + * To minimize the resources used by a bean, the classes used by bean editors + * are loaded only when the bean is being edited. They are not needed while the + * bean is running in an application and therefore not loaded. This information + * is kept in what's called a bean-info (see {@link java.beans.BeanInfo}). + *

                      + * Unless explicitly stated, null values or empty Strings are not valid + * parameters for the methods in this package. You may expect to see exceptions + * if these parameters are used. + * + *

                      Long-Term Persistence

                      + * As of v1.4, the {@code java.beans} package provides support for long-term + * persistence -- reading and writing a bean as a textual representation of + * its property values. The property values are treated as beans, and are + * recursively read or written to capture their publicly available state. This + * approach is suitable for long-term storage because it relies only on public + * API, rather than the likely-to-change private implementation. + * + *

                      Note: The persistence scheme cannot automatically + * instantiate custom inner classes, such as you might use for event handlers. + * By using the {@link java.beans.EventHandler} class instead of inner classes + * for custom event handlers, you can avoid this problem.
                      + *

                      + * You read and write beans in XML format using the + * {@link java.beans.XMLDecoder} and {@link java.beans.XMLEncoder} classes, + * respectively. One notable feature of the persistence scheme is that reading + * in a bean requires no special knowledge of the bean. + *

                      + * Writing out a bean, on the other hand, sometimes requires special knowledge + * of the bean's type. If the bean's state can be expressed using only the + * no-argument constructor and public getter and setter methods for properties, + * no special knowledge is required. Otherwise, the bean requires a custom + * persistence delegate -- an object that is in charge of writing out + * beans of a particular type. All classes provided in the JDK that descend from + * {@code java.awt.Component}, as well as all their properties, automatically + * have persistence delegates. + *

                      + * If you need (or choose) to provide a persistence delegate for a bean, you can + * do so either by using a {@link java.beans.DefaultPersistenceDelegate} + * instance or by creating your own subclass of {@code PersistenceDelegate}. If + * the only reason a bean needs a persistence delegate is because you want to + * invoke the bean's constructor with property values as arguments, you can + * create the bean's persistence delegate with the one-argument + * {@code DefaultPersistenceDelegate} constructor. Otherwise, you need to + * implement your own persistence delegate, for which you're likely to need the + * following classes: + *

                      + *
                      {@link java.beans.PersistenceDelegate}
                      + *
                      The abstract class from which all persistence delegates descend. Your + * subclass should use its knowledge of the bean's type to provide whatever + * {@code Statement}s and {@code Expression}s are necessary to create the + * bean and restore its state.
                      + *
                      {@link java.beans.Statement}
                      + *
                      Represents the invocation of a single method on an object. Includes + * a set of arguments to the method.
                      + *
                      {@link java.beans.Expression}
                      + *
                      A subclass of {@code Statement} used for methods that return a + * value.
                      + *
                      + *

                      + * Once you create a persistence delegate, you register it using the + * {@code setPersistenceDelegate} method of {@code XMLEncoder}. + * + *

                      Related Documentation

                      + * For overview, architecture, and tutorial documentation, please see: + * + */ +package java.beans; diff --git a/jdk/src/java.desktop/share/classes/java/beans/package.html b/jdk/src/java.desktop/share/classes/java/beans/package.html deleted file mode 100644 index 81a9cdafd7b..00000000000 --- a/jdk/src/java.desktop/share/classes/java/beans/package.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - -Contains classes related to developing -beans -- components -based on the JavaBeans™ architecture. -A few of the -classes are used by beans while they run in an application. -For example, the event classes are -used by beans that fire property and vetoable change -events (see -{@link java.beans.PropertyChangeEvent}). However, most of the classes in this -package are meant to be used by a bean editor (that is, a development environment -for customizing and putting together beans to create an application). In -particular, these classes help the bean editor create a user -interface that the user can use to customize the bean. For example, a bean may -contain a property of a special type that a bean editor may not know how to handle. -By using the PropertyEditor interface, a bean developer can -provide an editor for this special type. - -

                      -To minimize the resources used by a bean, the classes used by bean editors are loaded only -when the bean is being edited. They are not needed while the bean is running in an application -and therefore not loaded. This information is kept in what's called a bean-info (see {@link java.beans.BeanInfo}). - -

                      -Unless explicitly stated, null values or empty Strings are not valid -parameters for the methods in this package. You may expect to see -exceptions if these parameters are used. - - -

                      Long-Term Persistence

                      - -As of v1.4, -the java.beans package provides support for -long-term persistence -- reading and -writing a bean as a textual representation of its property values. -The property values are treated as beans, -and are recursively read or written to capture -their publicly available state. -This approach is suitable for long-term storage -because it relies only on public API, -rather than the likely-to-change private implementation. - -
                      -
                      -Note: -The persistence scheme cannot automatically instantiate -custom inner classes, such as you might use for event handlers. -By using the {@link java.beans.EventHandler} class -instead of inner classes for custom event handlers, -you can avoid this problem. -
                      -
                      - -

                      - -You read and write beans in XML format using the -{@link java.beans.XMLDecoder} -and -{@link java.beans.XMLEncoder} -classes, respectively. -One notable feature of the persistence scheme is that -reading in a bean requires no special knowledge of the bean. - -

                      -Writing out a bean, on the other hand, -sometimes requires special knowledge of the bean's type. -If the bean's state can be -expressed using only the no-argument constructor and -public getter and setter methods for properties, -no special knowledge is required. -Otherwise, the bean requires a custom persistence delegate -- -an object that is in charge of writing out beans of a particular type. -All classes provided in the JDK that descend -from java.awt.Component, -as well as all their properties, -automatically have persistence delegates. - -

                      - -If you need (or choose) to provide a persistence delegate for a bean, -you can do so either by using a -{@link java.beans.DefaultPersistenceDelegate} -instance -or by creating your own subclass of PersistenceDelegate. -If the only reason a bean needs a persistence delegate -is because you want to invoke the bean's constructor with -property values as arguments, -you can create the bean's persistence delegate -with the one-argument -DefaultPersistenceDelegate -constructor. -Otherwise, -you need to implement your own persistence delegate, -for which you're likely to need the following classes: - -

                      -
                      {@link java.beans.PersistenceDelegate} -
                      The abstract class from which all persistence delegates descend. - Your subclass should use its knowledge of the bean's type to provide - whatever Statements and Expressions - are necessary to create the bean - and restore its state. -
                      {@link java.beans.Statement} -
                      Represents the invocation of a single method on an object. - Includes a set of arguments to the method. -
                      {@link java.beans.Expression} -
                      A subclass of Statement - used for methods that return a value. -
                      - -

                      -Once you create a persistence delegate, -you register it using the -setPersistenceDelegate method of -XMLEncoder. - - -

                      Related Documentation

                      - -For overview, architecture, and tutorial documentation, please see: - - - - diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java index c3a30f3a5ae..0894847064a 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, 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 @@ -36,8 +36,6 @@ import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeEvent; import java.awt.IllegalComponentStateException; -import javax.swing.SwingContainer; - /** * AccessibleContext represents the minimum information all accessible objects * return. This information includes the accessible name, description, role, @@ -79,7 +77,6 @@ import javax.swing.SwingContainer; * @author Lynn Monsanto */ @JavaBean(description = "Minimal information that all accessible objects return") -@SwingContainer(false) public abstract class AccessibleContext { /** @@ -416,7 +413,7 @@ public abstract class AccessibleContext { * * @see #addPropertyChangeListener * @see #removePropertyChangeListener - * @see #firePropertyChangeListener + * @see #firePropertyChange */ private PropertyChangeSupport accessibleChangeSupport = null; diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/package-info.java b/jdk/src/java.desktop/share/classes/javax/accessibility/package-info.java new file mode 100644 index 00000000000..74b81fe272b --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/package-info.java @@ -0,0 +1,275 @@ +/* + * 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 + * 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. + */ + +/** + * Defines a contract between user-interface components and an assistive + * technology that provides access to those components. If a Java application + * fully supports the Java Accessibility API, then it should be compatible with, + * and friendly toward, assistive technologies such as screen readers, screen + * magnifiers, etc. With a Java application that fully supports the Java + * Accessibility API, no screen reader off screen model would be necessary + * because the API provides all of the information normally contained in an off + * screen model. + *

                      + * The Java Accessibility API package consists of 8 Java programming language + * interfaces, and 6 Java programming language classes. These are described + * below. + * + *

                      Interface + * Accessible

                      + * Interface Accessible is the main interface of + * the Java Accessibility API. All components that support the Java + * Accessibility API must implement this interface. It contains a single method, + * {@code getAccessibleContext}, that returns an instance of the class + * AccessibleContext. Sun thinks that + * implementing this interface is the absolute minimum requirement of every + * object that is part of the user interface of a Java application, if that + * program is to be compatible with assistive technologies. + * + *

                      Class + * AccessibleContext

                      + * AccessibleContext represents the minimum + * information all accessible objects return and is obtained by calling the + * {@code getAccessibleContext} method on an object that implements the + * Accessible interface. This information includes the + * accessible name, description, role, and + * state of the object, as well as information + * about the parent and children of the object.  In addition, + * JavaBeans™ property change support is also included to allow assisitive + * technologies learn when the values of the accessible properties change. + * AccessibleContext also contains methods for obtaining more specific + * accessibility information about a component. If the component supports it, + * these methods will return an object that implements one or more of the + * following interfaces: + *
                        + *
                      • AccessibleAction - the object + * can perform one or more actions. This interface provides the standard + * mechanism for an assistive technology to determine what those actions are + * and tell the object to perform those actions. Any object that can be + * manipulated should return an object that implements this interface when + * the {@code getAccessibleAction} method is called on an AccessibleContext. + *
                      • + *
                      • AccessibleComponent - the + * object has a graphical representation. This interface provides the + * standard mechanism for an assistive technology to determine and set the + * graphical representation of the object. Any object that is rendered on + * the screen should return an object that implements this interface when + * the {@code getAccessibleComponent} method is called on an + * AccessibleContext.
                      • + *
                      • AccessibleSelection - the + * object allows its children to be selected. This interface provides the + * standard mechanism for an assistive technology to determine the currently + * selected children as well as modify the selection set. Any object that + * has children that can be selected should return an object that implements + * this interface when the {@code getAccessibleSelection} method is called + * on an AccessibleContext.
                      • + *
                      • AccessibleText - the object + * presents editable textual information on the display. This interface + * provides the standard mechanism for an assistive technology to access + * that text via its content, attributes, and spatial location. Any object + * that contains editable text should return an object that implements this + * interface when the {@code getAccessibleText} method is called on an + * AccessibleContext.
                      • + *
                      • AccessibleHypertext - the + * object presents hypertext information on the display. This interface + * provides the standard mechanism for an assistive technology to access that + * hypertext via its content, attributes, and spatial location. Any object + * that contains hypertext should return an object that implements this + * interface when the {@code getAccessibleText} method is called on an + * AccessibleContext.
                      • + *
                      • AccessibleValue - the object + * supports a numerical value. This interface provides the standard + * mechanism for an assistive technology to determine and set the current + * value of the object, as well as the minimum and maximum values. Any + * object that supports a numerical value should return an object that + * implements this interface when the {@code getAccessibleValue} method is + * called on an AccessibleContext.
                      • + *
                      + * + *

                      Class + * AccessibleRole

                      + * This class encapsulates the Accessible object's role in the user interface + * and is obtained by calling the {@code getAccessibleRole} method on an + * AccessibleContext. Accessible roles include + * "Check box", "Menu Item", "Panel", etc. These roles are identified by the + * constants in this class such as {@code AccessibleRole.CHECK_BOX, + * AccessibleRole.MENU_ITEM,} and {@code AccessibleRole.PANEL}. The constants in + * this class present a strongly typed enumeration of common object roles. A + * public constructor for this class has been purposely omitted and applications + * should use one of the constants from this class. Although this class + * pre-defines a large list of standard roles, it is extensible so additional + * programmer-defined roles can be added in the future without needing to modify + * the base class. + * + *

                      Class + * AccessibleState

                      + * This class encapsulates a particular state of the Accessible object. + * Accessible states include things like "Armed", "Busy", "Checked", "Focused", + * etc. These roles are identified by the constants in this class such as + * {@code AccessibleState.ARMED, AccessibleState.BUSY, AccessibleState.CHECKED,} + * and {@code AccessibleState.FOCUSED}. The sum of all the states of an + * Accessible object is called the + * AccessibleStateSet, and can be obtained by + * calling the {@code getAccessibleStateSet} method on an + * AccessibleContext. + *

                      + * The constants in this class present a strongly typed enumeration of common + * object roles. A public constructor for this class has been purposely omitted + * and applications should use one of the constants from this class. Although + * this class pre-defines a large list of standard roles, it is extensible so + * additional, programmer-defined roles can be added in the future without + * needing to modify the base class. + * + *

                      Class + * AccessibleStateSet

                      + * This class encapsulates a collection of states of the Accessible object and + * is obtained by calling the {@code getAccessibleStateSet} method on an + * AccessibleContext. Since an object might + * have multiple states (e.g. it might be both "Checked" and "Focused"), this + * class is needed to encapsulate a collection of these states. Methods in the + * class provide for retrieving the individual + * AccessibleStates on the state set. + * + *

                      Class + * AccessibleBundle

                      + * This class is used to maintain a strongly typed enumeration. It is the super + * class of both the AccessibleRole and + * AccessibleState classes. Programmers normally + * do not interact with this class directly, but will instead use the + * AccessibleRole and + * AccessibleState classes. + * + *

                      Interface + * AccessibleAction

                      + * The AccessibleAction interface should be + * supported by any object that can perform one or more actions. This interface + * provides the standard mechanism for an assistive technology to determine what + * those actions are as well as tell the object to perform those actions. Any + * object that can be manipulated should support this interface. + *

                      + * Applications can determine if an object supports the AccessibleAction + * interface by first obtaining its + * AccessibleContext (see + * Accessible) and then calling the + * {@code getAccessibleAction} method of + * AccessibleContext. If the return value is + * not null, the object supports this interface. + * + *

                      + * Interface AccessibleComponent

                      + * The AccessibleComponent interface + * should be supported by any object that is rendered on the screen. This + * interface provides the standard mechanism for an assistive technology to + * determine and set the graphical representation of an object.

                      Applications + * can determine if an object supports the AccessibleComponent interface by + * first obtaining its AccessibleContext (see + * Accessible) and then calling the + * {@code getAccessibleComponent} method of + * AccessibleContext. If the return value is + * not null, the object supports this interface. + * + *

                      + * Interface AccessibleSelection

                      + * The AccessibleSelection interface + * provides the standard mechanism for an assistive technology to determine what + * the current selected children are, as well as modify the selection set. Any + * object that has children that can be selected should support this the + * AccessibleSelection interface. + *

                      + * Applications can determine if an object supports the AccessibleSelection + * interface by first obtaining its + * AccessibleContext (see + * Accessible) and then calling the + * {@code getAccessibleSelection} method of + * AccessibleContext. If the return value is + * not null, the object supports this interface. + * + *

                      Interface + * AccessibleText

                      + * Interface AccessibleText is the contract + * for making rich, editable text Accessible. Not all text displayed on the + * screen is rich and editable (e.g. text contained in buttons, labels, menus, + * etc., which users aren't expected to manipulate). However, objects containing + * editable text must implement interface AccessibleText if they are to + * interoperate with assistive technologies. + *

                      + * This interface provides support for going between pixel coordinates and the + * text at a given pixel coordinate, for retrieving the letter, word, and + * sentence at, before, or after a given position in the text. This interface + * provides support for retrieving the attributes of the character at a given + * position in the text (font, font size, style, etc.), as well as getting the + * selected text (if any), the length of the text, and the location of the text + * caret. + *

                      + * Applications can determine if an object supports the AccessibleText interface + * by first obtaining its AccessibleContext + * (see Accessible) and then calling the + * {@code getAccessibleText} method of + * AccessibleContext. If the return value is + * not null, the object supports this interface. + * + *

                      + * Interface AccessibleHypertext

                      + * The AccessibleHypertext interface + * should be supported by any object that presents hypertext information on the + * display. This interface provides the standard mechanism for an assistive + * technology to access that text via its content, attributes, and spatial + * location. It also provides standard mechanisms for manipulating + * hyperlinks. Applications can determine if + * an object supports the AccessibleHypertext interface by first obtaining its + * AccessibleContext (see + * Accessible) and then calling the + * AccessibleContext.getAccessibleText() method of + * AccessibleContext. If the return value is a + * class which extends AccessibleHypertext, then that object supports + * AccessibleHypertext. + * + *

                      + * Interface AccessibleHyperlink

                      + * An object that is a hyperlink should support the + * AccessibleHyperlink interface.  + * An object that implements this interface will be returned by calling the + * getLink method on an AccessibleHypertext + * object. + * + *

                      Interface + * AccessibleValue

                      + * The AccessibleValue interface should be + * supported by any object that supports a numerical value (e.g., a scroll bar). + * This interface provides the standard mechanism for an assistive technology to + * determine and set the numerical value as well as get the minimum and maximum + * values. + *

                      + * Applications can determine if an object supports the AccessibleValue + * interface by first obtaining its + * AccessibleContext (see + * Accessible) and then calling the + * {@code getAccessibleValue} method of + * AccessibleContext. If the return value is + * not null, the object supports this interface. + * + * @since 1.2 + */ +package javax.accessibility; diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/package.html b/jdk/src/java.desktop/share/classes/javax/accessibility/package.html deleted file mode 100644 index 4d1037aeb8b..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/package.html +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - -Defines a contract between user-interface components and an assistive technology -that provides access to those components. If a Java application fully supports -the Java Accessibility API, then it should be compatible with, and friendly -toward, assistive technologies such as screen readers, screen magnifiers, -etc. With a Java application that fully supports the Java Accessibility -API, no screen reader off screen model would be necessary because the API -provides all of the information normally contained in an off screen model. - -

                      The Java Accessibility API package consists of 8 Java programming language -interfaces, and 6 Java programming language classes. These are described -below. -

                      -Interface Accessible

                      -Interface Accessible is the main interface -of the Java Accessibility API. All components that support the Java Accessibility -API must implement this interface. It contains a single method, getAccessibleContext, -that returns an instance of the class AccessibleContext. -Sun thinks that implementing this interface is the absolute minimum requirement -of every object that is part of the user interface of a Java application, -if that program is to be compatible with assistive technologies. -

                      -Class -AccessibleContext

                      -AccessibleContext represents the minimum -information all accessible objects return and is obtained by calling the -getAccessibleContext method on an object that implements the Accessible -interface. This information includes the accessible name, description, -role, and state -of the object, as well as information about the parent and children of -the object.  In addition, JavaBeans TM -property change support is also included to allow assisitive technologies -learn when the values of the accessible properties change. AccessibleContext -also contains methods for obtaining more specific accessibility information -about a component. If the component supports it, these methods will return -an object that implements one or more of the following interfaces: -
                        -
                      • -AccessibleAction - the object can -perform one or more actions. This interface provides the standard mechanism -for an assistive technology to determine what those actions are and tell -the object to perform those actions. Any object that can be manipulated -should return an object that implements this interface when the getAccessibleAction -method is called on an AccessibleContext.
                      • - -
                      • -AccessibleComponent - the object -has a graphical representation. This interface provides the standard mechanism -for an assistive technology to determine and set the graphical representation -of the object. Any object that is rendered on the screen should return -an object that implements this interface when the getAccessibleComponent -method is called on an AccessibleContext.
                      • - -
                      • -AccessibleSelection - the object -allows its children to be selected. This interface provides the standard -mechanism for an assistive technology to determine the currently selected -children as well as modify the selection set. Any object that has children -that can be selected should return an object that implements this interface -when the getAccessibleSelection method is called on an AccessibleContext.
                      • - -
                      • -AccessibleText - the object presents -editable textual information on the display. This interface provides the -standard mechanism for an assistive technology to access that text via -its content, attributes, and spatial location. Any object that contains -editable text should return an object that implements this interface when -the getAccessibleText method is called on an AccessibleContext.
                      • - -
                      • -AccessibleHypertext - the object -presents hypertext information on the display. This interface provides -the standard mechanism for an assistive technology to access that hypertext -via its content, attributes, and spatial location. Any object that contains -hypertext should return an object that implements this interface when the -getAccessibleText method is called on an AccessibleContext.
                      • - -
                      • -AccessibleValue - the object supports -a numerical value. This interface provides the standard mechanism for an -assistive technology to determine and set the current value of the object, -as well as the minimum and maximum values. Any object that supports a numerical -value should return an object that implements this interface when the getAccessibleValue -method is called on an AccessibleContext.
                      • -
                      - -

                      -Class AccessibleRole

                      -This class encapsulates the Accessible object's role in the user interface -and is obtained by calling the getAccessibleRole method on an -AccessibleContext. Accessible roles include -"Check box", "Menu Item", "Panel", etc. These roles are identified by the -constants in this class such as AccessibleRole.CHECK_BOX, AccessibleRole.MENU_ITEM, -and AccessibleRole.PANEL. The constants in this class present -a strongly typed enumeration of common object roles. A public constructor -for this class has been purposely omitted and applications should use one -of the constants from this class. Although this class pre-defines a large -list of standard roles, it is extensible so additional programmer-defined -roles can be added in the future without needing to modify the base class. - -

                      -Class AccessibleState

                      -This class encapsulates a particular state of the Accessible object. Accessible -states include things like "Armed", "Busy", "Checked", "Focused", etc. -These roles are identified by the constants in this class such as AccessibleState.ARMED, -AccessibleState.BUSY, AccessibleState.CHECKED, and AccessibleState.FOCUSED. -The sum of all the states of an Accessible object is called the AccessibleStateSet, -and can be obtained by calling the getAccessibleStateSet method -on an AccessibleContext. - -

                      The constants in this class present a strongly typed enumeration of -common object roles. A public constructor for this class has been purposely -omitted and applications should use one of the constants from this class. -Although this class pre-defines a large list of standard roles, it is extensible -so additional, programmer-defined roles can be added in the future without -needing to modify the base class. - -

                      -Class -AccessibleStateSet

                      -This class encapsulates a collection of states of the Accessible object -and is obtained by calling the getAccessibleStateSet method on -an AccessibleContext. Since an object -might have multiple states (e.g. it might be both "Checked" and "Focused"), -this class is needed to encapsulate a collection of these states. Methods -in the class provide for retrieving the individual AccessibleStates -on the state set. -

                      -Class AccessibleBundle

                      -This class is used to maintain a strongly typed enumeration. It is the -super class of both the AccessibleRole and -AccessibleState classes. Programmers normally -do not interact with this class directly, but will instead use the AccessibleRole -and AccessibleState classes. - -

                      -Interface -AccessibleAction

                      -The AccessibleAction interface should -be supported by any object that can perform one or more actions. This interface -provides the standard mechanism for an assistive technology to determine -what those actions are as well as tell the object to perform those actions. -Any object that can be manipulated should support this interface. - -

                      Applications can determine if an object supports the AccessibleAction -interface by first obtaining its AccessibleContext -(see Accessible) and then calling the getAccessibleAction -method of AccessibleContext. If the return -value is not null, the object supports this interface. -

                      -Interface -AccessibleComponent

                      -The AccessibleComponent interface -should be supported by any object that is rendered on the screen. This -interface provides the standard mechanism for an assistive technology to -determine and set the graphical representation of an object. - -

                      Applications can determine if an object supports the AccessibleComponent -interface by first obtaining its AccessibleContext -(see Accessible) and then calling the getAccessibleComponent -method of AccessibleContext. If the return -value is not null, the object supports this interface. -

                      -Interface -AccessibleSelection

                      -The AccessibleSelection interface -provides the standard mechanism for an assistive technology to determine -what the current selected children are, as well as modify the selection -set. Any object that has children that can be selected should support this -the AccessibleSelection interface. - -

                      Applications can determine if an object supports the AccessibleSelection -interface by first obtaining its AccessibleContext -(see Accessible) and then calling the getAccessibleSelection -method of AccessibleContext. If the return -value is not null, the object supports this interface. -

                      -Interface AccessibleText

                      -Interface AccessibleText is the contract -for making rich, editable text Accessible. Not all text displayed on the -screen is rich and editable (e.g. text contained in buttons, labels, menus, -etc., which users aren't expected to manipulate). However, objects containing -editable text must implement interface AccessibleText if they are to interoperate -with assistive technologies. - -

                      This interface provides support for going between pixel coordinates -and the text at a given pixel coordinate, for retrieving the letter, word, -and sentence at, before, or after a given position in the text. This interface -provides support for retrieving the attributes of the character at a given -position in the text (font, font size, style, etc.), as well as getting -the selected text (if any), the length of the text, and the location of -the text caret. - -

                      Applications can determine if an object supports the AccessibleText -interface by first obtaining its AccessibleContext -(see Accessible) and then calling the getAccessibleText -method of AccessibleContext. If the return -value is not null, the object supports this interface. -

                      -Interface AccessibleHypertext

                      -The AccessibleHypertext interface -should be supported by any object that presents hypertext information on -the display. This interface provides the standard mechanism for an assistive -technology to access that text via its content, attributes, and spatial -location. It also provides standard mechanisms for manipulating hyperlinks. -Applications can determine if an object supports the AccessibleHypertext -interface by first obtaining its AccessibleContext -(see Accessible) and then calling the AccessibleContext.getAccessibleText() -method of AccessibleContext. If the return -value is a class which extends AccessibleHypertext, then that object supports -AccessibleHypertext. -

                      -Interface -AccessibleHyperlink

                      -An object that is a hyperlink should support the AccessibleHyperlink -interface.  An object that implements this interface will be returned -by calling the getLink method on an AccessibleHypertext -object. -

                      -Interface -AccessibleValue

                      -The AccessibleValue interface should -be supported by any object that supports a numerical value (e.g., a scroll -bar). This interface provides the standard mechanism for an assistive technology -to determine and set the numerical value as well as get the minimum and -maximum values. - -

                      Applications can determine if an object supports the AccessibleValue -interface by first obtaining its AccessibleContext -(see Accessible) and then calling the getAccessibleValue -method of AccessibleContext. If the return -value is not null, the object supports this interface. - -@since 1.2 - - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/event/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/event/package-info.java new file mode 100644 index 00000000000..2c2ebcf7f95 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/event/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * A package of the Java Image I/O API dealing with synchronous notification of + * events during the reading and writing of images. + *

                      + * The {@code IIOReadProgressListener} interface allows for notification of the + * percentage of an image that has been read successfully. + *

                      + * The {@code IIOReadUpdateListener} interface allows for notification of the + * portions of an image that have been read. This is useful, for example, for + * implementing dynamic display of an image as it is loaded. + *

                      + * The {@code IIOReadWarningListener} interface allows for notification of + * non-fatal errors during reading. + *

                      + * The {@code IIOWriteWarningListener} and {@code IIOWriteProgressListener} + * interfaces perform analogous functions for writers. + * + * @since 1.4 + */ +package javax.imageio.event; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/event/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/event/package.html deleted file mode 100644 index 000ab8bde0a..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/event/package.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - -A package of the Java Image I/O API dealing with synchronous -notification of events during the reading and writing of images. - -

                      - -The IIOReadProgressListener interface allows for -notification of the percentage of an image that has been read -successfully. - -

                      - -The IIOReadUpdateListener interface allows for -notification of the portions of an image that have been read. This is -useful, for example, for implementing dynamic display of an image as -it is loaded. - -

                      - -The IIOReadWarningListener interface allows for -notification of non-fatal errors during reading. - -

                      - -The IIOWriteWarningListener and -IIOWriteProgressListener interfaces perform analogous -functions for writers. - -@since 1.4 - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java index c9ac7374a00..08f31278c28 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadata.java @@ -28,7 +28,6 @@ package javax.imageio.metadata; import org.w3c.dom.Node; import java.lang.reflect.Method; -import java.lang.reflect.Module; import java.security.AccessController; import java.security.PrivilegedAction; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/package-info.java new file mode 100644 index 00000000000..e9d75bcf1a5 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/package-info.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * A package of the Java Image I/O API dealing with reading and writing + * metadata. + *

                      + * When reading an image, its per-stream and per-image metadata is made + * available as an {@code IIOMetadata} object. The internals of this object are + * specific to the plug-in that created it. Its contents may be accessed in the + * form of an XML {@code Document}, which is implemented as a tree of + * {@code IIOMetadataNode} objects. + *

                      + * When writing an image, its metadata may be set by defining or modifying an + * {@code IIOMetadata} object. Such an object may be obtained from an + * {@code ImageWriter} or {@code ImageTranscoder} (from the + * {@code javax.imageio} package). Once such an object has been obtained, its + * contents may be set of modified via a {@code Document} consisting of + * {@code IIOMetadataNode}s. The document format may optionally be described + * using an {@code IIOMetadataFormat} object. + *

                      + * The format of the metadata contained in the XML {@code Document} is + * identified by a string which appears as the root node of the tree of + * {@code IIOMetadataNode} objects. This string contains a version number, e.g. + * "javax_imageio_jpeg_image_1.0". Readers and writers may support multiple + * versions of the same basic format and the Image I/O API has methods that + * allow specifying which version to use by passing the string to the + * method/constructor used to obtain an {@code IIOMetadata} object. In some + * cases, a more recent version may not be strictly compatible with a program + * written expecting an older version (for an example, see the Native Metadata + * Format section of the JPEG Metadata Usage Notes below). + *

                      + * Plug-ins may choose to support a + * standard (plug-in neutral) format + * . This format does not provide lossless encoding of metadata, but allows + * a portion of the metadata to be accessed in a generic manner. + *

                      + * Each of the standard plug-ins supports a so-called "native" metadata format, + * which encodes its metadata losslessly: + *

                      + * @since 1.4 + */ +package javax.imageio.metadata; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/package.html deleted file mode 100644 index da369489951..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/package.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - -A package of the Java Image I/O API dealing with reading and writing -metadata. - -

                      - -When reading an image, its per-stream and per-image metadata is made -available as an IIOMetadata object. The internals of -this object are specific to the plug-in that created it. Its contents -may be accessed in the form of an XML Document, which is -implemented as a tree of IIOMetadataNode objects. - -

                      - -When writing an image, its metadata may be set by defining or -modifying an IIOMetadata object. Such an object may be -obtained from an ImageWriter or -ImageTranscoder (from the -javax.imageio package). Once such an object has -been obtained, its contents may be set of modified via a -Document consisting of IIOMetadataNodes. -The document format may optionally be described using an -IIOMetadataFormat object. - -

                      - -The format of the metadata contained in the XML Document -is identified by a string which appears as the root node of the tree -of IIOMetadataNode objects. This string contains a version -number, e.g. "javax_imageio_jpeg_image_1.0". Readers and writers may -support multiple versions of the same basic format and the Image I/O -API has methods that allow specifying which version to use by passing -the string to the method/constructor used to obtain an IIOMetadata -object. In some cases, a more recent version may not be strictly -compatible with a program written expecting an older version (for -an example, see the Native Metadata Format section of the JPEG Metadata -Usage Notes below). - -

                      - -Plug-ins may choose to support a standard (plug-in neutral) -format. This format does not provide lossless encoding of -metadata, but allows a portion of the metadata to be accessed in a -generic manner. - -

                      - -Each of the standard plug-ins supports a so-called "native" metadata -format, which encodes its metadata losslessly: - -

                      - -@since 1.4 - - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/package-info.java new file mode 100644 index 00000000000..342a6afc146 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/package-info.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * The main package of the Java Image I/O API. + *

                      + * Many common image I/O operations may be performed using the static methods of + * the {@code ImageIO} class. + *

                      + * This package contains the basic classes and interfaces for describing the + * contents of image files, including metadata and thumbnails + * ({@code IIOImage}); for controlling the image reading process + * ({@code ImageReader}, {@code ImageReadParam}, and {@code ImageTypeSpecifier}) + * and image writing process ({@code ImageWriter} and {@code ImageWriteParam}); + * for performing transcoding between formats ({@code ImageTranscoder}), and for + * reporting errors ({@code IIOException}). + *

                      + * All implementations of javax.imageio provide the following standard image + * format plug-ins: + *

                      + *
                  KeyValue TypePrincipal ConstantsDefault ValueKeyValue TypePrincipal ConstantsDefault Value
                  {@link #FAMILY}
                  + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
                   ReadingWritingNotesMetadata
                  + * BMPyesyesnoneBMP + * metadata format
                  GIF + * yesyesGIF plug-in notes + * GIF + * metadata format
                  JPEGyesyesnone + * JPEG metadata format
                  PNGyesyesnonePNG + * metadata format
                  + * TIFFyesyes + * TIFF plug-in notes + * TIFF metadata format
                  + * WBMPyesyesnone + * WBMP metadata format
                  + * + *
                  + *
                  + *
                  + * + *

                  Standard Plug-in Notes

                  + * + *

                  Standard plug-in for GIF image format

                  + * ImageIO provides {@code ImageReader} and {@code ImageWriter}plug-ins for the + * Graphics + * Interchange Format (GIF) image format. These are the "standard" GIF + * plug-ins, meaning those that are included in the JRE, as distinct from those + * included in standard extensions, or 3rd party plug-ins. The following notes + * and metadata specification apply to the standard plug-ins. + * + *

                  Writing GIF images

                  + * The GIF image writer plug-in guarantees lossless writing for images which + * meet the following requirements: + *
                    + *
                  • the number of bands is 1;
                  • + *
                  • the number of bits per sample is not greater than 8;
                  • + *
                  • the size of a color component is not greater than 8;
                  • + *
                  + *

                  + * By default the GIF writer plug-in creates version "89a" images. This can be + * changed to "87a" by explicitly setting the version in the stream metadata + * (see + * + * GIF Stream Metadata Format Specification). + * + * + *

                  + * The GIF writer plug-in supports the creation of animated GIF images through + * the standard sequence writing methods defined in the {@code ImageWriter} + * class. + * + * + * + * + *

                  + * A global color table is written to the output stream if one of the following + * conditions is met: + *

                    + *
                  • stream metadata containing a GlobalColorTable element is supplied; + *
                  • + *
                  • a sequence is being written and image metadata containing a + * LocalColorTable element is supplied for the first image in the sequence; + *
                  • + *
                  • image metadata is not supplied or does not contain a LocalColorTable + * element.
                  • + *
                  + *

                  + * In the first case the global color table in the stream metadata is used, in + * the second the local color table in the image metadata is used, and in the + * third a global color table is created from the ColorModel or SampleModel of + * the (first) image. + *

                  + * A local color table is written to the output stream only if image metadata + * containing a LocalColorTable element is supplied to the writer, or no image + * metadata is supplied to the writer and the local color table which would be + * generated from the image itself is not equal to the global color table. + *

                  + * A Graphic Control Extension block is written to the output stream only if + * image metadata containing a GraphicControlExtension element is supplied to + * the writer, or no image metadata is supplied and the local color table + * generated from the image requires a transparent index. Application, Plain + * Text, and Comment Extension blocks are written only if they are supplied to + * the writer via image metadata. + * + * + *

                  + * The writing of interlaced images can be controlled by the progressive mode of + * the provided {@code ImageWriteParam} instance. If progressive mode is + * {@code MODE_DISABLED} then a non-interlaced image will be written. If + * progressive mode is {@code MODE_DEFAULT} then an interlaced image will be + * written. If progressive mode is {@code MODE_COPY_FROM_METADATA}, then the + * metadata setting is used (if it is provided, otherwise an interlaced image + * will be written). + *

                  + * The GIF image writer plug-in supports setting output stream metadata from + * metadata supplied to the writer in either the native GIF stream metadata + * format + * + * javax_imageio_gif_stream_1.0 or the standard metadata format + * javax_imageio_1.0, + * and setting output image metadata from metadata supplied to the writer in + * either the native GIF image metadata format + * + * javax_imageio_gif_image_1.0 or the standard metadata format + * javax_imageio_1.0. + * The mapping of standard metadata format to the GIF native stream and image + * metadata formats is given in the tables + * here. + * + * @since 1.4 + */ +package javax.imageio; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/package.html deleted file mode 100644 index 63d6dcfeb26..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/package.html +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - -The main package of the Java Image I/O API. - -

                  - -Many common image I/O operations may be performed using the static -methods of the ImageIO class. - -

                  - -This package contains the basic classes and interfaces for describing -the contents of image files, including metadata and thumbnails -(IIOImage); for controlling the image reading process -(ImageReader, ImageReadParam, and -ImageTypeSpecifier) and image writing process -(ImageWriter and ImageWriteParam); for -performing transcoding between formats (ImageTranscoder), -and for reporting errors (IIOException). - -

                  -All implementations of javax.imageio provide the following standard -image format plug-ins: -

                  -
                  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                    Reading WritingNotes Metadata
                  BMPyesyesnone - BMP metadata format
                  GIFyesyes - GIF plug-in notes - GIF metadata format
                  JPEGyesyesnone - JPEG metadata format
                  PNGyesyesnone - PNG metadata format
                  TIFFyesyes - TIFF plug-in notes - TIFF metadata format
                  WBMPyesyesnone - WBMP metadata format
                  -
                  -
                  -
                  -
                  - -

                  Standard Plug-in Notes

                  -

                  Standard plug-in for GIF image format

                  - - -

                  -ImageIO provides ImageReader and ImageWriter -plug-ins for the -Graphics Interchange Format (GIF) image format. - -These are the "standard" GIF plug-ins, meaning those that are included in the -JRE, as distinct from those included in standard extensions, or 3rd party -plug-ins. The following notes and metadata specification apply to the -standard plug-ins. - -

                  Writing GIF images

                  - The GIF image writer plug-in guarantees lossless writing for images which meet - the following requirements: -
                    -
                  • the number of bands is 1; -
                  • the number of bits per sample is not greater than 8; -
                  • the size of a color component is not greater than 8; -
                  - -

                  - By default the GIF writer plug-in creates version "89a" images. This can be - changed to "87a" by explicitly setting the version in the - stream metadata (see - GIF Stream Metadata Format Specification). -

                  - - - -

                  - The GIF writer plug-in supports the creation of animated GIF images through - the standard sequence writing methods defined in the - ImageWriter class. - - -

                  - - -

                  - A global color table is written to the output stream if one of the - following conditions is met: -

                    -
                  • stream metadata containing a GlobalColorTable element is - supplied;
                  • -
                  • a sequence is being written and image metadata containing a - LocalColorTable element is supplied for the first image in the - sequence;
                  • -
                  • image metadata is not supplied or does not contain a LocalColorTable - element.
                  • -
                  - -

                  - In the first case the global color table in the stream metadata is - used, in the second the local color table in the image metadata is - used, and in the third a global color table is created from the - ColorModel or SampleModel of the (first) image. -

                  - -

                  - A local color table is written to the output stream only if image - metadata containing a LocalColorTable element is supplied to the - writer, or no image metadata is supplied to the writer and the local - color table which would be generated from the image itself is not - equal to the global color table. -

                  - -

                  - A Graphic Control Extension block is written to the output stream only - if image metadata containing a GraphicControlExtension element is - supplied to the writer, or no image metadata is supplied and the - local color table generated from the image requires a transparent - index. Application, Plain Text, and Comment Extension blocks are - written only if they are supplied to the writer via image metadata. - -

                  - - -

                  - - The writing of interlaced images can be controlled by the progressive - mode of the provided ImageWriteParam instance. - If progressive mode is - MODE_DISABLED then a non-interlaced image will be written. If - progressive mode is MODE_DEFAULT then an interlaced image will - be written. If progressive mode is MODE_COPY_FROM_METADATA, then - the metadata setting is used (if it is provided, otherwise an interlaced - image will be written). -

                  - -

                  - The GIF image writer plug-in supports setting output stream metadata from - metadata supplied to the writer in either the native GIF stream - metadata format - javax_imageio_gif_stream_1.0 or the standard metadata format - - javax_imageio_1.0, and setting - output image metadata from metadata supplied to the writer in either - the native GIF image metadata format - javax_imageio_gif_image_1.0 or the standard metadata format - javax_imageio_1.0. - - The mapping of standard metadata format to the GIF native stream and - image metadata formats is given in the tables here . -

                  - - - - -@since 1.4 - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/bmp/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/bmp/package-info.java new file mode 100644 index 00000000000..d423a14321d --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/bmp/package-info.java @@ -0,0 +1,31 @@ +/* + * 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 + * 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 containing the public classes used by the built-in BMP plug-in. + * + * @since 1.5 + */ +package javax.imageio.plugins.bmp; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/bmp/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/bmp/package.html deleted file mode 100644 index 36467da7f5f..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/bmp/package.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - -Package containing the public classes used by the built-in BMP plug-in. - -@since 1.5 - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/package-info.java new file mode 100644 index 00000000000..cd437729871 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/package-info.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Classes supporting the built-in JPEG plug-in. + *

                  + * This package contains some support classes for the built-in JPEG reader and + * writer plug-ins. Classes are provided for representing quantization and + * Huffman tables, and extensions of {@code ImageReadParam} and + * {@code ImageWriteParam} are provided to supply tables during the reading and + * writing process. For more information about the operation of the built-in + * JPEG plug-ins, see the + * JPEG metadata format + * specification and usage notes. + * + * @since 1.4 + */ +package javax.imageio.plugins.jpeg; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/package.html deleted file mode 100644 index 60d4e8eeaf4..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/jpeg/package.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - -Classes supporting the built-in JPEG plug-in. - -

                  - -This package contains some support classes for the built-in JPEG -reader and writer plug-ins. Classes are provided for representing -quantization and Huffman tables, and extensions of -ImageReadParam and ImageWriteParam are -provided to supply tables during the reading and writing process. For -more information about the operation of the built-in JPEG plug-ins, -see the JPEG -metadata format specification and usage notes. - -
                  -
                  -
                  - - - -@since 1.4 - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java index 7678762203f..8b522da3ed6 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java @@ -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 @@ -63,8 +63,8 @@ import com.sun.imageio.plugins.tiff.TIFFImageMetadata; *

                  A {@code TIFFDirectory} is aware of the tag numbers in the * group of {@link TIFFTagSet}s associated with it. When * a {@code TIFFDirectory} is created from a native image metadata - * object, these tag sets are derived from the tagSets attribute - * of the TIFFIFD node.

                  + * object, these tag sets are derived from the {@code tagSets} attribute + * of the {@code TIFFIFD} node.

                  * *

                  A {@code TIFFDirectory} might also have a parent {@link TIFFTag}. * This will occur if the directory represents an IFD other than the root @@ -73,8 +73,8 @@ import com.sun.imageio.plugins.tiff.TIFFImageMetadata; * {@link TIFFTag#isIFDPointer} method of this parent {@code TIFFTag} * must return {@code true}. When a {@code TIFFDirectory} is * created from a native image metadata object, the parent tag set is set - * from the parentTagName attribute of the corresponding - * TIFFIFD node. Note that a {@code TIFFDirectory} instance + * from the {@code parentTagName} attribute of the corresponding + * {@code TIFFIFD} node. Note that a {@code TIFFDirectory} instance * which has a non-{@code null} parent tag will be contained in the * data field of a {@code TIFFField} instance which has a tag field * equal to the contained directory's parent tag.

                  @@ -133,8 +133,8 @@ public class TIFFDirectory implements Cloneable { * an image metadata object. The supplied object must support an image * metadata format supported by the TIFF {@link javax.imageio.ImageWriter} * plug-in. This will usually be either the TIFF native image metadata - * format javax_imageio_tiff_image_1.0 or the Java - * Image I/O standard metadata format javax_imageio_1.0. + * format {@code javax_imageio_tiff_image_1.0} or the Java + * Image I/O standard metadata format {@code javax_imageio_1.0}. * * @param tiffImageMetadata A metadata object which supports a compatible * image metadata format. diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index 7d4152c3db4..abc041abca0 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -62,7 +62,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * BYTE + * {@code BYTE} * * {@link TIFFTag#TIFF_BYTE} @@ -77,7 +77,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * ASCII + * {@code ASCII} * * {@link TIFFTag#TIFF_ASCII} @@ -92,7 +92,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * SHORT + * {@code SHORT} * * {@link TIFFTag#TIFF_SHORT} @@ -107,7 +107,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * LONG + * {@code LONG} * * {@link TIFFTag#TIFF_LONG} @@ -122,7 +122,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * RATIONAL + * {@code RATIONAL} * * {@link TIFFTag#TIFF_RATIONAL} @@ -137,7 +137,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * SBYTE + * {@code SBYTE} * * {@link TIFFTag#TIFF_SBYTE} @@ -152,7 +152,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * UNDEFINED + * {@code UNDEFINED} * * {@link TIFFTag#TIFF_UNDEFINED} @@ -167,7 +167,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * SSHORT + * {@code SSHORT} * * {@link TIFFTag#TIFF_SSHORT} @@ -182,7 +182,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * SLONG + * {@code SLONG} * * {@link TIFFTag#TIFF_SLONG} @@ -197,7 +197,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * SRATIONAL + * {@code SRATIONAL} * * {@link TIFFTag#TIFF_SRATIONAL} @@ -212,7 +212,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * FLOAT + * {@code FLOAT} * * {@link TIFFTag#TIFF_FLOAT} @@ -227,7 +227,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * DOUBLE + * {@code DOUBLE} * * {@link TIFFTag#TIFF_DOUBLE} @@ -242,7 +242,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD; * *
                  - * IFD + * {@code IFD} * * {@link TIFFTag#TIFF_IFD_POINTER} @@ -941,14 +941,14 @@ public final class TIFFField implements Cloneable { /** * Returns the {@code TIFFField} as a node named either - * "TIFFField" or "TIFFIFD" as described in the + * {@code "TIFFField"} or {@code "TIFFIFD"} as described in the * TIFF native image metadata specification. The node will be named - * "TIFFIFD" if and only if {@link #hasDirectory()} returns + * {@code "TIFFIFD"} if and only if {@link #hasDirectory()} returns * {@code true} and the field's type is either {@link TIFFTag#TIFF_LONG} * or {@link TIFFTag#TIFF_IFD_POINTER}. * - * @return a {@code Node} named "TIFFField" or - * "TIFFIFD". + * @return a {@code Node} named {@code "TIFFField"} or + * {@code "TIFFIFD"}. */ public Node getAsNativeNode() { return new TIFFFieldNode(this); diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package-info.java new file mode 100644 index 00000000000..80defcc7a12 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package-info.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Public classes used by the built-in TIFF plug-ins. + *

                  + * This package contains classes supporting the built-in TIFF reader and writer + * plug-ins. Classes are provided for simplifying interaction with metadata, + * including Exif metadata common in digital photography, and an extension of + * {@link javax.imageio.ImageReadParam} which permits specifying which metadata + * tags are allowed to be read. For more information about the operation of the + * built-in TIFF plug-ins, see the + * TIFF metadata format + * specification and usage notes. + * + * @since 9 + */ +package javax.imageio.plugins.tiff; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html deleted file mode 100644 index 7c70425fd08..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - -Public classes used by the built-in TIFF plug-ins. - -

                  -This package contains classes supporting the built-in TIFF reader and writer -plug-ins. Classes are provided for simplifying interaction with metadata, -including Exif metadata common in digital photography, and an extension of -{@link javax.imageio.ImageReadParam} which permits specifying which metadata -tags are allowed to be read. For more information about the operation of the -built-in TIFF plug-ins, see the -TIFF metadata format -specification and usage notes. - -
                  -
                  -
                  - -@since 9 - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java index e5961b90e4a..dc2f2322100 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java @@ -28,7 +28,6 @@ package javax.imageio.spi; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import java.lang.reflect.Module; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Arrays; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java index 465f155374e..2df6e1ba03b 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.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 @@ -706,7 +706,17 @@ public class ServiceRegistry { * * @exception Throwable if an error occurs during superclass * finalization. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") public void finalize() throws Throwable { deregisterAll(); super.finalize(); @@ -846,6 +856,7 @@ class SubRegistry { poset.clear(); } + @SuppressWarnings("deprecation") public synchronized void finalize() { clear(); } diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/spi/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/spi/package-info.java new file mode 100644 index 00000000000..bdaf57c698f --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/spi/package-info.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * A package of the Java Image I/O API containing the plug-in interfaces for + * readers, writers, transcoders, and streams, and a runtime registry. + *

                  + * The {@code javax.imageio.spi} package contains service provider interfaces + * for reading, writing, and transcoding images, and obtaining image input and + * output streams, as well as a run-time registry that discovers installed + * instances of Image I/O service providers and allows new instances to be + * registered dynamically. + * + * @since 1.4 + */ +package javax.imageio.spi; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/spi/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/spi/package.html deleted file mode 100644 index 404e0a66289..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/spi/package.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - -A package of the Java Image I/O API containing the plug-in interfaces -for readers, writers, transcoders, and streams, and a runtime -registry. - -

                  - - -The javax.imageio.spi package contains service -provider interfaces for reading, writing, and transcoding images, and -obtaining image input and output streams, as well as a run-time registry -that discovers installed instances of Image I/O service providers and allows new -instances to be registered dynamically. - -@since 1.4 - - diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java index f354f7a113a..e5974900161 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, 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 @@ -260,7 +260,17 @@ public class FileCacheImageInputStream extends ImageInputStreamImpl { /** * {@inheritDoc} + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() throws Throwable { // Empty finalizer: for performance reasons we instead use the // Disposer mechanism for ensuring that the underlying diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java index b7129085317..7ecc28767a0 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2007, 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 @@ -155,7 +155,17 @@ public class FileImageInputStream extends ImageInputStreamImpl { /** * {@inheritDoc} + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() throws Throwable { // Empty finalizer: for performance reasons we instead use the // Disposer mechanism for ensuring that the underlying diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java index c76d09f4b71..e75c40396d8 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2007, 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 @@ -163,7 +163,17 @@ public class FileImageOutputStream extends ImageOutputStreamImpl { /** * {@inheritDoc} + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() throws Throwable { // Empty finalizer: for performance reasons we instead use the // Disposer mechanism for ensuring that the underlying diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java index 3d17e278e99..c7cdc47cdaf 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.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 @@ -867,7 +867,17 @@ public abstract class ImageInputStreamImpl implements ImageInputStream { * * @exception Throwable if an error occurs during superclass * finalization. + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() throws Throwable { if (!isClosed) { try { diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java index 87774c1d94f..4fcb0f40b81 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2007, 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 @@ -178,7 +178,17 @@ public class MemoryCacheImageInputStream extends ImageInputStreamImpl { /** * {@inheritDoc} + * + * @deprecated The {@code finalize} method has been deprecated. + * Subclasses that override {@code finalize} in order to perform cleanup + * should be modified to use alternative cleanup mechanisms and + * to remove the overriding {@code finalize} method. + * When overriding the {@code finalize} method, its implementation must explicitly + * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. + * See the specification for {@link Object#finalize()} for further + * information about migration options. */ + @Deprecated(since="9") protected void finalize() throws Throwable { // Empty finalizer: for performance reasons we instead use the // Disposer mechanism for ensuring that the underlying diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/package-info.java b/jdk/src/java.desktop/share/classes/javax/imageio/stream/package-info.java new file mode 100644 index 00000000000..b28caf0ef0d --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/package-info.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * A package of the Java Image I/O API dealing with low-level I/O from files and + * streams. + *

                  + * The {@code ImageInputStream} interface unifies streaming and file-based + * operations. An abstract base class, {@code ImageInputStreamImpl} is provided + * to simplify writing a new {@code ImageInputStream} class. Concrete + * implementation classes ({@code FileImageInputStream}, + * {@code FileCacheImageInputStream}, and {@code MemoryCacheImageInputStream}) + * are provided that allow input to come from a {@code File} or + * {@code InputStream} with or without the use of a temporary cache file. + *

                  + * The {@code ImageOutputStream} interface performs an analogous function for + * output. An abstract base class, {@code ImageOutputStreamImpl} is provided, + * along with concrete implementation classes ({@code FileImageOutputStream}, + * {@code FileCacheImageOutputStream}, and {@code MemoryCacheImageOutputStream}) + * are provided that allow output to go to a {@code File} or + * {@code OutputStream} with or without the use of a temporary cache file. + *

                  + * The {@code IIOByteBuffer} class provides an alternative way to perform reads + * of sequences of bytes that reduces the amount of internal data copying. + * + * @since 1.4 + */ +package javax.imageio.stream; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/stream/package.html b/jdk/src/java.desktop/share/classes/javax/imageio/stream/package.html deleted file mode 100644 index 41f84b8fb61..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/package.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - -A package of the Java Image I/O API dealing with low-level I/O from -files and streams. - -

                  - -The ImageInputStream interface unifies streaming and -file-based operations. An abstract base class, -ImageInputStreamImpl is provided to simplify writing -a new ImageInputStream class. Concrete implementation -classes (FileImageInputStream, -FileCacheImageInputStream, and -MemoryCacheImageInputStream) are provided that allow -input to come from a File or InputStream -with or without the use of a temporary cache file. - -

                  - -The ImageOutputStream interface performs an analogous -function for output. An abstract base class, -ImageOutputStreamImpl is provided, along with -concrete implementation classes (FileImageOutputStream, -FileCacheImageOutputStream, and -MemoryCacheImageOutputStream) are provided that allow -output to go to a File or OutputStream with -or without the use of a temporary cache file. - -

                  - -The IIOByteBuffer class provides an alternative way to -perform reads of sequences of bytes that reduces the amount of -internal data copying. - -@since 1.4 - - diff --git a/jdk/src/java.desktop/share/classes/javax/print/MimeType.java b/jdk/src/java.desktop/share/classes/javax/print/MimeType.java index c9d1f614af0..e96859e9c4c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/MimeType.java +++ b/jdk/src/java.desktop/share/classes/javax/print/MimeType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, 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,6 @@ import java.util.Vector; *

                2. * Since not all Java profiles include the AWT, the Jini Print Service should * not depend on an AWT class. - *

                  *

                3. * The implementation of class java.awt.datatransfer.MimeType does not * guarantee @@ -76,7 +75,6 @@ import java.util.Vector; *
                4. Quoting backslash characters inside parameter values are removed. *
                5. The parameters are arranged in ascending order of parameter name. * - *

                  * * @author Alan Kaminsky */ diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/package-info.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/package-info.java new file mode 100644 index 00000000000..f9c571f56c0 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/package-info.java @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Provides classes and interfaces that describe the types of Java™ Print + * Service attributes and how they can be collected into attribute sets. + * + *

                  What is an Attribute?

                  + * When setting up a print job, a client specifies two things: print data + * and processing instructions. The print data is the actual content to + * be printed. The processing instructions tell the printer how to print the + * print data, such as: what media to use, how many copies to print, and whether + * to print on one or both sides of a sheet. The client specifies these + * processing instructions with the attribute definitions of the Java Print + * Service API. + *

                  + * The print data and the processing instructions are separate entities. This + * means that: + *

                    + *
                  • You can print the same print data at different times using different + * processing instructions.
                    For example, you can print a slide + * presentation on US letter-sized white paper, double-sided, stapled, 20 + * copies to make handouts for a talk; and you could print the same slide + * presentation on US letter-sized transparencies, single-sided, one copy to + * make the actual slides for the talk.
                  • + *
                  • You can use the same processing instructions at different times to + * print different data. For example, you could set your default processing + * instructions to: US letter-sized paper, double sided, stapled. Whenever + * you print a job, it prints with these settings, unless you explicitly + * override them.
                  • + *
                  + *

                  + * The processing instruction does not specify how the print job processes the + * request; each processing instruction is only a description of the results of + * a print job. The print job determines the manner in which it achieves the + * results specified by the processing instructions. Representing processing + * instructions as descriptive items provides more flexibility for implementing + * print jobs. + * + *

                  Attribute Categories and Values

                  + * Each printer has a set of capabilities, such as the ability to print on + * different paper sizes or the ability to print more than one copy. Each of the + * capabilities has a range of values. For example, a printer's orientation + * capability might have this range of values: [landscape, portrait]. For each + * print request, the capability is set to one of these values. The Java Print + * Service API uses the term attribute category to refer to a printer + * capability and the term attribute value to refer to the value of the + * capability. + *

                  + * In the Java Print Service API, an attribute category is represented by a Java + * class implementing the Attribute interface. + * Attribute values are instances of such a class or one of its subclasses. For + * example, to specify the number of copies, an application constructs an + * instance of the Copies class with the + * number of desired copies and uses the {@code Copies} instance as part of the + * print request. In this case, the {@code Copies} class represents the + * attribute category, and the {@code Copies} instance represents the attribute + * value. + * + *

                  Attribute Roles

                  + * When submitting a print job to a printer, the client provides the attributes + * describing the characteristics of the print data, such as the document name, + * and how the print data should be printed, such as double-sided, five copies. + * If a print job consists of multiple pieces of print data, different pieces + * might have different processing instructions, such as 8 x 11 inch media for + * the first document, and 11 x 17 inch media for another document. + *

                  + * Once the printer starts processing the print job, additional information + * about the job becomes available, which might include: the job state (such as + * completed or queued) and the number of pages printed so far. + * These pieces of information are also attributes. Attributes can also describe + * the printer itself, such as: the printer name, the printer location, and the + * number of jobs queued. + *

                  + * The Java Print Service API defines these different kinds of attributes with + * five subinterfaces of {@code Attribute}: + *

                    + *
                  • DocAttribute specifies a + * characteristic of an individual document and the print job settings to be + * applied to an individual document.
                  • + *
                  • PrintRequestAttribute + * specifies a setting applied to a whole print job and to all the documents + * in the print job.
                  • + *
                  • PrintJobAttribute reports the + * status of a print job.
                  • + *
                  • PrintServiceAttribute + * reports the status of a print service.
                  • + *
                  • SupportedValuesAttribute + * gives the supported values for another attribute.
                  • + *
                  + * Each attribute class implements one or more of these tagging subinterfaces to + * indicate where the attribute can be used in the API. If an attribute class + * implements multiple tagging subinterfaces, the attribute can be used in + * multiple contexts. For example, the media attribute can apply to one document + * in a print job as a {@code DocAttribute} or to an entire print job as a + * {@code PrintRequestAttribute}. Certain low-level attributes are never used on + * their own but are always aggregated into higher-level attributes. These + * low-level attribute classes only implement interface + * Attribute, not any of the tagging subinterfaces. + *

                  + * The Java Print Service API defines a group of standard attribute classes + * modeled upon the attributes in the Internet Printing Protocol (IPP) version + * 1.1. The standard attribute classes are in the subpackage + * javax.print.attribute.standard to keep the actual attribute classes + * conceptually separate from the generic apparatus defined in package + * javax.print.attribute. + * + *

                  Attribute Sets

                  + * A client usually needs to provide more than one processing instruction when + * submitting a print job. For example, the client might need to specify a + * media size of A4 and a landscape orientation. To send more than one + * processing instruction, the client collects the attributes into an attribute + * set, which the Java Print Service API represents with the + * AttributeSet interface. + *

                  + * The {@code AttributeSet} interface is similar to the + * Map interface: it provides a map of + * key to values, in which each key is unique and can contain no more than one + * value. However, the {@code AttributeSet} interface is designed to + * specifically support the needs of the Java Print Service API. An {@code + * AttributeSet} requires that: + *

                    + *
                  1. Each key in an {@code AttributeSet} corresponds to a category, and + * the value of the key can only be one of the attribute values that belong + * to the category represented by the key. Thus, unlike a {@code Map}, an + * {@code AttributeSet} restricts the possible values of a key: an attribute + * category cannot be set to an attribute value that does not belong to that + * category.
                  2. + *
                  3. No two attributes from the same category can exist in the same set. + * For example, an attribute collection must not contain both a "one-sided" + * attribute and a "two-sided" attribute because these two attributes give + * the printer conflicting instructions.
                  4. + *
                  5. Only attributes implementing the {@code Attribute} interface can be + * added to the set.
                  6. + *
                  + *

                  + * The javax.print.attribute package includes + * HashAttributeSet as a concrete + * implementation of the attribute set interface. {@code HashAttributeSet} + * provides an attribute set based on a hash map. You can use this + * implementation or provide your own implementation of interface + * {@code AttributeSet}. + *

                  + * The Java Print Service API provides four specializations of an attribute set + * that are restricted to contain just one of the four kinds of attributes, as + * discussed in the Attribute Roles section: + *

                  + * Notice that only four kinds of attribute sets are listed here, but there are + * five kinds of attributes. Interface + * SupportedValuesAttribute + * denotes an attribute that gives the supported values for another attribute. + * Supported-values attributes are never aggregated into attribute sets, so + * there is no attribute set subinterface defined for them. + *

                  + * In some contexts, an attribute set is read-only, which means that the client + * is only allowed to examine an attribute set's contents but not change them. + * In other contexts, the attribute set is read-write, which means that the + * client is allowed both to examine and to change an attribute set's contents. + * For a read-only attribute set, calling a mutating operation throws an + * {@code UnmodifiableSetException}. + *

                  + * Package javax.print.attribute includes one concrete implementation of each of + * the attribute set subinterfaces: + *

                  + * All of these classes extend + * HashAttributeSet and enforce the + * restriction that the attribute set is only allowed to contain the + * corresponding kind of attribute. + * + *

                  Attribute Class Design

                  + * An attribute value is a small, atomic data item, such as an integer or an + * enumerated value. The Java Print Service API does not use primitive data + * types, such as int, to represent attribute values for these reasons: + *
                    + *
                  • Primitive data types are not type-safe. For example, a compiler + * should not allow a "copies" attribute value to be used for a "sides" + * attribute.
                  • + *
                  • Some attributes must be represented as a record of several values. + * One example is printer resolution, which requires two numbers, such as + * 600 and 300 representing 600 x 300 dpi.
                  • + *
                  + * For type-safety and to represent all attributes uniformly, the Java Print + * Service API defines each attribute category as a class, such as class + * {@code Copies}, class Sides, and class + * PrinterResolution. Each + * attribute class wraps one or more primitive data items containing the + * attribute's value. Attribute set operations perform frequent comparisons + * between attribute category objects when adding attributes, finding existing + * attributes in the same category, and looking up an attribute given its + * category. Because an attribute category is represented by a class, fast + * attribute-value comparisons can be performed with the {@code Class.equals} + * method. + *

                  + * Even though the Java Print Service API includes a large number of different + * attribute categories, there are only a few different types of attribute + * values. Most attributes can be represented by a small number of data types, + * such as: integer values, integer ranges, text, or an enumeration of integer + * values. The type of the attribute value that a category accepts is called the + * attribute's abstract syntax. To provide consistency and reduce code + * duplication, the Java Print Service API defines abstract syntax classes to + * represent each abstract syntax, and these classes are used as the parent of + * standard attributes whenever possible. The abstract syntax classes are: + *

                    + *
                  • EnumSyntax provides a type-safe + * enumeration in which enumerated values are represented as singleton + * objects. Each enumeration singleton is an instance of the enumeration + * class that wraps a hidden int value.
                  • + *
                  • IntegerSyntax is the abstract syntax + * for integer-valued attributes.
                  • + *
                  • TextSyntax is the abstract syntax for + * text-valued attributes, and includes a locale giving the text string's + * natural language.
                  • + *
                  • SetOfIntegerSyntax is the + * abstract syntax for attributes representing a range or set of integers + *
                  • ResolutionSyntax is the abstract + * syntax for attributes representing resolution values, such as 600x300 + * dpi.
                  • + *
                  • Size2DSyntax is the abstract syntax + * for attributes representing a two-dimensional size, such as a paper size + * of 8.5 x 11 inches.
                  • + *
                  • DateTimeSyntax is the abstract + * syntax for attributes whose value is a date and time.
                  • + *
                  • URISyntax is the abstract syntax for + * attributes whose value is a Uniform Resource Indicator.
                  • + *
                  + * The abstract syntax classes are independent of the attributes that use them. + * In fact, applications that have nothing to do with printing can use the + * abstract syntax classes. Although most of the standard attribute classes + * extend one of the abstract syntax classes, no attribute class is required to + * extend one of these classes. The abstract syntax classes merely provide a + * convenient implementation that can be shared by many attribute classes. + *

                  + * Each attribute class implements the {@code Attribute} interface, either + * directly or indirectly, to mark it as a printing attribute. An attribute + * class that can appear in restricted attribute sets in certain contexts also + * implements one or more subinterfaces of {@code Attribute}. Most attribute + * classes also extend the appropriate abstract syntax class to get the + * implementation. Consider the {@code Sides} attribute class: + *

                  + *
                  {@code
                  + * public class Sides
                  + *     extends EnumSyntax
                  + *     implements DocAttribute, PrintRequestAttribute, PrintJobAttribute
                  + * {
                  + *     public final Object getCategory()
                  + *     {
                  + *         return Sides.class;
                  + *     }
                  + * ...
                  + * }}
                  + * 
                  + *
                  + *

                  + * Since every attribute class implements {@code Attribute}, every attribute + * class must provide an implementation for the + * {@link javax.print.attribute.Attribute#getCategory() getCategory} method, + * which returns the attribute category. In the case of {@code Sides}, the + * {@code getCategory} method returns {@code Sides.class}. The + * {@code getCategory} method is final to ensure that any vendor-defined + * subclasses of a standard attribute class appear in the same category. Every + * attribute object is immutable once constructed so that attribute object + * references can be passed around freely. To get a different attribute value, + * construct a different attribute object. + * + *

                  Attribute Vendors

                  + * The Java Print Service API is designed so that vendors can: + *
                    + *
                  • define new vendor-specific values for any standard attribute defined + * in javax.print.attribute.standard + * .
                  • + *
                  • define new attribute categories representing the vendor printer's + * proprietary capabilities not already supported by the standard + * attributes.
                  • + *
                  + * To define a new value for an attribute, a client can construct instances of + * such attributes with arbitrary values at runtime. However, an enumerated + * attribute using an abstract syntax class of {@code EnumSyntax} specifies all + * the possible attribute values at compile time as singleton instances of the + * attribute class. This means that new enumerated values cannot be constructed + * at run time. To define new vendor-specific values for a standard enumerated + * attribute, the vendor must define a new attribute class specifying the new + * singleton instances. To ensure that the new attribute values fall in the same + * category as the standard attribute values, the new attribute class must be a + * subclass of the standard attribute class. + *

                  + * To define a new attribute category, a vendor defines a new attribute class. + * This attribute class, like the standard attribute classes, implements + * {@code Attribute} or one of its subinterfaces and extends an abstract syntax + * class. The vendor can either use an existing abstract syntax class or define + * a new one. The new vendor-defined attribute can be used wherever an + * {@code Attribute} is used, such as in an {@code AttributeSet}. + * + *

                  Using Attributes

                  + * A typical printing application uses the {@code PrintRequestAttributeSet} + * because print-request attributes are the types of attributes that client + * usually specifies. This example demonstrates creating an attribute set of + * print-request attributes and locating a printer that can print the document + * according to the specified attributes: + *
                  + *
                  {@code
                  + * FileInputStream psStream;
                  + * try {
                  + *     psstream = new FileInputStream("file.ps");
                  + * } catch (FileNotFoundException ffne) {
                  + * }
                  + * if (psstream == null) {
                  + *     return;
                  + * }
                  + * //Set the document type. See the DocFlavor documentation for
                  + * //more information.
                  + * DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
                  + * Doc myDoc = new SimpleDoc(pstream, psInFormat, null);
                  + * PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                  + * aset.add(new Copies(5));
                  + * aset.add(MediaSize.A4);
                  + * aset.add(Sides.DUPLEX);
                  + * PrintService[] services =
                  + *     PrintServiceLookup.lookupPrintServices(psInFormat, aset);
                  + * if (services.length > 0) {
                  + *     DocPrintJob job = services[0].createPrintJob();
                  + *     try {
                  + *         job.print(myDoc, aset);
                  + *     } catch (PrintException pe) {}
                  + * }
                  + * }
                  + *
                  + *

                  + * Please note: In the javax.print APIs, a null reference parameter to methods + * is incorrect unless explicitly documented on the method as having a + * meaningful interpretation. Usage to the contrary is incorrect coding and may + * result in a run time exception either immediately or at some later time. + * IllegalArgumentException and NullPointerException are examples of typical and + * acceptable run time exceptions for such cases. + * + * @since 1.4 + */ +package javax.print.attribute; diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/package.html b/jdk/src/java.desktop/share/classes/javax/print/attribute/package.html deleted file mode 100644 index aeedb0df2c2..00000000000 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/package.html +++ /dev/null @@ -1,404 +0,0 @@ - - - -javax.print.attribute package - - - -Provides classes and interfaces -that describe the types of JavaTM Print -Service attributes and how they can be collected into attribute sets. -

                  What is an Attribute?

                  -When setting up a print job, -a client specifies two things: -print data and processing instructions. -The print data is the actual content to be printed. -The processing instructions tell the printer how to print the print data, -such as: what media to use, how many copies to print, and -whether to print on one or both sides of a sheet. The client specifies -these processing instructions with the attribute definitions of the Java -Print Service API. -

                  -The print data and the processing instructions -are separate entities. This means that: -

                    -
                  • You can print the same print data -at different times using different processing instructions. -
                    -For example, you can print a slide presentation -on US letter-sized white paper, -double-sided, stapled, 20 copies -to make handouts for a talk; -and you could print the same slide presentation -on US letter-sized transparencies, -single-sided, one copy -to make the actual slides for the talk. -
                  • You can use the same processing instructions -at different times to print different data. -For example, you could set your default processing -instructions to: US letter-sized paper, double sided, stapled. -Whenever you print a job, it prints with these settings, -unless you explicitly override them. -
                  -

                  - -The processing instruction does not specify how the print job -processes the request; each processing instruction is only a description -of the results of a print job. The print job determines the manner in -which it achieves the results specified by the processing instructions. -Representing processing instructions as descriptive items -provides more flexibility for implementing print jobs. -

                  Attribute Categories and Values

                  -Each printer has a set of capabilities, such as the ability to print on -different paper sizes or the ability to print more than one copy. Each of -the capabilities has a range of values. For example, a printer's orientation -capability might have this range of values: [landscape, portrait]. -For each print request, the capability is set to one of these values. The -Java Print Service API uses the term attribute category to refer to -a printer capability and the term attribute value to refer to the value -of the capability. -

                  -In the Java Print Service API, an attribute category is represented by a Java -class implementing the Attribute interface. -Attribute values are instances of such a class or -one of its subclasses. For example, to specify the number of copies, an -application constructs an instance of the -Copies class with the -number of desired copies and uses the Copies instance as part of -the print request. In this case, the Copies class represents the -attribute category, and the Copies instance represents the -attribute value. - -

                  Attribute Roles

                  - -When submitting a print job to a printer, the client provides the -attributes describing the characteristics of the print data, such as -the document name, and how the print data should be printed, such as -double-sided, five copies. If a print job consists of multiple -pieces of print data, different pieces might have different processing -instructions, such as 8 x 11 inch media for the first document, and -11 x 17 inch media for another document. -

                  -Once the printer starts processing the print job, -additional information about the job becomes available, which might include: -the job state (such as completed or queued) and -the number of pages printed so far. These pieces of information are also -attributes. Attributes can also describe the printer itself, such as: -the printer name, the printer location, and the number of jobs queued. -

                  - -The Java Print Service API defines these different kinds of attributes -with five subinterfaces of Attribute: -

                  -Each attribute class -implements one or more of these tagging subinterfaces -to indicate where the attribute can be used in the API. -If an attribute class implements multiple tagging subinterfaces, -the attribute can be used in multiple contexts. For example, the media -attribute can apply to one document in a print job as a DocAttribute -or to an entire print job as a PrintRequestAttribute. -Certain low-level attributes -are never used on their own -but are always aggregated into higher-level attributes. -These low-level attribute classes only -implement interface Attribute, -not any of the tagging subinterfaces. -

                  -The Java Print Service API defines a group of -standard attribute classes modeled upon the attributes in -the Internet Printing Protocol (IPP) version 1.1. The -standard attribute classes are in the subpackage -javax.print.attribute.standard to keep the actual -attribute classes conceptually separate from the generic -apparatus defined in package javax.print.attribute. - -

                  Attribute Sets

                  -A client usually needs to provide more than one processing -instruction when submitting a print job. For example, the client might need to -specify a media size of A4 and a landscape orientation. To send more than one -processing instruction, the client collects the attributes into an -attribute set, which the Java Print Service API represents with the -AttributeSet - interface. -

                  -The AttributeSet interface is similar to the -Map interface: it provides a map of -key to values, in which each key is unique and can contain no more than one -value. However, the AttributeSet interface is designed to -specifically support the needs of the Java Print Service API. An -AttributeSet requires that: -

                    -
                  1. Each key in an AttributeSet corresponds to a category, and -the value of the key can only be one of the attribute values that belong -to the category represented by the key. Thus, unlike a Map, an -AttributeSet restricts the possible values of a key: an -attribute category cannot be set to an attribute value that does not belong to -that category. -
                  2. No two attributes from the same category can exist in the same set. -For example, an attribute collection -must not contain both a "one-sided" attribute and a "two-sided" attribute -because these two attributes give the printer conflicting instructions. -
                  3. Only attributes implementing the Attribute interface can -be added to the set. -
                  - -

                  -The javax.print.attribute package includes -HashAttributeSet -as a concrete implementation of the attribute set interface. -HashAttributeSet provides an attribute set based on a hash map. -You can use this implementation or provide your own implementation -of interface AttributeSet. -

                  -The Java Print Service API provides four specializations of an attribute set -that are restricted to contain just one of the four kinds of attributes, -as discussed in the Attribute Roles section: -

                  -Notice that only four kinds of attribute sets are listed here, but there are -five kinds of attributes. Interface -SupportedValuesAttribute -denotes an attribute that gives the supported values for another attribute. -Supported-values attributes are never aggregated into attribute sets, -so there is no attribute set subinterface defined for them. - -

                  -In some contexts, an attribute set is read-only, which means that the -client is only allowed to examine an attribute set's -contents but not change them. In other contexts, the attribute set is read-write, -which means that the client is allowed both to examine and to change an -attribute set's contents. For a read-only attribute set, calling a mutating -operation throws an UnmodifiableSetException. -

                  -Package javax.print.attribute includes -one concrete implementation of each of the attribute set subinterfaces: -

                  -All of these classes extend HashAttributeSet -and enforce the restriction that the attribute set is only allowed to contain -the corresponding kind of attribute. -

                  Attribute Class Design

                  -An attribute value is a small, atomic data item, -such as an integer or an enumerated value. The Java Print Service API -does not use primitive data types, such as int, to represent attribute -values for these reasons: -
                    -
                  • Primitive data types are not type-safe. For example, a compiler -should not allow a "copies" attribute value to -be used for a "sides" attribute. -
                  • Some attributes must be represented as a record of several -values. One example is printer resolution, which requires two -numbers, such as 600 and 300 representing 600 x 300 dpi. -
                  -For type-safety and to represent all attributes uniformly, the Java -Print Service API defines each attribute category as a class, such as -class Copies, class Sides, and class -PrinterResolution. Each -attribute class wraps one or more primitive data items containing the -attribute's value. Attribute set operations perform frequent -comparisons between attribute category objects when adding attributes, -finding existing attributes in the same category, and looking -up an attribute given its category. Because an attribute category is -represented by a class, fast attribute-value comparisons can be performed -with the Class.equals method. -

                  -Even though the Java Print Service API includes a large number of -different attribute categories, there are only a few different types -of attribute values. Most attributes can be represented by a small -number of data types, such as: integer values, integer ranges, text, -or an enumeration of integer values. The type of the attribute value that -a category accepts is called the attribute's abstract syntax. To -provide consistency and reduce code duplication, the Java Print Service -API defines abstract syntax classes to represent each -abstract syntax, and these classes are used as the parent of standard -attributes whenever possible. The abstract syntax classes are: -

                    -
                  • EnumSyntax -provides a type-safe enumeration in which enumerated -values are represented as singleton objects. Each enumeration -singleton is an instance of the enumeration class that wraps a hidden -int value. -
                  • IntegerSyntax - is the abstract syntax for integer-valued attributes. -
                  • TextSyntax is -the abstract syntax for text-valued attributes, and -includes a locale giving the text string's natural language. -
                  • SetOfIntegerSyntax - is the abstract syntax for attributes -representing a range or set of integers -
                  • ResolutionSyntax - is the abstract syntax for attributes representing - resolution values, such as 600x300 dpi. -
                  • Size2DSyntax - is the abstract syntax for attributes representing a -two-dimensional size, such as a paper size of 8.5 x 11 inches. -
                  • DateTimeSyntax - is the abstract syntax for attributes whose value is a date and time. -
                  • URISyntax is the -abstract syntax for attributes whose value is a Uniform Resource -Indicator. -
                  -The abstract syntax classes are independent of the attributes that -use them. In fact, applications that have nothing to do with -printing can use the abstract syntax classes. Although most of the -standard attribute classes extend one of the abstract syntax classes, -no attribute class is required to extend one of these classes. The -abstract syntax classes merely provide a convenient implementation that -can be shared by many attribute classes. -

                  -Each attribute class implements the Attribute interface, either -directly or indirectly, to mark it as a printing attribute. An -attribute class that can appear in restricted attribute sets in -certain contexts also implements one or more subinterfaces of -Attribute. Most attribute classes also extend the appropriate -abstract syntax class to get the implementation. Consider the -Sides attribute class: -

                  -
                  -public class Sides
                  -  extends EnumSyntax
                  -  implements DocAttribute, PrintRequestAttribute, PrintJobAttribute
                  -  {
                  -  public final Object getCategory()
                  -    {
                  -    return Sides.class;
                  -    }
                  -  ...
                  -  }
                  -
                  -
                  -

                  -Since every attribute class implements Attribute, every attribute -class must provide an implementation for the -{@link javax.print.attribute.Attribute#getCategory() getCategory} method, -which returns the attribute category. In the case of Sides, the -getCategory method returns Sides.class. The -getCategory method is final to ensure that any vendor-defined -subclasses of a standard attribute class appear in the same category. -Every attribute object is immutable once constructed so that attribute object -references can be passed around freely. To get a different attribute -value, construct a different attribute object. - -

                  Attribute Vendors

                  - -The Java Print Service API is designed so that vendors can: -
                    -
                  • define new vendor-specific values for any standard attribute -defined in -javax.print.attribute.standard. -
                  • define new attribute categories representing the vendor printer's -proprietary capabilities not already supported by the standard -attributes. -
                  -To define a new value for an attribute, a client can construct -instances of such attributes with arbitrary values at runtime. -However, an enumerated attribute using an abstract syntax class -of EnumSyntax specifies all the possible attribute values -at compile time as singleton instances of the attribute class. This -means that new enumerated values cannot be constructed at run time. -To define new vendor-specific values for a standard enumerated -attribute, the vendor must define a new attribute class specifying -the new singleton instances. To ensure that the new attribute values -fall in the same category as the standard attribute values, the new -attribute class must be a subclass of the standard attribute class. -

                  -To define a new attribute category, a vendor defines a new attribute -class. This attribute class, like the standard attribute classes, -implements Attribute or one of its subinterfaces and extends an -abstract syntax class. The vendor can either use an existing -abstract syntax class or define a new one. The new vendor-defined -attribute can be used wherever an Attribute is used, such as in an -AttributeSet. - -

                  Using Attributes

                  - -A typical printing application uses the PrintRequestAttributeSet -because print-request attributes are the types of attributes that -client usually specifies. This example demonstrates creating an attribute -set of print-request attributes and locating a printer that can -print the document according to the specified attributes: -
                  -
                  -
                  -FileInputStream psStream;
                  -try {
                  -   psstream = new FileInputStream("file.ps");
                  -} catch (FileNotFoundException ffne) {
                  -}
                  -if (psstream == null) {
                  -    return;
                  -}
                  -//Set the document type.  See the DocFlavor documentation for
                  -//more information.
                  -DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
                  -Doc myDoc = new SimpleDoc(pstream, psInFormat, null);  
                  -PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                  -aset.add(new Copies(5));
                  -aset.add(MediaSize.A4);
                  -aset.add(Sides.DUPLEX);
                  -
                  -PrintService[] services = 
                  -		PrintServiceLookup.lookupPrintServices(psInFormat, aset);
                  -if (services.length > 0) {
                  -   DocPrintJob job = services[0].createPrintJob();
                  -   try {
                  -	job.print(myDoc, aset);
                  -   } catch (PrintException pe) {}
                  -}
                  -
                  -
                  -

                  -Please note: In the javax.print APIs, a null reference parameter to methods -is incorrect unless explicitly documented on the method as having a meaningful -interpretation. Usage to the contrary is incorrect coding and may result -in a run time exception either immediately or at some later time. -IllegalArgumentException and NullPointerException are examples of -typical and acceptable run time exceptions for such cases. - -@since 1.4 - - diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java index 8369f7f4da8..7df44452a4f 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, 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 javax.print.attribute.PrintJobAttribute; * for purposes of finishing. *

                  * Standard Finishings values are: - * + *
                  * *
                  *   @@ -76,7 +76,7 @@ import javax.print.attribute.PrintJobAttribute; *

                  * The following Finishings values are more specific; they indicate a * corner or an edge as if the document were a portrait document: - * + *
                  * *
                  *   diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java index cfe9a34cbf8..05937b5dcaf 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.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 @@ -24,7 +24,9 @@ */ package javax.print.attribute.standard; +import javax.print.DocFlavor; import javax.print.attribute.Attribute; +import javax.print.attribute.AttributeSet; import javax.print.attribute.DocAttribute; import javax.print.attribute.PrintJobAttribute; import javax.print.attribute.PrintRequestAttribute; diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java index 7f06e953572..86a84de83d0 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, 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 @@ -70,7 +70,7 @@ import javax.print.attribute.PrintJobAttribute; * The standard MultipleDocumentHandling values are: *